static void Host_Say (qboolean teamonly) { client_t *client; client_t *save; int j; char *p; char text[64]; qboolean fromServer = false; if (cmd_source == src_command) { if (cls.state == ca_dedicated) { fromServer = true; teamonly = false; } else { CL_Cmd_ForwardToServer (); return; } } if (Cmd_Argc () < 2) return; save = host_client; p = Hunk_TempAlloc (strlen (Cmd_Args (1)) + 1); strcpy (p, Cmd_Args (1)); // remove quotes if present if (*p == '"') { p++; p[strlen (p) - 1] = 0; } // turn on color set 1 if (!fromServer) snprintf (text, sizeof (text), "%c%s: ", 1, save->name); else snprintf (text, sizeof (text), "%c<%s> ", 1, hostname->string); j = sizeof (text) - 2 - strlen (text); // -2 for /n and null terminator if ((int) strlen (p) > j) p[j] = 0; strcat (text, p); strcat (text, "\n"); for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) { if (!client || !client->active || !client->spawned) continue; if (teamplay->int_val && teamonly && SVfloat (client->edict, team) != SVfloat (save->edict, team)) continue; host_client = client; SV_ClientPrintf ("%s", text); } host_client = save; Sys_Printf ("%s", &text[1]); }
/* Host_God_f Sets client to godmode */ static void Host_God_f (void) { if (cmd_source == src_command) { CL_Cmd_ForwardToServer (); return; } if (*sv_globals.deathmatch && !host_client->privileged) return; SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) ^ FL_GODMODE; if (!((int) SVfloat (sv_player, flags) & FL_GODMODE)) SV_ClientPrintf ("godmode OFF\n"); else SV_ClientPrintf ("godmode ON\n"); }
static void Host_Notarget_f (void) { if (cmd_source == src_command) { CL_Cmd_ForwardToServer (); return; } if (*sv_globals.deathmatch && !host_client->privileged) return; SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) ^ FL_NOTARGET; if (!((int) SVfloat (sv_player, flags) & FL_NOTARGET)) SV_ClientPrintf ("notarget OFF\n"); else SV_ClientPrintf ("notarget ON\n"); }
static void Host_Viewframe_f (void) { edict_t *e; int f; model_t *m; e = FindViewthing (); if (!e) return; m = cl.model_precache[(int) SVfloat (e, modelindex)]; f = atoi (Cmd_Argv (1)); if (f >= m->numframes) f = m->numframes - 1; SVfloat (e, frame) = f; }
/* SV_God_f Sets client to godmode */ static void SV_God_f (void) { if (!sv_allow_cheats) { SV_Printf ("You must run the server with -cheats to enable this command.\n"); return; } if (!SV_SetPlayer ()) return; SVfloat (sv_player, flags) = (int) SVfloat (sv_player, flags) ^ FL_GODMODE; if (!((int) SVfloat (sv_player, flags) & FL_GODMODE)) SV_ClientPrintf (1, host_client, PRINT_HIGH, "godmode OFF\n"); else SV_ClientPrintf (1, host_client, PRINT_HIGH, "godmode ON\n"); }
/* Host_Fly_f Sets client to flymode */ static void Host_Fly_f (void) { if (cmd_source == src_command) { CL_Cmd_ForwardToServer (); return; } if (*sv_globals.deathmatch && !host_client->privileged) return; if (SVfloat (sv_player, movetype) != MOVETYPE_FLY) { SVfloat (sv_player, movetype) = MOVETYPE_FLY; SV_ClientPrintf ("flymode ON\n"); } else { SVfloat (sv_player, movetype) = MOVETYPE_WALK; SV_ClientPrintf ("flymode OFF\n"); } }
static void Host_Viewmodel_f (void) { edict_t *e; model_t *m; e = FindViewthing (); if (!e) return; m = Mod_ForName (Cmd_Argv (1), false); if (!m) { Sys_Printf ("Can't load %s\n", Cmd_Argv (1)); return; } SVfloat (e, frame) = 0; cl.model_precache[(int) SVfloat (e, modelindex)] = m; }
static void SV_Noclip_f (void) { if (!sv_allow_cheats) { SV_Printf ("You must run the server with -cheats to enable this command.\n"); return; } if (!SV_SetPlayer ()) return; if (SVfloat (sv_player, movetype) != MOVETYPE_NOCLIP) { SVfloat (sv_player, movetype) = MOVETYPE_NOCLIP; SV_ClientPrintf (1, host_client, PRINT_HIGH, "noclip ON\n"); } else { SVfloat (sv_player, movetype) = MOVETYPE_WALK; SV_ClientPrintf (1, host_client, PRINT_HIGH, "noclip OFF\n"); } }
static void Host_Noclip_f (void) { if (cmd_source == src_command) { CL_Cmd_ForwardToServer (); return; } if (*sv_globals.deathmatch && !host_client->privileged) return; if (SVfloat (sv_player, movetype) != MOVETYPE_NOCLIP) { noclip_anglehack = true; SVfloat (sv_player, movetype) = MOVETYPE_NOCLIP; SV_ClientPrintf ("noclip ON\n"); } else { noclip_anglehack = false; SVfloat (sv_player, movetype) = MOVETYPE_WALK; SV_ClientPrintf ("noclip OFF\n"); } }
static void Host_Kill_f (void) { if (cmd_source == src_command) { CL_Cmd_ForwardToServer (); return; } if (SVfloat (sv_player, health) <= 0) { SV_ClientPrintf ("Can't suicide -- already dead!\n"); return; } *sv_globals.time = sv.time; *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player); PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill); }
static void SV_Give_f (void) { const char *t; int v; if (!sv_allow_cheats) { SV_Printf ("You must run the server with -cheats to enable this command.\n"); return; } if (!SV_SetPlayer ()) return; t = Cmd_Argv (2); v = atoi (Cmd_Argv (3)); switch (t[0]) { case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': SVfloat (sv_player, items) = (int) SVfloat (sv_player, items) | IT_SHOTGUN << (t[0] - '2'); break; case 's': SVfloat (sv_player, ammo_shells) = v; break; case 'n': SVfloat (sv_player, ammo_nails) = v; break; case 'r': SVfloat (sv_player, ammo_rockets) = v; break; case 'h': SVfloat (sv_player, health) = v; break; case 'c': SVfloat (sv_player, ammo_cells) = v; break; } }
static void Host_Status_f (void) { client_t *client; int seconds; int minutes; int hours = 0; int j; void (*print) (const char *fmt, ...); if (cmd_source == src_command) { if (!sv.active) { CL_Cmd_ForwardToServer (); return; } print = Sys_Printf; } else print = SV_ClientPrintf; print ("host: %s\n", Cvar_VariableString ("hostname")); print ("version: %4.2f\n", PACKAGE_VERSION); if (tcpipAvailable) print ("tcp/ip: %s\n", my_tcpip_address); print ("map: %s\n", sv.name); print ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients); for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) { if (!client->active) continue; seconds = (int) (net_time - client->netconnection->connecttime); minutes = seconds / 60; if (minutes) { seconds -= (minutes * 60); hours = minutes / 60; if (hours) minutes -= (hours * 60); } else hours = 0; print ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j + 1, client->name, (int) SVfloat (client->edict, frags), hours, minutes, seconds); print (" %s\n", client->netconnection->address); } }
static void Host_Viewnext_f (void) { edict_t *e; model_t *m; e = FindViewthing (); if (!e) return; m = cl.model_precache[(int) SVfloat (e, modelindex)]; SVfloat (e, frame) = SVfloat (e, frame) + 1; if (SVfloat (e, frame) >= m->numframes) SVfloat (e, frame) = m->numframes - 1; PrintFrameName (m, SVfloat (e, frame)); }
static void Host_Viewprev_f (void) { edict_t *e; model_t *m; e = FindViewthing (); if (!e) return; m = cl.model_precache[(int) SVfloat (e, modelindex)]; SVfloat (e, frame) = SVfloat (e, frame) - 1; if (SVfloat (e, frame) < 0) SVfloat (e, frame) = 0; PrintFrameName (m, SVfloat (e, frame)); }
static void Host_Spawn_f (void) { int i; client_t *client; edict_t *ent; float *sendangles; if (cmd_source == src_command) { Sys_Printf ("spawn is not valid from the console\n"); return; } if (host_client->spawned) { Sys_Printf ("Spawn not valid -- already spawned\n"); return; } // run the entrance script if (sv.loadgame) { // loaded games are fully inited already // if this is the last client to be connected, unpause sv.paused = false; } else { // set up the edict ent = host_client->edict; memset (&ent->v, 0, sv_pr_state.progs->entityfields * 4); SVfloat (ent, colormap) = NUM_FOR_EDICT (&sv_pr_state, ent); SVfloat (ent, team) = (host_client->colors & 15) + 1; SVstring (ent, netname) = PR_SetString (&sv_pr_state, host_client->name); // copy spawn parms out of the client_t for (i = 0; i < NUM_SPAWN_PARMS; i++) sv_globals.parms[i] = host_client->spawn_parms[i]; // call the spawn function *sv_globals.time = sv.time; *sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player); PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientConnect); if ((Sys_DoubleTime () - host_client->netconnection->connecttime) <= sv.time) Sys_Printf ("%s entered the game\n", host_client->name); PR_ExecuteProgram (&sv_pr_state, sv_funcs.PutClientInServer); } // send all current names, colors, and frag counts SZ_Clear (&host_client->message); // send time of update MSG_WriteByte (&host_client->message, svc_time); MSG_WriteFloat (&host_client->message, sv.time); for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++) { MSG_WriteByte (&host_client->message, svc_updatename); MSG_WriteByte (&host_client->message, i); MSG_WriteString (&host_client->message, client->name); MSG_WriteByte (&host_client->message, svc_updatefrags); MSG_WriteByte (&host_client->message, i); MSG_WriteShort (&host_client->message, client->old_frags); MSG_WriteByte (&host_client->message, svc_updatecolors); MSG_WriteByte (&host_client->message, i); MSG_WriteByte (&host_client->message, client->colors); } // 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]); } // send some stats MSG_WriteByte (&host_client->message, svc_updatestat); MSG_WriteByte (&host_client->message, STAT_TOTALSECRETS); MSG_WriteLong (&host_client->message, *sv_globals.total_secrets); MSG_WriteByte (&host_client->message, svc_updatestat); MSG_WriteByte (&host_client->message, STAT_TOTALMONSTERS); MSG_WriteLong (&host_client->message, *sv_globals.total_monsters); MSG_WriteByte (&host_client->message, svc_updatestat); MSG_WriteByte (&host_client->message, STAT_SECRETS); MSG_WriteLong (&host_client->message, *sv_globals.found_secrets); MSG_WriteByte (&host_client->message, svc_updatestat); MSG_WriteByte (&host_client->message, STAT_MONSTERS); MSG_WriteLong (&host_client->message, *sv_globals.killed_monsters); // send a fixangle // Never send a roll angle, because savegames can catch the server // in a state where it is expecting the client to correct the angle // and it won't happen if the game was just loaded, so you wind up // with a permanent head tilt ent = EDICT_NUM (&sv_pr_state, 1 + (host_client - svs.clients)); MSG_WriteByte (&host_client->message, svc_setangle); sendangles = sv.loadgame ? SVvector (ent, v_angle): SVvector (ent, angles); MSG_WriteAngle (&host_client->message, sendangles[0]); MSG_WriteAngle (&host_client->message, sendangles[1]); MSG_WriteAngle (&host_client->message, 0); SV_WriteClientdataToMessage (sv_player, &host_client->message); MSG_WriteByte (&host_client->message, svc_signonnum); MSG_WriteByte (&host_client->message, 3); host_client->sendsignon = true; }
void Host_Give_f (void) { char *t; int v; if (cmd_source == src_command) { CL_Cmd_ForwardToServer (); return; } if (*sv_globals.deathmatch && !host_client->privileged) return; t = Cmd_Argv (1); v = atoi (Cmd_Argv (2)); switch (t[0]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': // MED 01/04/97 added hipnotic give stuff if (hipnotic) { if (t[0] == '6') { if (t[1] == 'a') SVfloat (sv_player, items) = (int) SVfloat (sv_player, items) | HIT_PROXIMITY_GUN; else SVfloat (sv_player, items) = (int) SVfloat (sv_player, items) | IT_GRENADE_LAUNCHER; } else if (t[0] == '9') SVfloat (sv_player, items) = (int) SVfloat (sv_player, items) | HIT_LASER_CANNON; else if (t[0] == '0') SVfloat (sv_player, items) = (int) SVfloat (sv_player, items) | HIT_MJOLNIR; else if (t[0] >= '2') SVfloat (sv_player, items) = (int) SVfloat (sv_player, items) | (IT_SHOTGUN << (t[0] - '2')); } else { if (t[0] >= '2') SVfloat (sv_player, items) = (int) SVfloat (sv_player, items) | (IT_SHOTGUN << (t[0] - '2')); } break; case 's': if (rogue) { SVfloat (sv_player, ammo_shells1) = v; } SVfloat (sv_player, ammo_shells) = v; break; case 'n': if (rogue) { SVfloat (sv_player, ammo_nails1) = v; if (SVfloat (sv_player, weapon) <= IT_LIGHTNING) SVfloat (sv_player, ammo_nails) = v; } else { SVfloat (sv_player, ammo_nails) = v; } break; case 'l': if (rogue) { SVfloat (sv_player, ammo_lava_nails) = v; if (SVfloat (sv_player, weapon) > IT_LIGHTNING) SVfloat (sv_player, ammo_nails) = v; } break; case 'r': if (rogue) { SVfloat (sv_player, ammo_rockets1) = v; if (SVfloat (sv_player, weapon) <= IT_LIGHTNING) SVfloat (sv_player, ammo_rockets) = v; } else { SVfloat (sv_player, ammo_rockets) = v; } break; case 'm': if (rogue) { SVfloat (sv_player, ammo_multi_rockets) = 0; if (SVfloat (sv_player, weapon) > IT_LIGHTNING) SVfloat (sv_player, ammo_rockets) = v; } break; case 'h': SVfloat (sv_player, health) = v; break; case 'c': if (rogue) { SVfloat (sv_player, ammo_cells1) = v; if (SVfloat (sv_player, weapon) <= IT_LIGHTNING) SVfloat (sv_player, ammo_cells) = v; } else { SVfloat (sv_player, ammo_cells) = v; } break; case 'p': if (rogue) { SVfloat (sv_player, ammo_plasma) = v; if (SVfloat (sv_player, weapon) > IT_LIGHTNING) SVfloat (sv_player, ammo_cells) = v; } break; } }
void SV_Status_f (void) { int i; client_t *cl; float cpu, avg, pak, demo = 0; const char *s; cpu = (svs.stats.latched_active + svs.stats.latched_idle); if (cpu) { demo = 100 * svs.stats.latched_demo / cpu; cpu = 100 * svs.stats.latched_active / cpu; } avg = 1000 * svs.stats.latched_active / STATFRAMES; pak = (float) svs.stats.latched_packets / STATFRAMES; SV_Printf ("net address : %s\n", NET_AdrToString (net_local_adr)); SV_Printf ("uptime : %s\n", nice_time (Sys_DoubleTime ())); SV_Printf ("cpu utilization : %3i%% (%3i%%)\n", (int) cpu, (int)demo); SV_Printf ("avg response time: %i ms\n", (int) avg); SV_Printf ("packets/frame : %5.2f\n", pak); // min fps lat drp if (sv_redirected != RD_NONE && sv_redirected != RD_MOD) { // most remote clients are 40 columns // 0123456789012345678901234567890123456789 SV_Printf ("name userid frags\n"); SV_Printf (" address rate ping drop\n"); SV_Printf (" ---------------- ---- ---- -----\n"); for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { if (!cl->state) continue; SV_Printf ("%-16.16s ", cl->name); SV_Printf ("%6i %5i", cl->userid, (int) SVfloat (cl->edict, frags)); if (cl->spectator) SV_Printf (" (s)\n"); else SV_Printf ("\n"); s = NET_BaseAdrToString (cl->netchan.remote_address); SV_Printf (" %-16.16s", s); if (cl->state == cs_connected) { SV_Printf ("CONNECTING\n"); continue; } if (cl->state == cs_zombie) { SV_Printf ("ZOMBIE\n"); continue; } if (cl->state == cs_server) { SV_Printf ("SERVER %d\n", cl->ping); continue; } SV_Printf ("%4i %4i %5.2f\n", (int) (1000 * cl->netchan.frame_rate), (int) SV_CalcPing (cl), 100.0 * cl->netchan.drop_count / cl->netchan.incoming_sequence); } } else { SV_Printf ("frags userid address name rate ping " "drop qport\n"); SV_Printf ("----- ------ --------------- --------------- ---- ---- " "----- -----\n"); for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { if (!cl->state) continue; SV_Printf ("%5i %6i ", (int) SVfloat (cl->edict, frags), cl->userid); s = NET_BaseAdrToString (cl->netchan.remote_address); SV_Printf ("%-15.15s ", s); SV_Printf ("%-15.15s ", cl->name); if (cl->state == cs_connected) { SV_Printf ("CONNECTING\n"); continue; } if (cl->state == cs_zombie) { SV_Printf ("ZOMBIE\n"); continue; } if (cl->state == cs_server) { SV_Printf ("SERVER %d\n", cl->ping); continue; } SV_Printf ("%4i %4i %3.1f %4i", (int) (1000 * cl->netchan.frame_rate), (int) SV_CalcPing (cl), 100.0 * cl->netchan.drop_count / cl->netchan.incoming_sequence, cl->netchan.qport); if (cl->spectator) SV_Printf (" (s)\n"); else SV_Printf ("\n"); } } SV_Printf ("\n"); }
static void Host_Savegame_f (void) { dstring_t *name; const char *save_name; char *save_text; QFile *f; int i; char *bup1, *bup2 = 0; if (cmd_source != src_command) return; if (!sv.active) { Sys_Printf ("Not playing a local game.\n"); return; } if (cl.intermission) { Sys_Printf ("Can't save in intermission.\n"); return; } if (svs.maxclients != 1) { Sys_Printf ("Can't save multiplayer games.\n"); return; } if (Cmd_Argc () != 2) { Sys_Printf ("save <savename> : save a game\n"); return; } if (strstr (Cmd_Argv (1), "..")) { Sys_Printf ("Relative pathnames are not allowed.\n"); return; } for (i = 0; i < svs.maxclients; i++) { if (svs.clients[i].active && (SVfloat (svs.clients[i].edict, health) <= 0)) { Sys_Printf ("Can't savegame with a dead player\n"); return; } } save_name = Cmd_Argv (1); name = dstring_newstr (); if (strcmp (save_name, "quick") == 0) { bup2 = nva ("%s/%s%d.sav", qfs_gamedir->dir.def, save_name, MAX_QUICK); QFS_Remove (bup2); for (i = MAX_QUICK - 1; i > 0; i--) { bup1 = nva ("%s/%s%d.sav", qfs_gamedir->dir.def, save_name, i); QFS_Rename (bup1, bup2); free (bup2); bup2 = bup1; } } dsprintf (name, "%s/%s", qfs_gamedir->dir.def, save_name); QFS_DefaultExtension (name, ".sav"); if (bup2) { QFS_Rename (name->str, bup2); free (bup2); } Sys_Printf ("Saving game to %s...\n", name->str); f = QFS_WOpen (name->str, 0); dstring_delete (name); if (!f) { Sys_Printf ("ERROR: couldn't open.\n"); return; } save_text = PL_WritePropertyList (game_dict ()); Qprintf (f, "%s\n%s", PACKAGE_NAME, save_text); free (save_text); Qclose (f); Sys_Printf ("done.\n"); }