for (players = 0, j = 0;j < svs.maxclients;j++)
if (svs.clients[j].active)
players++;
- print ("host: %s\n", Cvar_VariableString ("hostname"));
- print ("version: %s build %s\n", gamename, buildstring);
+ print ("host: %s\n", Cvar_VariableString ("hostname"));
+ print ("version: %s build %s\n", gamename, buildstring);
switch(sv.protocol)
{
case PROTOCOL_QUAKE: protocolname = sv.netquakecompatible ? "QUAKE" : "QUAKEDP";break;
default: protocolname = "PROTOCOL_UNKNOWN";break;
}
print ("protocol: %i (%s)\n", sv.protocol, protocolname);
- print ("map: %s\n", sv.name);
- print ("players: %i active (%i max)\n\n", players, svs.maxclients);
+ print ("map: %s\n", sv.name);
+ print ("players: %i active (%i max)\n\n", players, svs.maxclients);
for (j = 0, client = svs.clients;j < svs.maxclients;j++, client++)
{
if (!client->active)
if (cmd_source != src_command)
return;
- SCR_BeginLoadingPlaque ();
cls.demonum = -1; // stop demo loop in case this fails
CL_Disconnect ();
void Host_Changelevel_f (void)
{
char level[MAX_QPATH];
-
+
if (Cmd_Argc() != 2)
{
Con_Print("changelevel <levelname> : continue game on a new level\n");
key_consoleactive = 0;
SV_SaveSpawnparms ();
- SCR_BeginLoadingPlaque();
allowcheats = sv_cheats.integer != 0;
strcpy(level, Cmd_Argv(1));
SV_SpawnServer(level);
void Host_Restart_f (void)
{
char mapname[MAX_QPATH];
-
+
if (Cmd_Argc() != 1)
{
Con_Print("restart : restart current level\n");
key_dest = key_game;
key_consoleactive = 0;
- SCR_BeginLoadingPlaque();
allowcheats = sv_cheats.integer != 0;
strcpy(mapname, sv.name);
SV_SpawnServer(mapname);
//Con_Print("reconnect: no signon, ignoring reconnect\n");
return;
}
- SCR_BeginLoadingPlaque();
cls.signon = 0; // need new connection messages
}
FS_DefaultExtension (name, ".sav", sizeof (name));
Con_Printf("Saving game to %s...\n", name);
- f = FS_Open (name, "w", false);
+ f = FS_Open (name, "wb", false, false);
if (!f)
{
Con_Print("ERROR: couldn't open.\n");
FS_Printf(f, "%s\n", sv.name);
FS_Printf(f, "%f\n",sv.time);
-// write the light styles
-
+ // write the light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
{
if (sv.lightstyles[i])
FS_Print(f,"m\n");
}
-
ED_WriteGlobals (f);
for (i=0 ; i<sv.num_edicts ; i++)
- {
ED_Write (f, EDICT_NUM(i));
- FS_Flush (f);
- }
FS_Close (f);
Con_Print("done.\n");
}
-extern mempool_t *edictstring_mempool;
-
/*
===============
Host_Loadgame_f
*/
void Host_Loadgame_f (void)
{
- qfile_t *f;
char filename[MAX_QPATH];
char mapname[MAX_QPATH];
- float time, tfloat;
- char buf[32768];
+ float time;
const char *start;
- char *str;
- int i, r;
+ const char *t;
+ char *text;
edict_t *ent;
+ int i;
int entnum;
int version;
float spawn_parms[NUM_SPAWN_PARMS];
cls.demonum = -1; // stop demo loop in case this fails
- f = FS_Open (filename, "r", false);
- if (!f)
+ t = text = FS_LoadFile (filename, tempmempool, false);
+ if (!text)
{
Con_Print("ERROR: couldn't open.\n");
return;
}
- str = FS_Getline (f);
- sscanf (str, "%i\n", &version);
+ // version
+ COM_ParseToken(&t, false);
+ version = atoi(com_token);
if (version != SAVEGAME_VERSION)
{
- FS_Close (f);
+ Mem_Free(text);
Con_Printf("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
return;
}
- SCR_BeginLoadingPlaque ();
+ // description
+ // this is a little hard to parse, as : is a separator in COM_ParseToken,
+ // so use the console parser instead
+ COM_ParseTokenConsole(&t);
- str = FS_Getline (f);
for (i = 0;i < NUM_SPAWN_PARMS;i++)
{
- str = FS_Getline (f);
- sscanf (str, "%f\n", &spawn_parms[i]);
+ COM_ParseToken(&t, false);
+ spawn_parms[i] = atof(com_token);
}
+ // skill
+ COM_ParseToken(&t, false);
// this silliness is so we can load 1.06 save files, which have float skill values
- str = FS_Getline (f);
- sscanf (str, "%f\n", &tfloat);
- current_skill = (int)(tfloat + 0.1);
+ current_skill = (int)(atof(com_token) + 0.5);
Cvar_SetValue ("skill", (float)current_skill);
- strcpy (mapname, FS_Getline (f));
+ // mapname
+ COM_ParseToken(&t, false);
+ strcpy (mapname, com_token);
- str = FS_Getline (f);
- sscanf (str, "%f\n",&time);
+ // time
+ COM_ParseToken(&t, false);
+ time = atof(com_token);
allowcheats = sv_cheats.integer != 0;
+
SV_SpawnServer (mapname);
if (!sv.active)
{
+ Mem_Free(text);
Con_Print("Couldn't load map\n");
return;
}
for (i = 0;i < MAX_LIGHTSTYLES;i++)
{
- str = FS_Getline (f);
- sv.lightstyles[i] = Mem_Alloc(edictstring_mempool, strlen(str)+1);
- strcpy (sv.lightstyles[i], str);
+ // light style
+ COM_ParseToken(&t, false);
+ sv.lightstyles[i] = PR_Alloc(strlen(com_token)+1);
+ strcpy(sv.lightstyles[i], com_token);
}
// load the edicts out of the savegame file
entnum = -1;
for (;;)
{
- r = EOF;
- for (i = 0;i < (int)sizeof(buf) - 1;i++)
- {
- r = FS_Getc (f);
- if (r == EOF || !r)
+ start = t;
+ while (COM_ParseToken(&t, false))
+ if (!strcmp(com_token, "}"))
break;
- buf[i] = r;
- if (r == '}')
- {
- i++;
- break;
- }
- }
- if (r == EOF)
- break;
- if (i == sizeof(buf)-1)
- Host_Error ("Loadgame buffer overflow");
- buf[i] = 0;
- start = buf;
if (!COM_ParseToken(&start, false))
{
// end of file
break;
}
if (strcmp(com_token,"{"))
+ {
+ Mem_Free(text);
Host_Error ("First token isn't a brace");
+ }
if (entnum == -1)
{
{
// parse an edict
if (entnum >= MAX_EDICTS)
+ {
+ Mem_Free(text);
Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)\n", MAX_EDICTS);
+ }
while (entnum >= sv.max_edicts)
SV_IncreaseEdicts();
ent = EDICT_NUM(entnum);
sv.num_edicts = entnum;
sv.time = time;
- FS_Close (f);
-
for (i = 0;i < NUM_SPAWN_PARMS;i++)
svs.clients[0].spawn_parms[i] = spawn_parms[i];
SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
return;
}
-
+
host_client->nametime = sv.time + 5;
// point the string back at updateclient->name to keep it safe
}
}
+/*
+======================
+Host_Playermodel_f
+======================
+*/
+cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", ""};
+// the old cl_playermodel in cl_main has been renamed to __cl_playermodel
+void Host_Playermodel_f (void)
+{
+ int i, j;
+ char newPath[sizeof(host_client->playermodel)];
+
+ if (Cmd_Argc () == 1)
+ {
+ Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
+ return;
+ }
+
+ if (Cmd_Argc () == 2)
+ strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
+ else
+ strlcpy (newPath, Cmd_Args(), sizeof (newPath));
+
+ for (i = 0, j = 0;newPath[i];i++)
+ if (newPath[i] != '\r' && newPath[i] != '\n')
+ newPath[j++] = newPath[i];
+ newPath[j] = 0;
+
+ if (cmd_source == src_command)
+ {
+ Cvar_Set ("_cl_playermodel", newPath);
+ if (cls.state == ca_connected)
+ Cmd_ForwardToServer ();
+ return;
+ }
+
+ /*
+ if (sv.time < host_client->nametime)
+ {
+ SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
+ return;
+ }
+
+ host_client->nametime = sv.time + 5;
+ */
+
+ // point the string back at updateclient->name to keep it safe
+ strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
+ if( eval_playermodel )
+ GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PR_SetString(host_client->playermodel);
+ if (strcmp(host_client->old_model, host_client->playermodel))
+ {
+ if (host_client->spawned)
+ SV_BroadcastPrintf("%s changed model to %s\n", host_client->old_model, host_client->playermodel);
+ strcpy(host_client->old_model, host_client->playermodel);
+ /*// send notification to all clients
+ MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
+ MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
+ MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
+ }
+}
+
+/*
+======================
+Host_Playerskin_f
+======================
+*/
+cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", ""};
+void Host_Playerskin_f (void)
+{
+ int i, j;
+ char newPath[sizeof(host_client->playerskin)];
+
+ if (Cmd_Argc () == 1)
+ {
+ Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
+ return;
+ }
+
+ if (Cmd_Argc () == 2)
+ strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
+ else
+ strlcpy (newPath, Cmd_Args(), sizeof (newPath));
+
+ for (i = 0, j = 0;newPath[i];i++)
+ if (newPath[i] != '\r' && newPath[i] != '\n')
+ newPath[j++] = newPath[i];
+ newPath[j] = 0;
+
+ if (cmd_source == src_command)
+ {
+ Cvar_Set ("_cl_playerskin", newPath);
+ if (cls.state == ca_connected)
+ Cmd_ForwardToServer ();
+ return;
+ }
+
+ /*
+ if (sv.time < host_client->nametime)
+ {
+ SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
+ return;
+ }
+
+ host_client->nametime = sv.time + 5;
+ */
+
+ // point the string back at updateclient->name to keep it safe
+ strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
+ if( eval_playerskin )
+ GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PR_SetString(host_client->playerskin);
+ if (strcmp(host_client->old_skin, host_client->playerskin))
+ {
+ if (host_client->spawned)
+ SV_BroadcastPrintf("%s changed skin to %s\n", host_client->old_skin, host_client->playerskin);
+ strcpy(host_client->old_skin, host_client->playerskin);
+ /*// send notification to all clients
+ MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
+ MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
+ MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
+ }
+}
void Host_Version_f (void)
{
p1++;
}
if (!fromServer)
- snprintf (text, sizeof(text), "%c%s: %s", 1, host_client->name, p1);
+ dpsnprintf (text, sizeof(text), "%c%s: %s", 1, host_client->name, p1);
else
- snprintf (text, sizeof(text), "%c<%s> %s", 1, hostname.string, p1);
+ dpsnprintf (text, sizeof(text), "%c<%s> %s", 1, hostname.string, p1);
p2 = text + strlen(text);
while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
{
SV_ClientPrint(text);
host_client = save;
- Sys_Print(&text[1]);
+ //Con_Print(&text[1]);
}
PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
- Sys_Printf("%s entered the game\n", host_client->name);
+ Con_Printf("%s entered the game\n", host_client->name);
PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
}
Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
c = MAX_DEMOS;
}
- Con_DPrintf("%i demo(s) in loop\n", c);
+ Con_Printf("%i demo(s) in loop\n", c);
for (i=1 ; i<c+1 ; i++)
strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
if (svs.clients)
Mem_Free(svs.clients);
svs.maxclients = n;
- svs.clients = Mem_Alloc(sv_clients_mempool, sizeof(client_t) * svs.maxclients);
+ svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
if (n == 1)
Cvar_Set ("deathmatch", "0");
else
Cvar_RegisterVariable (&cl_pmodel);
Cmd_AddCommand ("pmodel", Host_PModel_f);
}
+
+ // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
+ Cvar_RegisterVariable (&cl_playermodel);
+ Cmd_AddCommand ("playermodel", Host_Playermodel_f);
+ Cvar_RegisterVariable (&cl_playerskin);
+ Cmd_AddCommand ("playerskin", Host_Playerskin_f);
+
Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
Cmd_AddCommand ("spawn", Host_Spawn_f);
Cmd_AddCommand ("begin", Host_Begin_f);