[Freeciv-Dev] (PR#40444) Simultaneous Phases in 2.1.x
http://bugs.freeciv.org/Ticket/Display.html?id=40444 > Version 4 committed to S2_2 (r15191) and trunk (r15192). -- ご無事ですか? ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40444) Simultaneous Phases in 2.1.x
http://bugs.freeciv.org/Ticket/Display.html?id=40444 > > [EMAIL PROTECTED] - Thu Aug 28 01:31:34 2008]: > > 2008/8/28 Madeline Book: > > Version 3 remains compatible with pre 2.2 savegames by > > checking for the presence of the old settings in the > > secfile. > > It's generally not a good idea to rely on version number for checking > savegame options. It should be possible to use values really present > in savegame in the lines of: > > old = look_bool_default(TRUE...) > if (old) > new_default = 1 > else > new_default = 1 > final = look_int_default(new_default...) > > Failing that, you should use savegame options. > > In any case your check against 020200 means that current S2_2 > development version 2.1.99 is not reading new values. Version 4 fixes this inaccuracy and improves comments. -- それはどうも client/packhand.c |6 +- client/text.c |9 - common/game.c | 26 -- common/game.h | 16 +--- common/packets.def |2 +- server/savegame.c | 43 +-- server/settings.c | 38 +++--- server/srv_main.c | 21 + 8 files changed, 132 insertions(+), 29 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 60c980b..cfc1339 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -1011,7 +1011,11 @@ void handle_end_phase(void) void handle_start_phase(int phase) { - if (phase < 0 || phase >= player_count()) { + if (phase < 0 + || (game.info.phase_mode == PMT_PLAYERS_ALTERNATE + && phase >= player_count()) + || (game.info.phase_mode == PMT_TEAMS_ALTERNATE + && phase >= team_count())) { freelog(LOG_ERROR, "handle_start_phase() illegal phase %d.", phase); diff --git a/client/text.c b/client/text.c index 1137b75..23daf69 100644 --- a/client/text.c +++ b/client/text.c @@ -616,13 +616,20 @@ const char *get_info_label_text(void) client.conn.playing->economic.luxury, client.conn.playing->economic.science); } - if (!game.info.simultaneous_phases) { + if (game.info.phase_mode == PMT_PLAYERS_ALTERNATE) { if (game.info.phase < 0 || game.info.phase >= game.info.nplayers) { astr_add_line(&str, _("Moving: Nobody")); } else { astr_add_line(&str, _("Moving: %s"), player_name(player_by_number(game.info.phase))); } + } else if (game.info.phase_mode == PMT_TEAMS_ALTERNATE) { +if (game.info.phase < 0 || game.info.phase >= team_count()) { + astr_add_line(&str, _("Moving: Nobody")); +} else { + astr_add_line(&str, _("Moving: %s"), +team_name_translation(team_by_number(game.info.phase))); +} } astr_add_line(&str, _("(Click for more info)")); return str.str; diff --git a/common/game.c b/common/game.c index fcd4868..bf0508f 100644 --- a/common/game.c +++ b/common/game.c @@ -319,7 +319,7 @@ void game_init(void) sz_strlcpy(game.info.start_units, GAME_DEFAULT_START_UNITS); game.fogofwar_old = game.info.fogofwar; - game.simultaneous_phases_stored = GAME_DEFAULT_SIMULTANEOUS_PHASES; + game.phase_mode_stored = GAME_DEFAULT_PHASE_MODE; game.timeoutint= GAME_DEFAULT_TIMEOUTINT; game.timeoutintinc = GAME_DEFAULT_TIMEOUTINTINC; game.timeoutinc= GAME_DEFAULT_TIMEOUTINC; @@ -615,10 +615,32 @@ void game_renumber_players(int plrno) /** Return TRUE if it is this player's phase. + NB: The meaning of the 'phase' argument must match its use in the + function begin_turn() in server/srv_main.c. + NB: The phase mode PMT_TEAMS_ALTERNATE assumes that every player is + on a team, i.e. that pplayer->team is never NULL. **/ bool is_player_phase(const struct player *pplayer, int phase) { - return game.info.simultaneous_phases || player_number(pplayer) == phase; + switch (game.info.phase_mode) { + case PMT_CONCURRENT: +return TRUE; +break; + case PMT_PLAYERS_ALTERNATE: +return player_number(pplayer) == phase; +break; + case PMT_TEAMS_ALTERNATE: +assert(pplayer->team != NULL); +return team_number(pplayer->team) == phase; +break; + default: +break; + } + + freelog(LOG_FATAL, "Unrecognized phase mode %d in is_player_phase().", + phase); + assert(FALSE); + return TRUE; } / diff --git a/common/game.h b/common/game.h index c397fa0..ba18102 100644 --- a/common/game.h +++ b/common/game.h @@ -32,6 +32,14 @@ enum debug_globals { DEBUG_LAST }; +/* NB: Must match phasemode setting + * help text in server/settings.c */ +enum phase_mode_types { + PMT_CONCURRENT = 0, + PMT_PLAYERS_ALTERNATE = 1, + PMT_TEAMS_A
Re: [Freeciv-Dev] (PR#40444) Simultaneous Phases in 2.1.x
http://bugs.freeciv.org/Ticket/Display.html?id=40444 > 2008/8/28 Madeline Book: > Version 3 remains compatible with pre 2.2 savegames by > checking for the presence of the old settings in the > secfile. It's generally not a good idea to rely on version number for checking savegame options. It should be possible to use values really present in savegame in the lines of: old = look_bool_default(TRUE...) if (old) new_default = 1 else new_default = 1 final = look_int_default(new_default...) Failing that, you should use savegame options. In any case your check against 020200 means that current S2_2 development version 2.1.99 is not reading new values. - ML ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40444) Simultaneous Phases in 2.1.x
http://bugs.freeciv.org/Ticket/Display.html?id=40444 > > [book - Mon Aug 25 03:02:37 2008]: > > > [book - Tue Aug 19 23:18:49 2008]: > > > > Attached patch extends the simultaneousphases setting to > > allow team-alternating movement phases. > > Version 2 renames "simultaneous phases" to "phase mode", > since it now has 3 possible values and is no longer a > boolean setting (it's also easier to code and type ;)). Version 3 remains compatible with pre 2.2 savegames by checking for the presence of the old settings in the secfile. -- きっとあなたは祭り寿司が欲しいね。 client/packhand.c |6 +- client/text.c |9 - common/game.c | 23 +-- common/game.h | 16 +--- common/packets.def |2 +- server/savegame.c | 35 +-- server/settings.c | 37 ++--- server/srv_main.c | 17 + 8 files changed, 116 insertions(+), 29 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index c46be30..631164b 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -1011,7 +1011,11 @@ void handle_end_phase(void) void handle_start_phase(int phase) { - if (phase < 0 || phase >= player_count()) { + if (phase < 0 + || (game.info.phase_mode == PMT_PLAYERS_ALTERNATE + && phase >= player_count()) + || (game.info.phase_mode == PMT_TEAMS_ALTERNATE + && phase >= team_count())) { freelog(LOG_ERROR, "handle_start_phase() illegal phase %d.", phase); diff --git a/client/text.c b/client/text.c index 1137b75..23daf69 100644 --- a/client/text.c +++ b/client/text.c @@ -616,13 +616,20 @@ const char *get_info_label_text(void) client.conn.playing->economic.luxury, client.conn.playing->economic.science); } - if (!game.info.simultaneous_phases) { + if (game.info.phase_mode == PMT_PLAYERS_ALTERNATE) { if (game.info.phase < 0 || game.info.phase >= game.info.nplayers) { astr_add_line(&str, _("Moving: Nobody")); } else { astr_add_line(&str, _("Moving: %s"), player_name(player_by_number(game.info.phase))); } + } else if (game.info.phase_mode == PMT_TEAMS_ALTERNATE) { +if (game.info.phase < 0 || game.info.phase >= team_count()) { + astr_add_line(&str, _("Moving: Nobody")); +} else { + astr_add_line(&str, _("Moving: %s"), +team_name_translation(team_by_number(game.info.phase))); +} } astr_add_line(&str, _("(Click for more info)")); return str.str; diff --git a/common/game.c b/common/game.c index fcd4868..789ac01 100644 --- a/common/game.c +++ b/common/game.c @@ -319,7 +319,7 @@ void game_init(void) sz_strlcpy(game.info.start_units, GAME_DEFAULT_START_UNITS); game.fogofwar_old = game.info.fogofwar; - game.simultaneous_phases_stored = GAME_DEFAULT_SIMULTANEOUS_PHASES; + game.phase_mode_stored = GAME_DEFAULT_PHASE_MODE; game.timeoutint= GAME_DEFAULT_TIMEOUTINT; game.timeoutintinc = GAME_DEFAULT_TIMEOUTINTINC; game.timeoutinc= GAME_DEFAULT_TIMEOUTINC; @@ -615,10 +615,29 @@ void game_renumber_players(int plrno) /** Return TRUE if it is this player's phase. + NB: Meaning of 'phase' argument must match its use in begin_turn(). + NB: phase mode PMT_TEAMS_ALTERNATE assumes that every player is on a + team. **/ bool is_player_phase(const struct player *pplayer, int phase) { - return game.info.simultaneous_phases || player_number(pplayer) == phase; + switch (game.info.phase_mode) { + case PMT_CONCURRENT: +return TRUE; +break; + case PMT_PLAYERS_ALTERNATE: +return player_number(pplayer) == phase; +break; + case PMT_TEAMS_ALTERNATE: +assert(pplayer->team != NULL); +return team_number(pplayer->team) == phase; +break; + default: +break; + } + + assert(FALSE); + return TRUE; } / diff --git a/common/game.h b/common/game.h index c397fa0..ba18102 100644 --- a/common/game.h +++ b/common/game.h @@ -32,6 +32,14 @@ enum debug_globals { DEBUG_LAST }; +/* NB: Must match phasemode setting + * help text in server/settings.c */ +enum phase_mode_types { + PMT_CONCURRENT = 0, + PMT_PLAYERS_ALTERNATE = 1, + PMT_TEAMS_ALTERNATE = 2 +}; + #define CONTAMINATION_POLLUTION 1 #define CONTAMINATION_FALLOUT 2 @@ -55,10 +63,10 @@ struct civ_game { time_t last_ping; struct timer *phase_timer; /* Time since seconds_to_phase_done was set. */ - /* The .info.simultaneous_phases value indicates the phase mode currently in + /* The .info.phase_mode value indicates the phase mode currently in * use. The "stored" value is a value the player can change; it won't * take eff
[Freeciv-Dev] (PR#40444) Simultaneous Phases in 2.1.x
http://bugs.freeciv.org/Ticket/Display.html?id=40444 > > [book - Tue Aug 19 23:18:49 2008]: > > Attached patch extends the simultaneousphases setting to > allow team-alternating movement phases. Version 2 renames "simultaneous phases" to "phase mode", since it now has 3 possible values and is no longer a boolean setting (it's also easier to code and type ;)). --- 果物の侵略んだ。 client/packhand.c |6 +- client/text.c |9 - common/game.c | 21 +++-- common/game.h | 16 +--- common/packets.def |2 +- server/savegame.c | 20 ++-- server/settings.c | 37 ++--- server/srv_main.c | 17 + 8 files changed, 99 insertions(+), 29 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index f0af5a9..9bbfdf2 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -1011,7 +1011,11 @@ void handle_end_phase(void) void handle_start_phase(int phase) { - if (phase < 0 || phase >= player_count()) { + if (phase < 0 + || (game.info.phase_mode == PMT_PLAYERS_ALTERNATE + && phase >= player_count()) + || (game.info.phase_mode == PMT_TEAMS_ALTERNATE + && phase >= team_count())) { freelog(LOG_ERROR, "handle_start_phase() illegal phase %d.", phase); diff --git a/client/text.c b/client/text.c index 1137b75..23daf69 100644 --- a/client/text.c +++ b/client/text.c @@ -616,13 +616,20 @@ const char *get_info_label_text(void) client.conn.playing->economic.luxury, client.conn.playing->economic.science); } - if (!game.info.simultaneous_phases) { + if (game.info.phase_mode == PMT_PLAYERS_ALTERNATE) { if (game.info.phase < 0 || game.info.phase >= game.info.nplayers) { astr_add_line(&str, _("Moving: Nobody")); } else { astr_add_line(&str, _("Moving: %s"), player_name(player_by_number(game.info.phase))); } + } else if (game.info.phase_mode == PMT_TEAMS_ALTERNATE) { +if (game.info.phase < 0 || game.info.phase >= team_count()) { + astr_add_line(&str, _("Moving: Nobody")); +} else { + astr_add_line(&str, _("Moving: %s"), +team_name_translation(team_by_number(game.info.phase))); +} } astr_add_line(&str, _("(Click for more info)")); return str.str; diff --git a/common/game.c b/common/game.c index fcd4868..bc59138 100644 --- a/common/game.c +++ b/common/game.c @@ -319,7 +319,7 @@ void game_init(void) sz_strlcpy(game.info.start_units, GAME_DEFAULT_START_UNITS); game.fogofwar_old = game.info.fogofwar; - game.simultaneous_phases_stored = GAME_DEFAULT_SIMULTANEOUS_PHASES; + game.phase_mode_stored = GAME_DEFAULT_PHASE_MODE; game.timeoutint= GAME_DEFAULT_TIMEOUTINT; game.timeoutintinc = GAME_DEFAULT_TIMEOUTINTINC; game.timeoutinc= GAME_DEFAULT_TIMEOUTINC; @@ -615,10 +615,27 @@ void game_renumber_players(int plrno) /** Return TRUE if it is this player's phase. + NB: Meaning of 'phase' argument must match its use in begin_turn(). **/ bool is_player_phase(const struct player *pplayer, int phase) { - return game.info.simultaneous_phases || player_number(pplayer) == phase; + switch (game.info.phase_mode) { + case PMT_CONCURRENT: +return TRUE; +break; + case PMT_PLAYERS_ALTERNATE: +return player_number(pplayer) == phase; +break; + case PMT_TEAMS_ALTERNATE: +assert(pplayer->team != NULL); +return team_number(pplayer->team) == phase; +break; + default: +break; + } + + assert(FALSE); + return TRUE; } / diff --git a/common/game.h b/common/game.h index c397fa0..ba18102 100644 --- a/common/game.h +++ b/common/game.h @@ -32,6 +32,14 @@ enum debug_globals { DEBUG_LAST }; +/* NB: Must match phasemode setting + * help text in server/settings.c */ +enum phase_mode_types { + PMT_CONCURRENT = 0, + PMT_PLAYERS_ALTERNATE = 1, + PMT_TEAMS_ALTERNATE = 2 +}; + #define CONTAMINATION_POLLUTION 1 #define CONTAMINATION_FALLOUT 2 @@ -55,10 +63,10 @@ struct civ_game { time_t last_ping; struct timer *phase_timer; /* Time since seconds_to_phase_done was set. */ - /* The .info.simultaneous_phases value indicates the phase mode currently in + /* The .info.phase_mode value indicates the phase mode currently in * use. The "stored" value is a value the player can change; it won't * take effect until the next turn. */ - bool simultaneous_phases_stored; + int phase_mode_stored; char *startmessage; struct player players[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS]; struct conn_list *all_connections;/* including not yet established */ @@ -275,7 +283,9 @@ boo
[Freeciv-Dev] (PR#40444) Simultaneous Phases in 2.1.x
http://bugs.freeciv.org/Ticket/Display.html?id=40444 > It makes sense that simultaneous phases be provided with an option to have team members simulate their turns at the same time. At present, this is not an option, even when simultaneousphases is set to 0, this option is not allowed. When I tried this with 2 players v. 2 players, the simultaneousphases = 0 option permitted only one player to move at a time, while it enabled all other players to set movements without moving; the simultaneousphases = 1 option did what it is expected to do, to allow all players to move at the same time. My proposal is to allow a third option (simultaneousphases = 2 ?) to allow team players to move at the same time. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev