[Freeciv-Dev] Re: (PR#4449) revolution choice doesn't work
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sat, Jul 12, 2003 at 09:25:43AM -0700, ChrisK@xxxxxxxx wrote:
>
> As I understand it, there are 2 packets, one for revolution ended and one
> for new government. The first one is for the popup dialog to appear. If the
> player already determined democracy as new government at the time he has
> started Revolution, just tell the client the new government. Or does the
> "revolution ended" packet have more functionality than just popup the Gov.
> dialog?
>
> Another point. It should be possible for the player to change her mind
> whenever she wants to, as long as the revolution continues. If she started
> with "Democracy", she should be able to say "Republic" one turn later, or
> just "Revolution", to get the popup later on. And vice versa.
>
> A message should be printed which informs about the upcoming government
> form, or just "Revolution" if none is determined, each time she issues such
> a command. This is an important decision in the game and should have clear
> feedback.
The relevant code bits are:
in client/packhand.c:
/**************************************************************************
government_selected will be set if the player has chosen a 'target'
government. If so, then government_choice holds that government value.
**************************************************************************/
static bool government_selected = FALSE;
static int government_choice;
/**************************************************************************
Reset the target government (for instance when you disconnect from a
server).
**************************************************************************/
void target_government_init(void)
{
/* We have to reset this, otherwise if we joined a new game where we
* were already in anarchy, odd behavior would result. */
government_selected = FALSE;
}
/**************************************************************************
Sets the target government. This will automatically start a revolution
if the target government differs from the current one.
**************************************************************************/
void set_government_choice(int government)
{
if (!government_selected
&& government != game.player_ptr->government
&& can_client_issue_orders()) {
struct packet_player_request packet;
send_packet_player_request(&aconnection, &packet,
PACKET_PLAYER_REVOLUTION);
government_selected = TRUE;
}
government_choice = government;
}
/**************************************************************************
Begin a revolution by telling the server to start it. This also clears
the current government choice.
**************************************************************************/
void start_revolution(void)
{
struct packet_player_request packet;
government_selected = FALSE;
send_packet_player_request(&aconnection, &packet,
PACKET_PLAYER_REVOLUTION);
}
/**************************************************************************
Choose the government after a revolution completes, either by taking the
government that the player has already specified or by popping up a
dialog to ask.
**************************************************************************/
static void choose_government(void)
{
if (government_selected) {
struct packet_player_request packet;
packet.government = government_choice;
send_packet_player_request(&aconnection, &packet,
PACKET_PLAYER_GOVERNMENT);
government_selected = FALSE;
} else {
popup_government_dialog();
}
}
/**************************************************************************
...
**************************************************************************/
void handle_player_info(struct packet_player_info *pinfo)
{
...
if (pplayer == game.player_ptr &&
(pplayer->revolution < 1 || pplayer->revolution > 5) &&
pplayer->government == game.government_when_anarchy &&
(!game.player_ptr->ai.control || ai_popup_windows) &&
can_client_change_view()) {
create_event(-1, -1, E_REVOLT_DONE, _("Game: Revolution finished"));
choose_government();
}
...
}
and server/plrhand.c:
/**************************************************************************
Count down if the player are in a revolution, notify him when revolution
has ended.
**************************************************************************/
void update_revolution(struct player *pplayer)
{
if(pplayer->revolution > 0)
pplayer->revolution--;
}
(from PACKET_PLAYER_GOVERNMENT and PACKET_PLAYER_REVOLUTION respectively)
/**************************************************************************
...
**************************************************************************/
void handle_player_government(struct player *pplayer,
struct packet_player_request *preq)
{
if (pplayer->government != game.government_when_anarchy ||
preq->government < 0 || preq->government >= game.government_count ||
!can_change_to_government(pplayer, preq->government)) {
return;
}
if((pplayer->revolution<=5) && (pplayer->revolution>0))
return;
pplayer->government=preq->government;
notify_player(pplayer, _("Game: %s now governs the %s as a %s."),
...
}
/**************************************************************************
...
**************************************************************************/
void handle_player_revolution(struct player *pplayer)
{
if ((pplayer->revolution<=5) &&
(pplayer->revolution>0) &&
( pplayer->government==game.government_when_anarchy))
return;
pplayer->revolution=myrand(5)+1;
pplayer->government=game.government_when_anarchy;
notify_player_ex(pplayer, -1, -1, E_REVOLT_START,
_("Game: The %s have incited a revolt!"),
...
}
This arrangement stinks. Better would be to have pplayer->next_government
that is used on the server side to make a government change immediately
after a revolution is over. That way the server doesn't have to recontact
the client to get instructions. On the client side, this can prevent
redundant revolution calls. The only question is what should the server do
if it recieves only a revolution request without future government? Should
we remain in game.government_when_anarchy until the client is fit to send a
GOVERNMENT packet?
-mike
PS: The revolution dialog (in GTK) doesn't work correctly for multiple
connections. The dialog should close automatically if a player_info
packet is received that changes the government.
|
|