cdPlaying = true;
}
-static void CD_f (void)
+static void CD_f(cmd_state_t *cmd)
{
const char *command;
#ifdef MAXTRACKS
int n;
#endif
- command = Cmd_Argv (1);
+ command = Cmd_Argv(cmd, 1);
if (strcasecmp(command, "remap") != 0)
Host_StartVideo();
if (strcasecmp(command, "remap") == 0)
{
#ifdef MAXTRACKS
- ret = Cmd_Argc() - 2;
+ ret = Cmd_Argc(cmd) - 2;
if (ret <= 0)
{
for (n = 1; n < MAXTRACKS; n++)
return;
}
for (n = 1; n <= ret; n++)
- strlcpy(remap[n], Cmd_Argv (n+1), sizeof(*remap));
+ strlcpy(remap[n], Cmd_Argv(cmd, n+1), sizeof(*remap));
#endif
return;
}
{
if (music_playlist_index.integer >= 0)
return;
- CDAudio_Play_byName(Cmd_Argv (2), false, true, (Cmd_Argc() > 3) ? atof( Cmd_Argv(3) ) : 0);
+ CDAudio_Play_byName(Cmd_Argv(cmd, 2), false, true, (Cmd_Argc(cmd) > 3) ? atof( Cmd_Argv(cmd, 3) ) : 0);
return;
}
{
if (music_playlist_index.integer >= 0)
return;
- CDAudio_Play_byName(Cmd_Argv (2), true, true, (Cmd_Argc() > 3) ? atof( Cmd_Argv(3) ) : 0);
+ CDAudio_Play_byName(Cmd_Argv(cmd, 2), true, true, (Cmd_Argc(cmd) > 3) ? atof( Cmd_Argv(cmd, 3) ) : 0);
return;
}
Cvar_RegisterVariable(&music_playlist_sampleposition[i]);
}
- Cmd_AddCommand("cd", CD_f, "execute a CD drive command (cd on/off/reset/remap/close/play/loop/stop/pause/resume/eject/info) - use cd by itself for usage");
+ Cmd_AddCommand(&cmd_client, "cd", CD_f, "execute a CD drive command (cd on/off/reset/remap/close/play/loop/stop/pause/resume/eject/info) - use cd by itself for usage");
+ Cmd_AddCommand(&cmd_clientfromserver, "cd", CD_f, "execute a CD drive command (cd on/off/reset/remap/close/play/loop/stop/pause/resume/eject/info) - use cd by itself for usage");
return 0;
}
}
dpsnprintf (str, sizeof(str), "playdemo %s\n", cls.demos[cls.demonum]);
- Cbuf_InsertText (str);
+ Cbuf_InsertText(&cmd_client, str);
cls.demonum++;
}
if (!cls.demostarting) // only quit if not starting another demo
if (COM_CheckParm("-demo") || COM_CheckParm("-capturedemo"))
- Host_Quit_f();
+ Host_Quit_f(&cmd_client);
}
CL_ParseServerMessage();
if (cls.signon != SIGNONS)
- Cbuf_Execute(); // immediately execute svc_stufftext if in the demo before connect!
+ Cbuf_Execute(&cmd_client); // immediately execute svc_stufftext if in the demo before connect!
// In case the demo contains a "svc_disconnect" message
if (!cls.demoplayback)
stop recording a demo
====================
*/
-void CL_Stop_f (void)
+void CL_Stop_f(cmd_state_t *cmd)
{
sizebuf_t buf;
unsigned char bufdata[64];
record <demoname> <map> [cd track]
====================
*/
-void CL_Record_f (void)
+void CL_Record_f(cmd_state_t *cmd)
{
int c, track;
char name[MAX_OSPATH];
char vabuf[1024];
- c = Cmd_Argc();
+ c = Cmd_Argc(cmd);
if (c != 2 && c != 3 && c != 4)
{
Con_Print("record <demoname> [<map> [cd track]]\n");
return;
}
- if (strstr(Cmd_Argv(1), ".."))
+ if (strstr(Cmd_Argv(cmd, 1), ".."))
{
Con_Print("Relative pathnames are not allowed.\n");
return;
// write the forced cd track number, or -1
if (c == 4)
{
- track = atoi(Cmd_Argv(3));
+ track = atoi(Cmd_Argv(cmd, 3));
Con_Printf("Forcing CD track to %i\n", cls.forcetrack);
}
else
track = -1;
// get the demo name
- strlcpy (name, Cmd_Argv(1), sizeof (name));
+ strlcpy (name, Cmd_Argv(cmd, 1), sizeof (name));
FS_DefaultExtension (name, ".dem", sizeof (name));
// start the map up
if (c > 2)
- Cmd_ExecuteString ( va(vabuf, sizeof(vabuf), "map %s", Cmd_Argv(2)), src_command, false);
+ Cmd_ExecuteString ( cmd, va(vabuf, sizeof(vabuf), "map %s", Cmd_Argv(cmd, 2)), src_command, false);
// open the demo file
Con_Printf("recording to %s.\n", name);
play [demoname]
====================
*/
-void CL_PlayDemo_f (void)
+void CL_PlayDemo_f(cmd_state_t *cmd)
{
char name[MAX_QPATH];
int c;
qboolean neg = false;
qfile_t *f;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("play <demoname> : plays a demo\n");
return;
}
// open the demo file
- strlcpy (name, Cmd_Argv(1), sizeof (name));
+ strlcpy (name, Cmd_Argv(cmd, 1), sizeof (name));
FS_DefaultExtension (name, ".dem", sizeof (name));
f = FS_OpenVirtualFile(name, false);
if (!f)
if(atoi(com_argv[i + 1]) > benchmark_runs)
{
// restart the benchmark
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "timedemo %s\n", cls.demoname));
+ Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", cls.demoname));
// cannot execute here
}
else
}
Z_Free(history);
history = NULL;
- Host_Quit_f();
+ Host_Quit_f(&cmd_client);
}
}
else
- Host_Quit_f();
+ Host_Quit_f(&cmd_client);
}
}
timedemo [demoname]
====================
*/
-void CL_TimeDemo_f (void)
+void CL_TimeDemo_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("timedemo <demoname> : gets demo speeds\n");
return;
srand(0); // predictable random sequence for benchmarking
- CL_PlayDemo_f ();
+ CL_PlayDemo_f (cmd);
// cls.td_starttime will be grabbed at the second frame of the demo, so
// all the loading time doesn't get counted
-static void KeyDown (kbutton_t *b)
+static void KeyDown (cmd_state_t *cmd, kbutton_t *b)
{
int k;
const char *c;
- c = Cmd_Argv(1);
+ c = Cmd_Argv(cmd, 1);
if (c[0])
k = atoi(c);
else
b->state |= 1 + 2; // down + impulse down
}
-static void KeyUp (kbutton_t *b)
+static void KeyUp (cmd_state_t *cmd, kbutton_t *b)
{
int k;
const char *c;
- c = Cmd_Argv(1);
+ c = Cmd_Argv(cmd, 1);
if (c[0])
k = atoi(c);
else
b->state |= 4; // impulse up
}
-static void IN_KLookDown (void) {KeyDown(&in_klook);}
-static void IN_KLookUp (void) {KeyUp(&in_klook);}
-static void IN_MLookDown (void) {KeyDown(&in_mlook);}
-static void IN_MLookUp (void)
+static void IN_KLookDown(cmd_state_t *cmd) {KeyDown(cmd, &in_klook);}
+static void IN_KLookUp(cmd_state_t *cmd) {KeyUp(cmd, &in_klook);}
+static void IN_MLookDown(cmd_state_t *cmd) {KeyDown(cmd, &in_mlook);}
+static void IN_MLookUp(cmd_state_t *cmd)
{
- KeyUp(&in_mlook);
+ KeyUp(cmd, &in_mlook);
if ( !(in_mlook.state&1) && lookspring.value)
- V_StartPitchDrift();
+ V_StartPitchDrift_f(cmd);
}
-static void IN_UpDown(void) {KeyDown(&in_up);}
-static void IN_UpUp(void) {KeyUp(&in_up);}
-static void IN_DownDown(void) {KeyDown(&in_down);}
-static void IN_DownUp(void) {KeyUp(&in_down);}
-static void IN_LeftDown(void) {KeyDown(&in_left);}
-static void IN_LeftUp(void) {KeyUp(&in_left);}
-static void IN_RightDown(void) {KeyDown(&in_right);}
-static void IN_RightUp(void) {KeyUp(&in_right);}
-static void IN_ForwardDown(void) {KeyDown(&in_forward);}
-static void IN_ForwardUp(void) {KeyUp(&in_forward);}
-static void IN_BackDown(void) {KeyDown(&in_back);}
-static void IN_BackUp(void) {KeyUp(&in_back);}
-static void IN_LookupDown(void) {KeyDown(&in_lookup);}
-static void IN_LookupUp(void) {KeyUp(&in_lookup);}
-static void IN_LookdownDown(void) {KeyDown(&in_lookdown);}
-static void IN_LookdownUp(void) {KeyUp(&in_lookdown);}
-static void IN_MoveleftDown(void) {KeyDown(&in_moveleft);}
-static void IN_MoveleftUp(void) {KeyUp(&in_moveleft);}
-static void IN_MoverightDown(void) {KeyDown(&in_moveright);}
-static void IN_MoverightUp(void) {KeyUp(&in_moveright);}
-
-static void IN_SpeedDown(void) {KeyDown(&in_speed);}
-static void IN_SpeedUp(void) {KeyUp(&in_speed);}
-static void IN_StrafeDown(void) {KeyDown(&in_strafe);}
-static void IN_StrafeUp(void) {KeyUp(&in_strafe);}
-
-static void IN_AttackDown(void) {KeyDown(&in_attack);}
-static void IN_AttackUp(void) {KeyUp(&in_attack);}
-
-static void IN_UseDown(void) {KeyDown(&in_use);}
-static void IN_UseUp(void) {KeyUp(&in_use);}
+static void IN_UpDown(cmd_state_t *cmd) {KeyDown(cmd, &in_up);}
+static void IN_UpUp(cmd_state_t *cmd) {KeyUp(cmd, &in_up);}
+static void IN_DownDown(cmd_state_t *cmd) {KeyDown(cmd, &in_down);}
+static void IN_DownUp(cmd_state_t *cmd) {KeyUp(cmd, &in_down);}
+static void IN_LeftDown(cmd_state_t *cmd) {KeyDown(cmd, &in_left);}
+static void IN_LeftUp(cmd_state_t *cmd) {KeyUp(cmd, &in_left);}
+static void IN_RightDown(cmd_state_t *cmd) {KeyDown(cmd, &in_right);}
+static void IN_RightUp(cmd_state_t *cmd) {KeyUp(cmd, &in_right);}
+static void IN_ForwardDown(cmd_state_t *cmd) {KeyDown(cmd, &in_forward);}
+static void IN_ForwardUp(cmd_state_t *cmd) {KeyUp(cmd, &in_forward);}
+static void IN_BackDown(cmd_state_t *cmd) {KeyDown(cmd, &in_back);}
+static void IN_BackUp(cmd_state_t *cmd) {KeyUp(cmd, &in_back);}
+static void IN_LookupDown(cmd_state_t *cmd) {KeyDown(cmd, &in_lookup);}
+static void IN_LookupUp(cmd_state_t *cmd) {KeyUp(cmd, &in_lookup);}
+static void IN_LookdownDown(cmd_state_t *cmd) {KeyDown(cmd, &in_lookdown);}
+static void IN_LookdownUp(cmd_state_t *cmd) {KeyUp(cmd, &in_lookdown);}
+static void IN_MoveleftDown(cmd_state_t *cmd) {KeyDown(cmd, &in_moveleft);}
+static void IN_MoveleftUp(cmd_state_t *cmd) {KeyUp(cmd, &in_moveleft);}
+static void IN_MoverightDown(cmd_state_t *cmd) {KeyDown(cmd, &in_moveright);}
+static void IN_MoverightUp(cmd_state_t *cmd) {KeyUp(cmd, &in_moveright);}
+
+static void IN_SpeedDown(cmd_state_t *cmd) {KeyDown(cmd, &in_speed);}
+static void IN_SpeedUp(cmd_state_t *cmd) {KeyUp(cmd, &in_speed);}
+static void IN_StrafeDown(cmd_state_t *cmd) {KeyDown(cmd, &in_strafe);}
+static void IN_StrafeUp(cmd_state_t *cmd) {KeyUp(cmd, &in_strafe);}
+
+static void IN_AttackDown(cmd_state_t *cmd) {KeyDown(cmd, &in_attack);}
+static void IN_AttackUp(cmd_state_t *cmd) {KeyUp(cmd, &in_attack);}
+
+static void IN_UseDown(cmd_state_t *cmd) {KeyDown(cmd, &in_use);}
+static void IN_UseUp(cmd_state_t *cmd) {KeyUp(cmd, &in_use);}
// LadyHavoc: added 6 new buttons
-static void IN_Button3Down(void) {KeyDown(&in_button3);}
-static void IN_Button3Up(void) {KeyUp(&in_button3);}
-static void IN_Button4Down(void) {KeyDown(&in_button4);}
-static void IN_Button4Up(void) {KeyUp(&in_button4);}
-static void IN_Button5Down(void) {KeyDown(&in_button5);}
-static void IN_Button5Up(void) {KeyUp(&in_button5);}
-static void IN_Button6Down(void) {KeyDown(&in_button6);}
-static void IN_Button6Up(void) {KeyUp(&in_button6);}
-static void IN_Button7Down(void) {KeyDown(&in_button7);}
-static void IN_Button7Up(void) {KeyUp(&in_button7);}
-static void IN_Button8Down(void) {KeyDown(&in_button8);}
-static void IN_Button8Up(void) {KeyUp(&in_button8);}
-
-static void IN_Button9Down(void) {KeyDown(&in_button9);}
-static void IN_Button9Up(void) {KeyUp(&in_button9);}
-static void IN_Button10Down(void) {KeyDown(&in_button10);}
-static void IN_Button10Up(void) {KeyUp(&in_button10);}
-static void IN_Button11Down(void) {KeyDown(&in_button11);}
-static void IN_Button11Up(void) {KeyUp(&in_button11);}
-static void IN_Button12Down(void) {KeyDown(&in_button12);}
-static void IN_Button12Up(void) {KeyUp(&in_button12);}
-static void IN_Button13Down(void) {KeyDown(&in_button13);}
-static void IN_Button13Up(void) {KeyUp(&in_button13);}
-static void IN_Button14Down(void) {KeyDown(&in_button14);}
-static void IN_Button14Up(void) {KeyUp(&in_button14);}
-static void IN_Button15Down(void) {KeyDown(&in_button15);}
-static void IN_Button15Up(void) {KeyUp(&in_button15);}
-static void IN_Button16Down(void) {KeyDown(&in_button16);}
-static void IN_Button16Up(void) {KeyUp(&in_button16);}
-
-static void IN_JumpDown (void) {KeyDown(&in_jump);}
-static void IN_JumpUp (void) {KeyUp(&in_jump);}
-
-static void IN_Impulse (void) {in_impulse=atoi(Cmd_Argv(1));}
+static void IN_Button3Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button3);}
+static void IN_Button3Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button3);}
+static void IN_Button4Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button4);}
+static void IN_Button4Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button4);}
+static void IN_Button5Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button5);}
+static void IN_Button5Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button5);}
+static void IN_Button6Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button6);}
+static void IN_Button6Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button6);}
+static void IN_Button7Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button7);}
+static void IN_Button7Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button7);}
+static void IN_Button8Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button8);}
+static void IN_Button8Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button8);}
+
+static void IN_Button9Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button9);}
+static void IN_Button9Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button9);}
+static void IN_Button10Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button10);}
+static void IN_Button10Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button10);}
+static void IN_Button11Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button11);}
+static void IN_Button11Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button11);}
+static void IN_Button12Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button12);}
+static void IN_Button12Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button12);}
+static void IN_Button13Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button13);}
+static void IN_Button13Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button13);}
+static void IN_Button14Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button14);}
+static void IN_Button14Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button14);}
+static void IN_Button15Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button15);}
+static void IN_Button15Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button15);}
+static void IN_Button16Down(cmd_state_t *cmd) {KeyDown(cmd, &in_button16);}
+static void IN_Button16Up(cmd_state_t *cmd) {KeyUp(cmd, &in_button16);}
+
+static void IN_JumpDown(cmd_state_t *cmd) {KeyDown(cmd, &in_jump);}
+static void IN_JumpUp(cmd_state_t *cmd) {KeyUp(cmd, &in_jump);}
+
+static void IN_Impulse(cmd_state_t *cmd) {in_impulse=atoi(Cmd_Argv(cmd, 1));}
in_bestweapon_info_t in_bestweapon_info[IN_BESTWEAPON_MAX];
IN_BestWeapon_Register("h", 226, HIT_MJOLNIR, HIT_MJOLNIR, STAT_CELLS, 0); // hipnotic mjolnir hammer
}
-static void IN_BestWeapon_Register_f (void)
+static void IN_BestWeapon_Register_f(cmd_state_t *cmd)
{
- if(Cmd_Argc() == 7)
+ if(Cmd_Argc(cmd) == 7)
{
IN_BestWeapon_Register(
- Cmd_Argv(1),
- atoi(Cmd_Argv(2)),
- atoi(Cmd_Argv(3)),
- atoi(Cmd_Argv(4)),
- atoi(Cmd_Argv(5)),
- atoi(Cmd_Argv(6))
+ Cmd_Argv(cmd, 1),
+ atoi(Cmd_Argv(cmd, 2)),
+ atoi(Cmd_Argv(cmd, 3)),
+ atoi(Cmd_Argv(cmd, 4)),
+ atoi(Cmd_Argv(cmd, 5)),
+ atoi(Cmd_Argv(cmd, 6))
);
}
- else if(Cmd_Argc() == 2 && !strcmp(Cmd_Argv(1), "clear"))
+ else if(Cmd_Argc(cmd) == 2 && !strcmp(Cmd_Argv(cmd, 1), "clear"))
{
memset(in_bestweapon_info, 0, sizeof(in_bestweapon_info));
}
- else if(Cmd_Argc() == 2 && !strcmp(Cmd_Argv(1), "quake"))
+ else if(Cmd_Argc(cmd) == 2 && !strcmp(Cmd_Argv(cmd, 1), "quake"))
{
IN_BestWeapon_ResetData();
}
else
{
- Con_Printf("Usage: %s weaponshortname impulse itemcode activeweaponcode ammostat ammomin; %s clear; %s quake\n", Cmd_Argv(0), Cmd_Argv(0), Cmd_Argv(0));
+ Con_Printf("Usage: %s weaponshortname impulse itemcode activeweaponcode ammostat ammomin; %s clear; %s quake\n", Cmd_Argv(cmd, 0), Cmd_Argv(cmd, 0), Cmd_Argv(cmd, 0));
}
}
-static void IN_BestWeapon (void)
+static void IN_BestWeapon_f(cmd_state_t *cmd)
{
int i, n;
const char *t;
- if (Cmd_Argc() < 2)
+ if (Cmd_Argc(cmd) < 2)
{
Con_Printf("bestweapon requires 1 or more parameters\n");
return;
}
- for (i = 1;i < Cmd_Argc();i++)
+ for (i = 1;i < Cmd_Argc(cmd);i++)
{
- t = Cmd_Argv(i);
+ t = Cmd_Argv(cmd, i);
// figure out which weapon this character refers to
for (n = 0;n < IN_BESTWEAPON_MAX && in_bestweapon_info[n].impulse;n++)
{
// if we couldn't find any of the weapons, there's nothing more we can do...
}
-#if 0
-void IN_CycleWeapon (void)
-{
- int i, n;
- int first = -1;
- qboolean found = false;
- const char *t;
- if (Cmd_Argc() < 2)
- {
- Con_Printf("bestweapon requires 1 or more parameters\n");
- return;
- }
- for (i = 1;i < Cmd_Argc();i++)
- {
- t = Cmd_Argv(i);
- // figure out which weapon this character refers to
- for (n = 0;n < IN_BESTWEAPON_MAX && in_bestweapon_info[n].impulse;n++)
- {
- if (!strcmp(in_bestweapon_info[n].name, t))
- {
- // we found out what weapon this character refers to
- // check if the inventory contains the weapon and enough ammo
- if ((cl.stats[STAT_ITEMS] & in_bestweapon_info[n].weaponbit) && (cl.stats[in_bestweapon_info[n].ammostat] >= in_bestweapon_info[n].ammomin))
- {
- // we found one of the weapons the player wanted
- if(first == -1)
- first = n;
- if(found)
- {
- in_impulse = in_bestweapon_info[n].impulse;
- return;
- }
- if(cl.stats[STAT_ACTIVEWEAPON] == in_bestweapon_info[n].activeweaponcode)
- found = true;
- }
- break;
- }
- }
- // if we couldn't identify the weapon we just ignore it and continue checking for other weapons
- }
- if(first != -1)
- {
- in_impulse = in_bestweapon_info[first].impulse;
- return;
- }
- // if we couldn't find any of the weapons, there's nothing more we can do...
-}
-#endif
-
/*
===============
CL_KeyState
*/
void CL_InitInput (void)
{
- Cmd_AddCommand ("+moveup",IN_UpDown, "swim upward");
- Cmd_AddCommand ("-moveup",IN_UpUp, "stop swimming upward");
- Cmd_AddCommand ("+movedown",IN_DownDown, "swim downward");
- Cmd_AddCommand ("-movedown",IN_DownUp, "stop swimming downward");
- Cmd_AddCommand ("+left",IN_LeftDown, "turn left");
- Cmd_AddCommand ("-left",IN_LeftUp, "stop turning left");
- Cmd_AddCommand ("+right",IN_RightDown, "turn right");
- Cmd_AddCommand ("-right",IN_RightUp, "stop turning right");
- Cmd_AddCommand ("+forward",IN_ForwardDown, "move forward");
- Cmd_AddCommand ("-forward",IN_ForwardUp, "stop moving forward");
- Cmd_AddCommand ("+back",IN_BackDown, "move backward");
- Cmd_AddCommand ("-back",IN_BackUp, "stop moving backward");
- Cmd_AddCommand ("+lookup", IN_LookupDown, "look upward");
- Cmd_AddCommand ("-lookup", IN_LookupUp, "stop looking upward");
- Cmd_AddCommand ("+lookdown", IN_LookdownDown, "look downward");
- Cmd_AddCommand ("-lookdown", IN_LookdownUp, "stop looking downward");
- Cmd_AddCommand ("+strafe", IN_StrafeDown, "activate strafing mode (move instead of turn)");
- Cmd_AddCommand ("-strafe", IN_StrafeUp, "deactivate strafing mode");
- Cmd_AddCommand ("+moveleft", IN_MoveleftDown, "strafe left");
- Cmd_AddCommand ("-moveleft", IN_MoveleftUp, "stop strafing left");
- Cmd_AddCommand ("+moveright", IN_MoverightDown, "strafe right");
- Cmd_AddCommand ("-moveright", IN_MoverightUp, "stop strafing right");
- Cmd_AddCommand ("+speed", IN_SpeedDown, "activate run mode (faster movement and turning)");
- Cmd_AddCommand ("-speed", IN_SpeedUp, "deactivate run mode");
- Cmd_AddCommand ("+attack", IN_AttackDown, "begin firing");
- Cmd_AddCommand ("-attack", IN_AttackUp, "stop firing");
- Cmd_AddCommand ("+jump", IN_JumpDown, "jump");
- Cmd_AddCommand ("-jump", IN_JumpUp, "end jump (so you can jump again)");
- Cmd_AddCommand ("impulse", IN_Impulse, "send an impulse number to server (select weapon, use item, etc)");
- Cmd_AddCommand ("+klook", IN_KLookDown, "activate keyboard looking mode, do not recenter view");
- Cmd_AddCommand ("-klook", IN_KLookUp, "deactivate keyboard looking mode");
- Cmd_AddCommand ("+mlook", IN_MLookDown, "activate mouse looking mode, do not recenter view");
- Cmd_AddCommand ("-mlook", IN_MLookUp, "deactivate mouse looking mode");
-
- // LadyHavoc: added use button
- Cmd_AddCommand ("+use", IN_UseDown, "use something (may be used by some mods)");
- Cmd_AddCommand ("-use", IN_UseUp, "stop using something");
-
- // LadyHavoc: added 6 new buttons
- Cmd_AddCommand ("+button3", IN_Button3Down, "activate button3 (behavior depends on mod)");
- Cmd_AddCommand ("-button3", IN_Button3Up, "deactivate button3");
- Cmd_AddCommand ("+button4", IN_Button4Down, "activate button4 (behavior depends on mod)");
- Cmd_AddCommand ("-button4", IN_Button4Up, "deactivate button4");
- Cmd_AddCommand ("+button5", IN_Button5Down, "activate button5 (behavior depends on mod)");
- Cmd_AddCommand ("-button5", IN_Button5Up, "deactivate button5");
- Cmd_AddCommand ("+button6", IN_Button6Down, "activate button6 (behavior depends on mod)");
- Cmd_AddCommand ("-button6", IN_Button6Up, "deactivate button6");
- Cmd_AddCommand ("+button7", IN_Button7Down, "activate button7 (behavior depends on mod)");
- Cmd_AddCommand ("-button7", IN_Button7Up, "deactivate button7");
- Cmd_AddCommand ("+button8", IN_Button8Down, "activate button8 (behavior depends on mod)");
- Cmd_AddCommand ("-button8", IN_Button8Up, "deactivate button8");
- Cmd_AddCommand ("+button9", IN_Button9Down, "activate button9 (behavior depends on mod)");
- Cmd_AddCommand ("-button9", IN_Button9Up, "deactivate button9");
- Cmd_AddCommand ("+button10", IN_Button10Down, "activate button10 (behavior depends on mod)");
- Cmd_AddCommand ("-button10", IN_Button10Up, "deactivate button10");
- Cmd_AddCommand ("+button11", IN_Button11Down, "activate button11 (behavior depends on mod)");
- Cmd_AddCommand ("-button11", IN_Button11Up, "deactivate button11");
- Cmd_AddCommand ("+button12", IN_Button12Down, "activate button12 (behavior depends on mod)");
- Cmd_AddCommand ("-button12", IN_Button12Up, "deactivate button12");
- Cmd_AddCommand ("+button13", IN_Button13Down, "activate button13 (behavior depends on mod)");
- Cmd_AddCommand ("-button13", IN_Button13Up, "deactivate button13");
- Cmd_AddCommand ("+button14", IN_Button14Down, "activate button14 (behavior depends on mod)");
- Cmd_AddCommand ("-button14", IN_Button14Up, "deactivate button14");
- Cmd_AddCommand ("+button15", IN_Button15Down, "activate button15 (behavior depends on mod)");
- Cmd_AddCommand ("-button15", IN_Button15Up, "deactivate button15");
- Cmd_AddCommand ("+button16", IN_Button16Down, "activate button16 (behavior depends on mod)");
- Cmd_AddCommand ("-button16", IN_Button16Up, "deactivate button16");
+ Cmd_AddCommand(&cmd_client, "+moveup",IN_UpDown, "swim upward");
+ Cmd_AddCommand(&cmd_client, "-moveup",IN_UpUp, "stop swimming upward");
+ Cmd_AddCommand(&cmd_client, "+movedown",IN_DownDown, "swim downward");
+ Cmd_AddCommand(&cmd_client, "-movedown",IN_DownUp, "stop swimming downward");
+ Cmd_AddCommand(&cmd_client, "+left",IN_LeftDown, "turn left");
+ Cmd_AddCommand(&cmd_client, "-left",IN_LeftUp, "stop turning left");
+ Cmd_AddCommand(&cmd_client, "+right",IN_RightDown, "turn right");
+ Cmd_AddCommand(&cmd_client, "-right",IN_RightUp, "stop turning right");
+ Cmd_AddCommand(&cmd_client, "+forward",IN_ForwardDown, "move forward");
+ Cmd_AddCommand(&cmd_client, "-forward",IN_ForwardUp, "stop moving forward");
+ Cmd_AddCommand(&cmd_client, "+back",IN_BackDown, "move backward");
+ Cmd_AddCommand(&cmd_client, "-back",IN_BackUp, "stop moving backward");
+ Cmd_AddCommand(&cmd_client, "+lookup", IN_LookupDown, "look upward");
+ Cmd_AddCommand(&cmd_client, "-lookup", IN_LookupUp, "stop looking upward");
+ Cmd_AddCommand(&cmd_client, "+lookdown", IN_LookdownDown, "look downward");
+ Cmd_AddCommand(&cmd_client, "-lookdown", IN_LookdownUp, "stop looking downward");
+ Cmd_AddCommand(&cmd_client, "+strafe", IN_StrafeDown, "activate strafing mode (move instead of turn)");
+ Cmd_AddCommand(&cmd_client, "-strafe", IN_StrafeUp, "deactivate strafing mode");
+ Cmd_AddCommand(&cmd_client, "+moveleft", IN_MoveleftDown, "strafe left");
+ Cmd_AddCommand(&cmd_client, "-moveleft", IN_MoveleftUp, "stop strafing left");
+ Cmd_AddCommand(&cmd_client, "+moveright", IN_MoverightDown, "strafe right");
+ Cmd_AddCommand(&cmd_client, "-moveright", IN_MoverightUp, "stop strafing right");
+ Cmd_AddCommand(&cmd_client, "+speed", IN_SpeedDown, "activate run mode (faster movement and turning)");
+ Cmd_AddCommand(&cmd_client, "-speed", IN_SpeedUp, "deactivate run mode");
+ Cmd_AddCommand(&cmd_client, "+attack", IN_AttackDown, "begin firing");
+ Cmd_AddCommand(&cmd_client, "-attack", IN_AttackUp, "stop firing");
+ Cmd_AddCommand(&cmd_client, "+jump", IN_JumpDown, "jump");
+ Cmd_AddCommand(&cmd_client, "-jump", IN_JumpUp, "end jump (so you can jump again)");
+ Cmd_AddCommand(&cmd_client, "impulse", IN_Impulse, "send an impulse number to server (select weapon, use item, etc)");
+ Cmd_AddCommand(&cmd_client, "+klook", IN_KLookDown, "activate keyboard looking mode, do not recenter view");
+ Cmd_AddCommand(&cmd_client, "-klook", IN_KLookUp, "deactivate keyboard looking mode");
+ Cmd_AddCommand(&cmd_client, "+mlook", IN_MLookDown, "activate mouse looking mode, do not recenter view");
+ Cmd_AddCommand(&cmd_client, "-mlook", IN_MLookUp, "deactivate mouse looking mode");
+
+ // LadyHavoc: added lots of buttons
+ Cmd_AddCommand(&cmd_client, "+use", IN_UseDown, "use something (may be used by some mods)");
+ Cmd_AddCommand(&cmd_client, "-use", IN_UseUp, "stop using something");
+ Cmd_AddCommand(&cmd_client, "+button3", IN_Button3Down, "activate button3 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button3", IN_Button3Up, "deactivate button3");
+ Cmd_AddCommand(&cmd_client, "+button4", IN_Button4Down, "activate button4 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button4", IN_Button4Up, "deactivate button4");
+ Cmd_AddCommand(&cmd_client, "+button5", IN_Button5Down, "activate button5 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button5", IN_Button5Up, "deactivate button5");
+ Cmd_AddCommand(&cmd_client, "+button6", IN_Button6Down, "activate button6 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button6", IN_Button6Up, "deactivate button6");
+ Cmd_AddCommand(&cmd_client, "+button7", IN_Button7Down, "activate button7 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button7", IN_Button7Up, "deactivate button7");
+ Cmd_AddCommand(&cmd_client, "+button8", IN_Button8Down, "activate button8 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button8", IN_Button8Up, "deactivate button8");
+ Cmd_AddCommand(&cmd_client, "+button9", IN_Button9Down, "activate button9 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button9", IN_Button9Up, "deactivate button9");
+ Cmd_AddCommand(&cmd_client, "+button10", IN_Button10Down, "activate button10 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button10", IN_Button10Up, "deactivate button10");
+ Cmd_AddCommand(&cmd_client, "+button11", IN_Button11Down, "activate button11 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button11", IN_Button11Up, "deactivate button11");
+ Cmd_AddCommand(&cmd_client, "+button12", IN_Button12Down, "activate button12 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button12", IN_Button12Up, "deactivate button12");
+ Cmd_AddCommand(&cmd_client, "+button13", IN_Button13Down, "activate button13 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button13", IN_Button13Up, "deactivate button13");
+ Cmd_AddCommand(&cmd_client, "+button14", IN_Button14Down, "activate button14 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button14", IN_Button14Up, "deactivate button14");
+ Cmd_AddCommand(&cmd_client, "+button15", IN_Button15Down, "activate button15 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button15", IN_Button15Up, "deactivate button15");
+ Cmd_AddCommand(&cmd_client, "+button16", IN_Button16Down, "activate button16 (behavior depends on mod)");
+ Cmd_AddCommand(&cmd_client, "-button16", IN_Button16Up, "deactivate button16");
// LadyHavoc: added bestweapon command
- Cmd_AddCommand ("bestweapon", IN_BestWeapon, "send an impulse number to server to select the first usable weapon out of several (example: 8 7 6 5 4 3 2 1)");
-#if 0
- Cmd_AddCommand ("cycleweapon", IN_CycleWeapon, "send an impulse number to server to select the next usable weapon out of several (example: 9 4 8) if you are holding one of these, and choose the first one if you are holding none of these");
-#endif
- Cmd_AddCommand ("register_bestweapon", IN_BestWeapon_Register_f, "(for QC usage only) change weapon parameters to be used by bestweapon; stuffcmd this in ClientConnect");
+ Cmd_AddCommand(&cmd_client, "bestweapon", IN_BestWeapon_f, "send an impulse number to server to select the first usable weapon out of several (example: 8 7 6 5 4 3 2 1)");
+ Cmd_AddCommand(&cmd_client, "register_bestweapon", IN_BestWeapon_Register_f, "(for QC usage only) change weapon parameters to be used by bestweapon; stuffcmd this in ClientConnect");
Cvar_RegisterVariable(&cl_movecliptokeyboard);
Cvar_RegisterVariable(&cl_movement);
sizebuf_t buf;
unsigned char bufdata[8];
if (cls.demorecording)
- CL_Stop_f();
+ CL_Stop_f(&cmd_client);
// send disconnect message 3 times to improve chances of server
// receiving it (but it still fails sometimes)
cls.signon = 0;
}
-void CL_Disconnect_f(void)
+void CL_Disconnect_f(cmd_state_t *cmd)
{
CL_Disconnect ();
if (sv.active)
{
int i;
*cls.connect_userinfo = 0;
- for(i = firstarg; i+2 <= Cmd_Argc(); i += 2)
- InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(i), Cmd_Argv(i+1));
+ for(i = firstarg; i+2 <= Cmd_Argc(&cmd_client); i += 2)
+ InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(&cmd_client, i), Cmd_Argv(&cmd_client, i+1));
}
else if(firstarg < -1)
{
CL_PrintEntities_f
==============
*/
-static void CL_PrintEntities_f(void)
+static void CL_PrintEntities_f(cmd_state_t *cmd)
{
entity_t *ent;
int i;
List information on all models in the client modelindex
===============
*/
-static void CL_ModelIndexList_f(void)
+static void CL_ModelIndexList_f(cmd_state_t *cmd)
{
int i;
dp_model_t *model;
List all sounds in the client soundindex
===============
*/
-static void CL_SoundIndexList_f(void)
+static void CL_SoundIndexList_f(cmd_state_t *cmd)
{
int i = 1;
}
// LadyHavoc: pausedemo command
-static void CL_PauseDemo_f (void)
+static void CL_PauseDemo_f(cmd_state_t *cmd)
{
cls.demopaused = !cls.demopaused;
if (cls.demopaused)
CL_Fog_f
======================
*/
-static void CL_Fog_f (void)
+static void CL_Fog_f(cmd_state_t *cmd)
{
- if (Cmd_Argc () == 1)
+ if (Cmd_Argc (cmd) == 1)
{
Con_Printf("\"fog\" is \"%f %f %f %f %f %f %f %f %f\"\n", r_refdef.fog_density, r_refdef.fog_red, r_refdef.fog_green, r_refdef.fog_blue, r_refdef.fog_alpha, r_refdef.fog_start, r_refdef.fog_end, r_refdef.fog_height, r_refdef.fog_fadedepth);
return;
}
FOG_clear(); // so missing values get good defaults
- if(Cmd_Argc() > 1)
- r_refdef.fog_density = atof(Cmd_Argv(1));
- if(Cmd_Argc() > 2)
- r_refdef.fog_red = atof(Cmd_Argv(2));
- if(Cmd_Argc() > 3)
- r_refdef.fog_green = atof(Cmd_Argv(3));
- if(Cmd_Argc() > 4)
- r_refdef.fog_blue = atof(Cmd_Argv(4));
- if(Cmd_Argc() > 5)
- r_refdef.fog_alpha = atof(Cmd_Argv(5));
- if(Cmd_Argc() > 6)
- r_refdef.fog_start = atof(Cmd_Argv(6));
- if(Cmd_Argc() > 7)
- r_refdef.fog_end = atof(Cmd_Argv(7));
- if(Cmd_Argc() > 8)
- r_refdef.fog_height = atof(Cmd_Argv(8));
- if(Cmd_Argc() > 9)
- r_refdef.fog_fadedepth = atof(Cmd_Argv(9));
+ if(Cmd_Argc(cmd) > 1)
+ r_refdef.fog_density = atof(Cmd_Argv(cmd, 1));
+ if(Cmd_Argc(cmd) > 2)
+ r_refdef.fog_red = atof(Cmd_Argv(cmd, 2));
+ if(Cmd_Argc(cmd) > 3)
+ r_refdef.fog_green = atof(Cmd_Argv(cmd, 3));
+ if(Cmd_Argc(cmd) > 4)
+ r_refdef.fog_blue = atof(Cmd_Argv(cmd, 4));
+ if(Cmd_Argc(cmd) > 5)
+ r_refdef.fog_alpha = atof(Cmd_Argv(cmd, 5));
+ if(Cmd_Argc(cmd) > 6)
+ r_refdef.fog_start = atof(Cmd_Argv(cmd, 6));
+ if(Cmd_Argc(cmd) > 7)
+ r_refdef.fog_end = atof(Cmd_Argv(cmd, 7));
+ if(Cmd_Argc(cmd) > 8)
+ r_refdef.fog_height = atof(Cmd_Argv(cmd, 8));
+ if(Cmd_Argc(cmd) > 9)
+ r_refdef.fog_fadedepth = atof(Cmd_Argv(cmd, 9));
}
/*
CL_FogHeightTexture_f
======================
*/
-static void CL_Fog_HeightTexture_f (void)
+static void CL_Fog_HeightTexture_f(cmd_state_t *cmd)
{
- if (Cmd_Argc () < 11)
+ if (Cmd_Argc (cmd) < 11)
{
Con_Printf("\"fog_heighttexture\" is \"%f %f %f %f %f %f %f %f %f %s\"\n", r_refdef.fog_density, r_refdef.fog_red, r_refdef.fog_green, r_refdef.fog_blue, r_refdef.fog_alpha, r_refdef.fog_start, r_refdef.fog_end, r_refdef.fog_height, r_refdef.fog_fadedepth, r_refdef.fog_height_texturename);
return;
}
FOG_clear(); // so missing values get good defaults
- r_refdef.fog_density = atof(Cmd_Argv(1));
- r_refdef.fog_red = atof(Cmd_Argv(2));
- r_refdef.fog_green = atof(Cmd_Argv(3));
- r_refdef.fog_blue = atof(Cmd_Argv(4));
- r_refdef.fog_alpha = atof(Cmd_Argv(5));
- r_refdef.fog_start = atof(Cmd_Argv(6));
- r_refdef.fog_end = atof(Cmd_Argv(7));
- r_refdef.fog_height = atof(Cmd_Argv(8));
- r_refdef.fog_fadedepth = atof(Cmd_Argv(9));
- strlcpy(r_refdef.fog_height_texturename, Cmd_Argv(10), sizeof(r_refdef.fog_height_texturename));
+ r_refdef.fog_density = atof(Cmd_Argv(cmd, 1));
+ r_refdef.fog_red = atof(Cmd_Argv(cmd, 2));
+ r_refdef.fog_green = atof(Cmd_Argv(cmd, 3));
+ r_refdef.fog_blue = atof(Cmd_Argv(cmd, 4));
+ r_refdef.fog_alpha = atof(Cmd_Argv(cmd, 5));
+ r_refdef.fog_start = atof(Cmd_Argv(cmd, 6));
+ r_refdef.fog_end = atof(Cmd_Argv(cmd, 7));
+ r_refdef.fog_height = atof(Cmd_Argv(cmd, 8));
+ r_refdef.fog_fadedepth = atof(Cmd_Argv(cmd, 9));
+ strlcpy(r_refdef.fog_height_texturename, Cmd_Argv(cmd, 10), sizeof(r_refdef.fog_height_texturename));
}
For program optimization
====================
*/
-static void CL_TimeRefresh_f (void)
+static void CL_TimeRefresh_f(cmd_state_t *cmd)
{
int i;
double timestart, timedelta;
Con_Printf("%f seconds (%f fps)\n", timedelta, 128/timedelta);
}
-static void CL_AreaStats_f(void)
+static void CL_AreaStats_f(cmd_state_t *cmd)
{
World_PrintAreaStats(&cl.world, "client");
}
*pointer = node;
}
-static void CL_Locs_Add_f(void)
+static void CL_Locs_Add_f(cmd_state_t *cmd)
{
vec3_t mins, maxs;
- if (Cmd_Argc() != 5 && Cmd_Argc() != 8)
+ if (Cmd_Argc(cmd) != 5 && Cmd_Argc(cmd) != 8)
{
- Con_Printf("usage: %s x y z[ x y z] name\n", Cmd_Argv(0));
+ Con_Printf("usage: %s x y z[ x y z] name\n", Cmd_Argv(cmd, 0));
return;
}
- mins[0] = atof(Cmd_Argv(1));
- mins[1] = atof(Cmd_Argv(2));
- mins[2] = atof(Cmd_Argv(3));
- if (Cmd_Argc() == 8)
+ mins[0] = atof(Cmd_Argv(cmd, 1));
+ mins[1] = atof(Cmd_Argv(cmd, 2));
+ mins[2] = atof(Cmd_Argv(cmd, 3));
+ if (Cmd_Argc(cmd) == 8)
{
- maxs[0] = atof(Cmd_Argv(4));
- maxs[1] = atof(Cmd_Argv(5));
- maxs[2] = atof(Cmd_Argv(6));
- CL_Locs_AddNode(mins, maxs, Cmd_Argv(7));
+ maxs[0] = atof(Cmd_Argv(cmd, 4));
+ maxs[1] = atof(Cmd_Argv(cmd, 5));
+ maxs[2] = atof(Cmd_Argv(cmd, 6));
+ CL_Locs_AddNode(mins, maxs, Cmd_Argv(cmd, 7));
}
else
- CL_Locs_AddNode(mins, mins, Cmd_Argv(4));
+ CL_Locs_AddNode(mins, mins, Cmd_Argv(cmd, 4));
}
-static void CL_Locs_RemoveNearest_f(void)
+static void CL_Locs_RemoveNearest_f(cmd_state_t *cmd)
{
cl_locnode_t *loc;
loc = CL_Locs_FindNearest(r_refdef.view.origin);
Con_Printf("no loc point or box found for your location\n");
}
-static void CL_Locs_Clear_f(void)
+static void CL_Locs_Clear_f(cmd_state_t *cmd)
{
while (cl.locnodes)
CL_Locs_FreeNode(cl.locnodes);
}
-static void CL_Locs_Save_f(void)
+static void CL_Locs_Save_f(cmd_state_t *cmd)
{
cl_locnode_t *loc;
qfile_t *outfile;
FS_Close(outfile);
}
-void CL_Locs_Reload_f(void)
+void CL_Locs_Reload_f(cmd_state_t *cmd)
{
int i, linenumber, limit, len;
const char *s;
return;
}
- CL_Locs_Clear_f();
+ CL_Locs_Clear_f(cmd);
// try maps/something.loc first (LadyHavoc: where I think they should be)
dpsnprintf(locfilename, sizeof(locfilename), "%s.loc", cl.worldnamenoextension);
Cvar_RegisterVariable (&cl_itembobspeed);
Cvar_RegisterVariable (&cl_itembobheight);
- Cmd_AddCommand ("entities", CL_PrintEntities_f, "print information on network entities known to client");
- Cmd_AddCommand ("disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
- Cmd_AddCommand ("record", CL_Record_f, "record a demo");
- Cmd_AddCommand ("stop", CL_Stop_f, "stop recording or playing a demo");
- Cmd_AddCommand ("playdemo", CL_PlayDemo_f, "watch a demo file");
- Cmd_AddCommand ("timedemo", CL_TimeDemo_f, "play back a demo as fast as possible and save statistics to benchmark.log");
+ Cmd_AddCommand(&cmd_client, "entities", CL_PrintEntities_f, "print information on network entities known to client");
+ Cmd_AddCommand(&cmd_client, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
+ Cmd_AddCommand(&cmd_client, "record", CL_Record_f, "record a demo");
+ Cmd_AddCommand(&cmd_client, "stop", CL_Stop_f, "stop recording or playing a demo");
+ Cmd_AddCommand(&cmd_client, "playdemo", CL_PlayDemo_f, "watch a demo file");
+ Cmd_AddCommand(&cmd_client, "timedemo", CL_TimeDemo_f, "play back a demo as fast as possible and save statistics to benchmark.log");
// Support Client-side Model Index List
- Cmd_AddCommand ("cl_modelindexlist", CL_ModelIndexList_f, "list information on all models in the client modelindex");
+ Cmd_AddCommand(&cmd_client, "cl_modelindexlist", CL_ModelIndexList_f, "list information on all models in the client modelindex");
// Support Client-side Sound Index List
- Cmd_AddCommand ("cl_soundindexlist", CL_SoundIndexList_f, "list all sounds in the client soundindex");
+ Cmd_AddCommand(&cmd_client, "cl_soundindexlist", CL_SoundIndexList_f, "list all sounds in the client soundindex");
Cvar_RegisterVariable (&cl_autodemo);
Cvar_RegisterVariable (&cl_autodemo_nameformat);
Cvar_RegisterVariable (&cl_autodemo_delete);
- Cmd_AddCommand ("fog", CL_Fog_f, "set global fog parameters (density red green blue [alpha [mindist [maxdist [top [fadedepth]]]]])");
- Cmd_AddCommand ("fog_heighttexture", CL_Fog_HeightTexture_f, "set global fog parameters (density red green blue alpha mindist maxdist top depth textures/mapname/fogheight.tga)");
+ Cmd_AddCommand(&cmd_client, "fog", CL_Fog_f, "set global fog parameters (density red green blue [alpha [mindist [maxdist [top [fadedepth]]]]])");
+ Cmd_AddCommand(&cmd_client, "fog_heighttexture", CL_Fog_HeightTexture_f, "set global fog parameters (density red green blue alpha mindist maxdist top depth textures/mapname/fogheight.tga)");
// LadyHavoc: added pausedemo
- Cmd_AddCommand ("pausedemo", CL_PauseDemo_f, "pause demo playback (can also safely pause demo recording if using QUAKE, QUAKEDP or NEHAHRAMOVIE protocol, useful for making movies)");
+ Cmd_AddCommand(&cmd_client, "pausedemo", CL_PauseDemo_f, "pause demo playback (can also safely pause demo recording if using QUAKE, QUAKEDP or NEHAHRAMOVIE protocol, useful for making movies)");
- Cmd_AddCommand ("cl_areastats", CL_AreaStats_f, "prints statistics on entity culling during collision traces");
+ Cmd_AddCommand(&cmd_client, "cl_areastats", CL_AreaStats_f, "prints statistics on entity culling during collision traces");
Cvar_RegisterVariable(&r_draweffects);
Cvar_RegisterVariable(&cl_explosions_alpha_start);
Cvar_RegisterVariable(&qport);
Cvar_SetValueQuick(&qport, (rand() * RAND_MAX + rand()) & 0xffff);
- Cmd_AddCommand("timerefresh", CL_TimeRefresh_f, "turn quickly and print rendering statistcs");
+ Cmd_AddCommand(&cmd_client, "timerefresh", CL_TimeRefresh_f, "turn quickly and print rendering statistcs");
Cvar_RegisterVariable(&cl_locs_enable);
Cvar_RegisterVariable(&cl_locs_show);
- Cmd_AddCommand("locs_add", CL_Locs_Add_f, "add a point or box location (usage: x y z[ x y z] \"name\", if two sets of xyz are supplied it is a box, otherwise point)");
- Cmd_AddCommand("locs_removenearest", CL_Locs_RemoveNearest_f, "remove the nearest point or box (note: you need to be very near a box to remove it)");
- Cmd_AddCommand("locs_clear", CL_Locs_Clear_f, "remove all loc points/boxes");
- Cmd_AddCommand("locs_reload", CL_Locs_Reload_f, "reload .loc file for this map");
- Cmd_AddCommand("locs_save", CL_Locs_Save_f, "save .loc file for this map containing currently defined points and boxes");
+ Cmd_AddCommand(&cmd_client, "locs_add", CL_Locs_Add_f, "add a point or box location (usage: x y z[ x y z] \"name\", if two sets of xyz are supplied it is a box, otherwise point)");
+ Cmd_AddCommand(&cmd_client, "locs_removenearest", CL_Locs_RemoveNearest_f, "remove the nearest point or box (note: you need to be very near a box to remove it)");
+ Cmd_AddCommand(&cmd_client, "locs_clear", CL_Locs_Clear_f, "remove all loc points/boxes");
+ Cmd_AddCommand(&cmd_client, "locs_reload", CL_Locs_Reload_f, "reload .loc file for this map");
+ Cmd_AddCommand(&cmd_client, "locs_save", CL_Locs_Save_f, "save .loc file for this map containing currently defined points and boxes");
CL_Parse_Init();
CL_Particles_Init();
static qboolean QW_CL_CheckOrDownloadFile(const char *filename);
static void QW_CL_RequestNextDownload(void);
-static void QW_CL_NextUpload(void);
+static void QW_CL_NextUpload_f(cmd_state_t *cmd);
//static qboolean QW_CL_IsUploading(void);
-static void QW_CL_StopUpload(void);
+static void QW_CL_StopUpload_f(cmd_state_t *cmd);
/*
==================
World_Start(&cl.world);
// load or reload .loc file for team chat messages
- CL_Locs_Reload_f();
+ CL_Locs_Reload_f(&cmd_client);
// make sure we send enough keepalives
CL_KeepaliveMessage(false);
QW_CL_RequestNextDownload();
}
-static void QW_CL_Skins_f(void)
+static void QW_CL_Skins_f(cmd_state_t *cmd)
{
cls.qw_downloadnumber = 0;
cls.qw_downloadtype = dl_skin;
QW_CL_RequestNextDownload();
}
-static void QW_CL_Changing_f(void)
+static void QW_CL_Changing_f(cmd_state_t *cmd)
{
if (cls.qw_downloadmemory) // don't change when downloading
return;
Con_Printf("\nChanging map...\n");
}
-void QW_CL_NextUpload(void)
+void QW_CL_NextUpload_f(cmd_state_t *cmd)
{
int r, percent, size;
Con_Printf("Upload completed\n");
- QW_CL_StopUpload();
+ QW_CL_StopUpload_f(cmd);
}
void QW_CL_StartUpload(unsigned char *data, int size)
return;
// abort existing upload if in progress
- QW_CL_StopUpload();
+ QW_CL_StopUpload_f(&cmd_client);
Con_DPrintf("Starting upload of %d bytes...\n", size);
cls.qw_uploadsize = size;
cls.qw_uploadpos = 0;
- QW_CL_NextUpload();
+ QW_CL_NextUpload_f(&cmd_client);
}
#if 0
}
#endif
-void QW_CL_StopUpload(void)
+void QW_CL_StopUpload_f(cmd_state_t *cmd)
{
if (cls.qw_uploaddata)
Mem_Free(cls.qw_uploaddata);
}
}
-static void CL_BeginDownloads_f(void)
+static void CL_BeginDownloads_f(cmd_state_t *cmd)
{
// prevent cl_begindownloads from being issued multiple times in one match
// to prevent accidentally cancelled downloads
cls.qw_downloadspeedcount += size;
}
-static void CL_DownloadBegin_f(void)
+static void CL_DownloadBegin_f(cmd_state_t *cmd)
{
- int size = atoi(Cmd_Argv(1));
+ int size = atoi(Cmd_Argv(cmd, 1));
- if (size < 0 || size > 1<<30 || FS_CheckNastyPath(Cmd_Argv(2), false))
+ if (size < 0 || size > 1<<30 || FS_CheckNastyPath(Cmd_Argv(cmd, 2), false))
{
Con_Printf("cl_downloadbegin: received bogus information\n");
CL_StopDownload(0, 0);
CL_StopDownload(0, 0);
// we're really beginning a download now, so initialize stuff
- strlcpy(cls.qw_downloadname, Cmd_Argv(2), sizeof(cls.qw_downloadname));
+ strlcpy(cls.qw_downloadname, Cmd_Argv(cmd, 2), sizeof(cls.qw_downloadname));
cls.qw_downloadmemorymaxsize = size;
cls.qw_downloadmemory = (unsigned char *) Mem_Alloc(cls.permanentmempool, cls.qw_downloadmemorymaxsize);
cls.qw_downloadnumber++;
cls.qw_download_deflate = false;
- if(Cmd_Argc() >= 4)
+ if(Cmd_Argc(cmd) >= 4)
{
- if(!strcmp(Cmd_Argv(3), "deflate"))
+ if(!strcmp(Cmd_Argv(cmd, 3), "deflate"))
cls.qw_download_deflate = true;
// check further encodings here
}
Cmd_ForwardStringToServer("sv_startdownload");
}
-static void CL_StopDownload_f(void)
+static void CL_StopDownload_f(cmd_state_t *cmd)
{
Curl_CancelAll();
if (cls.qw_downloadname[0])
CL_BeginDownloads(true);
}
-static void CL_DownloadFinished_f(void)
+static void CL_DownloadFinished_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() < 3)
+ if (Cmd_Argc(cmd) < 3)
{
Con_Printf("Malformed cl_downloadfinished command\n");
return;
}
- CL_StopDownload(atoi(Cmd_Argv(1)), atoi(Cmd_Argv(2)));
+ CL_StopDownload(atoi(Cmd_Argv(cmd, 1)), atoi(Cmd_Argv(cmd, 2)));
CL_BeginDownloads(false);
}
// execute cl_begindownloads next frame
// (after any commands added by svc_stufftext have been executed)
// when done with downloads the "prespawn" will be sent
- Cbuf_AddText("\ncl_begindownloads\n");
+ Cbuf_AddText(&cmd_client, "\ncl_begindownloads\n");
//MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
//MSG_WriteString (&cls.netcon->message, "prespawn");
if (cls.demorecording)
{
// finish the previous level's demo file
- CL_Stop_f();
+ CL_Stop_f(&cmd_client);
}
// start a new demo file
}
}
-static void CL_IPLog_List_f(void)
+static void CL_IPLog_List_f(cmd_state_t *cmd)
{
int i, j;
const char *addressprefix;
- if (Cmd_Argc() > 2)
+ if (Cmd_Argc(cmd) > 2)
{
- Con_Printf("usage: %s 123.456.789.\n", Cmd_Argv(0));
+ Con_Printf("usage: %s 123.456.789.\n", Cmd_Argv(cmd, 0));
return;
}
addressprefix = "";
- if (Cmd_Argc() >= 2)
- addressprefix = Cmd_Argv(1);
+ if (Cmd_Argc(cmd) >= 2)
+ addressprefix = Cmd_Argv(cmd, 1);
if (!cl_iplog_loaded)
CL_IPLog_Load();
if (addressprefix && addressprefix[0])
break;
case qw_svc_sellscreen:
- Cmd_ExecuteString ("help", src_command, true);
+ Cmd_ExecuteString(&cmd_client, "help", src_command, true);
break;
case qw_svc_smallkick:
break;
case svc_sellscreen:
- Cmd_ExecuteString ("help", src_command, true);
+ Cmd_ExecuteString(&cmd_client, "help", src_command, true);
break;
case svc_hidelmp:
if (gamemode == GAME_TENEBRAE)
void CL_Parse_ErrorCleanUp(void)
{
CL_StopDownload(0, 0);
- QW_CL_StopUpload();
+ QW_CL_StopUpload_f(&cmd_client);
}
void CL_Parse_Init(void)
Cvar_RegisterVariable(&cl_iplog_name);
Cvar_RegisterVariable(&cl_readpicture_force);
- Cmd_AddCommand("nextul", QW_CL_NextUpload, "sends next fragment of current upload buffer (screenshot for example)");
- Cmd_AddCommand("stopul", QW_CL_StopUpload, "aborts current upload (screenshot for example)");
- Cmd_AddCommand("skins", QW_CL_Skins_f, "downloads missing qw skins from server");
- Cmd_AddCommand("changing", QW_CL_Changing_f, "sent by qw servers to tell client to wait for level change");
- Cmd_AddCommand("cl_begindownloads", CL_BeginDownloads_f, "used internally by darkplaces client while connecting (causes loading of models and sounds or triggers downloads for missing ones)");
- Cmd_AddCommand("cl_downloadbegin", CL_DownloadBegin_f, "(networking) informs client of download file information, client replies with sv_startsoundload to begin the transfer");
- Cmd_AddCommand("stopdownload", CL_StopDownload_f, "terminates a download");
- Cmd_AddCommand("cl_downloadfinished", CL_DownloadFinished_f, "signals that a download has finished and provides the client with file size and crc to check its integrity");
- Cmd_AddCommand("iplog_list", CL_IPLog_List_f, "lists names of players whose IP address begins with the supplied text (example: iplog_list 123.456.789)");
+ Cmd_AddCommand(&cmd_client, "nextul", QW_CL_NextUpload_f, "sends next fragment of current upload buffer (screenshot for example)");
+ Cmd_AddCommand(&cmd_client, "stopul", QW_CL_StopUpload_f, "aborts current upload (screenshot for example)");
+ Cmd_AddCommand(&cmd_client, "skins", QW_CL_Skins_f, "downloads missing qw skins from server");
+ Cmd_AddCommand(&cmd_client, "changing", QW_CL_Changing_f, "sent by qw servers to tell client to wait for level change");
+ Cmd_AddCommand(&cmd_client, "cl_begindownloads", CL_BeginDownloads_f, "used internally by darkplaces client while connecting (causes loading of models and sounds or triggers downloads for missing ones)");
+ Cmd_AddCommand(&cmd_client, "cl_downloadbegin", CL_DownloadBegin_f, "(networking) informs client of download file information, client replies with sv_startsoundload to begin the transfer");
+ Cmd_AddCommand(&cmd_client, "stopdownload", CL_StopDownload_f, "terminates a download");
+ Cmd_AddCommand(&cmd_client, "cl_downloadfinished", CL_DownloadFinished_f, "signals that a download has finished and provides the client with file size and crc to check its integrity");
+ Cmd_AddCommand(&cmd_client, "iplog_list", CL_IPLog_List_f, "lists names of players whose IP address begins with the supplied text (example: iplog_list 123.456.789)");
}
void CL_Parse_Shutdown(void)
}
}
-static void CL_Particles_LoadEffectInfo_f(void)
+static void CL_Particles_LoadEffectInfo_f(cmd_state_t *cmd)
{
- CL_Particles_LoadEffectInfo(Cmd_Argc() > 1 ? Cmd_Argv(1) : NULL);
+ CL_Particles_LoadEffectInfo(Cmd_Argc(cmd) > 1 ? Cmd_Argv(cmd, 1) : NULL);
}
/*
CL_InitParticles
===============
*/
-void CL_ReadPointFile_f (void);
+void CL_ReadPointFile_f(cmd_state_t *cmd);
void CL_Particles_Init (void)
{
- Cmd_AddCommand ("pointfile", CL_ReadPointFile_f, "display point file produced by qbsp when a leak was detected in the map (a line leading through the leak hole, to an entity inside the level)");
- Cmd_AddCommand ("cl_particles_reloadeffects", CL_Particles_LoadEffectInfo_f, "reloads effectinfo.txt and maps/levelname_effectinfo.txt (where levelname is the current map) if parameter is given, loads from custom file (no levelname_effectinfo are loaded in this case)");
+ Cmd_AddCommand(&cmd_client, "pointfile", CL_ReadPointFile_f, "display point file produced by qbsp when a leak was detected in the map (a line leading through the leak hole, to an entity inside the level)");
+ Cmd_AddCommand(&cmd_client, "cl_particles_reloadeffects", CL_Particles_LoadEffectInfo_f, "reloads effectinfo.txt and maps/levelname_effectinfo.txt (where levelname is the current map) if parameter is given, loads from custom file (no levelname_effectinfo are loaded in this case)");
Cvar_RegisterVariable (&cl_particles);
Cvar_RegisterVariable (&cl_particles_quality);
}
-void CL_ReadPointFile_f (void)
+void CL_ReadPointFile_f(cmd_state_t *cmd)
{
double org[3], leakorg[3];
vec3_t vecorg;
extern int con_vislines;
-static void SCR_ScreenShot_f (void);
-static void R_Envmap_f (void);
+static void SCR_ScreenShot_f(cmd_state_t *cmd);
+static void R_Envmap_f(cmd_state_t *cmd);
// backend
void R_ClearScreen(qboolean fogcolor);
SCR_InfoBar_f
==============
*/
-static void SCR_InfoBar_f(void)
+static void SCR_InfoBar_f(cmd_state_t *cmd)
{
- if(Cmd_Argc() == 3)
+ if(Cmd_Argc(cmd) == 3)
{
- scr_infobartime_off = atof(Cmd_Argv(1));
- strlcpy(scr_infobarstring, Cmd_Argv(2), sizeof(scr_infobarstring));
+ scr_infobartime_off = atof(Cmd_Argv(cmd, 1));
+ strlcpy(scr_infobarstring, Cmd_Argv(cmd, 2), sizeof(scr_infobarstring));
}
else
{
Keybinding command
=================
*/
-static void SCR_SizeUp_f (void)
+static void SCR_SizeUp_f(cmd_state_t *cmd)
{
Cvar_SetValue ("viewsize",scr_viewsize.value+10);
}
Keybinding command
=================
*/
-static void SCR_SizeDown_f (void)
+static void SCR_SizeDown_f(cmd_state_t *cmd)
{
Cvar_SetValue ("viewsize",scr_viewsize.value-10);
}
if (COM_CheckParm ("-noconsole"))
Cvar_SetQuick(&scr_conforcewhiledisconnected, "0");
- Cmd_AddCommand ("sizeup",SCR_SizeUp_f, "increase view size (increases viewsize cvar)");
- Cmd_AddCommand ("sizedown",SCR_SizeDown_f, "decrease view size (decreases viewsize cvar)");
- Cmd_AddCommand ("screenshot",SCR_ScreenShot_f, "takes a screenshot of the next rendered frame");
- Cmd_AddCommand ("envmap", R_Envmap_f, "render a cubemap (skybox) of the current scene");
- Cmd_AddCommand ("infobar", SCR_InfoBar_f, "display a text in the infobar (usage: infobar expiretime string)");
+ Cmd_AddCommand(&cmd_client, "sizeup",SCR_SizeUp_f, "increase view size (increases viewsize cvar)");
+ Cmd_AddCommand(&cmd_client, "sizedown",SCR_SizeDown_f, "decrease view size (decreases viewsize cvar)");
+ Cmd_AddCommand(&cmd_client, "screenshot",SCR_ScreenShot_f, "takes a screenshot of the next rendered frame");
+ Cmd_AddCommand(&cmd_client, "envmap", R_Envmap_f, "render a cubemap (skybox) of the current scene");
+ Cmd_AddCommand(&cmd_client, "infobar", SCR_InfoBar_f, "display a text in the infobar (usage: infobar expiretime string)");
#ifdef CONFIG_VIDEO_CAPTURE
SCR_CaptureVideo_Ogg_Init();
SCR_ScreenShot_f
==================
*/
-void SCR_ScreenShot_f (void)
+void SCR_ScreenShot_f(cmd_state_t *cmd)
{
static int shotnumber;
static char old_prefix_name[MAX_QPATH];
qboolean png = (scr_screenshot_png.integer != 0) && !jpeg;
char vabuf[1024];
- if (Cmd_Argc() == 2)
+ if (Cmd_Argc(cmd) == 2)
{
const char *ext;
- strlcpy(filename, Cmd_Argv(1), sizeof(filename));
+ strlcpy(filename, Cmd_Argv(cmd, 1), sizeof(filename));
ext = FS_FileExtension(filename);
if (!strcasecmp(ext, "jpg"))
{
{{ 90, 180, 0}, "nz", false, false, true}
};
-static void R_Envmap_f (void)
+static void R_Envmap_f(cmd_state_t *cmd)
{
int j, size;
char filename[MAX_QPATH], basename[MAX_QPATH];
unsigned char *buffer2;
r_rendertarget_t *rt;
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
Con_Print("envmap <basename> <size>: save out 6 cubic environment map images, usable with loadsky, note that size must one of 128, 256, 512, or 1024 and can't be bigger than your current resolution\n");
return;
}
- strlcpy (basename, Cmd_Argv(1), sizeof (basename));
- size = atoi(Cmd_Argv(2));
+ strlcpy (basename, Cmd_Argv(cmd, 1), sizeof (basename));
+ size = atoi(Cmd_Argv(cmd, 2));
if (size != 128 && size != 256 && size != 512 && size != 1024)
{
Con_Print("envmap: size must be one of 128, 256, 512, or 1024\n");
CL_CloseVideo( cl_videos );
}
-static void CL_PlayVideo_f(void)
+static void CL_PlayVideo_f(cmd_state_t *cmd)
{
char name[MAX_QPATH], subtitlesfile[MAX_QPATH];
const char *extension;
if (COM_CheckParm("-benchmark"))
return;
- if (Cmd_Argc() < 2)
+ if (Cmd_Argc(cmd) < 2)
{
Con_Print("usage: playvideo <videoname> [custom_subtitles_file]\nplays video named video/<videoname>.dpv\nif custom subtitles file is not presented\nit tries video/<videoname>.sub");
return;
}
- extension = FS_FileExtension(Cmd_Argv(1));
+ extension = FS_FileExtension(Cmd_Argv(cmd, 1));
if (extension[0])
- dpsnprintf(name, sizeof(name), "video/%s", Cmd_Argv(1));
+ dpsnprintf(name, sizeof(name), "video/%s", Cmd_Argv(cmd, 1));
else
- dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(1));
- if ( Cmd_Argc() > 2)
- CL_VideoStart(name, Cmd_Argv(2));
+ dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(cmd, 1));
+ if ( Cmd_Argc(cmd) > 2)
+ CL_VideoStart(name, Cmd_Argv(cmd, 2));
else
{
- dpsnprintf(subtitlesfile, sizeof(subtitlesfile), "video/%s.dpsubs", Cmd_Argv(1));
+ dpsnprintf(subtitlesfile, sizeof(subtitlesfile), "video/%s.dpsubs", Cmd_Argv(cmd, 1));
CL_VideoStart(name, subtitlesfile);
}
}
-static void CL_StopVideo_f(void)
+static void CL_StopVideo_f(cmd_state_t *cmd)
{
CL_VideoStop();
}
bgra.i = 0;bgra.b[1] = 0xFF;cl_videogmask = bgra.i;
bgra.i = 0;bgra.b[2] = 0xFF;cl_videormask = bgra.i;
- Cmd_AddCommand( "playvideo", CL_PlayVideo_f, "play a .dpv video file" );
- Cmd_AddCommand( "stopvideo", CL_StopVideo_f, "stop playing a .dpv video file" );
+ Cmd_AddCommand(&cmd_client, "playvideo", CL_PlayVideo_f, "play a .dpv video file" );
+ Cmd_AddCommand(&cmd_client, "stopvideo", CL_StopVideo_f, "stop playing a .dpv video file" );
Cvar_RegisterVariable(&cl_video_subtitles);
Cvar_RegisterVariable(&cl_video_subtitles_lines);
void CL_EstablishConnection(const char *host, int firstarg);
void CL_Disconnect (void);
-void CL_Disconnect_f (void);
+void CL_Disconnect_f(cmd_state_t *cmd);
void CL_UpdateRenderEntity(entity_render_t *ent);
void CL_SetEntityColormapColors(entity_render_t *ent, int colormap);
void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
void CL_NextDemo(void);
-void CL_Stop_f(void);
-void CL_Record_f(void);
-void CL_PlayDemo_f(void);
-void CL_TimeDemo_f(void);
+void CL_Stop_f(cmd_state_t *cmd);
+void CL_Record_f(cmd_state_t *cmd);
+void CL_PlayDemo_f(cmd_state_t *cmd);
+void CL_TimeDemo_f(cmd_state_t *cmd);
//
// cl_parse.c
//
// view
//
-void V_StartPitchDrift (void);
+void V_StartPitchDrift_f(cmd_state_t *cmd);
void V_StopPitchDrift (void);
void V_Init (void);
void Sbar_ShowFPS(void);
void Sbar_ShowFPS_Update(void);
void Host_SaveConfig(void);
-void Host_LoadConfig_f(void);
+void Host_LoadConfig_f(cmd_state_t *cmd);
void CL_UpdateMoveVars(void);
void SCR_CaptureVideo_SoundFrame(const portable_sampleframe_t *paintbuffer, size_t length);
void V_DriftPitch(void);
void V_CalcViewBlend(void);
void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump, float clstatsviewheight, qboolean cldead, qboolean clintermission, const vec3_t clvelocity);
void V_CalcRefdef(void);
-void CL_Locs_Reload_f(void);
+void CL_Locs_Reload_f(cmd_state_t *cmd);
#endif
{
char *t;
VM_SAFEPARMCOUNT(1, VM_CL_registercmd);
- if(!Cmd_Exists(PRVM_G_STRING(OFS_PARM0)))
+ if(!Cmd_Exists(&cmd_client, PRVM_G_STRING(OFS_PARM0)))
{
size_t alloclen;
alloclen = strlen(PRVM_G_STRING(OFS_PARM0)) + 1;
t = (char *)Z_Malloc(alloclen);
memcpy(t, PRVM_G_STRING(OFS_PARM0), alloclen);
- Cmd_AddCommand(t, NULL, "console command created by QuakeC");
+ Cmd_AddCommand(&cmd_client, t, NULL, "console command created by QuakeC");
}
else
- Cmd_AddCommand(PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
+ Cmd_AddCommand(&cmd_client, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
}
VM_fabs, // #43 float(float f) fabs (QUAKE)
NULL, // #44 vector(entity e, float speed) aim (QUAKE)
VM_cvar, // #45 float(string s) cvar (QUAKE)
-VM_localcmd, // #46 void(string s) localcmd (QUAKE)
+VM_localcmd_client, // #46 void(string s) localcmd (QUAKE)
VM_nextent, // #47 entity(entity e) nextent (QUAKE)
VM_CL_particle, // #48 void(vector o, vector d, float color, float count) particle (QUAKE)
VM_changeyaw, // #49 void() ChangeYaw (QUAKE)
#include "quakedef.h"
#include "thread.h"
-typedef struct cmdalias_s
-{
- struct cmdalias_s *next;
- char name[MAX_ALIAS_NAME];
- char *value;
- qboolean initstate; // indicates this command existed at init
- char *initialvalue; // backup copy of value at init
-} cmdalias_t;
+cmd_state_t cmd_client;
+cmd_state_t cmd_clientfromserver;
+cmd_state_t cmd_server;
+cmd_state_t cmd_serverfromclient;
-static cmdalias_t *cmd_alias;
+typedef struct cmd_iter_s {
+ cmd_state_t *cmd;
+}
+cmd_iter_t;
-static qboolean cmd_wait;
+static cmd_iter_t cmd_iter_all[] = {
+ {&cmd_client},
+ {&cmd_clientfromserver},
+ {&cmd_server},
+ {&cmd_serverfromclient},
+ {NULL},
+};
-static mempool_t *cmd_mempool;
-static char cmd_tokenizebuffer[CMD_TOKENIZELENGTH];
-static int cmd_tokenizebufferpos = 0;
+// we only run the +whatever commandline arguments once
+qboolean host_stuffcmdsrun = false;
//=============================================================================
+void Cbuf_Lock(cmd_state_t *cmd)
+{
+ Thread_AtomicLock(&cmd->text_lock);
+}
+
+void Cbuf_Unlock(cmd_state_t *cmd)
+{
+ Thread_AtomicUnlock(&cmd->text_lock);
+}
+
+
/*
============
Cmd_Wait_f
bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2"
============
*/
-static void Cmd_Wait_f (void)
+static void Cmd_Wait_f (cmd_state_t *cmd)
{
- cmd_wait = true;
+ cmd->wait = true;
}
-typedef struct cmddeferred_s
-{
- struct cmddeferred_s *next;
- char *value;
- double delay;
-} cmddeferred_t;
-
-static cmddeferred_t *cmd_deferred_list = NULL;
-
/*
============
Cmd_Defer_f
Cause a command to be executed after a delay.
============
*/
-static void Cmd_Defer_f (void)
+static void Cmd_Defer_f (cmd_state_t *cmd)
{
- if(Cmd_Argc() == 1)
+ if(Cmd_Argc(cmd) == 1)
{
- cmddeferred_t *next = cmd_deferred_list;
+ cmddeferred_t *next = cmd->deferred_list;
if(!next)
Con_Printf("No commands are pending.\n");
while(next)
Con_Printf("-> In %9.2f: %s\n", next->delay, next->value);
next = next->next;
}
- } else if(Cmd_Argc() == 2 && !strcasecmp("clear", Cmd_Argv(1)))
+ } else if(Cmd_Argc(cmd) == 2 && !strcasecmp("clear", Cmd_Argv(cmd, 1)))
{
- while(cmd_deferred_list)
+ while(cmd->deferred_list)
{
- cmddeferred_t *cmd = cmd_deferred_list;
- cmd_deferred_list = cmd->next;
- Mem_Free(cmd->value);
- Mem_Free(cmd);
+ cmddeferred_t *defcmd = cmd->deferred_list;
+ cmd->deferred_list = defcmd->next;
+ Mem_Free(defcmd->value);
+ Mem_Free(defcmd);
}
- } else if(Cmd_Argc() == 3)
+ } else if(Cmd_Argc(cmd) == 3)
{
- const char *value = Cmd_Argv(2);
+ const char *value = Cmd_Argv(cmd, 2);
cmddeferred_t *defcmd = (cmddeferred_t*)Mem_Alloc(tempmempool, sizeof(*defcmd));
size_t len = strlen(value);
- defcmd->delay = atof(Cmd_Argv(1));
+ defcmd->delay = atof(Cmd_Argv(cmd, 1));
defcmd->value = (char*)Mem_Alloc(tempmempool, len+1);
memcpy(defcmd->value, value, len+1);
defcmd->next = NULL;
- if(cmd_deferred_list)
+ if(cmd->deferred_list)
{
- cmddeferred_t *next = cmd_deferred_list;
+ cmddeferred_t *next = cmd->deferred_list;
while(next->next)
next = next->next;
next->next = defcmd;
} else
- cmd_deferred_list = defcmd;
+ cmd->deferred_list = defcmd;
/* Stupid me... this changes the order... so commands with the same delay go blub :S
defcmd->next = cmd_deferred_list;
cmd_deferred_list = defcmd;*/
Print something to the center of the screen using SCR_Centerprint
============
*/
-static void Cmd_Centerprint_f (void)
+static void Cmd_Centerprint_f (cmd_state_t *cmd)
{
char msg[MAX_INPUTLINE];
unsigned int i, c, p;
- c = Cmd_Argc();
+ c = Cmd_Argc(cmd);
if(c >= 2)
{
- strlcpy(msg, Cmd_Argv(1), sizeof(msg));
+ strlcpy(msg, Cmd_Argv(cmd,1), sizeof(msg));
for(i = 2; i < c; ++i)
{
strlcat(msg, " ", sizeof(msg));
- strlcat(msg, Cmd_Argv(i), sizeof(msg));
+ strlcat(msg, Cmd_Argv(cmd, i), sizeof(msg));
}
c = (unsigned int)strlen(msg);
for(p = 0, i = 0; i < c; ++i)
=============================================================================
*/
-static sizebuf_t cmd_text;
-static unsigned char cmd_text_buf[CMDBUFSIZE];
-void *cmd_text_mutex = NULL;
-
/*
============
Cbuf_AddText
Adds command text at the end of the buffer
============
*/
-void Cbuf_AddText (const char *text)
+void Cbuf_AddText (cmd_state_t *cmd, const char *text)
{
int l;
l = (int)strlen(text);
- Cbuf_LockThreadMutex();
- if (cmd_text.cursize + l >= cmd_text.maxsize)
+ Cbuf_Lock(cmd);
+ if (cmd->text.cursize + l >= (size_t)cmd->text.maxsize)
Con_Print("Cbuf_AddText: overflow\n");
else
- SZ_Write(&cmd_text, (const unsigned char *)text, l);
- Cbuf_UnlockThreadMutex();
+ SZ_Write(&cmd->text, (const unsigned char *)text, l);
+ Cbuf_Unlock(cmd);
}
FIXME: actually change the command buffer to do less copying
============
*/
-void Cbuf_InsertText (const char *text)
+void Cbuf_InsertText (cmd_state_t *cmd, const char *text)
{
size_t l = strlen(text);
- Cbuf_LockThreadMutex();
+ Cbuf_Lock(cmd);
// we need to memmove the existing text and stuff this in before it...
- if (cmd_text.cursize + l >= (size_t)cmd_text.maxsize)
+ if (cmd->text.cursize + l >= (size_t)cmd->text.maxsize)
Con_Print("Cbuf_InsertText: overflow\n");
else
{
// we don't have a SZ_Prepend, so...
- memmove(cmd_text.data + l, cmd_text.data, cmd_text.cursize);
- cmd_text.cursize += (int)l;
- memcpy(cmd_text.data, text, l);
+ memmove(cmd->text.data + l, cmd->text.data, cmd->text.cursize);
+ cmd->text.cursize += (int)l;
+ memcpy(cmd->text.data, text, l);
}
- Cbuf_UnlockThreadMutex();
+ Cbuf_Unlock(cmd);
}
/*
Cbuf_Execute_Deferred --blub
============
*/
-static void Cbuf_Execute_Deferred (void)
+static void Cbuf_Execute_Deferred (cmd_state_t *cmd)
{
static double oldrealtime = 0;
- cmddeferred_t *cmd, *prev;
+ cmddeferred_t *defcmd, *prev;
double eat;
if (realtime - oldrealtime < 0 || realtime - oldrealtime > 1800) oldrealtime = realtime;
eat = realtime - oldrealtime;
return;
oldrealtime = realtime;
prev = NULL;
- cmd = cmd_deferred_list;
- while(cmd)
+ defcmd = cmd->deferred_list;
+ while(defcmd)
{
- cmd->delay -= eat;
- if(cmd->delay <= 0)
+ defcmd->delay -= eat;
+ if(defcmd->delay <= 0)
{
- Cbuf_AddText(cmd->value);
- Cbuf_AddText(";\n");
- Mem_Free(cmd->value);
+ Cbuf_AddText(cmd, defcmd->value);
+ Cbuf_AddText(cmd, ";\n");
+ Mem_Free(defcmd->value);
if(prev) {
- prev->next = cmd->next;
- Mem_Free(cmd);
- cmd = prev->next;
+ prev->next = defcmd->next;
+ Mem_Free(defcmd);
+ defcmd = prev->next;
} else {
- cmd_deferred_list = cmd->next;
- Mem_Free(cmd);
- cmd = cmd_deferred_list;
+ cmd->deferred_list = defcmd->next;
+ Mem_Free(defcmd);
+ defcmd = cmd->deferred_list;
}
continue;
}
- prev = cmd;
- cmd = cmd->next;
+ prev = defcmd;
+ defcmd = defcmd->next;
}
}
Cbuf_Execute
============
*/
-static qboolean Cmd_PreprocessString( const char *intext, char *outtext, unsigned maxoutlen, cmdalias_t *alias );
-void Cbuf_Execute (void)
+static qboolean Cmd_PreprocessString(cmd_state_t *cmd, const char *intext, char *outtext, unsigned maxoutlen, cmdalias_t *alias );
+void Cbuf_Execute (cmd_state_t *cmd)
{
int i;
char *text;
char *comment;
// LadyHavoc: making sure the tokenizebuffer doesn't get filled up by repeated crashes
- cmd_tokenizebufferpos = 0;
+ cmd->tokenizebufferpos = 0;
- while (cmd_text.cursize)
+ while (cmd->text.cursize)
{
// find a \n or ; line break
- text = (char *)cmd_text.data;
+ text = (char *)cmd->text.data;
quotes = false;
comment = NULL;
- for (i=0 ; i < cmd_text.cursize ; i++)
+ for (i=0 ; i < cmd->text.cursize ; i++)
{
if(!comment)
{
{
// make sure i doesn't get > cursize which causes a negative
// size in memmove, which is fatal --blub
- if (i < (cmd_text.cursize-1) && (text[i] == '\\' && (text[i+1] == '"' || text[i+1] == '\\')))
+ if (i < (cmd->text.cursize-1) && (text[i] == '\\' && (text[i+1] == '"' || text[i+1] == '\\')))
i++;
}
else
// this is necessary because commands (exec, alias) can insert data at the
// beginning of the text buffer
- if (i == cmd_text.cursize)
- cmd_text.cursize = 0;
+ if (i == cmd->text.cursize)
+ cmd->text.cursize = 0;
else
{
i++;
- cmd_text.cursize -= i;
- memmove (cmd_text.data, text+i, cmd_text.cursize);
+ cmd->text.cursize -= i;
+ memmove (cmd->text.data, text+i, cmd->text.cursize);
}
// execute the command line
(strncmp(firstchar, "in_bind", 7) || !ISWHITESPACE(firstchar[7]))
)
{
- if(Cmd_PreprocessString( line, preprocessed, sizeof(preprocessed), NULL ))
- Cmd_ExecuteString (preprocessed, src_command, false);
+ if(Cmd_PreprocessString( cmd, line, preprocessed, sizeof(preprocessed), NULL ))
+ Cmd_ExecuteString (cmd, preprocessed, src_command, false);
}
else
{
- Cmd_ExecuteString (line, src_command, false);
+ Cmd_ExecuteString (cmd, line, src_command, false);
}
- if (cmd_wait)
+ if (cmd->wait)
{ // skip out while text still remains in buffer, leaving it
// for next frame
- cmd_wait = false;
+ cmd->wait = false;
break;
}
}
}
-void Cbuf_Frame(void)
+void Cbuf_Frame(cmd_state_t *cmd)
{
- Cbuf_Execute_Deferred();
- if (cmd_text.cursize)
+ Cbuf_Execute_Deferred(cmd);
+ if (cmd->text.cursize)
{
SV_LockThreadMutex();
- Cbuf_Execute();
+ Cbuf_Execute(cmd);
SV_UnlockThreadMutex();
}
}
quake -nosound +cmd amlev1
===============
*/
-qboolean host_stuffcmdsrun = false;
-static void Cmd_StuffCmds_f (void)
+static void Cmd_StuffCmds_f (cmd_state_t *cmd)
{
int i, j, l;
// this is for all commandline options combined (and is bounds checked)
char build[MAX_INPUTLINE];
- if (Cmd_Argc () != 1)
+ if (Cmd_Argc (cmd) != 1)
{
Con_Print("stuffcmds : execute command line parameters\n");
return;
// now terminate the combined string and prepend it to the command buffer
// we already reserved space for the terminator
build[l++] = 0;
- Cbuf_InsertText (build);
+ Cbuf_InsertText (cmd, build);
}
-static void Cmd_Exec(const char *filename)
+static void Cmd_Exec(cmd_state_t *cmd, const char *filename)
{
char *f;
size_t filenameLen = strlen(filename);
// it may seem backwards to insert this text BEFORE the default.cfg
// but Cbuf_InsertText inserts before, so this actually ends up after it.
if (isdefaultcfg)
- Cbuf_InsertText("\ncvar_lockdefaults\n");
+ Cbuf_InsertText(cmd, "\ncvar_lockdefaults\n");
// insert newline after the text to make sure the last line is terminated (some text editors omit the trailing newline)
// (note: insertion order here is backwards from execution order, so this adds it after the text, by calling it before...)
- Cbuf_InsertText ("\n");
- Cbuf_InsertText (f);
+ Cbuf_InsertText (cmd, "\n");
+ Cbuf_InsertText (cmd, f);
Mem_Free(f);
if (isdefaultcfg)
switch(gamemode)
{
case GAME_NORMAL:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 0\n"
"sv_gameplayfix_findradiusdistancetobox 0\n"
"sv_gameplayfix_grenadebouncedownslopes 0\n"
);
break;
case GAME_NEHAHRA:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 0\n"
"sv_gameplayfix_findradiusdistancetobox 0\n"
"sv_gameplayfix_grenadebouncedownslopes 0\n"
// hipnotic mission pack has issues in their proximity mine sticking code, which causes them to bounce off.
case GAME_HIPNOTIC:
case GAME_QUOTH:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 0\n"
"sv_gameplayfix_findradiusdistancetobox 0\n"
"sv_gameplayfix_grenadebouncedownslopes 0\n"
break;
// rogue mission pack has a guardian boss that does not wake up if findradius returns one of the entities around its spawn area
case GAME_ROGUE:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 0\n"
"sv_gameplayfix_findradiusdistancetobox 0\n"
"sv_gameplayfix_grenadebouncedownslopes 0\n"
);
break;
case GAME_TENEBRAE:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 0\n"
"sv_gameplayfix_findradiusdistancetobox 0\n"
"sv_gameplayfix_grenadebouncedownslopes 0\n"
);
break;
case GAME_NEXUIZ:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 1\n"
"sv_gameplayfix_findradiusdistancetobox 1\n"
"sv_gameplayfix_grenadebouncedownslopes 1\n"
break;
// Steel Storm: Burning Retribution csqc misinterprets CSQC_InputEvent if type is a value other than 0 or 1
case GAME_STEELSTORM:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 1\n"
"sv_gameplayfix_findradiusdistancetobox 1\n"
"sv_gameplayfix_grenadebouncedownslopes 1\n"
);
break;
default:
- Cbuf_InsertText("\n"
+ Cbuf_InsertText(cmd, "\n"
"sv_gameplayfix_blowupfallenzombies 1\n"
"sv_gameplayfix_findradiusdistancetobox 1\n"
"sv_gameplayfix_grenadebouncedownslopes 1\n"
Cmd_Exec_f
===============
*/
-static void Cmd_Exec_f (void)
+static void Cmd_Exec_f (cmd_state_t *cmd)
{
fssearch_t *s;
int i;
- if (Cmd_Argc () != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("exec <filename> : execute a script file\n");
return;
}
- s = FS_Search(Cmd_Argv(1), true, true);
+ s = FS_Search(Cmd_Argv(cmd, 1), true, true);
if(!s || !s->numfilenames)
{
- Con_Printf("couldn't exec %s\n",Cmd_Argv(1));
+ Con_Printf("couldn't exec %s\n",Cmd_Argv(cmd, 1));
return;
}
for(i = 0; i < s->numfilenames; ++i)
- Cmd_Exec(s->filenames[i]);
+ Cmd_Exec(cmd, s->filenames[i]);
FS_FreeSearch(s);
}
Just prints the rest of the line to the console
===============
*/
-static void Cmd_Echo_f (void)
+static void Cmd_Echo_f (cmd_state_t *cmd)
{
int i;
- for (i=1 ; i<Cmd_Argc() ; i++)
- Con_Printf("%s ",Cmd_Argv(i));
+ for (i=1 ; i<Cmd_Argc(cmd) ; i++)
+ Con_Printf("%s ",Cmd_Argv(cmd, i));
Con_Print("\n");
}
Toggles a specified console variable amongst the values specified (default is 0 and 1)
===============
*/
-static void Cmd_Toggle_f(void)
+static void Cmd_Toggle_f(cmd_state_t *cmd)
{
// Acquire Number of Arguments
- int nNumArgs = Cmd_Argc();
+ int nNumArgs = Cmd_Argc(cmd);
if(nNumArgs == 1)
// No Arguments Specified; Print Usage
else
{ // Correct Arguments Specified
// Acquire Potential CVar
- cvar_t* cvCVar = Cvar_FindVar( Cmd_Argv(1) );
+ cvar_t* cvCVar = Cvar_FindVar( Cmd_Argv(cmd, 1) );
if(cvCVar != NULL)
{ // Valid CVar
else
if(nNumArgs == 3)
{ // 0 and Specified Usage
- if(cvCVar->integer == atoi(Cmd_Argv(2) ) )
+ if(cvCVar->integer == atoi(Cmd_Argv(cmd, 2) ) )
// CVar is Specified Value; // Reset to 0
Cvar_SetValueQuick(cvCVar, 0);
else
if(cvCVar->integer == 0)
// CVar is 0; Specify Value
- Cvar_SetQuick(cvCVar, Cmd_Argv(2) );
+ Cvar_SetQuick(cvCVar, Cmd_Argv(cmd, 2) );
else
// CVar does not match; Reset to 0
Cvar_SetValueQuick(cvCVar, 0);
for(nCnt = 2; nCnt < nNumArgs; nCnt++)
{ // Cycle through Values
- if( strcmp(cvCVar->string, Cmd_Argv(nCnt) ) == 0)
+ if( strcmp(cvCVar->string, Cmd_Argv(cmd, nCnt) ) == 0)
{ // Current Value Located; Increment to Next
if( (nCnt + 1) == nNumArgs)
// Max Value Reached; Reset
- Cvar_SetQuick(cvCVar, Cmd_Argv(2) );
+ Cvar_SetQuick(cvCVar, Cmd_Argv(cmd, 2) );
else
// Next Value
- Cvar_SetQuick(cvCVar, Cmd_Argv(nCnt + 1) );
+ Cvar_SetQuick(cvCVar, Cmd_Argv(cmd, nCnt + 1) );
// End Loop
nCnt = nNumArgs;
}
if(!bFound)
// Value not Found; Reset to Original
- Cvar_SetQuick(cvCVar, Cmd_Argv(2) );
+ Cvar_SetQuick(cvCVar, Cmd_Argv(cmd, 2) );
}
}
else
{ // Invalid CVar
- Con_Printf("ERROR : CVar '%s' not found\n", Cmd_Argv(1) );
+ Con_Printf("ERROR : CVar '%s' not found\n", Cmd_Argv(cmd, 1) );
}
}
}
Creates a new command that executes a command string (possibly ; seperated)
===============
*/
-static void Cmd_Alias_f (void)
+static void Cmd_Alias_f (cmd_state_t *cmd)
{
cmdalias_t *a;
- char cmd[MAX_INPUTLINE];
+ char line[MAX_INPUTLINE];
int i, c;
const char *s;
size_t alloclen;
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
Con_Print("Current alias commands:\n");
- for (a = cmd_alias ; a ; a=a->next)
+ for (a = cmd->alias ; a ; a=a->next)
Con_Printf("%s : %s", a->name, a->value);
return;
}
- s = Cmd_Argv(1);
+ s = Cmd_Argv(cmd, 1);
if (strlen(s) >= MAX_ALIAS_NAME)
{
Con_Print("Alias name is too long\n");
}
// if the alias already exists, reuse it
- for (a = cmd_alias ; a ; a=a->next)
+ for (a = cmd->alias ; a ; a=a->next)
{
if (!strcmp(s, a->name))
{
a = (cmdalias_t *)Z_Malloc (sizeof(cmdalias_t));
strlcpy (a->name, s, sizeof (a->name));
// insert it at the right alphanumeric position
- for( prev = NULL, current = cmd_alias ; current && strcmp( current->name, a->name ) < 0 ; prev = current, current = current->next )
+ for( prev = NULL, current = cmd->alias ; current && strcmp( current->name, a->name ) < 0 ; prev = current, current = current->next )
;
if( prev ) {
prev->next = a;
} else {
- cmd_alias = a;
+ cmd->alias = a;
}
a->next = current;
}
// copy the rest of the command line
- cmd[0] = 0; // start out with a null string
- c = Cmd_Argc();
+ line[0] = 0; // start out with a null string
+ c = Cmd_Argc(cmd);
for (i=2 ; i < c ; i++)
{
if (i != 2)
- strlcat (cmd, " ", sizeof (cmd));
- strlcat (cmd, Cmd_Argv(i), sizeof (cmd));
+ strlcat (line, " ", sizeof (line));
+ strlcat (line, Cmd_Argv(cmd, i), sizeof (line));
}
- strlcat (cmd, "\n", sizeof (cmd));
+ strlcat (line, "\n", sizeof (line));
- alloclen = strlen (cmd) + 1;
+ alloclen = strlen (line) + 1;
if(alloclen >= 2)
- cmd[alloclen - 2] = '\n'; // to make sure a newline is appended even if too long
+ line[alloclen - 2] = '\n'; // to make sure a newline is appended even if too long
a->value = (char *)Z_Malloc (alloclen);
- memcpy (a->value, cmd, alloclen);
+ memcpy (a->value, line, alloclen);
}
/*
Remove existing aliases.
===============
*/
-static void Cmd_UnAlias_f (void)
+static void Cmd_UnAlias_f (cmd_state_t *cmd)
{
cmdalias_t *a, *p;
int i;
const char *s;
- if(Cmd_Argc() == 1)
+ if(Cmd_Argc(cmd) == 1)
{
Con_Print("unalias: Usage: unalias alias1 [alias2 ...]\n");
return;
}
- for(i = 1; i < Cmd_Argc(); ++i)
+ for(i = 1; i < Cmd_Argc(cmd); ++i)
{
- s = Cmd_Argv(i);
+ s = Cmd_Argv(cmd, i);
p = NULL;
- for(a = cmd_alias; a; p = a, a = a->next)
+ for(a = cmd->alias; a; p = a, a = a->next)
{
if(!strcmp(s, a->name))
{
if (a->initstate) // we can not remove init aliases
continue;
- if(a == cmd_alias)
- cmd_alias = a->next;
+ if(a == cmd->alias)
+ cmd->alias = a->next;
if(p)
p->next = a->next;
Z_Free(a->value);
=============================================================================
*/
-typedef struct cmd_function_s
-{
- struct cmd_function_s *next;
- const char *name;
- const char *description;
- xcommand_t consolefunction;
- xcommand_t clientfunction;
- qboolean csqcfunc;
- qboolean initstate; // indicates this command existed at init
-} cmd_function_t;
-
-static int cmd_argc;
-static const char *cmd_argv[MAX_ARGS];
-static const char *cmd_null_string = "";
-static const char *cmd_args;
-cmd_source_t cmd_source;
-
-
-static cmd_function_t *cmd_functions; // possible commands to execute
-
-static const char *Cmd_GetDirectCvarValue(const char *varname, cmdalias_t *alias, qboolean *is_multiple)
+static const char *Cmd_GetDirectCvarValue(cmd_state_t *cmd, const char *varname, cmdalias_t *alias, qboolean *is_multiple)
{
cvar_t *cvar;
long argno;
{
if(is_multiple)
*is_multiple = true;
- return Cmd_Args();
+ return Cmd_Args(cmd);
}
else if(!strcmp(varname, "#"))
{
- return va(vabuf, sizeof(vabuf), "%d", Cmd_Argc());
+ return va(vabuf, sizeof(vabuf), "%d", Cmd_Argc(cmd));
}
else if(varname[strlen(varname) - 1] == '-')
{
if(endptr == varname + strlen(varname) - 1)
{
// whole string is a number, apart from the -
- const char *p = Cmd_Args();
+ const char *p = Cmd_Args(cmd);
for(; argno > 1; --argno)
if(!COM_ParseToken_Console(&p))
break;
{
// whole string is a number
// NOTE: we already made sure we don't have an empty cvar name!
- if(argno >= 0 && argno < Cmd_Argc())
- return Cmd_Argv(argno);
+ if(argno >= 0 && argno < Cmd_Argc(cmd))
+ return Cmd_Argv(cmd, argno);
}
}
}
return false;
}
-static const char *Cmd_GetCvarValue(const char *var, size_t varlen, cmdalias_t *alias)
+static const char *Cmd_GetCvarValue(cmd_state_t *cmd, const char *var, size_t varlen, cmdalias_t *alias)
{
static char varname[MAX_INPUTLINE]; // cmd_mutex
static char varval[MAX_INPUTLINE]; // cmd_mutex
}
if(varname[0] == '$')
- varstr = Cmd_GetDirectCvarValue(Cmd_GetDirectCvarValue(varname + 1, alias, NULL), alias, NULL);
+ varstr = Cmd_GetDirectCvarValue(cmd, Cmd_GetDirectCvarValue(cmd, varname + 1, alias, NULL), alias, NULL);
else
{
qboolean is_multiple = false;
// Exception: $* and $n- don't use the quoted form by default
- varstr = Cmd_GetDirectCvarValue(varname, alias, &is_multiple);
+ varstr = Cmd_GetDirectCvarValue(cmd, varname, alias, &is_multiple);
if(is_multiple)
if(!varfunc)
varfunc = asis;
Preprocesses strings and replaces $*, $param#, $cvar accordingly. Also strips comments.
*/
-static qboolean Cmd_PreprocessString( const char *intext, char *outtext, unsigned maxoutlen, cmdalias_t *alias ) {
+static qboolean Cmd_PreprocessString(cmd_state_t *cmd, const char *intext, char *outtext, unsigned maxoutlen, cmdalias_t *alias ) {
const char *in;
size_t eat, varlen;
unsigned outlen;
varlen = strcspn(in + 1, "}");
if(in[varlen + 1] == '}')
{
- val = Cmd_GetCvarValue(in + 1, varlen, alias);
+ val = Cmd_GetCvarValue(cmd, in + 1, varlen, alias);
if(!val)
return false;
eat = varlen + 2;
}
} else {
varlen = strspn(in, "#*0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-");
- val = Cmd_GetCvarValue(in, varlen, alias);
+ val = Cmd_GetCvarValue(cmd, in, varlen, alias);
if(!val)
return false;
eat = varlen;
Called for aliases and fills in the alias into the cbuffer
============
*/
-static void Cmd_ExecuteAlias (cmdalias_t *alias)
+static void Cmd_ExecuteAlias (cmd_state_t *cmd, cmdalias_t *alias)
{
static char buffer[ MAX_INPUTLINE ]; // cmd_mutex
static char buffer2[ MAX_INPUTLINE ]; // cmd_mutex
- qboolean ret = Cmd_PreprocessString( alias->value, buffer, sizeof(buffer) - 2, alias );
+ qboolean ret = Cmd_PreprocessString( cmd, alias->value, buffer, sizeof(buffer) - 2, alias );
if(!ret)
return;
// insert at start of command buffer, so that aliases execute in order
// have to make sure that no second variable expansion takes place, otherwise
// alias parameters containing dollar signs can have bad effects.
Cmd_QuoteString(buffer2, sizeof(buffer2), buffer, "$", false);
- Cbuf_InsertText( buffer2 );
+ Cbuf_InsertText(cmd, buffer2);
}
/*
========
*/
-static void Cmd_List_f (void)
+static void Cmd_List_f (cmd_state_t *cmd)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
const char *partial;
size_t len;
int count;
qboolean ispattern;
- if (Cmd_Argc() > 1)
+ if (Cmd_Argc(cmd) > 1)
{
- partial = Cmd_Argv (1);
+ partial = Cmd_Argv(cmd, 1);
len = strlen(partial);
ispattern = (strchr(partial, '*') || strchr(partial, '?'));
}
}
count = 0;
- for (cmd = cmd_functions; cmd; cmd = cmd->next)
+ for (func = cmd->functions; func; func = func->next)
{
- if (partial && (ispattern ? !matchpattern_with_separator(cmd->name, partial, false, "", false) : strncmp(partial, cmd->name, len)))
+ if (partial && (ispattern ? !matchpattern_with_separator(func->name, partial, false, "", false) : strncmp(partial, func->name, len)))
continue;
- Con_Printf("%s : %s\n", cmd->name, cmd->description);
+ Con_Printf("%s : %s\n", func->name, func->description);
count++;
}
Con_Printf("%i Command%s\n\n", count, (count > 1) ? "s" : "");
}
-static void Cmd_Apropos_f(void)
+static void Cmd_Apropos_f(cmd_state_t *cmd)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
cvar_t *cvar;
cmdalias_t *alias;
const char *partial;
qboolean ispattern;
char vabuf[1024];
- if (Cmd_Argc() > 1)
- partial = Cmd_Args();
+ if (Cmd_Argc(cmd) > 1)
+ partial = Cmd_Args(cmd);
else
{
Con_Printf("usage: apropos <string>\n");
Con_Printf ("cvar ^3%s^7 is \"%s\" [\"%s\"] %s\n", cvar->name, cvar->string, cvar->defstring, cvar->description);
count++;
}
- for (cmd = cmd_functions; cmd; cmd = cmd->next)
+ for (func = cmd->functions; func; func = func->next)
{
- if (!matchpattern_with_separator(cmd->name, partial, true, "", false))
- if (!matchpattern_with_separator(cmd->description, partial, true, "", false))
+ if (!matchpattern_with_separator(func->name, partial, true, "", false))
+ if (!matchpattern_with_separator(func->description, partial, true, "", false))
continue;
- Con_Printf("command ^2%s^7: %s\n", cmd->name, cmd->description);
+ Con_Printf("command ^2%s^7: %s\n", func->name, func->description);
count++;
}
- for (alias = cmd_alias; alias; alias = alias->next)
+ for (alias = cmd->alias; alias; alias = alias->next)
{
// procede here a bit differently as an alias value always got a final \n
if (!matchpattern_with_separator(alias->name, partial, true, "", false))
Cmd_Init
============
*/
-void Cmd_Init (void)
+void Cmd_Init(void)
{
- cmd_mempool = Mem_AllocPool("commands", 0, NULL);
- // space for commands and script files
- cmd_text.data = cmd_text_buf;
- cmd_text.maxsize = sizeof(cmd_text_buf);
- cmd_text.cursize = 0;
-
- if (Thread_HasThreads())
- cmd_text_mutex = Thread_CreateMutex();
+ cmd_iter_t *cmd_iter;
+ for (cmd_iter = cmd_iter_all; cmd_iter->cmd; cmd_iter++)
+ {
+ cmd_state_t *cmd = cmd_iter->cmd;
+ cmd->mempool = Mem_AllocPool("commands", 0, NULL);
+ // space for commands and script files
+ cmd->text.data = cmd->text_buf;
+ cmd->text.maxsize = sizeof(cmd->text_buf);
+ cmd->text.cursize = 0;
+ cmd->null_string = "";
+ }
}
-void Cmd_Init_Commands (void)
+void Cmd_Init_Commands(qboolean dedicated_server)
{
//
// register our commands
//
- Cmd_AddCommand ("stuffcmds",Cmd_StuffCmds_f, "execute commandline parameters (must be present in quake.rc script)");
- Cmd_AddCommand ("exec",Cmd_Exec_f, "execute a script file");
- Cmd_AddCommand ("echo",Cmd_Echo_f, "print a message to the console (useful in scripts)");
- Cmd_AddCommand ("alias",Cmd_Alias_f, "create a script function (parameters are passed in as $X (being X a number), $* for all parameters, $X- for all parameters starting from $X). Without arguments show the list of all alias");
- Cmd_AddCommand ("unalias",Cmd_UnAlias_f, "remove an alias");
- Cmd_AddCommand ("cmd", Cmd_ForwardToServer, "send a console commandline to the server (used by some mods)");
- Cmd_AddCommand ("wait", Cmd_Wait_f, "make script execution wait for next rendered frame");
- Cmd_AddCommand ("set", Cvar_Set_f, "create or change the value of a console variable");
- Cmd_AddCommand ("seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to config.cfg");
- Cmd_AddCommand ("unset", Cvar_Del_f, "delete a cvar (does not work for static ones like _cl_name, or read-only ones)");
+ // client-only commands
+ Cmd_AddCommand(&cmd_client, "cmd", Cmd_ForwardToServer_f, "send a console commandline to the server (used by some mods)");
+ Cmd_AddCommand(&cmd_client, "wait", Cmd_Wait_f, "make script execution wait for next rendered frame");
+ Cmd_AddCommand(&cmd_client, "cprint", Cmd_Centerprint_f, "print something at the screen center");
+
+ // maintenance commands used for upkeep of cvars and saved configs
+ Cmd_AddCommand(&cmd_client, "stuffcmds", Cmd_StuffCmds_f, "execute commandline parameters (must be present in quake.rc script)");
+ Cmd_AddCommand(&cmd_client, "cvar_lockdefaults", Cvar_LockDefaults_f, "stores the current values of all cvars into their default values, only used once during startup after parsing default.cfg");
+ Cmd_AddCommand(&cmd_client, "cvar_resettodefaults_all", Cvar_ResetToDefaults_All_f, "sets all cvars to their locked default values");
+ Cmd_AddCommand(&cmd_client, "cvar_resettodefaults_nosaveonly", Cvar_ResetToDefaults_NoSaveOnly_f, "sets all non-saved cvars to their locked default values (variables that will not be saved to config.cfg)");
+ Cmd_AddCommand(&cmd_client, "cvar_resettodefaults_saveonly", Cvar_ResetToDefaults_SaveOnly_f, "sets all saved cvars to their locked default values (variables that will be saved to config.cfg)");
+ Cmd_AddCommand(&cmd_server, "stuffcmds", Cmd_StuffCmds_f, "execute commandline parameters (must be present in quake.rc script)");
+ Cmd_AddCommand(&cmd_server, "cvar_lockdefaults", Cvar_LockDefaults_f, "stores the current values of all cvars into their default values, only used once during startup after parsing default.cfg");
+ Cmd_AddCommand(&cmd_server, "cvar_resettodefaults_all", Cvar_ResetToDefaults_All_f, "sets all cvars to their locked default values");
+ Cmd_AddCommand(&cmd_server, "cvar_resettodefaults_nosaveonly", Cvar_ResetToDefaults_NoSaveOnly_f, "sets all non-saved cvars to their locked default values (variables that will not be saved to config.cfg)");
+ Cmd_AddCommand(&cmd_server, "cvar_resettodefaults_saveonly", Cvar_ResetToDefaults_SaveOnly_f, "sets all saved cvars to their locked default values (variables that will be saved to config.cfg)");
+
+ // general console commands used in multiple environments
+ Cmd_AddCommand(&cmd_client, "exec", Cmd_Exec_f, "execute a script file");
+ Cmd_AddCommand(&cmd_client, "echo",Cmd_Echo_f, "print a message to the console (useful in scripts)");
+ Cmd_AddCommand(&cmd_client, "alias",Cmd_Alias_f, "create a script function (parameters are passed in as $X (being X a number), $* for all parameters, $X- for all parameters starting from $X). Without arguments show the list of all alias");
+ Cmd_AddCommand(&cmd_client, "unalias",Cmd_UnAlias_f, "remove an alias");
+ Cmd_AddCommand(&cmd_client, "set", Cvar_Set_f, "create or change the value of a console variable");
+ Cmd_AddCommand(&cmd_client, "seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to config.cfg");
+ Cmd_AddCommand(&cmd_client, "unset", Cvar_Del_f, "delete a cvar (does not work for static ones like _cl_name, or read-only ones)");
+ Cmd_AddCommand(&cmd_clientfromserver, "exec", Cmd_Exec_f, "execute a script file");
+ Cmd_AddCommand(&cmd_clientfromserver, "echo", Cmd_Echo_f, "print a message to the console (useful in scripts)");
+ Cmd_AddCommand(&cmd_clientfromserver, "alias", Cmd_Alias_f, "create a script function (parameters are passed in as $X (being X a number), $* for all parameters, $X- for all parameters starting from $X). Without arguments show the list of all alias");
+ Cmd_AddCommand(&cmd_clientfromserver, "unalias", Cmd_UnAlias_f, "remove an alias");
+ Cmd_AddCommand(&cmd_clientfromserver, "set", Cvar_Set_f, "create or change the value of a console variable");
+ Cmd_AddCommand(&cmd_clientfromserver, "seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to config.cfg");
+ Cmd_AddCommand(&cmd_clientfromserver, "unset", Cvar_Del_f, "delete a cvar (does not work for static ones like _cl_name, or read-only ones)");
+ Cmd_AddCommand(&cmd_server, "exec", Cmd_Exec_f, "execute a script file");
+ Cmd_AddCommand(&cmd_server, "echo", Cmd_Echo_f, "print a message to the console (useful in scripts)");
+ Cmd_AddCommand(&cmd_server, "alias", Cmd_Alias_f, "create a script function (parameters are passed in as $X (being X a number), $* for all parameters, $X- for all parameters starting from $X). Without arguments show the list of all alias");
+ Cmd_AddCommand(&cmd_server, "unalias", Cmd_UnAlias_f, "remove an alias");
+ Cmd_AddCommand(&cmd_server, "set", Cvar_Set_f, "create or change the value of a console variable");
+ Cmd_AddCommand(&cmd_server, "seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to config.cfg");
+ Cmd_AddCommand(&cmd_server, "unset", Cvar_Del_f, "delete a cvar (does not work for static ones like _cl_name, or read-only ones)");
+
#ifdef FILLALLCVARSWITHRUBBISH
- Cmd_AddCommand ("fillallcvarswithrubbish", Cvar_FillAll_f, "fill all cvars with a specified number of characters to provoke buffer overruns");
+ Cmd_AddCommand(&cmd_client, "fillallcvarswithrubbish", Cvar_FillAll_f, "fill all cvars with a specified number of characters to provoke buffer overruns");
+ Cmd_AddCommand(&cmd_server, "fillallcvarswithrubbish", Cvar_FillAll_f, "fill all cvars with a specified number of characters to provoke buffer overruns");
#endif /* FILLALLCVARSWITHRUBBISH */
// 2000-01-09 CmdList, CvarList commands By Matthias "Maddes" Buecher
// Added/Modified by EvilTypeGuy eviltypeguy@qeradiant.com
- Cmd_AddCommand ("cmdlist", Cmd_List_f, "lists all console commands beginning with the specified prefix or matching the specified wildcard pattern");
- Cmd_AddCommand ("cvarlist", Cvar_List_f, "lists all console variables beginning with the specified prefix or matching the specified wildcard pattern");
- Cmd_AddCommand ("apropos", Cmd_Apropos_f, "lists all console variables/commands/aliases containing the specified string in the name or description");
-
- Cmd_AddCommand ("cvar_lockdefaults", Cvar_LockDefaults_f, "stores the current values of all cvars into their default values, only used once during startup after parsing default.cfg");
- Cmd_AddCommand ("cvar_resettodefaults_all", Cvar_ResetToDefaults_All_f, "sets all cvars to their locked default values");
- Cmd_AddCommand ("cvar_resettodefaults_nosaveonly", Cvar_ResetToDefaults_NoSaveOnly_f, "sets all non-saved cvars to their locked default values (variables that will not be saved to config.cfg)");
- Cmd_AddCommand ("cvar_resettodefaults_saveonly", Cvar_ResetToDefaults_SaveOnly_f, "sets all saved cvars to their locked default values (variables that will be saved to config.cfg)");
+ Cmd_AddCommand(&cmd_client, "cmdlist", Cmd_List_f, "lists all console commands beginning with the specified prefix or matching the specified wildcard pattern");
+ Cmd_AddCommand(&cmd_client, "cvarlist", Cvar_List_f, "lists all console variables beginning with the specified prefix or matching the specified wildcard pattern");
+ Cmd_AddCommand(&cmd_client, "apropos", Cmd_Apropos_f, "lists all console variables/commands/aliases containing the specified string in the name or description");
+ Cmd_AddCommand(&cmd_server, "cmdlist", Cmd_List_f, "lists all console commands beginning with the specified prefix or matching the specified wildcard pattern");
+ Cmd_AddCommand(&cmd_server, "cvarlist", Cvar_List_f, "lists all console variables beginning with the specified prefix or matching the specified wildcard pattern");
+ Cmd_AddCommand(&cmd_server, "apropos", Cmd_Apropos_f, "lists all console variables/commands/aliases containing the specified string in the name or description");
- Cmd_AddCommand ("cprint", Cmd_Centerprint_f, "print something at the screen center");
- Cmd_AddCommand ("defer", Cmd_Defer_f, "execute a command in the future");
+ Cmd_AddCommand(&cmd_client, "defer", Cmd_Defer_f, "execute a command in the future");
+ Cmd_AddCommand(&cmd_server, "defer", Cmd_Defer_f, "execute a command in the future");
// DRESK - 5/14/06
// Support Doom3-style Toggle Command
- Cmd_AddCommand( "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)");
+ Cmd_AddCommand(&cmd_client, "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)");
+ Cmd_AddCommand(&cmd_server, "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)");
+ Cmd_AddCommand(&cmd_clientfromserver, "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)");
}
/*
*/
void Cmd_Shutdown(void)
{
- if (cmd_text_mutex)
+ cmd_iter_t *cmd_iter;
+ for (cmd_iter = cmd_iter_all; cmd_iter->cmd; cmd_iter++)
{
- // we usually have this locked when we get here from Host_Quit_f
- Cbuf_UnlockThreadMutex();
- Thread_DestroyMutex(cmd_text_mutex);
- }
- cmd_text_mutex = NULL;
+ cmd_state_t *cmd = cmd_iter->cmd;
- Mem_FreePool(&cmd_mempool);
+ if (cmd->text_lock)
+ {
+ // we usually have this locked when we get here from Host_Quit_f
+ Cbuf_Unlock(cmd);
+ }
+
+ Mem_FreePool(&cmd->mempool);
+ }
}
/*
Cmd_Argc
============
*/
-int Cmd_Argc (void)
+int Cmd_Argc (cmd_state_t *cmd)
{
- return cmd_argc;
+ return cmd->argc;
}
/*
Cmd_Argv
============
*/
-const char *Cmd_Argv (int arg)
+const char *Cmd_Argv(cmd_state_t *cmd, int arg)
{
- if (arg >= cmd_argc )
- return cmd_null_string;
- return cmd_argv[arg];
+ if (arg >= cmd->argc )
+ return cmd->null_string;
+ return cmd->argv[arg];
}
/*
Cmd_Args
============
*/
-const char *Cmd_Args (void)
+const char *Cmd_Args (cmd_state_t *cmd)
{
- return cmd_args;
+ return cmd->args;
}
============
*/
// AK: This function should only be called from ExcuteString because the current design is a bit of an hack
-static void Cmd_TokenizeString (const char *text)
+static void Cmd_TokenizeString (cmd_state_t *cmd, const char *text)
{
int l;
- cmd_argc = 0;
- cmd_args = NULL;
+ cmd->argc = 0;
+ cmd->args = NULL;
while (1)
{
if (!*text)
return;
- if (cmd_argc == 1)
- cmd_args = text;
+ if (cmd->argc == 1)
+ cmd->args = text;
if (!COM_ParseToken_Console(&text))
return;
- if (cmd_argc < MAX_ARGS)
+ if (cmd->argc < MAX_ARGS)
{
l = (int)strlen(com_token) + 1;
- if (cmd_tokenizebufferpos + l > CMD_TOKENIZELENGTH)
+ if (cmd->tokenizebufferpos + l > CMD_TOKENIZELENGTH)
{
Con_Printf("Cmd_TokenizeString: ran out of %i character buffer space for command arguements\n", CMD_TOKENIZELENGTH);
break;
}
- memcpy (cmd_tokenizebuffer + cmd_tokenizebufferpos, com_token, l);
- cmd_argv[cmd_argc] = cmd_tokenizebuffer + cmd_tokenizebufferpos;
- cmd_tokenizebufferpos += l;
- cmd_argc++;
+ memcpy (cmd->tokenizebuffer + cmd->tokenizebufferpos, com_token, l);
+ cmd->argv[cmd->argc] = cmd->tokenizebuffer + cmd->tokenizebufferpos;
+ cmd->tokenizebufferpos += l;
+ cmd->argc++;
}
}
}
Cmd_AddCommand
============
*/
-void Cmd_AddCommand_WithClientCommand (const char *cmd_name, xcommand_t consolefunction, xcommand_t clientfunction, const char *description)
+void Cmd_AddCommand(cmd_state_t *cmd, const char *cmd_name, xcommand_t function, const char *description)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
cmd_function_t *prev, *current;
// fail if the command is a variable name
return;
}
-// fail if the command already exists
- for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
+ // fail if the command already exists in this interpreter
+ for (func = cmd->functions; func; func = func->next)
+ if (!strcmp(cmd_name, func->name))
+ break;
+
+ if (func)
{
- if (!strcmp (cmd_name, cmd->name))
- {
- if (consolefunction || clientfunction)
- {
- Con_Printf("Cmd_AddCommand: %s already defined\n", cmd_name);
- return;
- }
- else //[515]: csqc
- {
- cmd->csqcfunc = true;
- return;
- }
- }
+ // command already defined...
+ if (function)
+ Con_Printf("Cmd_AddCommand: %s already defined\n", cmd_name);
+ else //[515]: csqc
+ func->csqcfunc = true;
}
+ else
+ {
+ func = (cmd_function_t *)Mem_Alloc(cmd->mempool, sizeof(cmd_function_t));
+ func->name = cmd_name;
+ func->function = function;
+ func->description = description;
+ if (!function) //[515]: csqc
+ func->csqcfunc = true;
+ func->next = cmd->functions;
- cmd = (cmd_function_t *)Mem_Alloc(cmd_mempool, sizeof(cmd_function_t));
- cmd->name = cmd_name;
- cmd->consolefunction = consolefunction;
- cmd->clientfunction = clientfunction;
- cmd->description = description;
- if(!consolefunction && !clientfunction) //[515]: csqc
- cmd->csqcfunc = true;
- cmd->next = cmd_functions;
-
-// insert it at the right alphanumeric position
- for( prev = NULL, current = cmd_functions ; current && strcmp( current->name, cmd->name ) < 0 ; prev = current, current = current->next )
- ;
- if( prev ) {
- prev->next = cmd;
- } else {
- cmd_functions = cmd;
+ // insert it at the right alphanumeric position
+ for (prev = NULL, current = cmd->functions; current && strcmp(current->name, func->name) < 0; prev = current, current = current->next)
+ ;
+ if (prev) {
+ prev->next = func;
+ }
+ else {
+ cmd->functions = func;
+ }
+ func->next = current;
}
- cmd->next = current;
-}
-
-void Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description)
-{
- Cmd_AddCommand_WithClientCommand (cmd_name, function, NULL, description);
}
/*
Cmd_Exists
============
*/
-qboolean Cmd_Exists (const char *cmd_name)
+qboolean Cmd_Exists (cmd_state_t *cmd, const char *cmd_name)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
- for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
- if (!strcmp (cmd_name,cmd->name))
+ for (func=cmd->functions ; func ; func=func->next)
+ if (!strcmp (cmd_name,func->name))
return true;
return false;
Cmd_CompleteCommand
============
*/
-const char *Cmd_CompleteCommand (const char *partial)
+const char *Cmd_CompleteCommand (cmd_state_t *cmd, const char *partial)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
size_t len;
len = strlen(partial);
return NULL;
// check functions
- for (cmd = cmd_functions; cmd; cmd = cmd->next)
- if (!strncasecmp(partial, cmd->name, len))
- return cmd->name;
+ for (func = cmd->functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
+ return func->name;
return NULL;
}
Thanks to taniwha
*/
-int Cmd_CompleteCountPossible (const char *partial)
+int Cmd_CompleteCountPossible (cmd_state_t *cmd, const char *partial)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
size_t len;
int h;
return 0;
// Loop through the command list and count all partial matches
- for (cmd = cmd_functions; cmd; cmd = cmd->next)
- if (!strncasecmp(partial, cmd->name, len))
+ for (func = cmd->functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
h++;
return h;
Thanks to taniwha
*/
-const char **Cmd_CompleteBuildList (const char *partial)
+const char **Cmd_CompleteBuildList (cmd_state_t *cmd, const char *partial)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
size_t len = 0;
size_t bpos = 0;
- size_t sizeofbuf = (Cmd_CompleteCountPossible (partial) + 1) * sizeof (const char *);
+ size_t sizeofbuf = (Cmd_CompleteCountPossible (cmd, partial) + 1) * sizeof (const char *);
const char **buf;
len = strlen(partial);
buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
// Loop through the alias list and print all matches
- for (cmd = cmd_functions; cmd; cmd = cmd->next)
- if (!strncasecmp(partial, cmd->name, len))
- buf[bpos++] = cmd->name;
+ for (func = cmd->functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
+ buf[bpos++] = func->name;
buf[bpos] = NULL;
return buf;
}
// written by LadyHavoc
-void Cmd_CompleteCommandPrint (const char *partial)
+void Cmd_CompleteCommandPrint (cmd_state_t *cmd, const char *partial)
{
- cmd_function_t *cmd;
+ cmd_function_t *func;
size_t len = strlen(partial);
// Loop through the command list and print all matches
- for (cmd = cmd_functions; cmd; cmd = cmd->next)
- if (!strncasecmp(partial, cmd->name, len))
- Con_Printf("^2%s^7: %s\n", cmd->name, cmd->description);
+ for (func = cmd->functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
+ Con_Printf("^2%s^7: %s\n", func->name, func->description);
}
/*
Thanks to taniwha
*/
-const char *Cmd_CompleteAlias (const char *partial)
+const char *Cmd_CompleteAlias (cmd_state_t *cmd, const char *partial)
{
cmdalias_t *alias;
size_t len;
return NULL;
// Check functions
- for (alias = cmd_alias; alias; alias = alias->next)
+ for (alias = cmd->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
return alias->name;
}
// written by LadyHavoc
-void Cmd_CompleteAliasPrint (const char *partial)
+void Cmd_CompleteAliasPrint (cmd_state_t *cmd, const char *partial)
{
cmdalias_t *alias;
size_t len = strlen(partial);
// Loop through the alias list and print all matches
- for (alias = cmd_alias; alias; alias = alias->next)
+ for (alias = cmd->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
Con_Printf("^5%s^7: %s", alias->name, alias->value);
}
Thanks to taniwha
*/
-int Cmd_CompleteAliasCountPossible (const char *partial)
+int Cmd_CompleteAliasCountPossible (cmd_state_t *cmd, const char *partial)
{
cmdalias_t *alias;
size_t len;
return 0;
// Loop through the command list and count all partial matches
- for (alias = cmd_alias; alias; alias = alias->next)
+ for (alias = cmd->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
h++;
Thanks to taniwha
*/
-const char **Cmd_CompleteAliasBuildList (const char *partial)
+const char **Cmd_CompleteAliasBuildList (cmd_state_t *cmd, const char *partial)
{
cmdalias_t *alias;
size_t len = 0;
size_t bpos = 0;
- size_t sizeofbuf = (Cmd_CompleteAliasCountPossible (partial) + 1) * sizeof (const char *);
+ size_t sizeofbuf = (Cmd_CompleteAliasCountPossible (cmd, partial) + 1) * sizeof (const char *);
const char **buf;
len = strlen(partial);
buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
// Loop through the alias list and print all matches
- for (alias = cmd_alias; alias; alias = alias->next)
+ for (alias = cmd->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
buf[bpos++] = alias->name;
return buf;
}
-void Cmd_ClearCsqcFuncs (void)
+void Cmd_ClearCsqcFuncs (cmd_state_t *cmd)
{
- cmd_function_t *cmd;
- for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
- cmd->csqcfunc = false;
+ cmd_function_t *func;
+ for (func = cmd->functions; func; func = func->next)
+ func->csqcfunc = false;
}
/*
FIXME: lookupnoadd the token to speed search?
============
*/
-void Cmd_ExecuteString (const char *text, cmd_source_t src, qboolean lockmutex)
+void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qboolean lockmutex)
{
int oldpos;
- int found;
- cmd_function_t *cmd;
+ cmd_function_t *func;
cmdalias_t *a;
if (lockmutex)
- Cbuf_LockThreadMutex();
- oldpos = cmd_tokenizebufferpos;
- cmd_source = src;
- found = false;
+ Cbuf_Lock(cmd);
+ oldpos = cmd->tokenizebufferpos;
+ cmd->source = src;
- Cmd_TokenizeString (text);
+ Cmd_TokenizeString (cmd, text);
// execute the command line
- if (!Cmd_Argc())
+ if (!Cmd_Argc(cmd))
goto done; // no tokens
// check functions
- for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
+ for (func = cmd->functions; func; func=func->next)
{
- if (!strcasecmp (cmd_argv[0],cmd->name))
+ if (!strcasecmp (cmd->argv[0], func->name))
{
- if (cmd->csqcfunc && CL_VM_ConsoleCommand (text)) //[515]: csqc
+ if (func->csqcfunc && CL_VM_ConsoleCommand (text)) //[515]: csqc
goto done;
switch (src)
{
case src_command:
- if (cmd->consolefunction)
- cmd->consolefunction ();
- else if (cmd->clientfunction)
- {
- if (cls.state == ca_connected)
- {
- // forward remote commands to the server for execution
- Cmd_ForwardToServer();
- }
- else
- Con_Printf("Can not send command \"%s\", not connected.\n", Cmd_Argv(0));
- }
+ if (func->function)
+ func->function(cmd);
else
- Con_Printf("Command \"%s\" can not be executed\n", Cmd_Argv(0));
- found = true;
- goto command_found;
+ Con_Printf("Command \"%s\" can not be executed\n", Cmd_Argv(cmd, 0));
+ goto done;
case src_client:
- if (cmd->clientfunction)
+ if (func->function)
{
- cmd->clientfunction ();
+ func->function(cmd);
goto done;
}
- break;
}
break;
}
}
-command_found:
// if it's a client command and no command was found, say so.
- if (cmd_source == src_client)
+ if (cmd->source == src_client)
{
Con_Printf("player \"%s\" tried to %s\n", host_client->name, text);
goto done;
}
// check alias
- for (a=cmd_alias ; a ; a=a->next)
+ for (a=cmd->alias ; a ; a=a->next)
{
- if (!strcasecmp (cmd_argv[0], a->name))
+ if (!strcasecmp (cmd->argv[0], a->name))
{
- Cmd_ExecuteAlias(a);
+ Cmd_ExecuteAlias(cmd, a);
goto done;
}
}
- if(found) // if the command was hooked and found, all is good
- goto done;
-
// check cvars
- if (!Cvar_Command () && host_framecount > 0)
- Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(0));
+ if (!Cvar_Command (cmd) && host_framecount > 0)
+ Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0));
done:
- cmd_tokenizebufferpos = oldpos;
+ cmd->tokenizebufferpos = oldpos;
if (lockmutex)
- Cbuf_UnlockThreadMutex();
+ Cbuf_Unlock(cmd);
}
Sends the entire command line over to the server
===================
*/
-void Cmd_ForwardToServer (void)
+void Cmd_ForwardToServer_f (cmd_state_t *cmd)
{
const char *s;
char vabuf[1024];
- if (!strcasecmp(Cmd_Argv(0), "cmd"))
+ if (!strcasecmp(Cmd_Argv(cmd, 0), "cmd"))
{
// we want to strip off "cmd", so just send the args
- s = Cmd_Argc() > 1 ? Cmd_Args() : "";
+ s = Cmd_Argc(cmd) > 1 ? Cmd_Args(cmd) : "";
}
else
{
- // we need to keep the command name, so send Cmd_Argv(0), a space and then Cmd_Args()
- s = va(vabuf, sizeof(vabuf), "%s %s", Cmd_Argv(0), Cmd_Argc() > 1 ? Cmd_Args() : "");
+ // we need to keep the command name, so send Cmd_Argv(cmd, 0), a space and then Cmd_Args(cmd)
+ s = va(vabuf, sizeof(vabuf), "%s %s", Cmd_Argv(cmd, 0), Cmd_Argc(cmd) > 1 ? Cmd_Args(cmd) : "");
}
// don't send an empty forward message if the user tries "cmd" by itself
if (!s || !*s)
================
*/
-int Cmd_CheckParm (const char *parm)
+int Cmd_CheckParm (cmd_state_t *cmd, const char *parm)
{
int i;
return 0;
}
- for (i = 1; i < Cmd_Argc (); i++)
- if (!strcasecmp (parm, Cmd_Argv (i)))
+ for (i = 1; i < Cmd_Argc (cmd); i++)
+ if (!strcasecmp (parm, Cmd_Argv(cmd, i)))
return i;
return 0;
void Cmd_SaveInitState(void)
{
- cmd_function_t *f;
- cmdalias_t *a;
- for (f = cmd_functions;f;f = f->next)
- f->initstate = true;
- for (a = cmd_alias;a;a = a->next)
+ cmd_iter_t *cmd_iter;
+ for (cmd_iter = cmd_iter_all; cmd_iter->cmd; cmd_iter++)
{
- a->initstate = true;
- a->initialvalue = Mem_strdup(zonemempool, a->value);
+ cmd_state_t *cmd = cmd_iter->cmd;
+ cmd_function_t *f;
+ cmdalias_t *a;
+ for (f = cmd->functions; f; f = f->next)
+ f->initstate = true;
+ for (a = cmd->alias; a; a = a->next)
+ {
+ a->initstate = true;
+ a->initialvalue = Mem_strdup(zonemempool, a->value);
+ }
}
Cvar_SaveInitState();
}
void Cmd_RestoreInitState(void)
{
- cmd_function_t *f, **fp;
- cmdalias_t *a, **ap;
- for (fp = &cmd_functions;(f = *fp);)
+ cmd_iter_t *cmd_iter;
+ for (cmd_iter = cmd_iter_all; cmd_iter->cmd; cmd_iter++)
{
- if (f->initstate)
- fp = &f->next;
- else
+ cmd_state_t *cmd = cmd_iter->cmd;
+ cmd_function_t *f, **fp;
+ cmdalias_t *a, **ap;
+ for (fp = &cmd->functions; (f = *fp);)
{
- // destroy this command, it didn't exist at init
- Con_DPrintf("Cmd_RestoreInitState: Destroying command %s\n", f->name);
- *fp = f->next;
- Z_Free(f);
+ if (f->initstate)
+ fp = &f->next;
+ else
+ {
+ // destroy this command, it didn't exist at init
+ Con_DPrintf("Cmd_RestoreInitState: Destroying command %s\n", f->name);
+ *fp = f->next;
+ Z_Free(f);
+ }
}
- }
- for (ap = &cmd_alias;(a = *ap);)
- {
- if (a->initstate)
+ for (ap = &cmd->alias; (a = *ap);)
{
- // restore this alias, it existed at init
- if (strcmp(a->value ? a->value : "", a->initialvalue ? a->initialvalue : ""))
+ if (a->initstate)
+ {
+ // restore this alias, it existed at init
+ if (strcmp(a->value ? a->value : "", a->initialvalue ? a->initialvalue : ""))
+ {
+ Con_DPrintf("Cmd_RestoreInitState: Restoring alias %s\n", a->name);
+ if (a->value)
+ Z_Free(a->value);
+ a->value = Mem_strdup(zonemempool, a->initialvalue);
+ }
+ ap = &a->next;
+ }
+ else
{
- Con_DPrintf("Cmd_RestoreInitState: Restoring alias %s\n", a->name);
+ // free this alias, it didn't exist at init...
+ Con_DPrintf("Cmd_RestoreInitState: Destroying alias %s\n", a->name);
+ *ap = a->next;
if (a->value)
Z_Free(a->value);
- a->value = Mem_strdup(zonemempool, a->initialvalue);
+ Z_Free(a);
}
- ap = &a->next;
- }
- else
- {
- // free this alias, it didn't exist at init...
- Con_DPrintf("Cmd_RestoreInitState: Destroying alias %s\n", a->name);
- *ap = a->next;
- if (a->value)
- Z_Free(a->value);
- Z_Free(a);
}
}
Cvar_RestoreInitState();
#ifndef CMD_H
#define CMD_H
-extern void *cmd_text_mutex;
-#define Cbuf_LockThreadMutex() (void)(cmd_text_mutex ? Thread_LockMutex(cmd_text_mutex) : 0)
-#define Cbuf_UnlockThreadMutex() (void)(cmd_text_mutex ? Thread_UnlockMutex(cmd_text_mutex) : 0)
+#include "thread.h"
-/// allocates an initial text buffer that will grow as needed
-void Cbuf_Init (void);
+struct cmd_state_s;
-void Cmd_Init_Commands (void);
+typedef void(*xcommand_t) (struct cmd_state_s *cmd);
-void Cbuf_Shutdown (void);
+typedef enum
+{
+ src_client, ///< came in over a net connection as a clc_stringcmd
+ ///< host_client will be valid during this state.
+ src_command ///< from the command buffer
+} cmd_source_t;
+
+typedef struct cmdalias_s
+{
+ struct cmdalias_s *next;
+ char name[MAX_ALIAS_NAME];
+ char *value;
+ qboolean initstate; // indicates this command existed at init
+ char *initialvalue; // backup copy of value at init
+} cmdalias_t;
+
+typedef struct cmd_function_s
+{
+ struct cmd_function_s *next;
+ const char *name;
+ const char *description;
+ xcommand_t function;
+ qboolean csqcfunc;
+ qboolean initstate; // indicates this command existed at init
+} cmd_function_t;
+
+typedef struct cmddeferred_s
+{
+ struct cmddeferred_s *next;
+ char *value;
+ double delay;
+} cmddeferred_t;
+
+typedef struct cmd_state_s
+{
+ cmdalias_t *alias;
+
+ qboolean wait;
+
+ mempool_t *mempool;
+
+ char tokenizebuffer[CMD_TOKENIZELENGTH];
+ int tokenizebufferpos;
+
+ cmddeferred_t *deferred_list;
+
+ sizebuf_t text;
+ unsigned char text_buf[CMDBUFSIZE];
+ Thread_SpinLock text_lock;
+
+ int argc;
+ const char *argv[MAX_ARGS];
+ const char *null_string;
+ const char *args;
+ cmd_source_t source;
+
+ cmd_function_t *functions; // possible commands to execute
+}
+cmd_state_t;
+
+// command interpreter for client commands injected by CSQC, MQC or client engine code
+extern cmd_state_t cmd_client;
+// command interpreter for client commands received over network from server
+extern cmd_state_t cmd_clientfromserver;
+// command interpreter for server commands injected by MQC, SVQC, menu engine code or server engine code
+extern cmd_state_t cmd_server;
+// command interpreter for server commands received over network from clients
+extern cmd_state_t cmd_serverfromclient;
+
+extern qboolean host_stuffcmdsrun;
+
+void Cbuf_Lock(cmd_state_t *cmd);
+void Cbuf_Unlock(cmd_state_t *cmd);
+
+void Cmd_Init_Commands(qboolean dedicated_server);
/*! as new commands are generated from the console or keybindings,
* the text is added to the end of the command buffer.
*/
-void Cbuf_AddText (const char *text);
+void Cbuf_AddText (cmd_state_t *cmd, const char *text);
/*! when a command wants to issue other commands immediately, the text is
* inserted at the beginning of the buffer, before any remaining unexecuted
* commands.
*/
-void Cbuf_InsertText (const char *text);
+void Cbuf_InsertText (cmd_state_t *cmd, const char *text);
/*! Pulls off terminated lines of text from the command buffer and sends
* them through Cmd_ExecuteString. Stops when the buffer is empty.
* Normally called once per frame, but may be explicitly invoked.
* \note Do not call inside a command function!
*/
-void Cbuf_Execute (void);
+void Cbuf_Execute (cmd_state_t *cmd);
/*! Performs deferred commands and runs Cbuf_Execute, called by Host_Main */
-void Cbuf_Frame (void);
+void Cbuf_Frame (cmd_state_t *cmd);
//===========================================================================
*/
-typedef void (*xcommand_t) (void);
-
-typedef enum
-{
- src_client, ///< came in over a net connection as a clc_stringcmd
- ///< host_client will be valid during this state.
- src_command ///< from the command buffer
-} cmd_source_t;
-
-extern cmd_source_t cmd_source;
-
-void Cmd_Init (void);
-void Cmd_Shutdown (void);
+void Cmd_Init(void);
+void Cmd_Shutdown(void);
// called by Host_Init, this marks cvars, commands and aliases with their init values
-void Cmd_SaveInitState (void);
+void Cmd_SaveInitState(void);
// called by FS_GameDir_f, this restores cvars, commands and aliases to init values
-void Cmd_RestoreInitState (void);
+void Cmd_RestoreInitState(void);
-void Cmd_AddCommand_WithClientCommand (const char *cmd_name, xcommand_t consolefunction, xcommand_t clientfunction, const char *description);
-void Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description);
+void Cmd_AddCommand(cmd_state_t *cmd, const char *cmd_name, xcommand_t function, const char *description);
// called by the init functions of other parts of the program to
// register commands and functions to call for them.
// The cmd_name is referenced later, so it should not be in temp memory
/// used by the cvar code to check for cvar / command name overlap
-qboolean Cmd_Exists (const char *cmd_name);
+qboolean Cmd_Exists (cmd_state_t *cmd, const char *cmd_name);
/// attempts to match a partial command for automatic command line completion
/// returns NULL if nothing fits
-const char *Cmd_CompleteCommand (const char *partial);
+const char *Cmd_CompleteCommand (cmd_state_t *cmd, const char *partial);
-int Cmd_CompleteAliasCountPossible (const char *partial);
+int Cmd_CompleteAliasCountPossible (cmd_state_t *cmd, const char *partial);
-const char **Cmd_CompleteAliasBuildList (const char *partial);
+const char **Cmd_CompleteAliasBuildList (cmd_state_t *cmd, const char *partial);
-int Cmd_CompleteCountPossible (const char *partial);
+int Cmd_CompleteCountPossible (cmd_state_t *cmd, const char *partial);
-const char **Cmd_CompleteBuildList (const char *partial);
+const char **Cmd_CompleteBuildList (cmd_state_t *cmd, const char *partial);
-void Cmd_CompleteCommandPrint (const char *partial);
+void Cmd_CompleteCommandPrint (cmd_state_t *cmd, const char *partial);
-const char *Cmd_CompleteAlias (const char *partial);
+const char *Cmd_CompleteAlias (cmd_state_t *cmd, const char *partial);
-void Cmd_CompleteAliasPrint (const char *partial);
+void Cmd_CompleteAliasPrint (cmd_state_t *cmd, const char *partial);
// Enhanced console completion by Fett erich@heintz.com
// Added by EvilTypeGuy eviltypeguy@qeradiant.com
-int Cmd_Argc (void);
-const char *Cmd_Argv (int arg);
-const char *Cmd_Args (void);
+int Cmd_Argc (cmd_state_t *cmd);
+const char *Cmd_Argv (cmd_state_t *cmd, int arg);
+const char *Cmd_Args (cmd_state_t *cmd);
// The functions that execute commands get their parameters with these
-// functions. Cmd_Argv () will return an empty string, not a NULL
+// functions. Cmd_Argv(cmd, ) will return an empty string, not a NULL
// if arg > argc, so string operations are always safe.
/// Returns the position (1 to argc-1) in the command's argument list
/// where the given parameter apears, or 0 if not present
-int Cmd_CheckParm (const char *parm);
+int Cmd_CheckParm (cmd_state_t *cmd, const char *parm);
//void Cmd_TokenizeString (char *text);
// Takes a null terminated string. Does not need to be /n terminated.
/// Parses a single line of text into arguments and tries to execute it.
/// The text can come from the command buffer, a remote client, or stdin.
-void Cmd_ExecuteString (const char *text, cmd_source_t src, qboolean lockmutex);
+void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qboolean lockmutex);
/// adds the string as a clc_stringcmd to the client message.
/// (used when there is no reason to generate a local command to do it)
/// adds the current command line as a clc_stringcmd to the client message.
/// things like godmode, noclip, etc, are commands directed to the server,
/// so when they are typed in at the console, they will need to be forwarded.
-void Cmd_ForwardToServer (void);
-
-/// used by command functions to send output to either the graphics console or
-/// passed as a print message to the client
-void Cmd_Print(const char *text);
+void Cmd_ForwardToServer_f (cmd_state_t *cmd);
/// quotes a string so that it can be used as a command argument again;
/// quoteset is a string that contains one or more of ", \, $ and specifies
/// enclosing quote marks are also put.
qboolean Cmd_QuoteString(char *out, size_t outlen, const char *in, const char *quoteset, qboolean putquotes);
-void Cmd_ClearCsqcFuncs (void);
+void Cmd_ClearCsqcFuncs (cmd_state_t *cmd);
#endif
Con_ToggleConsole_f
================
*/
-void Con_ToggleConsole_f (void)
+void Con_ToggleConsole_f(cmd_state_t *cmd)
{
if (COM_CheckParm ("-noconsole"))
if (!(key_consoleactive & KEY_CONSOLEACTIVE_USER))
Con_MessageMode_f
================
*/
-static void Con_MessageMode_f (void)
+static void Con_MessageMode_f(cmd_state_t *cmd)
{
key_dest = key_message;
chat_mode = 0; // "say"
- if(Cmd_Argc() > 1)
+ if(Cmd_Argc(cmd) > 1)
{
- dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args());
+ dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args(cmd));
chat_bufferlen = (unsigned int)strlen(chat_buffer);
}
}
Con_MessageMode2_f
================
*/
-static void Con_MessageMode2_f (void)
+static void Con_MessageMode2_f(cmd_state_t *cmd)
{
key_dest = key_message;
chat_mode = 1; // "say_team"
- if(Cmd_Argc() > 1)
+ if(Cmd_Argc(cmd) > 1)
{
- dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args());
+ dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args(cmd));
chat_bufferlen = (unsigned int)strlen(chat_buffer);
}
}
Con_CommandMode_f
================
*/
-static void Con_CommandMode_f (void)
+static void Con_CommandMode_f(cmd_state_t *cmd)
{
key_dest = key_message;
- if(Cmd_Argc() > 1)
+ if(Cmd_Argc(cmd) > 1)
{
- dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args());
+ dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args(cmd));
chat_bufferlen = (unsigned int)strlen(chat_buffer);
}
chat_mode = -1; // command
//[515]: the simplest command ever
//LadyHavoc: not so simple after I made it print usage...
-static void Con_Maps_f (void)
+static void Con_Maps_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() > 2)
+ if (Cmd_Argc(cmd) > 2)
{
Con_Printf("usage: maps [mapnameprefix]\n");
return;
}
- else if (Cmd_Argc() == 2)
- GetMapList(Cmd_Argv(1), NULL, 0);
+ else if (Cmd_Argc(cmd) == 2)
+ GetMapList(Cmd_Argv(cmd, 1), NULL, 0);
else
GetMapList("", NULL, 0);
}
-static void Con_ConDump_f (void)
+static void Con_ConDump_f(cmd_state_t *cmd)
{
int i;
qfile_t *file;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Printf("usage: condump <filename>\n");
return;
}
- file = FS_OpenRealFile(Cmd_Argv(1), "w", false);
+ file = FS_OpenRealFile(Cmd_Argv(cmd, 1), "w", false);
if (!file)
{
- Con_Printf("condump: unable to write file \"%s\"\n", Cmd_Argv(1));
+ Con_Printf("condump: unable to write file \"%s\"\n", Cmd_Argv(cmd, 1));
return;
}
if (con_mutex) Thread_LockMutex(con_mutex);
FS_Close(file);
}
-void Con_Clear_f (void)
+void Con_Clear_f(cmd_state_t *cmd)
{
if (con_mutex) Thread_LockMutex(con_mutex);
ConBuffer_Clear(&con);
Cvar_RegisterVariable (&condump_stripcolors);
// register our commands
- Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f, "opens or closes the console");
- Cmd_AddCommand ("messagemode", Con_MessageMode_f, "input a chat message to say to everyone");
- Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "input a chat message to say to only your team");
- Cmd_AddCommand ("commandmode", Con_CommandMode_f, "input a console command");
- Cmd_AddCommand ("clear", Con_Clear_f, "clear console history");
- Cmd_AddCommand ("maps", Con_Maps_f, "list information about available maps");
- Cmd_AddCommand ("condump", Con_ConDump_f, "output console history to a file (see also log_file)");
+ Cmd_AddCommand(&cmd_client, "toggleconsole", Con_ToggleConsole_f, "opens or closes the console");
+ Cmd_AddCommand(&cmd_client, "messagemode", Con_MessageMode_f, "input a chat message to say to everyone");
+ Cmd_AddCommand(&cmd_client, "messagemode2", Con_MessageMode2_f, "input a chat message to say to only your team");
+ Cmd_AddCommand(&cmd_client, "commandmode", Con_CommandMode_f, "input a console command");
+ Cmd_AddCommand(&cmd_client, "clear", Con_Clear_f, "clear console history");
+ Cmd_AddCommand(&cmd_client, "maps", Con_Maps_f, "list information about available maps");
+ Cmd_AddCommand(&cmd_client, "condump", Con_ConDump_f, "output console history to a file (see also log_file)");
+
+ Cmd_AddCommand(&cmd_server, "maps", Con_Maps_f, "list information about available maps");
+ Cmd_AddCommand(&cmd_server, "condump", Con_ConDump_f, "output console history to a file (see also log_file)");
con_initialized = true;
Con_DPrint("Console initialized.\n");
Enhanced to tab-complete map names by [515]
*/
-void Con_CompleteCommandLine (void)
+void Con_CompleteCommandLine (cmd_state_t *cmd)
{
- const char *cmd = "";
+ const char *text = "";
char *s;
const char **list[4] = {0, 0, 0, 0};
char s2[512];
}
// Count number of possible matches and print them
- c = Cmd_CompleteCountPossible(s);
+ c = Cmd_CompleteCountPossible(cmd, s);
if (c)
{
Con_Printf("\n%i possible command%s\n", c, (c > 1) ? "s: " : ":");
- Cmd_CompleteCommandPrint(s);
+ Cmd_CompleteCommandPrint(cmd, s);
}
v = Cvar_CompleteCountPossible(s);
if (v)
Con_Printf("\n%i possible variable%s\n", v, (v > 1) ? "s: " : ":");
Cvar_CompleteCvarPrint(s);
}
- a = Cmd_CompleteAliasCountPossible(s);
+ a = Cmd_CompleteAliasCountPossible(cmd, s);
if (a)
{
Con_Printf("\n%i possible alias%s\n", a, (a > 1) ? "es: " : ":");
- Cmd_CompleteAliasPrint(s);
+ Cmd_CompleteAliasPrint(cmd, s);
}
n = Nicks_CompleteCountPossible(key_line, key_linepos, s, true);
if (n)
}
if (c)
- cmd = *(list[0] = Cmd_CompleteBuildList(s));
+ text = *(list[0] = Cmd_CompleteBuildList(cmd, s));
if (v)
- cmd = *(list[1] = Cvar_CompleteBuildList(s));
+ text = *(list[1] = Cvar_CompleteBuildList(s));
if (a)
- cmd = *(list[2] = Cmd_CompleteAliasBuildList(s));
+ text = *(list[2] = Cmd_CompleteAliasBuildList(cmd, s));
if (n)
- cmd = *(list[3] = Nicks_CompleteBuildList(n));
+ text = *(list[3] = Nicks_CompleteBuildList(n));
for (cmd_len = (int)strlen(s);;cmd_len++)
{
for (i = 0; i < 3; i++)
if (list[i])
for (l = list[i];*l;l++)
- if ((*l)[cmd_len] != cmd[cmd_len])
+ if ((*l)[cmd_len] != text[cmd_len])
goto done;
// all possible matches share this character, so we continue...
- if (!cmd[cmd_len])
+ if (!text[cmd_len])
{
// if all matches ended at the same position, stop
// (this means there is only one match)
// prevent a buffer overrun by limiting cmd_len according to remaining space
cmd_len = min(cmd_len, (int)sizeof(key_line) - 1 - pos);
- if (cmd)
+ if (text)
{
key_linepos = pos;
- memcpy(&key_line[key_linepos], cmd, cmd_len);
+ memcpy(&key_line[key_linepos], text, cmd_len);
key_linepos += cmd_len;
// if there is only one match, add a space after it
if (c + v + a + n == 1 && key_linepos < (int)sizeof(key_line) - 1)
/// A Con_Printf that only shows up if the "developer" cvar is set
void Con_DPrintf(const char *fmt, ...) DP_FUNC_PRINTF(1);
-void Con_Clear_f (void);
+void Con_Clear_f(cmd_state_t *cmd);
void Con_DrawNotify (void);
/// Clear all notify lines.
void Con_ClearNotify (void);
-void Con_ToggleConsole_f (void);
+void Con_ToggleConsole_f(cmd_state_t *cmd);
int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos);
/// or to list possible matches grouped by type
/// (i.e. will display possible variables, aliases, commands
/// that match what they've typed so far)
-void Con_CompleteCommandLine(void);
+void Con_CompleteCommandLine(cmd_state_t *cmd);
/// Generic libs/util/console.c function to display a list
/// formatted in columns on the console
SV_UnlockThreadMutex();
}
-static void Crypto_KeyGen_f(void)
+static void Crypto_KeyGen_f(cmd_state_t *cmd)
{
int i;
const char *p[1];
Con_Print("libd0_blind_id DLL not found, this command is inactive.\n");
return;
}
- if(Cmd_Argc() != 3)
+ if(Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage:\n%s id url\n", Cmd_Argv(0));
+ Con_Printf("usage:\n%s id url\n", Cmd_Argv(cmd, 0));
return;
}
SV_LockThreadMutex();
Crypto_LoadKeys();
- i = atoi(Cmd_Argv(1));
+ i = atoi(Cmd_Argv(cmd, 1));
if(!pubkeys[i])
{
Con_Printf("there is no public key %d\n", i);
SV_UnlockThreadMutex();
return;
}
- buf2pos = strlen(Cmd_Argv(2));
- memcpy(buf2, Cmd_Argv(2), buf2pos);
+ buf2pos = strlen(Cmd_Argv(cmd, 2));
+ memcpy(buf2, Cmd_Argv(cmd, 2), buf2pos);
if(!(buf2l = Crypto_UnParsePack(buf2 + buf2pos, sizeof(buf2) - buf2pos - 1, FOURCC_D0IQ, p, l, 1)))
{
Con_Printf("Crypto_UnParsePack failed\n");
// end
// console commands
-static void Crypto_Reload_f(void)
+static void Crypto_Reload_f(cmd_state_t *cmd)
{
Crypto_ClearHostKeys();
Crypto_UnloadKeys();
Crypto_LoadKeys();
}
-static void Crypto_Keys_f(void)
+static void Crypto_Keys_f(cmd_state_t *cmd)
{
int i;
if(!d0_blind_id_dll)
}
}
-static void Crypto_HostKeys_f(void)
+static void Crypto_HostKeys_f(cmd_state_t *cmd)
{
int i;
crypto_storedhostkey_t *hk;
}
}
-static void Crypto_HostKey_Clear_f(void)
+static void Crypto_HostKey_Clear_f(cmd_state_t *cmd)
{
lhnetaddress_t addr;
int i;
return;
}
- for(i = 1; i < Cmd_Argc(); ++i)
+ for(i = 1; i < Cmd_Argc(cmd); ++i)
{
- LHNETADDRESS_FromString(&addr, Cmd_Argv(i), 26000);
+ LHNETADDRESS_FromString(&addr, Cmd_Argv(cmd, i), 26000);
if(Crypto_ClearHostKey(&addr))
{
- Con_Printf("cleared host key for %s\n", Cmd_Argv(i));
+ Con_Printf("cleared host key for %s\n", Cmd_Argv(cmd, i));
}
}
}
{
if(d0_blind_id_dll)
{
- Cmd_AddCommand("crypto_reload", Crypto_Reload_f, "reloads cryptographic keys");
- Cmd_AddCommand("crypto_keygen", Crypto_KeyGen_f, "generates and saves a cryptographic key");
- Cmd_AddCommand("crypto_keys", Crypto_Keys_f, "lists the loaded keys");
- Cmd_AddCommand("crypto_hostkeys", Crypto_HostKeys_f, "lists the cached host keys");
- Cmd_AddCommand("crypto_hostkey_clear", Crypto_HostKey_Clear_f, "clears a cached host key");
+ Cmd_AddCommand(&cmd_client, "crypto_reload", Crypto_Reload_f, "reloads cryptographic keys");
+ Cmd_AddCommand(&cmd_client, "crypto_keygen", Crypto_KeyGen_f, "generates and saves a cryptographic key");
+ Cmd_AddCommand(&cmd_client, "crypto_keys", Crypto_Keys_f, "lists the loaded keys");
+ Cmd_AddCommand(&cmd_client, "crypto_hostkeys", Crypto_HostKeys_f, "lists the cached host keys");
+ Cmd_AddCommand(&cmd_client, "crypto_hostkey_clear", Crypto_HostKey_Clear_f, "clears a cached host key");
+
+ Cmd_AddCommand(&cmd_server, "crypto_reload", Crypto_Reload_f, "reloads cryptographic keys");
+ Cmd_AddCommand(&cmd_server, "crypto_keygen", Crypto_KeyGen_f, "generates and saves a cryptographic key");
+ Cmd_AddCommand(&cmd_server, "crypto_keys", Crypto_Keys_f, "lists the loaded keys");
+ Cmd_AddCommand(&cmd_server, "crypto_hostkeys", Crypto_HostKeys_f, "lists the cached host keys");
+ Cmd_AddCommand(&cmd_server, "crypto_hostkey_clear", Crypto_HostKey_Clear_f, "clears a cached host key");
+
Cvar_RegisterVariable(&crypto_developer);
if(d0_rijndael_dll)
Cvar_RegisterVariable(&crypto_aeslevel);
int sizeflags = csqc_progcrc.flags;
csqc_progcrc.flags &= ~CVAR_READONLY;
csqc_progsize.flags &= ~CVAR_READONLY;
- Cmd_ExecuteString (msg, src_command, true);
+ Cmd_ExecuteString(&cmd_clientfromserver, msg, src_command, true);
csqc_progcrc.flags = crcflags;
csqc_progsize.flags = sizeflags;
return;
l = sizeof(buf) - 1;
strlcpy(buf, p, l + 1); // strlcpy needs a + 1 as it includes the newline!
- Cmd_ExecuteString(buf, src_command, true);
+ Cmd_ExecuteString(&cmd_clientfromserver, buf, src_command, true);
p += l;
if(*p == '\n')
else
break; // end of string or overflow
}
- Cmd_ExecuteString("curl --clear_autodownload", src_command, true); // don't inhibit CSQC loading
+ Cmd_ExecuteString(&cmd_clientfromserver, "curl --clear_autodownload", src_command, true); // don't inhibit CSQC loading
return;
}
if(!cl.csqc_loaded)
{
- Cbuf_AddText(msg);
+ Cbuf_AddText(&cmd_clientfromserver, msg);
return;
}
CSQC_BEGIN
prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
}
else
- Cbuf_AddText(msg);
+ Cbuf_AddText(&cmd_clientfromserver, msg);
CSQC_END
}
void CL_VM_ShutDown (void)
{
prvm_prog_t *prog = CLVM_prog;
- Cmd_ClearCsqcFuncs();
+ Cmd_ClearCsqcFuncs(&cmd_client);
//Cvar_SetValueQuick(&csqc_progcrc, -1);
//Cvar_SetValueQuick(&csqc_progsize, -1);
if(!cl.csqc_loaded)
}
// check for overlap with a command
- if (Cmd_Exists (variable->name))
+ if (Cmd_Exists(&cmd_client, variable->name) || Cmd_Exists(&cmd_server, variable->name))
{
Con_Printf("Cvar_RegisterVariable: %s is a command\n", variable->name);
return;
}
// check for overlap with a command
- if (Cmd_Exists (name))
+ if (Cmd_Exists(&cmd_client, name) || Cmd_Exists(&cmd_server, name))
{
Con_Printf("Cvar_Get: %s is a command\n", name);
return NULL;
Handles variable inspection and changing from the console
============
*/
-qboolean Cvar_Command (void)
+qboolean Cvar_Command (cmd_state_t *cmd)
{
cvar_t *v;
// check variables
- v = Cvar_FindVar (Cmd_Argv(0));
+ v = Cvar_FindVar (Cmd_Argv(cmd, 0));
if (!v)
return false;
// perform a variable print or set
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
Con_Printf("\"%s\" is \"%s\" [\"%s\"]\n", v->name, ((v->flags & CVAR_PRIVATE) ? "********"/*hunter2*/ : v->string), v->defstring);
return true;
Con_Printf("%s is read-only\n", v->name);
return true;
}
- Cvar_Set (v->name, Cmd_Argv(1));
+ Cvar_Set (v->name, Cmd_Argv(cmd, 1));
if (developer_extra.integer)
Con_DPrint("\n");
return true;
}
-void Cvar_LockDefaults_f (void)
+void Cvar_LockDefaults_f(cmd_state_t *cmd)
{
cvar_t *var;
// lock in the default values of all cvars
}
}
-void Cvar_ResetToDefaults_All_f (void)
+void Cvar_ResetToDefaults_All_f(cmd_state_t *cmd)
{
cvar_t *var;
// restore the default values of all cvars
}
-void Cvar_ResetToDefaults_NoSaveOnly_f (void)
+void Cvar_ResetToDefaults_NoSaveOnly_f(cmd_state_t *cmd)
{
cvar_t *var;
// restore the default values of all cvars
}
-void Cvar_ResetToDefaults_SaveOnly_f (void)
+void Cvar_ResetToDefaults_SaveOnly_f(cmd_state_t *cmd)
{
cvar_t *var;
// restore the default values of all cvars
Cvar_List
=========
*/
-void Cvar_List_f (void)
+void Cvar_List_f(cmd_state_t *cmd)
{
cvar_t *cvar;
const char *partial;
int count;
qboolean ispattern;
- if (Cmd_Argc() > 1)
+ if (Cmd_Argc(cmd) > 1)
{
- partial = Cmd_Argv (1);
+ partial = Cmd_Argv(cmd, 1);
len = strlen(partial);
ispattern = (strchr(partial, '*') || strchr(partial, '?'));
}
}
// 2000-01-09 CvarList command by Maddes
-void Cvar_Set_f (void)
+void Cvar_Set_f(cmd_state_t *cmd)
{
cvar_t *cvar;
// make sure it's the right number of parameters
- if (Cmd_Argc() < 3)
+ if (Cmd_Argc(cmd) < 3)
{
Con_Printf("Set: wrong number of parameters, usage: set <variablename> <value> [<description>]\n");
return;
}
// check if it's read-only
- cvar = Cvar_FindVar(Cmd_Argv(1));
+ cvar = Cvar_FindVar(Cmd_Argv(cmd, 1));
if (cvar && cvar->flags & CVAR_READONLY)
{
Con_Printf("Set: %s is read-only\n", cvar->name);
Con_DPrint("Set: ");
// all looks ok, create/modify the cvar
- Cvar_Get(Cmd_Argv(1), Cmd_Argv(2), 0, Cmd_Argc() > 3 ? Cmd_Argv(3) : NULL);
+ Cvar_Get(Cmd_Argv(cmd, 1), Cmd_Argv(cmd, 2), 0, Cmd_Argc(cmd) > 3 ? Cmd_Argv(cmd, 3) : NULL);
}
-void Cvar_SetA_f (void)
+void Cvar_SetA_f(cmd_state_t *cmd)
{
cvar_t *cvar;
// make sure it's the right number of parameters
- if (Cmd_Argc() < 3)
+ if (Cmd_Argc(cmd) < 3)
{
Con_Printf("SetA: wrong number of parameters, usage: seta <variablename> <value> [<description>]\n");
return;
}
// check if it's read-only
- cvar = Cvar_FindVar(Cmd_Argv(1));
+ cvar = Cvar_FindVar(Cmd_Argv(cmd, 1));
if (cvar && cvar->flags & CVAR_READONLY)
{
Con_Printf("SetA: %s is read-only\n", cvar->name);
Con_DPrint("SetA: ");
// all looks ok, create/modify the cvar
- Cvar_Get(Cmd_Argv(1), Cmd_Argv(2), CVAR_SAVE, Cmd_Argc() > 3 ? Cmd_Argv(3) : NULL);
+ Cvar_Get(Cmd_Argv(cmd, 1), Cmd_Argv(cmd, 2), CVAR_SAVE, Cmd_Argc(cmd) > 3 ? Cmd_Argv(cmd, 3) : NULL);
}
-void Cvar_Del_f (void)
+void Cvar_Del_f(cmd_state_t *cmd)
{
int i;
cvar_t *cvar, *parent, **link, *prev;
- if(Cmd_Argc() < 2)
+ if(Cmd_Argc(cmd) < 2)
{
Con_Printf("Del: wrong number of parameters, useage: unset <variablename1> [<variablename2> ...]\n");
return;
}
- for(i = 1; i < Cmd_Argc(); ++i)
+ for(i = 1; i < Cmd_Argc(cmd); ++i)
{
- cvar = Cvar_FindVarLink(Cmd_Argv(i), &parent, &link, &prev);
+ cvar = Cvar_FindVarLink(Cmd_Argv(cmd, i), &parent, &link, &prev);
if(!cvar)
{
- Con_Printf("Del: %s is not defined\n", Cmd_Argv(i));
+ Con_Printf("Del: %s is not defined\n", Cmd_Argv(cmd, i));
continue;
}
if(cvar->flags & CVAR_READONLY)
}
#ifdef FILLALLCVARSWITHRUBBISH
-void Cvar_FillAll_f()
+void Cvar_FillAll_f(cmd_state_t *cmd)
{
char *buf, *p, *q;
int n, i;
cvar_t *var;
qboolean verify;
- if(Cmd_Argc() != 2)
+ if(Cmd_Argc(cmd) != 2)
{
- Con_Printf("Usage: %s length to plant rubbish\n", Cmd_Argv(0));
- Con_Printf("Usage: %s -length to verify that the rubbish is still there\n", Cmd_Argv(0));
+ Con_Printf("Usage: %s length to plant rubbish\n", Cmd_Argv(cmd, 0));
+ Con_Printf("Usage: %s -length to verify that the rubbish is still there\n", Cmd_Argv(cmd, 0));
return;
}
- n = atoi(Cmd_Argv(1));
+ n = atoi(Cmd_Argv(cmd, 1));
verify = (n < 0);
if(verify)
n = -n;
*/
// cvar.h
+struct cmd_state_s;
+typedef struct cmd_state_s cmd_state_t;
+
/*
cvar_t variables are used to hold scalar or string variables that can be changed or displayed at the console or prog code as well as accessed directly
void Cvar_CompleteCvarPrint (const char *partial);
-qboolean Cvar_Command (void);
-// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
+qboolean Cvar_Command (cmd_state_t *cmd);
+// called by Cmd_ExecuteString when Cmd_Argv(cmd, 0) doesn't match a known
// command. Returns true if the command was a variable reference that
// was handled. (print or change)
void Cvar_RestoreInitState(void);
void Cvar_UnlockDefaults (void);
-void Cvar_LockDefaults_f (void);
-void Cvar_ResetToDefaults_All_f (void);
-void Cvar_ResetToDefaults_NoSaveOnly_f (void);
-void Cvar_ResetToDefaults_SaveOnly_f (void);
+void Cvar_LockDefaults_f(cmd_state_t *cmd);
+void Cvar_ResetToDefaults_All_f(cmd_state_t *cmd);
+void Cvar_ResetToDefaults_NoSaveOnly_f(cmd_state_t *cmd);
+void Cvar_ResetToDefaults_SaveOnly_f(cmd_state_t *cmd);
void Cvar_WriteVariables (qfile_t *f);
// Writes lines containing "set variable value" for all variables
/// Referenced in cmd.c in Cmd_Init hence it's inclusion here.
/// Added by EvilTypeGuy eviltypeguy@qeradiant.com
/// Thanks to Matthias "Maddes" Buecher, http://www.inside3d.com/qip/
-void Cvar_List_f (void);
+void Cvar_List_f(cmd_state_t *cmd);
-void Cvar_Set_f (void);
-void Cvar_SetA_f (void);
-void Cvar_Del_f (void);
+void Cvar_Set_f(cmd_state_t *cmd);
+void Cvar_SetA_f(cmd_state_t *cmd);
+void Cvar_Del_f(cmd_state_t *cmd);
// commands to create new cvars (or set existing ones)
// seta creates an archived cvar (saved to config)
void Cvar_UpdateAllAutoCvars(void); // updates ALL autocvars of the active prog to the cvar values (savegame loading)
#ifdef FILLALLCVARSWITHRUBBISH
-void Cvar_FillAll_f();
+void Cvar_FillAll_f(cmd_state_t *cmd);
#endif /* FILLALLCVARSWITHRUBBISH */
#endif
=============================================================================
*/
-void FS_Dir_f(void);
-void FS_Ls_f(void);
-void FS_Which_f(void);
+void FS_Dir_f(cmd_state_t *cmd);
+void FS_Ls_f(cmd_state_t *cmd);
+void FS_Which_f(cmd_state_t *cmd);
static searchpath_t *FS_FindFile (const char *name, int* index, qboolean quiet);
static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack,
============
*/
-static void FS_Path_f (void)
+static void FS_Path_f(cmd_state_t *cmd)
{
searchpath_t *s;
W_UnloadAll();
}
-static void FS_Rescan_f(void)
+static void FS_Rescan_f(cmd_state_t *cmd)
{
FS_Rescan();
}
if (cls.demoplayback)
{
- CL_Disconnect_f();
+ CL_Disconnect_f(&cmd_client);
cls.demonum = 0;
}
// unload all sounds so they will be reloaded from the new files as needed
- S_UnloadAllSounds_f();
+ S_UnloadAllSounds_f(&cmd_client);
// close down the video subsystem, it will start up again when the config finishes...
VID_Stop();
vid_opened = false;
// restart the video subsystem after the config is executed
- Cbuf_InsertText("\nloadconfig\nvid_restart\n\n");
+ Cbuf_InsertText(&cmd_client, "\nloadconfig\nvid_restart\n\n");
return true;
}
FS_GameDir_f
================
*/
-static void FS_GameDir_f (void)
+static void FS_GameDir_f(cmd_state_t *cmd)
{
int i;
int numgamedirs;
char gamedirs[MAX_GAMEDIRS][MAX_QPATH];
- if (Cmd_Argc() < 2)
+ if (Cmd_Argc(cmd) < 2)
{
Con_Printf("gamedirs active:");
for (i = 0;i < fs_numgamedirs;i++)
return;
}
- numgamedirs = Cmd_Argc() - 1;
+ numgamedirs = Cmd_Argc(cmd) - 1;
if (numgamedirs > MAX_GAMEDIRS)
{
Con_Printf("Too many gamedirs (%i > %i)\n", numgamedirs, MAX_GAMEDIRS);
}
for (i = 0;i < numgamedirs;i++)
- strlcpy(gamedirs[i], Cmd_Argv(i+1), sizeof(gamedirs[i]));
+ strlcpy(gamedirs[i], Cmd_Argv(cmd, i+1), sizeof(gamedirs[i]));
if ((cls.state == ca_connected && !cls.demoplayback) || sv.active)
{
Cvar_RegisterVariable (&fs_empty_files_in_pack_mark_deletions);
Cvar_RegisterVariable (&cvar_fs_gamedir);
- Cmd_AddCommand ("gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
- Cmd_AddCommand ("fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
- Cmd_AddCommand ("path", FS_Path_f, "print searchpath (game directories and archives)");
- Cmd_AddCommand ("dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
- Cmd_AddCommand ("ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
- Cmd_AddCommand ("which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
+ Cmd_AddCommand(&cmd_client, "gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
+ Cmd_AddCommand(&cmd_client, "fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
+ Cmd_AddCommand(&cmd_client, "path", FS_Path_f, "print searchpath (game directories and archives)");
+ Cmd_AddCommand(&cmd_client, "dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
+ Cmd_AddCommand(&cmd_client, "ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
+ Cmd_AddCommand(&cmd_client, "which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
+
+ Cmd_AddCommand(&cmd_server, "gamedir", FS_GameDir_f, "changes active gamedir list (can take multiple arguments), not including base directory (example usage: gamedir ctf)");
+ Cmd_AddCommand(&cmd_server, "fs_rescan", FS_Rescan_f, "rescans filesystem for new pack archives and any other changes");
+ Cmd_AddCommand(&cmd_server, "path", FS_Path_f, "print searchpath (game directories and archives)");
+ Cmd_AddCommand(&cmd_server, "dir", FS_Dir_f, "list files in searchpath matching an * filename pattern, one per line");
+ Cmd_AddCommand(&cmd_server, "ls", FS_Ls_f, "list files in searchpath matching an * filename pattern, multiple per line");
+ Cmd_AddCommand(&cmd_server, "which", FS_Which_f, "accepts a file name as argument and reports where the file is taken from");
}
/*
return (int)numfiles;
}
-static void FS_ListDirectoryCmd (const char* cmdname, int oneperline)
+static void FS_ListDirectoryCmd (cmd_state_t *cmd, const char* cmdname, int oneperline)
{
const char *pattern;
- if (Cmd_Argc() >= 3)
+ if (Cmd_Argc(cmd) >= 3)
{
Con_Printf("usage:\n%s [path/pattern]\n", cmdname);
return;
}
- if (Cmd_Argc() == 2)
- pattern = Cmd_Argv(1);
+ if (Cmd_Argc(cmd) == 2)
+ pattern = Cmd_Argv(cmd, 1);
else
pattern = "*";
if (!FS_ListDirectory(pattern, oneperline))
Con_Print("No files found.\n");
}
-void FS_Dir_f(void)
+void FS_Dir_f(cmd_state_t *cmd)
{
- FS_ListDirectoryCmd("dir", true);
+ FS_ListDirectoryCmd(cmd, "dir", true);
}
-void FS_Ls_f(void)
+void FS_Ls_f(cmd_state_t *cmd)
{
- FS_ListDirectoryCmd("ls", false);
+ FS_ListDirectoryCmd(cmd, "ls", false);
}
-void FS_Which_f(void)
+void FS_Which_f(cmd_state_t *cmd)
{
const char *filename;
int index;
searchpath_t *sp;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
- Con_Printf("usage:\n%s <file>\n", Cmd_Argv(0));
+ Con_Printf("usage:\n%s <file>\n", Cmd_Argv(cmd, 0));
return;
}
- filename = Cmd_Argv(1);
+ filename = Cmd_Argv(cmd, 1);
sp = FS_FindFile(filename, &index, true);
if (!sp) {
Con_Printf("%s isn't anywhere\n", filename);
#define BACKENDACTIVECHECK if (!gl_state.active) Sys_Error("GL backend function called when backend is not active");
-void SCR_ScreenShot_f (void);
+void SCR_ScreenShot_f(cmd_state_t *cmd);
typedef struct gltextureunit_s
{
int quadelement3i[QUADELEMENTS_MAXQUADS*6];
unsigned short quadelement3s[QUADELEMENTS_MAXQUADS*6];
-static void GL_VBOStats_f(void)
+static void GL_VBOStats_f(cmd_state_t *cmd)
{
GL_Mesh_ListVBOs(true);
}
Cvar_RegisterVariable(&gl_paranoid);
Cvar_RegisterVariable(&gl_printcheckerror);
- Cmd_AddCommand("gl_vbostats", GL_VBOStats_f, "prints a list of all buffer objects (vertex data and triangle elements) and total video memory used by them");
+ Cmd_AddCommand(&cmd_client, "gl_vbostats", GL_VBOStats_f, "prints a list of all buffer objects (vertex data and triangle elements) and total video memory used by them");
R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap, gl_backend_devicelost, gl_backend_devicerestored);
}
*/
}
-static void LoadFont_f(void)
+static void LoadFont_f(cmd_state_t *cmd)
{
dp_font_t *f;
int i, sizes;
float sz, scale, voffset;
char mainfont[MAX_QPATH];
- if(Cmd_Argc() < 2)
+ if(Cmd_Argc(cmd) < 2)
{
Con_Printf("Available font commands:\n");
for(i = 0; i < dp_fonts.maxsize; ++i)
);
return;
}
- f = FindFont(Cmd_Argv(1), true);
+ f = FindFont(Cmd_Argv(cmd, 1), true);
if(f == NULL)
{
Con_Printf("font function not found\n");
return;
}
- if(Cmd_Argc() < 3)
+ if(Cmd_Argc(cmd) < 3)
filelist = "gfx/conchars";
else
- filelist = Cmd_Argv(2);
+ filelist = Cmd_Argv(cmd, 2);
memset(f->fallbacks, 0, sizeof(f->fallbacks));
memset(f->fallback_faces, 0, sizeof(f->fallback_faces));
scale = 1;
voffset = 0;
- if(Cmd_Argc() >= 4)
+ if(Cmd_Argc(cmd) >= 4)
{
- for(sizes = 0, i = 3; i < Cmd_Argc(); ++i)
+ for(sizes = 0, i = 3; i < Cmd_Argc(cmd); ++i)
{
// special switches
- if (!strcmp(Cmd_Argv(i), "scale"))
+ if (!strcmp(Cmd_Argv(cmd, i), "scale"))
{
i++;
- if (i < Cmd_Argc())
- scale = atof(Cmd_Argv(i));
+ if (i < Cmd_Argc(cmd))
+ scale = atof(Cmd_Argv(cmd, i));
continue;
}
- if (!strcmp(Cmd_Argv(i), "voffset"))
+ if (!strcmp(Cmd_Argv(cmd, i), "voffset"))
{
i++;
- if (i < Cmd_Argc())
- voffset = atof(Cmd_Argv(i));
+ if (i < Cmd_Argc(cmd))
+ voffset = atof(Cmd_Argv(cmd, i));
continue;
}
continue; // no slot for other sizes
// parse one of sizes
- sz = atof(Cmd_Argv(i));
+ sz = atof(Cmd_Argv(cmd, i));
if (sz > 0.001f && sz < 1000.0f) // do not use crap sizes
{
// search for duplicated sizes
if(!FONT_USER(i)->title[0])
dpsnprintf(FONT_USER(i)->title, sizeof(FONT_USER(i)->title), "user%d", j++);
- Cmd_AddCommand ("loadfont",LoadFont_f, "loadfont function tganame loads a font; example: loadfont console gfx/veramono; loadfont without arguments lists the available functions");
+ Cmd_AddCommand(&cmd_client, "loadfont", LoadFont_f, "loadfont function tganame loads a font; example: loadfont console gfx/veramono; loadfont without arguments lists the available functions");
R_RegisterModule("GL_Draw", gl_draw_start, gl_draw_shutdown, gl_draw_newmap, NULL, NULL);
}
CHECKGLERROR
}
-void R_GLSL_Restart_f(void)
+void R_GLSL_Restart_f(cmd_state_t *cmd)
{
unsigned int i, limit;
switch(vid.renderpath)
}
}
-static void R_GLSL_DumpShader_f(void)
+static void R_GLSL_DumpShader_f(cmd_state_t *cmd)
{
int i, language, mode, dupe;
char *text;
r_texture_numcubemaps = 0;
//r_texture_fogintensity = NULL;
memset(&r_fb, 0, sizeof(r_fb));
- R_GLSL_Restart_f();
+ R_GLSL_Restart_f(&cmd_client);
r_glsl_permutation = NULL;
memset(r_glsl_permutationhash, 0, sizeof(r_glsl_permutationhash));
r_main_mempool = Mem_AllocPool("Renderer", 0, NULL);
R_InitShaderModeInfo();
- Cmd_AddCommand("r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
- Cmd_AddCommand("r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
+ Cmd_AddCommand(&cmd_client, "r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
+ Cmd_AddCommand(&cmd_client, "r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
// FIXME: the client should set up r_refdef.fog stuff including the fogmasktable
if (gamemode == GAME_NEHAHRA)
{
rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
if(R_CompileShader_CheckStaticParms())
- R_GLSL_Restart_f();
+ R_GLSL_Restart_f(&cmd_client);
if (!r_drawentities.integer)
r_refdef.scene.numentities = 0;
}
//Made by [515]
-static void R_ReplaceWorldTexture (void)
+static void R_ReplaceWorldTexture_f(cmd_state_t *cmd)
{
dp_model_t *m;
texture_t *t;
}
m = r_refdef.scene.worldmodel;
- if(Cmd_Argc() < 2)
+ if(Cmd_Argc(cmd) < 2)
{
Con_Print("r_replacemaptexture <texname> <newtexname> - replaces texture\n");
Con_Print("r_replacemaptexture <texname> - switch back to default texture\n");
Con_Print("This command works only in singleplayer\n");
return;
}
- r = Cmd_Argv(1);
- newt = Cmd_Argv(2);
+ r = Cmd_Argv(cmd, 1);
+ newt = Cmd_Argv(cmd, 2);
if(!newt[0])
newt = r;
for(i=0,t=m->data_textures;i<m->num_textures;i++,t++)
}
//Made by [515]
-static void R_ListWorldTextures (void)
+static void R_ListWorldTextures_f(cmd_state_t *cmd)
{
dp_model_t *m;
texture_t *t;
Cvar_RegisterVariable(&r_vis_trace_surfaces);
Cvar_RegisterVariable(&r_q3bsp_renderskydepth);
- Cmd_AddCommand ("r_replacemaptexture", R_ReplaceWorldTexture, "override a map texture for testing purposes");
- Cmd_AddCommand ("r_listmaptextures", R_ListWorldTextures, "list all textures used by the current map");
+ Cmd_AddCommand(&cmd_client, "r_replacemaptexture", R_ReplaceWorldTexture_f, "override a map texture for testing purposes");
+ Cmd_AddCommand(&cmd_client, "r_listmaptextures", R_ListWorldTextures_f, "list all textures used by the current map");
//R_RegisterModule("GL_Surf", gl_surf_start, gl_surf_shutdown, gl_surf_newmap);
}
{"GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}
};
-static void GL_TextureMode_f (void)
+static void GL_TextureMode_f(cmd_state_t *cmd)
{
int i;
GLint oldbindtexnum;
gltexture_t *glt;
gltexturepool_t *pool;
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
Con_Printf("Texture mode is %sforced\n", gl_filter_force ? "" : "not ");
for (i = 0;i < 6;i++)
}
for (i = 0;i < (int)(sizeof(modes)/sizeof(*modes));i++)
- if (!strcasecmp (modes[i].name, Cmd_Argv(1) ) )
+ if (!strcasecmp (modes[i].name, Cmd_Argv(cmd, 1) ) )
break;
if (i == 6)
{
gl_filter_min = modes[i].minification;
gl_filter_mag = modes[i].magnification;
- gl_filter_force = ((Cmd_Argc() > 2) && !strcasecmp(Cmd_Argv(2), "force"));
+ gl_filter_force = ((Cmd_Argc(cmd) > 2) && !strcasecmp(Cmd_Argv(cmd, 2), "force"));
switch(vid.renderpath)
{
Con_Printf("textures total: %i (%.3fMB, %.3fMB original), uploaded %i (%.3fMB, %.3fMB original), upload on demand %i (%.3fMB, %.3fMB original)\n", sumtotal, sumtotalt / 1048576.0, sumtotalp / 1048576.0, sumloaded, sumloadedt / 1048576.0, sumloadedp / 1048576.0, sumtotal - sumloaded, (sumtotalt - sumloadedt) / 1048576.0, (sumtotalp - sumloadedp) / 1048576.0);
}
-static void R_TextureStats_f(void)
+static void R_TextureStats_f(cmd_state_t *cmd)
{
R_TextureStats_Print(true, true, true);
}
void R_Textures_Init (void)
{
- Cmd_AddCommand("gl_texturemode", &GL_TextureMode_f, "set texture filtering mode (GL_NEAREST, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, etc); an additional argument 'force' forces the texture mode even in cases where it may not be appropriate");
- Cmd_AddCommand("r_texturestats", R_TextureStats_f, "print information about all loaded textures and some statistics");
+ Cmd_AddCommand(&cmd_client, "gl_texturemode", &GL_TextureMode_f, "set texture filtering mode (GL_NEAREST, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, etc); an additional argument 'force' forces the texture mode even in cases where it may not be appropriate");
+ Cmd_AddCommand(&cmd_client, "r_texturestats", R_TextureStats_f, "print information about all loaded textures and some statistics");
Cvar_RegisterVariable (&gl_max_size);
Cvar_RegisterVariable (&gl_picmip);
Cvar_RegisterVariable (&gl_picmip_world);
Host_InitLocal
======================
*/
-void Host_SaveConfig_f(void);
-void Host_LoadConfig_f(void);
+void Host_SaveConfig_f(cmd_state_t *cmd);
+void Host_LoadConfig_f(cmd_state_t *cmd);
extern cvar_t sv_writepicture_quality;
extern cvar_t r_texture_jpeg_fastpicmip;
static void Host_InitLocal (void)
{
- Cmd_AddCommand("saveconfig", Host_SaveConfig_f, "save settings to config.cfg (or a specified filename) immediately (also automatic when quitting)");
- Cmd_AddCommand("loadconfig", Host_LoadConfig_f, "reset everything and reload configs");
+ Cmd_AddCommand(&cmd_client, "saveconfig", Host_SaveConfig_f, "save settings to config.cfg (or a specified filename) immediately (also automatic when quitting)");
+ Cmd_AddCommand(&cmd_client, "loadconfig", Host_LoadConfig_f, "reset everything and reload configs");
+ Cmd_AddCommand(&cmd_server, "saveconfig", Host_SaveConfig_f, "save settings to config.cfg (or a specified filename) immediately (also automatic when quitting)");
+ Cmd_AddCommand(&cmd_server, "loadconfig", Host_LoadConfig_f, "reset everything and reload configs");
Cvar_RegisterVariable (&cl_maxphysicsframesperserverframe);
Cvar_RegisterVariable (&host_framerate);
{
Host_SaveConfig_to(CONFIGFILENAME);
}
-void Host_SaveConfig_f(void)
+void Host_SaveConfig_f(cmd_state_t *cmd)
{
const char *file = CONFIGFILENAME;
- if(Cmd_Argc() >= 2) {
- file = Cmd_Argv(1);
+ if(Cmd_Argc(cmd) >= 2) {
+ file = Cmd_Argv(cmd, 1);
Con_Printf("Saving to %s\n", file);
}
Host_SaveConfig_to(file);
}
-static void Host_AddConfigText(void)
+static void Host_AddConfigText(cmd_state_t *cmd)
{
// set up the default startmap_sp and startmap_dm aliases (mods can
// override these) and then execute the quake.rc startup script
if (gamemode == GAME_NEHAHRA)
- Cbuf_InsertText("alias startmap_sp \"map nehstart\"\nalias startmap_dm \"map nehstart\"\nexec " STARTCONFIGFILENAME "\n");
+ Cbuf_InsertText(cmd, "alias startmap_sp \"map nehstart\"\nalias startmap_dm \"map nehstart\"\nexec " STARTCONFIGFILENAME "\n");
else if (gamemode == GAME_TRANSFUSION)
- Cbuf_InsertText("alias startmap_sp \"map e1m1\"\n""alias startmap_dm \"map bb1\"\nexec " STARTCONFIGFILENAME "\n");
+ Cbuf_InsertText(cmd, "alias startmap_sp \"map e1m1\"\n""alias startmap_dm \"map bb1\"\nexec " STARTCONFIGFILENAME "\n");
else if (gamemode == GAME_TEU)
- Cbuf_InsertText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec teu.rc\n");
+ Cbuf_InsertText(cmd, "alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec teu.rc\n");
else
- Cbuf_InsertText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec " STARTCONFIGFILENAME "\n");
+ Cbuf_InsertText(cmd, "alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec " STARTCONFIGFILENAME "\n");
}
/*
Resets key bindings and cvars to defaults and then reloads scripts
===============
*/
-void Host_LoadConfig_f(void)
+void Host_LoadConfig_f(cmd_state_t *cmd)
{
// reset all cvars, commands and aliases to init values
Cmd_RestoreInitState();
#ifdef CONFIG_MENU
// prepend a menu restart command to execute after the config
- Cbuf_InsertText("\nmenu_restart\n");
+ Cbuf_InsertText(&cmd_client, "\nmenu_restart\n");
#endif
// reset cvars to their defaults, and then exec startup scripts again
- Host_AddConfigText();
+ Host_AddConfigText(&cmd_client);
}
/*
*/
static void Host_GetConsoleCommands (void)
{
- char *cmd;
+ char *line;
- while (1)
+ while ((line = Sys_ConsoleInput()))
{
- cmd = Sys_ConsoleInput ();
- if (!cmd)
- break;
- Cbuf_AddText (cmd);
+ if (cls.state == ca_dedicated)
+ Cbuf_AddText(&cmd_server, line);
+ else
+ Cbuf_AddText(&cmd_client, line);
}
}
// process console commands
// R_TimeReport("preconsole");
CL_VM_PreventInformationLeaks();
- Cbuf_Frame();
+ Cbuf_Frame(&cmd_client);
+ Cbuf_Frame(&cmd_server);
// R_TimeReport("console");
}
qboolean sys_nostdout = false;
-extern qboolean host_stuffcmdsrun;
-
static qfile_t *locksession_fh = NULL;
static qboolean locksession_run = false;
static void Host_InitSession(void)
int i;
const char* os;
char vabuf[1024];
+ qboolean dedicated_server = COM_CheckParm("-dedicated") || !cl_available;
+ cmd_state_t *cmd = &cmd_client;
if (COM_CheckParm("-profilegameonly"))
Sys_AllowProfiling(false);
// initialize console command/cvar/alias/command execution systems
Cmd_Init();
+ Cmd_Init_Commands(dedicated_server);
+
// initialize memory subsystem cvars/commands
Memory_Init_Commands();
// initialize various cvars that could not be initialized earlier
u8_Init();
Curl_Init_Commands();
- Cmd_Init_Commands();
Sys_Init_Commands();
COM_Init_Commands();
FS_Init_Commands();
TaskQueue_Init();
if (cls.state == ca_dedicated)
- Cmd_AddCommand ("disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
+ {
+ cmd = &cmd_server;
+ Cmd_AddCommand(&cmd_server, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
+ }
else
{
Con_DPrintf("Initializing client\n");
return;
}
- Host_AddConfigText();
- Cbuf_Execute();
+ Host_AddConfigText(cmd);
+ Cbuf_Execute(cmd);
// if stuffcmds wasn't run, then quake.rc is probably missing, use default
if (!host_stuffcmdsrun)
{
- Cbuf_AddText("exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\nstuffcmds\n");
- Cbuf_Execute();
+ Cbuf_AddText(cmd, "exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\nstuffcmds\n");
+ Cbuf_Execute(cmd);
}
// put up the loading image so the user doesn't stare at a black screen...
if (i && i + 1 < com_argc)
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "timedemo %s\n", com_argv[i + 1]));
- Cbuf_Execute();
+ Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", com_argv[i + 1]));
+ Cbuf_Execute(&cmd_client);
}
// check for special demo mode
if (i && i + 1 < com_argc)
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "playdemo %s\n", com_argv[i + 1]));
- Cbuf_Execute();
+ Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\n", com_argv[i + 1]));
+ Cbuf_Execute(&cmd_client);
}
// COMMANDLINEOPTION: Client: -capturedemo <demoname> captures a playdemo and quits
if (i && i + 1 < com_argc)
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", com_argv[i + 1]));
- Cbuf_Execute();
+ Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", com_argv[i + 1]));
+ Cbuf_Execute(&cmd_client);
}
if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
- Cbuf_AddText("startmap_dm\n");
- Cbuf_Execute();
+ Cbuf_AddText(&cmd_client, "startmap_dm\n");
+ Cbuf_Execute(&cmd_client);
}
if (!sv.active && !cls.demoplayback && !cls.connect_trying)
{
#ifdef CONFIG_MENU
- Cbuf_AddText("togglemenu 1\n");
+ Cbuf_AddText(&cmd_client, "togglemenu 1\n");
#endif
- Cbuf_Execute();
+ Cbuf_Execute(&cmd_client);
}
Con_DPrint("========Initialized=========\n");
==================
*/
-void Host_Quit_f (void)
+void Host_Quit_f(cmd_state_t *cmd)
{
if(host_shuttingdown)
Con_Printf("shutting down already!\n");
Host_Status_f
==================
*/
-static void Host_Status_f (void)
+static void Host_Status_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
char qcstatus[256];
int frags;
char vabuf[1024];
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
// if running a client, try to send over network so the client's status report parser will see the report
if (cls.state == ca_connected)
{
- Cmd_ForwardToServer ();
+ Cmd_ForwardToServer_f(cmd);
return;
}
print = Con_Printf;
return;
in = 0;
- if (Cmd_Argc() == 2)
+ if (Cmd_Argc(cmd) == 2)
{
- if (strcmp(Cmd_Argv(1), "1") == 0)
+ if (strcmp(Cmd_Argv(cmd, 1), "1") == 0)
in = 1;
- else if (strcmp(Cmd_Argv(1), "2") == 0)
+ else if (strcmp(Cmd_Argv(cmd, 1), "2") == 0)
in = 2;
}
ping = bound(0, (int)floor(client->ping*1000+0.5), 9999);
}
- if(sv_status_privacy.integer && cmd_source != src_command)
+ if(sv_status_privacy.integer && cmd->source != src_command)
strlcpy(ip, client->netconnection ? "hidden" : "botclient", 48);
else
strlcpy(ip, (client->netconnection && client->netconnection->address) ? client->netconnection->address : "botclient", 48);
Sets client to godmode
==================
*/
-static void Host_God_f (void)
+static void Host_God_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
if (!allowcheats)
SV_ClientPrint("godmode ON\n");
}
-static void Host_Notarget_f (void)
+static void Host_Notarget_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
if (!allowcheats)
qboolean noclip_anglehack;
-static void Host_Noclip_f (void)
+static void Host_Noclip_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
if (!allowcheats)
Sets client to flymode
==================
*/
-static void Host_Fly_f (void)
+static void Host_Fly_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
if (!allowcheats)
==================
*/
-void Host_Pings_f (void); // called by Host_Ping_f
-static void Host_Ping_f (void)
+static void Host_Ping_f(cmd_state_t *cmd)
{
int i;
client_t *client;
void (*print) (const char *fmt, ...);
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
// if running a client, try to send over network so the client's ping report parser will see the report
if (cls.state == ca_connected)
{
- Cmd_ForwardToServer ();
+ Cmd_ForwardToServer_f(cmd);
return;
}
print = Con_Printf;
continue;
print("%4i %s\n", bound(0, (int)floor(client->ping*1000+0.5), 9999), client->name);
}
-
- // now call the Pings command also, which will send a report that contains packet loss for the scoreboard (as well as a simpler ping report)
- // actually, don't, it confuses old clients (resulting in "unknown command pingplreport" flooding the console)
- //Host_Pings_f();
}
/*
command from the console. Active clients are kicked off.
======================
*/
-static void Host_Map_f (void)
+static void Host_Map_f(cmd_state_t *cmd)
{
char level[MAX_QPATH];
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("map <levelname> : start a new game (kicks off all players)\n");
return;
svs.serverflags = 0; // haven't completed an episode yet
allowcheats = sv_cheats.integer != 0;
- strlcpy(level, Cmd_Argv(1), sizeof(level));
+ strlcpy(level, Cmd_Argv(cmd, 1), sizeof(level));
SV_SpawnServer(level);
if (sv.active && cls.state == ca_disconnected)
CL_EstablishConnection("local:1", -2);
Goes to a new map, taking all clients along
==================
*/
-static void Host_Changelevel_f (void)
+static void Host_Changelevel_f(cmd_state_t *cmd)
{
char level[MAX_QPATH];
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("changelevel <levelname> : continue game on a new level\n");
return;
}
// HACKHACKHACK
if (!sv.active) {
- Host_Map_f();
+ Host_Map_f(cmd);
return;
}
SV_SaveSpawnparms ();
allowcheats = sv_cheats.integer != 0;
- strlcpy(level, Cmd_Argv(1), sizeof(level));
+ strlcpy(level, Cmd_Argv(cmd, 1), sizeof(level));
SV_SpawnServer(level);
if (sv.active && cls.state == ca_disconnected)
CL_EstablishConnection("local:1", -2);
Restarts the current server for a dead player
==================
*/
-static void Host_Restart_f (void)
+static void Host_Restart_f(cmd_state_t *cmd)
{
char mapname[MAX_QPATH];
- if (Cmd_Argc() != 1)
+ if (Cmd_Argc(cmd) != 1)
{
Con_Print("restart : restart current level\n");
return;
This is sent just before a server changes levels
==================
*/
-void Host_Reconnect_f (void)
+void Host_Reconnect_f(cmd_state_t *cmd)
{
char temp[128];
// if not connected, reconnect to the most recent server
else
{
// netquake uses reconnect on level changes (silly)
- if (Cmd_Argc() != 1)
+ if (Cmd_Argc(cmd) != 1)
{
Con_Print("reconnect : wait for signon messages again\n");
return;
User command to connect to server
=====================
*/
-static void Host_Connect_f (void)
+static void Host_Connect_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() < 2)
+ if (Cmd_Argc(cmd) < 2)
{
Con_Print("connect <serveraddress> [<key> <value> ...]: connect to a multiplayer game\n");
return;
// clear the rcon password, to prevent vulnerability by stuffcmd-ing a connect command
if(rcon_secure.integer <= 0)
Cvar_SetQuick(&rcon_password, "");
- CL_EstablishConnection(Cmd_Argv(1), 2);
+ CL_EstablishConnection(Cmd_Argv(cmd, 1), 2);
}
Host_Savegame_f
===============
*/
-static void Host_Savegame_f (void)
+static void Host_Savegame_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
char name[MAX_QPATH];
else
Con_Print("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() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("save <savename> : save a game\n");
return;
}
- if (strstr(Cmd_Argv(1), ".."))
+ if (strstr(Cmd_Argv(cmd, 1), ".."))
{
Con_Print("Relative pathnames are not allowed.\n");
return;
}
- strlcpy (name, Cmd_Argv(1), sizeof (name));
+ strlcpy (name, Cmd_Argv(cmd, 1), sizeof (name));
FS_DefaultExtension (name, ".sav", sizeof (name));
Host_Savegame_to(prog, name);
===============
*/
-static void Host_Loadgame_f (void)
+static void Host_Loadgame_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
char filename[MAX_QPATH];
float spawn_parms[NUM_SPAWN_PARMS];
prvm_stringbuffer_t *stringbuffer;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("load <savename> : load a game\n");
return;
}
- strlcpy (filename, Cmd_Argv(1), sizeof(filename));
+ strlcpy (filename, Cmd_Argv(cmd, 1), sizeof(filename));
FS_DefaultExtension (filename, ".sav", sizeof (filename));
Con_Printf("Loading game from %s...\n", filename);
======================
*/
cvar_t cl_name = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_name", "player", "internal storage cvar for current player name (changed by name command)"};
-static void Host_Name_f (void)
+static void Host_Name_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
int i, j;
const char *newNameSource;
char newName[sizeof(host_client->name)];
- if (Cmd_Argc () == 1)
+ if (Cmd_Argc (cmd) == 1)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("name: %s\n", cl_name.string);
}
return;
}
- if (Cmd_Argc () == 2)
- newNameSource = Cmd_Argv(1);
+ if (Cmd_Argc (cmd) == 2)
+ newNameSource = Cmd_Argv(cmd, 1);
else
- newNameSource = Cmd_Args();
+ newNameSource = Cmd_Args(cmd);
strlcpy(newName, newNameSource, sizeof(newName));
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Cvar_Set ("_cl_name", newName);
if (strlen(newNameSource) >= sizeof(newName)) // overflowed
*/
cvar_t cl_playermodel = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_playermodel", "", "internal storage cvar for current player model in Nexuiz/Xonotic (changed by playermodel command)"};
// the old cl_playermodel in cl_main has been renamed to __cl_playermodel
-static void Host_Playermodel_f (void)
+static void Host_Playermodel_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
int i, j;
char newPath[sizeof(host_client->playermodel)];
- if (Cmd_Argc () == 1)
+ if (Cmd_Argc (cmd) == 1)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
}
return;
}
- if (Cmd_Argc () == 2)
- strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
+ if (Cmd_Argc (cmd) == 2)
+ strlcpy (newPath, Cmd_Argv(cmd, 1), sizeof (newPath));
else
- strlcpy (newPath, Cmd_Args(), sizeof (newPath));
+ strlcpy (newPath, Cmd_Args(cmd), 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)
+ if (cmd->source == src_command)
{
Cvar_Set ("_cl_playermodel", newPath);
return;
======================
*/
cvar_t cl_playerskin = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_playerskin", "", "internal storage cvar for current player skin in Nexuiz/Xonotic (changed by playerskin command)"};
-static void Host_Playerskin_f (void)
+static void Host_Playerskin_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
int i, j;
char newPath[sizeof(host_client->playerskin)];
- if (Cmd_Argc () == 1)
+ if (Cmd_Argc (cmd) == 1)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
}
return;
}
- if (Cmd_Argc () == 2)
- strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
+ if (Cmd_Argc (cmd) == 2)
+ strlcpy (newPath, Cmd_Argv(cmd, 1), sizeof (newPath));
else
- strlcpy (newPath, Cmd_Args(), sizeof (newPath));
+ strlcpy (newPath, Cmd_Args(cmd), 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)
+ if (cmd->source == src_command)
{
Cvar_Set ("_cl_playerskin", newPath);
return;
}
}
-static void Host_Version_f (void)
+static void Host_Version_f(cmd_state_t *cmd)
{
Con_Printf("Version: %s build %s\n", gamename, buildstring);
}
-static void Host_Say(qboolean teamonly)
+static void Host_Say(cmd_state_t *cmd, qboolean teamonly)
{
prvm_prog_t *prog = SVVM_prog;
client_t *save;
char text[1024];
qboolean fromServer = false;
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
if (cls.state == ca_dedicated)
{
}
else
{
- Cmd_ForwardToServer ();
+ Cmd_ForwardToServer_f(cmd);
return;
}
}
- if (Cmd_Argc () < 2)
+ if (Cmd_Argc (cmd) < 2)
return;
if (!teamplay.integer)
teamonly = false;
- p1 = Cmd_Args();
+ p1 = Cmd_Args(cmd);
quoted = false;
if (*p1 == '\"')
{
}
-static void Host_Say_f(void)
+static void Host_Say_f(cmd_state_t *cmd)
{
- Host_Say(false);
+ Host_Say(cmd, false);
}
-static void Host_Say_Team_f(void)
+static void Host_Say_Team_f(cmd_state_t *cmd)
{
- Host_Say(true);
+ Host_Say(cmd, true);
}
-static void Host_Tell_f(void)
+static void Host_Tell_f(cmd_state_t *cmd)
{
const char *playername_start = NULL;
size_t playername_length = 0;
char text[MAX_INPUTLINE]; // LadyHavoc: FIXME: temporary buffer overflow fix (was 64)
qboolean fromServer = false;
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
if (cls.state == ca_dedicated)
fromServer = true;
else
{
- Cmd_ForwardToServer ();
+ Cmd_ForwardToServer_f(cmd);
return;
}
}
- if (Cmd_Argc () < 2)
+ if (Cmd_Argc (cmd) < 2)
return;
// note this uses the chat prefix \001
else
dpsnprintf (text, sizeof(text), "\001<%s tells you> ", hostname.string);
- p1 = Cmd_Args();
+ p1 = Cmd_Args(cmd);
p2 = p1 + strlen(p1);
// remove the target name
while (p1 < p2 && *p1 == ' ')
==================
*/
cvar_t cl_color = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"};
-static void Host_Color(int changetop, int changebottom)
+static void Host_Color(cmd_state_t *cmd, int changetop, int changebottom)
{
prvm_prog_t *prog = SVVM_prog;
int top, bottom, playercolor;
playercolor = top*16 + bottom;
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Cvar_SetValueQuick(&cl_color, playercolor);
return;
}
}
-static void Host_Color_f(void)
+static void Host_Color_f(cmd_state_t *cmd)
{
int top, bottom;
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("\"color\" is \"%i %i\"\n", cl_color.integer >> 4, cl_color.integer & 15);
Con_Print("color <0-15> [0-15]\n");
return;
}
- if (Cmd_Argc() == 2)
- top = bottom = atoi(Cmd_Argv(1));
+ if (Cmd_Argc(cmd) == 2)
+ top = bottom = atoi(Cmd_Argv(cmd, 1));
else
{
- top = atoi(Cmd_Argv(1));
- bottom = atoi(Cmd_Argv(2));
+ top = atoi(Cmd_Argv(cmd, 1));
+ bottom = atoi(Cmd_Argv(cmd, 2));
}
- Host_Color(top, bottom);
+ Host_Color(cmd, top, bottom);
}
-static void Host_TopColor_f(void)
+static void Host_TopColor_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("\"topcolor\" is \"%i\"\n", (cl_color.integer >> 4) & 15);
Con_Print("topcolor <0-15>\n");
return;
}
- Host_Color(atoi(Cmd_Argv(1)), -1);
+ Host_Color(cmd, atoi(Cmd_Argv(cmd, 1)), -1);
}
-static void Host_BottomColor_f(void)
+static void Host_BottomColor_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("\"bottomcolor\" is \"%i\"\n", cl_color.integer & 15);
Con_Print("bottomcolor <0-15>\n");
return;
}
- Host_Color(-1, atoi(Cmd_Argv(1)));
+ Host_Color(cmd, -1, atoi(Cmd_Argv(cmd, 1)));
}
cvar_t cl_rate = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_rate", "20000", "internal storage cvar for current rate (changed by rate command)"};
cvar_t cl_rate_burstsize = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_rate_burstsize", "1024", "internal storage cvar for current rate control burst size (changed by rate_burstsize command)"};
-static void Host_Rate_f(void)
+static void Host_Rate_f(cmd_state_t *cmd)
{
int rate;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("\"rate\" is \"%i\"\n", cl_rate.integer);
Con_Print("rate <bytespersecond>\n");
return;
}
- rate = atoi(Cmd_Argv(1));
+ rate = atoi(Cmd_Argv(cmd, 1));
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Cvar_SetValue ("_cl_rate", max(NET_MINRATE, rate));
return;
host_client->rate = rate;
}
-static void Host_Rate_BurstSize_f(void)
+static void Host_Rate_BurstSize_f(cmd_state_t *cmd)
{
int rate_burstsize;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Printf("\"rate_burstsize\" is \"%i\"\n", cl_rate_burstsize.integer);
Con_Print("rate_burstsize <bytes>\n");
return;
}
- rate_burstsize = atoi(Cmd_Argv(1));
+ rate_burstsize = atoi(Cmd_Argv(cmd, 1));
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Cvar_SetValue ("_cl_rate_burstsize", rate_burstsize);
return;
Host_Kill_f
==================
*/
-static void Host_Kill_f (void)
+static void Host_Kill_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
if (PRVM_serveredictfloat(host_client->edict, health) <= 0)
Host_Pause_f
==================
*/
-static void Host_Pause_f (void)
+static void Host_Pause_f(cmd_state_t *cmd)
{
void (*print) (const char *fmt, ...);
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
// if running a client, try to send over network so the pause is handled by the server
if (cls.state == ca_connected)
{
- Cmd_ForwardToServer ();
+ Cmd_ForwardToServer_f(cmd);
return;
}
print = Con_Printf;
if (!pausable.integer)
{
- if (cmd_source == src_client)
+ if (cmd->source == src_client)
{
if(cls.state == ca_dedicated || host_client != &svs.clients[0]) // non-admin
{
}
sv.paused ^= 1;
- if (cmd_source != src_command)
+ if (cmd->source != src_command)
SV_BroadcastPrintf("%s %spaused the game\n", host_client->name, sv.paused ? "" : "un");
else if(*(sv_adminnick.string))
SV_BroadcastPrintf("%s %spaused the game\n", sv_adminnick.string, sv.paused ? "" : "un");
======================
*/
cvar_t cl_pmodel = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_pmodel", "0", "internal storage cvar for current player model number in nehahra (changed by pmodel command)"};
-static void Host_PModel_f (void)
+static void Host_PModel_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
int i;
- if (Cmd_Argc () == 1)
+ if (Cmd_Argc (cmd) == 1)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
Con_Printf("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
}
return;
}
- i = atoi(Cmd_Argv(1));
+ i = atoi(Cmd_Argv(cmd, 1));
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
if (cl_pmodel.integer == i)
return;
Cvar_SetValue ("_cl_pmodel", i);
if (cls.state == ca_connected)
- Cmd_ForwardToServer ();
+ Cmd_ForwardToServer_f(cmd);
return;
}
Host_PreSpawn_f
==================
*/
-static void Host_PreSpawn_f (void)
+static void Host_PreSpawn_f(cmd_state_t *cmd)
{
if (host_client->prespawned)
{
Host_Spawn_f
==================
*/
-static void Host_Spawn_f (void)
+static void Host_Spawn_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
int i;
Host_Begin_f
==================
*/
-static void Host_Begin_f (void)
+static void Host_Begin_f(cmd_state_t *cmd)
{
if (!host_client->spawned)
{
Kicks a user off of the server
==================
*/
-static void Host_Kick_f (void)
+static void Host_Kick_f(cmd_state_t *cmd)
{
const char *who;
const char *message = NULL;
save = host_client;
- if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
+ if (Cmd_Argc(cmd) > 2 && strcmp(Cmd_Argv(cmd, 1), "#") == 0)
{
- i = (int)(atof(Cmd_Argv(2)) - 1);
+ i = (int)(atof(Cmd_Argv(cmd, 2)) - 1);
if (i < 0 || i >= svs.maxclients || !(host_client = svs.clients + i)->active)
return;
byNumber = true;
{
if (!host_client->active)
continue;
- if (strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
+ if (strcasecmp(host_client->name, Cmd_Argv(cmd, 1)) == 0)
break;
}
}
if (i < svs.maxclients)
{
- if (cmd_source == src_command)
+ if (cmd->source == src_command)
{
if (cls.state == ca_dedicated)
who = "Console";
if (host_client == save)
return;
- if (Cmd_Argc() > 2)
+ if (Cmd_Argc(cmd) > 2)
{
- message = Cmd_Args();
+ message = Cmd_Args(cmd);
COM_ParseToken_Simple(&message, false, false, true);
if (byNumber)
{
message++; // skip the #
while (*message == ' ') // skip white space
message++;
- message += strlen(Cmd_Argv(2)); // skip the number
+ message += strlen(Cmd_Argv(cmd, 2)); // skip the number
}
while (*message && *message == ' ')
message++;
Host_Give_f
==================
*/
-static void Host_Give_f (void)
+static void Host_Give_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
const char *t;
return;
}
- t = Cmd_Argv(1);
- v = atoi (Cmd_Argv(2));
+ t = Cmd_Argv(cmd, 1);
+ v = atoi (Cmd_Argv(cmd, 2));
switch (t[0])
{
Host_Viewmodel_f
==================
*/
-static void Host_Viewmodel_f (void)
+static void Host_Viewmodel_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
prvm_edict_t *e;
e = FindViewthing(prog);
if (e)
{
- m = Mod_ForName (Cmd_Argv(1), false, true, NULL);
+ m = Mod_ForName (Cmd_Argv(cmd, 1), false, true, NULL);
if (m && m->loaded && m->Draw)
{
PRVM_serveredictfloat(e, frame) = 0;
cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)] = m;
}
else
- Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
+ Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(cmd, 1));
}
}
Host_Viewframe_f
==================
*/
-static void Host_Viewframe_f (void)
+static void Host_Viewframe_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
prvm_edict_t *e;
{
m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)];
- f = atoi(Cmd_Argv(1));
+ f = atoi(Cmd_Argv(cmd, 1));
if (f >= m->numframes)
f = m->numframes-1;
Host_Viewnext_f
==================
*/
-static void Host_Viewnext_f (void)
+static void Host_Viewnext_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
prvm_edict_t *e;
Host_Viewprev_f
==================
*/
-static void Host_Viewprev_f (void)
+static void Host_Viewprev_f(cmd_state_t *cmd)
{
prvm_prog_t *prog = SVVM_prog;
prvm_edict_t *e;
Host_Startdemos_f
==================
*/
-static void Host_Startdemos_f (void)
+static void Host_Startdemos_f(cmd_state_t *cmd)
{
int i, c;
if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-capturedemo"))
return;
- c = Cmd_Argc() - 1;
+ c = Cmd_Argc(cmd) - 1;
if (c > MAX_DEMOS)
{
Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
Con_DPrintf("%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]));
+ strlcpy (cls.demos[i-1], Cmd_Argv(cmd, i), sizeof (cls.demos[i-1]));
// LadyHavoc: clear the remaining slots
for (;i <= MAX_DEMOS;i++)
Return to looping demos
==================
*/
-static void Host_Demos_f (void)
+static void Host_Demos_f(cmd_state_t *cmd)
{
if (cls.state == ca_dedicated)
return;
if (cls.demonum == -1)
cls.demonum = 1;
- CL_Disconnect_f ();
+ CL_Disconnect_f (cmd);
CL_NextDemo ();
}
Return to looping demos
==================
*/
-static void Host_Stopdemo_f (void)
+static void Host_Stopdemo_f(cmd_state_t *cmd)
{
if (!cls.demoplayback)
return;
Host_ShutdownServer ();
}
-static void Host_SendCvar_f (void)
+static void Host_SendCvar_f(cmd_state_t *cmd)
{
int i;
cvar_t *c;
client_t *old;
char vabuf[1024];
- if(Cmd_Argc() != 2)
+ if(Cmd_Argc(cmd) != 2)
return;
- cvarname = Cmd_Argv(1);
+ cvarname = Cmd_Argv(cmd, 1);
if (cls.state == ca_connected)
{
c = Cvar_FindVar(cvarname);
host_client = old;
}
-static void MaxPlayers_f(void)
+static void MaxPlayers_f(cmd_state_t *cmd)
{
int n;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Printf("\"maxplayers\" is \"%u\"\n", svs.maxclients_next);
return;
Con_Print("It will be changed on next server startup (\"map\" command).\n");
}
- n = atoi(Cmd_Argv(1));
+ n = atoi(Cmd_Argv(cmd, 1));
n = bound(1, n, MAX_SCOREBOARD);
Con_Printf("\"maxplayers\" set to \"%u\"\n", n);
ProQuake rcon support
=====================
*/
-static void Host_PQRcon_f (void)
+static void Host_PQRcon_f(cmd_state_t *cmd)
{
int n;
const char *e;
lhnetsocket_t *mysocket;
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
- Con_Printf("%s: Usage: %s command\n", Cmd_Argv(0), Cmd_Argv(0));
+ Con_Printf("%s: Usage: %s command\n", Cmd_Argv(cmd, 0), Cmd_Argv(cmd, 0));
return;
}
MSG_WriteByte(&buf, CCREQ_RCON);
SZ_Write(&buf, (const unsigned char*)rcon_password.string, n);
MSG_WriteByte(&buf, 0); // terminate the (possibly partial) string
- MSG_WriteString(&buf, Cmd_Args());
+ MSG_WriteString(&buf, Cmd_Args(cmd));
StoreBigLong(buf.data, NETFLAG_CTL | (buf.cursize & NETFLAG_LENGTH_MASK));
NetConn_Write(mysocket, buf.data, buf.cursize, &cls.rcon_address);
SZ_Clear(&buf);
an unconnected command.
=====================
*/
-static void Host_Rcon_f (void) // credit: taken from QuakeWorld
+static void Host_Rcon_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
{
int i, n;
const char *e;
lhnetsocket_t *mysocket;
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
- Con_Printf("%s: Usage: %s command\n", Cmd_Argv(0), Cmd_Argv(0));
+ Con_Printf("%s: Usage: %s command\n", Cmd_Argv(cmd, 0), Cmd_Argv(cmd, 0));
return;
}
LHNETADDRESS_FromString(&cls.rcon_address, rcon_address.string, sv_netport.integer);
}
mysocket = NetConn_ChooseClientSocketForAddress(&cls.rcon_address);
- if (mysocket && Cmd_Args()[0])
+ if (mysocket && Cmd_Args(cmd)[0])
{
// simply put together the rcon packet and send it
- if(Cmd_Argv(0)[0] == 's' || rcon_secure.integer > 1)
+ if(Cmd_Argv(cmd, 0)[0] == 's' || rcon_secure.integer > 1)
{
if(cls.rcon_commands[cls.rcon_ringpos][0])
{
++cls.rcon_trying;
if(i >= MAX_RCONS)
NetConn_WriteString(mysocket, "\377\377\377\377getchallenge", &cls.rcon_address); // otherwise we'll request the challenge later
- strlcpy(cls.rcon_commands[cls.rcon_ringpos], Cmd_Args(), sizeof(cls.rcon_commands[cls.rcon_ringpos]));
+ strlcpy(cls.rcon_commands[cls.rcon_ringpos], Cmd_Args(cmd), sizeof(cls.rcon_commands[cls.rcon_ringpos]));
cls.rcon_addresses[cls.rcon_ringpos] = cls.rcon_address;
cls.rcon_timeout[cls.rcon_ringpos] = realtime + rcon_secure_challengetimeout.value;
cls.rcon_ringpos = (cls.rcon_ringpos + 1) % MAX_RCONS;
{
char buf[1500];
char argbuf[1500];
- dpsnprintf(argbuf, sizeof(argbuf), "%ld.%06d %s", (long) time(NULL), (int) (rand() % 1000000), Cmd_Args());
+ dpsnprintf(argbuf, sizeof(argbuf), "%ld.%06d %s", (long) time(NULL), (int) (rand() % 1000000), Cmd_Args(cmd));
memcpy(buf, "\377\377\377\377srcon HMAC-MD4 TIME ", 24);
if(HMAC_MDFOUR_16BYTES((unsigned char *) (buf + 24), (unsigned char *) argbuf, (int)strlen(argbuf), (unsigned char *) rcon_password.string, n))
{
{
char buf[1500];
memcpy(buf, "\377\377\377\377", 4);
- dpsnprintf(buf+4, sizeof(buf)-4, "rcon %.*s %s", n, rcon_password.string, Cmd_Args());
+ dpsnprintf(buf+4, sizeof(buf)-4, "rcon %.*s %s", n, rcon_password.string, Cmd_Args(cmd));
NetConn_WriteString(mysocket, buf, &cls.rcon_address);
}
}
Dump userdata / masterdata for a user
====================
*/
-static void Host_User_f (void) // credit: taken from QuakeWorld
+static void Host_User_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
{
int uid;
int i;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Printf ("Usage: user <username / userid>\n");
return;
}
- uid = atoi(Cmd_Argv(1));
+ uid = atoi(Cmd_Argv(cmd, 1));
for (i = 0;i < cl.maxclients;i++)
{
if (!cl.scores[i].name[0])
continue;
- if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(1)))
+ if (cl.scores[i].qw_userid == uid || !strcasecmp(cl.scores[i].name, Cmd_Argv(cmd, 1)))
{
InfoString_Print(cl.scores[i].qw_userinfo);
return;
Dump userids for all current players
====================
*/
-static void Host_Users_f (void) // credit: taken from QuakeWorld
+static void Host_Users_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
{
int i;
int c;
==================
*/
// TODO: shouldn't this be a cvar instead?
-static void Host_FullServerinfo_f (void) // credit: taken from QuakeWorld
+static void Host_FullServerinfo_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
{
char temp[512];
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Printf ("usage: fullserverinfo <complete info string>\n");
return;
}
- strlcpy (cl.qw_serverinfo, Cmd_Argv(1), sizeof(cl.qw_serverinfo));
+ strlcpy (cl.qw_serverinfo, Cmd_Argv(cmd, 1), sizeof(cl.qw_serverinfo));
InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
cl.qw_teamplay = atoi(temp);
}
==================
Casey was here :)
*/
-static void Host_FullInfo_f (void) // credit: taken from QuakeWorld
+static void Host_FullInfo_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
{
char key[512];
char value[512];
const char *s;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Printf ("fullinfo <complete info string>\n");
return;
}
- s = Cmd_Argv(1);
+ s = Cmd_Argv(cmd, 1);
if (*s == '\\')
s++;
while (*s)
Allow clients to change userinfo
==================
*/
-static void Host_SetInfo_f (void) // credit: taken from QuakeWorld
+static void Host_SetInfo_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
{
- if (Cmd_Argc() == 1)
+ if (Cmd_Argc(cmd) == 1)
{
InfoString_Print(cls.userinfo);
return;
}
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
Con_Printf ("usage: setinfo [ <key> <value> ]\n");
return;
}
- CL_SetInfo(Cmd_Argv(1), Cmd_Argv(2), true, false, false, false);
+ CL_SetInfo(Cmd_Argv(cmd, 1), Cmd_Argv(cmd, 2), true, false, false, false);
}
/*
Contents allows \n escape character
====================
*/
-static void Host_Packet_f (void) // credit: taken from QuakeWorld
+static void Host_Packet_f(cmd_state_t *cmd) // credit: taken from QuakeWorld
{
char send[2048];
int i, l;
lhnetaddress_t address;
lhnetsocket_t *mysocket;
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
Con_Printf ("packet <destination> <contents>\n");
return;
}
- if (!LHNETADDRESS_FromString (&address, Cmd_Argv(1), sv_netport.integer))
+ if (!LHNETADDRESS_FromString (&address, Cmd_Argv(cmd, 1), sv_netport.integer))
{
Con_Printf ("Bad address\n");
return;
}
- in = Cmd_Argv(2);
+ in = Cmd_Argv(cmd, 2);
out = send+4;
send[0] = send[1] = send[2] = send[3] = -1;
Send back ping and packet loss update for all current players to this player
====================
*/
-void Host_Pings_f (void)
+void Host_Pings_f(cmd_state_t *cmd)
{
int i, j, ping, packetloss, movementloss;
char temp[128];
MSG_WriteString(&host_client->netconnection->message, "\n");
}
-static void Host_PingPLReport_f(void)
+static void Host_PingPLReport_f(cmd_state_t *cmd)
{
char *errbyte;
int i;
- int l = Cmd_Argc();
+ int l = Cmd_Argc(cmd);
if (l > cl.maxclients)
l = cl.maxclients;
for (i = 0;i < l;i++)
{
- cl.scores[i].qw_ping = atoi(Cmd_Argv(1+i*2));
- cl.scores[i].qw_packetloss = strtol(Cmd_Argv(1+i*2+1), &errbyte, 0);
+ cl.scores[i].qw_ping = atoi(Cmd_Argv(cmd, 1+i*2));
+ cl.scores[i].qw_packetloss = strtol(Cmd_Argv(cmd, 1+i*2+1), &errbyte, 0);
if(errbyte && *errbyte == ',')
cl.scores[i].qw_movementloss = atoi(errbyte + 1);
else
{
dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\dp");
- Cmd_AddCommand_WithClientCommand ("status", Host_Status_f, Host_Status_f, "print server status information");
- Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");
- Cmd_AddCommand_WithClientCommand ("god", NULL, Host_God_f, "god mode (invulnerability)");
- Cmd_AddCommand_WithClientCommand ("notarget", NULL, Host_Notarget_f, "notarget mode (monsters do not see you)");
- Cmd_AddCommand_WithClientCommand ("fly", NULL, Host_Fly_f, "fly mode (flight)");
- Cmd_AddCommand_WithClientCommand ("noclip", NULL, Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
- Cmd_AddCommand_WithClientCommand ("give", NULL, Host_Give_f, "alter inventory");
- Cmd_AddCommand ("map", Host_Map_f, "kick everyone off the server and start a new level");
- Cmd_AddCommand ("restart", Host_Restart_f, "restart current level");
- Cmd_AddCommand ("changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
- Cmd_AddCommand ("connect", Host_Connect_f, "connect to a server by IP address or hostname");
- Cmd_AddCommand ("reconnect", Host_Reconnect_f, "reconnect to the last server you were on, or resets a quakeworld connection (do not use if currently playing on a netquake server)");
- Cmd_AddCommand ("version", Host_Version_f, "print engine version");
- Cmd_AddCommand_WithClientCommand ("say", Host_Say_f, Host_Say_f, "send a chat message to everyone on the server");
- Cmd_AddCommand_WithClientCommand ("say_team", Host_Say_Team_f, Host_Say_Team_f, "send a chat message to your team on the server");
- Cmd_AddCommand_WithClientCommand ("tell", Host_Tell_f, Host_Tell_f, "send a chat message to only one person on the server");
- Cmd_AddCommand_WithClientCommand ("kill", NULL, Host_Kill_f, "die instantly");
- Cmd_AddCommand_WithClientCommand ("pause", Host_Pause_f, Host_Pause_f, "pause the game (if the server allows pausing)");
- Cmd_AddCommand ("kick", Host_Kick_f, "kick a player off the server by number or name");
- Cmd_AddCommand_WithClientCommand ("ping", Host_Ping_f, Host_Ping_f, "print ping times of all players on the server");
- Cmd_AddCommand ("load", Host_Loadgame_f, "load a saved game file");
- Cmd_AddCommand ("save", Host_Savegame_f, "save the game to a file");
-
- Cmd_AddCommand ("startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
- Cmd_AddCommand ("demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
- Cmd_AddCommand ("stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
-
- Cmd_AddCommand ("viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
- Cmd_AddCommand ("viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
- Cmd_AddCommand ("viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
- Cmd_AddCommand ("viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
-
- Cvar_RegisterVariable (&cl_name);
- Cmd_AddCommand_WithClientCommand ("name", Host_Name_f, Host_Name_f, "change your player name");
- Cvar_RegisterVariable (&cl_color);
- Cmd_AddCommand_WithClientCommand ("color", Host_Color_f, Host_Color_f, "change your player shirt and pants colors");
- Cvar_RegisterVariable (&cl_rate);
- Cmd_AddCommand_WithClientCommand ("rate", Host_Rate_f, Host_Rate_f, "change your network connection speed");
- Cvar_RegisterVariable (&cl_rate_burstsize);
- Cmd_AddCommand_WithClientCommand ("rate_burstsize", Host_Rate_BurstSize_f, Host_Rate_BurstSize_f, "change your network connection speed");
- Cvar_RegisterVariable (&cl_pmodel);
- Cmd_AddCommand_WithClientCommand ("pmodel", Host_PModel_f, Host_PModel_f, "(Nehahra-only) change your player model choice");
-
- // BLACK: This isnt game specific anymore (it was GAME_NEXUIZ at first)
- Cvar_RegisterVariable (&cl_playermodel);
- Cmd_AddCommand_WithClientCommand ("playermodel", Host_Playermodel_f, Host_Playermodel_f, "change your player model");
- Cvar_RegisterVariable (&cl_playerskin);
- Cmd_AddCommand_WithClientCommand ("playerskin", Host_Playerskin_f, Host_Playerskin_f, "change your player skin number");
-
- Cmd_AddCommand_WithClientCommand ("prespawn", NULL, Host_PreSpawn_f, "signon 1 (client acknowledges that server information has been received)");
- Cmd_AddCommand_WithClientCommand ("spawn", NULL, Host_Spawn_f, "signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
- Cmd_AddCommand_WithClientCommand ("begin", NULL, Host_Begin_f, "signon 3 (client asks server to start sending entities, and will go to signon 4 (playing) when the first entity update is received)");
- Cmd_AddCommand ("maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
-
- Cmd_AddCommand ("sendcvar", Host_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
-
- Cvar_RegisterVariable (&rcon_password);
- Cvar_RegisterVariable (&rcon_address);
- Cvar_RegisterVariable (&rcon_secure);
- Cvar_RegisterVariable (&rcon_secure_challengetimeout);
- Cmd_AddCommand ("rcon", Host_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); note: if rcon_secure is set, client and server clocks must be synced e.g. via NTP");
- Cmd_AddCommand ("srcon", Host_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); this always works as if rcon_secure is set; note: client and server clocks must be synced e.g. via NTP");
- Cmd_AddCommand ("pqrcon", Host_PQRcon_f, "sends a command to a proquake server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's)");
- Cmd_AddCommand ("user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
- Cmd_AddCommand ("users", Host_Users_f, "prints additional information about all players on the scoreboard");
- Cmd_AddCommand ("fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
- Cmd_AddCommand ("fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
- Cmd_AddCommand ("setinfo", Host_SetInfo_f, "modifies your userinfo");
- Cmd_AddCommand ("packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
- Cmd_AddCommand ("topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color");
- Cmd_AddCommand ("bottomcolor", Host_BottomColor_f, "QW command to set bottom color without changing top color");
-
- Cmd_AddCommand_WithClientCommand ("pings", NULL, Host_Pings_f, "command sent by clients to request updated ping and packetloss of players on scoreboard (originally from QW, but also used on NQ servers)");
- Cmd_AddCommand ("pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)");
-
- Cmd_AddCommand ("fixtrans", Image_FixTransparentPixels_f, "change alpha-zero pixels in an image file to sensible values, and write out a new TGA (warning: SLOW)");
- Cvar_RegisterVariable (&r_fixtrans_auto);
-
- Cvar_RegisterVariable (&team);
- Cvar_RegisterVariable (&skin);
- Cvar_RegisterVariable (&noaim);
-
+ Cvar_RegisterVariable(&cl_name);
+ Cvar_RegisterVariable(&cl_color);
+ Cvar_RegisterVariable(&cl_rate);
+ Cvar_RegisterVariable(&cl_rate_burstsize);
+ Cvar_RegisterVariable(&cl_pmodel);
+ Cvar_RegisterVariable(&cl_playermodel);
+ Cvar_RegisterVariable(&cl_playerskin);
+ Cvar_RegisterVariable(&rcon_password);
+ Cvar_RegisterVariable(&rcon_address);
+ Cvar_RegisterVariable(&rcon_secure);
+ Cvar_RegisterVariable(&rcon_secure_challengetimeout);
+ Cvar_RegisterVariable(&r_fixtrans_auto);
+ Cvar_RegisterVariable(&team);
+ Cvar_RegisterVariable(&skin);
+ Cvar_RegisterVariable(&noaim);
Cvar_RegisterVariable(&sv_cheats);
Cvar_RegisterVariable(&sv_adminnick);
Cvar_RegisterVariable(&sv_status_privacy);
Cvar_RegisterVariable(&sv_status_show_qcstatus);
Cvar_RegisterVariable(&sv_namechangetimer);
+
+ // client commands - this includes server commands because the client can host a server, so they must exist
+ Cmd_AddCommand(&cmd_client, "quit", Host_Quit_f, "quit the game");
+ Cmd_AddCommand(&cmd_client, "status", Host_Status_f, "print server status information");
+ Cmd_AddCommand(&cmd_client, "map", Host_Map_f, "kick everyone off the server and start a new level");
+ Cmd_AddCommand(&cmd_client, "restart", Host_Restart_f, "restart current level");
+ Cmd_AddCommand(&cmd_client, "changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
+ Cmd_AddCommand(&cmd_client, "version", Host_Version_f, "print engine version");
+ Cmd_AddCommand(&cmd_client, "say", Host_Say_f, "send a chat message to everyone on the server");
+ Cmd_AddCommand(&cmd_client, "tell", Host_Tell_f, "send a chat message to only one person on the server");
+ Cmd_AddCommand(&cmd_client, "pause", Host_Pause_f, "pause the game (if the server allows pausing)");
+ Cmd_AddCommand(&cmd_client, "kick", Host_Kick_f, "kick a player off the server by number or name");
+ Cmd_AddCommand(&cmd_client, "ping", Host_Ping_f, "print ping times of all players on the server");
+ Cmd_AddCommand(&cmd_client, "load", Host_Loadgame_f, "load a saved game file");
+ Cmd_AddCommand(&cmd_client, "save", Host_Savegame_f, "save the game to a file");
+ Cmd_AddCommand(&cmd_client, "viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_client, "viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_client, "viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_client, "viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_client, "maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
+ Cmd_AddCommand(&cmd_client, "user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
+ Cmd_AddCommand(&cmd_client, "users", Host_Users_f, "prints additional information about all players on the scoreboard");
+
+ // dedicated server commands
+ Cmd_AddCommand(&cmd_server, "quit", Host_Quit_f, "quit the game");
+ Cmd_AddCommand(&cmd_server, "status", Host_Status_f, "print server status information");
+ Cmd_AddCommand(&cmd_server, "map", Host_Map_f, "kick everyone off the server and start a new level");
+ Cmd_AddCommand(&cmd_server, "restart", Host_Restart_f, "restart current level");
+ Cmd_AddCommand(&cmd_server, "changelevel", Host_Changelevel_f, "change to another level, bringing along all connected clients");
+ Cmd_AddCommand(&cmd_server, "version", Host_Version_f, "print engine version");
+ Cmd_AddCommand(&cmd_server, "say", Host_Say_f, "send a chat message to everyone on the server");
+ Cmd_AddCommand(&cmd_server, "tell", Host_Tell_f, "send a chat message to only one person on the server");
+ Cmd_AddCommand(&cmd_server, "pause", Host_Pause_f, "pause the game (if the server allows pausing)");
+ Cmd_AddCommand(&cmd_server, "kick", Host_Kick_f, "kick a player off the server by number or name");
+ Cmd_AddCommand(&cmd_server, "ping", Host_Ping_f, "print ping times of all players on the server");
+ Cmd_AddCommand(&cmd_server, "load", Host_Loadgame_f, "load a saved game file");
+ Cmd_AddCommand(&cmd_server, "save", Host_Savegame_f, "save the game to a file");
+ Cmd_AddCommand(&cmd_server, "viewmodel", Host_Viewmodel_f, "change model of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_server, "viewframe", Host_Viewframe_f, "change animation frame of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_server, "viewnext", Host_Viewnext_f, "change to next animation frame of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_server, "viewprev", Host_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
+ Cmd_AddCommand(&cmd_server, "maxplayers", MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
+ Cmd_AddCommand(&cmd_server, "user", Host_User_f, "prints additional information about a player number or name on the scoreboard");
+ Cmd_AddCommand(&cmd_server, "users", Host_Users_f, "prints additional information about all players on the scoreboard");
+
+ // commands that do not have automatic forwarding from cmd_client, these are internal details of the network protocol and not of interest to users (if they know what they are doing they can still use a generic "cmd prespawn" or similar)
+ Cmd_AddCommand(&cmd_serverfromclient, "prespawn", Host_PreSpawn_f, "internal use - signon 1 (client acknowledges that server information has been received)");
+ Cmd_AddCommand(&cmd_serverfromclient, "spawn", Host_Spawn_f, "internal use - signon 2 (client has sent player information, and is asking server to send scoreboard rankings)");
+ Cmd_AddCommand(&cmd_serverfromclient, "begin", Host_Begin_f, "internal use - signon 3 (client asks server to start sending entities, and will go to signon 4 (playing) when the first entity update is received)");
+ Cmd_AddCommand(&cmd_serverfromclient, "pings", Host_Pings_f, "internal use - command sent by clients to request updated ping and packetloss of players on scoreboard (originally from QW, but also used on NQ servers)");
+
+ Cmd_AddCommand(&cmd_serverfromclient, "status", Host_Status_f, "print server status information");
+ Cmd_AddCommand(&cmd_serverfromclient, "god", Host_God_f, "god mode (invulnerability)");
+ Cmd_AddCommand(&cmd_serverfromclient, "notarget", Host_Notarget_f, "notarget mode (monsters do not see you)");
+ Cmd_AddCommand(&cmd_serverfromclient, "fly", Host_Fly_f, "fly mode (flight)");
+ Cmd_AddCommand(&cmd_serverfromclient, "noclip", Host_Noclip_f, "noclip mode (flight without collisions, move through walls)");
+ Cmd_AddCommand(&cmd_serverfromclient, "give", Host_Give_f, "alter inventory");
+ Cmd_AddCommand(&cmd_serverfromclient, "say", Host_Say_f, "send a chat message to everyone on the server");
+ Cmd_AddCommand(&cmd_serverfromclient, "say_team", Host_Say_Team_f, "send a chat message to your team on the server");
+ Cmd_AddCommand(&cmd_serverfromclient, "tell", Host_Tell_f, "send a chat message to only one person on the server");
+ Cmd_AddCommand(&cmd_serverfromclient, "kill", Host_Kill_f, "die instantly");
+ Cmd_AddCommand(&cmd_serverfromclient, "pause", Host_Pause_f, "pause the game (if the server allows pausing)");
+ Cmd_AddCommand(&cmd_serverfromclient, "ping", Host_Ping_f, "print ping times of all players on the server");
+ Cmd_AddCommand(&cmd_serverfromclient, "name", Host_Name_f, "change your player name");
+ Cmd_AddCommand(&cmd_serverfromclient, "color", Host_Color_f, "change your player shirt and pants colors");
+ Cmd_AddCommand(&cmd_serverfromclient, "rate", Host_Rate_f, "change your network connection speed");
+ Cmd_AddCommand(&cmd_serverfromclient, "rate_burstsize", Host_Rate_BurstSize_f, "change your network connection speed");
+ Cmd_AddCommand(&cmd_serverfromclient, "pmodel", Host_PModel_f, "(Nehahra-only) change your player model choice");
+ Cmd_AddCommand(&cmd_serverfromclient, "playermodel", Host_Playermodel_f, "change your player model");
+ Cmd_AddCommand(&cmd_serverfromclient, "playerskin", Host_Playerskin_f, "change your player skin number");
+
+ // client commands that require a connection and are simply forwarded to server
+ Cmd_AddCommand(&cmd_client, "status", Cmd_ForwardToServer_f, "print server status information");
+ Cmd_AddCommand(&cmd_client, "god", Cmd_ForwardToServer_f, "god mode (invulnerability)");
+ Cmd_AddCommand(&cmd_client, "notarget", Cmd_ForwardToServer_f, "notarget mode (monsters do not see you)");
+ Cmd_AddCommand(&cmd_client, "fly", Cmd_ForwardToServer_f, "fly mode (flight)");
+ Cmd_AddCommand(&cmd_client, "noclip", Cmd_ForwardToServer_f, "noclip mode (flight without collisions, move through walls)");
+ Cmd_AddCommand(&cmd_client, "give", Cmd_ForwardToServer_f, "alter inventory");
+ Cmd_AddCommand(&cmd_client, "say", Cmd_ForwardToServer_f, "send a chat message to everyone on the server");
+ Cmd_AddCommand(&cmd_client, "say_team", Cmd_ForwardToServer_f, "send a chat message to your team on the server");
+ Cmd_AddCommand(&cmd_client, "tell", Cmd_ForwardToServer_f, "send a chat message to only one person on the server");
+ Cmd_AddCommand(&cmd_client, "kill", Cmd_ForwardToServer_f, "die instantly");
+ Cmd_AddCommand(&cmd_client, "pause", Cmd_ForwardToServer_f, "pause the game (if the server allows pausing)");
+ Cmd_AddCommand(&cmd_client, "ping", Cmd_ForwardToServer_f, "print ping times of all players on the server");
+
+ Cmd_AddCommand(&cmd_client, "connect", Host_Connect_f, "connect to a server by IP address or hostname");
+ Cmd_AddCommand(&cmd_client, "reconnect", Host_Reconnect_f, "reconnect to the last server you were on, or resets a quakeworld connection (do not use if currently playing on a netquake server)");
+ Cmd_AddCommand(&cmd_client, "version", Host_Version_f, "print engine version");
+ Cmd_AddCommand(&cmd_client, "startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
+ Cmd_AddCommand(&cmd_client, "demos", Host_Demos_f, "restart looping demos defined by the last startdemos command");
+ Cmd_AddCommand(&cmd_client, "stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
+ Cmd_AddCommand(&cmd_client, "sendcvar", Host_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
+ Cmd_AddCommand(&cmd_client, "rcon", Host_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); note: if rcon_secure is set, client and server clocks must be synced e.g. via NTP");
+ Cmd_AddCommand(&cmd_client, "srcon", Host_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); this always works as if rcon_secure is set; note: client and server clocks must be synced e.g. via NTP");
+ Cmd_AddCommand(&cmd_client, "pqrcon", Host_PQRcon_f, "sends a command to a proquake server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's)");
+ Cmd_AddCommand(&cmd_client, "fullinfo", Host_FullInfo_f, "allows client to modify their userinfo");
+ Cmd_AddCommand(&cmd_client, "setinfo", Host_SetInfo_f, "modifies your userinfo");
+ Cmd_AddCommand(&cmd_client, "packet", Host_Packet_f, "send a packet to the specified address:port containing a text string");
+ Cmd_AddCommand(&cmd_client, "topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color");
+ Cmd_AddCommand(&cmd_client, "bottomcolor", Host_BottomColor_f, "QW command to set bottom color without changing top color");
+ Cmd_AddCommand(&cmd_client, "fixtrans", Image_FixTransparentPixels_f, "change alpha-zero pixels in an image file to sensible values, and write out a new TGA (warning: SLOW)");
+
+ // client commands that also exist as cmd_serverfromclient and are often forwarded
+ Cmd_AddCommand(&cmd_client, "name", Host_Name_f, "change your player name");
+ Cmd_AddCommand(&cmd_client, "color", Host_Color_f, "change your player shirt and pants colors");
+ Cmd_AddCommand(&cmd_client, "rate", Host_Rate_f, "change your network connection speed");
+ Cmd_AddCommand(&cmd_client, "rate_burstsize", Host_Rate_BurstSize_f, "change your network connection speed");
+ Cmd_AddCommand(&cmd_client, "pmodel", Host_PModel_f, "(Nehahra-only) change your player model choice");
+ Cmd_AddCommand(&cmd_client, "playermodel", Host_Playermodel_f, "change your player model");
+ Cmd_AddCommand(&cmd_client, "playerskin", Host_Playerskin_f, "change your player skin number");
+
+ // commands that are only sent by server to client for execution
+ Cmd_AddCommand(&cmd_clientfromserver, "pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)");
+ Cmd_AddCommand(&cmd_clientfromserver, "fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string");
}
-void Host_NoOperation_f(void)
+void Host_NoOperation_f(cmd_state_t *cmd)
{
}
return changedPixels;
}
-void Image_FixTransparentPixels_f(void)
+void Image_FixTransparentPixels_f(cmd_state_t *cmd)
{
const char *filename, *filename_pattern;
fssearch_t *search;
int i, n;
char outfilename[MAX_QPATH], buf[MAX_QPATH];
unsigned char *data;
- if(Cmd_Argc() != 2)
+ if(Cmd_Argc(cmd) != 2)
{
- Con_Printf("Usage: %s imagefile\n", Cmd_Argv(0));
+ Con_Printf("Usage: %s imagefile\n", Cmd_Argv(cmd, 0));
return;
}
- filename_pattern = Cmd_Argv(1);
+ filename_pattern = Cmd_Argv(cmd, 1);
search = FS_Search(filename_pattern, true, true);
if(!search)
return;
void Image_HeightmapToNormalmap_BGRA(const unsigned char *inpixels, unsigned char *outpixels, int width, int height, int clamp, float bumpscale);
// console command to fix the colors of transparent pixels (to prevent weird borders)
-void Image_FixTransparentPixels_f(void);
+void Image_FixTransparentPixels_f(cmd_state_t *cmd);
extern cvar_t r_fixtrans_auto;
#define Image_LinearFloatFromsRGBFloat(c) (((c) <= 0.04045f) ? (c) * (1.0f / 12.92f) : (float)pow(((c) + 0.055f)*(1.0f/1.055f), 2.4f))
Con_Printf("%i result%s\n\n", count, (count != 1) ? "s" : "");
}
-static void Key_History_f(void)
+static void Key_History_f(cmd_state_t *cmd)
{
char *errchar = NULL;
int i = 0;
char vabuf[1024];
size_t digits = strlen(va(vabuf, sizeof(vabuf), "%i", HIST_MAXLINES));
- if (Cmd_Argc () > 1)
+ if (Cmd_Argc (cmd) > 1)
{
- if (!strcmp(Cmd_Argv (1), "-c"))
+ if (!strcmp(Cmd_Argv(cmd, 1), "-c"))
{
ConBuffer_Clear(&history);
return;
}
- i = strtol(Cmd_Argv (1), &errchar, 0);
+ i = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
if ((i < 0) || (i > CONBUFFER_LINES_COUNT(&history)) || (errchar && *errchar))
i = 0;
else
====================
*/
static void
-Key_Console (int key, int unicode)
+Key_Console (cmd_state_t *cmd, int key, int unicode)
{
// LadyHavoc: copied most of this from Q2 to improve keyboard handling
switch (key)
if (key == 'l' && keydown[K_CTRL])
{
- Cbuf_AddText ("clear\n");
+ Cbuf_AddText (cmd, "clear\n");
return;
}
if (key == K_ENTER || key == K_KP_ENTER)
{
- Cbuf_AddText (key_line+1); // skip the ]
- Cbuf_AddText ("\n");
+ Cbuf_AddText (cmd, key_line+1); // skip the ]
+ Cbuf_AddText (cmd, "\n");
Key_History_Push();
key_line[0] = ']';
key_line[1] = 0; // EvilTypeGuy: null terminate
// Enhanced command completion
// by EvilTypeGuy eviltypeguy@qeradiant.com
// Thanks to Fett, Taniwha
- Con_CompleteCommandLine();
+ Con_CompleteCommandLine(cmd);
return;
}
unsigned int chat_bufferlen = 0;
static void
-Key_Message (int key, int ascii)
+Key_Message (cmd_state_t *cmd, int key, int ascii)
{
char vabuf[1024];
if (key == K_ENTER || key == K_KP_ENTER || ascii == 10 || ascii == 13)
{
if(chat_mode < 0)
- Cmd_ExecuteString(chat_buffer, src_command, true); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases!
+ Cmd_ExecuteString(cmd, chat_buffer, src_command, true); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases!
else
Cmd_ForwardStringToServer(va(vabuf, sizeof(vabuf), "%s %s", chat_mode ? "say_team" : "say ", chat_buffer));
}
static void
-Key_In_Unbind_f (void)
+Key_In_Unbind_f(cmd_state_t *cmd)
{
int b, m;
char *errchar = NULL;
- if (Cmd_Argc () != 3) {
+ if (Cmd_Argc (cmd) != 3) {
Con_Print("in_unbind <bindmap> <key> : remove commands from a key\n");
return;
}
- m = strtol(Cmd_Argv (1), &errchar, 0);
+ m = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
- Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
+ Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
return;
}
- b = Key_StringToKeynum (Cmd_Argv (2));
+ b = Key_StringToKeynum (Cmd_Argv(cmd, 2));
if (b == -1) {
- Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (2));
+ Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 2));
return;
}
}
static void
-Key_In_Bind_f (void)
+Key_In_Bind_f(cmd_state_t *cmd)
{
int i, c, b, m;
- char cmd[MAX_INPUTLINE];
+ char line[MAX_INPUTLINE];
char *errchar = NULL;
- c = Cmd_Argc ();
+ c = Cmd_Argc (cmd);
if (c != 3 && c != 4) {
Con_Print("in_bind <bindmap> <key> [command] : attach a command to a key\n");
return;
}
- m = strtol(Cmd_Argv (1), &errchar, 0);
+ m = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
- Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
+ Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
return;
}
- b = Key_StringToKeynum (Cmd_Argv (2));
+ b = Key_StringToKeynum (Cmd_Argv(cmd, 2));
if (b == -1 || b >= MAX_KEYS) {
- Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (2));
+ Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 2));
return;
}
if (c == 3) {
if (keybindings[m][b])
- Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv (2), keybindings[m][b]);
+ Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv(cmd, 2), keybindings[m][b]);
else
- Con_Printf("\"%s\" is not bound\n", Cmd_Argv (2));
+ Con_Printf("\"%s\" is not bound\n", Cmd_Argv(cmd, 2));
return;
}
// copy the rest of the command line
- cmd[0] = 0; // start out with a null string
+ line[0] = 0; // start out with a null string
for (i = 3; i < c; i++) {
- strlcat (cmd, Cmd_Argv (i), sizeof (cmd));
+ strlcat (line, Cmd_Argv(cmd, i), sizeof (line));
if (i != (c - 1))
- strlcat (cmd, " ", sizeof (cmd));
+ strlcat (line, " ", sizeof (line));
}
- if(!Key_SetBinding (b, m, cmd))
+ if(!Key_SetBinding (b, m, line))
Con_Printf("Key_SetBinding failed for unknown reason\n");
}
static void
-Key_In_Bindmap_f (void)
+Key_In_Bindmap_f(cmd_state_t *cmd)
{
int m1, m2, c;
char *errchar = NULL;
- c = Cmd_Argc ();
+ c = Cmd_Argc (cmd);
if (c != 3) {
Con_Print("in_bindmap <bindmap> <fallback>: set current bindmap and fallback\n");
return;
}
- m1 = strtol(Cmd_Argv (1), &errchar, 0);
+ m1 = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
if ((m1 < 0) || (m1 >= MAX_BINDMAPS) || (errchar && *errchar)) {
- Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
+ Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
return;
}
- m2 = strtol(Cmd_Argv (2), &errchar, 0);
+ m2 = strtol(Cmd_Argv(cmd, 2), &errchar, 0);
if ((m2 < 0) || (m2 >= MAX_BINDMAPS) || (errchar && *errchar)) {
- Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(2));
+ Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 2));
return;
}
}
static void
-Key_Unbind_f (void)
+Key_Unbind_f(cmd_state_t *cmd)
{
int b;
- if (Cmd_Argc () != 2) {
+ if (Cmd_Argc (cmd) != 2) {
Con_Print("unbind <key> : remove commands from a key\n");
return;
}
- b = Key_StringToKeynum (Cmd_Argv (1));
+ b = Key_StringToKeynum (Cmd_Argv(cmd, 1));
if (b == -1) {
- Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (1));
+ Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 1));
return;
}
}
static void
-Key_Unbindall_f (void)
+Key_Unbindall_f(cmd_state_t *cmd)
{
int i, j;
}
static void
-Key_In_BindList_f (void)
+Key_In_BindList_f(cmd_state_t *cmd)
{
int m;
char *errchar = NULL;
- if(Cmd_Argc() >= 2)
+ if(Cmd_Argc(cmd) >= 2)
{
- m = strtol(Cmd_Argv(1), &errchar, 0);
+ m = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
- Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
+ Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
return;
}
Key_PrintBindList(m);
}
static void
-Key_BindList_f (void)
+Key_BindList_f(cmd_state_t *cmd)
{
Key_PrintBindList(0);
}
static void
-Key_Bind_f (void)
+Key_Bind_f(cmd_state_t *cmd)
{
int i, c, b;
- char cmd[MAX_INPUTLINE];
+ char line[MAX_INPUTLINE];
- c = Cmd_Argc ();
+ c = Cmd_Argc (cmd);
if (c != 2 && c != 3) {
Con_Print("bind <key> [command] : attach a command to a key\n");
return;
}
- b = Key_StringToKeynum (Cmd_Argv (1));
+ b = Key_StringToKeynum (Cmd_Argv(cmd, 1));
if (b == -1 || b >= MAX_KEYS) {
- Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv (1));
+ Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 1));
return;
}
if (c == 2) {
if (keybindings[0][b])
- Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv (1), keybindings[0][b]);
+ Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv(cmd, 1), keybindings[0][b]);
else
- Con_Printf("\"%s\" is not bound\n", Cmd_Argv (1));
+ Con_Printf("\"%s\" is not bound\n", Cmd_Argv(cmd, 1));
return;
}
// copy the rest of the command line
- cmd[0] = 0; // start out with a null string
+ line[0] = 0; // start out with a null string
for (i = 2; i < c; i++) {
- strlcat (cmd, Cmd_Argv (i), sizeof (cmd));
+ strlcat (line, Cmd_Argv(cmd, i), sizeof (line));
if (i != (c - 1))
- strlcat (cmd, " ", sizeof (cmd));
+ strlcat (line, " ", sizeof (line));
}
- if(!Key_SetBinding (b, 0, cmd))
+ if(!Key_SetBinding (b, 0, line))
Con_Printf("Key_SetBinding failed for unknown reason\n");
}
//
// register our functions
//
- Cmd_AddCommand ("in_bind", Key_In_Bind_f, "binds a command to the specified key in the selected bindmap");
- Cmd_AddCommand ("in_unbind", Key_In_Unbind_f, "removes command on the specified key in the selected bindmap");
- Cmd_AddCommand ("in_bindlist", Key_In_BindList_f, "bindlist: displays bound keys for all bindmaps, or the given bindmap");
- Cmd_AddCommand ("in_bindmap", Key_In_Bindmap_f, "selects active foreground and background (used only if a key is not bound in the foreground) bindmaps for typing");
- Cmd_AddCommand ("in_releaseall", Key_ReleaseAll, "releases all currently pressed keys (debug command)");
+ Cmd_AddCommand(&cmd_client, "in_bind", Key_In_Bind_f, "binds a command to the specified key in the selected bindmap");
+ Cmd_AddCommand(&cmd_client, "in_unbind", Key_In_Unbind_f, "removes command on the specified key in the selected bindmap");
+ Cmd_AddCommand(&cmd_client, "in_bindlist", Key_In_BindList_f, "bindlist: displays bound keys for all bindmaps, or the given bindmap");
+ Cmd_AddCommand(&cmd_client, "in_bindmap", Key_In_Bindmap_f, "selects active foreground and background (used only if a key is not bound in the foreground) bindmaps for typing");
+ Cmd_AddCommand(&cmd_client, "in_releaseall", Key_ReleaseAll_f, "releases all currently pressed keys (debug command)");
- Cmd_AddCommand ("bind", Key_Bind_f, "binds a command to the specified key in bindmap 0");
- Cmd_AddCommand ("unbind", Key_Unbind_f, "removes a command on the specified key in bindmap 0");
- Cmd_AddCommand ("bindlist", Key_BindList_f, "bindlist: displays bound keys for bindmap 0 bindmaps");
- Cmd_AddCommand ("unbindall", Key_Unbindall_f, "removes all commands from all keys in all bindmaps (leaving only shift-escape and escape)");
+ Cmd_AddCommand(&cmd_client, "bind", Key_Bind_f, "binds a command to the specified key in bindmap 0");
+ Cmd_AddCommand(&cmd_client, "unbind", Key_Unbind_f, "removes a command on the specified key in bindmap 0");
+ Cmd_AddCommand(&cmd_client, "bindlist", Key_BindList_f, "bindlist: displays bound keys for bindmap 0 bindmaps");
+ Cmd_AddCommand(&cmd_client, "unbindall", Key_Unbindall_f, "removes all commands from all keys in all bindmaps (leaving only shift-escape and escape)");
- Cmd_AddCommand ("history", Key_History_f, "prints the history of executed commands (history X prints the last X entries, history -c clears the whole history)");
+ Cmd_AddCommand(&cmd_client, "history", Key_History_f, "prints the history of executed commands (history X prints the last X entries, history -c clears the whole history)");
Cvar_RegisterVariable (&con_closeontoggleconsole);
}
void
Key_Event (int key, int ascii, qboolean down)
{
+ cmd_state_t *cmd = &cmd_client;
const char *bind;
qboolean q;
keydest_t keydest = key_dest;
{
if(down)
{
- Con_ToggleConsole_f ();
+ Con_ToggleConsole_f(&cmd_client);
tbl_keydest[key] = key_void; // esc release should go nowhere (especially not to key_menu or key_game)
}
return;
#endif
}
else
- Con_ToggleConsole_f();
+ Con_ToggleConsole_f(&cmd_client);
}
break;
case key_message:
if (down)
- Key_Message (key, ascii); // that'll close the message input
+ Key_Message (cmd, key, ascii); // that'll close the message input
break;
case key_menu:
{
// button commands add keynum as a parm
if (bind[0] == '+')
- Cbuf_AddText (va(vabuf, sizeof(vabuf), "%s %i\n", bind, key));
+ Cbuf_AddText (cmd, va(vabuf, sizeof(vabuf), "%s %i\n", bind, key));
else
{
- Cbuf_AddText (bind);
- Cbuf_AddText ("\n");
+ Cbuf_AddText (cmd, bind);
+ Cbuf_AddText (cmd, "\n");
}
} else if(bind[0] == '+' && !down && keydown[key] == 0)
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "-%s %i\n", bind + 1, key));
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "-%s %i\n", bind + 1, key));
}
return;
}
// (special exemption for german keyboard layouts)
if (con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && (key_consoleactive & KEY_CONSOLEACTIVE_USER) && (con_closeontoggleconsole.integer >= ((ascii != STRING_COLOR_TAG) ? 2 : 3) || key_linepos == 1))
{
- Con_ToggleConsole_f ();
+ Con_ToggleConsole_f(&cmd_client);
return;
}
if (COM_CheckParm ("-noconsole"))
return; // only allow the key bind to turn off console
- Key_Console (key, ascii);
+ Key_Console (cmd, key, ascii);
return;
}
{
if (down && con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && ascii != STRING_COLOR_TAG)
{
- Cbuf_AddText("toggleconsole\n"); // Deferred to next frame so we're not sending the text event to the console.
+ Cbuf_AddText(cmd, "toggleconsole\n"); // Deferred to next frame so we're not sending the text event to the console.
tbl_keydest[key] = key_void; // key release should go nowhere (especially not to key_menu or key_game)
return;
}
{
case key_message:
if (down)
- Key_Message (key, ascii);
+ Key_Message (cmd, key, ascii);
break;
case key_menu:
case key_menu_grabbed:
{
// button commands add keynum as a parm
if (bind[0] == '+')
- Cbuf_AddText (va(vabuf, sizeof(vabuf), "%s %i\n", bind, key));
+ Cbuf_AddText (cmd, va(vabuf, sizeof(vabuf), "%s %i\n", bind, key));
else
{
- Cbuf_AddText (bind);
- Cbuf_AddText ("\n");
+ Cbuf_AddText (cmd, bind);
+ Cbuf_AddText (cmd, "\n");
}
} else if(bind[0] == '+' && !down && keydown[key] == 0)
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "-%s %i\n", bind + 1, key));
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "-%s %i\n", bind + 1, key));
}
break;
default:
// now all keys are guaranteed down (once the event queue is unblocked)
// and only future events count
}
+
+void Key_ReleaseAll_f(cmd_state_t *cmd)
+{
+ Key_ReleaseAll();
+}
\ No newline at end of file
void Key_Init_Cvars(void);
void Key_Event(int key, int ascii, qboolean down);
void Key_ReleaseAll (void);
+void Key_ReleaseAll_f(cmd_state_t *cmd);
void Key_EventQueue_Block(void);
void Key_EventQueue_Unblock(void);
if(numdownloads_fail == 0)
{
Con_DPrintf("cURL downloads occurred, executing %s\n", command_when_done);
- Cbuf_AddText("\n");
- Cbuf_AddText(command_when_done);
- Cbuf_AddText("\n");
+ Cbuf_AddText(&cmd_client, "\n");
+ Cbuf_AddText(&cmd_client, command_when_done);
+ Cbuf_AddText(&cmd_client, "\n");
}
else
{
Con_DPrintf("cURL downloads FAILED, executing %s\n", command_when_error);
- Cbuf_AddText("\n");
- Cbuf_AddText(command_when_error);
- Cbuf_AddText("\n");
+ Cbuf_AddText(&cmd_client, "\n");
+ Cbuf_AddText(&cmd_client, command_when_error);
+ Cbuf_AddText(&cmd_client, "\n");
}
Curl_Clear_forthismap();
}
====================
*/
// TODO rewrite using Curl_GetDownloadInfo?
-static void Curl_Info_f(void)
+static void Curl_Info_f(cmd_state_t *cmd)
{
downloadinfo *di;
char urlbuf[1024];
once the last download completes successfully, reconnect to the current server
====================
*/
-static void Curl_Curl_f(void)
+static void Curl_Curl_f(cmd_state_t *cmd)
{
double maxspeed = 0;
int i;
return;
}
- if(Cmd_Argc() < 2)
+ if(Cmd_Argc(cmd) < 2)
{
Con_Print("usage:\ncurl --info, curl --cancel [filename], curl url\n");
return;
}
- url = Cmd_Argv(Cmd_Argc() - 1);
- end = Cmd_Argc();
+ url = Cmd_Argv(cmd, Cmd_Argc(cmd) - 1);
+ end = Cmd_Argc(cmd);
for(i = 1; i != end; ++i)
{
- const char *a = Cmd_Argv(i);
+ const char *a = Cmd_Argv(cmd, i);
if(!strcmp(a, "--info"))
{
- Curl_Info_f();
+ Curl_Info_f(cmd);
return;
}
else if(!strcmp(a, "--cancel"))
{
for(i = i + 1; i != end - 1; ++i)
{
- if(!FS_FileExists(Cmd_Argv(i)))
+ if(!FS_FileExists(Cmd_Argv(cmd, i)))
goto needthefile; // why can't I have a "double break"?
}
// if we get here, we have all the files...
if(i < end - 1)
{
++i;
- name = Cmd_Argv(i);
+ name = Cmd_Argv(cmd, i);
}
}
else if(!strcmp(a, "--clear_autodownload"))
Z_Free(buffer);
}
-void Curl_CurlCat_f(void)
+void Curl_CurlCat_f(cmd_state_t *cmd)
{
unsigned char *buf;
- const char *url = Cmd_Argv(1);
+ const char *url = Cmd_Argv(cmd, 1);
buf = Z_Malloc(16384);
Curl_Begin_ToMemory(url, buf, 16384, curl_curlcat_callback, NULL);
}
Cvar_RegisterVariable (&sv_curl_maxspeed);
Cvar_RegisterVariable (&cl_curl_useragent);
Cvar_RegisterVariable (&cl_curl_useragent_append);
- Cmd_AddCommand ("curl", Curl_Curl_f, "download data from an URL and add to search path");
- //Cmd_AddCommand ("curlcat", Curl_CurlCat_f, "display data from an URL (debugging command)");
+ Cmd_AddCommand(&cmd_client, "curl", Curl_Curl_f, "download data from an URL and add to search path");
+ //Cmd_AddCommand(&cmd_client, "curlcat", Curl_CurlCat_f, "display data from an URL (debugging command)");
}
/*
enum m_state_e m_state;
char m_return_reason[128];
-void M_Menu_Main_f (void);
- void M_Menu_SinglePlayer_f (void);
- void M_Menu_Transfusion_Episode_f (void);
- void M_Menu_Transfusion_Skill_f (void);
- void M_Menu_Load_f (void);
- void M_Menu_Save_f (void);
- void M_Menu_MultiPlayer_f (void);
- void M_Menu_Setup_f (void);
- void M_Menu_Options_f (void);
- void M_Menu_Options_Effects_f (void);
- void M_Menu_Options_Graphics_f (void);
- void M_Menu_Options_ColorControl_f (void);
- void M_Menu_Keys_f (void);
- void M_Menu_Reset_f (void);
- void M_Menu_Video_f (void);
- void M_Menu_Help_f (void);
- void M_Menu_Credits_f (void);
- void M_Menu_Quit_f (void);
-void M_Menu_LanConfig_f (void);
-void M_Menu_GameOptions_f (void);
-void M_Menu_ServerList_f (void);
-void M_Menu_ModList_f (void);
+void M_Menu_Main_f(cmd_state_t *cmd);
+ void M_Menu_SinglePlayer_f(cmd_state_t *cmd);
+ void M_Menu_Transfusion_Episode_f(cmd_state_t *cmd);
+ void M_Menu_Transfusion_Skill_f(cmd_state_t *cmd);
+ void M_Menu_Load_f(cmd_state_t *cmd);
+ void M_Menu_Save_f(cmd_state_t *cmd);
+ void M_Menu_MultiPlayer_f(cmd_state_t *cmd);
+ void M_Menu_Setup_f(cmd_state_t *cmd);
+ void M_Menu_Options_f(cmd_state_t *cmd);
+ void M_Menu_Options_Effects_f(cmd_state_t *cmd);
+ void M_Menu_Options_Graphics_f(cmd_state_t *cmd);
+ void M_Menu_Options_ColorControl_f(cmd_state_t *cmd);
+ void M_Menu_Keys_f(cmd_state_t *cmd);
+ void M_Menu_Reset_f(cmd_state_t *cmd);
+ void M_Menu_Video_f(cmd_state_t *cmd);
+ void M_Menu_Help_f(cmd_state_t *cmd);
+ void M_Menu_Credits_f(cmd_state_t *cmd);
+ void M_Menu_Quit_f(cmd_state_t *cmd);
+void M_Menu_LanConfig_f(cmd_state_t *cmd);
+void M_Menu_GameOptions_f(cmd_state_t *cmd);
+void M_Menu_ServerList_f(cmd_state_t *cmd);
+void M_Menu_ModList_f(cmd_state_t *cmd);
static void M_Main_Draw (void);
static void M_SinglePlayer_Draw (void);
static void M_ModList_Draw (void);
-static void M_Main_Key (int key, int ascii);
- static void M_SinglePlayer_Key (int key, int ascii);
- static void M_Transfusion_Episode_Key (int key, int ascii);
- static void M_Transfusion_Skill_Key (int key, int ascii);
- static void M_Load_Key (int key, int ascii);
- static void M_Save_Key (int key, int ascii);
- static void M_MultiPlayer_Key (int key, int ascii);
- static void M_Setup_Key (int key, int ascii);
- static void M_Options_Key (int key, int ascii);
- static void M_Options_Effects_Key (int key, int ascii);
- static void M_Options_Graphics_Key (int key, int ascii);
- static void M_Options_ColorControl_Key (int key, int ascii);
- static void M_Keys_Key (int key, int ascii);
- static void M_Reset_Key (int key, int ascii);
- static void M_Video_Key (int key, int ascii);
- static void M_Help_Key (int key, int ascii);
- static void M_Credits_Key (int key, int ascii);
- static void M_Quit_Key (int key, int ascii);
-static void M_LanConfig_Key (int key, int ascii);
-static void M_GameOptions_Key (int key, int ascii);
-static void M_ServerList_Key (int key, int ascii);
-static void M_ModList_Key (int key, int ascii);
+static void M_Main_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_SinglePlayer_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Transfusion_Episode_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Transfusion_Skill_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Load_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Save_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_MultiPlayer_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Setup_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Options_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Options_Effects_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Options_Graphics_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Options_ColorControl_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Keys_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Reset_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Video_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Help_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Credits_Key(cmd_state_t *cmd, int key, int ascii);
+ static void M_Quit_Key(cmd_state_t *cmd, int key, int ascii);
+static void M_LanConfig_Key(cmd_state_t *cmd, int key, int ascii);
+static void M_GameOptions_Key(cmd_state_t *cmd, int key, int ascii);
+static void M_ServerList_Key(cmd_state_t *cmd, int key, int ascii);
+static void M_ModList_Key(cmd_state_t *cmd, int key, int ascii);
static qboolean m_entersound; ///< play after drawing a frame, so caching won't disrupt the sound
{
if(mode == 0)
return; // the menu is off, and we want it off
- M_Menu_Main_f ();
+ M_Menu_Main_f (&cmd_client);
}
else
{
}
-static void M_Menu_Demos_f (void)
+static void M_Menu_Demos_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_demo;
}
-static void M_Demo_Key (int k, int ascii)
+static void M_Demo_Key (cmd_state_t *cmd, int k, int ascii)
{
char vabuf[1024];
switch (k)
{
case K_ESCAPE:
- M_Menu_Main_f ();
+ M_Menu_Main_f (cmd);
break;
case K_ENTER:
S_LocalSound ("sound/misc/menu2.wav");
m_state = m_none;
key_dest = key_game;
- Cbuf_AddText (va(vabuf, sizeof(vabuf), "playdemo %s\n", NehahraDemos[demo_cursor].name));
+ Cbuf_AddText (cmd, va(vabuf, sizeof(vabuf), "playdemo %s\n", NehahraDemos[demo_cursor].name));
return;
case K_UPARROW:
static int MAIN_ITEMS = 4; // Nehahra: Menu Disable
-void M_Menu_Main_f (void)
+void M_Menu_Main_f(cmd_state_t *cmd)
{
const char *s;
s = "gfx/mainmenu";
}
-static void M_Main_Key (int key, int ascii)
+static void M_Main_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
m_state = m_none;
key_dest = key_game;
}
- Con_ToggleConsole_f ();
+ Con_ToggleConsole_f(cmd);
break;
case 1:
- M_Menu_Quit_f ();
+ M_Menu_Quit_f(cmd);
break;
}
}
switch (m_main_cursor)
{
case 0:
- M_Menu_SinglePlayer_f ();
+ M_Menu_SinglePlayer_f(cmd);
break;
case 1:
- M_Menu_Demos_f ();
+ M_Menu_Demos_f(cmd);
break;
case 2:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case 3:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case 4:
key_dest = key_game;
if (sv.active)
- Cbuf_AddText ("disconnect\n");
- Cbuf_AddText ("playdemo endcred\n");
+ Cbuf_AddText (cmd, "disconnect\n");
+ Cbuf_AddText (cmd, "playdemo endcred\n");
break;
case 5:
- M_Menu_Quit_f ();
+ M_Menu_Quit_f(cmd);
break;
}
break;
switch (m_main_cursor)
{
case 0:
- M_Menu_SinglePlayer_f ();
+ M_Menu_SinglePlayer_f(cmd);
break;
case 1:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case 2:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case 3:
key_dest = key_game;
if (sv.active)
- Cbuf_AddText ("disconnect\n");
- Cbuf_AddText ("playdemo endcred\n");
+ Cbuf_AddText (cmd, "disconnect\n");
+ Cbuf_AddText (cmd, "playdemo endcred\n");
break;
case 4:
- M_Menu_Quit_f ();
+ M_Menu_Quit_f(cmd);
break;
}
break;
switch (m_main_cursor)
{
case 0:
- M_Menu_Demos_f ();
+ M_Menu_Demos_f(cmd);
break;
case 1:
key_dest = key_game;
if (sv.active)
- Cbuf_AddText ("disconnect\n");
- Cbuf_AddText ("playdemo endcred\n");
+ Cbuf_AddText (cmd, "disconnect\n");
+ Cbuf_AddText (cmd, "playdemo endcred\n");
break;
case 2:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case 3:
- M_Menu_Quit_f ();
+ M_Menu_Quit_f(cmd);
break;
}
break;
switch (m_main_cursor)
{
case 0:
- M_Menu_Transfusion_Episode_f ();
+ M_Menu_Transfusion_Episode_f(cmd);
break;
case 1:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case 2:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case 3:
- M_Menu_Load_f ();
+ M_Menu_Load_f(cmd);
break;
case 4:
- M_Menu_Help_f ();
+ M_Menu_Help_f(cmd);
break;
case 5:
- M_Menu_Credits_f ();
+ M_Menu_Credits_f(cmd);
break;
case 6:
- M_Menu_Quit_f ();
+ M_Menu_Quit_f(cmd);
break;
}
}
switch (m_main_cursor)
{
case 0:
- M_Menu_Transfusion_Episode_f ();
+ M_Menu_Transfusion_Episode_f(cmd);
break;
case 1:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case 2:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case 3:
- M_Menu_Save_f ();
+ M_Menu_Save_f(cmd);
break;
case 4:
- M_Menu_Load_f ();
+ M_Menu_Load_f(cmd);
break;
case 5:
- M_Menu_Help_f ();
+ M_Menu_Help_f(cmd);
break;
case 6:
- M_Menu_Credits_f ();
+ M_Menu_Credits_f(cmd);
break;
case 7:
- M_Menu_Quit_f ();
+ M_Menu_Quit_f(cmd);
break;
}
}
switch (m_main_cursor)
{
case 0:
- M_Menu_SinglePlayer_f ();
+ M_Menu_SinglePlayer_f(cmd);
break;
case 1:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case 2:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case 3:
- M_Menu_Help_f ();
+ M_Menu_Help_f(cmd);
break;
case 4:
- M_Menu_Quit_f ();
+ M_Menu_Quit_f(cmd);
break;
}
}
#define SINGLEPLAYER_ITEMS 3
-void M_Menu_SinglePlayer_f (void)
+void M_Menu_SinglePlayer_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_singleplayer;
}
-static void M_SinglePlayer_Key (int key, int ascii)
+static void M_SinglePlayer_Key(cmd_state_t *cmd, int key, int ascii)
{
if (gamemode == GAME_GOODVSBAD2 || gamemode == GAME_BATTLEMECH)
{
switch (key)
{
case K_ESCAPE:
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
break;
case K_DOWNARROW:
case 0:
key_dest = key_game;
if (sv.active)
- Cbuf_AddText ("disconnect\n");
- Cbuf_AddText ("maxplayers 1\n");
- Cbuf_AddText ("deathmatch 0\n");
- Cbuf_AddText ("coop 0\n");
+ Cbuf_AddText(cmd, "disconnect\n");
+ Cbuf_AddText(cmd, "maxplayers 1\n");
+ Cbuf_AddText(cmd, "deathmatch 0\n");
+ Cbuf_AddText(cmd, "coop 0\n");
if (gamemode == GAME_TRANSFUSION)
{
key_dest = key_menu;
- M_Menu_Transfusion_Episode_f ();
+ M_Menu_Transfusion_Episode_f(cmd);
break;
}
- Cbuf_AddText ("startmap_sp\n");
+ Cbuf_AddText(cmd, "startmap_sp\n");
break;
case 1:
- M_Menu_Load_f ();
+ M_Menu_Load_f(cmd);
break;
case 2:
- M_Menu_Save_f ();
+ M_Menu_Save_f(cmd);
break;
}
}
}
}
-void M_Menu_Load_f (void)
+void M_Menu_Load_f(cmd_state_t *cmd)
{
m_entersound = true;
m_state = m_load;
}
-void M_Menu_Save_f (void)
+void M_Menu_Save_f(cmd_state_t *cmd)
{
if (!sv.active)
return;
}
-static void M_Load_Key (int k, int ascii)
+static void M_Load_Key(cmd_state_t *cmd, int k, int ascii)
{
char vabuf[1024];
switch (k)
{
case K_ESCAPE:
if (gamemode == GAME_TRANSFUSION)
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
else
- M_Menu_SinglePlayer_f ();
+ M_Menu_SinglePlayer_f(cmd);
break;
case K_ENTER:
key_dest = key_game;
// issue the load command
- Cbuf_AddText (va(vabuf, sizeof(vabuf), "load s%i\n", load_cursor) );
+ Cbuf_AddText (cmd, va(vabuf, sizeof(vabuf), "load s%i\n", load_cursor) );
return;
case K_UPARROW:
}
-static void M_Save_Key (int k, int ascii)
+static void M_Save_Key(cmd_state_t *cmd, int k, int ascii)
{
char vabuf[1024];
switch (k)
{
case K_ESCAPE:
if (gamemode == GAME_TRANSFUSION)
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
else
- M_Menu_SinglePlayer_f ();
+ M_Menu_SinglePlayer_f(cmd);
break;
case K_ENTER:
m_state = m_none;
key_dest = key_game;
- Cbuf_AddText (va(vabuf, sizeof(vabuf), "save s%i\n", load_cursor));
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "save s%i\n", load_cursor));
return;
case K_UPARROW:
static int m_episode_cursor;
#define EPISODE_ITEMS 6
-void M_Menu_Transfusion_Episode_f (void)
+void M_Menu_Transfusion_Episode_f(cmd_state_t *cmd)
{
m_entersound = true;
m_state = m_transfusion_episode;
M_DrawPic (0, 120 + (m_episode_cursor + 1) * 40, va(vabuf, sizeof(vabuf), "gfx/menu/episode%iselected", m_episode_cursor + 1));
}
-static void M_Transfusion_Episode_Key (int key, int ascii)
+static void M_Transfusion_Episode_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
case K_ESCAPE:
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
break;
case K_DOWNARROW:
break;
case K_ENTER:
- Cbuf_AddText ("deathmatch 0\n");
+ Cbuf_AddText(cmd, "deathmatch 0\n");
m_entersound = true;
- M_Menu_Transfusion_Skill_f ();
+ M_Menu_Transfusion_Skill_f(cmd);
}
}
static int m_skill_cursor = 2;
#define SKILL_ITEMS 5
-void M_Menu_Transfusion_Skill_f (void)
+void M_Menu_Transfusion_Skill_f(cmd_state_t *cmd)
{
m_entersound = true;
m_state = m_transfusion_skill;
M_DrawPic (0, 140 + (m_skill_cursor + 1) *40, va(vabuf, sizeof(vabuf), "gfx/menu/difficulty%iselected", m_skill_cursor + 1));
}
-static void M_Transfusion_Skill_Key (int key, int ascii)
+static void M_Transfusion_Skill_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
case K_ESCAPE:
- M_Menu_Transfusion_Episode_f ();
+ M_Menu_Transfusion_Episode_f(cmd);
break;
case K_DOWNARROW:
switch (m_skill_cursor)
{
case 0:
- Cbuf_AddText ("skill 1\n");
+ Cbuf_AddText(cmd, "skill 1\n");
break;
case 1:
- Cbuf_AddText ("skill 2\n");
+ Cbuf_AddText(cmd, "skill 2\n");
break;
case 2:
- Cbuf_AddText ("skill 3\n");
+ Cbuf_AddText(cmd, "skill 3\n");
break;
case 3:
- Cbuf_AddText ("skill 4\n");
+ Cbuf_AddText(cmd, "skill 4\n");
break;
case 4:
- Cbuf_AddText ("skill 5\n");
+ Cbuf_AddText(cmd, "skill 5\n");
break;
}
key_dest = key_game;
if (sv.active)
- Cbuf_AddText ("disconnect\n");
- Cbuf_AddText ("maxplayers 1\n");
- Cbuf_AddText ("deathmatch 0\n");
- Cbuf_AddText ("coop 0\n");
+ Cbuf_AddText(cmd, "disconnect\n");
+ Cbuf_AddText(cmd, "maxplayers 1\n");
+ Cbuf_AddText(cmd, "deathmatch 0\n");
+ Cbuf_AddText(cmd, "coop 0\n");
switch (m_episode_cursor)
{
case 0:
- Cbuf_AddText ("map e1m1\n");
+ Cbuf_AddText(cmd, "map e1m1\n");
break;
case 1:
- Cbuf_AddText ("map e2m1\n");
+ Cbuf_AddText(cmd, "map e2m1\n");
break;
case 2:
- Cbuf_AddText ("map e3m1\n");
+ Cbuf_AddText(cmd, "map e3m1\n");
break;
case 3:
- Cbuf_AddText ("map e4m1\n");
+ Cbuf_AddText(cmd, "map e4m1\n");
break;
case 4:
- Cbuf_AddText ("map e6m1\n");
+ Cbuf_AddText(cmd, "map e6m1\n");
break;
case 5:
- Cbuf_AddText ("map cp01\n");
+ Cbuf_AddText(cmd, "map cp01\n");
break;
}
}
#define MULTIPLAYER_ITEMS 3
-void M_Menu_MultiPlayer_f (void)
+void M_Menu_MultiPlayer_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_multiplayer;
}
-static void M_MultiPlayer_Key (int key, int ascii)
+static void M_MultiPlayer_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
case K_ESCAPE:
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
break;
case K_DOWNARROW:
{
case 0:
case 1:
- M_Menu_LanConfig_f ();
+ M_Menu_LanConfig_f(cmd);
break;
case 2:
- M_Menu_Setup_f ();
+ M_Menu_Setup_f(cmd);
break;
}
}
#define NUM_SETUP_CMDS 5
-void M_Menu_Setup_f (void)
+void M_Menu_Setup_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_setup;
}
-static void M_Setup_Key (int k, int ascii)
+static void M_Setup_Key(cmd_state_t *cmd, int k, int ascii)
{
int l;
char vabuf[1024];
switch (k)
{
case K_ESCAPE:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case K_UPARROW:
// setup_cursor == 4 (Accept changes)
if (strcmp(cl_name.string, setup_myname) != 0)
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "name \"%s\"\n", setup_myname) );
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "name \"%s\"\n", setup_myname) );
if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "color %i %i\n", setup_top, setup_bottom) );
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "color %i %i\n", setup_top, setup_bottom) );
if (setup_rate != setup_oldrate)
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "rate %i\n", setup_rate));
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "rate %i\n", setup_rate));
m_entersound = true;
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case K_BACKSPACE:
static int options_cursor;
-void M_Menu_Options_f (void)
+void M_Menu_Options_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_options;
}
-static void M_Options_Key (int k, int ascii)
+static void M_Options_Key(cmd_state_t *cmd, int k, int ascii)
{
switch (k)
{
case K_ESCAPE:
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
break;
case K_ENTER:
switch (options_cursor)
{
case 0:
- M_Menu_Keys_f ();
+ M_Menu_Keys_f(cmd);
break;
case 1:
m_state = m_none;
key_dest = key_game;
- Con_ToggleConsole_f ();
+ Con_ToggleConsole_f(cmd);
break;
case 2:
- M_Menu_Reset_f ();
+ M_Menu_Reset_f(cmd);
break;
case 3:
- M_Menu_Video_f ();
+ M_Menu_Video_f(cmd);
break;
case 11:
- M_Menu_Options_ColorControl_f ();
+ M_Menu_Options_ColorControl_f(cmd);
break;
case 17: // Customize Effects
- M_Menu_Options_Effects_f ();
+ M_Menu_Options_Effects_f(cmd);
break;
case 18: // Effects: Quake
- Cbuf_AddText("cl_particles 1;cl_particles_quake 1;cl_particles_quality 1;cl_particles_explosions_shell 0;r_explosionclip 1;cl_stainmaps 0;cl_stainmaps_clearonload 1;cl_decals 0;cl_particles_bulletimpacts 1;cl_particles_smoke 1;cl_particles_sparks 1;cl_particles_bubbles 1;cl_particles_blood 1;cl_particles_blood_alpha 1;cl_particles_blood_bloodhack 0;cl_beams_polygons 0;cl_beams_instantaimhack 0;cl_beams_quakepositionhack 1;cl_beams_lightatend 0;r_lerpmodels 1;r_lerpsprites 1;r_lerplightstyles 0;gl_polyblend 1;r_skyscroll1 1;r_skyscroll2 2;r_waterwarp 1;r_wateralpha 1;r_waterscroll 1\n");
+ Cbuf_AddText(cmd, "cl_particles 1;cl_particles_quake 1;cl_particles_quality 1;cl_particles_explosions_shell 0;r_explosionclip 1;cl_stainmaps 0;cl_stainmaps_clearonload 1;cl_decals 0;cl_particles_bulletimpacts 1;cl_particles_smoke 1;cl_particles_sparks 1;cl_particles_bubbles 1;cl_particles_blood 1;cl_particles_blood_alpha 1;cl_particles_blood_bloodhack 0;cl_beams_polygons 0;cl_beams_instantaimhack 0;cl_beams_quakepositionhack 1;cl_beams_lightatend 0;r_lerpmodels 1;r_lerpsprites 1;r_lerplightstyles 0;gl_polyblend 1;r_skyscroll1 1;r_skyscroll2 2;r_waterwarp 1;r_wateralpha 1;r_waterscroll 1\n");
break;
case 19: // Effects: Normal
- Cbuf_AddText("cl_particles 1;cl_particles_quake 0;cl_particles_quality 1;cl_particles_explosions_shell 0;r_explosionclip 1;cl_stainmaps 0;cl_stainmaps_clearonload 1;cl_decals 1;cl_particles_bulletimpacts 1;cl_particles_smoke 1;cl_particles_sparks 1;cl_particles_bubbles 1;cl_particles_blood 1;cl_particles_blood_alpha 1;cl_particles_blood_bloodhack 1;cl_beams_polygons 1;cl_beams_instantaimhack 0;cl_beams_quakepositionhack 1;cl_beams_lightatend 0;r_lerpmodels 1;r_lerpsprites 1;r_lerplightstyles 0;gl_polyblend 1;r_skyscroll1 1;r_skyscroll2 2;r_waterwarp 1;r_wateralpha 1;r_waterscroll 1\n");
+ Cbuf_AddText(cmd, "cl_particles 1;cl_particles_quake 0;cl_particles_quality 1;cl_particles_explosions_shell 0;r_explosionclip 1;cl_stainmaps 0;cl_stainmaps_clearonload 1;cl_decals 1;cl_particles_bulletimpacts 1;cl_particles_smoke 1;cl_particles_sparks 1;cl_particles_bubbles 1;cl_particles_blood 1;cl_particles_blood_alpha 1;cl_particles_blood_bloodhack 1;cl_beams_polygons 1;cl_beams_instantaimhack 0;cl_beams_quakepositionhack 1;cl_beams_lightatend 0;r_lerpmodels 1;r_lerpsprites 1;r_lerplightstyles 0;gl_polyblend 1;r_skyscroll1 1;r_skyscroll2 2;r_waterwarp 1;r_wateralpha 1;r_waterscroll 1\n");
break;
case 20: // Effects: High
- Cbuf_AddText("cl_particles 1;cl_particles_quake 0;cl_particles_quality 2;cl_particles_explosions_shell 0;r_explosionclip 1;cl_stainmaps 1;cl_stainmaps_clearonload 1;cl_decals 1;cl_particles_bulletimpacts 1;cl_particles_smoke 1;cl_particles_sparks 1;cl_particles_bubbles 1;cl_particles_blood 1;cl_particles_blood_alpha 1;cl_particles_blood_bloodhack 1;cl_beams_polygons 1;cl_beams_instantaimhack 0;cl_beams_quakepositionhack 1;cl_beams_lightatend 0;r_lerpmodels 1;r_lerpsprites 1;r_lerplightstyles 0;gl_polyblend 1;r_skyscroll1 1;r_skyscroll2 2;r_waterwarp 1;r_wateralpha 1;r_waterscroll 1\n");
+ Cbuf_AddText(cmd, "cl_particles 1;cl_particles_quake 0;cl_particles_quality 2;cl_particles_explosions_shell 0;r_explosionclip 1;cl_stainmaps 1;cl_stainmaps_clearonload 1;cl_decals 1;cl_particles_bulletimpacts 1;cl_particles_smoke 1;cl_particles_sparks 1;cl_particles_bubbles 1;cl_particles_blood 1;cl_particles_blood_alpha 1;cl_particles_blood_bloodhack 1;cl_beams_polygons 1;cl_beams_instantaimhack 0;cl_beams_quakepositionhack 1;cl_beams_lightatend 0;r_lerpmodels 1;r_lerpsprites 1;r_lerplightstyles 0;gl_polyblend 1;r_skyscroll1 1;r_skyscroll2 2;r_waterwarp 1;r_wateralpha 1;r_waterscroll 1\n");
break;
case 21:
- M_Menu_Options_Graphics_f ();
+ M_Menu_Options_Graphics_f(cmd);
break;
case 22: // Lighting: Flares
- Cbuf_AddText("r_coronas 1;gl_flashblend 1;r_shadow_gloss 0;r_shadow_realtime_dlight 0;r_shadow_realtime_dlight_shadows 0;r_shadow_realtime_world 0;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 0");
+ Cbuf_AddText(cmd, "r_coronas 1;gl_flashblend 1;r_shadow_gloss 0;r_shadow_realtime_dlight 0;r_shadow_realtime_dlight_shadows 0;r_shadow_realtime_world 0;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 0");
break;
case 23: // Lighting: Normal
- Cbuf_AddText("r_coronas 1;gl_flashblend 0;r_shadow_gloss 1;r_shadow_realtime_dlight 1;r_shadow_realtime_dlight_shadows 0;r_shadow_realtime_world 0;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 0");
+ Cbuf_AddText(cmd, "r_coronas 1;gl_flashblend 0;r_shadow_gloss 1;r_shadow_realtime_dlight 1;r_shadow_realtime_dlight_shadows 0;r_shadow_realtime_world 0;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 0");
break;
case 24: // Lighting: High
- Cbuf_AddText("r_coronas 1;gl_flashblend 0;r_shadow_gloss 1;r_shadow_realtime_dlight 1;r_shadow_realtime_dlight_shadows 1;r_shadow_realtime_world 0;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 1");
+ Cbuf_AddText(cmd, "r_coronas 1;gl_flashblend 0;r_shadow_gloss 1;r_shadow_realtime_dlight 1;r_shadow_realtime_dlight_shadows 1;r_shadow_realtime_world 0;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 1");
break;
case 25: // Lighting: Full
- Cbuf_AddText("r_coronas 1;gl_flashblend 0;r_shadow_gloss 1;r_shadow_realtime_dlight 1;r_shadow_realtime_dlight_shadows 1;r_shadow_realtime_world 1;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 1");
+ Cbuf_AddText(cmd, "r_coronas 1;gl_flashblend 0;r_shadow_gloss 1;r_shadow_realtime_dlight 1;r_shadow_realtime_dlight_shadows 1;r_shadow_realtime_world 1;r_shadow_realtime_world_lightmaps 0;r_shadow_realtime_world_shadows 1;r_bloom 1");
break;
case 26:
- M_Menu_ModList_f ();
+ M_Menu_ModList_f(cmd);
break;
default:
M_Menu_Options_AdjustSliders (1);
static int options_effects_cursor;
-void M_Menu_Options_Effects_f (void)
+void M_Menu_Options_Effects_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_options_effects;
}
-static void M_Options_Effects_Key (int k, int ascii)
+static void M_Options_Effects_Key(cmd_state_t *cmd, int k, int ascii)
{
switch (k)
{
case K_ESCAPE:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case K_ENTER:
static int options_graphics_cursor;
-void M_Menu_Options_Graphics_f (void)
+void M_Menu_Options_Graphics_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_options_graphics;
extern cvar_t r_hdr_glowintensity;
extern cvar_t gl_picmip;
-static void M_Menu_Options_Graphics_AdjustSliders (int dir)
+static void M_Menu_Options_Graphics_AdjustSliders (cmd_state_t *cmd, int dir)
{
int optnum;
S_LocalSound ("sound/misc/menu3.wav");
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_brighten, bound(1, r_bloom_brighten.value + dir * 0.0625, 4));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_blur, bound(1, r_bloom_blur.value + dir * 1, 16));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_resolution, bound(64, r_bloom_resolution.value + dir * 64, 2048));
- else if (options_graphics_cursor == optnum++) Cbuf_AddText ("r_restart\n");
+ else if (options_graphics_cursor == optnum++) Cbuf_AddText(cmd, "r_restart\n");
}
}
-static void M_Options_Graphics_Key (int k, int ascii)
+static void M_Options_Graphics_Key (cmd_state_t *cmd, int k, int ascii)
{
switch (k)
{
case K_ESCAPE:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case K_ENTER:
- M_Menu_Options_Graphics_AdjustSliders (1);
+ M_Menu_Options_Graphics_AdjustSliders (cmd, 1);
break;
case K_UPARROW:
break;
case K_LEFTARROW:
- M_Menu_Options_Graphics_AdjustSliders (-1);
+ M_Menu_Options_Graphics_AdjustSliders(cmd, -1);
break;
case K_RIGHTARROW:
- M_Menu_Options_Graphics_AdjustSliders (1);
+ M_Menu_Options_Graphics_AdjustSliders(cmd, 1);
break;
}
}
// intensity value to match up to 50% dither to 'correct' quake
static cvar_t menu_options_colorcontrol_correctionvalue = {0, "menu_options_colorcontrol_correctionvalue", "0.5", "intensity value that matches up to white/black dither pattern, should be 0.5 for linear color"};
-void M_Menu_Options_ColorControl_f (void)
+void M_Menu_Options_ColorControl_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_options_colorcontrol;
}
-static void M_Options_ColorControl_Key (int k, int ascii)
+static void M_Options_ColorControl_Key(cmd_state_t *cmd, int k, int ascii)
{
switch (k)
{
case K_ESCAPE:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case K_ENTER:
static int keys_cursor;
static int bind_grab;
-void M_Menu_Keys_f (void)
+void M_Menu_Keys_f(cmd_state_t *cmd)
{
key_dest = key_menu_grabbed;
m_state = m_keys;
}
-static void M_Keys_Key (int k, int ascii)
+static void M_Keys_Key(cmd_state_t *cmd, int k, int ascii)
{
- char cmd[80];
+ char line[80];
int keys[NUMKEYS];
char tinystr[2];
}
else //if (k != '`')
{
- dpsnprintf (cmd, sizeof(cmd), "bind \"%s\" \"%s\"\n", Key_KeynumToString (k, tinystr, sizeof(tinystr)), bindnames[keys_cursor][0]);
- Cbuf_InsertText (cmd);
+ dpsnprintf(line, sizeof(line), "bind \"%s\" \"%s\"\n", Key_KeynumToString(k, tinystr, sizeof(tinystr)), bindnames[keys_cursor][0]);
+ Cbuf_InsertText (cmd, line);
}
bind_grab = false;
switch (k)
{
case K_ESCAPE:
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case K_LEFTARROW:
}
}
-void M_Menu_Reset_f (void)
+void M_Menu_Reset_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_reset;
}
-static void M_Reset_Key (int key, int ascii)
+static void M_Reset_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
case 'Y':
case 'y':
- Cbuf_AddText ("cvar_resettodefaults_all;exec default.cfg\n");
+ Cbuf_AddText(cmd, "cvar_resettodefaults_all;exec default.cfg\n");
// no break here since we also exit the menu
case K_ESCAPE:
}
}
-void M_Menu_Video_f (void)
+void M_Menu_Video_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_video;
}
-static void M_Video_Key (int key, int ascii)
+static void M_Video_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
Cvar_SetValueQuick(&vid_userefreshrate, vid.userefreshrate);
S_LocalSound ("sound/misc/menu1.wav");
- M_Menu_Options_f ();
+ M_Menu_Options_f(cmd);
break;
case K_ENTER:
Cvar_SetValueQuick (&vid_conwidth, menu_video_resolutions[menu_video_resolution].conwidth);
Cvar_SetValueQuick (&vid_conheight, menu_video_resolutions[menu_video_resolution].conheight);
Cvar_SetValueQuick (&vid_pixelheight, menu_video_resolutions[menu_video_resolution].pixelheight);
- Cbuf_AddText ("vid_restart\n");
- M_Menu_Options_f ();
+ Cbuf_AddText(cmd, "vid_restart\n");
+ M_Menu_Options_f(cmd);
break;
default:
M_Menu_Video_AdjustSliders (1);
#define NUM_HELP_PAGES 6
-void M_Menu_Help_f (void)
+void M_Menu_Help_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_help;
}
-static void M_Help_Key (int key, int ascii)
+static void M_Help_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
case K_ESCAPE:
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
break;
case K_UPARROW:
//=============================================================================
/* CEDITS MENU */
-void M_Menu_Credits_f (void)
+void M_Menu_Credits_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_credits;
}
-static void M_Credits_Key (int key, int ascii)
+static void M_Credits_Key(cmd_state_t *cmd, int key, int ascii)
{
- M_Menu_Main_f ();
+ M_Menu_Main_f(cmd);
}
//=============================================================================
return 0;
}
-void M_Menu_Quit_f (void)
+void M_Menu_Quit_f(cmd_state_t *cmd)
{
int n;
if (m_state == m_quit)
}
-static void M_Quit_Key (int key, int ascii)
+static void M_Quit_Key(cmd_state_t *cmd, int key, int ascii)
{
switch (key)
{
case 'Y':
case 'y':
- Host_Quit_f ();
+ Host_Quit_f(cmd);
break;
default:
static char lanConfig_portname[6];
static char lanConfig_joinname[40];
-void M_Menu_LanConfig_f (void)
+void M_Menu_LanConfig_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_lanconfig;
}
-static void M_LanConfig_Key (int key, int ascii)
+static void M_LanConfig_Key(cmd_state_t *cmd, int key, int ascii)
{
int l;
char vabuf[1024];
switch (key)
{
case K_ESCAPE:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case K_UPARROW:
m_entersound = true;
- Cbuf_AddText ("stopdemo\n");
+ Cbuf_AddText(cmd, "stopdemo\n");
Cvar_SetValue("port", lanConfig_port);
{
if (StartingGame)
{
- M_Menu_GameOptions_f ();
+ M_Menu_GameOptions_f(cmd);
break;
}
- M_Menu_ServerList_f();
+ M_Menu_ServerList_f(cmd);
break;
}
if (lanConfig_cursor == 3)
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "connect \"%s\"\n", lanConfig_joinname) );
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "connect \"%s\"\n", lanConfig_joinname) );
break;
case K_BACKSPACE:
static qboolean m_serverInfoMessage = false;
static double m_serverInfoMessageTime;
-void M_Menu_GameOptions_f (void)
+void M_Menu_GameOptions_f(cmd_state_t *cmd)
{
int i;
key_dest = key_menu;
}
}
-static void M_GameOptions_Key (int key, int ascii)
+static void M_GameOptions_Key(cmd_state_t *cmd, int key, int ascii)
{
int l;
char hostnamebuf[128];
switch (key)
{
case K_ESCAPE:
- M_Menu_MultiPlayer_f ();
+ M_Menu_MultiPlayer_f(cmd);
break;
case K_UPARROW:
if (gameoptions_cursor == 0)
{
if (sv.active)
- Cbuf_AddText("disconnect\n");
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "maxplayers %u\n", maxplayers) );
+ Cbuf_AddText(cmd, "disconnect\n");
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "maxplayers %u\n", maxplayers) );
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "map %s\n", gameoptions_levels->levels[gameoptions_levels->episodes[startepisode].firstLevel + startlevel].name) );
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "map %s\n", gameoptions_levels->levels[gameoptions_levels->episodes[startepisode].firstLevel + startlevel].name) );
return;
}
static int slist_cursor;
-void M_Menu_ServerList_f (void)
+void M_Menu_ServerList_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_slist;
slist_cursor = 0;
M_Update_Return_Reason("");
if (lanConfig_cursor == 2)
- Net_SlistQW_f();
+ Net_SlistQW_f(cmd);
else
- Net_Slist_f();
+ Net_Slist_f(cmd);
}
}
-static void M_ServerList_Key(int k, int ascii)
+static void M_ServerList_Key(cmd_state_t *cmd, int k, int ascii)
{
char vabuf[1024];
switch (k)
{
case K_ESCAPE:
- M_Menu_LanConfig_f();
+ M_Menu_LanConfig_f(cmd);
break;
case K_SPACE:
if (lanConfig_cursor == 2)
- Net_SlistQW_f();
+ Net_SlistQW_f(cmd);
else
- Net_Slist_f();
+ Net_Slist_f(cmd);
break;
case K_UPARROW:
case K_ENTER:
S_LocalSound ("sound/misc/menu2.wav");
if (serverlist_viewcount)
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "connect \"%s\"\n", ServerList_GetViewEntry(slist_cursor)->info.cname));
+ Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "connect \"%s\"\n", ServerList_GetViewEntry(slist_cursor)->info.cname));
break;
default:
FS_ChangeGameDirs (modlist_numenabled, gamedirs, true, true);
}
-void M_Menu_ModList_f (void)
+void M_Menu_ModList_f(cmd_state_t *cmd)
{
key_dest = key_menu;
m_state = m_modlist;
}
}
-static void M_ModList_Key(int k, int ascii)
+static void M_ModList_Key(cmd_state_t *cmd, int k, int ascii)
{
switch (k)
{
case K_ESCAPE:
ModList_Enable ();
- M_Menu_Options_f();
+ M_Menu_Options_f(cmd);
break;
case K_SPACE:
menuplyr_load = true;
menuplyr_pixels = NULL;
- Cmd_AddCommand ("menu_main", M_Menu_Main_f, "open the main menu");
- Cmd_AddCommand ("menu_singleplayer", M_Menu_SinglePlayer_f, "open the singleplayer menu");
- Cmd_AddCommand ("menu_load", M_Menu_Load_f, "open the loadgame menu");
- Cmd_AddCommand ("menu_save", M_Menu_Save_f, "open the savegame menu");
- Cmd_AddCommand ("menu_multiplayer", M_Menu_MultiPlayer_f, "open the multiplayer menu");
- Cmd_AddCommand ("menu_setup", M_Menu_Setup_f, "open the player setup menu");
- Cmd_AddCommand ("menu_options", M_Menu_Options_f, "open the options menu");
- Cmd_AddCommand ("menu_options_effects", M_Menu_Options_Effects_f, "open the effects options menu");
- Cmd_AddCommand ("menu_options_graphics", M_Menu_Options_Graphics_f, "open the graphics options menu");
- Cmd_AddCommand ("menu_options_colorcontrol", M_Menu_Options_ColorControl_f, "open the color control menu");
- Cmd_AddCommand ("menu_keys", M_Menu_Keys_f, "open the key binding menu");
- Cmd_AddCommand ("menu_video", M_Menu_Video_f, "open the video options menu");
- Cmd_AddCommand ("menu_reset", M_Menu_Reset_f, "open the reset to defaults menu");
- Cmd_AddCommand ("menu_mods", M_Menu_ModList_f, "open the mods browser menu");
- Cmd_AddCommand ("help", M_Menu_Help_f, "open the help menu");
- Cmd_AddCommand ("menu_quit", M_Menu_Quit_f, "open the quit menu");
- Cmd_AddCommand ("menu_transfusion_episode", M_Menu_Transfusion_Episode_f, "open the transfusion episode select menu");
- Cmd_AddCommand ("menu_transfusion_skill", M_Menu_Transfusion_Skill_f, "open the transfusion skill select menu");
- Cmd_AddCommand ("menu_credits", M_Menu_Credits_f, "open the credits menu");
+ Cmd_AddCommand(&cmd_client, "menu_main", M_Menu_Main_f, "open the main menu");
+ Cmd_AddCommand(&cmd_client, "menu_singleplayer", M_Menu_SinglePlayer_f, "open the singleplayer menu");
+ Cmd_AddCommand(&cmd_client, "menu_load", M_Menu_Load_f, "open the loadgame menu");
+ Cmd_AddCommand(&cmd_client, "menu_save", M_Menu_Save_f, "open the savegame menu");
+ Cmd_AddCommand(&cmd_client, "menu_multiplayer", M_Menu_MultiPlayer_f, "open the multiplayer menu");
+ Cmd_AddCommand(&cmd_client, "menu_setup", M_Menu_Setup_f, "open the player setup menu");
+ Cmd_AddCommand(&cmd_client, "menu_options", M_Menu_Options_f, "open the options menu");
+ Cmd_AddCommand(&cmd_client, "menu_options_effects", M_Menu_Options_Effects_f, "open the effects options menu");
+ Cmd_AddCommand(&cmd_client, "menu_options_graphics", M_Menu_Options_Graphics_f, "open the graphics options menu");
+ Cmd_AddCommand(&cmd_client, "menu_options_colorcontrol", M_Menu_Options_ColorControl_f, "open the color control menu");
+ Cmd_AddCommand(&cmd_client, "menu_keys", M_Menu_Keys_f, "open the key binding menu");
+ Cmd_AddCommand(&cmd_client, "menu_video", M_Menu_Video_f, "open the video options menu");
+ Cmd_AddCommand(&cmd_client, "menu_reset", M_Menu_Reset_f, "open the reset to defaults menu");
+ Cmd_AddCommand(&cmd_client, "menu_mods", M_Menu_ModList_f, "open the mods browser menu");
+ Cmd_AddCommand(&cmd_client, "help", M_Menu_Help_f, "open the help menu");
+ Cmd_AddCommand(&cmd_client, "menu_quit", M_Menu_Quit_f, "open the quit menu");
+ Cmd_AddCommand(&cmd_client, "menu_transfusion_episode", M_Menu_Transfusion_Episode_f, "open the transfusion episode select menu");
+ Cmd_AddCommand(&cmd_client, "menu_transfusion_skill", M_Menu_Transfusion_Skill_f, "open the transfusion skill select menu");
+ Cmd_AddCommand(&cmd_client, "menu_credits", M_Menu_Credits_f, "open the credits menu");
}
void M_Draw (void)
void M_KeyEvent (int key, int ascii, qboolean downevent)
{
+ cmd_state_t *cmd = &cmd_client;
if (!downevent)
return;
switch (m_state)
return;
case m_main:
- M_Main_Key (key, ascii);
+ M_Main_Key(cmd, key, ascii);
return;
case m_demo:
- M_Demo_Key (key, ascii);
+ M_Demo_Key(cmd, key, ascii);
return;
case m_singleplayer:
- M_SinglePlayer_Key (key, ascii);
+ M_SinglePlayer_Key(cmd, key, ascii);
return;
case m_transfusion_episode:
- M_Transfusion_Episode_Key (key, ascii);
+ M_Transfusion_Episode_Key(cmd, key, ascii);
return;
case m_transfusion_skill:
- M_Transfusion_Skill_Key (key, ascii);
+ M_Transfusion_Skill_Key(cmd, key, ascii);
return;
case m_load:
- M_Load_Key (key, ascii);
+ M_Load_Key(cmd, key, ascii);
return;
case m_save:
- M_Save_Key (key, ascii);
+ M_Save_Key(cmd, key, ascii);
return;
case m_multiplayer:
- M_MultiPlayer_Key (key, ascii);
+ M_MultiPlayer_Key(cmd, key, ascii);
return;
case m_setup:
- M_Setup_Key (key, ascii);
+ M_Setup_Key(cmd, key, ascii);
return;
case m_options:
- M_Options_Key (key, ascii);
+ M_Options_Key(cmd, key, ascii);
return;
case m_options_effects:
- M_Options_Effects_Key (key, ascii);
+ M_Options_Effects_Key(cmd, key, ascii);
return;
case m_options_graphics:
- M_Options_Graphics_Key (key, ascii);
+ M_Options_Graphics_Key(cmd, key, ascii);
return;
case m_options_colorcontrol:
- M_Options_ColorControl_Key (key, ascii);
+ M_Options_ColorControl_Key(cmd, key, ascii);
return;
case m_keys:
- M_Keys_Key (key, ascii);
+ M_Keys_Key(cmd, key, ascii);
return;
case m_reset:
- M_Reset_Key (key, ascii);
+ M_Reset_Key(cmd, key, ascii);
return;
case m_video:
- M_Video_Key (key, ascii);
+ M_Video_Key(cmd, key, ascii);
return;
case m_help:
- M_Help_Key (key, ascii);
+ M_Help_Key(cmd, key, ascii);
return;
case m_credits:
- M_Credits_Key (key, ascii);
+ M_Credits_Key(cmd, key, ascii);
return;
case m_quit:
- M_Quit_Key (key, ascii);
+ M_Quit_Key(cmd, key, ascii);
return;
case m_lanconfig:
- M_LanConfig_Key (key, ascii);
+ M_LanConfig_Key(cmd, key, ascii);
return;
case m_gameoptions:
- M_GameOptions_Key (key, ascii);
+ M_GameOptions_Key(cmd, key, ascii);
return;
case m_slist:
- M_ServerList_Key (key, ascii);
+ M_ServerList_Key(cmd, key, ascii);
return;
case m_modlist:
- M_ModList_Key (key, ascii);
+ M_ModList_Key(cmd, key, ascii);
return;
}
MR_SetRouting (FALSE);
}
-static void Call_MR_ToggleMenu_f(void)
+static void MR_Restart_f(cmd_state_t *cmd)
+{
+ MR_Restart();
+}
+
+static void Call_MR_ToggleMenu_f(cmd_state_t *cmd)
{
int m;
- m = ((Cmd_Argc() < 2) ? -1 : atoi(Cmd_Argv(1)));
+ m = ((Cmd_Argc(cmd) < 2) ? -1 : atoi(Cmd_Argv(cmd, 1)));
Host_StartVideo();
if(MR_ToggleMenu)
MR_ToggleMenu(m);
Cvar_RegisterVariable (&forceqmenu);
Cvar_RegisterVariable (&menu_options_colorcontrol_correctionvalue);
Cvar_RegisterVariable (&menu_progs);
- Cmd_AddCommand ("menu_restart",MR_Restart, "restart menu system (reloads menu.dat)");
- Cmd_AddCommand ("togglemenu", Call_MR_ToggleMenu_f, "opens or closes menu");
+ Cmd_AddCommand(&cmd_client, "menu_restart", MR_Restart_f, "restart menu system (reloads menu.dat)");
+ Cmd_AddCommand(&cmd_client, "togglemenu", Call_MR_ToggleMenu_f, "opens or closes menu");
}
void MR_Init(void)
Mod_Init
===============
*/
-static void Mod_Print(void);
-static void Mod_Precache (void);
-static void Mod_Decompile_f(void);
-static void Mod_GenerateLightmaps_f(void);
+static void Mod_Print_f(cmd_state_t *cmd);
+static void Mod_Precache_f(cmd_state_t *cmd);
+static void Mod_Decompile_f(cmd_state_t *cmd);
+static void Mod_GenerateLightmaps_f(cmd_state_t *cmd);
void Mod_Init (void)
{
mod_mempool = Mem_AllocPool("modelinfo", 0, NULL);
Cvar_RegisterVariable(&mod_generatelightmaps_vertexradius);
Cvar_RegisterVariable(&mod_generatelightmaps_gridradius);
- Cmd_AddCommand ("modellist", Mod_Print, "prints a list of loaded models");
- Cmd_AddCommand ("modelprecache", Mod_Precache, "load a model");
- Cmd_AddCommand ("modeldecompile", Mod_Decompile_f, "exports a model in several formats for editing purposes");
- Cmd_AddCommand ("mod_generatelightmaps", Mod_GenerateLightmaps_f, "rebuilds lighting on current worldmodel");
+ Cmd_AddCommand(&cmd_client, "modellist", Mod_Print_f, "prints a list of loaded models");
+ Cmd_AddCommand(&cmd_client, "modelprecache", Mod_Precache_f, "load a model");
+ Cmd_AddCommand(&cmd_client, "modeldecompile", Mod_Decompile_f, "exports a model in several formats for editing purposes");
+ Cmd_AddCommand(&cmd_client, "mod_generatelightmaps", Mod_GenerateLightmaps_f, "rebuilds lighting on current worldmodel");
}
void Mod_RenderInit(void)
Mod_Print
================
*/
-static void Mod_Print(void)
+static void Mod_Print_f(cmd_state_t *cmd)
{
int i;
int nummodels = (int)Mem_ExpandableArray_IndexRange(&models);
Mod_Precache
================
*/
-static void Mod_Precache(void)
+static void Mod_Precache_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() == 2)
- Mod_ForName(Cmd_Argv(1), false, true, Cmd_Argv(1)[0] == '*' ? cl.model_name[1] : NULL);
+ if (Cmd_Argc(cmd) == 2)
+ Mod_ForName(Cmd_Argv(cmd, 1), false, true, Cmd_Argv(cmd, 1)[0] == '*' ? cl.model_name[1] : NULL);
else
Con_Print("usage: modelprecache <filename>\n");
}
decompiles a model to editable files
================
*/
-static void Mod_Decompile_f(void)
+static void Mod_Decompile_f(cmd_state_t *cmd)
{
int i, j, k, l, first, count;
dp_model_t *mod;
int framegroupstextsize = 0;
char vabuf[1024];
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("usage: modeldecompile <filename>\n");
return;
}
- strlcpy(inname, Cmd_Argv(1), sizeof(inname));
+ strlcpy(inname, Cmd_Argv(cmd, 1), sizeof(inname));
FS_StripExtension(inname, basename, sizeof(basename));
mod = Mod_ForName(inname, false, true, inname[0] == '*' ? cl.model_name[1] : NULL);
loadmodel = oldloadmodel;
}
-static void Mod_GenerateLightmaps_f(void)
+static void Mod_GenerateLightmaps_f(cmd_state_t *cmd)
{
- if (Cmd_Argc() != 1)
+ if (Cmd_Argc(cmd) != 1)
{
Con_Printf("usage: mod_generatelightmaps\n");
return;
VM_vectoyaw, // #10
VM_vectoangles, // #11
VM_random, // #12
-VM_localcmd, // #13
+VM_localcmd_client, // #13
VM_cvar, // #14
VM_cvar_set, // #15
VM_dprint, // #16
if(l)
{
client_t *host_client_save = host_client;
- Cmd_ExecuteString(s, src_command, true);
+ Cmd_ExecuteString(&cmd_server, s, src_command, true);
host_client = host_client_save;
// in case it is a command that changes host_client (like restart)
}
}
}
-static void Net_Heartbeat_f(void)
+static void Net_Heartbeat_f(cmd_state_t *cmd)
{
if (sv.active)
NetConn_Heartbeat(2);
Con_Printf("droppedDatagrams = %i\n", conn->droppedDatagrams);
}
-void Net_Stats_f(void)
+void Net_Stats_f(cmd_state_t *cmd)
{
netconn_t *conn;
Con_Print("connections =\n");
}
#ifdef CONFIG_MENU
-void Net_Refresh_f(void)
+void Net_Refresh_f(cmd_state_t *cmd)
{
if (m_state != m_slist) {
Con_Print("Sending new requests to master servers\n");
ServerList_QueryList(false, true, false, false);
}
-void Net_Slist_f(void)
+void Net_Slist_f(cmd_state_t *cmd)
{
ServerList_ResetMasks();
serverlist_sortbyfield = SLIF_PING;
ServerList_QueryList(true, true, false, false);
}
-void Net_SlistQW_f(void)
+void Net_SlistQW_f(cmd_state_t *cmd)
{
ServerList_ResetMasks();
serverlist_sortbyfield = SLIF_PING;
int i;
lhnetaddress_t tempaddress;
netconn_mempool = Mem_AllocPool("network connections", 0, NULL);
- Cmd_AddCommand("net_stats", Net_Stats_f, "print network statistics");
+ Cmd_AddCommand(&cmd_client, "net_stats", Net_Stats_f, "print network statistics");
+ Cmd_AddCommand(&cmd_server, "net_stats", Net_Stats_f, "print network statistics");
#ifdef CONFIG_MENU
- Cmd_AddCommand("net_slist", Net_Slist_f, "query dp master servers and print all server information");
- Cmd_AddCommand("net_slistqw", Net_SlistQW_f, "query qw master servers and print all server information");
- Cmd_AddCommand("net_refresh", Net_Refresh_f, "query dp master servers and refresh all server information");
+ Cmd_AddCommand(&cmd_client, "net_slist", Net_Slist_f, "query dp master servers and print all server information");
+ Cmd_AddCommand(&cmd_client, "net_slistqw", Net_SlistQW_f, "query qw master servers and print all server information");
+ Cmd_AddCommand(&cmd_client, "net_refresh", Net_Refresh_f, "query dp master servers and refresh all server information");
#endif
- Cmd_AddCommand("heartbeat", Net_Heartbeat_f, "send a heartbeat to the master server (updates your server information)");
+ Cmd_AddCommand(&cmd_server, "heartbeat", Net_Heartbeat_f, "send a heartbeat to the master server (updates your server information)");
Cvar_RegisterVariable(&net_test);
Cvar_RegisterVariable(&net_usesizelimit);
Cvar_RegisterVariable(&net_burstreserve);
void NetConn_ServerFrame(void);
void NetConn_SleepMicroseconds(int microseconds);
void NetConn_Heartbeat(int priority);
-void Net_Stats_f(void);
+void Net_Stats_f(cmd_state_t *cmd);
#ifdef CONFIG_MENU
void NetConn_QueryMasters(qboolean querydp, qboolean queryqw);
void NetConn_QueryQueueFrame(void);
-void Net_Slist_f(void);
-void Net_SlistQW_f(void);
-void Net_Refresh_f(void);
+void Net_Slist_f(cmd_state_t *cmd);
+void Net_SlistQW_f(cmd_state_t *cmd);
+void Net_Refresh_f(cmd_state_t *cmd);
/// ServerList interface (public)
/// manually refresh the view set, do this after having changed the mask or any other flag
#define PRVM_Free(buffer) Mem_Free(buffer)
void PRVM_Profile (prvm_prog_t *prog, int maxfunctions, double mintime, int sortby);
-void PRVM_Profile_f (void);
-void PRVM_ChildProfile_f (void);
-void PRVM_CallProfile_f (void);
-void PRVM_PrintFunction_f (void);
+void PRVM_Profile_f(cmd_state_t *cmd);
+void PRVM_ChildProfile_f(cmd_state_t *cmd);
+void PRVM_CallProfile_f(cmd_state_t *cmd);
+void PRVM_PrintFunction_f(cmd_state_t *cmd);
void PRVM_PrintState(prvm_prog_t *prog, int stack_index);
void PRVM_Crash(prvm_prog_t *prog);
void PRVM_Init_Exec(prvm_prog_t *prog);
-void PRVM_ED_PrintEdicts_f (void);
+void PRVM_ED_PrintEdicts_f(cmd_state_t *cmd);
void PRVM_ED_PrintNum (prvm_prog_t *prog, int ent, const char *wildcard_fieldname);
const char *PRVM_GetString(prvm_prog_t *prog, int num);
/*
=================
-VM_localcmd
+VM_localcmd_client
Sends text over to the client's execution buffer
cmd (string, ...)
=================
*/
-void VM_localcmd(prvm_prog_t *prog)
+void VM_localcmd_client(prvm_prog_t *prog)
{
char string[VM_STRINGTEMP_LENGTH];
VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd);
VM_VarString(prog, 0, string, sizeof(string));
- Cbuf_AddText(string);
+ Cbuf_AddText(&cmd_client, string);
+}
+
+/*
+=================
+VM_localcmd_server
+
+Sends text over to the server's execution buffer
+
+[localcmd (string, ...) or]
+cmd (string, ...)
+=================
+*/
+void VM_localcmd_server(prvm_prog_t *prog)
+{
+ char string[VM_STRINGTEMP_LENGTH];
+ VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd);
+ VM_VarString(prog, 0, string, sizeof(string));
+ Cbuf_AddText(&cmd_server, string);
}
static qboolean PRVM_Cvar_ReadOk(const char *string)
*/
void VM_coredump(prvm_prog_t *prog)
{
+ cmd_state_t *cmd = cls.state == ca_dedicated ? &cmd_server : &cmd_client;
VM_SAFEPARMCOUNT(0,VM_coredump);
- Cbuf_AddText("prvm_edicts ");
- Cbuf_AddText(prog->name);
- Cbuf_AddText("\n");
+ Cbuf_AddText(cmd, "prvm_edicts ");
+ Cbuf_AddText(cmd, prog->name);
+ Cbuf_AddText(cmd, "\n");
}
/*
return;
svs.changelevel_issued = true;
- Cbuf_AddText(va(vabuf, sizeof(vabuf), "changelevel %s\n",PRVM_G_STRING(OFS_PARM0)));
+ Cbuf_AddText(&cmd_server, va(vabuf, sizeof(vabuf), "changelevel %s\n", PRVM_G_STRING(OFS_PARM0)));
}
/*
return;
// check for overlap with a command
- if (Cmd_Exists (name))
+ if (Cmd_Exists(&cmd_client, name) || Cmd_Exists(&cmd_server, name))
{
VM_Warning(prog, "VM_registercvar: %s is a command\n", name);
return;
temp_client = host_client;
host_client = svs.clients + i;
- Cmd_ExecuteString (PRVM_G_STRING(OFS_PARM1), src_client, true);
+ Cmd_ExecuteString (&cmd_serverfromclient, PRVM_G_STRING(OFS_PARM1), src_client, true);
host_client = temp_client;
}
void VM_random (prvm_prog_t *prog);
void VM_localsound(prvm_prog_t *prog);
void VM_break (prvm_prog_t *prog);
-void VM_localcmd (prvm_prog_t *prog);
+void VM_localcmd_client(prvm_prog_t *prog);
+void VM_localcmd_server(prvm_prog_t *prog);
void VM_cvar (prvm_prog_t *prog);
void VM_cvar_string(prvm_prog_t *prog);
void VM_cvar_type (prvm_prog_t *prog);
For debugging, prints all the entities in the current server
=============
*/
-void PRVM_ED_PrintEdicts_f (void)
+void PRVM_ED_PrintEdicts_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i;
const char *wildcard_fieldname;
- if(Cmd_Argc() < 2 || Cmd_Argc() > 3)
+ if(Cmd_Argc(cmd) < 2 || Cmd_Argc(cmd) > 3)
{
Con_Print("prvm_edicts <program name> <optional field name wildcard>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- if( Cmd_Argc() == 3)
- wildcard_fieldname = Cmd_Argv(2);
+ if( Cmd_Argc(cmd) == 3)
+ wildcard_fieldname = Cmd_Argv(cmd, 2);
else
wildcard_fieldname = NULL;
For debugging, prints a single edict
=============
*/
-static void PRVM_ED_PrintEdict_f (void)
+static void PRVM_ED_PrintEdict_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i;
const char *wildcard_fieldname;
- if(Cmd_Argc() < 3 || Cmd_Argc() > 4)
+ if(Cmd_Argc(cmd) < 3 || Cmd_Argc(cmd) > 4)
{
Con_Print("prvm_edict <program name> <edict number> <optional field name wildcard>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- i = atoi (Cmd_Argv(2));
+ i = atoi (Cmd_Argv(cmd, 2));
if (i >= prog->num_edicts)
{
Con_Print("Bad edict number\n");
return;
}
- if( Cmd_Argc() == 4)
+ if( Cmd_Argc(cmd) == 4)
// Optional Wildcard Provided
- wildcard_fieldname = Cmd_Argv(3);
+ wildcard_fieldname = Cmd_Argv(cmd, 3);
else
// Use All
wildcard_fieldname = NULL;
*/
// 2 possibilities : 1. just displaying the active edict count
// 2. making a function pointer [x]
-static void PRVM_ED_Count_f (void)
+static void PRVM_ED_Count_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if(Cmd_Argc() != 2)
+ if(Cmd_Argc(cmd) != 2)
{
Con_Print("prvm_count <program name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
prog->count_edicts(prog);
QC, mg in menu QC.
=============
*/
-static void PRVM_GameCommand(const char *whichprogs, const char *whichcmd)
+static void PRVM_GameCommand(cmd_state_t *cmd, const char *whichprogs, const char *whichcmd)
{
prvm_prog_t *prog;
- if(Cmd_Argc() < 1)
+ if(Cmd_Argc(cmd) < 1)
{
Con_Printf("%s text...\n", whichcmd);
return;
int restorevm_tempstringsbuf_cursize;
const char *s;
- s = Cmd_Args();
+ s = Cmd_Args(cmd);
restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, s ? s : "");
prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
}
}
-static void PRVM_GameCommand_Server_f(void)
+static void PRVM_GameCommand_Server_f(cmd_state_t *cmd)
{
- PRVM_GameCommand("server", "sv_cmd");
+ PRVM_GameCommand(cmd, "server", "sv_cmd");
}
-static void PRVM_GameCommand_Client_f(void)
+static void PRVM_GameCommand_Client_f(cmd_state_t *cmd)
{
- PRVM_GameCommand("client", "cl_cmd");
+ PRVM_GameCommand(cmd, "client", "cl_cmd");
}
-static void PRVM_GameCommand_Menu_f(void)
+static void PRVM_GameCommand_Menu_f(cmd_state_t *cmd)
{
- PRVM_GameCommand("menu", "menu_cmd");
+ PRVM_GameCommand(cmd, "menu", "menu_cmd");
}
/*
Console command to load a field of a specified edict
=============
*/
-static void PRVM_ED_EdictGet_f(void)
+static void PRVM_ED_EdictGet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
prvm_edict_t *ed;
prvm_eval_t *v;
char valuebuf[MAX_INPUTLINE];
- if(Cmd_Argc() != 4 && Cmd_Argc() != 5)
+ if(Cmd_Argc(cmd) != 4 && Cmd_Argc(cmd) != 5)
{
Con_Print("prvm_edictget <program name> <edict number> <field> [<cvar>]\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(2)));
+ ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(cmd, 2)));
- if((key = PRVM_ED_FindField(prog, Cmd_Argv(3))) == 0)
+ if((key = PRVM_ED_FindField(prog, Cmd_Argv(cmd, 3))) == 0)
{
- Con_Printf("Key %s not found !\n", Cmd_Argv(3));
+ Con_Printf("Key %s not found !\n", Cmd_Argv(cmd, 3));
goto fail;
}
v = (prvm_eval_t *)(ed->fields.fp + key->ofs);
s = PRVM_UglyValueString(prog, (etype_t)key->type, v, valuebuf, sizeof(valuebuf));
- if(Cmd_Argc() == 5)
+ if(Cmd_Argc(cmd) == 5)
{
- cvar_t *cvar = Cvar_FindVar(Cmd_Argv(4));
+ cvar_t *cvar = Cvar_FindVar(Cmd_Argv(cmd, 4));
if (cvar && cvar->flags & CVAR_READONLY)
{
Con_Printf("prvm_edictget: %s is read-only\n", cvar->name);
goto fail;
}
- Cvar_Get(Cmd_Argv(4), s, 0, NULL);
+ Cvar_Get(Cmd_Argv(cmd, 4), s, 0, NULL);
}
else
Con_Printf("%s\n", s);
;
}
-static void PRVM_ED_GlobalGet_f(void)
+static void PRVM_ED_GlobalGet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
ddef_t *key;
prvm_eval_t *v;
char valuebuf[MAX_INPUTLINE];
- if(Cmd_Argc() != 3 && Cmd_Argc() != 4)
+ if(Cmd_Argc(cmd) != 3 && Cmd_Argc(cmd) != 4)
{
Con_Print("prvm_globalget <program name> <global> [<cvar>]\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- key = PRVM_ED_FindGlobal(prog, Cmd_Argv(2));
+ key = PRVM_ED_FindGlobal(prog, Cmd_Argv(cmd, 2));
if(!key)
{
- Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
+ Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(cmd, 2), Cmd_Argv(cmd, 1) );
goto fail;
}
v = (prvm_eval_t *) &prog->globals.fp[key->ofs];
s = PRVM_UglyValueString(prog, (etype_t)key->type, v, valuebuf, sizeof(valuebuf));
- if(Cmd_Argc() == 4)
+ if(Cmd_Argc(cmd) == 4)
{
- cvar_t *cvar = Cvar_FindVar(Cmd_Argv(3));
+ cvar_t *cvar = Cvar_FindVar(Cmd_Argv(cmd, 3));
if (cvar && cvar->flags & CVAR_READONLY)
{
Con_Printf("prvm_globalget: %s is read-only\n", cvar->name);
goto fail;
}
- Cvar_Get(Cmd_Argv(3), s, 0, NULL);
+ Cvar_Get(Cmd_Argv(cmd, 3), s, 0, NULL);
}
else
Con_Printf("%s\n", s);
Console command to set a field of a specified edict
=============
*/
-static void PRVM_ED_EdictSet_f(void)
+static void PRVM_ED_EdictSet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
prvm_edict_t *ed;
ddef_t *key;
- if(Cmd_Argc() != 5)
+ if(Cmd_Argc(cmd) != 5)
{
Con_Print("prvm_edictset <program name> <edict number> <field> <value>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(2)));
+ ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(cmd, 2)));
- if((key = PRVM_ED_FindField(prog, Cmd_Argv(3))) == 0)
- Con_Printf("Key %s not found !\n", Cmd_Argv(3));
+ if((key = PRVM_ED_FindField(prog, Cmd_Argv(cmd, 3))) == 0)
+ Con_Printf("Key %s not found !\n", Cmd_Argv(cmd, 3));
else
- PRVM_ED_ParseEpair(prog, ed, key, Cmd_Argv(4), true);
+ PRVM_ED_ParseEpair(prog, ed, key, Cmd_Argv(cmd, 4), true);
}
/*
}
-static void PRVM_Fields_f (void)
+static void PRVM_Fields_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i, j, ednum, used, usedamount;
}
*/
- if(Cmd_Argc() != 2)
+ if(Cmd_Argc(cmd) != 2)
{
Con_Print("prvm_fields <program name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
counts = (int *)Mem_Alloc(tempmempool, prog->numfielddefs * sizeof(int));
Con_Printf("%s: %i entity fields (%i in use), totalling %i bytes per edict (%i in use), %i edicts allocated, %i bytes total spent on edict fields (%i needed)\n", prog->name, prog->entityfields, used, prog->entityfields * 4, usedamount * 4, prog->max_edicts, prog->entityfields * 4 * prog->max_edicts, usedamount * 4 * prog->max_edicts);
}
-static void PRVM_Globals_f (void)
+static void PRVM_Globals_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i;
Con_Print("no progs loaded\n");
return;
}*/
- if(Cmd_Argc () < 2 || Cmd_Argc() > 3)
+ if(Cmd_Argc (cmd) < 2 || Cmd_Argc(cmd) > 3)
{
Con_Print("prvm_globals <program name> <optional name wildcard>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- if( Cmd_Argc() == 3)
- wildcard = Cmd_Argv(2);
+ if( Cmd_Argc(cmd) == 3)
+ wildcard = Cmd_Argv(cmd, 2);
else
wildcard = NULL;
PRVM_Global
===============
*/
-static void PRVM_Global_f(void)
+static void PRVM_Global_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
ddef_t *global;
char valuebuf[MAX_INPUTLINE];
- if( Cmd_Argc() != 3 ) {
+ if( Cmd_Argc(cmd) != 3 ) {
Con_Printf( "prvm_global <program name> <global name>\n" );
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- global = PRVM_ED_FindGlobal( prog, Cmd_Argv(2) );
+ global = PRVM_ED_FindGlobal( prog, Cmd_Argv(cmd, 2) );
if( !global )
- Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
+ Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(cmd, 2), Cmd_Argv(cmd, 1) );
else
- Con_Printf( "%s: %s\n", Cmd_Argv(2), PRVM_ValueString( prog, (etype_t)global->type, PRVM_GLOBALFIELDVALUE(global->ofs), valuebuf, sizeof(valuebuf) ) );
+ Con_Printf( "%s: %s\n", Cmd_Argv(cmd, 2), PRVM_ValueString( prog, (etype_t)global->type, PRVM_GLOBALFIELDVALUE(global->ofs), valuebuf, sizeof(valuebuf) ) );
}
/*
PRVM_GlobalSet
===============
*/
-static void PRVM_GlobalSet_f(void)
+static void PRVM_GlobalSet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
ddef_t *global;
- if( Cmd_Argc() != 4 ) {
+ if( Cmd_Argc(cmd) != 4 ) {
Con_Printf( "prvm_globalset <program name> <global name> <value>\n" );
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- global = PRVM_ED_FindGlobal( prog, Cmd_Argv(2) );
+ global = PRVM_ED_FindGlobal( prog, Cmd_Argv(cmd, 2) );
if( !global )
- Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
+ Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(cmd, 2), Cmd_Argv(cmd, 1) );
else
- PRVM_ED_ParseEpair( prog, NULL, global, Cmd_Argv(3), true );
+ PRVM_ED_ParseEpair( prog, NULL, global, Cmd_Argv(cmd, 3), true );
}
/*
prog->watch_field_type = ev_void;
}
-static void PRVM_Breakpoint_f(void)
+static void PRVM_Breakpoint_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if( Cmd_Argc() == 2 ) {
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if( Cmd_Argc(cmd) == 2 ) {
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
PRVM_UpdateBreakpoints(prog);
return;
}
- if( Cmd_Argc() != 3 ) {
+ if( Cmd_Argc(cmd) != 3 ) {
Con_Printf( "prvm_breakpoint <program name> <function name | statement>\n" );
return;
}
- if (!(prog = PRVM_ProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_ProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
- strlcpy(debug->break_statement, Cmd_Argv(2), sizeof(debug->break_statement));
+ strlcpy(debug->break_statement, Cmd_Argv(cmd, 2), sizeof(debug->break_statement));
}
PRVM_UpdateBreakpoints(prog);
}
-static void PRVM_GlobalWatchpoint_f(void)
+static void PRVM_GlobalWatchpoint_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if( Cmd_Argc() == 2 ) {
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if( Cmd_Argc(cmd) == 2 ) {
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
PRVM_UpdateBreakpoints(prog);
return;
}
- if( Cmd_Argc() != 3 ) {
+ if( Cmd_Argc(cmd) != 3 ) {
Con_Printf( "prvm_globalwatchpoint <program name> <global name>\n" );
return;
}
- if (!(prog = PRVM_ProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_ProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
- strlcpy(debug->watch_global, Cmd_Argv(2), sizeof(debug->watch_global));
+ strlcpy(debug->watch_global, Cmd_Argv(cmd, 2), sizeof(debug->watch_global));
}
PRVM_UpdateBreakpoints(prog);
}
-static void PRVM_EdictWatchpoint_f(void)
+static void PRVM_EdictWatchpoint_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if( Cmd_Argc() == 2 ) {
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if( Cmd_Argc(cmd) == 2 ) {
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
PRVM_UpdateBreakpoints(prog);
return;
}
- if( Cmd_Argc() != 4 ) {
+ if( Cmd_Argc(cmd) != 4 ) {
Con_Printf( "prvm_edictwatchpoint <program name> <edict number> <field name>\n" );
return;
}
- if (!(prog = PRVM_ProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_ProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
- debug->watch_edict = atoi(Cmd_Argv(2));
- strlcpy(debug->watch_field, Cmd_Argv(3), sizeof(debug->watch_field));
+ debug->watch_edict = atoi(Cmd_Argv(cmd, 2));
+ strlcpy(debug->watch_field, Cmd_Argv(cmd, 3), sizeof(debug->watch_field));
}
PRVM_UpdateBreakpoints(prog);
}
*/
void PRVM_Init (void)
{
- Cmd_AddCommand ("prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_childprofile", PRVM_ChildProfile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu), sorted by time taken in function with child calls");
- Cmd_AddCommand ("prvm_callprofile", PRVM_CallProfile_f, "prints execution statistics about the most time consuming QuakeC calls from the engine in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_fields", PRVM_Fields_f, "prints usage statistics on properties (how many entities have non-zero values) in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edictset", PRVM_ED_EdictSet_f, "changes value of a specified property of a specified entity in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edictget", PRVM_ED_EdictGet_f, "retrieves the value of a specified property of a specified entity in the selected VM (server, client menu) into a cvar or to the console");
- Cmd_AddCommand ("prvm_globalget", PRVM_ED_GlobalGet_f, "retrieves the value of a specified global variable in the selected VM (server, client menu) into a cvar or to the console");
- Cmd_AddCommand ("prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)");
- Cmd_AddCommand ("cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument");
- Cmd_AddCommand ("menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument");
- Cmd_AddCommand ("sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument");
-
- Cmd_AddCommand ("prvm_breakpoint", PRVM_Breakpoint_f, "marks a statement or function as breakpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear breakpoint");
- Cmd_AddCommand ("prvm_globalwatchpoint", PRVM_GlobalWatchpoint_f, "marks a global as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
- Cmd_AddCommand ("prvm_edictwatchpoint", PRVM_EdictWatchpoint_f, "marks an entity field as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+ Cmd_AddCommand(&cmd_client, "prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_childprofile", PRVM_ChildProfile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu), sorted by time taken in function with child calls");
+ Cmd_AddCommand(&cmd_client, "prvm_callprofile", PRVM_CallProfile_f, "prints execution statistics about the most time consuming QuakeC calls from the engine in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_fields", PRVM_Fields_f, "prints usage statistics on properties (how many entities have non-zero values) in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edictset", PRVM_ED_EdictSet_f, "changes value of a specified property of a specified entity in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edictget", PRVM_ED_EdictGet_f, "retrieves the value of a specified property of a specified entity in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_client, "prvm_globalget", PRVM_ED_GlobalGet_f, "retrieves the value of a specified global variable in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_client, "prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_client, "menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_client, "sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_client, "prvm_breakpoint", PRVM_Breakpoint_f, "marks a statement or function as breakpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear breakpoint");
+ Cmd_AddCommand(&cmd_client, "prvm_globalwatchpoint", PRVM_GlobalWatchpoint_f, "marks a global as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+ Cmd_AddCommand(&cmd_client, "prvm_edictwatchpoint", PRVM_EdictWatchpoint_f, "marks an entity field as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+
+ Cmd_AddCommand(&cmd_server, "prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_childprofile", PRVM_ChildProfile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu), sorted by time taken in function with child calls");
+ Cmd_AddCommand(&cmd_server, "prvm_callprofile", PRVM_CallProfile_f, "prints execution statistics about the most time consuming QuakeC calls from the engine in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_fields", PRVM_Fields_f, "prints usage statistics on properties (how many entities have non-zero values) in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edictset", PRVM_ED_EdictSet_f, "changes value of a specified property of a specified entity in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edictget", PRVM_ED_EdictGet_f, "retrieves the value of a specified property of a specified entity in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_server, "prvm_globalget", PRVM_ED_GlobalGet_f, "retrieves the value of a specified global variable in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_server, "prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_server, "menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_server, "sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_server, "prvm_breakpoint", PRVM_Breakpoint_f, "marks a statement or function as breakpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear breakpoint");
+ Cmd_AddCommand(&cmd_server, "prvm_globalwatchpoint", PRVM_GlobalWatchpoint_f, "marks a global as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+ Cmd_AddCommand(&cmd_server, "prvm_edictwatchpoint", PRVM_EdictWatchpoint_f, "marks an entity field as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
Cvar_RegisterVariable (&prvm_language);
Cvar_RegisterVariable (&prvm_traceqc);
============
*/
-void PRVM_PrintFunction_f (void)
+void PRVM_PrintFunction_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
Con_Printf("usage: prvm_printfunction <program name> <function name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- PRVM_PrintFunctionStatements(prog, Cmd_Argv(2));
+ PRVM_PrintFunctionStatements(prog, Cmd_Argv(cmd, 2));
}
/*
============
*/
-void PRVM_CallProfile_f (void)
+void PRVM_CallProfile_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) != 2)
{
Con_Print("prvm_callprofile <program name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
PRVM_CallProfile(prog);
============
*/
-void PRVM_Profile_f (void)
+void PRVM_Profile_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int howmany;
}
howmany = 1<<30;
- if (Cmd_Argc() == 3)
- howmany = atoi(Cmd_Argv(2));
- else if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) == 3)
+ howmany = atoi(Cmd_Argv(cmd, 2));
+ else if (Cmd_Argc(cmd) != 2)
{
Con_Print("prvm_profile <program name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
PRVM_Profile(prog, howmany, 0, 0);
}
-void PRVM_ChildProfile_f (void)
+void PRVM_ChildProfile_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int howmany;
}
howmany = 1<<30;
- if (Cmd_Argc() == 3)
- howmany = atoi(Cmd_Argv(2));
- else if (Cmd_Argc() != 2)
+ if (Cmd_Argc(cmd) == 3)
+ howmany = atoi(Cmd_Argv(cmd, 2));
+ else if (Cmd_Argc(cmd) != 2)
{
Con_Print("prvm_childprofile <program name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
PRVM_Profile(prog, howmany, 0, 1);
void Host_Shutdown(void);
void Host_StartVideo(void);
void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
-void Host_Quit_f(void);
+void Host_Quit_f(cmd_state_t *cmd);
void Host_ClientCommands(const char *fmt, ...) DP_FUNC_PRINTF(1);
void Host_ShutdownServer(void);
-void Host_Reconnect_f(void);
-void Host_NoOperation_f(void);
+void Host_Reconnect_f(cmd_state_t *cmd);
+void Host_NoOperation_f(cmd_state_t *cmd);
void Host_LockSession(void);
void Host_UnlockSession(void);
void R_Modules_Init(void)
{
- Cmd_AddCommand("r_restart", R_Modules_Restart, "restarts renderer");
+ Cmd_AddCommand(&cmd_client, "r_restart", R_Modules_Restart_f, "restarts renderer");
}
void R_RegisterModule(const char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void), void(*devicelost)(void), void(*devicerestored)(void))
}
}
-void R_Modules_Restart(void)
+void R_Modules_Restart_f(cmd_state_t *cmd)
{
Host_StartVideo();
Con_Print("restarting renderer\n");
void R_Modules_Start(void);
void R_Modules_Shutdown(void);
void R_Modules_NewMap(void);
-void R_Modules_Restart(void);
+void R_Modules_Restart_f(cmd_state_t *cmd);
void R_Modules_DeviceLost(void);
void R_Modules_DeviceRestored(void);
void R_Shadow_LoadWorldLights(void);
void R_Shadow_LoadLightsFile(void);
void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void);
-void R_Shadow_EditLights_Reload_f(void);
+void R_Shadow_EditLights_Reload_f(cmd_state_t *cmd);
static void R_Shadow_MakeTextures(void);
#define EDLIGHTSPRSIZE 8
}
if(R_CompileShader_CheckStaticParms())
- R_GLSL_Restart_f();
+ R_GLSL_Restart_f(&cmd_client);
}
qboolean R_Shadow_ShadowMappingEnabled(void)
if (r_editlights_sprcubemapnoshadowlight) { R_SkinFrame_MarkUsed(r_editlights_sprcubemapnoshadowlight); }
if (r_editlights_sprselection) { R_SkinFrame_MarkUsed(r_editlights_sprselection); }
if (strncmp(cl.worldname, r_shadow_mapname, sizeof(r_shadow_mapname)))
- R_Shadow_EditLights_Reload_f();
+ R_Shadow_EditLights_Reload_f(&cmd_client);
}
void R_Shadow_Init(void)
R_Shadow_SelectLight(NULL);
}
-static void R_Shadow_EditLights_Clear_f(void)
+static void R_Shadow_EditLights_Clear_f(cmd_state_t *cmd)
{
R_Shadow_ClearWorldLights();
}
-void R_Shadow_EditLights_Reload_f(void)
+void R_Shadow_EditLights_Reload_f(cmd_state_t *cmd)
{
if (!cl.worldmodel)
return;
}
}
-static void R_Shadow_EditLights_Save_f(void)
+static void R_Shadow_EditLights_Save_f(cmd_state_t *cmd)
{
if (!cl.worldmodel)
return;
R_Shadow_SaveWorldLights();
}
-static void R_Shadow_EditLights_ImportLightEntitiesFromMap_f(void)
+static void R_Shadow_EditLights_ImportLightEntitiesFromMap_f(cmd_state_t *cmd)
{
R_Shadow_ClearWorldLights();
R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite();
}
-static void R_Shadow_EditLights_ImportLightsFile_f(void)
+static void R_Shadow_EditLights_ImportLightsFile_f(cmd_state_t *cmd)
{
R_Shadow_ClearWorldLights();
R_Shadow_LoadLightsFile();
}
-static void R_Shadow_EditLights_Spawn_f(void)
+static void R_Shadow_EditLights_Spawn_f(cmd_state_t *cmd)
{
vec3_t color;
if (!r_editlights.integer)
Con_Print("Cannot spawn light when not in editing mode. Set r_editlights to 1.\n");
return;
}
- if (Cmd_Argc() != 1)
+ if (Cmd_Argc(cmd) != 1)
{
Con_Print("r_editlights_spawn does not take parameters\n");
return;
R_Shadow_UpdateWorldLight(R_Shadow_NewWorldLight(), r_editlights_cursorlocation, vec3_origin, color, 200, 0, 0, true, NULL, 0.25, 0, 1, 1, LIGHTFLAG_REALTIMEMODE);
}
-static void R_Shadow_EditLights_Edit_f(void)
+static void R_Shadow_EditLights_Edit_f(cmd_state_t *cmd)
{
vec3_t origin, angles, color;
vec_t radius, corona, coronasizescale, ambientscale, diffusescale, specularscale;
flags = r_shadow_selectedlight->flags;
normalmode = (flags & LIGHTFLAG_NORMALMODE) != 0;
realtimemode = (flags & LIGHTFLAG_REALTIMEMODE) != 0;
- if (!strcmp(Cmd_Argv(1), "origin"))
+ if (!strcmp(Cmd_Argv(cmd, 1), "origin"))
{
- if (Cmd_Argc() != 5)
+ if (Cmd_Argc(cmd) != 5)
{
- Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(cmd, 1));
return;
}
- origin[0] = atof(Cmd_Argv(2));
- origin[1] = atof(Cmd_Argv(3));
- origin[2] = atof(Cmd_Argv(4));
+ origin[0] = atof(Cmd_Argv(cmd, 2));
+ origin[1] = atof(Cmd_Argv(cmd, 3));
+ origin[2] = atof(Cmd_Argv(cmd, 4));
}
- else if (!strcmp(Cmd_Argv(1), "originscale"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "originscale"))
{
- if (Cmd_Argc() != 5)
+ if (Cmd_Argc(cmd) != 5)
{
- Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(cmd, 1));
return;
}
- origin[0] *= atof(Cmd_Argv(2));
- origin[1] *= atof(Cmd_Argv(3));
- origin[2] *= atof(Cmd_Argv(4));
+ origin[0] *= atof(Cmd_Argv(cmd, 2));
+ origin[1] *= atof(Cmd_Argv(cmd, 3));
+ origin[2] *= atof(Cmd_Argv(cmd, 4));
}
- else if (!strcmp(Cmd_Argv(1), "originx"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "originx"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- origin[0] = atof(Cmd_Argv(2));
+ origin[0] = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "originy"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "originy"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- origin[1] = atof(Cmd_Argv(2));
+ origin[1] = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "originz"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "originz"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- origin[2] = atof(Cmd_Argv(2));
+ origin[2] = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "move"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "move"))
{
- if (Cmd_Argc() != 5)
+ if (Cmd_Argc(cmd) != 5)
{
- Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(cmd, 1));
return;
}
- origin[0] += atof(Cmd_Argv(2));
- origin[1] += atof(Cmd_Argv(3));
- origin[2] += atof(Cmd_Argv(4));
+ origin[0] += atof(Cmd_Argv(cmd, 2));
+ origin[1] += atof(Cmd_Argv(cmd, 3));
+ origin[2] += atof(Cmd_Argv(cmd, 4));
}
- else if (!strcmp(Cmd_Argv(1), "movex"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "movex"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- origin[0] += atof(Cmd_Argv(2));
+ origin[0] += atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "movey"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "movey"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- origin[1] += atof(Cmd_Argv(2));
+ origin[1] += atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "movez"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "movez"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- origin[2] += atof(Cmd_Argv(2));
+ origin[2] += atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "angles"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "angles"))
{
- if (Cmd_Argc() != 5)
+ if (Cmd_Argc(cmd) != 5)
{
- Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s x y z\n", Cmd_Argv(cmd, 1));
return;
}
- angles[0] = atof(Cmd_Argv(2));
- angles[1] = atof(Cmd_Argv(3));
- angles[2] = atof(Cmd_Argv(4));
+ angles[0] = atof(Cmd_Argv(cmd, 2));
+ angles[1] = atof(Cmd_Argv(cmd, 3));
+ angles[2] = atof(Cmd_Argv(cmd, 4));
}
- else if (!strcmp(Cmd_Argv(1), "anglesx"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "anglesx"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- angles[0] = atof(Cmd_Argv(2));
+ angles[0] = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "anglesy"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "anglesy"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- angles[1] = atof(Cmd_Argv(2));
+ angles[1] = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "anglesz"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "anglesz"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- angles[2] = atof(Cmd_Argv(2));
+ angles[2] = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "color"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "color"))
{
- if (Cmd_Argc() != 5)
+ if (Cmd_Argc(cmd) != 5)
{
- Con_Printf("usage: r_editlights_edit %s red green blue\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s red green blue\n", Cmd_Argv(cmd, 1));
return;
}
- color[0] = atof(Cmd_Argv(2));
- color[1] = atof(Cmd_Argv(3));
- color[2] = atof(Cmd_Argv(4));
+ color[0] = atof(Cmd_Argv(cmd, 2));
+ color[1] = atof(Cmd_Argv(cmd, 3));
+ color[2] = atof(Cmd_Argv(cmd, 4));
}
- else if (!strcmp(Cmd_Argv(1), "radius"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "radius"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- radius = atof(Cmd_Argv(2));
+ radius = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "colorscale"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "colorscale"))
{
- if (Cmd_Argc() == 3)
+ if (Cmd_Argc(cmd) == 3)
{
- double scale = atof(Cmd_Argv(2));
+ double scale = atof(Cmd_Argv(cmd, 2));
color[0] *= scale;
color[1] *= scale;
color[2] *= scale;
}
else
{
- if (Cmd_Argc() != 5)
+ if (Cmd_Argc(cmd) != 5)
{
- Con_Printf("usage: r_editlights_edit %s red green blue (OR grey instead of red green blue)\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s red green blue (OR grey instead of red green blue)\n", Cmd_Argv(cmd, 1));
return;
}
- color[0] *= atof(Cmd_Argv(2));
- color[1] *= atof(Cmd_Argv(3));
- color[2] *= atof(Cmd_Argv(4));
+ color[0] *= atof(Cmd_Argv(cmd, 2));
+ color[1] *= atof(Cmd_Argv(cmd, 3));
+ color[2] *= atof(Cmd_Argv(cmd, 4));
}
}
- else if (!strcmp(Cmd_Argv(1), "radiusscale") || !strcmp(Cmd_Argv(1), "sizescale"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "radiusscale") || !strcmp(Cmd_Argv(cmd, 1), "sizescale"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- radius *= atof(Cmd_Argv(2));
+ radius *= atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "style"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "style"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- style = atoi(Cmd_Argv(2));
+ style = atoi(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "cubemap"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "cubemap"))
{
- if (Cmd_Argc() > 3)
+ if (Cmd_Argc(cmd) > 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- if (Cmd_Argc() == 3)
- strlcpy(cubemapname, Cmd_Argv(2), sizeof(cubemapname));
+ if (Cmd_Argc(cmd) == 3)
+ strlcpy(cubemapname, Cmd_Argv(cmd, 2), sizeof(cubemapname));
else
cubemapname[0] = 0;
}
- else if (!strcmp(Cmd_Argv(1), "shadows"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "shadows"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- shadows = Cmd_Argv(2)[0] == 'y' || Cmd_Argv(2)[0] == 'Y' || Cmd_Argv(2)[0] == 't' || atoi(Cmd_Argv(2));
+ shadows = Cmd_Argv(cmd, 2)[0] == 'y' || Cmd_Argv(cmd, 2)[0] == 'Y' || Cmd_Argv(cmd, 2)[0] == 't' || atoi(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "corona"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "corona"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- corona = atof(Cmd_Argv(2));
+ corona = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "coronasize"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "coronasize"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- coronasizescale = atof(Cmd_Argv(2));
+ coronasizescale = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "ambient"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "ambient"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- ambientscale = atof(Cmd_Argv(2));
+ ambientscale = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "diffuse"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "diffuse"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- diffusescale = atof(Cmd_Argv(2));
+ diffusescale = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "specular"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "specular"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- specularscale = atof(Cmd_Argv(2));
+ specularscale = atof(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "normalmode"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "normalmode"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- normalmode = Cmd_Argv(2)[0] == 'y' || Cmd_Argv(2)[0] == 'Y' || Cmd_Argv(2)[0] == 't' || atoi(Cmd_Argv(2));
+ normalmode = Cmd_Argv(cmd, 2)[0] == 'y' || Cmd_Argv(cmd, 2)[0] == 'Y' || Cmd_Argv(cmd, 2)[0] == 't' || atoi(Cmd_Argv(cmd, 2));
}
- else if (!strcmp(Cmd_Argv(1), "realtimemode"))
+ else if (!strcmp(Cmd_Argv(cmd, 1), "realtimemode"))
{
- if (Cmd_Argc() != 3)
+ if (Cmd_Argc(cmd) != 3)
{
- Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(1));
+ Con_Printf("usage: r_editlights_edit %s value\n", Cmd_Argv(cmd, 1));
return;
}
- realtimemode = Cmd_Argv(2)[0] == 'y' || Cmd_Argv(2)[0] == 'Y' || Cmd_Argv(2)[0] == 't' || atoi(Cmd_Argv(2));
+ realtimemode = Cmd_Argv(cmd, 2)[0] == 'y' || Cmd_Argv(cmd, 2)[0] == 'Y' || Cmd_Argv(cmd, 2)[0] == 't' || atoi(Cmd_Argv(cmd, 2));
}
else
{
R_Shadow_UpdateWorldLight(r_shadow_selectedlight, origin, angles, color, radius, corona, style, shadows, cubemapname, coronasizescale, ambientscale, diffusescale, specularscale, flags);
}
-static void R_Shadow_EditLights_EditAll_f(void)
+static void R_Shadow_EditLights_EditAll_f(cmd_state_t *cmd)
{
size_t lightindex;
dlight_t *light, *oldselected;
if (!light)
continue;
R_Shadow_SelectLight(light);
- R_Shadow_EditLights_Edit_f();
+ R_Shadow_EditLights_Edit_f(&cmd_client);
}
// return to old selected (to not mess editing once selection is locked)
R_Shadow_SelectLight(oldselected);
dpsnprintf(temp, sizeof(temp), "BG stats : %i traces %i hits\n", r_shadow_selectedlight->rtlight.bouncegrid_traces, r_shadow_selectedlight->rtlight.bouncegrid_hits); DrawQ_String(x, y, temp, 0, 8, 8, 1, 1, 1, 1, 0, NULL, true, FONT_DEFAULT); y += 8;
}
-static void R_Shadow_EditLights_ToggleShadow_f(void)
+static void R_Shadow_EditLights_ToggleShadow_f(cmd_state_t *cmd)
{
if (!r_editlights.integer)
{
R_Shadow_UpdateWorldLight(r_shadow_selectedlight, r_shadow_selectedlight->origin, r_shadow_selectedlight->angles, r_shadow_selectedlight->color, r_shadow_selectedlight->radius, r_shadow_selectedlight->corona, r_shadow_selectedlight->style, !r_shadow_selectedlight->shadow, r_shadow_selectedlight->cubemapname, r_shadow_selectedlight->coronasizescale, r_shadow_selectedlight->ambientscale, r_shadow_selectedlight->diffusescale, r_shadow_selectedlight->specularscale, r_shadow_selectedlight->flags);
}
-static void R_Shadow_EditLights_ToggleCorona_f(void)
+static void R_Shadow_EditLights_ToggleCorona_f(cmd_state_t *cmd)
{
if (!r_editlights.integer)
{
R_Shadow_UpdateWorldLight(r_shadow_selectedlight, r_shadow_selectedlight->origin, r_shadow_selectedlight->angles, r_shadow_selectedlight->color, r_shadow_selectedlight->radius, !r_shadow_selectedlight->corona, r_shadow_selectedlight->style, r_shadow_selectedlight->shadow, r_shadow_selectedlight->cubemapname, r_shadow_selectedlight->coronasizescale, r_shadow_selectedlight->ambientscale, r_shadow_selectedlight->diffusescale, r_shadow_selectedlight->specularscale, r_shadow_selectedlight->flags);
}
-static void R_Shadow_EditLights_Remove_f(void)
+static void R_Shadow_EditLights_Remove_f(cmd_state_t *cmd)
{
if (!r_editlights.integer)
{
r_shadow_selectedlight = NULL;
}
-static void R_Shadow_EditLights_Help_f(void)
+static void R_Shadow_EditLights_Help_f(cmd_state_t *cmd)
{
Con_Print(
"Documentation on r_editlights system:\n"
);
}
-static void R_Shadow_EditLights_CopyInfo_f(void)
+static void R_Shadow_EditLights_CopyInfo_f(cmd_state_t *cmd)
{
if (!r_editlights.integer)
{
r_shadow_bufferlight.flags = r_shadow_selectedlight->flags;
}
-static void R_Shadow_EditLights_PasteInfo_f(void)
+static void R_Shadow_EditLights_PasteInfo_f(cmd_state_t *cmd)
{
if (!r_editlights.integer)
{
R_Shadow_UpdateWorldLight(r_shadow_selectedlight, r_shadow_selectedlight->origin, r_shadow_bufferlight.angles, r_shadow_bufferlight.color, r_shadow_bufferlight.radius, r_shadow_bufferlight.corona, r_shadow_bufferlight.style, r_shadow_bufferlight.shadow, r_shadow_bufferlight.cubemapname, r_shadow_bufferlight.coronasizescale, r_shadow_bufferlight.ambientscale, r_shadow_bufferlight.diffusescale, r_shadow_bufferlight.specularscale, r_shadow_bufferlight.flags);
}
-static void R_Shadow_EditLights_Lock_f(void)
+static void R_Shadow_EditLights_Lock_f(cmd_state_t *cmd)
{
if (!r_editlights.integer)
{
Cvar_RegisterVariable(&r_editlights_current_specular);
Cvar_RegisterVariable(&r_editlights_current_normalmode);
Cvar_RegisterVariable(&r_editlights_current_realtimemode);
- Cmd_AddCommand("r_editlights_help", R_Shadow_EditLights_Help_f, "prints documentation on console commands and variables in rtlight editing system");
- Cmd_AddCommand("r_editlights_clear", R_Shadow_EditLights_Clear_f, "removes all world lights (let there be darkness!)");
- Cmd_AddCommand("r_editlights_reload", R_Shadow_EditLights_Reload_f, "reloads rtlights file (or imports from .lights file or .ent file or the map itself)");
- Cmd_AddCommand("r_editlights_save", R_Shadow_EditLights_Save_f, "save .rtlights file for current level");
- Cmd_AddCommand("r_editlights_spawn", R_Shadow_EditLights_Spawn_f, "creates a light with default properties (let there be light!)");
- Cmd_AddCommand("r_editlights_edit", R_Shadow_EditLights_Edit_f, "changes a property on the selected light");
- Cmd_AddCommand("r_editlights_editall", R_Shadow_EditLights_EditAll_f, "changes a property on ALL lights at once (tip: use radiusscale and colorscale to alter these properties)");
- Cmd_AddCommand("r_editlights_remove", R_Shadow_EditLights_Remove_f, "remove selected light");
- Cmd_AddCommand("r_editlights_toggleshadow", R_Shadow_EditLights_ToggleShadow_f, "toggle on/off the shadow option on the selected light");
- Cmd_AddCommand("r_editlights_togglecorona", R_Shadow_EditLights_ToggleCorona_f, "toggle on/off the corona option on the selected light");
- Cmd_AddCommand("r_editlights_importlightentitiesfrommap", R_Shadow_EditLights_ImportLightEntitiesFromMap_f, "load lights from .ent file or map entities (ignoring .rtlights or .lights file)");
- Cmd_AddCommand("r_editlights_importlightsfile", R_Shadow_EditLights_ImportLightsFile_f, "load lights from .lights file (ignoring .rtlights or .ent files and map entities)");
- Cmd_AddCommand("r_editlights_copyinfo", R_Shadow_EditLights_CopyInfo_f, "store a copy of all properties (except origin) of the selected light");
- Cmd_AddCommand("r_editlights_pasteinfo", R_Shadow_EditLights_PasteInfo_f, "apply the stored properties onto the selected light (making it exactly identical except for origin)");
- Cmd_AddCommand("r_editlights_lock", R_Shadow_EditLights_Lock_f, "lock selection to current light, if already locked - unlock");
+ Cmd_AddCommand(&cmd_client, "r_editlights_help", R_Shadow_EditLights_Help_f, "prints documentation on console commands and variables in rtlight editing system");
+ Cmd_AddCommand(&cmd_client, "r_editlights_clear", R_Shadow_EditLights_Clear_f, "removes all world lights (let there be darkness!)");
+ Cmd_AddCommand(&cmd_client, "r_editlights_reload", R_Shadow_EditLights_Reload_f, "reloads rtlights file (or imports from .lights file or .ent file or the map itself)");
+ Cmd_AddCommand(&cmd_client, "r_editlights_save", R_Shadow_EditLights_Save_f, "save .rtlights file for current level");
+ Cmd_AddCommand(&cmd_client, "r_editlights_spawn", R_Shadow_EditLights_Spawn_f, "creates a light with default properties (let there be light!)");
+ Cmd_AddCommand(&cmd_client, "r_editlights_edit", R_Shadow_EditLights_Edit_f, "changes a property on the selected light");
+ Cmd_AddCommand(&cmd_client, "r_editlights_editall", R_Shadow_EditLights_EditAll_f, "changes a property on ALL lights at once (tip: use radiusscale and colorscale to alter these properties)");
+ Cmd_AddCommand(&cmd_client, "r_editlights_remove", R_Shadow_EditLights_Remove_f, "remove selected light");
+ Cmd_AddCommand(&cmd_client, "r_editlights_toggleshadow", R_Shadow_EditLights_ToggleShadow_f, "toggle on/off the shadow option on the selected light");
+ Cmd_AddCommand(&cmd_client, "r_editlights_togglecorona", R_Shadow_EditLights_ToggleCorona_f, "toggle on/off the corona option on the selected light");
+ Cmd_AddCommand(&cmd_client, "r_editlights_importlightentitiesfrommap", R_Shadow_EditLights_ImportLightEntitiesFromMap_f, "load lights from .ent file or map entities (ignoring .rtlights or .lights file)");
+ Cmd_AddCommand(&cmd_client, "r_editlights_importlightsfile", R_Shadow_EditLights_ImportLightsFile_f, "load lights from .lights file (ignoring .rtlights or .ent files and map entities)");
+ Cmd_AddCommand(&cmd_client, "r_editlights_copyinfo", R_Shadow_EditLights_CopyInfo_f, "store a copy of all properties (except origin) of the selected light");
+ Cmd_AddCommand(&cmd_client, "r_editlights_pasteinfo", R_Shadow_EditLights_PasteInfo_f, "apply the stored properties onto the selected light (making it exactly identical except for origin)");
+ Cmd_AddCommand(&cmd_client, "r_editlights_lock", R_Shadow_EditLights_Lock_f, "lock selection to current light, if already locked - unlock");
}
}
// LadyHavoc: added LoadSky console command
-static void LoadSky_f (void)
+static void LoadSky_f(cmd_state_t *cmd)
{
- switch (Cmd_Argc())
+ switch (Cmd_Argc(cmd))
{
case 1:
if (skyname[0])
Con_Print("no skybox has been set\n");
break;
case 2:
- if (R_SetSkyBox(Cmd_Argv(1)))
+ if (R_SetSkyBox(Cmd_Argv(cmd, 1)))
{
if (skyname[0])
Con_Printf("skybox set to %s\n", skyname);
Con_Print("skybox disabled\n");
}
else
- Con_Printf("failed to load skybox %s\n", Cmd_Argv(1));
+ Con_Printf("failed to load skybox %s\n", Cmd_Argv(cmd, 1));
break;
default:
Con_Print("usage: loadsky skyname\n");
void R_Sky_Init(void)
{
- Cmd_AddCommand ("loadsky", &LoadSky_f, "load a skybox by basename (for example loadsky mtnsun_ loads mtnsun_ft.tga and so on)");
+ Cmd_AddCommand(&cmd_client, "loadsky", &LoadSky_f, "load a skybox by basename (for example loadsky mtnsun_ loads mtnsun_ft.tga and so on)");
Cvar_RegisterVariable (&r_sky);
Cvar_RegisterVariable (&r_skyscroll1);
Cvar_RegisterVariable (&r_skyscroll2);
void Font_Init(void);
qboolean R_CompileShader_CheckStaticParms(void);
-void R_GLSL_Restart_f(void);
+void R_GLSL_Restart_f(cmd_state_t *cmd);
#endif
Tab key down
===============
*/
-static void Sbar_ShowScores (void)
+static void Sbar_ShowScores_f(cmd_state_t *cmd)
{
if (sb_showscores)
return;
Tab key up
===============
*/
-static void Sbar_DontShowScores (void)
+static void Sbar_DontShowScores_f(cmd_state_t *cmd)
{
sb_showscores = false;
CL_VM_UpdateShowingScoresState(sb_showscores);
void Sbar_Init (void)
{
- Cmd_AddCommand("+showscores", Sbar_ShowScores, "show scoreboard");
- Cmd_AddCommand("-showscores", Sbar_DontShowScores, "hide scoreboard");
+ Cmd_AddCommand(&cmd_client, "+showscores", Sbar_ShowScores_f, "show scoreboard");
+ Cmd_AddCommand(&cmd_client, "-showscores", Sbar_DontShowScores_f, "hide scoreboard");
Cvar_RegisterVariable(&showfps);
Cvar_RegisterVariable(&showsound);
Cvar_RegisterVariable(&showblur);
void S_FreeSfx (sfx_t *sfx, qboolean force);
-static void S_Play_Common (float fvol, float attenuation)
+static void S_Play_Common (cmd_state_t *cmd, float fvol, float attenuation)
{
int i, ch_ind;
char name [MAX_QPATH];
sfx_t *sfx;
i = 1;
- while (i < Cmd_Argc ())
+ while (i < Cmd_Argc (cmd))
{
// Get the name, and appends ".wav" as an extension if there's none
- strlcpy (name, Cmd_Argv (i), sizeof (name));
+ strlcpy (name, Cmd_Argv(cmd, i), sizeof (name));
if (!strrchr (name, '.'))
strlcat (name, ".wav", sizeof (name));
i++;
// If we need to get the volume from the command line
if (fvol == -1.0f)
{
- fvol = atof (Cmd_Argv (i));
+ fvol = atof (Cmd_Argv(cmd, i));
i++;
}
}
}
-static void S_Play_f(void)
+static void S_Play_f(cmd_state_t *cmd)
{
- S_Play_Common (1.0f, 1.0f);
+ S_Play_Common(cmd, 1.0f, 1.0f);
}
-static void S_Play2_f(void)
+static void S_Play2_f(cmd_state_t *cmd)
{
- S_Play_Common (1.0f, 0.0f);
+ S_Play_Common(cmd, 1.0f, 0.0f);
}
-static void S_PlayVol_f(void)
+static void S_PlayVol_f(cmd_state_t *cmd)
{
- S_Play_Common (-1.0f, 0.0f);
+ S_Play_Common(cmd, -1.0f, 0.0f);
}
-static void S_SoundList_f (void)
+static void S_SoundList_f(cmd_state_t *cmd)
{
unsigned int i;
sfx_t *sfx;
}
-static void S_SoundInfo_f(void)
+static void S_SoundInfo_f(cmd_state_t *cmd)
{
if (snd_renderbuffer == NULL)
{
sound_spatialized = false;
}
-static void S_Restart_f(void)
+static void S_Restart_f(cmd_state_t *cmd)
{
// NOTE: we can't free all sounds if we are running a map (this frees sfx_t that are still referenced by precaches)
// So, refuse to do this if we are connected.
if (COM_CheckParm("-nosound"))
{
// dummy out Play and Play2 because mods stuffcmd that
- Cmd_AddCommand("play", Host_NoOperation_f, "does nothing because -nosound was specified");
- Cmd_AddCommand("play2", Host_NoOperation_f, "does nothing because -nosound was specified");
+ Cmd_AddCommand(&cmd_client, "play", Host_NoOperation_f, "does nothing because -nosound was specified");
+ Cmd_AddCommand(&cmd_client, "play2", Host_NoOperation_f, "does nothing because -nosound was specified");
return;
}
if (COM_CheckParm("-simsound"))
simsound = true;
- Cmd_AddCommand("play", S_Play_f, "play a sound at your current location (not heard by anyone else)");
- Cmd_AddCommand("play2", S_Play2_f, "play a sound globally throughout the level (not heard by anyone else)");
- Cmd_AddCommand("playvol", S_PlayVol_f, "play a sound at the specified volume level at your current location (not heard by anyone else)");
- Cmd_AddCommand("stopsound", S_StopAllSounds, "silence");
- Cmd_AddCommand("soundlist", S_SoundList_f, "list loaded sounds");
- Cmd_AddCommand("soundinfo", S_SoundInfo_f, "print sound system information (such as channels and speed)");
- Cmd_AddCommand("snd_restart", S_Restart_f, "restart sound system");
- Cmd_AddCommand("snd_unloadallsounds", S_UnloadAllSounds_f, "unload all sound files");
+ Cmd_AddCommand(&cmd_client, "play", S_Play_f, "play a sound at your current location (not heard by anyone else)");
+ Cmd_AddCommand(&cmd_client, "play2", S_Play2_f, "play a sound globally throughout the level (not heard by anyone else)");
+ Cmd_AddCommand(&cmd_client, "playvol", S_PlayVol_f, "play a sound at the specified volume level at your current location (not heard by anyone else)");
+ Cmd_AddCommand(&cmd_client, "stopsound", S_StopAllSounds_f, "silence");
+ Cmd_AddCommand(&cmd_client, "soundlist", S_SoundList_f, "list loaded sounds");
+ Cmd_AddCommand(&cmd_client, "soundinfo", S_SoundInfo_f, "print sound system information (such as channels and speed)");
+ Cmd_AddCommand(&cmd_client, "snd_restart", S_Restart_f, "restart sound system");
+ Cmd_AddCommand(&cmd_client, "snd_unloadallsounds", S_UnloadAllSounds_f, "unload all sound files");
Cvar_RegisterVariable(&nosound);
Cvar_RegisterVariable(&snd_precache);
S_UnloadAllSounds_f
==================
*/
-void S_UnloadAllSounds_f (void)
+void S_UnloadAllSounds_f(cmd_state_t *cmd)
{
int i;
}
}
-void S_StopAllSounds (void)
+void S_StopAllSounds(void)
{
unsigned int i;
}
}
+void S_StopAllSounds_f(cmd_state_t *cmd)
+{
+ S_StopAllSounds();
+}
+
+
void S_PauseGameSounds (qboolean toggle)
{
unsigned int i;
void S_Startup (void);
void S_Shutdown (void);
-void S_UnloadAllSounds_f (void);
+void S_UnloadAllSounds_f(cmd_state_t *cmd);
void S_Update(const matrix4x4_t *listenermatrix);
void S_ExtraUpdate (void);
void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void S_StopSound (int entnum, int entchannel);
void S_StopAllSounds (void);
+void S_StopAllSounds_f(cmd_state_t *cmd);
void S_PauseGameSounds (qboolean toggle);
void S_StopChannel (unsigned int channel_ind, qboolean lockmutex, qboolean freesfx);
#include "csprogs.h"
#include "thread.h"
-static void SV_SaveEntFile_f(void);
-static void SV_StartDownload_f(void);
-static void SV_Download_f(void);
+static void SV_SaveEntFile_f(cmd_state_t *cmd);
+static void SV_StartDownload_f(cmd_state_t *cmd);
+static void SV_Download_f(cmd_state_t *cmd);
static void SV_VM_Setup(void);
extern cvar_t net_connecttimeout;
//============================================================================
-static void SV_AreaStats_f(void)
+static void SV_AreaStats_f(cmd_state_t *cmd)
{
World_PrintAreaStats(&sv.world, "server");
}
Cvar_RegisterVariable (&csqc_progsize);
Cvar_RegisterVariable (&csqc_usedemoprogs);
- Cmd_AddCommand("sv_saveentfile", SV_SaveEntFile_f, "save map entities to .ent file (to allow external editing)");
- Cmd_AddCommand("sv_areastats", SV_AreaStats_f, "prints statistics on entity culling during collision traces");
- Cmd_AddCommand_WithClientCommand("sv_startdownload", NULL, SV_StartDownload_f, "begins sending a file to the client (network protocol use only)");
- Cmd_AddCommand_WithClientCommand("download", NULL, SV_Download_f, "downloads a specified file from the server");
+ Cmd_AddCommand(&cmd_server, "sv_saveentfile", SV_SaveEntFile_f, "save map entities to .ent file (to allow external editing)");
+ Cmd_AddCommand(&cmd_server, "sv_areastats", SV_AreaStats_f, "prints statistics on entity culling during collision traces");
+ Cmd_AddCommand(&cmd_serverfromclient, "sv_startdownload", SV_StartDownload_f, "begins sending a file to the client (network protocol use only)");
+ Cmd_AddCommand(&cmd_serverfromclient, "download", SV_Download_f, "downloads a specified file from the server");
+ Cmd_AddCommand(&cmd_client, "sv_startdownload", Cmd_ForwardToServer_f, "begins sending a file to the client (network protocol use only)");
+ Cmd_AddCommand(&cmd_client, "download", Cmd_ForwardToServer_f, "downloads a specified file from the server");
Cvar_RegisterVariable (&sv_disablenotify);
Cvar_RegisterVariable (&coop);
sv_mempool = Mem_AllocPool("server", 0, NULL);
}
-static void SV_SaveEntFile_f(void)
+static void SV_SaveEntFile_f(cmd_state_t *cmd)
{
char vabuf[1024];
if (!sv.active || !sv.worldmodel)
SV_CleanupEnts();
}
-static void SV_StartDownload_f(void)
+static void SV_StartDownload_f(cmd_state_t *cmd)
{
if (host_client->download_file)
host_client->download_started = true;
* assume this extension is not supported!
*/
-static void Download_CheckExtensions(void)
+static void Download_CheckExtensions(cmd_state_t *cmd)
{
int i;
- int argc = Cmd_Argc();
+ int argc = Cmd_Argc(cmd);
// first reset them all
host_client->download_deflate = false;
for(i = 2; i < argc; ++i)
{
- if(!strcmp(Cmd_Argv(i), "deflate"))
+ if(!strcmp(Cmd_Argv(cmd, i), "deflate"))
{
host_client->download_deflate = true;
break;
}
}
-static void SV_Download_f(void)
+static void SV_Download_f(cmd_state_t *cmd)
{
const char *whichpack, *whichpack2, *extension;
qboolean is_csqc; // so we need to check only once
- if (Cmd_Argc() < 2)
+ if (Cmd_Argc(cmd) < 2)
{
SV_ClientPrintf("usage: download <filename> {<extensions>}*\n");
SV_ClientPrintf(" supported extensions: deflate\n");
return;
}
- if (FS_CheckNastyPath(Cmd_Argv(1), false))
+ if (FS_CheckNastyPath(Cmd_Argv(cmd, 1), false))
{
- SV_ClientPrintf("Download rejected: nasty filename \"%s\"\n", Cmd_Argv(1));
+ SV_ClientPrintf("Download rejected: nasty filename \"%s\"\n", Cmd_Argv(cmd, 1));
return;
}
host_client->download_started = false;
}
- is_csqc = (sv.csqc_progname[0] && strcmp(Cmd_Argv(1), sv.csqc_progname) == 0);
+ is_csqc = (sv.csqc_progname[0] && strcmp(Cmd_Argv(cmd, 1), sv.csqc_progname) == 0);
if (!sv_allowdownloads.integer && !is_csqc)
{
return;
}
- Download_CheckExtensions();
+ Download_CheckExtensions(cmd);
- strlcpy(host_client->download_name, Cmd_Argv(1), sizeof(host_client->download_name));
+ strlcpy(host_client->download_name, Cmd_Argv(cmd, 1), sizeof(host_client->download_name));
extension = FS_FileExtension(host_client->download_name);
// host_client is asking to download a specified file
if (strncasecmp(s, "spawn", 5) == 0
|| strncasecmp(s, "begin", 5) == 0
|| strncasecmp(s, "prespawn", 8) == 0)
- Cmd_ExecuteString (s, src_client, true);
+ Cmd_ExecuteString (&cmd_serverfromclient, s, src_client, true);
else if (PRVM_serverfunction(SV_ParseClientCommand))
{
int restorevm_tempstringsbuf_cursize;
prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
}
else
- Cmd_ExecuteString (s, src_client, true);
+ Cmd_ExecuteString (&cmd_serverfromclient, s, src_client, true);
break;
clc_stringcmd_invalid:
temp_client = host_client;
host_client = svs.clients + i;
- Cmd_ExecuteString (PRVM_G_STRING(OFS_PARM1), src_client, true);
+ Cmd_ExecuteString(&cmd_serverfromclient, PRVM_G_STRING(OFS_PARM1), src_client, true);
host_client = temp_client;
}
VM_fabs, // #43 float(float f) fabs (QUAKE)
VM_SV_aim, // #44 vector(entity e, float speed) aim (QUAKE)
VM_cvar, // #45 float(string s) cvar (QUAKE)
-VM_localcmd, // #46 void(string s) localcmd (QUAKE)
+VM_localcmd_server, // #46 void(string s) localcmd (QUAKE)
VM_nextent, // #47 entity(entity e) nextent (QUAKE)
VM_SV_particle, // #48 void(vector o, vector d, float color, float count) particle (QUAKE)
VM_changeyaw, // #49 void() ChangeYaw (QUAKE)
void Sys_Quit (int returnvalue)
{
// Unlock mutexes because the quit command may jump directly here, causing a deadlock
- Cbuf_UnlockThreadMutex();
+ if (cmd_client.text_lock)
+ Cbuf_Unlock(&cmd_client);
+ if (cmd_server.text_lock)
+ Cbuf_Unlock(&cmd_server);
SV_UnlockThreadMutex();
TaskQueue_Frame(true);
void VID_SetMouse (qboolean fullscreengrab, qboolean relative, qboolean hidecursor);
void VID_Finish (void);
-void VID_Restart_f(void);
+void VID_Restart_f(cmd_state_t *cmd);
void VID_Start(void);
void VID_Stop(void);
if (!VID_ShowingKeyboard())
{
// user entered a command, close the console now
- Con_ToggleConsole_f();
+ Con_ToggleConsole_f(&cmd_client);
}
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, NULL, &buttons[15], (keynum_t)0, NULL, 0, 0, 0, true);
VID_TouchscreenArea( 0, 0, 0, 0, 0, NULL , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
vid.width = event.window.data1;
vid.height = event.window.data2;
#ifdef SDL_R_RESTART
- // better not call R_Modules_Restart from here directly, as this may wreak havoc...
+ // better not call R_Modules_Restart_f from here directly, as this may wreak havoc...
// so, let's better queue it for next frame
if(!sdl_needs_restart)
{
- Cbuf_AddText("\nr_restart\n");
+ Cbuf_AddText(&cmd_client, "\nr_restart\n");
sdl_needs_restart = true;
}
#endif
}
-static void Force_CenterView_f (void)
+static void Force_CenterView_f(cmd_state_t *cmd)
{
cl.viewangles[PITCH] = 0;
}
Sys_LoadLibrary(xinputdllnames, &xinputdll_dll, xinputdllfuncs);
#endif
- Cmd_AddCommand("force_centerview", Force_CenterView_f, "recenters view (stops looking up/down)");
- Cmd_AddCommand("vid_restart", VID_Restart_f, "restarts video system (closes and reopens the window, restarts renderer)");
+ Cmd_AddCommand(&cmd_client, "force_centerview", Force_CenterView_f, "recenters view (stops looking up/down)");
+ Cmd_AddCommand(&cmd_client, "vid_restart", VID_Restart_f, "restarts video system (closes and reopens the window, restarts renderer)");
}
static int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate, int stereobuffer, int samples)
qboolean vid_commandlinecheck = true;
extern qboolean vid_opened;
-void VID_Restart_f(void)
+void VID_Restart_f(cmd_state_t *cmd)
{
char vabuf[1024];
char vabuf2[1024];
}
}
+void V_StartPitchDrift_f(cmd_state_t *cmd)
+{
+ V_StartPitchDrift();
+}
+
void V_StopPitchDrift (void)
{
cl.laststop = cl.time;
V_cshift_f
==================
*/
-static void V_cshift_f (void)
+static void V_cshift_f(cmd_state_t *cmd)
{
- v_cshift.destcolor[0] = atof(Cmd_Argv(1));
- v_cshift.destcolor[1] = atof(Cmd_Argv(2));
- v_cshift.destcolor[2] = atof(Cmd_Argv(3));
- v_cshift.percent = atof(Cmd_Argv(4));
+ v_cshift.destcolor[0] = atof(Cmd_Argv(cmd, 1));
+ v_cshift.destcolor[1] = atof(Cmd_Argv(cmd, 2));
+ v_cshift.destcolor[2] = atof(Cmd_Argv(cmd, 3));
+ v_cshift.percent = atof(Cmd_Argv(cmd, 4));
}
When you run over an item, the server sends this command
==================
*/
-static void V_BonusFlash_f (void)
+static void V_BonusFlash_f(cmd_state_t *cmd)
{
- if(Cmd_Argc() == 1)
+ if(Cmd_Argc(cmd) == 1)
{
cl.cshifts[CSHIFT_BONUS].destcolor[0] = 215;
cl.cshifts[CSHIFT_BONUS].destcolor[1] = 186;
cl.cshifts[CSHIFT_BONUS].percent = 50;
cl.cshifts[CSHIFT_BONUS].alphafade = 100;
}
- else if(Cmd_Argc() >= 4 && Cmd_Argc() <= 6)
+ else if(Cmd_Argc(cmd) >= 4 && Cmd_Argc(cmd) <= 6)
{
- cl.cshifts[CSHIFT_BONUS].destcolor[0] = atof(Cmd_Argv(1)) * 255;
- cl.cshifts[CSHIFT_BONUS].destcolor[1] = atof(Cmd_Argv(2)) * 255;
- cl.cshifts[CSHIFT_BONUS].destcolor[2] = atof(Cmd_Argv(3)) * 255;
- if(Cmd_Argc() >= 5)
- cl.cshifts[CSHIFT_BONUS].percent = atof(Cmd_Argv(4)) * 255; // yes, these are HEXADECIMAL percent ;)
+ cl.cshifts[CSHIFT_BONUS].destcolor[0] = atof(Cmd_Argv(cmd, 1)) * 255;
+ cl.cshifts[CSHIFT_BONUS].destcolor[1] = atof(Cmd_Argv(cmd, 2)) * 255;
+ cl.cshifts[CSHIFT_BONUS].destcolor[2] = atof(Cmd_Argv(cmd, 3)) * 255;
+ if(Cmd_Argc(cmd) >= 5)
+ cl.cshifts[CSHIFT_BONUS].percent = atof(Cmd_Argv(cmd, 4)) * 255; // yes, these are HEXADECIMAL percent ;)
else
cl.cshifts[CSHIFT_BONUS].percent = 50;
- if(Cmd_Argc() >= 6)
- cl.cshifts[CSHIFT_BONUS].alphafade = atof(Cmd_Argv(5)) * 255;
+ if(Cmd_Argc(cmd) >= 6)
+ cl.cshifts[CSHIFT_BONUS].alphafade = atof(Cmd_Argv(cmd, 5)) * 255;
else
cl.cshifts[CSHIFT_BONUS].alphafade = 100;
}
*/
void V_Init (void)
{
- Cmd_AddCommand ("v_cshift", V_cshift_f, "sets tint color of view");
- Cmd_AddCommand ("bf", V_BonusFlash_f, "briefly flashes a bright color tint on view (used when items are picked up); optionally takes R G B [A [alphafade]] arguments to specify how the flash looks");
- Cmd_AddCommand ("centerview", V_StartPitchDrift, "gradually recenter view (stop looking up/down)");
+ Cmd_AddCommand(&cmd_client, "v_cshift", V_cshift_f, "sets tint color of view");
+ Cmd_AddCommand(&cmd_client, "bf", V_BonusFlash_f, "briefly flashes a bright color tint on view (used when items are picked up); optionally takes R G B [A [alphafade]] arguments to specify how the flash looks");
+ Cmd_AddCommand(&cmd_client, "centerview", V_StartPitchDrift_f, "gradually recenter view (stop looking up/down)");
+
+ Cmd_AddCommand(&cmd_clientfromserver, "v_cshift", V_cshift_f, "sets tint color of view");
+ Cmd_AddCommand(&cmd_clientfromserver, "bf", V_BonusFlash_f, "briefly flashes a bright color tint on view (used when items are picked up); optionally takes R G B [A [alphafade]] arguments to specify how the flash looks");
Cvar_RegisterVariable (&v_centermove);
Cvar_RegisterVariable (&v_centerspeed);
}
}
-static void MemList_f(void)
+static void MemList_f(cmd_state_t *cmd)
{
- switch(Cmd_Argc())
+ switch(Cmd_Argc(cmd))
{
case 1:
Mem_PrintList(1<<30);
Mem_PrintStats();
break;
case 2:
- Mem_PrintList(atoi(Cmd_Argv(1)) * 1024);
+ Mem_PrintList(atoi(Cmd_Argv(cmd, 1)) * 1024);
Mem_PrintStats();
break;
default:
}
}
-static void MemStats_f(void)
+static void MemStats_f(cmd_state_t *cmd)
{
Mem_CheckSentinelsGlobal();
R_TextureStats_Print(false, false, true);
void Memory_Init_Commands (void)
{
- Cmd_AddCommand ("memstats", MemStats_f, "prints memory system statistics");
- Cmd_AddCommand ("memlist", MemList_f, "prints memory pool information (or if used as memlist 5 lists individual allocations of 5K or larger, 0 lists all allocations)");
+ Cmd_AddCommand(&cmd_client, "memstats", MemStats_f, "prints memory system statistics");
+ Cmd_AddCommand(&cmd_client, "memlist", MemList_f, "prints memory pool information (or if used as memlist 5 lists individual allocations of 5K or larger, 0 lists all allocations)");
+
+ Cmd_AddCommand(&cmd_server, "memstats", MemStats_f, "prints memory system statistics");
+ Cmd_AddCommand(&cmd_server, "memlist", MemList_f, "prints memory pool information (or if used as memlist 5 lists individual allocations of 5K or larger, 0 lists all allocations)");
+
Cvar_RegisterVariable (&developer_memory);
Cvar_RegisterVariable (&developer_memorydebug);
Cvar_RegisterVariable (&developer_memoryreportlargerthanmb);