本文整理汇总了C++中VM_ExplicitArgPtr函数的典型用法代码示例。如果您正苦于以下问题:C++ VM_ExplicitArgPtr函数的具体用法?C++ VM_ExplicitArgPtr怎么用?C++ VM_ExplicitArgPtr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VM_ExplicitArgPtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SV_MapRestart_f
//.........这里部分代码省略.........
}
// make sure server is running
if ( !com_sv_running->integer ) {
Com_Printf( "Server is not running.\n" );
return;
}
if ( sv.restartTime ) {
return;
}
if (Cmd_Argc() > 1 ) {
delay = atoi( Cmd_Argv(1) );
}
else {
delay = 5;
}
if( delay && (!Cvar_VariableValue("g_doWarmup") || Cvar_VariableValue("g_gametype") == GT_TOURNAMENT) ) {
sv.restartTime = svs.time + delay * 1000;
SV_SetConfigstring( CS_WARMUP, va("%i", sv.restartTime) );
return;
}
// check for changes in variables that can't just be restarted
// check for maxclients change
if ( sv_maxclients->modified || sv_gametype->modified ) {
char mapname[MAX_QPATH];
Com_Printf( "variable change -- restarting.\n" );
// restart the map the slow way
Q_strncpyz( mapname, Cvar_VariableString( "mapname" ), sizeof( mapname ) );
SV_SpawnServer( mapname, qfalse, eForceReload_NOTHING );
return;
}
// toggle the server bit so clients can detect that a
// map_restart has happened
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// generate a new serverid
sv.restartedServerId = sv.serverId;
sv.serverId = com_frameTime;
Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );
// reset all the vm data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
// had been changed from their default values will generate broadcast updates
sv.state = SS_LOADING;
sv.restarting = qtrue;
SV_RestartGameProgs();
// run a few frames to allow everything to settle
for ( i = 0 ;i < 3 ; i++ ) {
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
svs.time += 100;
}
sv.state = SS_GAME;
sv.restarting = qfalse;
// connect and begin all the clients
for (i=0 ; i<sv_maxclients->integer ; i++) {
client = &svs.clients[i];
// send the new gamestate to all connected clients
if ( client->state < CS_CONNECTED) {
continue;
}
if ( client->netchan.remoteAddress.type == NA_BOT ) {
isBot = qtrue;
} else {
isBot = qfalse;
}
// add the map_restart command
SV_AddServerCommand( client, "map_restart\n" );
// connect the client again, without the firstTime flag
denied = (char *)VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) );
if ( denied ) {
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( client, denied );
Com_Printf( "SV_MapRestart_f(%d): dropped client %i - denied!\n", delay, i ); // bk010125
continue;
}
client->state = CS_ACTIVE;
SV_ClientEnterWorld( client, &client->lastUsercmd );
}
// run another frame to allow things to look at all the players
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
svs.time += 100;
}
示例2: SV_SpawnServer
//.........这里部分代码省略.........
for ( i = 0; i < GAME_INIT_FRAMES; i++ )
{
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
SV_BotFrame( svs.time );
svs.time += FRAMETIME;
}
// create a baseline for more efficient communications
SV_CreateBaseline();
for ( i = 0; i < sv_maxclients->integer; i++ )
{
// send the new gamestate to all connected clients
if ( svs.clients[ i ].state >= CS_CONNECTED )
{
char *denied;
if ( svs.clients[ i ].netchan.remoteAddress.type == NA_BOT )
{
if ( killBots || SV_GameIsSinglePlayer() || SV_GameIsCoop() )
{
SV_DropClient( &svs.clients[ i ], "" );
continue;
}
isBot = qtrue;
}
else
{
isBot = qfalse;
}
// connect the client again
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) ); // firstTime = qfalse
if ( denied )
{
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( &svs.clients[ i ], denied );
}
else
{
if ( !isBot )
{
// when we get the next packet from a connected client,
// the new gamestate will be sent
svs.clients[ i ].state = CS_CONNECTED;
}
else
{
client_t *client;
sharedEntity_t *ent;
client = &svs.clients[ i ];
client->state = CS_ACTIVE;
ent = SV_GentityNum( i );
ent->s.number = i;
client->gentity = ent;
client->deltaMessage = -1;
client->nextSnapshotTime = svs.time; // generate a snapshot immediately
VM_Call( gvm, GAME_CLIENT_BEGIN, i );
}
}
示例3: SV_SpawnServer
//.........这里部分代码省略.........
// to load during actual gameplay
sv.state = SS_LOADING;
// load and spawn all other entities
SV_InitGameProgs();
// run a few frames to allow everything to settle
for (i = 0 ; i < GAME_INIT_FRAMES ; i++)
{
VM_Call(gvm, GAME_RUN_FRAME, svs.time);
svs.time += FRAMETIME;
}
// create a baseline for more efficient communications
SV_CreateBaseline();
for (i = 0 ; i < sv_maxclients->integer ; i++)
{
// send the new gamestate to all connected clients
if (svs.clients[i].state >= CS_CONNECTED)
{
char *denied;
if (svs.clients[i].netchan.remoteAddress.type == NA_BOT)
{
isBot = qtrue;
}
else
{
isBot = qfalse;
}
// connect the client again
denied = VM_ExplicitArgPtr(gvm, VM_Call(gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot)); // firstTime = qfalse
if (denied)
{
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient(&svs.clients[i], denied);
}
else
{
if (!isBot)
{
// when we get the next packet from a connected client,
// the new gamestate will be sent
svs.clients[i].state = CS_CONNECTED;
}
else
{
client_t *client;
sharedEntity_t *ent;
client = &svs.clients[i];
client->state = CS_ACTIVE;
ent = SV_GentityNum(i);
ent->s.number = i;
client->gentity = ent;
client->deltaMessage = -1;
client->nextSnapshotTime = svs.time; // generate a snapshot immediately
VM_Call(gvm, GAME_CLIENT_BEGIN, i);
}
}
}
示例4: SV_MapRestart_f
//.........这里部分代码省略.........
}
// check for changes in variables that can't just be restarted
// check for maxclients change
if ( sv_maxclients->modified )
{
char mapname[ MAX_QPATH ];
Com_Printf(_( "sv_maxclients variable change — restarting.\n" ));
// restart the map the slow way
Q_strncpyz( mapname, Cvar_VariableString( "mapname" ), sizeof( mapname ) );
SV_SpawnServer( mapname );
return;
}
// toggle the server bit so clients can detect that a
// map_restart has happened
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// generate a new serverid
// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
sv.serverId = com_frameTime;
Cvar_Set( "sv_serverid", va( "%i", sv.serverId ) );
// reset all the VM data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
// had been changed from their default values will generate broadcast updates
sv.state = SS_LOADING;
sv.restarting = qtrue;
Cvar_Set( "sv_serverRestarting", "1" );
SV_RestartGameProgs();
// run a few frames to allow everything to settle
for ( i = 0; i < GAME_INIT_FRAMES; i++ )
{
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
svs.time += FRAMETIME;
}
// create a baseline for more efficient communications
// Gordon: meh, this won't work here as the client doesn't know it has happened
// SV_CreateBaseline ();
sv.state = SS_GAME;
sv.restarting = qfalse;
// connect and begin all the clients
for ( i = 0; i < sv_maxclients->integer; i++ )
{
client = &svs.clients[ i ];
// send the new gamestate to all connected clients
if ( client->state < CS_CONNECTED )
{
continue;
}
if ( client->netchan.remoteAddress.type == NA_BOT )
{
isBot = qtrue;
}
else
{
isBot = qfalse;
}
// add the map_restart command
SV_AddServerCommand( client, "map_restart\n" );
// connect the client again, without the firstTime flag
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) );
if ( denied )
{
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( client, denied );
if ( !isBot )
{
Com_Printf( "SV_MapRestart_f(%d): dropped client %i: denied!\n", delay, i ); // bk010125
}
continue;
}
client->state = CS_ACTIVE;
SV_ClientEnterWorld( client, &client->lastUsercmd );
}
// run another frame to allow things to look at all the players
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
svs.time += FRAMETIME;
Cvar_Set( "sv_serverRestarting", "0" );
}
示例5: SV_DirectConnect
//.........这里部分代码省略.........
newcl = NULL;
for ( i = startIndex; i < MAX_PLAYERS ; i++ ) {
cl = &svs.clients[i];
if (cl->state == CS_FREE) {
newcl = cl;
break;
}
}
if ( !newcl ) {
if ( NET_IsLocalAddress( from ) ) {
count = 0;
for ( i = startIndex; i < sv_maxclients->integer ; i++ ) {
cl = &svs.clients[i];
if (cl->netchan.remoteAddress.type == NA_BOT) {
count++;
}
}
// if they're all bots
if (count >= sv_maxclients->integer - startIndex) {
SV_DropClient(&svs.clients[sv_maxclients->integer - 1], "only bots on server");
newcl = &svs.clients[sv_maxclients->integer - 1];
}
else {
Com_Error( ERR_FATAL, "server is full on local connect\n" );
return;
}
}
else {
NET_OutOfBandPrint( NS_SERVER, from, "print\nServer is full.\n" );
Com_DPrintf ("Rejected a connection.\n");
return;
}
}
// we got a newcl, so reset the reliableSequence and reliableAcknowledge
cl->reliableAcknowledge = 0;
cl->reliableSequence = 0;
gotnewcl:
// build a new connection
// accept the new client
// this is the only place a client_t is ever initialized
*newcl = temp;
clientNum = newcl - svs.clients;
ent = SV_GentityNum( clientNum );
newcl->gentity = ent;
// save the challenge
newcl->challenge = challenge;
// save the address
Netchan_Setup (NS_SERVER, &newcl->netchan , from, qport);
// init the netchan queue
newcl->netchan_end_queue = &newcl->netchan_start_queue;
// save the userinfo
Q_strncpyz( newcl->userinfo, userinfo, sizeof(newcl->userinfo) );
// get the game a chance to reject this connection or modify the userinfo
denied = VM_Call( gvm, GAME_CLIENT_CONNECT, clientNum, qtrue, qfalse ); // firstTime = qtrue
if ( denied ) {
// we can't just use VM_ArgPtr, because that is only valid inside a VM_Call
char *str = VM_ExplicitArgPtr( gvm, denied );
NET_OutOfBandPrint( NS_SERVER, from, "error\n%s\n", str );
Com_DPrintf ("Game rejected a connection: %s.\n", str);
return;
}
SV_UserinfoChanged( newcl );
// send the connect packet to the client
NET_OutOfBandPrint( NS_SERVER, from, "connectResponse" );
Com_DPrintf( "Going from CS_FREE to CS_CONNECTED for %s\n", newcl->name );
newcl->state = CS_CONNECTED;
newcl->nextSnapshotTime = svs.time;
newcl->lastPacketTime = svs.time;
newcl->lastConnectTime = svs.time;
// 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
newcl->gamestateMessageNum = -1;
// if this was the first client on the server, or the last client
// the server can hold, send a heartbeat to the master.
count = 0;
for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {
if ( svs.clients[i].state >= CS_CONNECTED ) {
count++;
}
}
if ( count == 1 || count == sv_maxclients->integer ) {
SV_Heartbeat_f();
}
}
示例6: SV_DirectConnect
//.........这里部分代码省略.........
cl = &svs.clients[i];
if (cl->state == CS_FREE) {
newcl = cl;
break;
}
}
if ( !newcl ) {
if ( NET_IsLocalAddress( from ) ) {
count = 0;
for ( i = startIndex; i < sv_maxclients->integer ; i++ ) {
cl = &svs.clients[i];
if (cl->netchan.remoteAddress.type == NA_BOT) {
count++;
}
}
// if they're all bots
if (count >= sv_maxclients->integer - startIndex) {
SV_DropClient(&svs.clients[sv_maxclients->integer - 1], "only bots on server");
newcl = &svs.clients[sv_maxclients->integer - 1];
}
else {
Com_Error( ERR_FATAL, "server is full on local connect\n" );
return;
}
}
else {
const char *SV_GetStringEdString(char *refSection, char *refName);
NET_OutOfBandPrint( NS_SERVER, from, va("print\n%s\n", SV_GetStringEdString("MP_SVGAME","SERVER_IS_FULL")));
Com_DPrintf ("Rejected a connection.\n");
return;
}
}
// we got a newcl, so reset the reliableSequence and reliableAcknowledge
cl->reliableAcknowledge = 0;
cl->reliableSequence = 0;
gotnewcl:
// build a new connection
// accept the new client
// this is the only place a client_t is ever initialized
*newcl = temp;
clientNum = newcl - svs.clients;
ent = SV_GentityNum( clientNum );
newcl->gentity = ent;
// save the challenge
newcl->challenge = challenge;
// save the address
Netchan_Setup (NS_SERVER, &newcl->netchan , from, qport);
// save the userinfo
Q_strncpyz( newcl->userinfo, userinfo, sizeof(newcl->userinfo) );
// get the game a chance to reject this connection or modify the userinfo
denied = (char *)VM_Call( gvm, GAME_CLIENT_CONNECT, clientNum, qtrue, qfalse ); // firstTime = qtrue
if ( denied ) {
// we can't just use VM_ArgPtr, because that is only valid inside a VM_Call
denied = (char *)VM_ExplicitArgPtr( gvm, (int)denied );
NET_OutOfBandPrint( NS_SERVER, from, "print\n%s\n", denied );
Com_DPrintf ("Game rejected a connection: %s.\n", denied);
return;
}
SV_UserinfoChanged( newcl );
// send the connect packet to the client
NET_OutOfBandPrint( NS_SERVER, from, "connectResponse" );
Com_DPrintf( "Going from CS_FREE to CS_CONNECTED for %s\n", newcl->name );
newcl->state = CS_CONNECTED;
newcl->nextSnapshotTime = svs.time;
newcl->lastPacketTime = svs.time;
newcl->lastConnectTime = svs.time;
// 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
newcl->gamestateMessageNum = -1;
newcl->lastUserInfoChange = 0; //reset the delay
newcl->lastUserInfoCount = 0; //reset the count
// if this was the first client on the server, or the last client
// the server can hold, send a heartbeat to the master.
count = 0;
for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++) {
if ( svs.clients[i].state >= CS_CONNECTED ) {
count++;
}
}
if ( count == 1 || count == sv_maxclients->integer ) {
SV_Heartbeat_f();
}
}
示例7: SV_SpawnServer
//.........这里部分代码省略.........
sv.serverId = com_frameTime;
sv.restartedServerId = sv.serverId; // I suppose the init here is just to be safe
sv.checksumFeedServerId = sv.serverId;
Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );
// clear physics interaction links
SV_ClearWorld ();
// media configstring setting should be done during
// the loading stage, so connected clients don't have
// to load during actual gameplay
sv.state = SS_LOADING;
// load and spawn all other entities
SV_InitGameProgs();
// run a few frames to allow everything to settle
for (i = 0;i < 3; i++)
{
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
sv.time += 100;
svs.time += 100;
}
// create a baseline for more efficient communications
SV_CreateBaseline ();
for (i=0 ; i<sv_maxclients->integer ; i++) {
// send the new gamestate to all connected clients
if (svs.clients[i].state >= CS_CONNECTED) {
char *denied;
// connect the client again
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse ) ); // firstTime = qfalse
if ( denied ) {
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( &svs.clients[i], denied );
} else {
// when we get the next packet from a connected client,
// the new gamestate will be sent
svs.clients[i].state = CS_CONNECTED;
}
}
}
// run another frame to allow things to look at all the players
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
sv.time += 100;
svs.time += 100;
// if a dedicated server we need to touch the cgame because it could be in a
// seperate pk3 file and the client will need to load the latest cgame.qvm
if ( com_dedicated->integer ) {
SV_TouchCGame();
}
// the server sends these to the clients so they will only
// load pk3s also loaded at the server
Cvar_Set( "sv_paks", sv_pure->integer ? FS_LoadedPakChecksums() : "" );
Cvar_Set( "sv_pakNames", sv_pure->integer ? FS_LoadedPakNames() : "" );
// the server sends these to the clients so they can figure
// out which pk3s should be auto-downloaded
p = FS_ReferencedPakChecksums();
Cvar_Set( "sv_referencedPaks", p );
示例8: SV_MapRestart_f
//.........这里部分代码省略.........
Q_strncpyz(mapname, Cvar_VariableString("mapname"), sizeof(mapname));
SV_SpawnServer(mapname);
return;
}
SV_DemoStopAll();
// toggle the server bit so clients can detect that a
// map_restart has happened
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// generate a new serverid
// don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
sv.serverId = com_frameTime;
Cvar_Set("sv_serverid", va("%i", sv.serverId));
// reset all the vm data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
// had been changed from their default values will generate broadcast updates
sv.state = SS_LOADING;
sv.restarting = qtrue;
SV_RestartGameProgs();
// run a few frames to allow everything to settle
for (i = 0; i < GAME_INIT_FRAMES; i++)
{
VM_Call(gvm, GAME_RUN_FRAME, svs.time);
svs.time += FRAMETIME;
}
sv.state = SS_GAME;
sv.restarting = qfalse;
// connect and begin all the clients
for (i = 0 ; i < sv_maxclients->integer ; i++)
{
client = &svs.clients[i];
// send the new gamestate to all connected clients
if (client->state < CS_CONNECTED)
{
continue;
}
if (client->netchan.remoteAddress.type == NA_BOT)
{
isBot = qtrue;
}
else
{
isBot = qfalse;
}
// add the map_restart command
SV_AddServerCommand(client, "map_restart\n");
// connect the client again, without the firstTime flag
denied = VM_ExplicitArgPtr(gvm, VM_Call(gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot));
if (denied)
{
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient(client, denied);
if (!isBot)
{
Com_Printf("SV_MapRestart_f(%d): dropped client %i - denied!\n", delay, i); // bk010125
}
continue;
}
// Player won't enter the world until the download is done
if (client->download == 0)
{
if (client->state == CS_ACTIVE)
{
SV_ClientEnterWorld(client, &client->lastUsercmd);
}
else
{
// If we don't reset client->lastUsercmd and are restarting during map load,
// the client will hang because we'll use the last Usercmd from the previous map,
// which is wrong obviously.
SV_ClientEnterWorld(client, NULL);
}
}
}
// run another frame to allow things to look at all the players
VM_Call(gvm, GAME_RUN_FRAME, svs.time);
svs.time += FRAMETIME;
// start recording a demo
if (sv_autoDemo->integer)
{
SV_DemoAutoDemoRecord();
}
}
示例9: SV_MapRestart_f
//.........这里部分代码省略.........
if ( delay ) {
sv.restartTime = svs.time + delay * 1000;
SV_SetConfigstring( CS_WARMUP, va( "%i", sv.restartTime ) );
return;
}
// NERVE - SMF - read in gamestate or just default to GS_PLAYING
old_gs = atoi( Cvar_VariableString( "gamestate" ) );
if ( Cmd_Argc() > 2 ) {
new_gs = atoi( Cmd_Argv( 2 ) );
} else {
new_gs = GS_PLAYING;
}
if ( !SV_TransitionGameState( new_gs, old_gs, delay ) ) {
return;
}
// check for changes in variables that can't just be restarted
// check for maxclients change
if ( sv_maxclients->modified ) {
char mapname[MAX_QPATH];
Com_Printf( "sv_maxclients variable change -- restarting.\n" );
// restart the map the slow way
Q_strncpyz( mapname, Cvar_VariableString( "mapname" ), sizeof( mapname ) );
SV_SpawnServer( mapname, qfalse );
return;
}
// toggle the server bit so clients can detect that a
// map_restart has happened
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// generate a new serverid
// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
sv.serverId = com_frameTime;
Cvar_Set( "sv_serverid", va( "%i", sv.serverId ) );
// reset all the vm data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
// had been changed from their default values will generate broadcast updates
sv.state = SS_LOADING;
sv.restarting = qtrue;
Cvar_Set( "sv_serverRestarting", "1" );
SV_RestartGameProgs();
// run a few frames to allow everything to settle
for ( i = 0 ; i < 3 ; i++ ) {
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
svs.time += 100;
}
sv.state = SS_GAME;
sv.restarting = qfalse;
// connect and begin all the clients
for ( i = 0 ; i < sv_maxclients->integer ; i++ ) {
client = &svs.clients[i];
// send the new gamestate to all connected clients
if ( client->state < CS_CONNECTED ) {
continue;
}
if ( client->netchan.remoteAddress.type == NA_BOT ) {
isBot = qtrue;
} else {
isBot = qfalse;
}
// add the map_restart command
SV_AddServerCommand( client, "map_restart\n" );
// connect the client again, without the firstTime flag
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) );
if ( denied ) {
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( client, denied );
Com_Printf( "SV_MapRestart_f(%d): dropped client %i - denied!\n", delay, i ); // bk010125
continue;
}
client->state = CS_ACTIVE;
SV_ClientEnterWorld( client, &client->lastUsercmd );
}
// run another frame to allow things to look at all the players
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
svs.time += 100;
Cvar_Set( "sv_serverRestarting", "0" );
}
示例10: SV_MapRestart_f
//.........这里部分代码省略.........
}
size = FS_ReadFile(savemap, NULL);
if(size < 0) {
Com_Printf("Can't find savegame %s\n", savemap);
return;
}
//buffer = Hunk_AllocateTempMemory(size);
FS_ReadFile(savemap, (void **)&buffer);
// the mapname is at the very start of the savegame file
savegameTime = *(int *)(buffer + sizeof(int) + MAX_QPATH);
if(savegameTime >= 0) {
svs.time = savegameTime;
}
Hunk_FreeTempMemory(buffer);
}
// done.
// toggle the server bit so clients can detect that a
// map_restart has happened
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// generate a new serverid
// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
sv.serverId = com_frameTime;
Cvar_Set("sv_serverid", va("%i", sv.serverId));
// reset all the vm data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
// had been changed from their default values will generate broadcast updates
sv.state = SS_LOADING;
sv.restarting = qtrue;
Cvar_Set("sv_serverRestarting", "1");
SV_RestartGameProgs();
// run a few frames to allow everything to settle
for(i = 0; i < GAME_INIT_FRAMES; i++)
{
VM_Call(gvm, GAME_RUN_FRAME, svs.time);
svs.time += FRAMETIME;
}
// create a baseline for more efficient communications
// Gordon: meh, this wont work here as the client doesn't know it has happened
// SV_CreateBaseline ();
sv.state = SS_GAME;
sv.restarting = qfalse;
// connect and begin all the clients
for(i = 0; i < sv_maxclients->integer; i++) {
client = &svs.clients[i];
// send the new gamestate to all connected clients
if(client->state < CS_CONNECTED) {
continue;
}
if(client->netchan.remoteAddress.type == NA_BOT) {
if(SV_GameIsSinglePlayer() || SV_GameIsCoop()) {
continue; // dont carry across bots in single player
}
isBot = qtrue;
} else {
isBot = qfalse;
}
// add the map_restart command
SV_AddServerCommand(client, "map_restart\n");
// connect the client again, without the firstTime flag
denied = (char*)VM_ExplicitArgPtr(gvm, VM_Call(gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot));
if(denied)
{
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient(client, denied);
if((!SV_GameIsSinglePlayer()) || (!isBot)) {
Com_Printf("SV_MapRestart_f(%d): dropped client %i - denied!\n", delay, i); // bk010125
}
continue;
}
client->state = CS_ACTIVE;
SV_ClientEnterWorld(client, &client->lastUsercmd);
}
// run another frame to allow things to look at all the players
VM_Call(gvm, GAME_RUN_FRAME, svs.time);
svs.time += FRAMETIME;
Cvar_Set("sv_serverRestarting", "0");
}
示例11: SV_SpawnServer
//.........这里部分代码省略.........
// load and spawn all other entities
SV_InitGameProgs();
// don't allow a map_restart if game is modified
sv_gametype->modified = qfalse;
// run a few frames to allow everything to settle
for ( i = 0 ;i < 3 ; i++ ) {
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
SV_BotFrame( svs.time );
svs.time += 100;
}
// create a baseline for more efficient communications
SV_CreateBaseline ();
for (i=0 ; i<sv_maxclients->integer ; i++) {
// send the new gamestate to all connected clients
if (svs.clients[i].state >= CS_CONNECTED) {
char *denied;
if ( svs.clients[i].netchan.remoteAddress.type == NA_BOT ) {
if ( killBots ) {
SV_DropClient( &svs.clients[i], "" );
continue;
}
isBot = qtrue;
}
else {
isBot = qfalse;
}
// connect the client again
denied = (char *)VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) ); // firstTime = qfalse
if ( denied ) {
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( &svs.clients[i], denied );
} else {
if( !isBot ) {
// when we get the next packet from a connected client,
// the new gamestate will be sent
svs.clients[i].state = CS_CONNECTED;
}
else {
client_t *client;
sharedEntity_t *ent;
client = &svs.clients[i];
client->state = CS_ACTIVE;
ent = SV_GentityNum( i );
ent->s.number = i;
client->gentity = ent;
client->deltaMessage = -1;
client->nextSnapshotTime = svs.time; // generate a snapshot immediately
VM_Call( gvm, GAME_CLIENT_BEGIN, i );
}
}
}
}
// run another frame to allow things to look at all the players
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
SV_BotFrame( svs.time );
示例12: SV_SpawnServer_after_FS_Restart
static void SV_SpawnServer_after_FS_Restart( cb_context_t *context, int status ) {
int i;
int checksum;
qboolean isBot;
char systemInfo[16384];
const char *p;
spawnserver_data_t *data;
cb_context_t *after;
char mapname[MAX_QPATH];
qboolean killBots;
data = (spawnserver_data_t*)context->data;
Q_strncpyz(mapname, data->mapname, MAX_QPATH);
killBots = data->killBots;
after = data->after;
cb_free_context(context);
CM_LoadMap( va("maps/%s.bsp", mapname), qfalse, &checksum );
Cvar_Set( "sv_mapChecksum", va("%i",checksum) );
// serverid should be different each time
sv.serverId = com_frameTime;
sv.restartedServerId = sv.serverId; // I suppose the init here is just to be safe
sv.checksumFeedServerId = sv.serverId;
Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );
// clear physics interaction links
SV_ClearWorld ();
// media configstring setting should be done during
// the loading stage, so connected clients don't have
// to load during actual gameplay
sv.state = SS_LOADING;
// load and spawn all other entities
SV_InitGameProgs();
// don't allow a map_restart if game is modified
sv_gametype->modified = qfalse;
// run a few frames to allow everything to settle
for (i = 0;i < 3; i++)
{
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
SV_BotFrame (sv.time);
sv.time += 100;
svs.time += 100;
}
// create a baseline for more efficient communications
SV_CreateBaseline ();
for (i=0 ; i<sv_maxclients->integer ; i++) {
// send the new gamestate to all connected clients
if (svs.clients[i].state >= CS_CONNECTED) {
char *denied;
if ( svs.clients[i].netchan.remoteAddress.type == NA_BOT ) {
if ( killBots ) {
SV_DropClient( &svs.clients[i], "" );
continue;
}
isBot = qtrue;
}
else {
isBot = qfalse;
}
// connect the client again
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) ); // firstTime = qfalse
if ( denied ) {
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( &svs.clients[i], denied );
} else {
if( !isBot ) {
// when we get the next packet from a connected client,
// the new gamestate will be sent
svs.clients[i].state = CS_CONNECTED;
}
else {
client_t *client;
sharedEntity_t *ent;
client = &svs.clients[i];
client->state = CS_ACTIVE;
ent = SV_GentityNum( i );
ent->s.number = i;
client->gentity = ent;
client->deltaMessage = -1;
client->lastSnapshotTime = 0; // generate a snapshot immediately
VM_Call( gvm, GAME_CLIENT_BEGIN, i );
}
}
}
}
//.........这里部分代码省略.........
示例13: SV_SpawnServer
//.........这里部分代码省略.........
// load and spawn all other entities
SV_InitGameProgs();
// don't allow a map_restart if game is modified
sv_gametype->modified = qfalse;
// run a few frames to allow everything to settle
for ( i = 0 ; i < 3 ; i++ ) {
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
SV_BotFrame( svs.time );
svs.time += 100;
}
// create a baseline for more efficient communications
SV_CreateBaseline ();
for (i=0 ; i<sv_maxclients->integer ; i++) {
// send the new gamestate to all connected clients
if (svs.clients[i].state >= CS_CONNECTED) {
char *denied;
if ( svs.clients[i].netchan.remoteAddress.type == NA_BOT ) {
if ( killBots ) {
SV_DropClient( &svs.clients[i], "" );
continue;
}
isBot = qtrue;
}
else {
isBot = qfalse;
}
// connect the client again
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse, isBot ) ); // firstTime = qfalse
if ( denied ) {
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( &svs.clients[i], denied );
} else {
if( !isBot ) {
// when we get the next packet from a connected client,
// the new gamestate will be sent
svs.clients[i].state = CS_CONNECTED;
}
else {
client_t *client;
sharedEntity_t *ent;
client = &svs.clients[i];
client->state = CS_ACTIVE;
ent = SV_GentityNum( i );
ent->s.number = i;
client->gentity = ent;
client->deltaMessage = -1;
client->nextSnapshotTime = svs.time; // generate a snapshot immediately
VM_Call( gvm, GAME_CLIENT_BEGIN, i );
}
}
}
}
// run another frame to allow things to look at all the players
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
SV_BotFrame( svs.time );
示例14: SV_MapRestart_f
//.........这里部分代码省略.........
Q_strncpyz( mapname, Cvar_VariableString( "mapname" ), sizeof( mapname ) );
SV_SpawnServer( mapname, qfalse );
return;
}
// toggle the server bit so clients can detect that a
// map_restart has happened
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// generate a new serverid
// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
sv.serverId = com_frameTime;
Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );
// if a map_restart occurs while a client is changing maps, we need
// to give them the correct time so that when they finish loading
// they don't violate the backwards time check in cl_cgame.c
for (i=0 ; i<sv_maxclients->integer ; i++) {
if (svs.clients[i].state == CS_PRIMED) {
svs.clients[i].oldServerTime = sv.restartTime;
}
}
// reset all the vm data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
// had been changed from their default values will generate broadcast updates
sv.state = SS_LOADING;
sv.restarting = qtrue;
SV_RestartGameProgs();
// run a few frames to allow everything to settle
for (i = 0; i < 3; i++)
{
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
sv.time += 100;
svs.time += 100;
}
sv.state = SS_GAME;
sv.restarting = qfalse;
// connect and begin all the clients
for (i=0 ; i<sv_maxclients->integer ; i++) {
client = &svs.clients[i];
// send the new gamestate to all connected clients
if ( client->state < CS_CONNECTED) {
continue;
}
if ( client->netchan.remoteAddress.type == NA_BOT ) {
isBot = qtrue;
} else {
isBot = qfalse;
}
// add the map_restart command
SV_AddServerCommand( client, -1, "map_restart\n" );
for ( j = 0; j < MAX_SPLITVIEW; j++ ) {
player = client->localPlayers[j];
if ( !player )
continue;
// setup entity before connecting
SV_SetupPlayerEntity( player );
// connect the client again, without the firstTime flag
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_PLAYER_CONNECT, player - svs.players, qfalse, isBot, client - svs.clients, j ) );
player = client->localPlayers[j]; // may be NULL if game dropped player
if ( denied ) {
// this generally shouldn't happen, because the player
// was connected before the level change
if ( player != NULL ) {
SV_DropPlayer( player, denied );
}
Com_Printf( "SV_MapRestart_f: dropped client %i - denied!\n", i );
continue;
}
if(client->state == CS_ACTIVE)
SV_PlayerEnterWorld( player, &player->lastUsercmd );
else
{
// If we don't reset player->lastUsercmd and are restarting during map load,
// the client will hang because we'll use the last Usercmd from the previous map,
// which is wrong obviously.
SV_PlayerEnterWorld( player, NULL );
}
}
}
// run another frame to allow things to look at all the players
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
sv.time += 100;
svs.time += 100;
}
示例15: SV_MapRestart_f
//.........这里部分代码省略.........
if (Cmd_Argc() > 1 ) {
delay = atoi( Cmd_Argv(1) );
}
else {
delay = 5;
}
if( delay && !Cvar_VariableValue("g_doWarmup") ) {
sv.restartTime = sv.time + delay * 1000;
SV_SetConfigstring( CS_WARMUP, va("%i", sv.restartTime) );
return;
}
// check for changes in variables that can't just be restarted
// check for maxclients change
if ( sv_maxclients->modified ) {
char mapname[MAX_QPATH];
Com_Printf( "variable change -- restarting.\n" );
// restart the map the slow way
Q_strncpyz( mapname, Cvar_VariableString( "mapname" ), sizeof( mapname ) );
SV_SpawnServer( mapname, qfalse );
return;
}
// toggle the server bit so clients can detect that a
// map_restart has happened
svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;
// generate a new serverid
// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
sv.serverId = com_frameTime;
Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );
// if a map_restart occurs while a client is changing maps, we need
// to give them the correct time so that when they finish loading
// they don't violate the backwards time check in cl_cgame.c
for (i=0 ; i<sv_maxclients->integer ; i++) {
if (svs.clients[i].state == CS_PRIMED) {
svs.clients[i].oldServerTime = sv.restartTime;
}
}
// reset all the vm data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
// had been changed from their default values will generate broadcast updates
sv.state = SS_LOADING;
sv.restarting = qtrue;
SV_RestartGameProgs();
// run a few frames to allow everything to settle
for (i = 0; i < 3; i++)
{
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
sv.time += 100;
svs.time += 100;
}
sv.state = SS_GAME;
sv.restarting = qfalse;
// connect and begin all the clients
for (i=0 ; i<sv_maxclients->integer ; i++) {
client = &svs.clients[i];
// send the new gamestate to all connected clients
if ( client->state < CS_CONNECTED) {
continue;
}
// add the map_restart command
SV_AddServerCommand( client, "map_restart\n" );
// connect the client again, without the firstTime flag
denied = VM_ExplicitArgPtr( gvm, VM_Call( gvm, GAME_CLIENT_CONNECT, i, qfalse ) );
if ( denied ) {
// this generally shouldn't happen, because the client
// was connected before the level change
SV_DropClient( client, denied );
Com_Printf( "SV_MapRestart_f(%d): dropped client %i - denied!\n", delay, i );
continue;
}
if(client->state == CS_ACTIVE)
SV_ClientEnterWorld(client, &client->lastUsercmd);
else
{
// If we don't reset client->lastUsercmd and are restarting during map load,
// the client will hang because we'll use the last Usercmd from the previous map,
// which is wrong obviously.
SV_ClientEnterWorld(client, NULL);
}
}
// run another frame to allow things to look at all the players
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
sv.time += 100;
svs.time += 100;
}