--
[ Picked text/plain from multipart/alternative ]

We're currently trying to fix an elsuive crash bug which didn't make much sense 
to us until recently. Basically, our weapons access data from a singleton 
"NDGameSettings" entity that is networked to all clients (in similar fashion to 
how CTeam is broadcast to all clients). This singleton is currently accessed 
from the weapon entity's Spawn() method on both client and server side.The 
strange thing is, occasionnaly, the game would crash with an error-trapping 
message saying that the NDGameSettings singleton instance pointer is null, 
while the game has been running fine for several minutes. The only way of this 
happening is if the weapon entity is created & spawned before the 
NDGameSettings() entity. One would expect this error scenario to happen at map 
load time since this is the only place where the NDGameSettings entity is 
created. However, it doesnt crash at load time, but randomly during the game, 
at any moment.Here is a quick snippet of the NDGameSettings code 
used.*************************************************************class 
CNDGameSettings : public CBaseEntity{    DECLARE_CLASS( CNDGameSettings, 
CBaseEntity );    DECLARE_NETWORKCLASS();public:    static CNDGameSettings* 
GetInstance() { return s_pInstance; }protected:    static CNDGameSettings* 
s_pInstance;    ...}CNDGameSettings::CNDGameSettings(){    if( GetInstance() )  
  {#ifdef CLIENT_DLL        Warning("[CLIENT] 
CNDGameSettings::CNDGameSettings() - An instance of CNDGameSettings already 
exists on the client side\n");#else        Warning("[SERVER] 
CNDGameSettings::CNDGameSettings() - An instance of CNDGameSettings already 
exists\n");        UTIL_Remove( GetInstance() );#endif    }    // Save pointer 
to instance in class global    s_pInstance = 
this;}CNDGameSettings::~CNDGameSettings(){    if( GetInstance() == this )    {  
      Msg( "####### CNDGameSettings Destructor - Instance removed ########\n" 
);        s_pInstance = NULL;    }}*** server side only ***int 
CNDGameSettings::UpdateTransmitState( void ){    // always transmit to all 
clients    return SetTransmitState( FL_EDICT_ALWAYS 
);}***************************************************************************After
 several attempts at reproducing the crash bug, we found out that people with 
bad/unstable connections and high latency were a lot more susceptible to this 
crash. We therefore suspected that the bug had something to do with the network 
behavior of HL2, and that some mechanism unknown to us would cause the 
NDGameSettings entity to be recreated during the game, instead of just once at 
map load time. Our debugging tests proved this, as we got the "####### 
CNDGameSettings Destructor - Instance removed ########" message several times 
during the game (along with many other debugging messages displayed when weapon 
entities are created), using a laptop with a very bad connection to our test 
server. Now my theory is this has something to do with this "full world 
snapshot" update explained in the Source Multiplayer Networking article 
(http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking):"Game 
data is compressed using delta compression to reduce
network load. That means the server doesn't send a full world snapshot
each time, but rather only changes (a delta snapshot) that happened
since the last acknowledged update. With each packet sent between the
client and server, acknowledge numbers are attached to keep track of
their data flow. Usually full (non-delta) snapshots are only sent when
a game starts or a client suffers from heavy packet loss for a couple
of seconds. Clients can request a full snapshot manually with the cl_fullupdate 
command."To me, it seems that the client-side entities list is cleared and 
recreated when receiving a full world snapshot from the network. This would 
explain why the client-side NDGameSettings entity is destroyed and then 
recreated at random moments during the game and would also explain why the 
"load time error scenario" can happen at anytime while the game is running, 
especially to people with bad connections to the server.My questions:- Am I 
looking in the wrong direction?- If not, could someone explain the mechanics 
behind the full world snapshot a bit more indepth? - Are there any flags I can 
set to my NDGameSettings entity to somehow make it resistant to this?- Why use 
a proxy entity to network the GameRules data and not make the GameRules class 
directly inherit from CBaseEntity? - What is a correct way of safely 
creating/accessing singleton entity objects in Source?Thanks in advance!
_________________________________________________________________
David Guetta a réuni les sons les plus connus de Messenger dans le Mix 
Messenger, le son de l’été ! Téléchargez-le gratuitement !
http://specials.divertissements.fr.msn.com/mixmessenger
--

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to