int i, k, l, numbuffers, lightstyles = 64;
char comment[SAVEGAME_COMMENT_LENGTH+1];
char line[MAX_INPUTLINE];
- qboolean isserver;
+ qbool isserver;
char *s;
// first we have to figure out if this can be saved in 64 lightstyles
Con_Print("done.\n");
}
+static qbool SV_CanSave(void)
+{
+ prvm_prog_t *prog = SVVM_prog;
+ if(SV_IsLocalServer() == 1)
+ {
+ // singleplayer checks
+ // FIXME: This only checks if the first player is dead?
+ if ((svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag)))
+ {
+ Con_Print("Can't savegame with a dead player\n");
+ return false;
+ }
+
+ if(host.hook.CL_Intermission && host.hook.CL_Intermission())
+ {
+ Con_Print("Can't save in intermission.\n");
+ return false;
+ }
+ }
+ else
+ Con_Print(CON_WARN "Warning: saving a multiplayer game may have strange results when restored (to properly resume, all players must join in the same player slots and then the game can be reloaded).\n");
+ return true;
+}
+
/*
===============
SV_Savegame_f
{
prvm_prog_t *prog = SVVM_prog;
char name[MAX_QPATH];
- qboolean deadflag = false;
if (!sv.active)
{
return;
}
- deadflag = cl.islocalgame && svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag);
-
- if (cl.islocalgame)
- {
- // singleplayer checks
- if (cl.intermission)
- {
- Con_Print("Can't save in intermission.\n");
- return;
- }
-
- if (deadflag)
- {
- Con_Print("Can't savegame with a dead player\n");
- return;
- }
- }
- else
- Con_Warn("Warning: saving a multiplayer game may have strange results when restored (to properly resume, all players must join in the same player slots and then the game can be reloaded).\n");
+ if(!SV_CanSave())
+ return;
if (Cmd_Argc(cmd) != 2)
{
return;
}
- strlcpy (name, Cmd_Argv(cmd, 1), sizeof (name));
+ dp_strlcpy (name, Cmd_Argv(cmd, 1), sizeof (name));
FS_DefaultExtension (name, ".sav", sizeof (name));
SV_Savegame_to(prog, name);
return;
}
- strlcpy (filename, Cmd_Argv(cmd, 1), sizeof(filename));
+ dp_strlcpy (filename, Cmd_Argv(cmd, 1), sizeof(filename));
FS_DefaultExtension (filename, ".sav", sizeof (filename));
Con_Printf("Loading game from %s...\n", filename);
- // stop playing demos
- if (cls.demoplayback)
- CL_Disconnect ();
+ if(host.hook.Disconnect)
+ host.hook.Disconnect(false, NULL);
-#ifdef CONFIG_MENU
- // remove menu
- if (key_dest == key_menu || key_dest == key_menu_grabbed)
- MR_ToggleMenu(0);
-#endif
- key_dest = key_game;
+ if(host.hook.ToggleMenu)
+ host.hook.ToggleMenu();
cls.demonum = -1; // stop demo loop in case this fails
// mapname
COM_ParseToken_Simple(&t, false, false, true);
- strlcpy (mapname, com_token, sizeof(mapname));
+ dp_strlcpy (mapname, com_token, sizeof(mapname));
if(developer_entityparsing.integer)
Con_Printf("SV_Loadgame_f: loading time\n");
t = start;
break;
}
- strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
+ dp_strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
}
if(developer_entityparsing.integer)
PRVM_MEM_IncreaseEdicts(prog);
ent = PRVM_EDICT_NUM(entnum);
memset(ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
- ent->priv.server->free = false;
+ ent->free = false;
if(developer_entityparsing.integer)
Con_Printf("SV_Loadgame_f: loading edict %d\n", entnum);
PRVM_ED_ParseEdict (prog, start, ent);
// link it into the bsp tree
- if (!ent->priv.server->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
+ if (!ent->free)
SV_LinkEdict(ent);
}
i = atoi(com_token);
COM_ParseToken_Simple(&t, false, false, true);
if (i >= 0 && i < MAX_LIGHTSTYLES)
- strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
+ dp_strlcpy(sv.lightstyles[i], com_token, sizeof(sv.lightstyles[i]));
else
Con_Printf("unsupported lightstyle %i \"%s\"\n", i, com_token);
}
COM_ParseToken_Simple(&t, false, false, true);
if (i >= 0 && i < MAX_MODELS)
{
- strlcpy(sv.model_precache[i], com_token, sizeof(sv.model_precache[i]));
+ dp_strlcpy(sv.model_precache[i], com_token, sizeof(sv.model_precache[i]));
sv.models[i] = Mod_ForName (sv.model_precache[i], true, false, sv.model_precache[i][0] == '*' ? sv.worldname : NULL);
}
else
i = atoi(com_token);
COM_ParseToken_Simple(&t, false, false, true);
if (i >= 0 && i < MAX_SOUNDS)
- strlcpy(sv.sound_precache[i], com_token, sizeof(sv.sound_precache[i]));
+ dp_strlcpy(sv.sound_precache[i], com_token, sizeof(sv.sound_precache[i]));
else
Con_Printf("unsupported sound %i \"%s\"\n", i, com_token);
}
if (COM_ParseToken_Simple(&t, false, false, true))
k |= atoi(com_token);
if (!BufStr_FindCreateReplace(prog, i, k, "string"))
- Con_Errorf("failed to create stringbuffer %i\n", i);
+ Con_Printf(CON_ERROR "failed to create stringbuffer %i\n", i);
}
else
Con_Printf("unsupported stringbuffer index %i \"%s\"\n", i, com_token);
Con_Printf("unexpected end of line when parsing sv.bufstr (expected strindex)\n");
}
else
- Con_Errorf("failed to create stringbuffer %i \"%s\"\n", i, com_token);
+ Con_Printf(CON_ERROR "failed to create stringbuffer %i \"%s\"\n", i, com_token);
}
}
// skip any trailing text or unrecognized commands
Con_Printf("SV_Loadgame_f: finished\n");
// make sure we're connected to loopback
- if (sv.active && cls.state == ca_disconnected)
- CL_EstablishConnection("local:1", -2);
+ if(sv.active && host.hook.ConnectLocal)
+ host.hook.ConnectLocal();
}