/* ================ SV_SendClientGameState Sends the first message from the server to a connected client. This will be sent on the initial connection and upon each new map load. It will be resent if the client acknowledges a later message but has the wrong gamestate. ================ */ void SV_SendClientGameState( client_t *client ) { msg_t msg; byte msgBuffer[MAX_MSGLEN]; MSG_Init( &msg, msgBuffer, sizeof( msgBuffer ) ); // MW - my attempt to fix illegible server message errors caused by // packet fragmentation of initial snapshot. while(client->state&&client->netchan.unsentFragments) { // send additional message fragments if the last message // was too large to send at once Com_Printf ("[ISM]SV_SendClientGameState() [2] for %s, writing out old fragments\n", client->name); SV_Netchan_TransmitNextFragment(&client->netchan); } Com_DPrintf ("SV_SendClientGameState() for %s\n", client->name); Com_DPrintf( "Going from CS_CONNECTED to CS_PRIMED for %s\n", client->name ); if ( client->state == CS_CONNECTED ) client->state = CS_PRIMED; client->pureAuthentic = 0; client->gotCP = qfalse; // when we receive the first packet from the client, we will // notice that it is from a different serverid and that the // gamestate message was not just sent, forcing a retransmit client->gamestateMessageNum = client->netchan.outgoingSequence; SV_CreateClientGameStateMessage( client, &msg ); // deliver this to the client SV_SendMessageToClient( &msg, client ); }
void SV_RecordDemo( client_t *cl, char *demoName ) { char name[MAX_OSPATH]; byte bufData[MAX_MSGLEN]; msg_t msg; int len; if ( cl->demo.demorecording ) { Com_Printf( "Already recording.\n" ); return; } if ( cl->state != CS_ACTIVE ) { Com_Printf( "Client is not active.\n" ); return; } // open the demo file Q_strncpyz( cl->demo.demoName, demoName, sizeof( cl->demo.demoName ) ); Com_sprintf( name, sizeof( name ), "demos/%s.dm_%d", cl->demo.demoName, PROTOCOL_VERSION ); Com_Printf( "recording to %s.\n", name ); cl->demo.demofile = FS_FOpenFileWrite( name ); if ( !cl->demo.demofile ) { Com_Printf ("ERROR: couldn't open.\n"); return; } cl->demo.demorecording = qtrue; // don't start saving messages until a non-delta compressed message is received cl->demo.demowaiting = qtrue; cl->demo.isBot = ( cl->netchan.remoteAddress.type == NA_BOT ) ? qtrue : qfalse; cl->demo.botReliableAcknowledge = cl->reliableSent; // write out the gamestate message MSG_Init( &msg, bufData, sizeof( bufData ) ); // NOTE, MRE: all server->client messages now acknowledge int tmp = cl->reliableSent; SV_CreateClientGameStateMessage( cl, &msg ); cl->reliableSent = tmp; // finished writing the client packet MSG_WriteByte( &msg, svc_EOF ); // write it to the demo file len = LittleLong( cl->netchan.outgoingSequence - 1 ); FS_Write( &len, 4, cl->demo.demofile ); len = LittleLong( msg.cursize ); FS_Write( &len, 4, cl->demo.demofile ); FS_Write( msg.data, msg.cursize, cl->demo.demofile ); // the rest of the demo file will be copied from net messages }