Hi,
here we go. Here is a first attempt of modularization of aigoals via a call table. (They could possibly be inlined to make it even faster)
Patch attached.
The old functions at this moment also point into the call table, making some kind of "polymorphism" possible.
The thing is:
I think the current AI code is to difficult to understand and clean up without breaking compatibility somewhere. The only solution to this is to split it up.
As the code has no clean interface at all to the outside I see no other solution than to wrap all functions.
The advantage is that you don't have to copy & paste all code if you just want to add some minimal functionality. (provided the polymorphism I suggested is used)
The disadvantage of the polymorphism is that the current code gets a bit slower as also all internal functions are evaluated through two function calls, which might add up ...
Though I think with inlining this disadvantage could be solved. Also the code is not _that_ efficient from the start on and that should not be a problem on modern computers ...
If you agree with this modularization approach, I'll try to finish it next week end.
ai_profiles imho does not need to be modularized, which leaves aiturret, aibig and aicode to be modularized.
Btw. if you are curious:
- Doxygen now takes 340 MB and a very long time to generate (I needed this for easy overview of which function calls which)
- These functions are defined for extern, but those signed with "-" are never called from external.
-ai_add_dock_name
-ai_add_goal_ship_internal
-ai_add_goal_sub_sexp
-ai_add_goal_wing_internal
ai_add_ship_goal_player
ai_add_ship_goal_sexp
ai_add_wing_goal_player
ai_add_wing_goal_sexp
ai_clear_ship_goals
ai_clear_wing_goals
ai_copy_mission_wing_goal
ai_get_subsystem_type
-ai_get_subsystem_type_name
Ai_goal_text
ai_maybe_add_form_goal
ai_mission_goal_complete
-ai_mission_wing_goal_complete
ai_post_process_mission
-ai_process_mission_orders
ai_query_goal_valid
ai_remove_ship_goal
-ai_update_goal_references
-query_referenced_in_ai_goals
- Modularization is heavily scriptable (I love linux

) and such quite efficient work.
cu
Fabian
[attachment deleted by admin]