View previous topic :: View next topic |
Author |
Message |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Wed Aug 11, 2010 3:22 am Post subject: Loading Multiplayer Save Games ... |
|
|
Now I swear that I've seen some people @ Func_Msgboard like Necros or aguirRe (in the past) talk about actually doing this ...
Yet searches in FitzQuake, Enhanced GLQuake and TyrQuake ... you know, teh mappers engines ... have yielded no such sign of such capability ...
Saving multiplayer save games appears to work fine. Loading them doesn't work ...
Code: | /*
===============
Host_Loadgame_f
===============
*/
void Host_Loadgame_f (void)
{
char name[MAX_OSPATH];
FILE *f;
char mapname[MAX_QPATH];
float time, tfloat;
char str[32768], *start;
int i, r;
edict_t *ent;
int entnum;
int version;
float spawn_parms[NUM_SPAWN_PARMS];
if (cmd_source != src_command)
return;
if (Cmd_Argc() != 2)
{
Con_Printf ("load <savename> : load a game\n");
return;
}
cls.demonum = -1; // stop demo loop in case this fails
snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
COM_DefaultExtension (name, ".sav");
// we can't call SCR_BeginLoadingPlaque, because too much stack space has
// been used. The menu calls it before stuffing loadgame command
// SCR_BeginLoadingPlaque ();
Con_Printf ("Loading game from %s...\n", name);
f = fopen (name, "r");
if (!f)
{
Con_Printf ("ERROR: couldn't open save file for reading.\n");
return;
}
fscanf (f, "%i\n", &version);
if (version != SAVEGAME_VERSION)
{
fclose (f);
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
return;
}
fscanf (f, "%s\n", str);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
fscanf (f, "%f\n", &spawn_parms[i]);
// this silliness is so we can load 1.06 save files, which have float skill values
fscanf (f, "%f\n", &tfloat);
current_skill = (int)(tfloat + 0.1);
Cvar_SetValue ("skill", (float)current_skill);
fscanf (f, "%s\n",mapname);
fscanf (f, "%f\n",&time);
CL_Disconnect_f ();
SV_SpawnServer (mapname);
if (!sv.active)
{
Con_Printf ("Couldn't load map\n");
return;
}
sv.paused = true; // pause until all clients connect
sv.loadgame = true;
// load the light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
{
fscanf (f, "%s\n", str);
sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
strcpy (sv.lightstyles[i], str);
}
// load the edicts out of the savegame file
entnum = -1; // -1 is the globals
while (!feof(f))
{
for (i=0 ; i<sizeof(str)-1 ; i++)
{
r = fgetc (f);
if (r == EOF || !r)
break;
str[i] = r;
if (r == '}')
{
i++;
break;
}
}
if (i == sizeof(str)-1)
Sys_Error ("Loadgame buffer overflow");
str[i] = 0;
start = str;
start = COM_Parse(str);
if (!com_token[0])
break; // end of file
if (strcmp(com_token,"{"))
Sys_Error ("First token isn't a brace");
if (entnum == -1)
{ // parse the global vars
ED_ParseGlobals (start);
}
else
{ // parse an edict
ent = EDICT_NUM(entnum);
memset (&ent->v, 0, progs->entityfields * 4);
ent->free = false;
ED_ParseEdict (start, ent);
// link it into the bsp tree
if (!ent->free)
SV_LinkEdict (ent, false);
}
entnum++;
}
sv.num_edicts = entnum;
sv.time = time;
fclose (f);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
svs.clients->spawn_parms[i] = spawn_parms[i];
if (cls.state != ca_dedicated)
{
CL_EstablishConnection ("local");
Host_Reconnect_f ();
}
} |
So ... naturally I checked DarkPlaces.
DarkPlaces can save and restore multiplayer save games.
To be continued .... _________________ Tomorrow Never Dies. I feel this Tomorrow knocking on the door ... |
|
Back to top |
|
 |
leileilol

Joined: 15 Oct 2004 Posts: 1321
|
Posted: Wed Aug 11, 2010 4:13 am Post subject: |
|
|
so can hexen2 _________________
 |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Fri Aug 13, 2010 4:12 am Post subject: |
|
|
Hmm, i'm kinda at a loss. The multiplayer saved game would have to somehow store the progs.dat and possibly the current snapshot of the world/entity list etc. But beyond the realtime of the saved game data everything would just be idle and you would be running around a lifeless game right?? |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Fri Aug 13, 2010 9:14 am Post subject: |
|
|
Things potentially worth saving:
globals (note that this includes time)
ents+fields (duh)
lightstyles (switchable lightstyles, yay)
precache lists (at least if you can precache mid-level or you want to protect against mod versions)
per-player parms (multiplayer = multiple)
state of various cvars (coop+deathmatch+skill+maxplayers)
hub system (if you have one, which you don't)
the only logical difference between a single player and multiplayer save is the maxplayers value. if you save a multiplayer game, you can only load a single player however, thanks to the per-player parms. FTE does save all, so is meant to be able to properly save/restore coop games (player order doesn't matter, but your players need the same names on reload in order to match them to their slots, and they need to be on the server or to connect within a tiny timescale). However, I'm told FTE spawns you in solid stuff... so mneh. _________________ What's a signature? |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2004 phpBB Group
|