[Freeciv-Dev] (PR#12223) city has changed multiple times (CMA detaches)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12223 >
> [jdorje - Mon Apr 25 06:26:03 2005]:
>
> > [bhudson - Fri Apr 22 03:32:24 2005]:
> >
> > I made a patch for this a while back but something gobbled
> > up my message it seems.
> >
> > I've been playing with this a while and I never see the "changed
> > multiple times" error anymore. Pity it didn't make it in to 2.0.0
> >
> > The error, and how this fixes it:
> > The GAME_STATE packet includes clearing the delta caches.
> > Currently, the server sends that packet and immediately clears
> > both send and receive caches.
> >
> > However, if it so happens that the GAME_STATE packet is in
> > flight and the client sends a packet to the server, the client
> > sends using its old delta cache, and the server receives using
> > the new, cleared delta cache.
> >
> > Fix: the server sends GAME_STATE and clears its outgoing
> > cache. Upon receipt, the client clears its caches and sends
> > a GAME_STATE_ACK. Finally, when the server gets the ack,
> > it clears its incoming cache.
>
> But the situation when this error shows up is usually when a game is
> just loaded. And in this case why would the client be doing any action
> (particularly CM, but generally anything that would involve sending some
> sort of change packet to the server) before it receives the game-state
> packet from the server that tells it to start running?
Ah hah. There is a bug in the agents causing them to be run any time
there's a thaw, regardless of the game state. With this patch:
1. The agents will not be run on a thaw unless the game state is
running. (The thaw still happens so the freeze/thaw value is properly
kept.)
2. When the game starts all agents will be run (since they won't have
been run during the preceeding thaw).
I can no longer reproduce the original bug in cvs HEAD. However I can
reproduce it (with the civgame+0720 from the very top of this ticket) in
2.0, and this patch fixes it. Which brings me to my next point: since
this doesn't change the network code this fix can go into S2_0.
Also this may make things faster, since changes to the city in pregame
no longer result in rerunning the CMA (I've noted before that sometimes
cities are run twice each on game start). This is just a guess; I
haven't tested it.
-jason
Index: client/agents/agents.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/agents.c,v
retrieving revision 1.32
diff -u -r1.32 agents.c
--- client/agents/agents.c 22 Jan 2005 19:45:39 -0000 1.32
+++ client/agents/agents.c 25 Apr 2005 06:44:31 -0000
@@ -277,7 +277,7 @@
}
frozen_level--;
assert(frozen_level >= 0);
- if (frozen_level == 0) {
+ if (frozen_level == 0 && get_client_state() == CLIENT_GAME_RUNNING_STATE) {
call_handle_methods();
}
}
@@ -462,6 +462,7 @@
void agents_game_start(void)
{
freelog(META_CALLBACKS_LOGLEVEL, "agents_game_start()");
+ call_handle_methods();
}
/***********************************************************************
|
|