Author: sveinung Date: Tue Mar 14 10:39:03 2017 New Revision: 35107 URL: http://svn.gna.org/viewcvs/freeciv?rev=35107&view=rev Log: Prepare action counting for generic actions.
Make it possible to distinguish the number of actions in the current ruleset from the maximum number of actions. This will be needed when actions becomes generic. Introduce the distinction in action auto performers. Introduce the distinction in action_iterate. Other areas should be clarified in follow up patches. See hrm Feature #644446 Modified: trunk/common/actions.c trunk/common/actions.h trunk/common/networking/packets.def trunk/server/ruleset.c trunk/tools/ruleutil/rulesave.c Modified: trunk/common/actions.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=35107&r1=35106&r2=35107&view=diff ============================================================================== --- trunk/common/actions.c (original) +++ trunk/common/actions.c Tue Mar 14 10:39:03 2017 @@ -512,7 +512,7 @@ /* The criteria to pick *this* auto performer for its cause. */ requirement_vector_init(&auto_perfs[i].reqs); - for (j = 0; j < ACTION_COUNT; j++) { + for (j = 0; j < MAX_NUM_ACTIONS; j++) { /* Nothing here. Nothing after this point. */ auto_perfs[i].alternatives[j] = ACTION_NONE; } Modified: trunk/common/actions.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=35107&r1=35106&r2=35107&view=diff ============================================================================== --- trunk/common/actions.h (original) +++ trunk/common/actions.h Tue Mar 14 10:39:03 2017 @@ -123,6 +123,10 @@ /* Used to signal the absence of any actions. */ #define ACTION_NONE ACTION_COUNT +/* Used in the network protocol. */ +#define MAX_NUM_ACTIONS ACTION_COUNT +#define NUM_ACTIONS MAX_NUM_ACTIONS + /* Who ordered the action to be performed? */ #define SPECENUM_NAME action_requester /* The player ordered it directly. */ @@ -212,10 +216,10 @@ TYPED_LIST_ITERATE(struct action_enabler, action_enabler_list, aenabler) #define action_enabler_list_iterate_end LIST_ITERATE_END -#define action_iterate(_act_) \ -{ \ - int _act_; \ - for (_act_ = 0; _act_ < ACTION_COUNT; _act_++) { +#define action_iterate(_act_) \ +{ \ + int _act_; \ + for (_act_ = 0; _act_ < NUM_ACTIONS; _act_++) { #define action_iterate_end \ } \ @@ -266,7 +270,7 @@ /* Auto perform the first legal action in this list. * The list is terminated by ACTION_NONE. */ - enum gen_action alternatives[ACTION_COUNT]; + enum gen_action alternatives[MAX_NUM_ACTIONS]; }; #define action_auto_perf_iterate(_act_perf_) \ @@ -298,7 +302,7 @@ { \ int _perf_pos_; \ \ - for (_perf_pos_ = 0; _perf_pos_ < ACTION_COUNT; _perf_pos_++) { \ + for (_perf_pos_ = 0; _perf_pos_ < NUM_ACTIONS; _perf_pos_++) { \ const int _act_id_ = _autoperf_->alternatives[_perf_pos_]; \ \ if (_act_id_ == ACTION_NONE) { \ Modified: trunk/common/networking/packets.def URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/networking/packets.def?rev=35107&r1=35106&r2=35107&view=diff ============================================================================== --- trunk/common/networking/packets.def (original) +++ trunk/common/networking/packets.def Tue Mar 14 10:39:03 2017 @@ -1758,7 +1758,7 @@ REQUIREMENT reqs[MAX_NUM_REQS:reqs_count]; UINT8 alternatives_count; - GEN_ACTION alternatives[ACTION_COUNT:alternatives_count]; + GEN_ACTION alternatives[MAX_NUM_ACTIONS:alternatives_count]; end PACKET_RULESET_MUSIC = 240; sc, lsend Modified: trunk/server/ruleset.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=35107&r1=35106&r2=35107&view=diff ============================================================================== --- trunk/server/ruleset.c (original) +++ trunk/server/ruleset.c Tue Mar 14 10:39:03 2017 @@ -7495,7 +7495,7 @@ for (counter = 0; /* Can't list more actions than all actions. */ - counter < ACTION_COUNT + counter < NUM_ACTIONS /* ACTION_NONE terminates the list. */ && aperf->alternatives[counter] != ACTION_NONE; counter++) { Modified: trunk/tools/ruleutil/rulesave.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruleutil/rulesave.c?rev=35107&r1=35106&r2=35107&view=diff ============================================================================== --- trunk/tools/ruleutil/rulesave.c (original) +++ trunk/tools/ruleutil/rulesave.c Tue Mar 14 10:39:03 2017 @@ -563,7 +563,7 @@ const int aap, const char *actions_path) { - enum gen_action unit_acts[ACTION_COUNT]; + enum gen_action unit_acts[MAX_NUM_ACTIONS]; size_t i; size_t ret; @@ -572,7 +572,7 @@ i = 0; for (i = 0; - i < ACTION_COUNT && auto_perf->alternatives[i] != ACTION_NONE; + i < NUM_ACTIONS && auto_perf->alternatives[i] != ACTION_NONE; i++) { unit_acts[i] = auto_perf->alternatives[i]; } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits