CL_EstablishConnection("local:1", -2);
}
+static qbool CL_Intermission(void)
+{
+ return cl.intermission;
+}
+
/*
==============
CL_PrintEntities_f
CL_Video_Init();
host.hook.ConnectLocal = CL_EstablishConnection_Local;
+ host.hook.CL_Intermission = CL_Intermission;
}
}
struct
{
void (*ConnectLocal)(void);
+ qbool (*CL_Intermission)(void); // Quake compatibility
+ qbool (*SV_CanSave)(void); // Quake compatibility
} hook;
} host_t;
double SV_Frame(double time);
void SV_Shutdown(void);
+int SV_IsLocalGame(void);
+
void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate);
void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation, qbool reliable, float speed);
World_PrintAreaStats(&sv.world, "server");
}
+static qbool SV_CanSave(void)
+{
+ prvm_prog_t *prog = SVVM_prog;
+ if(SV_IsLocalGame() == 1)
+ {
+ // singleplayer checks
+ 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_Init
Cvar_RegisterVariable (&sv_mapformat_is_quake3);
SV_InitOperatorCommands();
+ host.hook.SV_CanSave = SV_CanSave;
sv_mempool = Mem_AllocPool("server", 0, NULL);
}
// SV_UnlockThreadMutex();
}
+/*
+ * Returns number of slots if we're a listen server.
+ * Returns 0 if we're a dedicated server.
+ */
+int SV_IsLocalGame(void)
+{
+ if (sv.active && LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) == LHNETADDRESSTYPE_LOOP)
+ return svs.maxclients;
+ return 0;
+}
+
/*
==================
SV_Shutdown
{
prvm_prog_t *prog = SVVM_prog;
char name[MAX_QPATH];
- qbool deadflag = false;
if (!sv.active)
{
return;
}
- deadflag = cl.islocalgame && svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag);
-
- if (cl.islocalgame)
+ if(host.hook.SV_CanSave)
{
- // 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");
+ if(!host.hook.SV_CanSave())
return;
- }
}
- 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");
if (Cmd_Argc(cmd) != 2)
{