diff ai/aihand.c ai/aihand.c --- ai/aihand.c Tue Dec 26 22:50:48 2000 +++ ai/aihand.c Fri Dec 29 23:26:44 2000 @@ -396,7 +396,7 @@ freelog(LOG_DEBUG, "ai_man_gov (%s): change sub %d (%d)", pplayer->name, subgoal, goal); ai_government_change(pplayer, subgoal); - break; + return; } goal = subgoal; if (++failsafe > game.government_count) { @@ -406,15 +406,11 @@ } } - if (pplayer->government == game.government_when_anarchy) { - /* if the ai ever intends to stay anarchy, */ - /* change condition to if( (pplayer->revolution==0) && */ - if( ((pplayer->revolution<=0) || (pplayer->revolution>5)) - && can_change_to_government(pplayer, game.default_government)) { - freelog(LOG_DEBUG, "ai_man_gov (%s): change from anarchy", - pplayer->name); - ai_government_change(pplayer, game.default_government); - } + if (pplayer->revolution == REVOLUTION_GOVERNMENT && + can_change_to_government(pplayer, game.default_government)) { + freelog(LOG_DEBUG, "ai_man_gov (%s): change from anarchy", + pplayer->name); + ai_government_change(pplayer, game.default_government); } } diff ai/aitools.c ai/aitools.c --- ai/aitools.c Tue Dec 26 22:50:48 2000 +++ ai/aitools.c Fri Dec 29 23:26:44 2000 @@ -83,10 +83,8 @@ if (gov == pplayer->government) return; preq.government=gov; - pplayer->revolution=0; - pplayer->government=game.government_when_anarchy; - handle_player_government(pplayer, &preq); - pplayer->revolution = -1; /* yes, I really mean this. -- Syela */ + pplayer->revolution=REVOLUTION_GOVERNMENT; /* Anarchy is for human players! */ + handle_player_government(pplayer, &preq, REVOLUTION_GOV_HUMAN); } /* --------------------------------TAX---------------------------------- */ diff client/gui-gtk/dialogs.c client/gui-gtk/dialogs.c --- client/gui-gtk/dialogs.c Tue Dec 26 22:50:52 2000 +++ client/gui-gtk/dialogs.c Sat Dec 30 00:08:23 2000 @@ -1304,7 +1304,13 @@ for (i=0; irequired_tech == A_LAST) continue; + + /* Remove this when "revolution_fix" removed. */ + if(!has_capability("revolution_fix", aconnection.capability) && + i == game.government_when_anarchy) continue; + /* Remove to here ("revolution_fix") */ + button=gtk_button_new_with_label(g->name); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, FALSE, 0); gtk_signal_connect( diff client/gui-mui/dialogs.c client/gui-mui/dialogs.c --- client/gui-mui/dialogs.c Tue Dec 26 22:50:55 2000 +++ client/gui-mui/dialogs.c Sat Dec 30 00:08:23 2000 @@ -1142,7 +1142,13 @@ for(i=0;irevolution < 1 || pplayer->revolution > 5) && - pplayer->government==game.government_when_anarchy && - (!game.player_ptr->ai.control || ai_popup_windows) && - (get_client_state()==CLIENT_GAME_RUNNING_STATE)) - popup_government_dialog(); + + /* Remove this when "revolution_fix" removed. There is more + to remove further down. */ + if (has_capability("revolution_fix", aconnection.capability)) { + /* Remove to here ("revolution_fix") */ + + if(pplayer==game.player_ptr && pplayer->revolution == REVOLUTION_GOVERNMENT && + (!game.player_ptr->ai.control || ai_popup_windows) && + (get_client_state()==CLIENT_GAME_RUNNING_STATE)) + popup_government_dialog(); + + /* Remove this when "revolution_fix" removed. */ + } else { + if(pplayer==game.player_ptr && pplayer->revolution < 1 && + pplayer->government == game.government_when_anarchy && + (!game.player_ptr->ai.control || ai_popup_windows) && + (get_client_state()==CLIENT_GAME_RUNNING_STATE)) + popup_government_dialog(); + } + /* Remove to here ("revolution_fix") */ update_players_dialog(); update_worklist_report_dialog(); diff common/capstr.c common/capstr.c --- common/capstr.c Tue Dec 26 22:51:01 2000 +++ common/capstr.c Sat Dec 30 00:08:22 2000 @@ -73,7 +73,7 @@ #define CAPABILITY "+1.11 diplomat_investigate_fix production_change_fix" \ " game_ruleset nuclear_fallout land_channel_requirement event_wonder_obsolete" \ " event00_fix conn_info gen_impr_oversights diplo_move_city packet_short_city" \ -" indef_impr_types worklist_true_ids shared_vision activity_patrol" +" indef_impr_types worklist_true_ids shared_vision activity_patrol revolution_fix" /* "+1.11" is protocol for 1.11.0 stable release. @@ -129,6 +129,18 @@ "activity_patrol" is the patrol activity and the ability to send a goto route from the client to the server (for both goto and patrol activities). + + "revolution_fix" allows setting "when_anarchy" government to type + available also otherwise. + + +Removing capabilities: + + "revolution_fix" + - client/gui-xxx/dialogs.c/popup_government_dialog() + - client/packhand.c/handle_player_info() + - common/packets.c - Remove #include government.h + - common/packets.c/send_packet_player_info() */ void init_our_capability(void) diff common/government.h common/government.h --- common/government.h Thu Apr 27 18:03:51 2000 +++ common/government.h Sat Dec 30 00:27:55 2000 @@ -24,6 +24,13 @@ /* special values for free_* fields -- SKi */ #define G_CITY_SIZE_FREE G_MAGIC +/* Value of revolution counter, when one may change to new government. */ +#define REVOLUTION_GOVERNMENT 100 +/* AI already changed, dialog popup might required. */ +#define REVOLUTION_GOV_HUMAN 1 +/* Minimum starting value for revolution counter. */ +#define REVOLUTION_MIN (REVOLUTION_GOVERNMENT+1) + enum government_flag_id { G_BUILD_VETERAN_DIPLOMAT=0, /* and Spies (in general: all F_DIPLOMAT) */ G_REVOLUTION_WHEN_UNHAPPY, diff common/packets.c common/packets.c --- common/packets.c Tue Dec 26 22:51:02 2000 +++ common/packets.c Sat Dec 30 00:08:22 2000 @@ -32,6 +32,7 @@ #include "capability.h" #include "events.h" +#include "government.h" /* 'revolution_fix' capability requires this. */ #include "log.h" #include "mem.h" #include "support.h" @@ -1657,7 +1658,23 @@ } /* Remove to here */ - cptr=put_uint8(cptr, pinfo->revolution); + /* Remove this when "revolution_fix" removed. There is more + to remove further down. */ + if (pc && has_capability("revolution_fix", pc->capability)) { + /* Remove to here ("revolution_fix") */ + + cptr=put_uint8(cptr, pinfo->revolution); + + /* Remove this when "revolution_fix" removed. */ + } else { + if (pinfo->revolution == REVOLUTION_GOVERNMENT || + !pinfo->revolution) + cptr=put_uint8(cptr, 0); + else + cptr=put_uint8(cptr, pinfo->revolution - REVOLUTION_MIN + 1); + } + /* Remove to here ("revolution_fix") */ + cptr=put_uint8(cptr, pinfo->tech_goal); cptr=put_uint8(cptr, pinfo->ai?1:0); cptr=put_uint8(cptr, pinfo->is_barbarian); diff common/player.c common/player.c --- common/player.c Tue Dec 26 22:51:03 2000 +++ common/player.c Fri Dec 29 23:26:45 2000 @@ -68,6 +68,7 @@ plr->government=game.default_government; plr->nation=MAX_NUM_NATIONS; plr->capital=0; + plr->revolution=0; unit_list_init(&plr->units); city_list_init(&plr->cities); conn_list_init(&plr->connections); diff data/civ1/governments.ruleset data/civ1/governments.ruleset --- data/civ1/governments.ruleset Tue Dec 26 22:51:09 2000 +++ data/civ1/governments.ruleset Fri Dec 29 23:26:45 2000 @@ -101,7 +101,7 @@ [government_anarchy] name = _("Anarchy") -tech_req = "None" +tech_req = "Never" graphic = "gov.anarchy" graphic_alt = "-" flags = "-" diff data/civ2/governments.ruleset data/civ2/governments.ruleset --- data/civ2/governments.ruleset Tue Dec 26 22:51:10 2000 +++ data/civ2/governments.ruleset Fri Dec 29 23:26:45 2000 @@ -99,7 +99,7 @@ [government_anarchy] name = _("Anarchy") -tech_req = "None" +tech_req = "Never" graphic = "gov.anarchy" graphic_alt = "-" flags = "-" diff data/default/governments.ruleset data/default/governments.ruleset --- data/default/governments.ruleset Tue Dec 26 22:51:10 2000 +++ data/default/governments.ruleset Sat Dec 30 02:08:15 2000 @@ -100,7 +100,7 @@ [government_anarchy] name = _("Anarchy") -tech_req = "None" +tech_req = "Never" graphic = "gov.anarchy" graphic_alt = "-" flags = "-" diff server/citytools.c server/citytools.c --- server/citytools.c Fri Dec 29 21:45:13 2000 +++ server/citytools.c Fri Dec 29 23:26:45 2000 @@ -796,7 +796,7 @@ sz_strlcpy(cplayer->username, cplayer->name); cplayer->is_connected = 0; cplayer->government = game.government_when_anarchy; - pplayer->revolution = 1; + pplayer->revolution = REVOLUTION_MIN; cplayer->capital = 1; /* This should probably be DS_NEUTRAL when AI knows about diplomacy, @@ -852,7 +852,7 @@ /* change the original player */ pplayer->government = game.government_when_anarchy; - pplayer->revolution = 1; + pplayer->revolution = REVOLUTION_MIN; pplayer->economic.tax = PLAYER_DEFAULT_TAX_RATE; pplayer->economic.science = PLAYER_DEFAULT_SCIENCE_RATE; pplayer->economic.luxury = PLAYER_DEFAULT_LUXURY_RATE; diff server/plrhand.c server/plrhand.c --- server/plrhand.c Tue Dec 26 22:52:34 2000 +++ server/plrhand.c Sat Dec 30 02:02:16 2000 @@ -140,8 +140,14 @@ **************************************************************************/ static void update_revolution(struct player *pplayer) { - if(pplayer->revolution) + assert(!pplayer->revolution || pplayer->revolution >= REVOLUTION_MIN || + pplayer->revolution == REVOLUTION_GOVERNMENT || + pplayer->revolution == REVOLUTION_GOV_HUMAN); + + if(pplayer->revolution >= REVOLUTION_MIN) pplayer->revolution--; + if(pplayer->revolution == REVOLUTION_GOV_HUMAN) + pplayer->revolution = 0; } /************************************************************************** @@ -529,16 +535,15 @@ ... **************************************************************************/ void handle_player_government(struct player *pplayer, - struct packet_player_request *preq) + struct packet_player_request *preq, + int new_revol_state) { - if( pplayer->government!=game.government_when_anarchy || - !can_change_to_government(pplayer, preq->government) - ) - return; - - if((pplayer->revolution<=5) && (pplayer->revolution>0)) + if((pplayer->revolution != REVOLUTION_GOVERNMENT && + pplayer->revolution != REVOLUTION_GOV_HUMAN) || + !can_change_to_government(pplayer, preq->government)) return; + pplayer->revolution=new_revol_state; pplayer->government=preq->government; notify_player(pplayer, _("Game: %s now governs the %s as a %s."), pplayer->name, @@ -568,11 +573,9 @@ **************************************************************************/ void handle_player_revolution(struct player *pplayer) { - if ((pplayer->revolution<=5) && - (pplayer->revolution>0) && - ( pplayer->government==game.government_when_anarchy)) + if (pplayer->revolution >= REVOLUTION_MIN) return; - pplayer->revolution=myrand(5)+1; + pplayer->revolution=myrand(5)+REVOLUTION_MIN; pplayer->government=game.government_when_anarchy; notify_player(pplayer, _("Game: The %s have incited a revolt!"), get_nation_name_plural(pplayer->nation)); @@ -585,7 +588,7 @@ send_player_info(pplayer, pplayer); if (player_owns_active_govchange_wonder(pplayer)) - pplayer->revolution=1; + pplayer->revolution=REVOLUTION_MIN; } /************************************************************************** @@ -1022,8 +1025,15 @@ packet->researchpoints = plr->research.researchpoints; packet->researching = plr->research.researching; packet->future_tech = plr->future_tech; - if (plr->revolution) - packet->revolution = 1; + if (plr->revolution == REVOLUTION_GOVERNMENT || + plr->revolution == REVOLUTION_GOV_HUMAN) { + if (info_level >= INFO_FULL) + packet->revolution = REVOLUTION_GOVERNMENT; + else + packet->revolution = REVOLUTION_MIN; + } + else if (plr->revolution >= REVOLUTION_MIN) + packet->revolution = REVOLUTION_MIN; else packet->revolution = 0; } else { diff server/plrhand.h server/plrhand.h --- server/plrhand.h Tue Dec 26 22:52:34 2000 +++ server/plrhand.h Fri Dec 29 23:26:45 2000 @@ -59,7 +59,8 @@ struct conn_list *player_reply_dest(struct player *pplayer); void handle_player_government(struct player *pplayer, - struct packet_player_request *preq); + struct packet_player_request *preq, + int new_revol_state); void handle_player_research(struct player *pplayer, struct packet_player_request *preq); void handle_player_tech_goal(struct player *pplayer, diff server/savegame.c server/savegame.c --- server/savegame.c Sat Oct 28 01:20:18 2000 +++ server/savegame.c Sat Dec 30 00:51:17 2000 @@ -24,6 +24,7 @@ #include "city.h" #include "fcintl.h" #include "game.h" +#include "government.h" #include "idex.h" #include "log.h" #include "map.h" @@ -59,7 +60,7 @@ * include it when appropriate for maximum savegame compatibility.) */ #define SAVEFILE_OPTIONS "1.7 startoptions spacerace2 rulesets" \ -" diplchance_percent worklists2" +" diplchance_percent worklists2 revolution_fix" /*************************************************************** @@ -611,8 +612,16 @@ p=secfile_lookup_str(file, "player%d.invs", plrno); plr->capital=secfile_lookup_int(file, "player%d.capital", plrno); - plr->revolution=secfile_lookup_int_default(file, 0, "player%d.revolution", - plrno); + plr->revolution=secfile_lookup_int_default(file, 0, "player%d.revolution", plrno); + + if (!has_capability("revolution_fix", savefile_options)) { + if (plr->revolution < 0) + plr->revolution = REVOLUTION_GOV_HUMAN; + else if (plr->revolution > 5) + plr->revolution = 0; + else if (plr->revolution > 0) + plr->revolution += REVOLUTION_MIN - 1; + } for(i=0; i