*/
void Host_Ping_f (void)
{
- int i, j;
- float total;
+ int i;
client_t *client;
if (cmd_source == src_command)
{
if (!client->active)
continue;
- total = 0;
- for (j=0 ; j<NUM_PING_TIMES ; j++)
- total+=client->ping_times[j];
- total /= NUM_PING_TIMES;
- SV_ClientPrintf("%4i %s\n", (int)(total*1000), client->name);
+ SV_ClientPrintf("%4i %s\n", (int)floor(client->ping*1000+0.5), client->name);
}
}
allowcheats = sv_cheats.integer != 0;
strcpy(mapname, sv.name);
SV_SpawnServer(mapname);
- if (sv.active && cls.state == ca_disconnected)
+ if (sv.active && cls.state == ca_disconnected)
{
SV_VM_Begin();
CL_EstablishConnection("local:1");
*/
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");
Con_Print("connect <serveraddress> : connect to a multiplayer game\n");
return;
}
- SV_VM_Begin();
- CL_EstablishConnection("local:1");
- SV_VM_End();
+ if( sv.active ) {
+ SV_VM_Begin();
+ CL_EstablishConnection(Cmd_Argv(1));
+ SV_VM_End();
+ } else {
+ CL_EstablishConnection(Cmd_Argv(1));
+ }
}
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';
}
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);
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)))
{
SV_ClientPrint(text);
host_client = save;
- //Con_Print(&text[1]);
+ if (cls.state == ca_dedicated)
+ Con_Print(&text[1]);
}
void Host_Tell_f(void)
{
client_t *save;
- int j;
+ size_t j;
const char *p1, *p2;
char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
qboolean fromServer = false;
}
while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
p2--;
- for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
+ for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;)
text[j++] = *p1++;
text[j++] = '\n';
text[j++] = 0;
if (cmd_source != src_command || !sv.active)
return;
+ SV_VM_Begin();
save = host_client;
if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
}
host_client = save;
+ SV_VM_End();
}
/*
prvm_edict_t *e;
model_t *m;
+ if (!sv.active)
+ return;
+
+ SV_VM_Begin();
e = FindViewthing ();
+ SV_VM_End();
if (!e)
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 f;
model_t *m;
+ if (!sv.active)
+ return;
+
+ SV_VM_Begin();
e = FindViewthing ();
+ SV_VM_End();
if (!e)
return;
m = cl.model_precache[(int)e->fields.server->modelindex];
prvm_edict_t *e;
model_t *m;
+ if (!sv.active)
+ return;
+
+ SV_VM_Begin();
e = FindViewthing ();
+ SV_VM_End();
if (!e)
return;
m = cl.model_precache[(int)e->fields.server->modelindex];
prvm_edict_t *e;
model_t *m;
+ if (!sv.active)
+ return;
+
+ SV_VM_Begin();
e = FindViewthing ();
+ SV_VM_End();
if (!e)
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;