diff ai/aihand.c ai/aihand.c --- ai/aihand.c Tue Dec 26 22:50:48 2000 +++ ai/aihand.c Tue Dec 26 18:58:03 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 Tue Dec 26 18:50:13 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 Tue Dec 26 23:26:20 2000 @@ -1304,7 +1304,11 @@ for (i=0; irequired_tech == A_LAST) continue; + + if(!has_capability("revolution_fix", aconnection.capability) && + i == game.government_when_anarchy) continue; + 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 Tue Dec 26 23:26:22 2000 @@ -1142,7 +1142,11 @@ 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(); + if (has_capability("revolution_fix", aconnection.capability)) { + + 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(); + + } 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(); + } 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 Tue Dec 26 15:45:24 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. diff common/government.h common/government.h --- common/government.h Thu Apr 27 18:03:51 2000 +++ common/government.h Tue Dec 26 18:50:14 2000 @@ -24,6 +24,13 @@ /* special values for free_* fields -- SKi */ #define G_CITY_SIZE_FREE G_MAGIC +/* Revolution counter values when one may change to new government. */ +#define REVOLUTION_GOVERNMENT 2 +/* AI already chaned, human may overrule. */ +#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 Tue Dec 26 21:02:40 2000 @@ -32,6 +32,7 @@ #include "capability.h" #include "events.h" +#include "government.h" /* Remove this with 'revolution_fix' capability. */ #include "log.h" #include "mem.h" #include "support.h" @@ -1657,7 +1658,16 @@ } /* Remove to here */ - cptr=put_uint8(cptr, pinfo->revolution); + if (pc && has_capability("revolution_fix", pc->capability)) { + cptr=put_uint8(cptr, pinfo->revolution); + } else { + if (pinfo->revolution == REVOLUTION_GOVERNMENT || + !pinfo->revolution) + cptr=put_uint8(cptr, 0); + else + cptr=put_uint8(cptr, pinfo->revolution - REVOLUTION_MIN + 1); + } + 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 Tue Dec 26 18:50:15 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 Tue Dec 26 23:19:13 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 Tue Dec 26 23:19:10 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 Tue Dec 26 23:19:17 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 Tue Dec 26 22:52:33 2000 +++ server/citytools.c Tue Dec 26 18:50:12 2000 @@ -787,7 +787,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, @@ -843,7 +843,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 Wed Dec 27 01:53:55 2000 @@ -140,8 +140,10 @@ **************************************************************************/ static void update_revolution(struct player *pplayer) { - if(pplayer->revolution) + if(pplayer->revolution >= REVOLUTION_MIN) pplayer->revolution--; + if(pplayer->revolution == REVOLUTION_GOV_HUMAN) + pplayer->revolution = 0; } /************************************************************************** @@ -529,16 +531,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 +569,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 +584,7 @@ send_player_info(pplayer, pplayer); if (player_owns_active_govchange_wonder(pplayer)) - pplayer->revolution=1; + pplayer->revolution=REVOLUTION_MIN; } /************************************************************************** @@ -1022,8 +1021,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 Tue Dec 26 19:33:55 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 Tue Dec 26 19:37:13 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,18 @@ 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); + + if (has_capability("revolution_fix", savefile_options)) { + plr->revolution=secfile_lookup_int(file, "player%d.revolution", plrno); + } else { + plr->revolution=secfile_lookup_int_default(file, 0, "player%d.revolution", plrno); + 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; + } for(i=0; i