*/
void Host_Ping_f (void)
{
- int i;
- client_t *client;
+ int i;
+ client_t *client;
+ void (*print) (const char *fmt, ...);
if (cmd_source == src_command)
{
- Cmd_ForwardToServer ();
- return;
+ if (!sv.active)
+ {
+ Cmd_ForwardToServer ();
+ return;
+ }
+ print = Con_Printf;
}
+ else
+ print = SV_ClientPrintf;
- SV_ClientPrint("Client ping times:\n");
+ print("Client ping times:\n");
for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
{
if (!client->active)
continue;
- SV_ClientPrintf("%4i %s\n", (int)(client->ping*1000), client->name);
+ print("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
}
}
Con_Print("changelevel <levelname> : continue game on a new level\n");
return;
}
- if (!sv.active || cls.demoplayback)
+ // HACKHACKHACK
+ if (!sv.active) {
+ Host_Map_f();
+ return;
+ }
+ if (cls.demoplayback)
{
Con_Print("Only the server may changelevel\n");
return;
*/
void Host_Reconnect_f (void)
{
+ if (cmd_source == src_command)
+ {
+ Con_Print("reconnect is not valid from the console\n");
+ return;
+ }
if (Cmd_Argc() != 1)
{
Con_Print("reconnect : wait for signon messages again\n");
for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
text[i] = ' ';
- memcpy (text, cl.levelname, strlen(cl.levelname));
+ // LordHavoc: added min() to prevent overflow
+ memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
memcpy (text+22, kills, strlen(kills));
-// convert space to _ to make stdio happy
+ // convert space to _ to make stdio happy
+ // LordHavoc: convert control characters to _ as well
for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
- if (text[i] == ' ')
+ if (text[i] <= ' ')
text[i] = '_';
text[SAVEGAME_COMMENT_LENGTH] = '\0';
}
*/
void Host_Savegame_f (void)
{
- char name[256];
+ char name[MAX_QPATH];
qfile_t *f;
int i;
char comment[SAVEGAME_COMMENT_LENGTH+1];
cls.demonum = -1; // stop demo loop in case this fails
- t = text = FS_LoadFile (filename, tempmempool, false);
+ t = text = (char *)FS_LoadFile (filename, tempmempool, false, NULL);
if (!text)
{
Con_Print("ERROR: couldn't open.\n");
if (entnum >= MAX_EDICTS)
{
Mem_Free(text);
- Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)\n", MAX_EDICTS);
+ Host_Error("Host_PerformLoadGame: too many edicts in save file (reached MAX_EDICTS %i)", MAX_EDICTS);
}
while (entnum >= prog->max_edicts)
//SV_IncreaseEdicts();
PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(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->name, host_client->playermodel);
strcpy(host_client->old_model, host_client->playermodel);
/*// send notification to all clients
MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
int j, quoted;
const char *p1;
char *p2;
- // LordHavoc: 256 char say messages
- unsigned char text[256];
+ // LordHavoc: long say messages
+ char text[1024];
qboolean fromServer = false;
if (cmd_source == src_command)
p1++;
}
if (!fromServer)
- dpsnprintf (text, sizeof(text), "%c%s: %s", 1, host_client->name, p1);
+ dpsnprintf (text, sizeof(text), "%c%s" STRING_COLOR_DEFAULT_STR ": %s", 1, host_client->name, p1);
else
- dpsnprintf (text, sizeof(text), "%c<%s> %s", 1, hostname.string, p1);
+ dpsnprintf (text, sizeof(text), "%c<%s" STRING_COLOR_DEFAULT_STR "> %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)))
{
client_t *save;
int j;
const char *p1, *p2;
- char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
+ char text[MAX_INPUTLINE]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
qboolean fromServer = false;
if (cmd_source == src_command)
}
while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
p2--;
- for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
+ for (j = (int)strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
text[j++] = *p1++;
text[j++] = '\n';
text[j++] = 0;
======================
Host_PModel_f
LordHavoc: only supported for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
+LordHavoc: correction, Mindcrime will be removing pmodel in the future, but it's still stuck here for compatibility.
======================
*/
cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0"};
}
else
{
- // set up the edict
- PRVM_ED_ClearEdict(host_client->edict);
-
//Con_Printf("Host_Spawn_f: host_client->edict->netname = %s, host_client->edict->netname = %s, host_client->name = %s\n", PRVM_GetString(host_client->edict->fields.server->netname), PRVM_GetString(host_client->edict->fields.server->netname), host_client->name);
// copy spawn parms out of the client_t
// send all current light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
{
- MSG_WriteByte (&host_client->message, svc_lightstyle);
- MSG_WriteByte (&host_client->message, (char)i);
- MSG_WriteString (&host_client->message, sv.lightstyles[i]);
+ if (sv.lightstyles[i][0])
+ {
+ MSG_WriteByte (&host_client->message, svc_lightstyle);
+ MSG_WriteByte (&host_client->message, (char)i);
+ MSG_WriteString (&host_client->message, sv.lightstyles[i]);
+ }
}
// send some stats
return;
m = Mod_ForName (Cmd_Argv(1), false, true, false);
- if (!m)
+ if (!m || !m->loaded || !m->Draw)
{
- Con_Printf("Can't load %s\n", Cmd_Argv(1));
+ Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
return;
}
{
int i, c;
- if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
+ if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-demolooponly"))
return;
c = Cmd_Argc() - 1;
if (svs.clients)
Mem_Free(svs.clients);
svs.maxclients = n;
- svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
+ svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
if (n == 1)
Cvar_Set ("deathmatch", "0");
else