More conversion
This commit is contained in:
+20
-20
@@ -29,7 +29,7 @@
|
||||
#define MUSIC_DIRNAME "music"
|
||||
|
||||
qboolean bgmloop;
|
||||
cvar_t bgm_extmusic = {"bgm_extmusic", "1", CVAR_ARCHIVE};
|
||||
convar bgm_extmusic{"bgm_extmusic", "1", {.archive = true}};
|
||||
|
||||
static qboolean no_extmusic= false;
|
||||
static float old_volume = -1.0f;
|
||||
@@ -76,8 +76,8 @@ static snd_stream_t *bgmstream = NULL;
|
||||
|
||||
static void BGM_Play_f (void)
|
||||
{
|
||||
if (Cmd_Argc() == 2) {
|
||||
BGM_Play (Cmd_Argv(1));
|
||||
if (command::argc() == 2) {
|
||||
BGM_Play (command::argv(1)->c_str());
|
||||
}
|
||||
else {
|
||||
Con_Printf ("music <musicfile>\n");
|
||||
@@ -96,14 +96,14 @@ static void BGM_Resume_f (void)
|
||||
|
||||
static void BGM_Loop_f (void)
|
||||
{
|
||||
if (Cmd_Argc() == 2) {
|
||||
if (q_strcasecmp(Cmd_Argv(1), "0") == 0 ||
|
||||
q_strcasecmp(Cmd_Argv(1),"off") == 0)
|
||||
if (command::argc() == 2) {
|
||||
if (q_strcasecmp(command::argv(1)->c_str(), "0") == 0 ||
|
||||
q_strcasecmp(command::argv(1)->c_str(),"off") == 0)
|
||||
bgmloop = false;
|
||||
else if (q_strcasecmp(Cmd_Argv(1), "1") == 0 ||
|
||||
q_strcasecmp(Cmd_Argv(1),"on") == 0)
|
||||
else if (q_strcasecmp(command::argv(1)->c_str(), "1") == 0 ||
|
||||
q_strcasecmp(command::argv(1)->c_str(),"on") == 0)
|
||||
bgmloop = true;
|
||||
else if (q_strcasecmp(Cmd_Argv(1),"toggle") == 0)
|
||||
else if (q_strcasecmp(command::argv(1)->c_str(),"toggle") == 0)
|
||||
bgmloop = !bgmloop;
|
||||
|
||||
if (bgmstream) bgmstream->loop = bgmloop;
|
||||
@@ -122,11 +122,11 @@ static void BGM_Stop_f (void)
|
||||
|
||||
static void BGM_Jump_f (void)
|
||||
{
|
||||
if (Cmd_Argc() != 2) {
|
||||
if (command::argc() != 2) {
|
||||
Con_Printf ("music_jump <ordernum>\n");
|
||||
}
|
||||
else if (bgmstream) {
|
||||
S_CodecJumpToOrder(bgmstream, atoi(Cmd_Argv(1)));
|
||||
S_CodecJumpToOrder(bgmstream, atoi(command::argv(1)->c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,13 +135,13 @@ qboolean BGM_Init (void)
|
||||
music_handler_t *handlers = NULL;
|
||||
int i;
|
||||
|
||||
Cvar_RegisterVariable(&bgm_extmusic);
|
||||
Cmd_AddCommand("music", BGM_Play_f);
|
||||
Cmd_AddCommand("music_pause", BGM_Pause_f);
|
||||
Cmd_AddCommand("music_resume", BGM_Resume_f);
|
||||
Cmd_AddCommand("music_loop", BGM_Loop_f);
|
||||
Cmd_AddCommand("music_stop", BGM_Stop_f);
|
||||
Cmd_AddCommand("music_jump", BGM_Jump_f);
|
||||
bgm_extmusic.inscribe();
|
||||
command::add("music", BGM_Play_f);
|
||||
command::add("music_pause", BGM_Pause_f);
|
||||
command::add("music_resume", BGM_Resume_f);
|
||||
command::add("music_loop", BGM_Loop_f);
|
||||
command::add("music_stop", BGM_Stop_f);
|
||||
command::add("music_jump", BGM_Jump_f);
|
||||
|
||||
if (COM_CheckParm("-noextmusic") != 0)
|
||||
no_extmusic = true;
|
||||
@@ -467,9 +467,9 @@ void BGM_Update (void)
|
||||
if (old_volume != bgmvolume.value)
|
||||
{
|
||||
if (bgmvolume.value < 0)
|
||||
Cvar_SetQuick (&bgmvolume, "0");
|
||||
bgmvolume.set("0");
|
||||
else if (bgmvolume.value > 1)
|
||||
Cvar_SetQuick (&bgmvolume, "1");
|
||||
bgmvolume.set("1");
|
||||
old_volume = bgmvolume.value;
|
||||
}
|
||||
if (bgmstream)
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
#define _BGMUSIC_H_
|
||||
|
||||
extern qboolean bgmloop;
|
||||
extern cvar_t bgm_extmusic;
|
||||
extern convar bgm_extmusic;
|
||||
|
||||
qboolean BGM_Init (void);
|
||||
void BGM_Shutdown (void);
|
||||
|
||||
+7
-7
@@ -221,7 +221,7 @@ static void CD_f (void)
|
||||
const char *command;
|
||||
int ret, n;
|
||||
|
||||
if (Cmd_Argc() < 2)
|
||||
if (command::argc() < 2)
|
||||
{
|
||||
Con_Printf("commands:");
|
||||
Con_Printf("on, off, reset, remap, \n");
|
||||
@@ -230,7 +230,7 @@ static void CD_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
command = Cmd_Argv (1);
|
||||
command = command::argv (1)->c_str();
|
||||
|
||||
if (q_strcasecmp(command, "on") == 0)
|
||||
{
|
||||
@@ -259,7 +259,7 @@ static void CD_f (void)
|
||||
|
||||
if (q_strcasecmp(command, "remap") == 0)
|
||||
{
|
||||
ret = Cmd_Argc() - 2;
|
||||
ret = command::argc() - 2;
|
||||
if (ret <= 0)
|
||||
{
|
||||
for (n = 1; n < 100; n++)
|
||||
@@ -268,7 +268,7 @@ static void CD_f (void)
|
||||
return;
|
||||
}
|
||||
for (n = 1; n <= ret; n++)
|
||||
remap[n] = atoi(Cmd_Argv (n + 1));
|
||||
remap[n] = atoi(command::argv (n + 1)->c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ static void CD_f (void)
|
||||
|
||||
if (q_strcasecmp(command, "play") == 0)
|
||||
{
|
||||
n = atoi(Cmd_Argv (2));
|
||||
n = atoi(command::argv (2)->c_str());
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
CDAudio_Play((byte)n, false);
|
||||
@@ -293,7 +293,7 @@ static void CD_f (void)
|
||||
|
||||
if (q_strcasecmp(command, "loop") == 0)
|
||||
{
|
||||
CDAudio_Play((byte)atoi(Cmd_Argv (2)), true);
|
||||
CDAudio_Play((byte)atoi(command::argv (2)->c_str()), true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ int CDAudio_Init(void)
|
||||
cdValid = false;
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("cd", CD_f);
|
||||
command::add ("cd", CD_f);
|
||||
|
||||
hw_vol_works = CD_GetVolume (NULL); /* no SDL support at present. */
|
||||
if (hw_vol_works)
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@ void CFG_ReadCvars (const char **vars, int num_vars)
|
||||
tmp = strchr(buff, '\"');
|
||||
if (tmp)
|
||||
{
|
||||
Cvar_Set (vars[i], tmp + 1);
|
||||
convar::set(vars[i], tmp + 1);
|
||||
j++;
|
||||
break;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void CFG_ReadCvarOverrides (const char **vars, int num_vars)
|
||||
if (j != 0 && j < com_argc - 1)
|
||||
{
|
||||
if (com_argv[j + 1][0] != '-' && com_argv[j + 1][0] != '+')
|
||||
Cvar_Set(vars[i], com_argv[j + 1]);
|
||||
convar::set(vars[i], com_argv[j + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -23,10 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
cvar_t chase_back = {"chase_back", "100", CVAR_NONE};
|
||||
cvar_t chase_up = {"chase_up", "16", CVAR_NONE};
|
||||
cvar_t chase_right = {"chase_right", "0", CVAR_NONE};
|
||||
cvar_t chase_active = {"chase_active", "0", CVAR_NONE};
|
||||
convar chase_back{"chase_back", "100"};
|
||||
convar chase_up{"chase_up", "16"};
|
||||
convar chase_right{"chase_right", "0"};
|
||||
convar chase_active{"chase_active", "0"};
|
||||
|
||||
/*
|
||||
==============
|
||||
@@ -35,10 +35,10 @@ Chase_Init
|
||||
*/
|
||||
void Chase_Init (void)
|
||||
{
|
||||
Cvar_RegisterVariable (&chase_back);
|
||||
Cvar_RegisterVariable (&chase_up);
|
||||
Cvar_RegisterVariable (&chase_right);
|
||||
Cvar_RegisterVariable (&chase_active);
|
||||
chase_back.inscribe();
|
||||
chase_up.inscribe();
|
||||
chase_right.inscribe();
|
||||
chase_active.inscribe();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+13
-12
@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
@@ -202,7 +203,7 @@ stop recording a demo
|
||||
*/
|
||||
void CL_Stop_f (void)
|
||||
{
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (!cls.demorecording)
|
||||
@@ -239,7 +240,7 @@ void CL_Record_f (void)
|
||||
char name[MAX_OSPATH];
|
||||
int track;
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (cls.demoplayback)
|
||||
@@ -251,14 +252,14 @@ void CL_Record_f (void)
|
||||
if (cls.demorecording)
|
||||
CL_Stop_f();
|
||||
|
||||
c = Cmd_Argc();
|
||||
c = command::argc();
|
||||
if (c != 2 && c != 3 && c != 4)
|
||||
{
|
||||
Con_Printf ("record <demoname> [<map> [cd track]]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(Cmd_Argv(1), ".."))
|
||||
if (strstr(command::argv(1).value_or("").c_str(), ".."))
|
||||
{
|
||||
Con_Printf ("Relative pathnames are not allowed.\n");
|
||||
return;
|
||||
@@ -280,7 +281,7 @@ void CL_Record_f (void)
|
||||
// write the forced cd track number, or -1
|
||||
if (c == 4)
|
||||
{
|
||||
track = atoi(Cmd_Argv(3));
|
||||
track = atoi(command::argv(3)->c_str());
|
||||
Con_Printf ("Forcing CD track to %i\n", cls.forcetrack);
|
||||
}
|
||||
else
|
||||
@@ -288,12 +289,12 @@ void CL_Record_f (void)
|
||||
track = -1;
|
||||
}
|
||||
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1).value_or("").c_str());
|
||||
|
||||
// start the map up
|
||||
if (c > 2)
|
||||
{
|
||||
Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command);
|
||||
command::execute_string ( std::format("map {:s}", *command::argv(2)), command::source::command);
|
||||
if (cls.state != ca_connected)
|
||||
return;
|
||||
}
|
||||
@@ -403,10 +404,10 @@ void CL_PlayDemo_f (void)
|
||||
{
|
||||
char name[MAX_OSPATH];
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("playdemo <demoname> : plays a demo\n");
|
||||
return;
|
||||
@@ -416,7 +417,7 @@ void CL_PlayDemo_f (void)
|
||||
CL_Disconnect ();
|
||||
|
||||
// open the demo file
|
||||
std::strncpy(name, Cmd_Argv(1), sizeof(name));
|
||||
std::strncpy(name, command::argv(1).value_or("").c_str(), sizeof(name));
|
||||
COM_AddExtension (name, ".dem", sizeof(name));
|
||||
|
||||
Con_Printf ("Playing demo from %s.\n", name);
|
||||
@@ -480,10 +481,10 @@ timedemo [demoname]
|
||||
*/
|
||||
void CL_TimeDemo_f (void)
|
||||
{
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("timedemo <demoname> : gets demo speeds\n");
|
||||
return;
|
||||
|
||||
+51
-52
@@ -26,8 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
extern cvar_t cl_maxpitch; //johnfitz -- variable pitch clamping
|
||||
extern cvar_t cl_minpitch; //johnfitz -- variable pitch clamping
|
||||
extern convar cl_maxpitch; //johnfitz -- variable pitch clamping
|
||||
extern convar cl_minpitch; //johnfitz -- variable pitch clamping
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
@@ -63,11 +63,10 @@ int in_impulse;
|
||||
void KeyDown (kbutton_t *b)
|
||||
{
|
||||
int k;
|
||||
const char *c;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
if (c[0])
|
||||
k = atoi(c);
|
||||
auto c = command::argv(1).value_or("");
|
||||
if (!c.empty())
|
||||
k = atoi(c.c_str());
|
||||
else
|
||||
k = -1; // typed manually at the console for continuous down
|
||||
|
||||
@@ -94,7 +93,7 @@ void KeyUp (kbutton_t *b)
|
||||
int k;
|
||||
const char *c;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
c = command::argv(1)->c_str();
|
||||
if (c[0])
|
||||
k = atoi(c);
|
||||
else
|
||||
@@ -161,7 +160,7 @@ void IN_UseUp (void) {KeyUp(&in_use);}
|
||||
void IN_JumpDown (void) {KeyDown(&in_jump);}
|
||||
void IN_JumpUp (void) {KeyUp(&in_jump);}
|
||||
|
||||
void IN_Impulse (void) {in_impulse=Q_atoi(Cmd_Argv(1));}
|
||||
void IN_Impulse (void) {in_impulse=Q_atoi(command::argv(1)->c_str());}
|
||||
|
||||
/*
|
||||
===============
|
||||
@@ -220,19 +219,19 @@ float CL_KeyState (kbutton_t *key)
|
||||
|
||||
//==========================================================================
|
||||
|
||||
cvar_t cl_upspeed = {"cl_upspeed","200",CVAR_NONE};
|
||||
cvar_t cl_forwardspeed = {"cl_forwardspeed","200", CVAR_ARCHIVE};
|
||||
cvar_t cl_backspeed = {"cl_backspeed","200", CVAR_ARCHIVE};
|
||||
cvar_t cl_sidespeed = {"cl_sidespeed","350",CVAR_NONE};
|
||||
convar cl_upspeed{"cl_upspeed","200"};
|
||||
convar cl_forwardspeed{"cl_forwardspeed","200", {.archive = true}};
|
||||
convar cl_backspeed{"cl_backspeed","200", {.archive = true}};
|
||||
convar cl_sidespeed{"cl_sidespeed","350"};
|
||||
|
||||
cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0",CVAR_NONE};
|
||||
convar cl_movespeedkey{"cl_movespeedkey","2.0"};
|
||||
|
||||
cvar_t cl_yawspeed = {"cl_yawspeed","140",CVAR_NONE};
|
||||
cvar_t cl_pitchspeed = {"cl_pitchspeed","150",CVAR_NONE};
|
||||
convar cl_yawspeed{"cl_yawspeed","140"};
|
||||
convar cl_pitchspeed{"cl_pitchspeed","150"};
|
||||
|
||||
cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5",CVAR_NONE};
|
||||
convar cl_anglespeedkey{"cl_anglespeedkey","1.5"};
|
||||
|
||||
cvar_t cl_alwaysrun = {"cl_alwaysrun","0",CVAR_ARCHIVE}; // QuakeSpasm -- new always run
|
||||
convar cl_alwaysrun{"cl_alwaysrun","0",{.archive = true}}; // QuakeSpasm -- new always run
|
||||
|
||||
/*
|
||||
================
|
||||
@@ -414,41 +413,41 @@ CL_InitInput
|
||||
*/
|
||||
void CL_InitInput (void)
|
||||
{
|
||||
Cmd_AddCommand ("+moveup",IN_UpDown);
|
||||
Cmd_AddCommand ("-moveup",IN_UpUp);
|
||||
Cmd_AddCommand ("+movedown",IN_DownDown);
|
||||
Cmd_AddCommand ("-movedown",IN_DownUp);
|
||||
Cmd_AddCommand ("+left",IN_LeftDown);
|
||||
Cmd_AddCommand ("-left",IN_LeftUp);
|
||||
Cmd_AddCommand ("+right",IN_RightDown);
|
||||
Cmd_AddCommand ("-right",IN_RightUp);
|
||||
Cmd_AddCommand ("+forward",IN_ForwardDown);
|
||||
Cmd_AddCommand ("-forward",IN_ForwardUp);
|
||||
Cmd_AddCommand ("+back",IN_BackDown);
|
||||
Cmd_AddCommand ("-back",IN_BackUp);
|
||||
Cmd_AddCommand ("+lookup", IN_LookupDown);
|
||||
Cmd_AddCommand ("-lookup", IN_LookupUp);
|
||||
Cmd_AddCommand ("+lookdown", IN_LookdownDown);
|
||||
Cmd_AddCommand ("-lookdown", IN_LookdownUp);
|
||||
Cmd_AddCommand ("+strafe", IN_StrafeDown);
|
||||
Cmd_AddCommand ("-strafe", IN_StrafeUp);
|
||||
Cmd_AddCommand ("+moveleft", IN_MoveleftDown);
|
||||
Cmd_AddCommand ("-moveleft", IN_MoveleftUp);
|
||||
Cmd_AddCommand ("+moveright", IN_MoverightDown);
|
||||
Cmd_AddCommand ("-moveright", IN_MoverightUp);
|
||||
Cmd_AddCommand ("+speed", IN_SpeedDown);
|
||||
Cmd_AddCommand ("-speed", IN_SpeedUp);
|
||||
Cmd_AddCommand ("+attack", IN_AttackDown);
|
||||
Cmd_AddCommand ("-attack", IN_AttackUp);
|
||||
Cmd_AddCommand ("+use", IN_UseDown);
|
||||
Cmd_AddCommand ("-use", IN_UseUp);
|
||||
Cmd_AddCommand ("+jump", IN_JumpDown);
|
||||
Cmd_AddCommand ("-jump", IN_JumpUp);
|
||||
Cmd_AddCommand ("impulse", IN_Impulse);
|
||||
Cmd_AddCommand ("+klook", IN_KLookDown);
|
||||
Cmd_AddCommand ("-klook", IN_KLookUp);
|
||||
Cmd_AddCommand ("+mlook", IN_MLookDown);
|
||||
Cmd_AddCommand ("-mlook", IN_MLookUp);
|
||||
command::add ("+moveup",IN_UpDown);
|
||||
command::add ("-moveup",IN_UpUp);
|
||||
command::add ("+movedown",IN_DownDown);
|
||||
command::add ("-movedown",IN_DownUp);
|
||||
command::add ("+left",IN_LeftDown);
|
||||
command::add ("-left",IN_LeftUp);
|
||||
command::add ("+right",IN_RightDown);
|
||||
command::add ("-right",IN_RightUp);
|
||||
command::add ("+forward",IN_ForwardDown);
|
||||
command::add ("-forward",IN_ForwardUp);
|
||||
command::add ("+back",IN_BackDown);
|
||||
command::add ("-back",IN_BackUp);
|
||||
command::add ("+lookup", IN_LookupDown);
|
||||
command::add ("-lookup", IN_LookupUp);
|
||||
command::add ("+lookdown", IN_LookdownDown);
|
||||
command::add ("-lookdown", IN_LookdownUp);
|
||||
command::add ("+strafe", IN_StrafeDown);
|
||||
command::add ("-strafe", IN_StrafeUp);
|
||||
command::add ("+moveleft", IN_MoveleftDown);
|
||||
command::add ("-moveleft", IN_MoveleftUp);
|
||||
command::add ("+moveright", IN_MoverightDown);
|
||||
command::add ("-moveright", IN_MoverightUp);
|
||||
command::add ("+speed", IN_SpeedDown);
|
||||
command::add ("-speed", IN_SpeedUp);
|
||||
command::add ("+attack", IN_AttackDown);
|
||||
command::add ("-attack", IN_AttackUp);
|
||||
command::add ("+use", IN_UseDown);
|
||||
command::add ("-use", IN_UseUp);
|
||||
command::add ("+jump", IN_JumpDown);
|
||||
command::add ("-jump", IN_JumpUp);
|
||||
command::add ("impulse", IN_Impulse);
|
||||
command::add ("+klook", IN_KLookDown);
|
||||
command::add ("-klook", IN_KLookUp);
|
||||
command::add ("+mlook", IN_MLookDown);
|
||||
command::add ("-mlook", IN_MLookUp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+52
-52
@@ -28,27 +28,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
// references them even when on a unix system.
|
||||
|
||||
// these two are not intended to be set directly
|
||||
cvar_t cl_name = {"_cl_name", "player", CVAR_ARCHIVE};
|
||||
cvar_t cl_color = {"_cl_color", "0", CVAR_ARCHIVE};
|
||||
convar cl_name{"_cl_name", "player", {.archive = true}};
|
||||
convar cl_color{"_cl_color", "0", {.archive = true}};
|
||||
|
||||
cvar_t cl_shownet = {"cl_shownet","0",CVAR_NONE}; // can be 0, 1, or 2
|
||||
cvar_t cl_nolerp = {"cl_nolerp","0",CVAR_NONE};
|
||||
convar cl_shownet{"cl_shownet","0"}; // can be 0, 1, or 2
|
||||
convar cl_nolerp{"cl_nolerp","0"};
|
||||
|
||||
cvar_t cfg_unbindall = {"cfg_unbindall", "1", CVAR_ARCHIVE};
|
||||
convar cfg_unbindall{"cfg_unbindall", "1", {.archive = true}};
|
||||
|
||||
cvar_t lookspring = {"lookspring","0", CVAR_ARCHIVE};
|
||||
cvar_t lookstrafe = {"lookstrafe","0", CVAR_ARCHIVE};
|
||||
cvar_t sensitivity = {"sensitivity","3", CVAR_ARCHIVE};
|
||||
convar lookspring{"lookspring","0", {.archive = true}};
|
||||
convar lookstrafe{"lookstrafe","0", {.archive = true}};
|
||||
convar sensitivity{"sensitivity","3", {.archive = true}};
|
||||
|
||||
cvar_t m_pitch = {"m_pitch","0.022", CVAR_ARCHIVE};
|
||||
cvar_t m_yaw = {"m_yaw","0.022", CVAR_ARCHIVE};
|
||||
cvar_t m_forward = {"m_forward","1", CVAR_ARCHIVE};
|
||||
cvar_t m_side = {"m_side","0.8", CVAR_ARCHIVE};
|
||||
convar m_pitch{"m_pitch","0.022", {.archive = true}};
|
||||
convar m_yaw{"m_yaw","0.022", {.archive = true}};
|
||||
convar m_forward{"m_forward","1", {.archive = true}};
|
||||
convar m_side{"m_side","0.8", {.archive = true}};
|
||||
|
||||
cvar_t cl_maxpitch = {"cl_maxpitch", "90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping
|
||||
cvar_t cl_minpitch = {"cl_minpitch", "-90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping
|
||||
convar cl_maxpitch{"cl_maxpitch", "90", {.archive = true}}; //johnfitz -- variable pitch clamping
|
||||
convar cl_minpitch{"cl_minpitch", "-90", {.archive = true}}; //johnfitz -- variable pitch clamping
|
||||
|
||||
cvar_t cl_startdemos = {"cl_startdemos", "1", CVAR_ARCHIVE};
|
||||
convar cl_startdemos{"cl_startdemos", "1", {.archive = true}};
|
||||
|
||||
client_static_t cls;
|
||||
client_state_t cl;
|
||||
@@ -63,7 +63,7 @@ int cl_max_edicts; //johnfitz -- only changes when new map loads
|
||||
int cl_numvisedicts;
|
||||
entity_t *cl_visedicts[MAX_VISEDICTS];
|
||||
|
||||
extern cvar_t r_lerpmodels, r_lerpmove; //johnfitz
|
||||
extern convar r_lerpmodels, r_lerpmove; //johnfitz
|
||||
|
||||
/*
|
||||
=====================
|
||||
@@ -651,13 +651,13 @@ int CL_ReadFromServer (void)
|
||||
if (cl_numvisedicts > 256 && dev_peakstats.visedicts <= 256)
|
||||
Con_DWarning ("%i visedicts exceeds standard limit of 256 (max = %d).\n", cl_numvisedicts, MAX_VISEDICTS);
|
||||
dev_stats.visedicts = cl_numvisedicts;
|
||||
dev_peakstats.visedicts = q_max(cl_numvisedicts, dev_peakstats.visedicts);
|
||||
dev_peakstats.visedicts = std::max(cl_numvisedicts, dev_peakstats.visedicts);
|
||||
|
||||
//temp entities
|
||||
if (num_temp_entities > 64 && dev_peakstats.tempents <= 64)
|
||||
Con_DWarning ("%i tempentities exceeds standard limit of 64 (max = %d).\n", num_temp_entities, MAX_TEMP_ENTITIES);
|
||||
dev_stats.tempents = num_temp_entities;
|
||||
dev_peakstats.tempents = q_max(num_temp_entities, dev_peakstats.tempents);
|
||||
dev_peakstats.tempents = std::max(num_temp_entities, dev_peakstats.tempents);
|
||||
|
||||
//beams
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
@@ -666,7 +666,7 @@ int CL_ReadFromServer (void)
|
||||
if (num_beams > 24 && dev_peakstats.beams <= 24)
|
||||
Con_DWarning ("%i beams exceeded standard limit of 24 (max = %d).\n", num_beams, MAX_BEAMS);
|
||||
dev_stats.beams = num_beams;
|
||||
dev_peakstats.beams = q_max(num_beams, dev_peakstats.beams);
|
||||
dev_peakstats.beams = std::max(num_beams, dev_peakstats.beams);
|
||||
|
||||
//dlights
|
||||
for (i=0, l=cl_dlights ; i<MAX_DLIGHTS ; i++, l++)
|
||||
@@ -675,7 +675,7 @@ int CL_ReadFromServer (void)
|
||||
if (num_dlights > 32 && dev_peakstats.dlights <= 32)
|
||||
Con_DWarning ("%i dlights exceeded standard limit of 32 (max = %d).\n", num_dlights, MAX_DLIGHTS);
|
||||
dev_stats.dlights = num_dlights;
|
||||
dev_peakstats.dlights = q_max(num_dlights, dev_peakstats.dlights);
|
||||
dev_peakstats.dlights = std::max(num_dlights, dev_peakstats.dlights);
|
||||
|
||||
//johnfitz
|
||||
|
||||
@@ -798,44 +798,44 @@ void CL_Init (void)
|
||||
CL_InitInput ();
|
||||
CL_InitTEnts ();
|
||||
|
||||
Cvar_RegisterVariable (&cl_name);
|
||||
Cvar_RegisterVariable (&cl_color);
|
||||
Cvar_RegisterVariable (&cl_upspeed);
|
||||
Cvar_RegisterVariable (&cl_forwardspeed);
|
||||
Cvar_RegisterVariable (&cl_backspeed);
|
||||
Cvar_RegisterVariable (&cl_sidespeed);
|
||||
Cvar_RegisterVariable (&cl_movespeedkey);
|
||||
Cvar_RegisterVariable (&cl_yawspeed);
|
||||
Cvar_RegisterVariable (&cl_pitchspeed);
|
||||
Cvar_RegisterVariable (&cl_anglespeedkey);
|
||||
Cvar_RegisterVariable (&cl_shownet);
|
||||
Cvar_RegisterVariable (&cl_nolerp);
|
||||
Cvar_RegisterVariable (&lookspring);
|
||||
Cvar_RegisterVariable (&lookstrafe);
|
||||
Cvar_RegisterVariable (&sensitivity);
|
||||
cl_name.inscribe();
|
||||
cl_color.inscribe();
|
||||
cl_upspeed.inscribe();
|
||||
cl_forwardspeed.inscribe();
|
||||
cl_backspeed.inscribe();
|
||||
cl_sidespeed.inscribe();
|
||||
cl_movespeedkey.inscribe();
|
||||
cl_yawspeed.inscribe();
|
||||
cl_pitchspeed.inscribe();
|
||||
cl_anglespeedkey.inscribe();
|
||||
cl_shownet.inscribe();
|
||||
cl_nolerp.inscribe();
|
||||
lookspring.inscribe();
|
||||
lookstrafe.inscribe();
|
||||
sensitivity.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&cl_alwaysrun);
|
||||
cl_alwaysrun.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&m_pitch);
|
||||
Cvar_RegisterVariable (&m_yaw);
|
||||
Cvar_RegisterVariable (&m_forward);
|
||||
Cvar_RegisterVariable (&m_side);
|
||||
m_pitch.inscribe();
|
||||
m_yaw.inscribe();
|
||||
m_forward.inscribe();
|
||||
m_side.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&cfg_unbindall);
|
||||
cfg_unbindall.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&cl_maxpitch); //johnfitz -- variable pitch clamping
|
||||
Cvar_RegisterVariable (&cl_minpitch); //johnfitz -- variable pitch clamping
|
||||
cl_maxpitch.inscribe(); //johnfitz -- variable pitch clamping
|
||||
cl_minpitch.inscribe(); //johnfitz -- variable pitch clamping
|
||||
|
||||
Cvar_RegisterVariable (&cl_startdemos);
|
||||
cl_startdemos.inscribe();
|
||||
|
||||
Cmd_AddCommand ("entities", CL_PrintEntities_f);
|
||||
Cmd_AddCommand ("disconnect", CL_Disconnect_f);
|
||||
Cmd_AddCommand ("record", CL_Record_f);
|
||||
Cmd_AddCommand ("stop", CL_Stop_f);
|
||||
Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
|
||||
Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
|
||||
command::add ("entities", CL_PrintEntities_f);
|
||||
command::add ("disconnect", CL_Disconnect_f);
|
||||
command::add ("record", CL_Record_f);
|
||||
command::add ("stop", CL_Stop_f);
|
||||
command::add ("playdemo", CL_PlayDemo_f);
|
||||
command::add ("timedemo", CL_TimeDemo_f);
|
||||
|
||||
Cmd_AddCommand ("tracepos", CL_Tracepos_f); //johnfitz
|
||||
Cmd_AddCommand ("viewpos", CL_Viewpos_f); //johnfitz
|
||||
command::add ("tracepos", CL_Tracepos_f); //johnfitz
|
||||
command::add ("viewpos", CL_Viewpos_f); //johnfitz
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1067,7 +1067,7 @@ void CL_ParseServerMessage(void) {
|
||||
cl_lightstyle[i].peak = 'a';
|
||||
for (j = 0; j < cl_lightstyle[i].length; j++) {
|
||||
total += cl_lightstyle[i].map[j] - 'a';
|
||||
cl_lightstyle[i].peak = q_max(cl_lightstyle[i].peak, cl_lightstyle[i].map[j]);
|
||||
cl_lightstyle[i].peak = std::max(cl_lightstyle[i].peak, cl_lightstyle[i].map[j]);
|
||||
}
|
||||
cl_lightstyle[i].average = total / cl_lightstyle[i].length + 'a';
|
||||
} else
|
||||
@@ -1214,7 +1214,7 @@ void CL_ParseServerMessage(void) {
|
||||
break;
|
||||
|
||||
case svc_sellscreen:
|
||||
Cmd_ExecuteString("help", src_command);
|
||||
command::execute_string("help", command::source::command);
|
||||
break;
|
||||
|
||||
//johnfitz -- new svc types
|
||||
@@ -1223,7 +1223,7 @@ void CL_ParseServerMessage(void) {
|
||||
break;
|
||||
|
||||
case svc_bf:
|
||||
Cmd_ExecuteString("bf", src_command);
|
||||
command::execute_string("bf", command::source::command);
|
||||
break;
|
||||
|
||||
case svc_fog:
|
||||
|
||||
+25
-25
@@ -230,41 +230,41 @@ typedef struct
|
||||
//
|
||||
// cvars
|
||||
//
|
||||
extern cvar_t cl_name;
|
||||
extern cvar_t cl_color;
|
||||
extern convar cl_name;
|
||||
extern convar cl_color;
|
||||
|
||||
extern cvar_t cl_upspeed;
|
||||
extern cvar_t cl_forwardspeed;
|
||||
extern cvar_t cl_backspeed;
|
||||
extern cvar_t cl_sidespeed;
|
||||
extern convar cl_upspeed;
|
||||
extern convar cl_forwardspeed;
|
||||
extern convar cl_backspeed;
|
||||
extern convar cl_sidespeed;
|
||||
|
||||
extern cvar_t cl_movespeedkey;
|
||||
extern convar cl_movespeedkey;
|
||||
|
||||
extern cvar_t cl_yawspeed;
|
||||
extern cvar_t cl_pitchspeed;
|
||||
extern convar cl_yawspeed;
|
||||
extern convar cl_pitchspeed;
|
||||
|
||||
extern cvar_t cl_anglespeedkey;
|
||||
extern convar cl_anglespeedkey;
|
||||
|
||||
extern cvar_t cl_alwaysrun; // QuakeSpasm
|
||||
extern convar cl_alwaysrun; // QuakeSpasm
|
||||
|
||||
extern cvar_t cl_autofire;
|
||||
extern convar cl_autofire;
|
||||
|
||||
extern cvar_t cl_shownet;
|
||||
extern cvar_t cl_nolerp;
|
||||
extern convar cl_shownet;
|
||||
extern convar cl_nolerp;
|
||||
|
||||
extern cvar_t cfg_unbindall;
|
||||
extern convar cfg_unbindall;
|
||||
|
||||
extern cvar_t cl_pitchdriftspeed;
|
||||
extern cvar_t lookspring;
|
||||
extern cvar_t lookstrafe;
|
||||
extern cvar_t sensitivity;
|
||||
extern convar cl_pitchdriftspeed;
|
||||
extern convar lookspring;
|
||||
extern convar lookstrafe;
|
||||
extern convar sensitivity;
|
||||
|
||||
extern cvar_t m_pitch;
|
||||
extern cvar_t m_yaw;
|
||||
extern cvar_t m_forward;
|
||||
extern cvar_t m_side;
|
||||
extern convar m_pitch;
|
||||
extern convar m_yaw;
|
||||
extern convar m_forward;
|
||||
extern convar m_side;
|
||||
|
||||
extern cvar_t cl_startdemos;
|
||||
extern convar cl_startdemos;
|
||||
|
||||
|
||||
#define MAX_TEMP_ENTITIES 256 //johnfitz -- was 64
|
||||
@@ -368,7 +368,7 @@ void CL_SignonReply (void);
|
||||
//
|
||||
// chase
|
||||
//
|
||||
extern cvar_t chase_active;
|
||||
extern convar chase_active;
|
||||
|
||||
void Chase_Init (void);
|
||||
void TraceLine (vec3_t start, vec3_t end, vec3_t impact);
|
||||
|
||||
+528
-707
File diff suppressed because it is too large
Load Diff
+50
-30
@@ -20,8 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _QUAKE_CMD_H
|
||||
#define _QUAKE_CMD_H
|
||||
#pragma once
|
||||
|
||||
// cmd.h -- Command buffer and command execution
|
||||
|
||||
@@ -72,56 +71,77 @@ not apropriate.
|
||||
|
||||
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);
|
||||
namespace command {
|
||||
enum class source {
|
||||
client,
|
||||
command
|
||||
};
|
||||
|
||||
extern source last_source;
|
||||
|
||||
struct alias {
|
||||
std::string name;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct definition {
|
||||
std::string name{};
|
||||
xcommand_t func{nullptr};
|
||||
|
||||
definition(const std::string &name, const xcommand_t func) {
|
||||
this->name = name;
|
||||
this->func = func;
|
||||
}
|
||||
};
|
||||
|
||||
using definition_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, definition, std::less<>>>, 1>;
|
||||
using alias_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, alias, std::less<>>>, 1>;
|
||||
|
||||
|
||||
void init();
|
||||
|
||||
void add(const std::string &name, xcommand_t cmd);
|
||||
std::optional<std::string> complete(const std::string &partial);
|
||||
bool exists(std::string_view lookup);
|
||||
|
||||
int argc();
|
||||
std::optional<std::string> argv(int arg);
|
||||
std::string args();
|
||||
|
||||
int check_parm(const std::string &parm);
|
||||
|
||||
void tokenize_string(const std::string &text);
|
||||
|
||||
void execute_string(const std::string &text, source src);
|
||||
|
||||
void forward_to_server();
|
||||
|
||||
definition_view get_commands();
|
||||
|
||||
alias_view get_aliases();
|
||||
}
|
||||
|
||||
void Cmd_AddCommand (const char *cmd_name, xcommand_t function);
|
||||
// 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
|
||||
|
||||
qboolean Cmd_Exists (const char *cmd_name);
|
||||
// used by the cvar code to check for cvar / command name overlap
|
||||
|
||||
const char *Cmd_CompleteCommand (const char *partial);
|
||||
// attempts to match a partial command for automatic command line completion
|
||||
// returns NULL if nothing fits
|
||||
|
||||
int Cmd_Argc (void);
|
||||
const char *Cmd_Argv (int arg);
|
||||
const char *Cmd_Args (void);
|
||||
// The functions that execute commands get their parameters with these
|
||||
// functions. Cmd_Argv () will return an empty string, not a NULL
|
||||
// if arg > argc, so string operations are allways safe.
|
||||
|
||||
int Cmd_CheckParm (const char *parm);
|
||||
// Returns the position (1 to argc-1) in the command's argument list
|
||||
// where the given parameter apears, or 0 if not present
|
||||
|
||||
void Cmd_TokenizeString (const char *text);
|
||||
// Takes a null terminated string. Does not need to be /n terminated.
|
||||
// breaks the string up into arg tokens.
|
||||
|
||||
void Cmd_ExecuteString (const char *text, cmd_source_t src);
|
||||
// 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_ForwardToServer (void);
|
||||
// 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_Print (const char *text);
|
||||
// used by command functions to send output to either the graphics console or
|
||||
// passed as a print message to the client
|
||||
|
||||
#endif /* _QUAKE_CMD_H */
|
||||
|
||||
|
||||
+1827
-2051
File diff suppressed because it is too large
Load Diff
+17
-43
@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef _Q_COMMON_H
|
||||
#define _Q_COMMON_H
|
||||
#include "convar.hpp"
|
||||
|
||||
// comndef.h -- general definitions
|
||||
|
||||
@@ -57,10 +58,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#define NO_COMMA
|
||||
|
||||
#define IMPL_GENERIC_FUNCS(type, suffix) \
|
||||
static inline type q_min_##suffix (type a, type b) { \
|
||||
static inline type std::min_##suffix (type a, type b) { \
|
||||
return (a < b) ? a : b; \
|
||||
} \
|
||||
static inline type q_max_##suffix (type a, type b) { \
|
||||
static inline type std::max_##suffix (type a, type b) { \
|
||||
return (a > b) ? a : b; \
|
||||
} \
|
||||
static inline type clamp_##suffix (type minval, type val, type maxval) { \
|
||||
@@ -69,30 +70,17 @@ static inline type clamp_##suffix (type minval, type val, type maxval) { \
|
||||
|
||||
GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA)
|
||||
|
||||
#define SELECT_Q_MIN(type, suffix) type: q_min_##suffix
|
||||
#define q_min(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_Q_MIN, COMMA))(a, b)
|
||||
#define SELECT_std::min(type, suffix) type: std::min_##suffix
|
||||
#define std::min(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_std::min, COMMA))(a, b)
|
||||
|
||||
#define SELECT_Q_MAX(type, suffix) type: q_max_##suffix
|
||||
#define q_max(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_Q_MAX, COMMA))(a, b)
|
||||
#define SELECT_std::max(type, suffix) type: std::max_##suffix
|
||||
#define std::max(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_std::max, COMMA))(a, b)
|
||||
|
||||
#define SELECT_CLAMP(type, suffix) type: clamp_##suffix
|
||||
#define CLAMP(minval, val, maxval) _Generic((minval) + (val) + (maxval), \
|
||||
GENERIC_TYPES (SELECT_CLAMP, COMMA))(minval, val, maxval)
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
/* min and max macros with type checking -- based on tyrquake. */
|
||||
#define q_max(a,b) ({ \
|
||||
const __typeof(a) a_ = (a); \
|
||||
const __typeof(b) b_ = (b); \
|
||||
(void)(&a_ == &b_); \
|
||||
(a_ > b_) ? a_ : b_; \
|
||||
})
|
||||
#define q_min(a,b) ({ \
|
||||
const __typeof(a) a_ = (a); \
|
||||
const __typeof(b) b_ = (b); \
|
||||
(void)(&a_ == &b_); \
|
||||
(a_ < b_) ? a_ : b_; \
|
||||
})
|
||||
#define CLAMP(_minval, x, _maxval) ({ \
|
||||
const __typeof(x) x_ = (x); \
|
||||
const __typeof(_minval) valmin_ = (_minval);\
|
||||
@@ -104,8 +92,8 @@ GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA)
|
||||
})
|
||||
|
||||
#else
|
||||
#define q_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define q_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define std::min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define std::max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define CLAMP(_minval, x, _maxval) \
|
||||
((x) < (_minval) ? (_minval) : \
|
||||
(x) > (_maxval) ? (_maxval) : (x))
|
||||
@@ -237,17 +225,16 @@ extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern char com_token[1024];
|
||||
extern qboolean com_eof;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CPE_NOTRUNC, // return parse error in case of overflow
|
||||
CPE_ALLOWTRUNC // truncate com_token in case of overflow
|
||||
} cpe_mode;
|
||||
|
||||
const char *COM_Parse (const char *data);
|
||||
const char *COM_ParseEx (const char *data, cpe_mode mode);
|
||||
namespace common {
|
||||
std::optional<std::string> parse_token(std::istringstream &ss);
|
||||
std::string parse_string_newline(std::istringstream &ss);
|
||||
|
||||
int parse_int_newline(std::istringstream &ss);
|
||||
float parse_float_newline(std::istringstream &ss);
|
||||
}
|
||||
|
||||
|
||||
extern int com_argc;
|
||||
@@ -358,19 +345,6 @@ byte *COM_LoadMallocFile (const char *path, unsigned int *path_id);
|
||||
// Loads in "t" mode so CRLF to LF translation is performed on Windows.
|
||||
byte *COM_LoadMallocFile_TextMode_OSPath (const char *path, long *len_out);
|
||||
|
||||
// Attempts to parse an int, followed by a newline.
|
||||
// Returns advanced buffer position.
|
||||
// Doesn't signal parsing failure, but this is not needed for savegame loading.
|
||||
const char *COM_ParseIntNewline(const char *buffer, int *value);
|
||||
|
||||
// Attempts to parse a float followed by a newline.
|
||||
// Returns advanced buffer position.
|
||||
const char *COM_ParseFloatNewline(const char *buffer, float *value);
|
||||
|
||||
// Parse a string of non-whitespace into com_token, then tries to consume a
|
||||
// newline. Returns advanced buffer position.
|
||||
const char *COM_ParseStringNewline(const char *buffer);
|
||||
|
||||
|
||||
#define FS_ENT_NONE (0)
|
||||
#define FS_ENT_FILE (1 << 0)
|
||||
@@ -403,7 +377,7 @@ char *FS_fgets(char *s, int size, fshandle_t *fh);
|
||||
long FS_filelength (fshandle_t *fh);
|
||||
|
||||
|
||||
extern struct cvar_s registered;
|
||||
extern convar registered;
|
||||
extern qboolean standard_quake, rogue, hipnotic;
|
||||
extern qboolean fitzmode;
|
||||
/* if true, run in fitzquake mode disabling custom quakespasm hacks */
|
||||
|
||||
+21
-37
@@ -50,8 +50,8 @@ int con_current; // where next message will be printed
|
||||
int con_x; // offset in current line for next print
|
||||
char *con_text = NULL;
|
||||
|
||||
cvar_t con_notifytime = {"con_notifytime","3",CVAR_NONE}; //seconds
|
||||
cvar_t con_logcenterprint = {"con_logcenterprint", "1", CVAR_NONE}; //johnfitz
|
||||
convar con_notifytime{"con_notifytime","3"}; //seconds
|
||||
convar con_logcenterprint{"con_logcenterprint", "1"}; //johnfitz
|
||||
|
||||
char con_lastcenterstring[1024]; //johnfitz
|
||||
|
||||
@@ -78,8 +78,8 @@ const char *Con_Quakebar (int len)
|
||||
static char bar[42];
|
||||
int i;
|
||||
|
||||
len = q_min(len, (int)sizeof(bar) - 2);
|
||||
len = q_min(len, con_linewidth);
|
||||
len = std::min(len, (int)sizeof(bar) - 2);
|
||||
len = std::min(len, con_linewidth);
|
||||
|
||||
bar[0] = '\35';
|
||||
for (i = 1; i < len - 1; i++)
|
||||
@@ -331,14 +331,14 @@ void Con_Init (void)
|
||||
|
||||
Con_Printf ("Console initialized.\n");
|
||||
|
||||
Cvar_RegisterVariable (&con_notifytime);
|
||||
Cvar_RegisterVariable (&con_logcenterprint); //johnfitz
|
||||
con_notifytime.inscribe();
|
||||
con_logcenterprint.inscribe(); //johnfitz
|
||||
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
|
||||
Cmd_AddCommand ("messagemode", Con_MessageMode_f);
|
||||
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f);
|
||||
Cmd_AddCommand ("clear", Con_Clear_f);
|
||||
Cmd_AddCommand ("condump", Con_Dump_f); //johnfitz
|
||||
command::add ("toggleconsole", Con_ToggleConsole_f);
|
||||
command::add ("messagemode", Con_MessageMode_f);
|
||||
command::add ("messagemode2", Con_MessageMode2_f);
|
||||
command::add ("clear", Con_Clear_f);
|
||||
command::add ("condump", Con_Dump_f); //johnfitz
|
||||
con_initialized = true;
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ void Con_CenterPrintf (int linewidth, const char *fmt, ...)
|
||||
q_vsnprintf (msg, sizeof(msg), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
linewidth = q_min(linewidth, con_linewidth);
|
||||
linewidth = std::min(linewidth, con_linewidth);
|
||||
for (src = msg; *src; )
|
||||
{
|
||||
dst = line;
|
||||
@@ -727,21 +727,7 @@ tab_t *tablist;
|
||||
|
||||
//defs from elsewhere
|
||||
extern qboolean keydown[256];
|
||||
typedef struct cmd_function_s
|
||||
{
|
||||
struct cmd_function_s *next;
|
||||
const char *name;
|
||||
xcommand_t function;
|
||||
} cmd_function_t;
|
||||
extern cmd_function_t *cmd_functions;
|
||||
#define MAX_ALIAS_NAME 32
|
||||
typedef struct cmdalias_s
|
||||
{
|
||||
struct cmdalias_s *next;
|
||||
char name[MAX_ALIAS_NAME];
|
||||
char *value;
|
||||
} cmdalias_t;
|
||||
extern cmdalias_t *cmd_alias;
|
||||
|
||||
/*
|
||||
============
|
||||
@@ -897,8 +883,6 @@ BuildTabList -- johnfitz
|
||||
*/
|
||||
void BuildTabList (const char *partial)
|
||||
{
|
||||
cmdalias_t *alias;
|
||||
cmd_function_t *cmd;
|
||||
int len;
|
||||
|
||||
tablist = NULL;
|
||||
@@ -907,17 +891,17 @@ void BuildTabList (const char *partial)
|
||||
bash_partial[0] = 0;
|
||||
bash_singlematch = 1;
|
||||
|
||||
for (auto cvar : std::ranges::views::values(CLIENT_VARIABLES))
|
||||
if (!Q_strncmp (partial, cvar->name, len))
|
||||
AddToTabList (cvar->name, "cvar");
|
||||
for (const auto cvar : convar::get_variables())
|
||||
if (!Q_strncmp (partial, cvar->name.c_str(), len))
|
||||
AddToTabList (cvar->name.c_str(), "cvar");
|
||||
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
if (!Q_strncmp (partial,cmd->name, len))
|
||||
AddToTabList (cmd->name, "command");
|
||||
for (const auto &ccmd : command::get_commands())
|
||||
if (!Q_strncmp (partial,ccmd.name.c_str(), len))
|
||||
AddToTabList (ccmd.name.c_str(), "command");
|
||||
|
||||
for (alias=cmd_alias ; alias ; alias=alias->next)
|
||||
if (!Q_strncmp (partial, alias->name, len))
|
||||
AddToTabList (alias->name, "alias");
|
||||
for (const auto &alias : command::get_aliases())
|
||||
if (!Q_strncmp (partial, alias.name.c_str(), len))
|
||||
AddToTabList (alias.name.c_str(), "alias");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,540 @@
|
||||
/*
|
||||
Copyright (C) 1996-2001 Id Software, Inc.
|
||||
Copyright (C) 2002-2009 John Fitzgibbons and others
|
||||
Copyright (C) 2010-2014 QuakeSpasm developers
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// cvar.c -- dynamic variable tracking
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <ranges>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include <format>
|
||||
|
||||
std::map<std::string, convar *> CLIENT_VARIABLES{};
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
// USER COMMANDS
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_List_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_List_f() {
|
||||
convar *cvar;
|
||||
const char *partial;
|
||||
int len, count;
|
||||
|
||||
if (command::argc() > 1) {
|
||||
partial = command::argv(1)->c_str();
|
||||
len = Q_strlen(partial);
|
||||
} else {
|
||||
partial = NULL;
|
||||
len = 0;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for (const auto &[name, var]: CLIENT_VARIABLES) {
|
||||
if (partial && Q_strncmp(partial, name.c_str(), len)) {
|
||||
continue;
|
||||
}
|
||||
Con_SafePrintf("%s%s %s \"%s\"\n",
|
||||
var->flags.archive ? "*" : " ",
|
||||
var->flags.notify ? "s" : " ",
|
||||
name.c_str(),
|
||||
var->string);
|
||||
count++;
|
||||
}
|
||||
|
||||
Con_SafePrintf("%i cvars", count);
|
||||
if (partial) {
|
||||
Con_SafePrintf(" beginning with \"%s\"", partial);
|
||||
}
|
||||
Con_SafePrintf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Inc_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Inc_f(void) {
|
||||
switch (command::argc()) {
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("inc <cvar> [amount] : increment cvar\n");
|
||||
break;
|
||||
case 2:
|
||||
convar::set_value(*command::argv(1), convar::variable_value(*command::argv(1)).value_or(0.0) + 1);
|
||||
break;
|
||||
case 3:
|
||||
convar::set_value(*command::argv(1), convar::variable_value(*command::argv(1)).value_or(0.0) + Q_atof(command::argv(2)->c_str()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Toggle_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Toggle_f() {
|
||||
switch (command::argc()) {
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("toggle <cvar> : toggle cvar\n");
|
||||
break;
|
||||
case 2:
|
||||
if (convar::variable_value(*command::argv(1)).value_or(0.0) != 0.0)
|
||||
convar::set(*command::argv(1), "0");
|
||||
else
|
||||
convar::set(*command::argv(1), "1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Cycle_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Cycle_f() {
|
||||
int i;
|
||||
|
||||
if (command::argc() < 3) {
|
||||
Con_Printf("cycle <cvar> <value list>: cycle cvar through a list of values\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//loop through the args until you find one that matches the current cvar value.
|
||||
//yes, this will get stuck on a list that contains the same value twice.
|
||||
//it's not worth dealing with, and i'm not even sure it can be dealt with.
|
||||
for (i = 2; i < command::argc(); i++) {
|
||||
//zero is assumed to be a string, even though it could actually be zero. The worst case
|
||||
//is that the first time you call this command, it won't match on zero when it should, but after that,
|
||||
//it will be comparing strings that all had the same source (the user) so it will work.
|
||||
if (Q_atof(command::argv(i)->c_str()) == 0) {
|
||||
if (!strcmp(command::argv(i)->c_str(), convar::variable_string(*command::argv(1)).value_or("").c_str()))
|
||||
break;
|
||||
} else {
|
||||
if (Q_atof(command::argv(i)->c_str()) == convar::variable_value(*command::argv(1)).value_or(0.0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == command::argc())
|
||||
convar::set(*command::argv(1), *command::argv(2)); // no match
|
||||
else if (i + 1 == command::argc())
|
||||
convar::set(*command::argv(1), *command::argv(2)); // matched last value in list
|
||||
else
|
||||
convar::set(*command::argv(1), *command::argv(i + 1)); // matched earlier in list
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Reset_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Reset_f() {
|
||||
switch (command::argc()) {
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("reset <cvar> : reset cvar to default\n");
|
||||
break;
|
||||
case 2:
|
||||
convar::reset(*command::argv(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_ResetAll_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_ResetAll_f(void) {
|
||||
convar *var;
|
||||
|
||||
for (auto name: std::views::keys(CLIENT_VARIABLES))
|
||||
convar::reset(name);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_ResetCfg_f -- QuakeSpasm
|
||||
============
|
||||
*/
|
||||
void Cvar_ResetCfg_f() {
|
||||
for (const auto &var: std::views::values(CLIENT_VARIABLES))
|
||||
if (var->flags.archive) convar::reset(var->name);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
// INIT
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Init -- johnfitz
|
||||
============
|
||||
*/
|
||||
|
||||
void Cvar_Init() {
|
||||
command::add("cvarlist", Cvar_List_f);
|
||||
command::add("toggle", Cvar_Toggle_f);
|
||||
command::add("cycle", Cvar_Cycle_f);
|
||||
command::add("inc", Cvar_Inc_f);
|
||||
command::add("reset", Cvar_Reset_f);
|
||||
command::add("resetall", Cvar_ResetAll_f);
|
||||
command::add("resetcfg", Cvar_ResetCfg_f);
|
||||
}
|
||||
|
||||
std::optional<convar *> convar::find_var(const std::string_view &desired) {
|
||||
for (auto &[name, var]: CLIENT_VARIABLES) {
|
||||
if (name == desired)
|
||||
return var;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<convar *> convar::find_var_after(const std::optional<std::string> &prev_name,
|
||||
const std::optional<cvar_flags> with_flags) {
|
||||
auto iter = CLIENT_VARIABLES.begin();
|
||||
if (prev_name.has_value()) {
|
||||
iter = CLIENT_VARIABLES.find(prev_name.value());
|
||||
if (iter == CLIENT_VARIABLES.end())
|
||||
return std::nullopt;
|
||||
++iter;
|
||||
}
|
||||
|
||||
// search for the next cvar matching the needed flags
|
||||
while (iter != CLIENT_VARIABLES.end()) {
|
||||
if (!with_flags.has_value() || iter->second->flags.matches_mask(with_flags.value()))
|
||||
break;
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (iter != CLIENT_VARIABLES.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void convar::lock_var(const std::string_view &name) {
|
||||
if (const auto var = find_var(name); var.has_value())
|
||||
var.value()->flags.locked = true;
|
||||
}
|
||||
|
||||
void convar::unlock_var(const std::string_view &name) {
|
||||
if (const auto var = find_var(name); var.has_value())
|
||||
var.value()->flags.locked = false;
|
||||
}
|
||||
|
||||
void convar::unlock_all() {
|
||||
for (const auto &var: std::views::values(CLIENT_VARIABLES)) {
|
||||
var->flags.locked = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a floating-point representation of the `string` value of the `convar` matching `name`.
|
||||
*
|
||||
* @param name The name of the variable to retreive
|
||||
* @return The value of the variable matching `name`, or `std::nullopt` if a variable with
|
||||
* that name cannot be found.
|
||||
*/
|
||||
std::optional<float> convar::variable_value(const std::string_view &name) {
|
||||
const auto var = find_var(name);
|
||||
if (!var.has_value())
|
||||
return std::nullopt;
|
||||
return std::strtof(var.value()->string, nullptr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the `string` value of the `convar` matching `name`.
|
||||
*
|
||||
* @param name The name of the variable to retreive
|
||||
* @return The value of the variable matching `name`, or `std::nullopt` if a variable with
|
||||
* that name cannot be found.
|
||||
*/
|
||||
std::optional<std::string> convar::variable_string(const std::string_view &name) {
|
||||
const auto var = find_var(name);
|
||||
if (!var.has_value())
|
||||
return std::nullopt;
|
||||
return var.value()->string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autocompletes the name of a `convar` starting with `partial`.
|
||||
*
|
||||
* @param partial Partial name of a variable to retrieve
|
||||
* @return The full name of the first variable beginning with `partial`, or `std::nullopt` if
|
||||
* no matching variable is found.
|
||||
*/
|
||||
std::optional<std::string_view> convar::complete_variable(const std::string_view &partial) {
|
||||
if (!partial.empty())
|
||||
return std::nullopt;
|
||||
|
||||
// check functions
|
||||
for (const auto &name: CLIENT_VARIABLES | std::views::keys) {
|
||||
if (name.starts_with(name))
|
||||
return name;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets a `convar`s `string` to its `default_string` value.
|
||||
*
|
||||
* @param name Name of the convar to reset
|
||||
*/
|
||||
void convar::reset(const std::string &name) {
|
||||
if (const auto var = find_var(name); !var.has_value())
|
||||
Con_Printf("variable \"%s\" not found\n", name.c_str());
|
||||
else
|
||||
var.value()->set(var.value()->default_string);
|
||||
}
|
||||
|
||||
void convar::set(const std::string &new_value) {
|
||||
if (this->flags.rom || this->flags.locked)
|
||||
return;
|
||||
if (!(this->flags.registered))
|
||||
return;
|
||||
|
||||
if (!this->string)
|
||||
this->string = Z_Strdup(new_value.c_str());
|
||||
else {
|
||||
if (!strcmp(this->string, new_value.c_str()))
|
||||
return; // no change
|
||||
|
||||
this->flags.changed = true;
|
||||
|
||||
const std::size_t len = new_value.length();
|
||||
|
||||
if (len != Q_strlen(this->string)) {
|
||||
Z_Free((void *) this->string);
|
||||
this->string = (char *) Z_Malloc(len + 1);
|
||||
}
|
||||
memcpy((char *) this->string, new_value.c_str(), len + 1);
|
||||
}
|
||||
|
||||
this->value = Q_atof(this->string);
|
||||
|
||||
//johnfitz -- save initial value for "reset" command
|
||||
if (!this->default_string)
|
||||
this->default_string = Z_Strdup(this->string);
|
||||
//johnfitz -- during initialization, update default too
|
||||
else if (!host_initialized) {
|
||||
// Sys_Printf("changing default of %s: %s -> %s\n",
|
||||
// this->name, this->default_string, this->string);
|
||||
Z_Free((void *) this->default_string);
|
||||
this->default_string = Z_Strdup(this->string);
|
||||
}
|
||||
//johnfitz
|
||||
|
||||
if (this->callback)
|
||||
this->callback(this);
|
||||
}
|
||||
|
||||
void convar::set_value(const float new_value) {
|
||||
std::string val;
|
||||
|
||||
if (new_value == static_cast<float>(static_cast<int>(new_value)))
|
||||
val = std::format("{:d}", static_cast<int>(new_value));
|
||||
else {
|
||||
val = std::format("{:f}", new_value);
|
||||
|
||||
// kill trailing zeroes
|
||||
val.erase(val.find_last_not_of('0') + 1, std::string::npos);
|
||||
}
|
||||
|
||||
this->set(val);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Set
|
||||
============
|
||||
*/
|
||||
void convar::set(const std::string &name, const std::string &value) {
|
||||
const auto var = find_var(name);
|
||||
if (!var.has_value()) {
|
||||
// there is an error in C code if this happens
|
||||
Con_Printf("Cvar_Set: variable %s not found\n", name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
var.value()->set(value);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
convar::set_value
|
||||
============
|
||||
*/
|
||||
void convar::set_value(const std::string &name, const float new_value) {
|
||||
std::string val;
|
||||
|
||||
if (new_value == static_cast<float>(static_cast<int>(new_value)))
|
||||
val = std::format("{:d}", static_cast<int>(new_value));
|
||||
else {
|
||||
val = std::format("{:f}", new_value);
|
||||
|
||||
// kill trailing zeroes
|
||||
val.erase(val.find_last_not_of('0') + 1, std::string::npos);
|
||||
}
|
||||
|
||||
set(name, val);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_SetROM
|
||||
============
|
||||
*/
|
||||
void convar::set_rom(const std::string_view &name, const std::string value) {
|
||||
if (const auto var = find_var(name); var.has_value()) {
|
||||
var.value()->flags.rom = false;
|
||||
var.value()->set(value);
|
||||
var.value()->flags.rom = true;
|
||||
}
|
||||
}
|
||||
|
||||
void convar::set_value_rom(const std::string_view &name, const float value) {
|
||||
if (const auto var = find_var(name); var.has_value()) {
|
||||
var.value()->flags.rom = false;
|
||||
var.value()->set_value(value);
|
||||
var.value()->flags.rom = true;
|
||||
}
|
||||
}
|
||||
|
||||
convar_view convar::get_variables() {
|
||||
return std::ranges::views::values(CLIENT_VARIABLES);
|
||||
}
|
||||
|
||||
convar::convar(const std::string_view name, const char *str) : convar(name, str, {}) {
|
||||
}
|
||||
|
||||
convar::convar(const std::string_view name, const char *str, const cvar_flags flags) {
|
||||
this->name = name;
|
||||
this->string = str;
|
||||
this->flags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a freestanding variable to the variable list.
|
||||
*/
|
||||
void convar::inscribe() {
|
||||
char value[512];
|
||||
convar *cursor, *prev; //johnfitz -- sorted list insert
|
||||
|
||||
// first check to see if it has already been defined
|
||||
if (find_var(this->name)) {
|
||||
Con_Printf("Can't register variable %s, already defined\n", this->name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// check for overlap with a command
|
||||
if (command::exists(this->name)) {
|
||||
Con_Printf("Cvar_RegisterVariable: %s is a command\n", this->name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
CLIENT_VARIABLES.emplace(std::string(this->name), this);
|
||||
|
||||
//johnfitz
|
||||
this->flags.registered = true;
|
||||
|
||||
// copy the value off, because future sets will Z_Free it
|
||||
std::strncpy(value, this->string, sizeof(value));
|
||||
this->string = nullptr;
|
||||
this->default_string = nullptr;
|
||||
|
||||
if (!this->flags.callback)
|
||||
this->callback = nullptr;
|
||||
|
||||
// set it through the function to be consistent
|
||||
const bool set_rom = (this->flags.rom);
|
||||
this->flags.rom = false;
|
||||
this->set(value);
|
||||
if (set_rom)
|
||||
this->flags.rom = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback function for the variable
|
||||
* @param func Callback to be used (or `nullptr` to disable to callback).
|
||||
*/
|
||||
void convar::set_callback(const cvarcallback_t func) {
|
||||
this->callback = func;
|
||||
this->flags.callback = func != nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Command
|
||||
|
||||
Handles variable inspection and changing from the console
|
||||
============
|
||||
*/
|
||||
qboolean Cvar_Command() {
|
||||
// check variables
|
||||
auto var = convar::find_var(command::argv(0).value_or(""));
|
||||
if (!var.has_value())
|
||||
return false;
|
||||
|
||||
// perform a variable print or set
|
||||
if (command::argc() == 1) {
|
||||
Con_Printf("\"%s\" is \"%s\"\n", var.value()->name.c_str(), var.value()->string);
|
||||
return true;
|
||||
}
|
||||
|
||||
convar::set(var.value()->name, *command::argv(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_WriteVariables
|
||||
|
||||
Writes lines containing "set variable value" for all variables
|
||||
with the archive flag set to true.
|
||||
============
|
||||
*/
|
||||
void Cvar_WriteVariables(FILE *f) {
|
||||
for (const auto &[name, var]: CLIENT_VARIABLES) {
|
||||
if (var->flags.archive)
|
||||
fprintf(f, "%s \"%s\"\n", name.c_str(), var->string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Copyright (C) 1996-2001 Id Software, Inc.
|
||||
Copyright (C) 2002-2009 John Fitzgibbons and others
|
||||
Copyright (C) 2010-2014 QuakeSpasm developers
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
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 in C code.
|
||||
|
||||
it is sufficient to initialize a cvar_t with just the first two fields,
|
||||
or you can add a ,true flag for variables that you want saved to the
|
||||
configuration file when the game is quit:
|
||||
|
||||
cvar_t r_draworder = {"r_draworder","1"};
|
||||
cvar_t scr_screensize = {"screensize","1",true};
|
||||
|
||||
Cvars must be registered before use, or they will have a 0 value instead
|
||||
of the float interpretation of the string.
|
||||
Generally, all cvar_t declarations should be registered in the apropriate
|
||||
init function before any console commands are executed:
|
||||
|
||||
host_framerate.inscribe();
|
||||
|
||||
C code usually just references a cvar in place:
|
||||
if ( r_draworder.value )
|
||||
|
||||
It could optionally ask for the value to be looked up for a string name:
|
||||
if (Cvar_VariableValue ("r_draworder"))
|
||||
|
||||
Interpreted prog code can access cvars with the cvar(name) or
|
||||
cvar_set (name, value) internal functions:
|
||||
teamplay = cvar("teamplay");
|
||||
cvar_set ("registered", "1");
|
||||
|
||||
The user can access cvars from the console in two ways:
|
||||
r_draworder prints the current value
|
||||
r_draworder 0 sets the current value to 0
|
||||
|
||||
Cvars are restricted from having the same names as commands to keep this
|
||||
interface from being ambiguous.
|
||||
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <ranges>
|
||||
|
||||
#include "convar.hpp"
|
||||
|
||||
void Cvar_Init();
|
||||
|
||||
struct cvar_flags {
|
||||
bool archive{false};
|
||||
bool notify{false};
|
||||
bool server_info{false};
|
||||
bool user_info{false};
|
||||
bool changed{false};
|
||||
bool rom{false};
|
||||
bool locked{false};
|
||||
bool registered{false};
|
||||
bool callback{false};
|
||||
|
||||
[[nodiscard]] bool matches_mask(const cvar_flags &rhs) const {
|
||||
return (!rhs.archive || this->archive) &&
|
||||
(!rhs.notify || this->notify) &&
|
||||
(!rhs.server_info || this->server_info) &&
|
||||
(!rhs.user_info || this->user_info) &&
|
||||
(!rhs.changed || this->changed) &&
|
||||
(!rhs.rom || this->rom) &&
|
||||
(!rhs.locked || this->locked) &&
|
||||
(!rhs.registered || this->registered) &&
|
||||
(!rhs.callback || this->callback);
|
||||
}
|
||||
};
|
||||
|
||||
struct convar;
|
||||
|
||||
typedef void (*cvarcallback_t)(convar *);
|
||||
|
||||
using convar_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, convar *> >, 1>;
|
||||
|
||||
struct convar {
|
||||
std::string name{};
|
||||
const char *string{nullptr};
|
||||
cvar_flags flags{};
|
||||
float value{};
|
||||
const char *default_string{nullptr}; //johnfitz -- remember defaults for reset function
|
||||
cvarcallback_t callback{nullptr};
|
||||
|
||||
convar(std::string_view name, const char *str);
|
||||
|
||||
convar(std::string_view name, const char *str, cvar_flags flags);
|
||||
|
||||
void inscribe();
|
||||
|
||||
void set_callback(cvarcallback_t func);
|
||||
|
||||
void set(const std::string &new_value);
|
||||
|
||||
void set_value(float new_value);
|
||||
|
||||
static std::optional<convar *> find_var(const std::string_view &desired);
|
||||
|
||||
static std::optional<convar *> find_var_after(const std::optional<std::string> &prev_name,
|
||||
std::optional<cvar_flags> with_flags);
|
||||
|
||||
static void reset(const std::string &name);
|
||||
|
||||
static void set(const std::string &name, const std::string &new_value);
|
||||
|
||||
static void set_value(const std::string &name, float new_value);
|
||||
|
||||
static std::optional<std::string_view> complete_variable(const std::string_view &partial);
|
||||
|
||||
static std::optional<float> variable_value(const std::string_view &name);
|
||||
|
||||
static std::optional<std::string> variable_string(const std::string_view &name);
|
||||
|
||||
static void lock_var(const std::string_view &name);
|
||||
|
||||
static void unlock_var(const std::string_view &name);
|
||||
|
||||
static void unlock_all();
|
||||
|
||||
static void set_rom(const std::string_view &name, std::string value);
|
||||
|
||||
static void set_value_rom(const std::string_view &name, float value);
|
||||
|
||||
static convar_view get_variables();
|
||||
};
|
||||
|
||||
qboolean Cvar_Command(void);
|
||||
|
||||
void Cvar_WriteVariables(FILE *f);
|
||||
-560
@@ -1,560 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 1996-2001 Id Software, Inc.
|
||||
Copyright (C) 2002-2009 John Fitzgibbons and others
|
||||
Copyright (C) 2010-2014 QuakeSpasm developers
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// cvar.c -- dynamic variable tracking
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <ranges>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
static cvar_t *cvar_vars;
|
||||
static char cvar_null_string[] = "";
|
||||
|
||||
std::map<std::string, cvar_t* > CLIENT_VARIABLES{};
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
// USER COMMANDS
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
void Cvar_Reset(const std::string &name); //johnfitz
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_List_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_List_f() {
|
||||
cvar_t *cvar;
|
||||
const char *partial;
|
||||
int len, count;
|
||||
|
||||
if (Cmd_Argc() > 1) {
|
||||
partial = Cmd_Argv(1);
|
||||
len = Q_strlen(partial);
|
||||
} else {
|
||||
partial = NULL;
|
||||
len = 0;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for (const auto &[name, var]: CLIENT_VARIABLES) {
|
||||
if (partial && Q_strncmp(partial, name.c_str(), len)) {
|
||||
continue;
|
||||
}
|
||||
Con_SafePrintf("%s%s %s \"%s\"\n",
|
||||
(var->flags & CVAR_ARCHIVE) ? "*" : " ",
|
||||
(var->flags & CVAR_NOTIFY) ? "s" : " ",
|
||||
name.c_str(),
|
||||
var->string);
|
||||
count++;
|
||||
}
|
||||
|
||||
Con_SafePrintf("%i cvars", count);
|
||||
if (partial) {
|
||||
Con_SafePrintf(" beginning with \"%s\"", partial);
|
||||
}
|
||||
Con_SafePrintf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Inc_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Inc_f(void) {
|
||||
switch (Cmd_Argc()) {
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("inc <cvar> [amount] : increment cvar\n");
|
||||
break;
|
||||
case 2:
|
||||
Cvar_SetValue(Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + 1);
|
||||
break;
|
||||
case 3:
|
||||
Cvar_SetValue(Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + Q_atof(Cmd_Argv(2)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Toggle_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Toggle_f(void) {
|
||||
switch (Cmd_Argc()) {
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("toggle <cvar> : toggle cvar\n");
|
||||
break;
|
||||
case 2:
|
||||
if (Cvar_VariableValue(Cmd_Argv(1)))
|
||||
Cvar_Set(Cmd_Argv(1), "0");
|
||||
else
|
||||
Cvar_Set(Cmd_Argv(1), "1");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Cycle_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Cycle_f() {
|
||||
int i;
|
||||
|
||||
if (Cmd_Argc() < 3) {
|
||||
Con_Printf("cycle <cvar> <value list>: cycle cvar through a list of values\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//loop through the args until you find one that matches the current cvar value.
|
||||
//yes, this will get stuck on a list that contains the same value twice.
|
||||
//it's not worth dealing with, and i'm not even sure it can be dealt with.
|
||||
for (i = 2; i < Cmd_Argc(); i++) {
|
||||
//zero is assumed to be a string, even though it could actually be zero. The worst case
|
||||
//is that the first time you call this command, it won't match on zero when it should, but after that,
|
||||
//it will be comparing strings that all had the same source (the user) so it will work.
|
||||
if (Q_atof(Cmd_Argv(i)) == 0) {
|
||||
if (!strcmp(Cmd_Argv(i), Cvar_VariableString(Cmd_Argv(1))))
|
||||
break;
|
||||
} else {
|
||||
if (Q_atof(Cmd_Argv(i)) == Cvar_VariableValue(Cmd_Argv(1)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == Cmd_Argc())
|
||||
Cvar_Set(Cmd_Argv(1), Cmd_Argv(2)); // no match
|
||||
else if (i + 1 == Cmd_Argc())
|
||||
Cvar_Set(Cmd_Argv(1), Cmd_Argv(2)); // matched last value in list
|
||||
else
|
||||
Cvar_Set(Cmd_Argv(1), Cmd_Argv(i + 1)); // matched earlier in list
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Reset_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Reset_f() {
|
||||
switch (Cmd_Argc()) {
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("reset <cvar> : reset cvar to default\n");
|
||||
break;
|
||||
case 2:
|
||||
Cvar_Reset(Cmd_Argv(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_ResetAll_f -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_ResetAll_f(void) {
|
||||
cvar_t *var;
|
||||
|
||||
for (auto name: std::views::keys(CLIENT_VARIABLES))
|
||||
Cvar_Reset(name);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_ResetCfg_f -- QuakeSpasm
|
||||
============
|
||||
*/
|
||||
void Cvar_ResetCfg_f() {
|
||||
for (const auto &var: std::views::values(CLIENT_VARIABLES))
|
||||
if (var->flags & CVAR_ARCHIVE) Cvar_Reset(var->name);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
// INIT
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Init -- johnfitz
|
||||
============
|
||||
*/
|
||||
|
||||
void Cvar_Init() {
|
||||
Cmd_AddCommand("cvarlist", Cvar_List_f);
|
||||
Cmd_AddCommand("toggle", Cvar_Toggle_f);
|
||||
Cmd_AddCommand("cycle", Cvar_Cycle_f);
|
||||
Cmd_AddCommand("inc", Cvar_Inc_f);
|
||||
Cmd_AddCommand("reset", Cvar_Reset_f);
|
||||
Cmd_AddCommand("resetall", Cvar_ResetAll_f);
|
||||
Cmd_AddCommand("resetcfg", Cvar_ResetCfg_f);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
// CVAR FUNCTIONS
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_FindVar
|
||||
============
|
||||
*/
|
||||
std::optional<cvar_t *> Cvar_FindVar(const std::string &desired) {
|
||||
for (auto &[name, var]: CLIENT_VARIABLES) {
|
||||
if (name == desired)
|
||||
return var;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
cvar_t *Cvar_FindVarAfter(const char *prev_name, unsigned int with_flags) {
|
||||
// cvar_t *var;
|
||||
//
|
||||
// if (*prev_name)
|
||||
// {
|
||||
// var = Cvar_FindVar (prev_name);
|
||||
// if (!var)
|
||||
// return NULL;
|
||||
// var = var->next;
|
||||
// }
|
||||
// else
|
||||
// var = cvar_vars;
|
||||
//
|
||||
// // search for the next cvar matching the needed flags
|
||||
// while (var)
|
||||
// {
|
||||
// if ((var->flags & with_flags) || !with_flags)
|
||||
// break;
|
||||
// var = var->next;
|
||||
// }
|
||||
// return var;
|
||||
return nullptr; // TODO
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_LockVar
|
||||
============
|
||||
*/
|
||||
void Cvar_LockVar(const std::string &name) {
|
||||
if (const auto var = Cvar_FindVar(name); var.has_value())
|
||||
var.value()->flags |= CVAR_LOCKED;
|
||||
}
|
||||
|
||||
void Cvar_UnlockVar(const std::string &name) {
|
||||
if (const auto var = Cvar_FindVar(name); var.has_value())
|
||||
var.value()->flags &= ~CVAR_LOCKED;
|
||||
}
|
||||
|
||||
void Cvar_UnlockAll() {
|
||||
for (const auto &var: std::views::values(CLIENT_VARIABLES)) {
|
||||
var->flags &= ~CVAR_LOCKED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_VariableValue
|
||||
============
|
||||
*/
|
||||
float Cvar_VariableValue(const char *var_name) {
|
||||
const auto var = Cvar_FindVar(var_name);
|
||||
if (!var.has_value())
|
||||
return 0;
|
||||
return std::strtof(var.value()->string, nullptr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_VariableString
|
||||
============
|
||||
*/
|
||||
const char *Cvar_VariableString(const char *var_name) {
|
||||
const auto var = Cvar_FindVar(var_name);
|
||||
if (!var.has_value())
|
||||
return cvar_null_string;
|
||||
return var.value()->string;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_CompleteVariable
|
||||
============
|
||||
*/
|
||||
std::optional<std::string_view> Cvar_CompleteVariable(const std::string_view &partial) {
|
||||
if (!partial.empty())
|
||||
return std::nullopt;
|
||||
|
||||
// check functions
|
||||
for (const auto &name: CLIENT_VARIABLES | std::views::keys) {
|
||||
if (name.contains(name))
|
||||
return name;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Reset -- johnfitz
|
||||
============
|
||||
*/
|
||||
void Cvar_Reset(const std::string &name) {
|
||||
if (const auto var = Cvar_FindVar(name); !var.has_value())
|
||||
Con_Printf("variable \"%s\" not found\n", name.c_str());
|
||||
else
|
||||
Cvar_SetQuick(var.value(), var.value()->default_string);
|
||||
}
|
||||
|
||||
void Cvar_SetQuick(cvar_t *var, const std::string &value) {
|
||||
if (var->flags & (CVAR_ROM | CVAR_LOCKED))
|
||||
return;
|
||||
if (!(var->flags & CVAR_REGISTERED))
|
||||
return;
|
||||
|
||||
if (!var->string)
|
||||
var->string = Z_Strdup(value.c_str());
|
||||
else {
|
||||
int len;
|
||||
|
||||
if (!strcmp(var->string, value.c_str()))
|
||||
return; // no change
|
||||
|
||||
var->flags |= CVAR_CHANGED;
|
||||
len = value.length();
|
||||
if (len != Q_strlen(var->string)) {
|
||||
Z_Free((void *) var->string);
|
||||
var->string = (char *) Z_Malloc(len + 1);
|
||||
}
|
||||
memcpy((char *) var->string, value.c_str(), len + 1);
|
||||
}
|
||||
|
||||
var->value = Q_atof(var->string);
|
||||
|
||||
//johnfitz -- save initial value for "reset" command
|
||||
if (!var->default_string)
|
||||
var->default_string = Z_Strdup(var->string);
|
||||
//johnfitz -- during initialization, update default too
|
||||
else if (!host_initialized) {
|
||||
// Sys_Printf("changing default of %s: %s -> %s\n",
|
||||
// var->name, var->default_string, var->string);
|
||||
Z_Free((void *) var->default_string);
|
||||
var->default_string = Z_Strdup(var->string);
|
||||
}
|
||||
//johnfitz
|
||||
|
||||
if (var->callback)
|
||||
var->callback(var);
|
||||
}
|
||||
|
||||
void Cvar_SetValueQuick(cvar_t *var, const float value) {
|
||||
char val[32], *ptr = val;
|
||||
|
||||
if (value == (float) ((int) value))
|
||||
q_snprintf(val, sizeof(val), "%i", (int) value);
|
||||
else {
|
||||
q_snprintf(val, sizeof(val), "%f", value);
|
||||
// kill trailing zeroes
|
||||
while (*ptr)
|
||||
ptr++;
|
||||
while (--ptr > val && *ptr == '0' && ptr[-1] != '.')
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
Cvar_SetQuick(var, val);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Set
|
||||
============
|
||||
*/
|
||||
void Cvar_Set(const std::string &name, const std::string &value) {
|
||||
auto var = Cvar_FindVar(name);
|
||||
if (!var.has_value()) {
|
||||
// there is an error in C code if this happens
|
||||
Con_Printf("Cvar_Set: variable %s not found\n", name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Cvar_SetQuick(var.value(), value);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_SetValue
|
||||
============
|
||||
*/
|
||||
void Cvar_SetValue(const char *var_name, const float value) {
|
||||
char val[32], *ptr = val;
|
||||
|
||||
if (value == (float) ((int) value))
|
||||
q_snprintf(val, sizeof(val), "%i", (int) value);
|
||||
else {
|
||||
q_snprintf(val, sizeof(val), "%f", value);
|
||||
// kill trailing zeroes
|
||||
while (*ptr)
|
||||
ptr++;
|
||||
while (--ptr > val && *ptr == '0' && ptr[-1] != '.')
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
Cvar_Set(var_name, val);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_SetROM
|
||||
============
|
||||
*/
|
||||
void Cvar_SetROM(const char *var_name, const char *value) {
|
||||
if (const auto var = Cvar_FindVar(var_name); var.has_value()) {
|
||||
var.value()->flags &= ~CVAR_ROM;
|
||||
Cvar_SetQuick(var.value(), value);
|
||||
var.value()->flags |= CVAR_ROM;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_SetValueROM
|
||||
============
|
||||
*/
|
||||
void Cvar_SetValueROM(const char *var_name, const float value) {
|
||||
if (const auto var = Cvar_FindVar(var_name); var.has_value()) {
|
||||
var.value()->flags &= ~CVAR_ROM;
|
||||
Cvar_SetValueQuick(var.value(), value);
|
||||
var.value()->flags |= CVAR_ROM;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_RegisterVariable
|
||||
|
||||
Adds a freestanding variable to the variable list.
|
||||
============
|
||||
*/
|
||||
void Cvar_RegisterVariable(cvar_t *variable) {
|
||||
char value[512];
|
||||
qboolean set_rom;
|
||||
cvar_t *cursor, *prev; //johnfitz -- sorted list insert
|
||||
|
||||
// first check to see if it has already been defined
|
||||
if (Cvar_FindVar(variable->name)) {
|
||||
Con_Printf("Can't register variable %s, already defined\n", variable->name);
|
||||
return;
|
||||
}
|
||||
|
||||
// check for overlap with a command
|
||||
if (Cmd_Exists(variable->name)) {
|
||||
Con_Printf("Cvar_RegisterVariable: %s is a command\n", variable->name);
|
||||
return;
|
||||
}
|
||||
|
||||
CLIENT_VARIABLES.emplace(std::string(variable->name), variable);
|
||||
|
||||
//johnfitz
|
||||
variable->flags |= CVAR_REGISTERED;
|
||||
|
||||
// copy the value off, because future sets will Z_Free it
|
||||
std::strncpy(value, variable->string, sizeof(value));
|
||||
variable->string = NULL;
|
||||
variable->default_string = NULL;
|
||||
|
||||
if (!(variable->flags & CVAR_CALLBACK))
|
||||
variable->callback = NULL;
|
||||
|
||||
// set it through the function to be consistent
|
||||
set_rom = (variable->flags & CVAR_ROM);
|
||||
variable->flags &= ~CVAR_ROM;
|
||||
Cvar_SetQuick(variable, value);
|
||||
if (set_rom)
|
||||
variable->flags |= CVAR_ROM;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_SetCallback
|
||||
|
||||
Set a callback function to the var
|
||||
============
|
||||
*/
|
||||
void Cvar_SetCallback(cvar_t *var, cvarcallback_t func) {
|
||||
var->callback = func;
|
||||
if (func)
|
||||
var->flags |= CVAR_CALLBACK;
|
||||
else var->flags &= ~CVAR_CALLBACK;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_Command
|
||||
|
||||
Handles variable inspection and changing from the console
|
||||
============
|
||||
*/
|
||||
qboolean Cvar_Command() {
|
||||
// check variables
|
||||
auto var = Cvar_FindVar(Cmd_Argv(0));
|
||||
if (!var.has_value())
|
||||
return false;
|
||||
|
||||
// perform a variable print or set
|
||||
if (Cmd_Argc() == 1) {
|
||||
Con_Printf("\"%s\" is \"%s\"\n", var.value()->name, var.value()->string);
|
||||
return true;
|
||||
}
|
||||
|
||||
Cvar_Set(var.value()->name, Cmd_Argv(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
Cvar_WriteVariables
|
||||
|
||||
Writes lines containing "set variable value" for all variables
|
||||
with the archive flag set to true.
|
||||
============
|
||||
*/
|
||||
void Cvar_WriteVariables(FILE *f) {
|
||||
for (const auto &[name, var] : CLIENT_VARIABLES) {
|
||||
if (var->flags & CVAR_ARCHIVE)
|
||||
fprintf(f, "%s \"%s\"\n", name.c_str(), var->string);
|
||||
}
|
||||
}
|
||||
-146
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 1996-2001 Id Software, Inc.
|
||||
Copyright (C) 2002-2009 John Fitzgibbons and others
|
||||
Copyright (C) 2010-2014 QuakeSpasm developers
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __CVAR_H__
|
||||
#define __CVAR_H__
|
||||
|
||||
/*
|
||||
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 in C code.
|
||||
|
||||
it is sufficient to initialize a cvar_t with just the first two fields,
|
||||
or you can add a ,true flag for variables that you want saved to the
|
||||
configuration file when the game is quit:
|
||||
|
||||
cvar_t r_draworder = {"r_draworder","1"};
|
||||
cvar_t scr_screensize = {"screensize","1",true};
|
||||
|
||||
Cvars must be registered before use, or they will have a 0 value instead
|
||||
of the float interpretation of the string.
|
||||
Generally, all cvar_t declarations should be registered in the apropriate
|
||||
init function before any console commands are executed:
|
||||
|
||||
Cvar_RegisterVariable (&host_framerate);
|
||||
|
||||
|
||||
C code usually just references a cvar in place:
|
||||
if ( r_draworder.value )
|
||||
|
||||
It could optionally ask for the value to be looked up for a string name:
|
||||
if (Cvar_VariableValue ("r_draworder"))
|
||||
|
||||
Interpreted prog code can access cvars with the cvar(name) or
|
||||
cvar_set (name, value) internal functions:
|
||||
teamplay = cvar("teamplay");
|
||||
cvar_set ("registered", "1");
|
||||
|
||||
The user can access cvars from the console in two ways:
|
||||
r_draworder prints the current value
|
||||
r_draworder 0 sets the current value to 0
|
||||
|
||||
Cvars are restricted from having the same names as commands to keep this
|
||||
interface from being ambiguous.
|
||||
|
||||
*/
|
||||
|
||||
#define CVAR_NONE 0
|
||||
#define CVAR_ARCHIVE (1U << 0) // if set, causes it to be saved to config
|
||||
#define CVAR_NOTIFY (1U << 1) // changes will be broadcasted to all players (q1)
|
||||
#define CVAR_SERVERINFO (1U << 2) // added to serverinfo will be sent to clients (q1/net_dgrm.c and qwsv)
|
||||
#define CVAR_USERINFO (1U << 3) // added to userinfo, will be sent to server (qwcl)
|
||||
#define CVAR_CHANGED (1U << 4)
|
||||
#define CVAR_ROM (1U << 6)
|
||||
#define CVAR_LOCKED (1U << 8) // locked temporarily
|
||||
#define CVAR_REGISTERED (1U << 10) // the var is added to the list of variables
|
||||
#define CVAR_CALLBACK (1U << 16) // var has a callback
|
||||
|
||||
#include <map>
|
||||
#include <optional>
|
||||
|
||||
typedef void (*cvarcallback_t) (struct cvar_s *);
|
||||
|
||||
typedef struct cvar_s
|
||||
{
|
||||
const char *name;
|
||||
const char *string;
|
||||
unsigned int flags;
|
||||
float value;
|
||||
const char *default_string; //johnfitz -- remember defaults for reset function
|
||||
cvarcallback_t callback;
|
||||
} cvar_t;
|
||||
|
||||
void Cvar_RegisterVariable (cvar_t *variable);
|
||||
// registers a cvar that already has the name, string, and optionally
|
||||
// the archive elements set.
|
||||
|
||||
void Cvar_SetCallback (cvar_t *var, cvarcallback_t func);
|
||||
// set a callback function to the var
|
||||
|
||||
void Cvar_Set(const std::string &name, const std::string &value);
|
||||
// equivelant to "<name> <variable>" typed at the console
|
||||
|
||||
void Cvar_SetValue (const char *var_name, const float value);
|
||||
// expands value to a string and calls Cvar_Set
|
||||
|
||||
void Cvar_SetROM (const char *var_name, const char *value);
|
||||
void Cvar_SetValueROM (const char *var_name, const float value);
|
||||
// sets a CVAR_ROM variable from within the engine
|
||||
|
||||
void Cvar_SetQuick(cvar_t *var, const std::string &value);
|
||||
void Cvar_SetValueQuick (cvar_t *var, const float value);
|
||||
// these two accept a cvar pointer instead of a var name,
|
||||
// but are otherwise identical to the "non-Quick" versions.
|
||||
// the cvar MUST be registered.
|
||||
|
||||
float Cvar_VariableValue (const char *var_name);
|
||||
// returns 0 if not defined or non numeric
|
||||
|
||||
const char *Cvar_VariableString (const char *var_name);
|
||||
// returns an empty string if not defined
|
||||
|
||||
qboolean Cvar_Command (void);
|
||||
// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
|
||||
// command. Returns true if the command was a variable reference that
|
||||
// was handled. (print or change)
|
||||
|
||||
void Cvar_WriteVariables (FILE *f);
|
||||
// Writes lines containing "set variable value" for all variables
|
||||
// with the CVAR_ARCHIVE flag set
|
||||
|
||||
std::optional<cvar_t*> Cvar_FindVar (const std::string &desired);
|
||||
cvar_t *Cvar_FindVarAfter (const char *prev_name, unsigned int with_flags);
|
||||
|
||||
void Cvar_LockVar(const std::string &name);
|
||||
void Cvar_UnlockVar(const std::string &name);
|
||||
void Cvar_UnlockAll (void);
|
||||
|
||||
void Cvar_Init (void);
|
||||
|
||||
const char *Cvar_CompleteVariable (const char *partial);
|
||||
// attempts to match a partial variable name for command line completion
|
||||
// returns NULL if nothing fits
|
||||
|
||||
extern std::map<std::string, cvar_t* > CLIENT_VARIABLES;
|
||||
|
||||
#endif /* __CVAR_H__ */
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
//extern unsigned char d_15to8table[65536]; //johnfitz -- never used
|
||||
|
||||
cvar_t scr_conalpha = {"scr_conalpha", "0.5", CVAR_ARCHIVE}; //johnfitz
|
||||
convar scr_conalpha = {"scr_conalpha", "0.5", {.archive = true}}; //johnfitz
|
||||
|
||||
qpic_t *draw_disc;
|
||||
qpic_t *draw_backtile;
|
||||
@@ -400,7 +400,7 @@ Draw_Init -- johnfitz -- rewritten
|
||||
*/
|
||||
void Draw_Init (void)
|
||||
{
|
||||
Cvar_RegisterVariable (&scr_conalpha);
|
||||
scr_conalpha.inscribe();
|
||||
|
||||
// clear scrap and allocate gltextures
|
||||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||
@@ -703,7 +703,7 @@ void GL_SetCanvas (canvastype newcanvas)
|
||||
glViewport (glx, gly, glwidth, glheight);
|
||||
break;
|
||||
case CANVAS_MENU:
|
||||
s = q_min((float)glwidth / 320.0f, (float)glheight / 200.0f);
|
||||
s = std::min((float)glwidth / 320.0f, (float)glheight / 200.0f);
|
||||
s = CLAMP (1.0f, scr_menuscale.value, s);
|
||||
// ericw -- doubled width to 640 to accommodate long keybindings
|
||||
glOrtho (0, 640, 200, 0, -99999, 99999);
|
||||
|
||||
+212
-222
@@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//gl_fog.c -- global and volumetric fog
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
//==============================================================================
|
||||
@@ -52,37 +54,32 @@ Fog_Update
|
||||
update internal variables
|
||||
=============
|
||||
*/
|
||||
void Fog_Update (float density, float red, float green, float blue, float time)
|
||||
{
|
||||
//save previous settings for fade
|
||||
if (time > 0)
|
||||
{
|
||||
//check for a fade in progress
|
||||
if (fade_done > cl.time)
|
||||
{
|
||||
float f;
|
||||
void Fog_Update(float density, float red, float green, float blue, float time) {
|
||||
//save previous settings for fade
|
||||
if (time > 0) {
|
||||
//check for a fade in progress
|
||||
if (fade_done > cl.time) {
|
||||
float f;
|
||||
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
old_density = f * old_density + (1.0 - f) * fog_density;
|
||||
old_red = f * old_red + (1.0 - f) * fog_red;
|
||||
old_green = f * old_green + (1.0 - f) * fog_green;
|
||||
old_blue = f * old_blue + (1.0 - f) * fog_blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
old_density = fog_density;
|
||||
old_red = fog_red;
|
||||
old_green = fog_green;
|
||||
old_blue = fog_blue;
|
||||
}
|
||||
}
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
old_density = f * old_density + (1.0 - f) * fog_density;
|
||||
old_red = f * old_red + (1.0 - f) * fog_red;
|
||||
old_green = f * old_green + (1.0 - f) * fog_green;
|
||||
old_blue = f * old_blue + (1.0 - f) * fog_blue;
|
||||
} else {
|
||||
old_density = fog_density;
|
||||
old_red = fog_red;
|
||||
old_green = fog_green;
|
||||
old_blue = fog_blue;
|
||||
}
|
||||
}
|
||||
|
||||
fog_density = density;
|
||||
fog_red = red;
|
||||
fog_green = green;
|
||||
fog_blue = blue;
|
||||
fade_time = time;
|
||||
fade_done = cl.time + time;
|
||||
fog_density = density;
|
||||
fog_red = red;
|
||||
fog_green = green;
|
||||
fog_blue = blue;
|
||||
fade_time = time;
|
||||
fade_done = cl.time + time;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -92,18 +89,17 @@ Fog_ParseServerMessage
|
||||
handle an SVC_FOG message from server
|
||||
=============
|
||||
*/
|
||||
void Fog_ParseServerMessage (void)
|
||||
{
|
||||
float density, red, green, blue, time;
|
||||
void Fog_ParseServerMessage(void) {
|
||||
float density, red, green, blue, time;
|
||||
|
||||
density = MSG_ReadByte() / 255.0;
|
||||
red = MSG_ReadByte() / 255.0;
|
||||
green = MSG_ReadByte() / 255.0;
|
||||
blue = MSG_ReadByte() / 255.0;
|
||||
time = MSG_ReadShort() / 100.0;
|
||||
if (time < 0.0f) time = 0.0f;
|
||||
density = MSG_ReadByte() / 255.0;
|
||||
red = MSG_ReadByte() / 255.0;
|
||||
green = MSG_ReadByte() / 255.0;
|
||||
blue = MSG_ReadByte() / 255.0;
|
||||
time = MSG_ReadShort() / 100.0;
|
||||
if (time < 0.0f) time = 0.0f;
|
||||
|
||||
Fog_Update (density, red, green, blue, time);
|
||||
Fog_Update(density, red, green, blue, time);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -113,69 +109,67 @@ Fog_FogCommand_f
|
||||
handle the 'fog' console command
|
||||
=============
|
||||
*/
|
||||
void Fog_FogCommand_f (void)
|
||||
{
|
||||
float d, r, g, b, t;
|
||||
void Fog_FogCommand_f(void) {
|
||||
float d, r, g, b, t;
|
||||
|
||||
switch (Cmd_Argc())
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("usage:\n");
|
||||
Con_Printf(" fog <density>\n");
|
||||
Con_Printf(" fog <red> <green> <blue>\n");
|
||||
Con_Printf(" fog <density> <red> <green> <blue>\n");
|
||||
Con_Printf("current values:\n");
|
||||
Con_Printf(" \"density\" is \"%f\"\n", fog_density);
|
||||
Con_Printf(" \"red\" is \"%f\"\n", fog_red);
|
||||
Con_Printf(" \"green\" is \"%f\"\n", fog_green);
|
||||
Con_Printf(" \"blue\" is \"%f\"\n", fog_blue);
|
||||
return;
|
||||
case 2:
|
||||
d = Q_atof(Cmd_Argv(1));
|
||||
t = 0.0f;
|
||||
r = fog_red;
|
||||
g = fog_green;
|
||||
b = fog_blue;
|
||||
break;
|
||||
case 3: //TEST
|
||||
d = Q_atof(Cmd_Argv(1));
|
||||
t = Q_atof(Cmd_Argv(2));
|
||||
r = fog_red;
|
||||
g = fog_green;
|
||||
b = fog_blue;
|
||||
break;
|
||||
case 4:
|
||||
d = fog_density;
|
||||
t = 0.0f;
|
||||
r = Q_atof(Cmd_Argv(1));
|
||||
g = Q_atof(Cmd_Argv(2));
|
||||
b = Q_atof(Cmd_Argv(3));
|
||||
break;
|
||||
case 5:
|
||||
d = Q_atof(Cmd_Argv(1));
|
||||
r = Q_atof(Cmd_Argv(2));
|
||||
g = Q_atof(Cmd_Argv(3));
|
||||
b = Q_atof(Cmd_Argv(4));
|
||||
t = 0.0f;
|
||||
break;
|
||||
case 6: //TEST
|
||||
d = Q_atof(Cmd_Argv(1));
|
||||
r = Q_atof(Cmd_Argv(2));
|
||||
g = Q_atof(Cmd_Argv(3));
|
||||
b = Q_atof(Cmd_Argv(4));
|
||||
t = Q_atof(Cmd_Argv(5));
|
||||
break;
|
||||
}
|
||||
switch (command::argc()) {
|
||||
default:
|
||||
case 1:
|
||||
Con_Printf("usage:\n");
|
||||
Con_Printf(" fog <density>\n");
|
||||
Con_Printf(" fog <red> <green> <blue>\n");
|
||||
Con_Printf(" fog <density> <red> <green> <blue>\n");
|
||||
Con_Printf("current values:\n");
|
||||
Con_Printf(" \"density\" is \"%f\"\n", fog_density);
|
||||
Con_Printf(" \"red\" is \"%f\"\n", fog_red);
|
||||
Con_Printf(" \"green\" is \"%f\"\n", fog_green);
|
||||
Con_Printf(" \"blue\" is \"%f\"\n", fog_blue);
|
||||
return;
|
||||
case 2:
|
||||
d = Q_atof(command::argv(1)->c_str());
|
||||
t = 0.0f;
|
||||
r = fog_red;
|
||||
g = fog_green;
|
||||
b = fog_blue;
|
||||
break;
|
||||
case 3: //TEST
|
||||
d = Q_atof(command::argv(1)->c_str());
|
||||
t = Q_atof(command::argv(2)->c_str());
|
||||
r = fog_red;
|
||||
g = fog_green;
|
||||
b = fog_blue;
|
||||
break;
|
||||
case 4:
|
||||
d = fog_density;
|
||||
t = 0.0f;
|
||||
r = Q_atof(command::argv(1)->c_str());
|
||||
g = Q_atof(command::argv(2)->c_str());
|
||||
b = Q_atof(command::argv(3)->c_str());
|
||||
break;
|
||||
case 5:
|
||||
d = Q_atof(command::argv(1)->c_str());
|
||||
r = Q_atof(command::argv(2)->c_str());
|
||||
g = Q_atof(command::argv(3)->c_str());
|
||||
b = Q_atof(command::argv(4)->c_str());
|
||||
t = 0.0f;
|
||||
break;
|
||||
case 6: //TEST
|
||||
d = Q_atof(command::argv(1)->c_str());
|
||||
r = Q_atof(command::argv(2)->c_str());
|
||||
g = Q_atof(command::argv(3)->c_str());
|
||||
b = Q_atof(command::argv(4)->c_str());
|
||||
t = Q_atof(command::argv(5)->c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
if (d < 0.0f) d = 0.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
else if (r > 1.0f) r = 1.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
else if (g > 1.0f) g = 1.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
else if (b > 1.0f) b = 1.0f;
|
||||
Fog_Update(d, r, g, b, t);
|
||||
if (d < 0.0f) d = 0.0f;
|
||||
if (r < 0.0f) r = 0.0f;
|
||||
else if (r > 1.0f) r = 1.0f;
|
||||
if (g < 0.0f) g = 0.0f;
|
||||
else if (g > 1.0f) g = 1.0f;
|
||||
if (b < 0.0f) b = 0.0f;
|
||||
else if (b > 1.0f) b = 1.0f;
|
||||
Fog_Update(d, r, g, b, t);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -185,53 +179,61 @@ Fog_ParseWorldspawn
|
||||
called at map load
|
||||
=============
|
||||
*/
|
||||
void Fog_ParseWorldspawn (void)
|
||||
{
|
||||
char key[128], value[4096];
|
||||
const char *data;
|
||||
void Fog_ParseWorldspawn() {
|
||||
std::string key{};
|
||||
std::string value{};
|
||||
|
||||
//initially no fog
|
||||
fog_density = DEFAULT_DENSITY;
|
||||
fog_red = DEFAULT_GRAY;
|
||||
fog_green = DEFAULT_GRAY;
|
||||
fog_blue = DEFAULT_GRAY;
|
||||
//initially no fog
|
||||
fog_density = DEFAULT_DENSITY;
|
||||
fog_red = DEFAULT_GRAY;
|
||||
fog_green = DEFAULT_GRAY;
|
||||
fog_blue = DEFAULT_GRAY;
|
||||
|
||||
old_density = DEFAULT_DENSITY;
|
||||
old_red = DEFAULT_GRAY;
|
||||
old_green = DEFAULT_GRAY;
|
||||
old_blue = DEFAULT_GRAY;
|
||||
old_density = DEFAULT_DENSITY;
|
||||
old_red = DEFAULT_GRAY;
|
||||
old_green = DEFAULT_GRAY;
|
||||
old_blue = DEFAULT_GRAY;
|
||||
|
||||
fade_time = 0.0;
|
||||
fade_done = 0.0;
|
||||
fade_time = 0.0;
|
||||
fade_done = 0.0;
|
||||
|
||||
data = COM_Parse(cl.worldmodel->entities);
|
||||
if (!data)
|
||||
return; // error
|
||||
if (com_token[0] != '{')
|
||||
return; // error
|
||||
while (1)
|
||||
{
|
||||
data = COM_Parse(data);
|
||||
if (!data)
|
||||
return; // error
|
||||
if (com_token[0] == '}')
|
||||
break; // end of worldspawn
|
||||
if (com_token[0] == '_')
|
||||
q_strlcpy(key, com_token + 1, sizeof(key));
|
||||
else
|
||||
q_strlcpy(key, com_token, sizeof(key));
|
||||
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
|
||||
key[strlen(key)-1] = 0;
|
||||
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
|
||||
if (!data)
|
||||
return; // error
|
||||
q_strlcpy(value, com_token, sizeof(value));
|
||||
std::istringstream ss{cl.worldmodel->entities};
|
||||
|
||||
if (!strcmp("fog", key))
|
||||
{
|
||||
sscanf(value, "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue);
|
||||
}
|
||||
}
|
||||
auto token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
return; // error
|
||||
}
|
||||
if (token->front() != '{') {
|
||||
return; // error
|
||||
}
|
||||
while (true) {
|
||||
token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
return; // error
|
||||
}
|
||||
if (token->front() == '}') {
|
||||
break; // end of worldspawn
|
||||
}
|
||||
if (token->front() == '_') {
|
||||
key = token->substr(1);
|
||||
} else {
|
||||
key = token.value();
|
||||
}
|
||||
|
||||
while (!key.empty() && key.back() == ' ') {
|
||||
key.pop_back();
|
||||
}
|
||||
|
||||
token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
return; // error
|
||||
}
|
||||
value = token.value();
|
||||
|
||||
if (key == "fog") {
|
||||
std::sscanf(value.c_str(), "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -241,38 +243,34 @@ Fog_GetColor
|
||||
calculates fog color for this frame, taking into account fade times
|
||||
=============
|
||||
*/
|
||||
float *Fog_GetColor (void)
|
||||
{
|
||||
static float c[4];
|
||||
float f;
|
||||
int i;
|
||||
float *Fog_GetColor(void) {
|
||||
static float c[4];
|
||||
float f;
|
||||
int i;
|
||||
|
||||
if (fade_done > cl.time)
|
||||
{
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
c[0] = f * old_red + (1.0 - f) * fog_red;
|
||||
c[1] = f * old_green + (1.0 - f) * fog_green;
|
||||
c[2] = f * old_blue + (1.0 - f) * fog_blue;
|
||||
c[3] = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
c[0] = fog_red;
|
||||
c[1] = fog_green;
|
||||
c[2] = fog_blue;
|
||||
c[3] = 1.0;
|
||||
}
|
||||
if (fade_done > cl.time) {
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
c[0] = f * old_red + (1.0 - f) * fog_red;
|
||||
c[1] = f * old_green + (1.0 - f) * fog_green;
|
||||
c[2] = f * old_blue + (1.0 - f) * fog_blue;
|
||||
c[3] = 1.0;
|
||||
} else {
|
||||
c[0] = fog_red;
|
||||
c[1] = fog_green;
|
||||
c[2] = fog_blue;
|
||||
c[3] = 1.0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
c[i] = CLAMP (0.f, c[i], 1.f);
|
||||
}
|
||||
for (i = 0; i < 3; i++) {
|
||||
c[i] = CLAMP(0.f, c[i], 1.f);
|
||||
}
|
||||
|
||||
//find closest 24-bit RGB value, so solid-colored sky can match the fog perfectly
|
||||
for (i = 0; i < 3; i++) {
|
||||
c[i] = (float)(Q_rint(c[i] * 255)) / 255.0f;
|
||||
}
|
||||
//find closest 24-bit RGB value, so solid-colored sky can match the fog perfectly
|
||||
for (i = 0; i < 3; i++) {
|
||||
c[i] = (float) (Q_rint(c[i] * 255)) / 255.0f;
|
||||
}
|
||||
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -282,17 +280,14 @@ Fog_GetDensity
|
||||
returns current density of fog
|
||||
=============
|
||||
*/
|
||||
float Fog_GetDensity (void)
|
||||
{
|
||||
float f;
|
||||
float Fog_GetDensity(void) {
|
||||
float f;
|
||||
|
||||
if (fade_done > cl.time)
|
||||
{
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
return f * old_density + (1.0 - f) * fog_density;
|
||||
}
|
||||
else
|
||||
return fog_density;
|
||||
if (fade_done > cl.time) {
|
||||
f = (fade_done - cl.time) / fade_time;
|
||||
return f * old_density + (1.0 - f) * fog_density;
|
||||
} else
|
||||
return fog_density;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -302,10 +297,9 @@ Fog_SetupFrame
|
||||
called at the beginning of each frame
|
||||
=============
|
||||
*/
|
||||
void Fog_SetupFrame (void)
|
||||
{
|
||||
glFogfv(GL_FOG_COLOR, Fog_GetColor());
|
||||
glFogf(GL_FOG_DENSITY, Fog_GetDensity() / 64.0);
|
||||
void Fog_SetupFrame(void) {
|
||||
glFogfv(GL_FOG_COLOR, Fog_GetColor());
|
||||
glFogf(GL_FOG_DENSITY, Fog_GetDensity() / 64.0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -315,10 +309,9 @@ Fog_EnableGFog
|
||||
called before drawing stuff that should be fogged
|
||||
=============
|
||||
*/
|
||||
void Fog_EnableGFog (void)
|
||||
{
|
||||
if (Fog_GetDensity() > 0)
|
||||
glEnable(GL_FOG);
|
||||
void Fog_EnableGFog(void) {
|
||||
if (Fog_GetDensity() > 0)
|
||||
glEnable(GL_FOG);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -328,10 +321,9 @@ Fog_DisableGFog
|
||||
called after drawing stuff that should be fogged
|
||||
=============
|
||||
*/
|
||||
void Fog_DisableGFog (void)
|
||||
{
|
||||
if (Fog_GetDensity() > 0)
|
||||
glDisable(GL_FOG);
|
||||
void Fog_DisableGFog(void) {
|
||||
if (Fog_GetDensity() > 0)
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -341,12 +333,11 @@ Fog_StartAdditive
|
||||
called before drawing stuff that is additive blended -- sets fog color to black
|
||||
=============
|
||||
*/
|
||||
void Fog_StartAdditive (void)
|
||||
{
|
||||
vec3_t color = {0,0,0};
|
||||
void Fog_StartAdditive(void) {
|
||||
vec3_t color = {0, 0, 0};
|
||||
|
||||
if (Fog_GetDensity() > 0)
|
||||
glFogfv(GL_FOG_COLOR, color);
|
||||
if (Fog_GetDensity() > 0)
|
||||
glFogfv(GL_FOG_COLOR, color);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -356,10 +347,9 @@ Fog_StopAdditive
|
||||
called after drawing stuff that is additive blended -- restores fog color
|
||||
=============
|
||||
*/
|
||||
void Fog_StopAdditive (void)
|
||||
{
|
||||
if (Fog_GetDensity() > 0)
|
||||
glFogfv(GL_FOG_COLOR, Fog_GetColor());
|
||||
void Fog_StopAdditive(void) {
|
||||
if (Fog_GetDensity() > 0)
|
||||
glFogfv(GL_FOG_COLOR, Fog_GetColor());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@@ -368,10 +358,13 @@ void Fog_StopAdditive (void)
|
||||
//
|
||||
//==============================================================================
|
||||
|
||||
cvar_t r_vfog = {"r_vfog", "1", CVAR_NONE};
|
||||
convar r_vfog{"r_vfog", "1"};
|
||||
|
||||
void Fog_DrawVFog (void){}
|
||||
void Fog_MarkModels (void){}
|
||||
void Fog_DrawVFog(void) {
|
||||
}
|
||||
|
||||
void Fog_MarkModels(void) {
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//
|
||||
@@ -386,10 +379,9 @@ Fog_NewMap
|
||||
called whenever a map is loaded
|
||||
=============
|
||||
*/
|
||||
void Fog_NewMap (void)
|
||||
{
|
||||
Fog_ParseWorldspawn (); //for global fog
|
||||
Fog_MarkModels (); //for volumetric fog
|
||||
void Fog_NewMap(void) {
|
||||
Fog_ParseWorldspawn(); //for global fog
|
||||
Fog_MarkModels(); //for volumetric fog
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -399,29 +391,27 @@ Fog_Init
|
||||
called when quake initializes
|
||||
=============
|
||||
*/
|
||||
void Fog_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("fog",Fog_FogCommand_f);
|
||||
void Fog_Init(void) {
|
||||
command::add("fog", Fog_FogCommand_f);
|
||||
|
||||
//Cvar_RegisterVariable (&r_vfog);
|
||||
//r_vfog.inscribe();
|
||||
|
||||
//set up global fog
|
||||
fog_density = DEFAULT_DENSITY;
|
||||
fog_red = DEFAULT_GRAY;
|
||||
fog_green = DEFAULT_GRAY;
|
||||
fog_blue = DEFAULT_GRAY;
|
||||
//set up global fog
|
||||
fog_density = DEFAULT_DENSITY;
|
||||
fog_red = DEFAULT_GRAY;
|
||||
fog_green = DEFAULT_GRAY;
|
||||
fog_blue = DEFAULT_GRAY;
|
||||
|
||||
Fog_SetupState ();
|
||||
Fog_SetupState();
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
Fog_SetupState
|
||||
|
||||
|
||||
ericw -- moved from Fog_Init, state that needs to be setup when a new context is created
|
||||
=============
|
||||
*/
|
||||
void Fog_SetupState (void)
|
||||
{
|
||||
glFogi(GL_FOG_MODE, GL_EXP2);
|
||||
void Fog_SetupState(void) {
|
||||
glFogi(GL_FOG_MODE, GL_EXP2);
|
||||
}
|
||||
|
||||
+16
-16
@@ -36,8 +36,8 @@ static qmodel_t *Mod_LoadModel (qmodel_t *mod, qboolean crash);
|
||||
|
||||
static void Mod_Print (void);
|
||||
|
||||
static cvar_t external_ents = {"external_ents", "1", CVAR_ARCHIVE};
|
||||
static cvar_t external_vis = {"external_vis", "1", CVAR_ARCHIVE};
|
||||
static convar external_ents = {"external_ents", "1", {.archive = true}};
|
||||
static convar external_vis = {"external_vis", "1", {.archive = true}};
|
||||
|
||||
static byte *mod_novis;
|
||||
static int mod_novis_capacity;
|
||||
@@ -59,11 +59,11 @@ Mod_Init
|
||||
*/
|
||||
void Mod_Init (void)
|
||||
{
|
||||
Cvar_RegisterVariable (&gl_subdivide_size);
|
||||
Cvar_RegisterVariable (&external_vis);
|
||||
Cvar_RegisterVariable (&external_ents);
|
||||
gl_subdivide_size.inscribe();
|
||||
external_vis.inscribe();
|
||||
external_ents.inscribe();
|
||||
|
||||
Cmd_AddCommand ("mcache", Mod_Print);
|
||||
command::add ("mcache", Mod_Print);
|
||||
|
||||
//johnfitz -- create notexture miptex
|
||||
r_notexture_mip = (texture_t *) Hunk_AllocName (sizeof(texture_t), "r_notexture_mip");
|
||||
@@ -525,7 +525,7 @@ static void Mod_LoadTextures (lump_t *l)
|
||||
if (((byte*)(mt+1) + pixels) > (mod_base + l->fileofs + l->filelen))
|
||||
{
|
||||
Con_DPrintf("Texture %s extends past end of lump\n", mt->name);
|
||||
pixels = q_max(0L, (long)((mod_base + l->fileofs + l->filelen) - (byte*)(mt+1)));
|
||||
pixels = std::max(0L, (long)((mod_base + l->fileofs + l->filelen) - (byte*)(mt+1)));
|
||||
}
|
||||
|
||||
tx->update_warp = false; //johnfitz
|
||||
@@ -2054,21 +2054,21 @@ static void Mod_BoundsFromClipNode (qmodel_t *mod, int hull, int nodenum)
|
||||
|
||||
case PLANE_X:
|
||||
if (plane->signbits == 1)
|
||||
mod->clipmins[0] = q_min(mod->clipmins[0], -plane->dist - mod->hulls[hull].clip_mins[0]);
|
||||
mod->clipmins[0] = std::min(mod->clipmins[0], -plane->dist - mod->hulls[hull].clip_mins[0]);
|
||||
else
|
||||
mod->clipmaxs[0] = q_max(mod->clipmaxs[0], plane->dist - mod->hulls[hull].clip_maxs[0]);
|
||||
mod->clipmaxs[0] = std::max(mod->clipmaxs[0], plane->dist - mod->hulls[hull].clip_maxs[0]);
|
||||
break;
|
||||
case PLANE_Y:
|
||||
if (plane->signbits == 2)
|
||||
mod->clipmins[1] = q_min(mod->clipmins[1], -plane->dist - mod->hulls[hull].clip_mins[1]);
|
||||
mod->clipmins[1] = std::min(mod->clipmins[1], -plane->dist - mod->hulls[hull].clip_mins[1]);
|
||||
else
|
||||
mod->clipmaxs[1] = q_max(mod->clipmaxs[1], plane->dist - mod->hulls[hull].clip_maxs[1]);
|
||||
mod->clipmaxs[1] = std::max(mod->clipmaxs[1], plane->dist - mod->hulls[hull].clip_maxs[1]);
|
||||
break;
|
||||
case PLANE_Z:
|
||||
if (plane->signbits == 4)
|
||||
mod->clipmins[2] = q_min(mod->clipmins[2], -plane->dist - mod->hulls[hull].clip_mins[2]);
|
||||
mod->clipmins[2] = std::min(mod->clipmins[2], -plane->dist - mod->hulls[hull].clip_mins[2]);
|
||||
else
|
||||
mod->clipmaxs[2] = q_max(mod->clipmaxs[2], plane->dist - mod->hulls[hull].clip_maxs[2]);
|
||||
mod->clipmaxs[2] = std::max(mod->clipmaxs[2], plane->dist - mod->hulls[hull].clip_maxs[2]);
|
||||
break;
|
||||
default:
|
||||
//skip nonaxial planes; don't need them
|
||||
@@ -2648,8 +2648,8 @@ static void Mod_CalcAliasBounds (aliashdr_t *a)
|
||||
|
||||
for (k=0; k<3;k++)
|
||||
{
|
||||
loadmodel->mins[k] = q_min(loadmodel->mins[k], v[k]);
|
||||
loadmodel->maxs[k] = q_max(loadmodel->maxs[k], v[k]);
|
||||
loadmodel->mins[k] = std::min(loadmodel->mins[k], v[k]);
|
||||
loadmodel->maxs[k] = std::max(loadmodel->maxs[k], v[k]);
|
||||
}
|
||||
dist = v[0] * v[0] + v[1] * v[1];
|
||||
if (yawradius < dist)
|
||||
@@ -2711,7 +2711,7 @@ Mod_SetExtraFlags -- johnfitz -- set up extra flags that aren't in the mdl
|
||||
*/
|
||||
void Mod_SetExtraFlags (qmodel_t *mod)
|
||||
{
|
||||
extern cvar_t r_nolerp_list, r_noshadow_list;
|
||||
extern convar r_nolerp_list, r_noshadow_list;
|
||||
|
||||
if (!mod || mod->type != mod_alias)
|
||||
return;
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ void R_CheckEfrags (void)
|
||||
Con_DWarning ("%i efrags exceeds standard limit of 640.\n", cl.num_efrags);
|
||||
|
||||
dev_stats.efrags = cl.num_efrags;
|
||||
dev_peakstats.efrags = q_max(cl.num_efrags, dev_peakstats.efrags);
|
||||
dev_peakstats.efrags = std::max(cl.num_efrags, dev_peakstats.efrags);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
static int r_dlightframecount;
|
||||
|
||||
extern cvar_t r_flatlightstyles; //johnfitz
|
||||
extern convar r_flatlightstyles; //johnfitz
|
||||
|
||||
/*
|
||||
==================
|
||||
@@ -359,7 +359,7 @@ loc0:
|
||||
// caused by overlapping surfaces with mixed lighting data.
|
||||
const float nearby = 8.f;
|
||||
dist += nearby;
|
||||
*maxdist = q_min(*maxdist, dist);
|
||||
*maxdist = std::min(*maxdist, dist);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+668
-729
File diff suppressed because it is too large
Load Diff
+354
-378
@@ -22,35 +22,37 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
// r_misc.c
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
//johnfitz -- new cvars
|
||||
extern cvar_t r_stereo;
|
||||
extern cvar_t r_stereodepth;
|
||||
extern cvar_t r_clearcolor;
|
||||
extern cvar_t r_drawflat;
|
||||
extern cvar_t r_flatlightstyles;
|
||||
extern cvar_t gl_fullbrights;
|
||||
extern cvar_t gl_farclip;
|
||||
extern cvar_t gl_overbright;
|
||||
extern cvar_t gl_overbright_models;
|
||||
extern cvar_t r_waterquality;
|
||||
extern cvar_t r_oldwater;
|
||||
extern cvar_t r_waterwarp;
|
||||
extern cvar_t r_oldskyleaf;
|
||||
extern cvar_t r_drawworld;
|
||||
extern cvar_t r_showtris;
|
||||
extern cvar_t r_showbboxes;
|
||||
extern cvar_t r_lerpmodels;
|
||||
extern cvar_t r_lerpmove;
|
||||
extern cvar_t r_nolerp_list;
|
||||
extern cvar_t r_noshadow_list;
|
||||
extern convar r_stereo;
|
||||
extern convar r_stereodepth;
|
||||
extern convar r_clearcolor;
|
||||
extern convar r_drawflat;
|
||||
extern convar r_flatlightstyles;
|
||||
extern convar gl_fullbrights;
|
||||
extern convar gl_farclip;
|
||||
extern convar gl_overbright;
|
||||
extern convar gl_overbright_models;
|
||||
extern convar r_waterquality;
|
||||
extern convar r_oldwater;
|
||||
extern convar r_waterwarp;
|
||||
extern convar r_oldskyleaf;
|
||||
extern convar r_drawworld;
|
||||
extern convar r_showtris;
|
||||
extern convar r_showbboxes;
|
||||
extern convar r_lerpmodels;
|
||||
extern convar r_lerpmove;
|
||||
extern convar r_nolerp_list;
|
||||
extern convar r_noshadow_list;
|
||||
//johnfitz
|
||||
extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix
|
||||
extern convar gl_zfix; // QuakeSpasm z-fighting fix
|
||||
|
||||
extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz
|
||||
|
||||
cvar_t r_lightmapwide = {"r_lightmapwide","0",CVAR_ROM};
|
||||
convar r_lightmapwide = {"r_lightmapwide", "0", {.rom = true}};
|
||||
|
||||
|
||||
/*
|
||||
@@ -58,9 +60,8 @@ cvar_t r_lightmapwide = {"r_lightmapwide","0",CVAR_ROM};
|
||||
GL_Overbright_f -- johnfitz
|
||||
====================
|
||||
*/
|
||||
static void GL_Overbright_f (cvar_t *var)
|
||||
{
|
||||
R_RebuildAllLightmaps ();
|
||||
static void GL_Overbright_f(convar *var) {
|
||||
R_RebuildAllLightmaps();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -68,9 +69,8 @@ static void GL_Overbright_f (cvar_t *var)
|
||||
GL_Fullbrights_f -- johnfitz
|
||||
====================
|
||||
*/
|
||||
static void GL_Fullbrights_f (cvar_t *var)
|
||||
{
|
||||
TexMgr_ReloadNobrightImages ();
|
||||
static void GL_Fullbrights_f(convar *var) {
|
||||
TexMgr_ReloadNobrightImages();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -78,14 +78,13 @@ static void GL_Fullbrights_f (cvar_t *var)
|
||||
R_SetClearColor_f -- johnfitz
|
||||
====================
|
||||
*/
|
||||
static void R_SetClearColor_f (cvar_t *var)
|
||||
{
|
||||
byte *rgb;
|
||||
int s;
|
||||
static void R_SetClearColor_f(convar *var) {
|
||||
byte *rgb;
|
||||
int s;
|
||||
|
||||
s = (int)r_clearcolor.value & 0xFF;
|
||||
rgb = (byte*)(d_8to24table + s);
|
||||
glClearColor (rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0,0);
|
||||
s = (int) r_clearcolor.value & 0xFF;
|
||||
rgb = (byte *) (d_8to24table + s);
|
||||
glClearColor(rgb[0] / 255.0, rgb[1] / 255.0, rgb[2] / 255.0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -93,11 +92,10 @@ static void R_SetClearColor_f (cvar_t *var)
|
||||
R_Model_ExtraFlags_List_f -- johnfitz -- called when r_nolerp_list or r_noshadow_list cvar changes
|
||||
===============
|
||||
*/
|
||||
static void R_Model_ExtraFlags_List_f (cvar_t *var)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < MAX_MODELS; i++)
|
||||
Mod_SetExtraFlags (cl.model_precache[i]);
|
||||
static void R_Model_ExtraFlags_List_f(convar *var) {
|
||||
int i;
|
||||
for (i = 0; i < MAX_MODELS; i++)
|
||||
Mod_SetExtraFlags(cl.model_precache[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -105,9 +103,8 @@ static void R_Model_ExtraFlags_List_f (cvar_t *var)
|
||||
R_SetWateralpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetWateralpha_f (cvar_t *var)
|
||||
{
|
||||
map_wateralpha = var->value;
|
||||
static void R_SetWateralpha_f(convar *var) {
|
||||
map_wateralpha = var->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -115,9 +112,8 @@ static void R_SetWateralpha_f (cvar_t *var)
|
||||
R_SetLavaalpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetLavaalpha_f (cvar_t *var)
|
||||
{
|
||||
map_lavaalpha = var->value;
|
||||
static void R_SetLavaalpha_f(convar *var) {
|
||||
map_lavaalpha = var->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -125,9 +121,8 @@ static void R_SetLavaalpha_f (cvar_t *var)
|
||||
R_SetTelealpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetTelealpha_f (cvar_t *var)
|
||||
{
|
||||
map_telealpha = var->value;
|
||||
static void R_SetTelealpha_f(convar *var) {
|
||||
map_telealpha = var->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -135,9 +130,8 @@ static void R_SetTelealpha_f (cvar_t *var)
|
||||
R_SetSlimealpha_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetSlimealpha_f (cvar_t *var)
|
||||
{
|
||||
map_slimealpha = var->value;
|
||||
static void R_SetSlimealpha_f(convar *var) {
|
||||
map_slimealpha = var->value;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -145,16 +139,15 @@ static void R_SetSlimealpha_f (cvar_t *var)
|
||||
GL_WaterAlphaForSurfface -- ericw
|
||||
====================
|
||||
*/
|
||||
float GL_WaterAlphaForSurface (msurface_t *fa)
|
||||
{
|
||||
if (fa->flags & SURF_DRAWLAVA)
|
||||
return map_lavaalpha > 0 ? map_lavaalpha : map_wateralpha;
|
||||
else if (fa->flags & SURF_DRAWTELE)
|
||||
return map_telealpha > 0 ? map_telealpha : map_wateralpha;
|
||||
else if (fa->flags & SURF_DRAWSLIME)
|
||||
return map_slimealpha > 0 ? map_slimealpha : map_wateralpha;
|
||||
else
|
||||
return map_wateralpha;
|
||||
float GL_WaterAlphaForSurface(msurface_t *fa) {
|
||||
if (fa->flags & SURF_DRAWLAVA)
|
||||
return map_lavaalpha > 0 ? map_lavaalpha : map_wateralpha;
|
||||
else if (fa->flags & SURF_DRAWTELE)
|
||||
return map_telealpha > 0 ? map_telealpha : map_wateralpha;
|
||||
else if (fa->flags & SURF_DRAWSLIME)
|
||||
return map_slimealpha > 0 ? map_slimealpha : map_wateralpha;
|
||||
else
|
||||
return map_wateralpha;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,79 +156,78 @@ float GL_WaterAlphaForSurface (msurface_t *fa)
|
||||
R_Init
|
||||
===============
|
||||
*/
|
||||
void R_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
|
||||
Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
|
||||
void R_Init(void) {
|
||||
command::add("timerefresh", R_TimeRefresh_f);
|
||||
command::add("pointfile", R_ReadPointFile_f);
|
||||
|
||||
Cvar_RegisterVariable (&r_norefresh);
|
||||
Cvar_RegisterVariable (&r_lightmap);
|
||||
Cvar_RegisterVariable (&r_fullbright);
|
||||
Cvar_RegisterVariable (&r_drawentities);
|
||||
Cvar_RegisterVariable (&r_drawviewmodel);
|
||||
Cvar_RegisterVariable (&r_shadows);
|
||||
Cvar_RegisterVariable (&r_wateralpha);
|
||||
Cvar_SetCallback (&r_wateralpha, R_SetWateralpha_f);
|
||||
Cvar_RegisterVariable (&r_litwater);
|
||||
Cvar_RegisterVariable (&r_dynamic);
|
||||
Cvar_RegisterVariable (&r_novis);
|
||||
Cvar_RegisterVariable (&r_speeds);
|
||||
Cvar_RegisterVariable (&r_pos);
|
||||
r_norefresh.inscribe();
|
||||
r_lightmap.inscribe();
|
||||
r_fullbright.inscribe();
|
||||
r_drawentities.inscribe();
|
||||
r_drawviewmodel.inscribe();
|
||||
r_shadows.inscribe();
|
||||
r_wateralpha.inscribe();
|
||||
r_wateralpha.set_callback(R_SetWateralpha_f);
|
||||
r_litwater.inscribe();
|
||||
r_dynamic.inscribe();
|
||||
r_novis.inscribe();
|
||||
r_speeds.inscribe();
|
||||
r_pos.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&gl_finish);
|
||||
Cvar_RegisterVariable (&gl_clear);
|
||||
Cvar_RegisterVariable (&gl_cull);
|
||||
Cvar_RegisterVariable (&gl_smoothmodels);
|
||||
Cvar_RegisterVariable (&gl_affinemodels);
|
||||
Cvar_RegisterVariable (&gl_polyblend);
|
||||
Cvar_RegisterVariable (&gl_flashblend);
|
||||
Cvar_RegisterVariable (&gl_playermip);
|
||||
Cvar_RegisterVariable (&gl_nocolors);
|
||||
gl_finish.inscribe();
|
||||
gl_clear.inscribe();
|
||||
gl_cull.inscribe();
|
||||
gl_smoothmodels.inscribe();
|
||||
gl_affinemodels.inscribe();
|
||||
gl_polyblend.inscribe();
|
||||
gl_flashblend.inscribe();
|
||||
gl_playermip.inscribe();
|
||||
gl_nocolors.inscribe();
|
||||
|
||||
//johnfitz -- new cvars
|
||||
Cvar_RegisterVariable (&r_stereo);
|
||||
Cvar_RegisterVariable (&r_stereodepth);
|
||||
Cvar_RegisterVariable (&r_clearcolor);
|
||||
Cvar_SetCallback (&r_clearcolor, R_SetClearColor_f);
|
||||
Cvar_RegisterVariable (&r_waterquality);
|
||||
Cvar_RegisterVariable (&r_oldwater);
|
||||
Cvar_RegisterVariable (&r_waterwarp);
|
||||
Cvar_RegisterVariable (&r_drawflat);
|
||||
Cvar_RegisterVariable (&r_flatlightstyles);
|
||||
Cvar_RegisterVariable (&r_oldskyleaf);
|
||||
Cvar_RegisterVariable (&r_drawworld);
|
||||
Cvar_RegisterVariable (&r_showtris);
|
||||
Cvar_RegisterVariable (&r_showbboxes);
|
||||
Cvar_RegisterVariable (&gl_farclip);
|
||||
Cvar_RegisterVariable (&gl_fullbrights);
|
||||
Cvar_RegisterVariable (&gl_overbright);
|
||||
Cvar_SetCallback (&gl_fullbrights, GL_Fullbrights_f);
|
||||
Cvar_SetCallback (&gl_overbright, GL_Overbright_f);
|
||||
Cvar_RegisterVariable (&gl_overbright_models);
|
||||
Cvar_RegisterVariable (&r_lerpmodels);
|
||||
Cvar_RegisterVariable (&r_lerpmove);
|
||||
Cvar_RegisterVariable (&r_nolerp_list);
|
||||
Cvar_SetCallback (&r_nolerp_list, R_Model_ExtraFlags_List_f);
|
||||
Cvar_RegisterVariable (&r_noshadow_list);
|
||||
Cvar_SetCallback (&r_noshadow_list, R_Model_ExtraFlags_List_f);
|
||||
//johnfitz
|
||||
Cvar_RegisterVariable (&r_lightmapwide);
|
||||
Cvar_SetROM ("r_lightmapwide", gl_packed_pixels ? "1" : "0");
|
||||
//johnfitz -- new cvars
|
||||
r_stereo.inscribe();
|
||||
r_stereodepth.inscribe();
|
||||
r_clearcolor.inscribe();
|
||||
r_clearcolor.set_callback(R_SetClearColor_f);
|
||||
r_waterquality.inscribe();
|
||||
r_oldwater.inscribe();
|
||||
r_waterwarp.inscribe();
|
||||
r_drawflat.inscribe();
|
||||
r_flatlightstyles.inscribe();
|
||||
r_oldskyleaf.inscribe();
|
||||
r_drawworld.inscribe();
|
||||
r_showtris.inscribe();
|
||||
r_showbboxes.inscribe();
|
||||
gl_farclip.inscribe();
|
||||
gl_fullbrights.inscribe();
|
||||
gl_overbright.inscribe();
|
||||
gl_fullbrights.set_callback(GL_Fullbrights_f);
|
||||
gl_overbright.set_callback(GL_Overbright_f);
|
||||
gl_overbright_models.inscribe();
|
||||
r_lerpmodels.inscribe();
|
||||
r_lerpmove.inscribe();
|
||||
r_nolerp_list.inscribe();
|
||||
r_nolerp_list.set_callback(R_Model_ExtraFlags_List_f);
|
||||
r_noshadow_list.inscribe();
|
||||
r_noshadow_list.set_callback(R_Model_ExtraFlags_List_f);
|
||||
//johnfitz
|
||||
r_lightmapwide.inscribe();
|
||||
convar::set_rom("r_lightmapwide", gl_packed_pixels ? "1" : "0");
|
||||
|
||||
Cvar_RegisterVariable (&gl_zfix); // QuakeSpasm z-fighting fix
|
||||
Cvar_RegisterVariable (&r_lavaalpha);
|
||||
Cvar_RegisterVariable (&r_telealpha);
|
||||
Cvar_RegisterVariable (&r_slimealpha);
|
||||
Cvar_RegisterVariable (&r_scale);
|
||||
Cvar_SetCallback (&r_lavaalpha, R_SetLavaalpha_f);
|
||||
Cvar_SetCallback (&r_telealpha, R_SetTelealpha_f);
|
||||
Cvar_SetCallback (&r_slimealpha, R_SetSlimealpha_f);
|
||||
gl_zfix.inscribe(); // QuakeSpasm z-fighting fix
|
||||
r_lavaalpha.inscribe();
|
||||
r_telealpha.inscribe();
|
||||
r_slimealpha.inscribe();
|
||||
r_scale.inscribe();
|
||||
r_lavaalpha.set_callback(R_SetLavaalpha_f);
|
||||
r_telealpha.set_callback(R_SetTelealpha_f);
|
||||
r_slimealpha.set_callback(R_SetSlimealpha_f);
|
||||
|
||||
R_InitParticles ();
|
||||
R_SetClearColor_f (&r_clearcolor); //johnfitz
|
||||
R_InitParticles();
|
||||
R_SetClearColor_f(&r_clearcolor); //johnfitz
|
||||
|
||||
Sky_Init (); //johnfitz
|
||||
Fog_Init (); //johnfitz
|
||||
Sky_Init(); //johnfitz
|
||||
Fog_Init(); //johnfitz
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -243,19 +235,17 @@ void R_Init (void)
|
||||
R_TranslatePlayerSkin -- johnfitz -- rewritten. also, only handles new colors, not new skins
|
||||
===============
|
||||
*/
|
||||
void R_TranslatePlayerSkin (int playernum)
|
||||
{
|
||||
int top, bottom;
|
||||
void R_TranslatePlayerSkin(int playernum) {
|
||||
int top, bottom;
|
||||
|
||||
top = (cl.scores[playernum].colors & 0xf0)>>4;
|
||||
bottom = cl.scores[playernum].colors &15;
|
||||
top = (cl.scores[playernum].colors & 0xf0) >> 4;
|
||||
bottom = cl.scores[playernum].colors & 15;
|
||||
|
||||
//FIXME: if gl_nocolors is on, then turned off, the textures may be out of sync with the scoreboard colors.
|
||||
if (!gl_nocolors.value)
|
||||
{
|
||||
if (playertextures[playernum])
|
||||
TexMgr_ReloadImage (playertextures[playernum], top, bottom);
|
||||
}
|
||||
//FIXME: if gl_nocolors is on, then turned off, the textures may be out of sync with the scoreboard colors.
|
||||
if (!gl_nocolors.value) {
|
||||
if (playertextures[playernum])
|
||||
TexMgr_ReloadImage(playertextures[playernum], top, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -265,39 +255,40 @@ the skin or model actually changes, instead of just new colors
|
||||
added bug fix from bengt jardup
|
||||
===============
|
||||
*/
|
||||
void R_TranslateNewPlayerSkin (int playernum)
|
||||
{
|
||||
char name[64];
|
||||
byte *pixels;
|
||||
aliashdr_t *paliashdr;
|
||||
int skinnum;
|
||||
void R_TranslateNewPlayerSkin(int playernum) {
|
||||
char name[64];
|
||||
byte *pixels;
|
||||
aliashdr_t *paliashdr;
|
||||
int skinnum;
|
||||
|
||||
//get correct texture pixels
|
||||
currententity = &cl_entities[1+playernum];
|
||||
//get correct texture pixels
|
||||
currententity = &cl_entities[1 + playernum];
|
||||
|
||||
if (!currententity->model || currententity->model->type != mod_alias)
|
||||
return;
|
||||
if (!currententity->model || currententity->model->type != mod_alias)
|
||||
return;
|
||||
|
||||
paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);
|
||||
paliashdr = (aliashdr_t *) Mod_Extradata(currententity->model);
|
||||
|
||||
skinnum = currententity->skinnum;
|
||||
skinnum = currententity->skinnum;
|
||||
|
||||
//TODO: move these tests to the place where skinnum gets received from the server
|
||||
if (skinnum < 0 || skinnum >= paliashdr->numskins)
|
||||
{
|
||||
Con_DPrintf("(%d): Invalid player skin #%d\n", playernum, skinnum);
|
||||
skinnum = 0;
|
||||
}
|
||||
//TODO: move these tests to the place where skinnum gets received from the server
|
||||
if (skinnum < 0 || skinnum >= paliashdr->numskins) {
|
||||
Con_DPrintf("(%d): Invalid player skin #%d\n", playernum, skinnum);
|
||||
skinnum = 0;
|
||||
}
|
||||
|
||||
pixels = (byte *)paliashdr + paliashdr->texels[skinnum]; // This is not a persistent place!
|
||||
pixels = (byte *) paliashdr + paliashdr->texels[skinnum]; // This is not a persistent place!
|
||||
|
||||
//upload new image
|
||||
q_snprintf(name, sizeof(name), "player_%i", playernum);
|
||||
playertextures[playernum] = TexMgr_LoadImage (currententity->model, name, paliashdr->skinwidth, paliashdr->skinheight,
|
||||
SRC_INDEXED, pixels, paliashdr->gltextures[skinnum][0]->source_file, paliashdr->gltextures[skinnum][0]->source_offset, TEXPREF_PAD | TEXPREF_OVERWRITE);
|
||||
//upload new image
|
||||
q_snprintf(name, sizeof(name), "player_%i", playernum);
|
||||
playertextures[playernum] = TexMgr_LoadImage(currententity->model, name, paliashdr->skinwidth,
|
||||
paliashdr->skinheight,
|
||||
SRC_INDEXED, pixels, paliashdr->gltextures[skinnum][0]->source_file,
|
||||
paliashdr->gltextures[skinnum][0]->source_offset,
|
||||
TEXPREF_PAD | TEXPREF_OVERWRITE);
|
||||
|
||||
//now recolor it
|
||||
R_TranslatePlayerSkin (playernum);
|
||||
//now recolor it
|
||||
R_TranslatePlayerSkin(playernum);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -305,13 +296,12 @@ void R_TranslateNewPlayerSkin (int playernum)
|
||||
R_NewGame -- johnfitz -- handle a game switch
|
||||
===============
|
||||
*/
|
||||
void R_NewGame (void)
|
||||
{
|
||||
int i;
|
||||
void R_NewGame(void) {
|
||||
int i;
|
||||
|
||||
//clear playertexture pointers (the textures themselves were freed by texmgr_newgame)
|
||||
for (i=0; i<MAX_SCOREBOARD; i++)
|
||||
playertextures[i] = NULL;
|
||||
//clear playertexture pointers (the textures themselves were freed by texmgr_newgame)
|
||||
for (i = 0; i < MAX_SCOREBOARD; i++)
|
||||
playertextures[i] = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -321,52 +311,61 @@ R_ParseWorldspawn
|
||||
called at map load
|
||||
=============
|
||||
*/
|
||||
static void R_ParseWorldspawn (void)
|
||||
{
|
||||
char key[128], value[4096];
|
||||
const char *data;
|
||||
static void R_ParseWorldspawn() {
|
||||
map_wateralpha = r_wateralpha.value;
|
||||
map_lavaalpha = r_lavaalpha.value;
|
||||
map_telealpha = r_telealpha.value;
|
||||
map_slimealpha = r_slimealpha.value;
|
||||
|
||||
map_wateralpha = r_wateralpha.value;
|
||||
map_lavaalpha = r_lavaalpha.value;
|
||||
map_telealpha = r_telealpha.value;
|
||||
map_slimealpha = r_slimealpha.value;
|
||||
std::string key{};
|
||||
std::string value{};
|
||||
std::istringstream ss{cl.worldmodel->entities};
|
||||
|
||||
data = COM_Parse(cl.worldmodel->entities);
|
||||
if (!data)
|
||||
return; // error
|
||||
if (com_token[0] != '{')
|
||||
return; // error
|
||||
auto token = common::parse_token(ss);
|
||||
if (!token.has_value())
|
||||
return; // error
|
||||
if ((*token)[0] != '{')
|
||||
return; // error
|
||||
|
||||
while (1)
|
||||
{
|
||||
data = COM_Parse(data);
|
||||
if (!data)
|
||||
return; // error
|
||||
if (com_token[0] == '}')
|
||||
break; // end of worldspawn
|
||||
if (com_token[0] == '_')
|
||||
q_strlcpy(key, com_token + 1, sizeof(key));
|
||||
else
|
||||
q_strlcpy(key, com_token, sizeof(key));
|
||||
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
|
||||
key[strlen(key)-1] = 0;
|
||||
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
|
||||
if (!data)
|
||||
return; // error
|
||||
q_strlcpy(value, com_token, sizeof(value));
|
||||
while (true) {
|
||||
token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
return; // error
|
||||
}
|
||||
if ((*token)[0] == '}') {
|
||||
break; // end of worldspawn
|
||||
}
|
||||
if ((*token)[0] == '_') {
|
||||
key = token->substr(1);
|
||||
} else {
|
||||
key = *token;
|
||||
}
|
||||
while (!key.empty() && key.back() == ' ') {
|
||||
// remove trailing spaces
|
||||
key.pop_back();
|
||||
}
|
||||
token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
return; // error
|
||||
}
|
||||
value = *token;
|
||||
|
||||
if (!strcmp("wateralpha", key))
|
||||
map_wateralpha = atof(value);
|
||||
if (key == "wateralpha") {
|
||||
map_wateralpha = std::strtof(value.c_str(), nullptr);
|
||||
}
|
||||
|
||||
if (!strcmp("lavaalpha", key))
|
||||
map_lavaalpha = atof(value);
|
||||
if (key == "lavaalpha") {
|
||||
map_lavaalpha = std::strtof(value.c_str(), nullptr);
|
||||
}
|
||||
|
||||
if (!strcmp("telealpha", key))
|
||||
map_telealpha = atof(value);
|
||||
if (key == "telealpha") {
|
||||
map_telealpha = std::strtof(value.c_str(), nullptr);
|
||||
}
|
||||
|
||||
if (!strcmp("slimealpha", key))
|
||||
map_slimealpha = atof(value);
|
||||
}
|
||||
if (key == "slimealpha") {
|
||||
map_slimealpha = std::strtof(value.c_str(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -375,33 +374,32 @@ static void R_ParseWorldspawn (void)
|
||||
R_NewMap
|
||||
===============
|
||||
*/
|
||||
void R_NewMap (void)
|
||||
{
|
||||
int i;
|
||||
void R_NewMap(void) {
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<256 ; i++)
|
||||
d_lightstylevalue[i] = 264; // normal light value
|
||||
for (i = 0; i < 256; i++)
|
||||
d_lightstylevalue[i] = 264; // normal light value
|
||||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
// FIXME: is this one short?
|
||||
for (i=0 ; i<cl.worldmodel->numleafs ; i++)
|
||||
cl.worldmodel->leafs[i].efrags = NULL;
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
// FIXME: is this one short?
|
||||
for (i = 0; i < cl.worldmodel->numleafs; i++)
|
||||
cl.worldmodel->leafs[i].efrags = NULL;
|
||||
|
||||
r_viewleaf = NULL;
|
||||
R_ClearParticles ();
|
||||
r_viewleaf = NULL;
|
||||
R_ClearParticles();
|
||||
|
||||
GL_BuildLightmaps ();
|
||||
GL_BuildBModelVertexBuffer ();
|
||||
//ericw -- no longer load alias models into a VBO here, it's done in Mod_LoadAliasModel
|
||||
GL_BuildLightmaps();
|
||||
GL_BuildBModelVertexBuffer();
|
||||
//ericw -- no longer load alias models into a VBO here, it's done in Mod_LoadAliasModel
|
||||
|
||||
r_framecount = 0; //johnfitz -- paranoid?
|
||||
r_visframecount = 0; //johnfitz -- paranoid?
|
||||
r_framecount = 0; //johnfitz -- paranoid?
|
||||
r_visframecount = 0; //johnfitz -- paranoid?
|
||||
|
||||
Sky_NewMap (); //johnfitz -- skybox in worldspawn
|
||||
Fog_NewMap (); //johnfitz -- global fog in worldspawn
|
||||
R_ParseWorldspawn (); //ericw -- wateralpha, lavaalpha, telealpha, slimealpha in worldspawn
|
||||
Sky_NewMap(); //johnfitz -- skybox in worldspawn
|
||||
Fog_NewMap(); //johnfitz -- global fog in worldspawn
|
||||
R_ParseWorldspawn(); //ericw -- wateralpha, lavaalpha, telealpha, slimealpha in worldspawn
|
||||
|
||||
load_subdivide_size = gl_subdivide_size.value; //johnfitz -- is this the right place to set this?
|
||||
load_subdivide_size = gl_subdivide_size.value; //johnfitz -- is this the right place to set this?
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -411,75 +409,67 @@ R_TimeRefresh_f
|
||||
For program optimization
|
||||
====================
|
||||
*/
|
||||
void R_TimeRefresh_f (void)
|
||||
{
|
||||
int i;
|
||||
float start, stop, time;
|
||||
void R_TimeRefresh_f(void) {
|
||||
int i;
|
||||
float start, stop, time;
|
||||
|
||||
if (cls.state != ca_connected)
|
||||
{
|
||||
Con_Printf("Not connected to a server\n");
|
||||
return;
|
||||
}
|
||||
if (cls.state != ca_connected) {
|
||||
Con_Printf("Not connected to a server\n");
|
||||
return;
|
||||
}
|
||||
|
||||
start = Sys_DoubleTime ();
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
GL_BeginRendering(&glx, &gly, &glwidth, &glheight);
|
||||
r_refdef.viewangles[1] = i/128.0*360.0;
|
||||
R_RenderView ();
|
||||
GL_EndRendering ();
|
||||
}
|
||||
start = Sys_DoubleTime();
|
||||
for (i = 0; i < 128; i++) {
|
||||
GL_BeginRendering(&glx, &gly, &glwidth, &glheight);
|
||||
r_refdef.viewangles[1] = i / 128.0 * 360.0;
|
||||
R_RenderView();
|
||||
GL_EndRendering();
|
||||
}
|
||||
|
||||
glFinish ();
|
||||
stop = Sys_DoubleTime ();
|
||||
time = stop-start;
|
||||
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
|
||||
glFinish();
|
||||
stop = Sys_DoubleTime();
|
||||
time = stop - start;
|
||||
Con_Printf("%f seconds (%f fps)\n", time, 128 / time);
|
||||
}
|
||||
|
||||
void D_FlushCaches (void)
|
||||
{
|
||||
void D_FlushCaches(void) {
|
||||
}
|
||||
|
||||
static GLuint gl_programs[16];
|
||||
static int gl_num_programs;
|
||||
|
||||
static qboolean GL_CheckShader (GLuint shader)
|
||||
{
|
||||
GLint status;
|
||||
GL_GetShaderivFunc (shader, GL_COMPILE_STATUS, &status);
|
||||
static qboolean GL_CheckShader(GLuint shader) {
|
||||
GLint status;
|
||||
GL_GetShaderivFunc(shader, GL_COMPILE_STATUS, &status);
|
||||
|
||||
if (status != GL_TRUE)
|
||||
{
|
||||
char infolog[1024];
|
||||
if (status != GL_TRUE) {
|
||||
char infolog[1024];
|
||||
|
||||
memset(infolog, 0, sizeof(infolog));
|
||||
GL_GetShaderInfoLogFunc (shader, sizeof(infolog), NULL, infolog);
|
||||
memset(infolog, 0, sizeof(infolog));
|
||||
GL_GetShaderInfoLogFunc(shader, sizeof(infolog), NULL, infolog);
|
||||
|
||||
Con_Warning ("GLSL program failed to compile: %s", infolog);
|
||||
Con_Warning("GLSL program failed to compile: %s", infolog);
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static qboolean GL_CheckProgram (GLuint program)
|
||||
{
|
||||
GLint status;
|
||||
GL_GetProgramivFunc (program, GL_LINK_STATUS, &status);
|
||||
static qboolean GL_CheckProgram(GLuint program) {
|
||||
GLint status;
|
||||
GL_GetProgramivFunc(program, GL_LINK_STATUS, &status);
|
||||
|
||||
if (status != GL_TRUE)
|
||||
{
|
||||
char infolog[1024];
|
||||
if (status != GL_TRUE) {
|
||||
char infolog[1024];
|
||||
|
||||
memset(infolog, 0, sizeof(infolog));
|
||||
GL_GetProgramInfoLogFunc (program, sizeof(infolog), NULL, infolog);
|
||||
memset(infolog, 0, sizeof(infolog));
|
||||
GL_GetProgramInfoLogFunc(program, sizeof(infolog), NULL, infolog);
|
||||
|
||||
Con_Warning ("GLSL program failed to link: %s", infolog);
|
||||
Con_Warning("GLSL program failed to link: %s", infolog);
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -487,20 +477,18 @@ static qboolean GL_CheckProgram (GLuint program)
|
||||
GL_GetUniformLocation
|
||||
=============
|
||||
*/
|
||||
GLint GL_GetUniformLocation (GLuint *programPtr, const char *name)
|
||||
{
|
||||
GLint location;
|
||||
GLint GL_GetUniformLocation(GLuint *programPtr, const char *name) {
|
||||
GLint location;
|
||||
|
||||
if (!programPtr)
|
||||
return -1;
|
||||
if (!programPtr)
|
||||
return -1;
|
||||
|
||||
location = GL_GetUniformLocationFunc(*programPtr, name);
|
||||
if (location == -1)
|
||||
{
|
||||
Con_Warning("GL_GetUniformLocationFunc %s failed\n", name);
|
||||
*programPtr = 0;
|
||||
}
|
||||
return location;
|
||||
location = GL_GetUniformLocationFunc(*programPtr, name);
|
||||
if (location == -1) {
|
||||
Con_Warning("GL_GetUniformLocationFunc %s failed\n", name);
|
||||
*programPtr = 0;
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -510,61 +498,55 @@ GL_CreateProgram
|
||||
Compiles and returns GLSL program.
|
||||
====================
|
||||
*/
|
||||
GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int numbindings, const glsl_attrib_binding_t *bindings)
|
||||
{
|
||||
int i;
|
||||
GLuint program, vertShader, fragShader;
|
||||
GLuint GL_CreateProgram(const GLchar *vertSource, const GLchar *fragSource, int numbindings,
|
||||
const glsl_attrib_binding_t *bindings) {
|
||||
int i;
|
||||
GLuint program, vertShader, fragShader;
|
||||
|
||||
if (!gl_glsl_able)
|
||||
return 0;
|
||||
if (!gl_glsl_able)
|
||||
return 0;
|
||||
|
||||
vertShader = GL_CreateShaderFunc (GL_VERTEX_SHADER);
|
||||
GL_ShaderSourceFunc (vertShader, 1, &vertSource, NULL);
|
||||
GL_CompileShaderFunc (vertShader);
|
||||
if (!GL_CheckShader (vertShader))
|
||||
{
|
||||
GL_DeleteShaderFunc (vertShader);
|
||||
return 0;
|
||||
}
|
||||
vertShader = GL_CreateShaderFunc(GL_VERTEX_SHADER);
|
||||
GL_ShaderSourceFunc(vertShader, 1, &vertSource, NULL);
|
||||
GL_CompileShaderFunc(vertShader);
|
||||
if (!GL_CheckShader(vertShader)) {
|
||||
GL_DeleteShaderFunc(vertShader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fragShader = GL_CreateShaderFunc (GL_FRAGMENT_SHADER);
|
||||
GL_ShaderSourceFunc (fragShader, 1, &fragSource, NULL);
|
||||
GL_CompileShaderFunc (fragShader);
|
||||
if (!GL_CheckShader (fragShader))
|
||||
{
|
||||
GL_DeleteShaderFunc (vertShader);
|
||||
GL_DeleteShaderFunc (fragShader);
|
||||
return 0;
|
||||
}
|
||||
fragShader = GL_CreateShaderFunc(GL_FRAGMENT_SHADER);
|
||||
GL_ShaderSourceFunc(fragShader, 1, &fragSource, NULL);
|
||||
GL_CompileShaderFunc(fragShader);
|
||||
if (!GL_CheckShader(fragShader)) {
|
||||
GL_DeleteShaderFunc(vertShader);
|
||||
GL_DeleteShaderFunc(fragShader);
|
||||
return 0;
|
||||
}
|
||||
|
||||
program = GL_CreateProgramFunc ();
|
||||
GL_AttachShaderFunc (program, vertShader);
|
||||
GL_DeleteShaderFunc (vertShader);
|
||||
GL_AttachShaderFunc (program, fragShader);
|
||||
GL_DeleteShaderFunc (fragShader);
|
||||
program = GL_CreateProgramFunc();
|
||||
GL_AttachShaderFunc(program, vertShader);
|
||||
GL_DeleteShaderFunc(vertShader);
|
||||
GL_AttachShaderFunc(program, fragShader);
|
||||
GL_DeleteShaderFunc(fragShader);
|
||||
|
||||
for (i = 0; i < numbindings; i++)
|
||||
{
|
||||
GL_BindAttribLocationFunc (program, bindings[i].attrib, bindings[i].name);
|
||||
}
|
||||
for (i = 0; i < numbindings; i++) {
|
||||
GL_BindAttribLocationFunc(program, bindings[i].attrib, bindings[i].name);
|
||||
}
|
||||
|
||||
GL_LinkProgramFunc (program);
|
||||
GL_LinkProgramFunc(program);
|
||||
|
||||
if (!GL_CheckProgram (program))
|
||||
{
|
||||
GL_DeleteProgramFunc (program);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gl_num_programs == Q_COUNTOF(gl_programs))
|
||||
Host_Error ("gl_programs overflow");
|
||||
if (!GL_CheckProgram(program)) {
|
||||
GL_DeleteProgramFunc(program);
|
||||
return 0;
|
||||
} else {
|
||||
if (gl_num_programs == Q_COUNTOF(gl_programs))
|
||||
Host_Error("gl_programs overflow");
|
||||
|
||||
gl_programs[gl_num_programs] = program;
|
||||
gl_num_programs++;
|
||||
gl_programs[gl_num_programs] = program;
|
||||
gl_num_programs++;
|
||||
|
||||
return program;
|
||||
}
|
||||
return program;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -574,19 +556,17 @@ R_DeleteShaders
|
||||
Deletes any GLSL programs that have been created.
|
||||
====================
|
||||
*/
|
||||
void R_DeleteShaders (void)
|
||||
{
|
||||
int i;
|
||||
void R_DeleteShaders(void) {
|
||||
int i;
|
||||
|
||||
if (!gl_glsl_able)
|
||||
return;
|
||||
if (!gl_glsl_able)
|
||||
return;
|
||||
|
||||
for (i = 0; i < gl_num_programs; i++)
|
||||
{
|
||||
GL_DeleteProgramFunc (gl_programs[i]);
|
||||
gl_programs[i] = 0;
|
||||
}
|
||||
gl_num_programs = 0;
|
||||
for (i = 0; i < gl_num_programs; i++) {
|
||||
GL_DeleteProgramFunc(gl_programs[i]);
|
||||
gl_programs[i] = 0;
|
||||
}
|
||||
gl_num_programs = 0;
|
||||
}
|
||||
|
||||
static GLuint current_array_buffer, current_element_array_buffer;
|
||||
@@ -598,31 +578,28 @@ GL_BindBuffer
|
||||
glBindBuffer wrapper
|
||||
====================
|
||||
*/
|
||||
void GL_BindBuffer (GLenum target, GLuint buffer)
|
||||
{
|
||||
GLuint *cache;
|
||||
void GL_BindBuffer(GLenum target, GLuint buffer) {
|
||||
GLuint *cache;
|
||||
|
||||
if (!gl_vbo_able)
|
||||
return;
|
||||
if (!gl_vbo_able)
|
||||
return;
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case GL_ARRAY_BUFFER:
|
||||
cache = ¤t_array_buffer;
|
||||
break;
|
||||
case GL_ELEMENT_ARRAY_BUFFER:
|
||||
cache = ¤t_element_array_buffer;
|
||||
break;
|
||||
default:
|
||||
Host_Error("GL_BindBuffer: unsupported target %d", (int)target);
|
||||
return;
|
||||
}
|
||||
switch (target) {
|
||||
case GL_ARRAY_BUFFER:
|
||||
cache = ¤t_array_buffer;
|
||||
break;
|
||||
case GL_ELEMENT_ARRAY_BUFFER:
|
||||
cache = ¤t_element_array_buffer;
|
||||
break;
|
||||
default:
|
||||
Host_Error("GL_BindBuffer: unsupported target %d", (int) target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (*cache != buffer)
|
||||
{
|
||||
*cache = buffer;
|
||||
GL_BindBufferFunc (target, *cache);
|
||||
}
|
||||
if (*cache != buffer) {
|
||||
*cache = buffer;
|
||||
GL_BindBufferFunc(target, *cache);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -633,13 +610,12 @@ This must be called if you do anything that could make the cached bindings
|
||||
invalid (e.g. manually binding, destroying the context).
|
||||
====================
|
||||
*/
|
||||
void GL_ClearBufferBindings (void)
|
||||
{
|
||||
if (!gl_vbo_able)
|
||||
return;
|
||||
void GL_ClearBufferBindings(void) {
|
||||
if (!gl_vbo_able)
|
||||
return;
|
||||
|
||||
current_array_buffer = 0;
|
||||
current_element_array_buffer = 0;
|
||||
GL_BindBufferFunc (GL_ARRAY_BUFFER, 0);
|
||||
GL_BindBufferFunc (GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
current_array_buffer = 0;
|
||||
current_element_array_buffer = 0;
|
||||
GL_BindBufferFunc(GL_ARRAY_BUFFER, 0);
|
||||
GL_BindBufferFunc(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
+64
-64
@@ -78,30 +78,30 @@ float scr_con_current;
|
||||
float scr_conlines; // lines of console to display
|
||||
|
||||
//johnfitz -- new cvars
|
||||
cvar_t scr_menuscale = {"scr_menuscale", "1", CVAR_ARCHIVE};
|
||||
cvar_t scr_sbarscale = {"scr_sbarscale", "1", CVAR_ARCHIVE};
|
||||
cvar_t scr_sbaralpha = {"scr_sbaralpha", "0.75", CVAR_ARCHIVE};
|
||||
cvar_t scr_conwidth = {"scr_conwidth", "0", CVAR_ARCHIVE};
|
||||
cvar_t scr_conscale = {"scr_conscale", "1", CVAR_ARCHIVE};
|
||||
cvar_t scr_crosshairscale = {"scr_crosshairscale", "1", CVAR_ARCHIVE};
|
||||
cvar_t scr_showfps = {"scr_showfps", "0", CVAR_NONE};
|
||||
cvar_t scr_clock = {"scr_clock", "0", CVAR_NONE};
|
||||
convar scr_menuscale = {"scr_menuscale", "1", {.archive = true}};
|
||||
convar scr_sbarscale = {"scr_sbarscale", "1", {.archive = true}};
|
||||
convar scr_sbaralpha = {"scr_sbaralpha", "0.75", {.archive = true}};
|
||||
convar scr_conwidth = {"scr_conwidth", "0", {.archive = true}};
|
||||
convar scr_conscale = {"scr_conscale", "1", {.archive = true}};
|
||||
convar scr_crosshairscale = {"scr_crosshairscale", "1", {.archive = true}};
|
||||
convar scr_showfps = {"scr_showfps", "0"};
|
||||
convar scr_clock = {"scr_clock", "0"};
|
||||
//johnfitz
|
||||
cvar_t scr_usekfont = {"scr_usekfont", "0", CVAR_NONE}; // 2021 re-release
|
||||
convar scr_usekfont = {"scr_usekfont", "0"}; // 2021 re-release
|
||||
|
||||
cvar_t scr_viewsize = {"viewsize","100", CVAR_ARCHIVE};
|
||||
cvar_t scr_fov = {"fov","90",CVAR_NONE}; // 10 - 170
|
||||
cvar_t scr_fov_adapt = {"fov_adapt","1",CVAR_ARCHIVE};
|
||||
cvar_t scr_conspeed = {"scr_conspeed","500",CVAR_ARCHIVE};
|
||||
cvar_t scr_centertime = {"scr_centertime","2",CVAR_NONE};
|
||||
cvar_t scr_showturtle = {"showturtle","0",CVAR_NONE};
|
||||
cvar_t scr_showpause = {"showpause","1",CVAR_NONE};
|
||||
cvar_t scr_printspeed = {"scr_printspeed","8",CVAR_NONE};
|
||||
cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", CVAR_ARCHIVE};
|
||||
convar scr_viewsize = {"viewsize","100", {.archive = true}};
|
||||
convar scr_fov = {"fov","90"}; // 10 - 170
|
||||
convar scr_fov_adapt = {"fov_adapt","1",{.archive = true}};
|
||||
convar scr_conspeed = {"scr_conspeed","500",{.archive = true}};
|
||||
convar scr_centertime = {"scr_centertime","2"};
|
||||
convar scr_showturtle = {"showturtle","0"};
|
||||
convar scr_showpause = {"showpause","1"};
|
||||
convar scr_printspeed = {"scr_printspeed","8"};
|
||||
convar gl_triplebuffer = {"gl_triplebuffer", "1", {.archive = true}};
|
||||
|
||||
cvar_t cl_gun_fovscale = {"cl_gun_fovscale","1",CVAR_ARCHIVE}; // Qrack
|
||||
convar cl_gun_fovscale = {"cl_gun_fovscale","1",{.archive = true}}; // Qrack
|
||||
|
||||
extern cvar_t crosshair;
|
||||
extern convar crosshair;
|
||||
|
||||
qboolean scr_initialized; // ready to draw
|
||||
|
||||
@@ -291,15 +291,15 @@ static void SCR_CalcRefdef (void)
|
||||
|
||||
// bound viewsize
|
||||
if (scr_viewsize.value < 30)
|
||||
Cvar_SetQuick (&scr_viewsize, "30");
|
||||
scr_viewsize.set("30");
|
||||
if (scr_viewsize.value > 120)
|
||||
Cvar_SetQuick (&scr_viewsize, "120");
|
||||
scr_viewsize.set("120");
|
||||
|
||||
// bound fov
|
||||
if (scr_fov.value < 10)
|
||||
Cvar_SetQuick (&scr_fov, "10");
|
||||
scr_fov.set("10");
|
||||
if (scr_fov.value > 170)
|
||||
Cvar_SetQuick (&scr_fov, "170");
|
||||
scr_fov.set("170");
|
||||
|
||||
vid.recalc_refdef = 0;
|
||||
|
||||
@@ -314,12 +314,12 @@ static void SCR_CalcRefdef (void)
|
||||
else
|
||||
sb_lines = 48 * scale;
|
||||
|
||||
size = q_min(scr_viewsize.value, 100.f) / 100;
|
||||
size = std::min(scr_viewsize.value, 100.f) / 100;
|
||||
//johnfitz
|
||||
|
||||
//johnfitz -- rewrote this section
|
||||
r_refdef.vrect.width = q_max(glwidth * size, 96.0f); //no smaller than 96, for icons
|
||||
r_refdef.vrect.height = q_min((int)(glheight * size), glheight - sb_lines); //make room for sbar
|
||||
r_refdef.vrect.width = std::max(glwidth * size, 96.0f); //no smaller than 96, for icons
|
||||
r_refdef.vrect.height = std::min((int)(glheight * size), glheight - sb_lines); //make room for sbar
|
||||
r_refdef.vrect.x = (glwidth - r_refdef.vrect.width)/2;
|
||||
r_refdef.vrect.y = (glheight - sb_lines - r_refdef.vrect.height)/2;
|
||||
//johnfitz
|
||||
@@ -340,7 +340,7 @@ Keybinding command
|
||||
*/
|
||||
void SCR_SizeUp_f (void)
|
||||
{
|
||||
Cvar_SetValueQuick (&scr_viewsize, scr_viewsize.value+10);
|
||||
scr_viewsize.set_value(scr_viewsize.value+10);
|
||||
}
|
||||
|
||||
|
||||
@@ -353,10 +353,10 @@ Keybinding command
|
||||
*/
|
||||
void SCR_SizeDown_f (void)
|
||||
{
|
||||
Cvar_SetValueQuick (&scr_viewsize, scr_viewsize.value-10);
|
||||
scr_viewsize.set_value(scr_viewsize.value-10);
|
||||
}
|
||||
|
||||
static void SCR_Callback_refdef (cvar_t *var)
|
||||
static void SCR_Callback_refdef (convar *var)
|
||||
{
|
||||
vid.recalc_refdef = 1;
|
||||
}
|
||||
@@ -366,7 +366,7 @@ static void SCR_Callback_refdef (cvar_t *var)
|
||||
SCR_Conwidth_f -- johnfitz -- called when scr_conwidth or scr_conscale changes
|
||||
==================
|
||||
*/
|
||||
void SCR_Conwidth_f (cvar_t *var)
|
||||
void SCR_Conwidth_f (convar *var)
|
||||
{
|
||||
vid.recalc_refdef = 1;
|
||||
vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width;
|
||||
@@ -396,36 +396,36 @@ SCR_Init
|
||||
void SCR_Init (void)
|
||||
{
|
||||
//johnfitz -- new cvars
|
||||
Cvar_RegisterVariable (&scr_menuscale);
|
||||
Cvar_RegisterVariable (&scr_sbarscale);
|
||||
Cvar_SetCallback (&scr_sbaralpha, SCR_Callback_refdef);
|
||||
Cvar_RegisterVariable (&scr_sbaralpha);
|
||||
Cvar_SetCallback (&scr_conwidth, &SCR_Conwidth_f);
|
||||
Cvar_SetCallback (&scr_conscale, &SCR_Conwidth_f);
|
||||
Cvar_RegisterVariable (&scr_conwidth);
|
||||
Cvar_RegisterVariable (&scr_conscale);
|
||||
Cvar_RegisterVariable (&scr_crosshairscale);
|
||||
Cvar_RegisterVariable (&scr_showfps);
|
||||
Cvar_RegisterVariable (&scr_clock);
|
||||
scr_menuscale.inscribe();
|
||||
scr_sbarscale.inscribe();
|
||||
scr_sbaralpha.set_callback(SCR_Callback_refdef);
|
||||
scr_sbaralpha.inscribe();
|
||||
scr_conwidth.set_callback(&SCR_Conwidth_f);
|
||||
scr_conscale.set_callback(&SCR_Conwidth_f);
|
||||
scr_conwidth.inscribe();
|
||||
scr_conscale.inscribe();
|
||||
scr_crosshairscale.inscribe();
|
||||
scr_showfps.inscribe();
|
||||
scr_clock.inscribe();
|
||||
//johnfitz
|
||||
Cvar_RegisterVariable (&scr_usekfont); // 2021 re-release
|
||||
Cvar_SetCallback (&scr_fov, SCR_Callback_refdef);
|
||||
Cvar_SetCallback (&scr_fov_adapt, SCR_Callback_refdef);
|
||||
Cvar_SetCallback (&scr_viewsize, SCR_Callback_refdef);
|
||||
Cvar_RegisterVariable (&scr_fov);
|
||||
Cvar_RegisterVariable (&scr_fov_adapt);
|
||||
Cvar_RegisterVariable (&scr_viewsize);
|
||||
Cvar_RegisterVariable (&scr_conspeed);
|
||||
Cvar_RegisterVariable (&scr_showturtle);
|
||||
Cvar_RegisterVariable (&scr_showpause);
|
||||
Cvar_RegisterVariable (&scr_centertime);
|
||||
Cvar_RegisterVariable (&scr_printspeed);
|
||||
Cvar_RegisterVariable (&gl_triplebuffer);
|
||||
Cvar_RegisterVariable (&cl_gun_fovscale);
|
||||
scr_usekfont.inscribe(); // 2021 re-release
|
||||
scr_fov.set_callback(SCR_Callback_refdef);
|
||||
scr_fov_adapt.set_callback(SCR_Callback_refdef);
|
||||
scr_viewsize.set_callback(SCR_Callback_refdef);
|
||||
scr_fov.inscribe();
|
||||
scr_fov_adapt.inscribe();
|
||||
scr_viewsize.inscribe();
|
||||
scr_conspeed.inscribe();
|
||||
scr_showturtle.inscribe();
|
||||
scr_showpause.inscribe();
|
||||
scr_centertime.inscribe();
|
||||
scr_printspeed.inscribe();
|
||||
gl_triplebuffer.inscribe();
|
||||
cl_gun_fovscale.inscribe();
|
||||
|
||||
Cmd_AddCommand ("screenshot",SCR_ScreenShot_f);
|
||||
Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
|
||||
Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
|
||||
command::add ("screenshot",SCR_ScreenShot_f);
|
||||
command::add ("sizeup",SCR_SizeUp_f);
|
||||
command::add ("sizedown",SCR_SizeDown_f);
|
||||
|
||||
SCR_LoadPics (); //johnfitz
|
||||
|
||||
@@ -666,7 +666,7 @@ SCR_SetUpToDrawConsole
|
||||
void SCR_SetUpToDrawConsole (void)
|
||||
{
|
||||
//johnfitz -- let's hack away the problem of slow console when host_timescale is <0
|
||||
extern cvar_t host_timescale;
|
||||
extern convar host_timescale;
|
||||
float timescale, conspeed;
|
||||
//johnfitz
|
||||
|
||||
@@ -765,9 +765,9 @@ void SCR_ScreenShot_f (void)
|
||||
|
||||
Q_strncpy (ext, "png", sizeof(ext));
|
||||
|
||||
if (Cmd_Argc () >= 2)
|
||||
if (command::argc () >= 2)
|
||||
{
|
||||
const char *requested_ext = Cmd_Argv (1);
|
||||
const char *requested_ext = command::argv (1)->c_str();
|
||||
|
||||
if (!q_strcasecmp ("png", requested_ext)
|
||||
|| !q_strcasecmp ("tga", requested_ext)
|
||||
@@ -782,8 +782,8 @@ void SCR_ScreenShot_f (void)
|
||||
|
||||
// read quality as the 3rd param (only used for JPG)
|
||||
quality = 90;
|
||||
if (Cmd_Argc () >= 3)
|
||||
quality = Q_atoi (Cmd_Argv(2));
|
||||
if (command::argc () >= 3)
|
||||
quality = Q_atoi (command::argv(2)->c_str());
|
||||
if (quality < 1 || quality > 100)
|
||||
{
|
||||
SCR_ScreenShot_Usage ();
|
||||
|
||||
+55
-46
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//gl_sky.c
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
#define MAX_CLIP_VERTS 64
|
||||
@@ -40,11 +42,11 @@ static char skybox_name[1024]; //name of current skybox, or "" if no skybox
|
||||
static gltexture_t *skybox_textures[6];
|
||||
static gltexture_t *solidskytexture, *alphaskytexture;
|
||||
|
||||
extern cvar_t gl_farclip;
|
||||
static cvar_t r_fastsky = {"r_fastsky", "0", CVAR_NONE};
|
||||
static cvar_t r_sky_quality = {"r_sky_quality", "12", CVAR_NONE};
|
||||
static cvar_t r_skyalpha = {"r_skyalpha", "1", CVAR_NONE};
|
||||
static cvar_t r_skyfog = {"r_skyfog","0.5",CVAR_NONE};
|
||||
extern convar gl_farclip;
|
||||
static convar r_fastsky{"r_fastsky", "0"};
|
||||
static convar r_sky_quality{"r_sky_quality", "12"};
|
||||
static convar r_skyalpha{"r_skyalpha", "1"};
|
||||
static convar r_skyfog{"r_skyfog","0.5"};
|
||||
|
||||
static const int skytexorder[6] = {0,2,1,3,4,5}; //for skybox
|
||||
|
||||
@@ -298,53 +300,60 @@ Sky_NewMap
|
||||
*/
|
||||
void Sky_NewMap (void)
|
||||
{
|
||||
char key[128], value[4096];
|
||||
const char *data;
|
||||
|
||||
skyfog = r_skyfog.value;
|
||||
|
||||
std::string key{};
|
||||
std::string value{};
|
||||
|
||||
//
|
||||
// read worldspawn (this is so ugly, and shouldn't it be done on the server?)
|
||||
//
|
||||
data = cl.worldmodel->entities;
|
||||
if (!data)
|
||||
std::istringstream ss{cl.worldmodel->entities};
|
||||
if (ss.eof())
|
||||
return; //FIXME: how could this possibly ever happen? -- if there's no
|
||||
// worldspawn then the sever wouldn't send the loadmap message to the client
|
||||
|
||||
data = COM_Parse(data);
|
||||
if (!data) //should never happen
|
||||
auto token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
//should never happen
|
||||
return; // error
|
||||
if (com_token[0] != '{') //should never happen
|
||||
}
|
||||
if (token->front() != '{') {
|
||||
//should never happen
|
||||
return; // error
|
||||
while (1)
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
data = COM_Parse(data);
|
||||
if (!data)
|
||||
token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
return; // error
|
||||
if (com_token[0] == '}')
|
||||
}
|
||||
if (token->front() == '}') {
|
||||
break; // end of worldspawn
|
||||
if (com_token[0] == '_')
|
||||
q_strlcpy(key, com_token + 1, sizeof(key));
|
||||
else
|
||||
q_strlcpy(key, com_token, sizeof(key));
|
||||
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
|
||||
key[strlen(key)-1] = 0;
|
||||
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
|
||||
if (!data)
|
||||
}
|
||||
if (token->front() == '_') {
|
||||
key = token->substr(1);
|
||||
}
|
||||
else {
|
||||
key = token.value();
|
||||
}
|
||||
while (!key.empty() && key.back() == ' ') {
|
||||
key.pop_back();
|
||||
}
|
||||
|
||||
token = common::parse_token(ss);
|
||||
if (!token.has_value()) {
|
||||
return; // error
|
||||
q_strlcpy(value, com_token, sizeof(value));
|
||||
}
|
||||
value = token.value();
|
||||
|
||||
if (!strcmp("sky", key))
|
||||
Sky_LoadSkyBox(value);
|
||||
if (key == "sky" || key == "skyname" || key == "qlsky") {
|
||||
Sky_LoadSkyBox(value.c_str());
|
||||
}
|
||||
|
||||
if (!strcmp("skyfog", key))
|
||||
skyfog = atof(value);
|
||||
#if 1 /* also accept non-standard keys */
|
||||
else if (!strcmp("skyname", key)) //half-life
|
||||
Sky_LoadSkyBox(value);
|
||||
else if (!strcmp("qlsky", key)) //quake lives
|
||||
Sky_LoadSkyBox(value);
|
||||
#endif
|
||||
if (key == "skyfog") {
|
||||
skyfog = std::strtof(value.c_str(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,13 +364,13 @@ Sky_SkyCommand_f
|
||||
*/
|
||||
void Sky_SkyCommand_f (void)
|
||||
{
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
Con_Printf("\"sky\" is \"%s\"\n", skybox_name);
|
||||
break;
|
||||
case 2:
|
||||
Sky_LoadSkyBox(Cmd_Argv(1));
|
||||
Sky_LoadSkyBox(command::argv(1)->c_str());
|
||||
break;
|
||||
default:
|
||||
Con_Printf("usage: sky <skyname>\n");
|
||||
@@ -373,7 +382,7 @@ void Sky_SkyCommand_f (void)
|
||||
R_SetSkyfog_f -- ericw
|
||||
====================
|
||||
*/
|
||||
static void R_SetSkyfog_f (cvar_t *var)
|
||||
static void R_SetSkyfog_f (convar *var)
|
||||
{
|
||||
// clear any skyfog setting from worldspawn
|
||||
skyfog = var->value;
|
||||
@@ -388,13 +397,13 @@ void Sky_Init (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
Cvar_RegisterVariable (&r_fastsky);
|
||||
Cvar_RegisterVariable (&r_sky_quality);
|
||||
Cvar_RegisterVariable (&r_skyalpha);
|
||||
Cvar_RegisterVariable (&r_skyfog);
|
||||
Cvar_SetCallback (&r_skyfog, R_SetSkyfog_f);
|
||||
r_fastsky.inscribe();
|
||||
r_sky_quality.inscribe();
|
||||
r_skyalpha.inscribe();
|
||||
r_skyfog.inscribe();
|
||||
r_skyfog.set_callback(R_SetSkyfog_f);
|
||||
|
||||
Cmd_AddCommand ("sky",Sky_SkyCommand_f);
|
||||
command::add ("sky",Sky_SkyCommand_f);
|
||||
|
||||
skybox_name[0] = 0;
|
||||
for (i=0; i<6; i++)
|
||||
@@ -1020,7 +1029,7 @@ void Sky_DrawFace (int axis)
|
||||
VectorSubtract(verts[2],verts[3],up);
|
||||
VectorSubtract(verts[2],verts[1],right);
|
||||
|
||||
di = q_max((int)r_sky_quality.value, 1);
|
||||
di = std::max((int)r_sky_quality.value, 1);
|
||||
qi = 1.0 / di;
|
||||
dj = (axis < 4) ? di*2 : di; //subdivide vertically more than horizontally on skybox sides
|
||||
qj = 1.0 / dj;
|
||||
|
||||
+933
-1011
File diff suppressed because it is too large
Load Diff
+1381
-1537
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -22,11 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
extern cvar_t r_drawflat;
|
||||
extern convar r_drawflat;
|
||||
|
||||
cvar_t r_oldwater = {"r_oldwater", "0", CVAR_ARCHIVE};
|
||||
cvar_t r_waterquality = {"r_waterquality", "8", CVAR_NONE};
|
||||
cvar_t r_waterwarp = {"r_waterwarp", "1", CVAR_NONE};
|
||||
convar r_oldwater{"r_oldwater", "0", {.archive = true}};
|
||||
convar r_waterquality{"r_waterquality", "8"};
|
||||
convar r_waterwarp{"r_waterwarp", "1"};
|
||||
|
||||
int gl_warpimagesize;
|
||||
float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded
|
||||
@@ -46,7 +46,7 @@ static const float turbsin[] = {
|
||||
|
||||
static msurface_t *warpface;
|
||||
|
||||
cvar_t gl_subdivide_size = {"gl_subdivide_size", "128", CVAR_ARCHIVE};
|
||||
convar gl_subdivide_size{"gl_subdivide_size", "128", {.archive = true}};
|
||||
|
||||
static void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs)
|
||||
{
|
||||
|
||||
+30
-30
@@ -125,38 +125,38 @@ extern refdef_t r_refdef;
|
||||
extern mleaf_t *r_viewleaf, *r_oldviewleaf;
|
||||
extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
|
||||
|
||||
extern cvar_t r_norefresh;
|
||||
extern cvar_t r_drawentities;
|
||||
extern cvar_t r_drawworld;
|
||||
extern cvar_t r_drawviewmodel;
|
||||
extern cvar_t r_speeds;
|
||||
extern cvar_t r_pos;
|
||||
extern cvar_t r_waterwarp;
|
||||
extern cvar_t r_fullbright;
|
||||
extern cvar_t r_lightmap;
|
||||
extern cvar_t r_lightmapwide;
|
||||
extern cvar_t r_shadows;
|
||||
extern cvar_t r_wateralpha;
|
||||
extern cvar_t r_lavaalpha;
|
||||
extern cvar_t r_telealpha;
|
||||
extern cvar_t r_slimealpha;
|
||||
extern cvar_t r_litwater;
|
||||
extern cvar_t r_dynamic;
|
||||
extern cvar_t r_novis;
|
||||
extern cvar_t r_scale;
|
||||
extern convar r_norefresh;
|
||||
extern convar r_drawentities;
|
||||
extern convar r_drawworld;
|
||||
extern convar r_drawviewmodel;
|
||||
extern convar r_speeds;
|
||||
extern convar r_pos;
|
||||
extern convar r_waterwarp;
|
||||
extern convar r_fullbright;
|
||||
extern convar r_lightmap;
|
||||
extern convar r_lightmapwide;
|
||||
extern convar r_shadows;
|
||||
extern convar r_wateralpha;
|
||||
extern convar r_lavaalpha;
|
||||
extern convar r_telealpha;
|
||||
extern convar r_slimealpha;
|
||||
extern convar r_litwater;
|
||||
extern convar r_dynamic;
|
||||
extern convar r_novis;
|
||||
extern convar r_scale;
|
||||
|
||||
extern cvar_t gl_clear;
|
||||
extern cvar_t gl_cull;
|
||||
extern cvar_t gl_smoothmodels;
|
||||
extern cvar_t gl_affinemodels;
|
||||
extern cvar_t gl_polyblend;
|
||||
extern cvar_t gl_flashblend;
|
||||
extern cvar_t gl_nocolors;
|
||||
extern cvar_t gl_finish;
|
||||
extern convar gl_clear;
|
||||
extern convar gl_cull;
|
||||
extern convar gl_smoothmodels;
|
||||
extern convar gl_affinemodels;
|
||||
extern convar gl_polyblend;
|
||||
extern convar gl_flashblend;
|
||||
extern convar gl_nocolors;
|
||||
extern convar gl_finish;
|
||||
|
||||
extern cvar_t gl_playermip;
|
||||
extern convar gl_playermip;
|
||||
|
||||
extern cvar_t gl_subdivide_size;
|
||||
extern convar gl_subdivide_size;
|
||||
extern float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded
|
||||
|
||||
extern int gl_stencilbits;
|
||||
@@ -281,7 +281,7 @@ extern int rs_brushpolys, rs_aliaspolys, rs_skypolys;
|
||||
extern int rs_dynamiclightmaps, rs_brushpasses, rs_aliaspasses, rs_skypasses;
|
||||
|
||||
//johnfitz -- track developer statistics that vary every frame
|
||||
extern cvar_t devstats;
|
||||
extern convar devstats;
|
||||
typedef struct {
|
||||
int packetsize;
|
||||
int edicts;
|
||||
|
||||
+60
-60
@@ -57,35 +57,35 @@ jmp_buf host_abortserver;
|
||||
|
||||
byte *host_colormap;
|
||||
|
||||
cvar_t host_framerate = {"host_framerate","0",CVAR_NONE}; // set for slow motion
|
||||
cvar_t host_speeds = {"host_speeds","0",CVAR_NONE}; // set for running times
|
||||
cvar_t host_maxfps = {"host_maxfps", "72", CVAR_ARCHIVE}; //johnfitz
|
||||
cvar_t host_timescale = {"host_timescale", "0", CVAR_NONE}; //johnfitz
|
||||
cvar_t max_edicts = {"max_edicts", "8192", CVAR_NONE}; //johnfitz //ericw -- changed from 2048 to 8192, removed CVAR_ARCHIVE
|
||||
convar host_framerate = {"host_framerate","0"}; // set for slow motion
|
||||
convar host_speeds = {"host_speeds","0"}; // set for running times
|
||||
convar host_maxfps = {"host_maxfps", "72", {.archive = true}}; //johnfitz
|
||||
convar host_timescale = {"host_timescale", "0"}; //johnfitz
|
||||
convar max_edicts = {"max_edicts", "8192"}; //johnfitz //ericw -- changed from 2048 to 8192, removed CVAR_ARCHIVE
|
||||
|
||||
cvar_t sys_ticrate = {"sys_ticrate","0.05",CVAR_NONE}; // dedicated server
|
||||
cvar_t serverprofile = {"serverprofile","0",CVAR_NONE};
|
||||
convar sys_ticrate = {"sys_ticrate","0.05"}; // dedicated server
|
||||
convar serverprofile = {"serverprofile","0"};
|
||||
|
||||
cvar_t fraglimit = {"fraglimit","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
||||
cvar_t timelimit = {"timelimit","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
||||
cvar_t teamplay = {"teamplay","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
||||
cvar_t samelevel = {"samelevel","0",CVAR_NONE};
|
||||
cvar_t noexit = {"noexit","0",CVAR_NOTIFY|CVAR_SERVERINFO};
|
||||
cvar_t skill = {"skill","1",CVAR_NONE}; // 0 - 3
|
||||
cvar_t deathmatch = {"deathmatch","0",CVAR_NONE}; // 0, 1, or 2
|
||||
cvar_t coop = {"coop","0",CVAR_NONE}; // 0 or 1
|
||||
convar fraglimit = {"fraglimit","0",{.notify = true, .server_info = true}};
|
||||
convar timelimit = {"timelimit","0", {.notify = true, .server_info = true}};
|
||||
convar teamplay = {"teamplay","0",{.notify = true, .server_info = true}};
|
||||
convar samelevel = {"samelevel","0"};
|
||||
convar noexit = {"noexit","0",{.notify = true, .server_info = true}};
|
||||
convar skill = {"skill","1"}; // 0 - 3
|
||||
convar deathmatch = {"deathmatch","0"}; // 0, 1, or 2
|
||||
convar coop = {"coop","0"}; // 0 or 1
|
||||
|
||||
cvar_t pausable = {"pausable","1",CVAR_NONE};
|
||||
convar pausable = {"pausable","1"};
|
||||
|
||||
cvar_t developer = {"developer","0",CVAR_NONE};
|
||||
convar developer = {"developer","0"};
|
||||
|
||||
cvar_t temp1 = {"temp1","0",CVAR_NONE};
|
||||
convar temp1 = {"temp1","0"};
|
||||
|
||||
cvar_t devstats = {"devstats","0",CVAR_NONE}; //johnfitz -- track developer statistics that vary every frame
|
||||
convar devstats = {"devstats","0"}; //johnfitz -- track developer statistics that vary every frame
|
||||
|
||||
cvar_t campaign = {"campaign","0",CVAR_NONE}; // for the 2021 rerelease
|
||||
cvar_t horde = {"horde","0",CVAR_NONE}; // for the 2021 rerelease
|
||||
cvar_t sv_cheats = {"sv_cheats","0",CVAR_NONE}; // for the 2021 rerelease
|
||||
convar campaign = {"campaign","0"}; // for the 2021 rerelease
|
||||
convar horde = {"horde","0"}; // for the 2021 rerelease
|
||||
convar sv_cheats = {"sv_cheats","0"}; // for the 2021 rerelease
|
||||
|
||||
devstats_t dev_stats, dev_peakstats;
|
||||
overflowtimes_t dev_overflows; //this stores the last time overflow messages were displayed, not the last time overflows occured
|
||||
@@ -95,7 +95,7 @@ overflowtimes_t dev_overflows; //this stores the last time overflow messages wer
|
||||
Max_Edicts_f -- johnfitz
|
||||
================
|
||||
*/
|
||||
static void Max_Edicts_f (cvar_t *var)
|
||||
static void Max_Edicts_f (convar *var)
|
||||
{
|
||||
//TODO: clamp it here?
|
||||
if (cls.state == ca_connected || sv.active)
|
||||
@@ -107,7 +107,7 @@ static void Max_Edicts_f (cvar_t *var)
|
||||
Max_Fps_f -- ericw
|
||||
================
|
||||
*/
|
||||
static void Max_Fps_f (cvar_t *var)
|
||||
static void Max_Fps_f (convar *var)
|
||||
{
|
||||
if (var->value > 72)
|
||||
Con_Warning ("host_maxfps above 72 breaks physics.\n");
|
||||
@@ -227,9 +227,9 @@ void Host_FindMaxClients (void)
|
||||
svs.clients = (struct client_s *) Hunk_AllocName (svs.maxclientslimit*sizeof(client_t), "clients");
|
||||
|
||||
if (svs.maxclients > 1)
|
||||
Cvar_SetQuick (&deathmatch, "1");
|
||||
deathmatch.set("1");
|
||||
else
|
||||
Cvar_SetQuick (&deathmatch, "0");
|
||||
deathmatch.set("0");
|
||||
}
|
||||
|
||||
void Host_Version_f (void)
|
||||
@@ -240,10 +240,10 @@ void Host_Version_f (void)
|
||||
}
|
||||
|
||||
/* cvar callback functions : */
|
||||
void Host_Callback_Notify (cvar_t *var)
|
||||
void Host_Callback_Notify (convar *var)
|
||||
{
|
||||
if (sv.active)
|
||||
SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string);
|
||||
SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name.c_str(), var->string);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -253,45 +253,45 @@ Host_InitLocal
|
||||
*/
|
||||
void Host_InitLocal (void)
|
||||
{
|
||||
Cmd_AddCommand ("version", Host_Version_f);
|
||||
command::add ("version", Host_Version_f);
|
||||
|
||||
Host_InitCommands ();
|
||||
|
||||
Cvar_RegisterVariable (&host_framerate);
|
||||
Cvar_RegisterVariable (&host_speeds);
|
||||
Cvar_RegisterVariable (&host_maxfps); //johnfitz
|
||||
Cvar_SetCallback (&host_maxfps, Max_Fps_f);
|
||||
Cvar_RegisterVariable (&host_timescale); //johnfitz
|
||||
host_framerate.inscribe();
|
||||
host_speeds.inscribe();
|
||||
host_maxfps.inscribe(); //johnfitz
|
||||
host_maxfps.set_callback(Max_Fps_f);
|
||||
host_timescale.inscribe(); //johnfitz
|
||||
|
||||
Cvar_RegisterVariable (&max_edicts); //johnfitz
|
||||
Cvar_SetCallback (&max_edicts, Max_Edicts_f);
|
||||
Cvar_RegisterVariable (&devstats); //johnfitz
|
||||
max_edicts.inscribe(); //johnfitz
|
||||
max_edicts.set_callback(Max_Edicts_f);
|
||||
devstats.inscribe(); //johnfitz
|
||||
|
||||
Cvar_RegisterVariable (&sys_ticrate);
|
||||
Cvar_RegisterVariable (&sys_throttle);
|
||||
Cvar_RegisterVariable (&serverprofile);
|
||||
sys_ticrate.inscribe();
|
||||
sys_throttle.inscribe();
|
||||
serverprofile.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&fraglimit);
|
||||
Cvar_RegisterVariable (&timelimit);
|
||||
Cvar_RegisterVariable (&teamplay);
|
||||
Cvar_SetCallback (&fraglimit, Host_Callback_Notify);
|
||||
Cvar_SetCallback (&timelimit, Host_Callback_Notify);
|
||||
Cvar_SetCallback (&teamplay, Host_Callback_Notify);
|
||||
Cvar_RegisterVariable (&samelevel);
|
||||
Cvar_RegisterVariable (&noexit);
|
||||
Cvar_SetCallback (&noexit, Host_Callback_Notify);
|
||||
Cvar_RegisterVariable (&skill);
|
||||
Cvar_RegisterVariable (&developer);
|
||||
Cvar_RegisterVariable (&coop);
|
||||
Cvar_RegisterVariable (&deathmatch);
|
||||
fraglimit.inscribe();
|
||||
timelimit.inscribe();
|
||||
teamplay.inscribe();
|
||||
fraglimit.set_callback(Host_Callback_Notify);
|
||||
timelimit.set_callback(Host_Callback_Notify);
|
||||
teamplay.set_callback(Host_Callback_Notify);
|
||||
samelevel.inscribe();
|
||||
noexit.inscribe();
|
||||
noexit.set_callback(Host_Callback_Notify);
|
||||
skill.inscribe();
|
||||
developer.inscribe();
|
||||
coop.inscribe();
|
||||
deathmatch.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&campaign);
|
||||
Cvar_RegisterVariable (&horde);
|
||||
Cvar_RegisterVariable (&sv_cheats);
|
||||
campaign.inscribe();
|
||||
horde.inscribe();
|
||||
sv_cheats.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&pausable);
|
||||
pausable.inscribe();
|
||||
|
||||
Cvar_RegisterVariable (&temp1);
|
||||
temp1.inscribe();
|
||||
|
||||
Host_FindMaxClients ();
|
||||
}
|
||||
@@ -661,7 +661,7 @@ void Host_ServerFrame (void)
|
||||
if (active > 600 && dev_peakstats.edicts <= 600)
|
||||
Con_DWarning ("%i edicts exceeds standard limit of 600 (max = %d).\n", active, sv.max_edicts);
|
||||
dev_stats.edicts = active;
|
||||
dev_peakstats.edicts = q_max(active, dev_peakstats.edicts);
|
||||
dev_peakstats.edicts = std::max(active, dev_peakstats.edicts);
|
||||
}
|
||||
//johnfitz
|
||||
|
||||
@@ -832,7 +832,7 @@ void Host_Init (void)
|
||||
|
||||
Memory_Init (host_parms->membase, host_parms->memsize);
|
||||
Cbuf_Init ();
|
||||
Cmd_Init ();
|
||||
command::init ();
|
||||
LOG_Init (host_parms);
|
||||
Cvar_Init (); //johnfitz
|
||||
COM_Init ();
|
||||
|
||||
+182
-176
@@ -21,12 +21,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
#ifndef _WIN32
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
extern cvar_t pausable;
|
||||
extern convar pausable;
|
||||
|
||||
int current_skill;
|
||||
|
||||
@@ -425,11 +427,11 @@ static void Host_Status_f (void)
|
||||
int hours = 0;
|
||||
int j;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (!sv.active)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
print_fn = Con_Printf;
|
||||
@@ -437,7 +439,7 @@ static void Host_Status_f (void)
|
||||
else
|
||||
print_fn = SV_ClientPrintf;
|
||||
|
||||
print_fn ("host: %s\n", Cvar_VariableString ("hostname"));
|
||||
print_fn ("host: %s\n", convar::variable_string("hostname").value_or("").c_str());
|
||||
print_fn ("version: %4.2f\n", VERSION);
|
||||
if (tcpipAvailable)
|
||||
print_fn ("tcp/ip: %s\n", my_tcpip_address);
|
||||
@@ -474,9 +476,9 @@ Sets client to godmode
|
||||
*/
|
||||
static void Host_God_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -484,7 +486,7 @@ static void Host_God_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set god mode to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
|
||||
@@ -493,8 +495,8 @@ static void Host_God_f (void)
|
||||
else
|
||||
SV_ClientPrintf ("godmode ON\n");
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
sv_player->v.flags = (int)sv_player->v.flags | FL_GODMODE;
|
||||
SV_ClientPrintf ("godmode ON\n");
|
||||
@@ -513,9 +515,9 @@ static void Host_God_f (void)
|
||||
}
|
||||
|
||||
static void Host_Buddha_f (void) {
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -536,9 +538,9 @@ Host_Notarget_f
|
||||
*/
|
||||
static void Host_Notarget_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -546,7 +548,7 @@ static void Host_Notarget_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set notarget to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
|
||||
@@ -555,8 +557,8 @@ static void Host_Notarget_f (void)
|
||||
else
|
||||
SV_ClientPrintf ("notarget ON\n");
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
sv_player->v.flags = (int)sv_player->v.flags | FL_NOTARGET;
|
||||
SV_ClientPrintf ("notarget ON\n");
|
||||
@@ -583,9 +585,9 @@ Host_Noclip_f
|
||||
*/
|
||||
static void Host_Noclip_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -593,7 +595,7 @@ static void Host_Noclip_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set noclip to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
|
||||
@@ -609,8 +611,8 @@ static void Host_Noclip_f (void)
|
||||
SV_ClientPrintf ("noclip OFF\n");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
noclip_anglehack = true;
|
||||
sv_player->v.movetype = MOVETYPE_NOCLIP;
|
||||
@@ -639,16 +641,15 @@ adapted from fteqw, originally by Alex Shadowalker
|
||||
*/
|
||||
static void Host_SetPos_f(void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pr_global_struct->deathmatch)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 7 && Cmd_Argc() != 4)
|
||||
if (command::argc() != 7 && command::argc() != 4)
|
||||
{
|
||||
SV_ClientPrintf("usage:\n");
|
||||
SV_ClientPrintf(" setpos <x> <y> <z>\n");
|
||||
@@ -676,15 +677,15 @@ static void Host_SetPos_f(void)
|
||||
sv_player->v.velocity[1] = 0;
|
||||
sv_player->v.velocity[2] = 0;
|
||||
|
||||
sv_player->v.origin[0] = atof(Cmd_Argv(1));
|
||||
sv_player->v.origin[1] = atof(Cmd_Argv(2));
|
||||
sv_player->v.origin[2] = atof(Cmd_Argv(3));
|
||||
sv_player->v.origin[0] = atof(command::argv(1)->c_str());
|
||||
sv_player->v.origin[1] = atof(command::argv(2)->c_str());
|
||||
sv_player->v.origin[2] = atof(command::argv(3)->c_str());
|
||||
|
||||
if (Cmd_Argc() == 7)
|
||||
if (command::argc() == 7)
|
||||
{
|
||||
sv_player->v.angles[0] = atof(Cmd_Argv(4));
|
||||
sv_player->v.angles[1] = atof(Cmd_Argv(5));
|
||||
sv_player->v.angles[2] = atof(Cmd_Argv(6));
|
||||
sv_player->v.angles[0] = atof(command::argv(4)->c_str());
|
||||
sv_player->v.angles[1] = atof(command::argv(5)->c_str());
|
||||
sv_player->v.angles[2] = atof(command::argv(6)->c_str());
|
||||
sv_player->v.fixangle = 1;
|
||||
}
|
||||
|
||||
@@ -700,9 +701,9 @@ Sets client to flymode
|
||||
*/
|
||||
static void Host_Fly_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -710,7 +711,7 @@ static void Host_Fly_f (void)
|
||||
return;
|
||||
|
||||
//johnfitz -- allow user to explicitly set noclip to on or off
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
if (sv_player->v.movetype != MOVETYPE_FLY)
|
||||
@@ -724,8 +725,8 @@ static void Host_Fly_f (void)
|
||||
SV_ClientPrintf ("flymode OFF\n");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (Q_atof(Cmd_Argv(1)))
|
||||
case 2:
|
||||
if (Q_atof(command::argv(1)->c_str()))
|
||||
{
|
||||
sv_player->v.movetype = MOVETYPE_FLY;
|
||||
SV_ClientPrintf ("flymode ON\n");
|
||||
@@ -755,9 +756,9 @@ static void Host_Ping_f (void)
|
||||
float total;
|
||||
client_t *client;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -796,7 +797,7 @@ static void Host_Map_f (void)
|
||||
int i;
|
||||
char name[MAX_QPATH], *p;
|
||||
|
||||
if (Cmd_Argc() < 2) //no map name given
|
||||
if (command::argc() < 2) //no map name given
|
||||
{
|
||||
if (cls.state == ca_dedicated)
|
||||
{
|
||||
@@ -816,8 +817,10 @@ static void Host_Map_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cls.demonum = -1; // stop demo loop in case this fails
|
||||
|
||||
@@ -830,7 +833,7 @@ static void Host_Map_f (void)
|
||||
SCR_BeginLoadingPlaque ();
|
||||
|
||||
svs.serverflags = 0; // haven't completed an episode yet
|
||||
q_strlcpy (name, Cmd_Argv(1), sizeof(name));
|
||||
q_strlcpy (name, command::argv(1)->c_str(), sizeof(name));
|
||||
// remove (any) trailing ".bsp" from mapname -- S.A.
|
||||
p = strstr(name, ".bsp");
|
||||
if (p && p[4] == '\0')
|
||||
@@ -842,13 +845,13 @@ static void Host_Map_f (void)
|
||||
if (cls.state != ca_dedicated)
|
||||
{
|
||||
memset (cls.spawnparms, 0, MAX_MAPSTRING);
|
||||
for (i = 2; i < Cmd_Argc(); i++)
|
||||
for (i = 2; i < command::argc(); i++)
|
||||
{
|
||||
q_strlcat (cls.spawnparms, Cmd_Argv(i), MAX_MAPSTRING);
|
||||
q_strlcat (cls.spawnparms, command::argv(i)->c_str(), MAX_MAPSTRING);
|
||||
q_strlcat (cls.spawnparms, " ", MAX_MAPSTRING);
|
||||
}
|
||||
|
||||
Cmd_ExecuteString ("connect local", src_command);
|
||||
command::execute_string ("connect local", command::source::command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,7 +867,7 @@ static void Host_Randmap_f (void)
|
||||
int i, randlevel, numlevels;
|
||||
filelist_item_t *level;
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
for (level = extralevels, numlevels = 0; level; level = level->next)
|
||||
@@ -900,7 +903,7 @@ static void Host_Changelevel_f (void)
|
||||
{
|
||||
char level[MAX_QPATH];
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("changelevel <levelname> : continue game on a new level\n");
|
||||
return;
|
||||
@@ -912,7 +915,7 @@ static void Host_Changelevel_f (void)
|
||||
}
|
||||
|
||||
//johnfitz -- check for client having map before anything else
|
||||
q_snprintf (level, sizeof(level), "maps/%s.bsp", Cmd_Argv(1));
|
||||
q_snprintf (level, sizeof(level), "maps/%s.bsp", command::argv(1)->c_str());
|
||||
if (!COM_FileExists(level, NULL))
|
||||
Host_Error ("cannot find map %s", level);
|
||||
//johnfitz
|
||||
@@ -921,7 +924,7 @@ static void Host_Changelevel_f (void)
|
||||
IN_Activate(); // -- S.A.
|
||||
key_dest = key_game; // remove console or menu
|
||||
SV_SaveSpawnparms ();
|
||||
q_strlcpy (level, Cmd_Argv(1), sizeof(level));
|
||||
q_strlcpy (level, command::argv(1)->c_str(), sizeof(level));
|
||||
SV_SpawnServer (level);
|
||||
// also issue an error if spawn failed -- O.S.
|
||||
if (!sv.active)
|
||||
@@ -942,7 +945,7 @@ static void Host_Restart_f (void)
|
||||
if (cls.demoplayback || !sv.active)
|
||||
return;
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
q_strlcpy (mapname, sv.name, sizeof(mapname)); // mapname gets cleared in spawnserver
|
||||
SV_SpawnServer (mapname);
|
||||
@@ -984,7 +987,7 @@ static void Host_Connect_f (void)
|
||||
CL_StopPlayback ();
|
||||
CL_Disconnect ();
|
||||
}
|
||||
q_strlcpy (name, Cmd_Argv(1), sizeof(name));
|
||||
q_strlcpy (name, command::argv(1).value_or("").c_str(), sizeof(name));
|
||||
CL_EstablishConnection (name);
|
||||
Host_Reconnect_f ();
|
||||
}
|
||||
@@ -1051,7 +1054,7 @@ static void Host_Savegame_f (void)
|
||||
int i;
|
||||
char comment[SAVEGAME_COMMENT_LENGTH+1];
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (!sv.active)
|
||||
@@ -1072,13 +1075,13 @@ static void Host_Savegame_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("save <savename> : save a game\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(Cmd_Argv(1), ".."))
|
||||
if (strstr(command::argv(1)->c_str(), ".."))
|
||||
{
|
||||
Con_Printf ("Relative pathnames are not allowed.\n");
|
||||
return;
|
||||
@@ -1093,7 +1096,7 @@ static void Host_Savegame_f (void)
|
||||
}
|
||||
}
|
||||
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1)->c_str());
|
||||
COM_AddExtension (name, ".sav", sizeof(name));
|
||||
|
||||
Con_Printf ("Saving game to %s...\n", name);
|
||||
@@ -1143,24 +1146,22 @@ static void Host_Loadgame_f (void)
|
||||
|
||||
char name[MAX_OSPATH];
|
||||
char mapname[MAX_QPATH];
|
||||
float time, tfloat;
|
||||
const char *data;
|
||||
int i;
|
||||
edict_t *ent;
|
||||
int entnum;
|
||||
int version;
|
||||
float spawn_parms[NUM_SPAWN_PARMS];
|
||||
|
||||
if (cmd_source != src_command)
|
||||
if (command::last_source != command::source::command)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("load <savename> : load a game\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr(Cmd_Argv(1), ".."))
|
||||
if (strstr(command::argv(1)->c_str(), ".."))
|
||||
{
|
||||
Con_Printf ("Relative pathnames are not allowed.\n");
|
||||
return;
|
||||
@@ -1168,7 +1169,7 @@ static void Host_Loadgame_f (void)
|
||||
|
||||
cls.demonum = -1; // stop demo loop in case this fails
|
||||
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1));
|
||||
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1)->c_str());
|
||||
COM_AddExtension (name, ".sav", sizeof(name));
|
||||
|
||||
// we can't call SCR_BeginLoadingPlaque, because too much stack space has
|
||||
@@ -1188,8 +1189,8 @@ static void Host_Loadgame_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
data = start;
|
||||
data = COM_ParseIntNewline (data, &version);
|
||||
std::istringstream ss{start};
|
||||
version = common::parse_int_newline(ss);
|
||||
if (version != SAVEGAME_VERSION)
|
||||
{
|
||||
free (start);
|
||||
@@ -1197,17 +1198,17 @@ static void Host_Loadgame_f (void)
|
||||
Host_Error ("Savegame is version %i, not %i", version, SAVEGAME_VERSION);
|
||||
return;
|
||||
}
|
||||
data = COM_ParseStringNewline (data);
|
||||
auto strr = common::parse_string_newline (ss);
|
||||
for (i = 0; i < NUM_SPAWN_PARMS; i++)
|
||||
data = COM_ParseFloatNewline (data, &spawn_parms[i]);
|
||||
spawn_parms[i] = common::parse_float_newline(ss);
|
||||
// this silliness is so we can load 1.06 save files, which have float skill values
|
||||
data = COM_ParseFloatNewline(data, &tfloat);
|
||||
const float tfloat = common::parse_float_newline(ss);
|
||||
current_skill = (int)(tfloat + 0.1);
|
||||
Cvar_SetValue ("skill", (float)current_skill);
|
||||
convar::set_value ("skill", (float)current_skill);
|
||||
|
||||
data = COM_ParseStringNewline (data);
|
||||
q_strlcpy (mapname, com_token, sizeof(mapname));
|
||||
data = COM_ParseFloatNewline (data, &time);
|
||||
strr = common::parse_string_newline(ss);
|
||||
q_strlcpy (mapname, strr.c_str(), sizeof(mapname));
|
||||
const float time = common::parse_float_newline(ss);
|
||||
|
||||
CL_Disconnect_f ();
|
||||
|
||||
@@ -1227,25 +1228,25 @@ static void Host_Loadgame_f (void)
|
||||
// load the light styles
|
||||
for (i = 0; i < MAX_LIGHTSTYLES; i++)
|
||||
{
|
||||
data = COM_ParseStringNewline (data);
|
||||
sv.lightstyles[i] = (const char *)Hunk_Strdup (com_token, "lightstyles");
|
||||
strr = common::parse_string_newline(ss);
|
||||
sv.lightstyles[i] = (const char *)Hunk_Strdup (strr.c_str(), "lightstyles");
|
||||
}
|
||||
|
||||
// load the edicts out of the savegame file
|
||||
entnum = -1; // -1 is the globals
|
||||
while (*data)
|
||||
while (!ss.eof())
|
||||
{
|
||||
data = COM_Parse (data);
|
||||
if (!com_token[0])
|
||||
auto token = common::parse_token(ss);
|
||||
if (!token.has_value())
|
||||
break; // end of file
|
||||
if (strcmp(com_token,"{"))
|
||||
if (token->front() != '{')
|
||||
{
|
||||
Host_Error ("First token isn't a brace");
|
||||
}
|
||||
|
||||
if (entnum == -1)
|
||||
{ // parse the global vars
|
||||
data = ED_ParseGlobals (data);
|
||||
ED_ParseGlobals (ss);
|
||||
}
|
||||
else
|
||||
{ // parse an edict
|
||||
@@ -1258,7 +1259,7 @@ static void Host_Loadgame_f (void)
|
||||
memset (ent, 0, pr_edict_size);
|
||||
ent->baseline.scale = ENTSCALE_DEFAULT;
|
||||
}
|
||||
data = ED_ParseEdict (data, ent);
|
||||
ED_ParseEdict (ss, ent);
|
||||
|
||||
// link it into the bsp tree
|
||||
if (!ent->free)
|
||||
@@ -1302,24 +1303,24 @@ static void Host_Name_f (void)
|
||||
{
|
||||
char newName[32];
|
||||
|
||||
if (Cmd_Argc () == 1)
|
||||
if (command::argc () == 1)
|
||||
{
|
||||
Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
|
||||
return;
|
||||
}
|
||||
if (Cmd_Argc () == 2)
|
||||
q_strlcpy(newName, Cmd_Argv(1), sizeof(newName));
|
||||
if (command::argc () == 2)
|
||||
q_strlcpy(newName, command::argv(1)->c_str(), sizeof(newName));
|
||||
else
|
||||
q_strlcpy(newName, Cmd_Args(), sizeof(newName));
|
||||
q_strlcpy(newName, command::args().c_str(), sizeof(newName));
|
||||
newName[15] = 0; // client_t structure actually says name[32].
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (Q_strcmp(cl_name.string, newName) == 0)
|
||||
return;
|
||||
Cvar_Set ("_cl_name", newName);
|
||||
convar::set("_cl_name", newName);
|
||||
if (cls.state == ca_connected)
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1342,28 +1343,28 @@ static void Host_Say(qboolean teamonly)
|
||||
int j;
|
||||
client_t *client;
|
||||
client_t *save;
|
||||
const char *p;
|
||||
char text[MAXCMDLINE], *p2;
|
||||
qboolean quoted;
|
||||
qboolean fromServer = false;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (cls.state != ca_dedicated)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
fromServer = true;
|
||||
teamonly = false;
|
||||
}
|
||||
|
||||
if (Cmd_Argc () < 2)
|
||||
if (command::argc () < 2)
|
||||
return;
|
||||
|
||||
save = host_client;
|
||||
|
||||
p = Cmd_Args();
|
||||
auto args = command::args();
|
||||
auto p = args.c_str();
|
||||
// remove quotes if present
|
||||
quoted = false;
|
||||
if (*p == '\"')
|
||||
@@ -1433,16 +1434,17 @@ static void Host_Tell_f(void)
|
||||
char text[MAXCMDLINE], *p2;
|
||||
qboolean quoted;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc () < 3)
|
||||
if (command::argc () < 3)
|
||||
return;
|
||||
|
||||
p = Cmd_Args();
|
||||
auto args = command::args();
|
||||
p = args.c_str();
|
||||
// remove quotes if present
|
||||
quoted = false;
|
||||
if (*p == '\"')
|
||||
@@ -1479,7 +1481,7 @@ static void Host_Tell_f(void)
|
||||
{
|
||||
if (!client->active || !client->spawned)
|
||||
continue;
|
||||
if (q_strcasecmp(client->name, Cmd_Argv(1)))
|
||||
if (q_strcasecmp(client->name, command::argv(1)->c_str()))
|
||||
continue;
|
||||
host_client = client;
|
||||
SV_ClientPrintf("%s", text);
|
||||
@@ -1498,19 +1500,19 @@ static void Host_Color_f(void)
|
||||
int top, bottom;
|
||||
int playercolor;
|
||||
|
||||
if (Cmd_Argc() == 1)
|
||||
if (command::argc() == 1)
|
||||
{
|
||||
Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
|
||||
Con_Printf ("color <0-13> [0-13]\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() == 2)
|
||||
top = bottom = atoi(Cmd_Argv(1));
|
||||
if (command::argc() == 2)
|
||||
top = bottom = atoi(command::argv(1)->c_str());
|
||||
else
|
||||
{
|
||||
top = atoi(Cmd_Argv(1));
|
||||
bottom = atoi(Cmd_Argv(2));
|
||||
top = atoi(command::argv(1)->c_str());
|
||||
bottom = atoi(command::argv(2)->c_str());
|
||||
}
|
||||
|
||||
top &= 15;
|
||||
@@ -1522,11 +1524,11 @@ static void Host_Color_f(void)
|
||||
|
||||
playercolor = top*16 + bottom;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cvar_SetValue ("_cl_color", playercolor);
|
||||
convar::set_value ("_cl_color", playercolor);
|
||||
if (cls.state == ca_connected)
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1546,9 +1548,9 @@ Host_Kill_f
|
||||
*/
|
||||
static void Host_Kill_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1578,9 +1580,9 @@ static void Host_Pause_f (void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
if (!pausable.value)
|
||||
@@ -1613,7 +1615,7 @@ Host_PreSpawn_f
|
||||
*/
|
||||
static void Host_PreSpawn_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Con_Printf ("prespawn is not valid from the console\n");
|
||||
return;
|
||||
@@ -1640,7 +1642,7 @@ static void Host_Spawn_f (void)
|
||||
client_t *client;
|
||||
edict_t *ent;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Con_Printf ("spawn is not valid from the console\n");
|
||||
return;
|
||||
@@ -1755,7 +1757,7 @@ Host_Begin_f
|
||||
*/
|
||||
static void Host_Begin_f (void)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Con_Printf ("begin is not valid from the console\n");
|
||||
return;
|
||||
@@ -1776,16 +1778,15 @@ Kicks a user off of the server
|
||||
static void Host_Kick_f (void)
|
||||
{
|
||||
const char *who;
|
||||
const char *message = NULL;
|
||||
client_t *save;
|
||||
int i;
|
||||
qboolean byNumber = false;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
if (!sv.active)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1794,9 +1795,9 @@ static void Host_Kick_f (void)
|
||||
|
||||
save = host_client;
|
||||
|
||||
if (Cmd_Argc() > 2 && Q_strcmp(Cmd_Argv(1), "#") == 0)
|
||||
if (command::argc() > 2 && Q_strcmp(command::argv(1)->c_str(), "#") == 0)
|
||||
{
|
||||
i = Q_atof(Cmd_Argv(2)) - 1;
|
||||
i = Q_atof(command::argv(2)->c_str()) - 1;
|
||||
if (i < 0 || i >= svs.maxclients)
|
||||
return;
|
||||
if (!svs.clients[i].active)
|
||||
@@ -1810,14 +1811,14 @@ static void Host_Kick_f (void)
|
||||
{
|
||||
if (!host_client->active)
|
||||
continue;
|
||||
if (q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0)
|
||||
if (q_strcasecmp(host_client->name, command::argv(1).value_or("").c_str()) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < svs.maxclients)
|
||||
{
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
if (cls.state == ca_dedicated)
|
||||
who = "Console";
|
||||
else
|
||||
@@ -1829,21 +1830,25 @@ static void Host_Kick_f (void)
|
||||
if (host_client == save)
|
||||
return;
|
||||
|
||||
if (Cmd_Argc() > 2)
|
||||
std::string message{};
|
||||
if (command::argc() > 2)
|
||||
{
|
||||
message = COM_Parse(Cmd_Args());
|
||||
std::istringstream ss{command::args()};
|
||||
auto token = common::parse_token(ss);
|
||||
if (byNumber)
|
||||
{
|
||||
message++; // skip the #
|
||||
while (*message == ' ') // skip white space
|
||||
message++;
|
||||
message += strlen(Cmd_Argv(2)); // skip the number
|
||||
ss.get();
|
||||
while (ss.peek() == ' ') // skip white space
|
||||
ss.get();
|
||||
ss.seekg(command::argv(2)->length(), std::ios_base::seekdir::_S_cur); // skip the number
|
||||
}
|
||||
while (*message && *message == ' ')
|
||||
message++;
|
||||
while (!ss.eof() && ss.peek() == ' ')
|
||||
ss.get();
|
||||
|
||||
message += ss.str().substr(ss.tellg());
|
||||
}
|
||||
if (message)
|
||||
SV_ClientPrintf ("Kicked by %s: %s\n", who, message);
|
||||
if (!message.empty())
|
||||
SV_ClientPrintf ("Kicked by %s: %s\n", who, message.c_str());
|
||||
else
|
||||
SV_ClientPrintf ("Kicked by %s\n", who);
|
||||
SV_DropClient (false);
|
||||
@@ -1871,17 +1876,18 @@ static void Host_Give_f (void)
|
||||
int v;
|
||||
eval_t *val;
|
||||
|
||||
if (cmd_source == src_command)
|
||||
if (command::last_source == command::source::command)
|
||||
{
|
||||
Cmd_ForwardToServer ();
|
||||
command::forward_to_server();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pr_global_struct->deathmatch)
|
||||
return;
|
||||
|
||||
t = Cmd_Argv(1);
|
||||
v = atoi (Cmd_Argv(2));
|
||||
auto arg1 = command::argv(1).value_or("");
|
||||
t = arg1.c_str();
|
||||
v = atoi (command::argv(2).value_or("").c_str());
|
||||
|
||||
switch (t[0])
|
||||
{
|
||||
@@ -2119,10 +2125,10 @@ static void Host_Viewmodel_f (void)
|
||||
if (!e)
|
||||
return;
|
||||
|
||||
m = Mod_ForName (Cmd_Argv(1), false);
|
||||
m = Mod_ForName (command::argv(1).value_or("").c_str(), false);
|
||||
if (!m)
|
||||
{
|
||||
Con_Printf ("Can't load %s\n", Cmd_Argv(1));
|
||||
Con_Printf ("Can't load %s\n", command::argv(1).value_or("").c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2146,7 +2152,7 @@ static void Host_Viewframe_f (void)
|
||||
return;
|
||||
m = cl.model_precache[(int)e->v.modelindex];
|
||||
|
||||
f = atoi(Cmd_Argv(1));
|
||||
f = atoi(command::argv(1).value_or("").c_str());
|
||||
if (f >= m->numframes)
|
||||
f = m->numframes - 1;
|
||||
|
||||
@@ -2231,7 +2237,7 @@ static void Host_Startdemos_f (void)
|
||||
if (cls.state == ca_dedicated)
|
||||
return;
|
||||
|
||||
c = Cmd_Argc() - 1;
|
||||
c = command::argc() - 1;
|
||||
if (c > MAX_DEMOS)
|
||||
{
|
||||
Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
|
||||
@@ -2240,7 +2246,7 @@ static void Host_Startdemos_f (void)
|
||||
Con_Printf ("%i demo(s) in loop\n", c);
|
||||
|
||||
for (i = 1; i < c + 1; i++)
|
||||
q_strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0]));
|
||||
q_strlcpy (cls.demos[i-1], command::argv(i)->c_str(), sizeof(cls.demos[0]));
|
||||
|
||||
if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
|
||||
{
|
||||
@@ -2316,49 +2322,49 @@ Host_InitCommands
|
||||
*/
|
||||
void Host_InitCommands (void)
|
||||
{
|
||||
Cmd_AddCommand ("maps", Host_Maps_f); //johnfitz
|
||||
Cmd_AddCommand ("mods", Host_Mods_f); //johnfitz
|
||||
Cmd_AddCommand ("games", Host_Mods_f); // as an alias to "mods" -- S.A. / QuakeSpasm
|
||||
Cmd_AddCommand ("mapname", Host_Mapname_f); //johnfitz
|
||||
Cmd_AddCommand ("randmap", Host_Randmap_f); //ericw
|
||||
command::add ("maps", Host_Maps_f); //johnfitz
|
||||
command::add ("mods", Host_Mods_f); //johnfitz
|
||||
command::add ("games", Host_Mods_f); // as an alias to "mods" -- S.A. / QuakeSpasm
|
||||
command::add ("mapname", Host_Mapname_f); //johnfitz
|
||||
command::add ("randmap", Host_Randmap_f); //ericw
|
||||
|
||||
Cmd_AddCommand ("status", Host_Status_f);
|
||||
Cmd_AddCommand ("quit", Host_Quit_f);
|
||||
Cmd_AddCommand ("god", Host_God_f);
|
||||
Cmd_AddCommand("buddha", Host_Buddha_f);
|
||||
Cmd_AddCommand ("notarget", Host_Notarget_f);
|
||||
Cmd_AddCommand ("fly", Host_Fly_f);
|
||||
Cmd_AddCommand ("map", Host_Map_f);
|
||||
Cmd_AddCommand ("restart", Host_Restart_f);
|
||||
Cmd_AddCommand ("changelevel", Host_Changelevel_f);
|
||||
Cmd_AddCommand ("connect", Host_Connect_f);
|
||||
Cmd_AddCommand ("reconnect", Host_Reconnect_f);
|
||||
Cmd_AddCommand ("name", Host_Name_f);
|
||||
Cmd_AddCommand ("noclip", Host_Noclip_f);
|
||||
Cmd_AddCommand ("setpos", Host_SetPos_f); //QuakeSpasm
|
||||
command::add ("status", Host_Status_f);
|
||||
command::add ("quit", Host_Quit_f);
|
||||
command::add ("god", Host_God_f);
|
||||
command::add("buddha", Host_Buddha_f);
|
||||
command::add ("notarget", Host_Notarget_f);
|
||||
command::add ("fly", Host_Fly_f);
|
||||
command::add ("map", Host_Map_f);
|
||||
command::add ("restart", Host_Restart_f);
|
||||
command::add ("changelevel", Host_Changelevel_f);
|
||||
command::add ("connect", Host_Connect_f);
|
||||
command::add ("reconnect", Host_Reconnect_f);
|
||||
command::add ("name", Host_Name_f);
|
||||
command::add ("noclip", Host_Noclip_f);
|
||||
command::add ("setpos", Host_SetPos_f); //QuakeSpasm
|
||||
|
||||
Cmd_AddCommand ("say", Host_Say_f);
|
||||
Cmd_AddCommand ("say_team", Host_Say_Team_f);
|
||||
Cmd_AddCommand ("tell", Host_Tell_f);
|
||||
Cmd_AddCommand ("color", Host_Color_f);
|
||||
Cmd_AddCommand ("kill", Host_Kill_f);
|
||||
Cmd_AddCommand ("pause", Host_Pause_f);
|
||||
Cmd_AddCommand ("spawn", Host_Spawn_f);
|
||||
Cmd_AddCommand ("begin", Host_Begin_f);
|
||||
Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
|
||||
Cmd_AddCommand ("kick", Host_Kick_f);
|
||||
Cmd_AddCommand ("ping", Host_Ping_f);
|
||||
Cmd_AddCommand ("load", Host_Loadgame_f);
|
||||
Cmd_AddCommand ("save", Host_Savegame_f);
|
||||
Cmd_AddCommand ("give", Host_Give_f);
|
||||
command::add ("say", Host_Say_f);
|
||||
command::add ("say_team", Host_Say_Team_f);
|
||||
command::add ("tell", Host_Tell_f);
|
||||
command::add ("color", Host_Color_f);
|
||||
command::add ("kill", Host_Kill_f);
|
||||
command::add ("pause", Host_Pause_f);
|
||||
command::add ("spawn", Host_Spawn_f);
|
||||
command::add ("begin", Host_Begin_f);
|
||||
command::add ("prespawn", Host_PreSpawn_f);
|
||||
command::add ("kick", Host_Kick_f);
|
||||
command::add ("ping", Host_Ping_f);
|
||||
command::add ("load", Host_Loadgame_f);
|
||||
command::add ("save", Host_Savegame_f);
|
||||
command::add ("give", Host_Give_f);
|
||||
|
||||
Cmd_AddCommand ("startdemos", Host_Startdemos_f);
|
||||
Cmd_AddCommand ("demos", Host_Demos_f);
|
||||
Cmd_AddCommand ("stopdemo", Host_Stopdemo_f);
|
||||
command::add ("startdemos", Host_Startdemos_f);
|
||||
command::add ("demos", Host_Demos_f);
|
||||
command::add ("stopdemo", Host_Stopdemo_f);
|
||||
|
||||
Cmd_AddCommand ("viewmodel", Host_Viewmodel_f);
|
||||
Cmd_AddCommand ("viewframe", Host_Viewframe_f);
|
||||
Cmd_AddCommand ("viewnext", Host_Viewnext_f);
|
||||
Cmd_AddCommand ("viewprev", Host_Viewprev_f);
|
||||
command::add ("viewmodel", Host_Viewmodel_f);
|
||||
command::add ("viewframe", Host_Viewframe_f);
|
||||
command::add ("viewnext", Host_Viewnext_f);
|
||||
command::add ("viewprev", Host_Viewprev_f);
|
||||
}
|
||||
|
||||
|
||||
+745
-830
File diff suppressed because it is too large
Load Diff
+14
-13
@@ -628,6 +628,7 @@ void Key_SetBinding (int keynum, const char *binding)
|
||||
// allocate memory for new binding
|
||||
if (binding)
|
||||
keybindings[keynum] = Z_Strdup(binding);
|
||||
printf("%d is now %s\n", keynum, keybindings[keynum]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -639,16 +640,16 @@ void Key_Unbind_f (void)
|
||||
{
|
||||
int b;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if (command::argc() != 2)
|
||||
{
|
||||
Con_Printf ("unbind <key> : remove commands from a key\n");
|
||||
return;
|
||||
}
|
||||
|
||||
b = Key_StringToKeynum (Cmd_Argv(1));
|
||||
b = Key_StringToKeynum (command::argv(1)->c_str());
|
||||
if (b == -1)
|
||||
{
|
||||
Con_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1));
|
||||
Con_Printf ("\"%s\" isn't a valid key\n", command::argv(1)->c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -697,26 +698,26 @@ void Key_Bind_f (void)
|
||||
int i, c, b;
|
||||
char cmd[1024];
|
||||
|
||||
c = Cmd_Argc();
|
||||
c = command::argc();
|
||||
|
||||
if (c != 2 && c != 3)
|
||||
{
|
||||
Con_Printf ("bind <key> [command] : attach a command to a key\n");
|
||||
return;
|
||||
}
|
||||
b = Key_StringToKeynum (Cmd_Argv(1));
|
||||
b = Key_StringToKeynum (command::argv(1)->c_str());
|
||||
if (b == -1)
|
||||
{
|
||||
Con_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1));
|
||||
Con_Printf ("\"%s\" isn't a valid key\n", command::argv(1)->c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == 2)
|
||||
{
|
||||
if (keybindings[b])
|
||||
Con_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), keybindings[b] );
|
||||
Con_Printf ("\"%s\" = \"%s\"\n", command::argv(1)->c_str(), keybindings[b] );
|
||||
else
|
||||
Con_Printf ("\"%s\" is not bound\n", Cmd_Argv(1) );
|
||||
Con_Printf ("\"%s\" is not bound\n", command::argv(1)->c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -724,7 +725,7 @@ void Key_Bind_f (void)
|
||||
cmd[0] = 0;
|
||||
for (i = 2; i < c; i++)
|
||||
{
|
||||
q_strlcat (cmd, Cmd_Argv(i), sizeof(cmd));
|
||||
q_strlcat (cmd, command::argv(i)->c_str(), sizeof(cmd));
|
||||
if (i != (c-1))
|
||||
q_strlcat (cmd, " ", sizeof(cmd));
|
||||
}
|
||||
@@ -890,10 +891,10 @@ void Key_Init (void)
|
||||
//
|
||||
// register our functions
|
||||
//
|
||||
Cmd_AddCommand ("bindlist",Key_Bindlist_f); //johnfitz
|
||||
Cmd_AddCommand ("bind",Key_Bind_f);
|
||||
Cmd_AddCommand ("unbind",Key_Unbind_f);
|
||||
Cmd_AddCommand ("unbindall",Key_Unbindall_f);
|
||||
command::add ("bindlist",Key_Bindlist_f); //johnfitz
|
||||
command::add ("bind",Key_Bind_f);
|
||||
command::add ("unbind",Key_Unbind_f);
|
||||
command::add ("unbindall",Key_Unbindall_f);
|
||||
}
|
||||
|
||||
static struct {
|
||||
|
||||
+2010
-2138
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@
|
||||
#define MINIZ_EXPORT
|
||||
#endif
|
||||
|
||||
|
||||
/* miniz.c 2.2.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
|
||||
See "unlicense" statement at the end of this file.
|
||||
Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
extern int DEFAULTnet_hostport;
|
||||
extern int net_hostport;
|
||||
|
||||
extern cvar_t hostname;
|
||||
extern convar hostname;
|
||||
|
||||
extern double net_time;
|
||||
extern sizebuf_t net_message;
|
||||
|
||||
+970
-1103
File diff suppressed because it is too large
Load Diff
+519
-614
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -80,7 +80,7 @@ char *PL_GetClipboardData (void)
|
||||
* such as an ip address, etc: do chop the size
|
||||
* here, otherwise we may experience Z_Malloc()
|
||||
* failures and all other not-oh-so-fun stuff. */
|
||||
size = q_min((size_t)(MAX_CLIPBOARDTXT), size);
|
||||
size = std::min((size_t)(MAX_CLIPBOARDTXT), size);
|
||||
data = (char *) Z_Malloc((int)size);
|
||||
q_strlcpy (data, cliptext, size);
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ char *PL_GetClipboardData (void)
|
||||
if (srcdata != NULL)
|
||||
{
|
||||
size_t sz = [clipboardString length] + 1;
|
||||
sz = q_min((size_t)(MAX_CLIPBOARDTXT), sz);
|
||||
sz = std::min((size_t)(MAX_CLIPBOARDTXT), sz);
|
||||
data = (char *) Z_Malloc((int)sz);
|
||||
q_strlcpy (data, srcdata, sz);
|
||||
}
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ char *PL_GetClipboardData (void)
|
||||
* such as an ip address, etc: do chop the size
|
||||
* here, otherwise we may experience Z_Malloc()
|
||||
* failures and all other not-oh-so-fun stuff. */
|
||||
size = q_min((size_t)(MAX_CLIPBOARDTXT), size);
|
||||
size = std::min((size_t)(MAX_CLIPBOARDTXT), size);
|
||||
data = (char *) Z_Malloc((int)size);
|
||||
q_strlcpy (data, cliptext, size);
|
||||
GlobalUnlock (hClipboardData);
|
||||
|
||||
+3
-3
@@ -930,7 +930,7 @@ static void PF_cvar (void)
|
||||
|
||||
str = G_STRING(OFS_PARM0);
|
||||
|
||||
G_FLOAT(OFS_RETURN) = Cvar_VariableValue (str);
|
||||
G_FLOAT(OFS_RETURN) = convar::variable_value(str).value_or(0.0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -947,7 +947,7 @@ static void PF_cvar_set (void)
|
||||
var = G_STRING(OFS_PARM0);
|
||||
val = G_STRING(OFS_PARM1);
|
||||
|
||||
Cvar_Set (var, val);
|
||||
convar::set (var, val);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1378,7 +1378,7 @@ Pick a vector for the player to shoot along
|
||||
vector aim(entity, missilespeed)
|
||||
=============
|
||||
*/
|
||||
cvar_t sv_aim = {"sv_aim", "1", CVAR_NONE}; // ericw -- turn autoaim off by default. was 0.93
|
||||
convar sv_aim{"sv_aim", "1"}; // ericw -- turn autoaim off by default. was 0.93
|
||||
static void PF_aim (void)
|
||||
{
|
||||
edict_t *ent, *check, *bestent;
|
||||
|
||||
+84
-77
@@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
// sv_edict.c -- entity dictionary
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
dprograms_t *progs;
|
||||
@@ -72,17 +74,17 @@ static gefv_cache gefvCache[GEFV_CACHESIZE] =
|
||||
{ NULL, "" }
|
||||
};
|
||||
|
||||
cvar_t nomonsters = {"nomonsters", "0", CVAR_NONE};
|
||||
cvar_t gamecfg = {"gamecfg", "0", CVAR_NONE};
|
||||
cvar_t scratch1 = {"scratch1", "0", CVAR_NONE};
|
||||
cvar_t scratch2 = {"scratch2", "0", CVAR_NONE};
|
||||
cvar_t scratch3 = {"scratch3", "0", CVAR_NONE};
|
||||
cvar_t scratch4 = {"scratch4", "0", CVAR_NONE};
|
||||
cvar_t savedgamecfg = {"savedgamecfg", "0", CVAR_ARCHIVE};
|
||||
cvar_t saved1 = {"saved1", "0", CVAR_ARCHIVE};
|
||||
cvar_t saved2 = {"saved2", "0", CVAR_ARCHIVE};
|
||||
cvar_t saved3 = {"saved3", "0", CVAR_ARCHIVE};
|
||||
cvar_t saved4 = {"saved4", "0", CVAR_ARCHIVE};
|
||||
convar nomonsters{"nomonsters", "0"};
|
||||
convar gamecfg{"gamecfg", "0"};
|
||||
convar scratch1{"scratch1", "0"};
|
||||
convar scratch2{"scratch2", "0"};
|
||||
convar scratch3{"scratch3", "0"};
|
||||
convar scratch4{"scratch4", "0"};
|
||||
convar savedgamecfg{"savedgamecfg", "0", {.archive = true}};
|
||||
convar saved1{"saved1", "0", {.archive = true}};
|
||||
convar saved2{"saved2", "0", {.archive = true}};
|
||||
convar saved3{"saved3", "0", {.archive = true}};
|
||||
convar saved4{"saved4", "0", {.archive = true}};
|
||||
|
||||
/*
|
||||
=================
|
||||
@@ -619,7 +621,7 @@ static void ED_PrintEdict_f (void)
|
||||
if (!sv.active)
|
||||
return;
|
||||
|
||||
i = Q_atoi (Cmd_Argv(1));
|
||||
i = Q_atoi (command::argv(1).value_or("").c_str());
|
||||
if (i < 0 || i >= sv.num_edicts)
|
||||
{
|
||||
Con_Printf("Bad edict number\n");
|
||||
@@ -711,41 +713,43 @@ void ED_WriteGlobals (FILE *f)
|
||||
ED_ParseGlobals
|
||||
=============
|
||||
*/
|
||||
const char *ED_ParseGlobals (const char *data)
|
||||
void ED_ParseGlobals (std::istringstream &ss)
|
||||
{
|
||||
char keyname[64];
|
||||
ddef_t *key;
|
||||
|
||||
while (1)
|
||||
std::string keyname;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// parse key
|
||||
data = COM_Parse (data);
|
||||
if (com_token[0] == '}')
|
||||
auto token = common::parse_token(ss);
|
||||
if (token.has_value() && token->front() == '}') {
|
||||
break;
|
||||
if (!data)
|
||||
}
|
||||
if (ss.eof()) {
|
||||
Host_Error ("ED_ParseEntity: EOF without closing brace");
|
||||
}
|
||||
|
||||
q_strlcpy (keyname, com_token, sizeof(keyname));
|
||||
keyname = token.value();
|
||||
|
||||
// parse value
|
||||
data = COM_Parse (data);
|
||||
if (!data)
|
||||
token = common::parse_token(ss);
|
||||
if (ss.eof())
|
||||
Host_Error ("ED_ParseEntity: EOF without closing brace");
|
||||
|
||||
if (com_token[0] == '}')
|
||||
if (token->front() == '}')
|
||||
Host_Error ("ED_ParseEntity: closing brace without data");
|
||||
|
||||
key = ED_FindGlobal (keyname);
|
||||
key = ED_FindGlobal (keyname.c_str());
|
||||
if (!key)
|
||||
{
|
||||
Con_Printf ("'%s' is not a global\n", keyname);
|
||||
Con_Printf ("'%s' is not a global\n", keyname.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ED_ParseEpair ((void *)pr_globals, key, com_token))
|
||||
if (!ED_ParseEpair ((void *)pr_globals, key, token->c_str()))
|
||||
Host_Error ("ED_ParseGlobals: parse error");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
@@ -879,13 +883,14 @@ ed should be a properly initialized empty edict.
|
||||
Used for initial level load and for savegames.
|
||||
====================
|
||||
*/
|
||||
const char *ED_ParseEdict (const char *data, edict_t *ent)
|
||||
void ED_ParseEdict(std::istringstream &ss, edict_t *ent)
|
||||
{
|
||||
ddef_t *key;
|
||||
char keyname[256];
|
||||
qboolean anglehack, init;
|
||||
int n;
|
||||
|
||||
std::string keyname{};
|
||||
|
||||
init = false;
|
||||
|
||||
// clear it
|
||||
@@ -896,83 +901,82 @@ const char *ED_ParseEdict (const char *data, edict_t *ent)
|
||||
while (1)
|
||||
{
|
||||
// parse key
|
||||
data = COM_Parse (data);
|
||||
if (com_token[0] == '}')
|
||||
auto token = common::parse_token(ss);
|
||||
if (token.has_value() && token->front() == '}') {
|
||||
break;
|
||||
if (!data)
|
||||
}
|
||||
if (ss.eof()) {
|
||||
Host_Error ("ED_ParseEntity: EOF without closing brace");
|
||||
}
|
||||
|
||||
// anglehack is to allow QuakeEd to write single scalar angles
|
||||
// and allow them to be turned into vectors. (FIXME...)
|
||||
if (!strcmp(com_token, "angle"))
|
||||
if (token == "angle")
|
||||
{
|
||||
strcpy (com_token, "angles");
|
||||
token = "angles";
|
||||
anglehack = true;
|
||||
}
|
||||
else
|
||||
anglehack = false;
|
||||
|
||||
// FIXME: change light to _light to get rid of this hack
|
||||
if (!strcmp(com_token, "light"))
|
||||
strcpy (com_token, "light_lev"); // hack for single light def
|
||||
if (token == "light") {
|
||||
token = "light_lev";
|
||||
}
|
||||
|
||||
q_strlcpy (keyname, com_token, sizeof(keyname));
|
||||
keyname = *token;
|
||||
|
||||
// another hack to fix keynames with trailing spaces
|
||||
n = strlen(keyname);
|
||||
while (n && keyname[n-1] == ' ')
|
||||
{
|
||||
keyname[n-1] = 0;
|
||||
n--;
|
||||
while (!keyname.empty() && keyname.back() == ' ') {
|
||||
keyname.pop_back();
|
||||
}
|
||||
|
||||
// parse value
|
||||
// HACK: we allow truncation when reading the wad field,
|
||||
// otherwise maps using lots of wads with absolute paths
|
||||
// could cause a parse error
|
||||
data = COM_ParseEx (data, !strcmp (keyname, "wad") ? CPE_ALLOWTRUNC : CPE_NOTRUNC);
|
||||
if (!data)
|
||||
token = common::parse_token(ss);
|
||||
if (ss.eof()) {
|
||||
Host_Error ("ED_ParseEntity: EOF without closing brace");
|
||||
}
|
||||
|
||||
if (com_token[0] == '}')
|
||||
if (token->front() == '}') {
|
||||
Host_Error ("ED_ParseEntity: closing brace without data");
|
||||
}
|
||||
|
||||
init = true;
|
||||
|
||||
// keynames with a leading underscore are used for utility comments,
|
||||
// and are immediately discarded by quake
|
||||
if (keyname[0] == '_')
|
||||
if (keyname[0] == '_') {
|
||||
continue;
|
||||
}
|
||||
|
||||
//johnfitz -- hack to support .alpha even when progs.dat doesn't know about it
|
||||
if (!strcmp(keyname, "alpha"))
|
||||
ent->alpha = ENTALPHA_ENCODE(Q_atof(com_token));
|
||||
if (keyname == "alpha")
|
||||
ent->alpha = ENTALPHA_ENCODE(Q_atof(token->c_str()));
|
||||
//johnfitz
|
||||
|
||||
key = ED_FindField (keyname);
|
||||
key = ED_FindField (keyname.c_str());
|
||||
if (!key)
|
||||
{
|
||||
//johnfitz -- HACK -- suppress error becuase fog/sky/alpha fields might not be mentioned in defs.qc
|
||||
if (strncmp(keyname, "sky", 3) && strcmp(keyname, "fog") && strcmp(keyname, "alpha"))
|
||||
Con_DPrintf ("\"%s\" is not a field\n", keyname); //johnfitz -- was Con_Printf
|
||||
if (keyname != "sky" && keyname != "fog" && keyname != "alpha")
|
||||
Con_DPrintf ("\"%s\" is not a field\n", keyname.c_str()); //johnfitz -- was Con_Printf
|
||||
continue;
|
||||
}
|
||||
|
||||
if (anglehack)
|
||||
{
|
||||
char temp[32];
|
||||
strcpy (temp, com_token);
|
||||
sprintf (com_token, "0 %s 0", temp);
|
||||
token = std::format("0 {} 0", *token);
|
||||
}
|
||||
|
||||
if (!ED_ParseEpair ((void *)&ent->v, key, com_token))
|
||||
if (!ED_ParseEpair ((void *)&ent->v, key, token->c_str()))
|
||||
Host_Error ("ED_ParseEdict: parse error");
|
||||
}
|
||||
|
||||
if (!init)
|
||||
ent->free = true;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -999,21 +1003,24 @@ void ED_LoadFromFile (const char *data)
|
||||
|
||||
pr_global_struct->time = sv.time;
|
||||
|
||||
std::istringstream ss{data};
|
||||
|
||||
|
||||
// parse ents
|
||||
while (1)
|
||||
while (true)
|
||||
{
|
||||
// parse the opening brace
|
||||
data = COM_Parse (data);
|
||||
if (!data)
|
||||
auto token = common::parse_token(ss);
|
||||
if (ss.eof())
|
||||
break;
|
||||
if (com_token[0] != '{')
|
||||
Host_Error ("ED_LoadFromFile: found %s when expecting {",com_token);
|
||||
if (token->front() != '{')
|
||||
Host_Error ("ED_LoadFromFile: found %s when expecting {", token->c_str());
|
||||
|
||||
if (!ent)
|
||||
ent = EDICT_NUM(0);
|
||||
else
|
||||
ent = ED_Alloc ();
|
||||
data = ED_ParseEdict (data, ent);
|
||||
ED_ParseEdict (ss, ent);
|
||||
|
||||
// remove things from different skill levels or deathmatch
|
||||
if (deathmatch.value)
|
||||
@@ -1270,21 +1277,21 @@ PR_Init
|
||||
*/
|
||||
void PR_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("edict", ED_PrintEdict_f);
|
||||
Cmd_AddCommand ("edicts", ED_PrintEdicts);
|
||||
Cmd_AddCommand ("edictcount", ED_Count);
|
||||
Cmd_AddCommand ("profile", PR_Profile_f);
|
||||
Cvar_RegisterVariable (&nomonsters);
|
||||
Cvar_RegisterVariable (&gamecfg);
|
||||
Cvar_RegisterVariable (&scratch1);
|
||||
Cvar_RegisterVariable (&scratch2);
|
||||
Cvar_RegisterVariable (&scratch3);
|
||||
Cvar_RegisterVariable (&scratch4);
|
||||
Cvar_RegisterVariable (&savedgamecfg);
|
||||
Cvar_RegisterVariable (&saved1);
|
||||
Cvar_RegisterVariable (&saved2);
|
||||
Cvar_RegisterVariable (&saved3);
|
||||
Cvar_RegisterVariable (&saved4);
|
||||
command::add("edict", ED_PrintEdict_f);
|
||||
command::add("edicts", ED_PrintEdicts);
|
||||
command::add("edictcount", ED_Count);
|
||||
command::add("profile", PR_Profile_f);
|
||||
nomonsters.inscribe();
|
||||
gamecfg.inscribe();
|
||||
scratch1.inscribe();
|
||||
scratch2.inscribe();
|
||||
scratch3.inscribe();
|
||||
scratch4.inscribe();
|
||||
savedgamecfg.inscribe();
|
||||
saved1.inscribe();
|
||||
saved2.inscribe();
|
||||
saved3.inscribe();
|
||||
saved4.inscribe();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -87,10 +87,11 @@ void ED_Free (edict_t *ed);
|
||||
|
||||
void ED_Print (edict_t *ed);
|
||||
void ED_Write (FILE *f, edict_t *ed);
|
||||
const char *ED_ParseEdict (const char *data, edict_t *ent);
|
||||
|
||||
void ED_ParseEdict(std::istringstream &ss, edict_t *ent);
|
||||
|
||||
void ED_WriteGlobals (FILE *f);
|
||||
const char *ED_ParseGlobals (const char *data);
|
||||
void ED_ParseGlobals (std::istringstream &ss);
|
||||
|
||||
void ED_LoadFromFile (const char *data);
|
||||
|
||||
|
||||
+6
-6
@@ -168,16 +168,16 @@ extern vec3_t listener_forward;
|
||||
extern vec3_t listener_right;
|
||||
extern vec3_t listener_up;
|
||||
|
||||
extern cvar_t sndspeed;
|
||||
extern cvar_t snd_mixspeed;
|
||||
extern cvar_t snd_filterquality;
|
||||
extern cvar_t sfxvolume;
|
||||
extern cvar_t loadas8bit;
|
||||
extern convar sndspeed;
|
||||
extern convar snd_mixspeed;
|
||||
extern convar snd_filterquality;
|
||||
extern convar sfxvolume;
|
||||
extern convar loadas8bit;
|
||||
|
||||
#define MAX_RAW_SAMPLES 8192
|
||||
extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
|
||||
|
||||
extern cvar_t bgmvolume;
|
||||
extern convar bgmvolume;
|
||||
|
||||
void S_LocalSound (const char *name);
|
||||
sfxcache_t *S_LoadSound (sfx_t *s);
|
||||
|
||||
+8
-8
@@ -75,15 +75,15 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define Q_MAXCHAR ((char)0x7f)
|
||||
#define Q_MAXSHORT ((short)0x7fff)
|
||||
#define Q_MAXINT ((int)0x7fffffff)
|
||||
#define Q_MAXLONG ((int)0x7fffffff)
|
||||
#define q_maxCHAR ((char)0x7f)
|
||||
#define q_maxSHORT ((short)0x7fff)
|
||||
#define q_maxINT ((int)0x7fffffff)
|
||||
#define q_maxLONG ((int)0x7fffffff)
|
||||
|
||||
#define Q_MINCHAR ((char)0x80)
|
||||
#define Q_MINSHORT ((short)0x8000)
|
||||
#define Q_MININT ((int)0x80000000)
|
||||
#define Q_MINLONG ((int)0x80000000)
|
||||
#define q_minCHAR ((char)0x80)
|
||||
#define q_minSHORT ((short)0x8000)
|
||||
#define q_minINT ((int)0x80000000)
|
||||
#define q_minLONG ((int)0x80000000)
|
||||
|
||||
#ifndef COMPILE_TIME_ASSERT
|
||||
#if defined(__cplusplus)
|
||||
|
||||
+7
-7
@@ -211,7 +211,7 @@ typedef struct
|
||||
#include "sys.hpp"
|
||||
#include "zone.hpp"
|
||||
#include "mathlib.hpp"
|
||||
#include "cvar.hpp"
|
||||
#include "convar.hpp"
|
||||
|
||||
#include "protocol.hpp"
|
||||
#include "net.hpp"
|
||||
@@ -275,11 +275,11 @@ extern qboolean noclip_anglehack;
|
||||
//
|
||||
extern quakeparms_t *host_parms;
|
||||
|
||||
extern cvar_t sys_ticrate;
|
||||
extern cvar_t sys_throttle;
|
||||
extern cvar_t sys_nostdout;
|
||||
extern cvar_t developer;
|
||||
extern cvar_t max_edicts; //johnfitz
|
||||
extern convar sys_ticrate;
|
||||
extern convar sys_throttle;
|
||||
extern convar sys_nostdout;
|
||||
extern convar developer;
|
||||
extern convar max_edicts; //johnfitz
|
||||
|
||||
extern qboolean host_initialized; // true if into command execution
|
||||
extern double host_frametime;
|
||||
@@ -303,7 +303,7 @@ void Host_ServerFrame (void);
|
||||
void Host_InitCommands (void);
|
||||
void Host_Init (void);
|
||||
void Host_Shutdown(void);
|
||||
void Host_Callback_Notify (cvar_t *var); /* callback function for CVAR_NOTIFY */
|
||||
void Host_Callback_Notify (convar *var); /* callback function for CVAR_NOTIFY */
|
||||
FUNC_NORETURN void Host_Error (const char *error, ...) FUNC_PRINTF(1,2);
|
||||
FUNC_NORETURN void Host_EndGame (const char *message, ...) FUNC_PRINTF(1,2);
|
||||
#ifdef __WATCOMC__
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
extern cvar_t r_drawflat, gl_overbright_models, gl_fullbrights, r_lerpmodels, r_lerpmove; //johnfitz
|
||||
extern cvar_t scr_fov, cl_gun_fovscale;
|
||||
extern convar r_drawflat, gl_overbright_models, gl_fullbrights, r_lerpmodels, r_lerpmove; //johnfitz
|
||||
extern convar scr_fov, cl_gun_fovscale;
|
||||
|
||||
//up to 16 color translated skins
|
||||
gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz -- changed to an array of pointers
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater; //johnfitz
|
||||
extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix
|
||||
extern convar gl_fullbrights, r_drawflat, gl_overbright, r_oldwater; //johnfitz
|
||||
extern convar gl_zfix; // QuakeSpasm z-fighting fix
|
||||
|
||||
int gl_lightmap_format;
|
||||
int lightmap_bytes;
|
||||
|
||||
+10
-10
@@ -39,8 +39,8 @@ static int r_numparticles;
|
||||
static gltexture_t *particletexture, *particletexture1, *particletexture2, *particletexture3; //johnfitz
|
||||
static float texturescalefactor; //johnfitz -- compensate for apparent size of different particle textures
|
||||
|
||||
cvar_t r_particles = {"r_particles","1", CVAR_ARCHIVE}; //johnfitz
|
||||
cvar_t r_quadparticles = {"r_quadparticles","1", CVAR_ARCHIVE}; //johnfitz
|
||||
convar r_particles{"r_particles","1", {.archive = true}}; //johnfitz
|
||||
convar r_quadparticles{"r_quadparticles","1", {.archive = true}}; //johnfitz
|
||||
|
||||
/*
|
||||
===============
|
||||
@@ -57,7 +57,7 @@ int R_ParticleTextureLookup (int x, int y, int sharpness)
|
||||
r = x * x + y * y;
|
||||
r = r > 255 ? 255 : r;
|
||||
a = sharpness * (255 - r);
|
||||
a = q_min(a,255);
|
||||
a = std::min(a,255);
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void R_InitParticleTextures (void)
|
||||
R_SetParticleTexture_f -- johnfitz
|
||||
===============
|
||||
*/
|
||||
static void R_SetParticleTexture_f (cvar_t *var)
|
||||
static void R_SetParticleTexture_f (convar *var)
|
||||
{
|
||||
switch ((int)(r_particles.value))
|
||||
{
|
||||
@@ -166,9 +166,9 @@ void R_InitParticles (void)
|
||||
particles = (particle_t *)
|
||||
Hunk_AllocName (r_numparticles * sizeof(particle_t), "particles");
|
||||
|
||||
Cvar_RegisterVariable (&r_particles); //johnfitz
|
||||
Cvar_SetCallback (&r_particles, R_SetParticleTexture_f);
|
||||
Cvar_RegisterVariable (&r_quadparticles); //johnfitz
|
||||
r_particles.inscribe(); //johnfitz
|
||||
r_particles.set_callback(R_SetParticleTexture_f);
|
||||
r_quadparticles.inscribe(); //johnfitz
|
||||
|
||||
R_InitParticleTextures (); //johnfitz
|
||||
}
|
||||
@@ -722,7 +722,7 @@ void CL_RunParticles (void)
|
||||
particle_t *p, *kill;
|
||||
int i;
|
||||
float time1, time2, time3, dvel, frametime, grav;
|
||||
extern cvar_t sv_gravity;
|
||||
extern convar sv_gravity;
|
||||
|
||||
frametime = cl.time - cl.oldtime;
|
||||
time3 = frametime * 15;
|
||||
@@ -829,7 +829,7 @@ void R_DrawParticles (void)
|
||||
float scale;
|
||||
vec3_t up, right, p_up, p_right, p_upright; //johnfitz -- p_ vectors
|
||||
GLubyte color[4], *c; //johnfitz -- particle transparency
|
||||
extern cvar_t r_particles; //johnfitz
|
||||
extern convar r_particles; //johnfitz
|
||||
//float alpha; //johnfitz -- particle transparency
|
||||
|
||||
if (!r_particles.value)
|
||||
@@ -949,7 +949,7 @@ void R_DrawParticles_ShowTris (void)
|
||||
particle_t *p;
|
||||
float scale;
|
||||
vec3_t up, right, p_up, p_right, p_upright;
|
||||
extern cvar_t r_particles;
|
||||
extern convar r_particles;
|
||||
|
||||
if (!r_particles.value)
|
||||
return;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "quakedef.hpp"
|
||||
|
||||
extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater, r_oldskyleaf, r_showtris; //johnfitz
|
||||
extern convar gl_fullbrights, r_drawflat, gl_overbright, r_oldwater, r_oldskyleaf, r_showtris; //johnfitz
|
||||
|
||||
byte *SV_FatPVS (vec3_t org, qmodel_t *worldmodel);
|
||||
|
||||
|
||||
+8
-8
@@ -253,8 +253,8 @@ Sbar_Init -- johnfitz -- rewritten
|
||||
*/
|
||||
void Sbar_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("+showscores", Sbar_ShowScores);
|
||||
Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
|
||||
command::add ("+showscores", Sbar_ShowScores);
|
||||
command::add ("-showscores", Sbar_DontShowScores);
|
||||
|
||||
Sbar_LoadPics ();
|
||||
}
|
||||
@@ -388,7 +388,7 @@ void Sbar_DrawNum (int x, int y, int num, int digits, int color)
|
||||
char *ptr;
|
||||
int l, frame;
|
||||
|
||||
num = q_min(999,num); //johnfitz -- cap high values rather than truncating number
|
||||
num = std::min(999,num); //johnfitz -- cap high values rather than truncating number
|
||||
|
||||
l = Sbar_itoa (num, str);
|
||||
ptr = str;
|
||||
@@ -640,7 +640,7 @@ void Sbar_DrawInventory (void)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
val = cl.stats[STAT_SHELLS+i];
|
||||
val = (val < 0)? 0 : q_min(999,val);//johnfitz -- cap displayed value to 999
|
||||
val = (val < 0)? 0 : std::min(999,val);//johnfitz -- cap displayed value to 999
|
||||
sprintf (num, "%3i", val);
|
||||
if (num[0] != ' ')
|
||||
Sbar_DrawCharacter ( (6*i+1)*8 + 2, -24, 18 + num[0] - '0');
|
||||
@@ -754,7 +754,7 @@ void Sbar_DrawFrags (void)
|
||||
Sbar_SortFrags ();
|
||||
|
||||
// draw the text
|
||||
numscores = q_min(scoreboardlines, 4);
|
||||
numscores = std::min(scoreboardlines, 4);
|
||||
|
||||
for (i = 0, x = 184; i<numscores; i++, x += 32)
|
||||
{
|
||||
@@ -1302,12 +1302,12 @@ void Sbar_IntermissionOverlay (void)
|
||||
lsecrets = Sbar_IntermissionTextWidth (secrets, 0);
|
||||
lmonsters = Sbar_IntermissionTextWidth (monsters, 0);
|
||||
|
||||
total = q_max (ltime, lsecrets);
|
||||
total = q_max (lmonsters, total);
|
||||
total = std::max (ltime, lsecrets);
|
||||
total = std::max (lmonsters, total);
|
||||
|
||||
pic = Draw_CachePic ("gfx/inter.lmp");
|
||||
total += pic->width + 24;
|
||||
total = q_min (320, total);
|
||||
total = std::min (320, total);
|
||||
Draw_Pic (160 - total / 2, 56, pic);
|
||||
|
||||
pic = Draw_CachePic ("gfx/complete.lmp");
|
||||
|
||||
+8
-8
@@ -50,9 +50,9 @@ extern int clearnotify; // set to 0 whenever notify text is drawn
|
||||
extern qboolean scr_disabled_for_loading;
|
||||
extern qboolean scr_skipupdate;
|
||||
|
||||
extern cvar_t scr_viewsize;
|
||||
extern convar scr_viewsize;
|
||||
|
||||
extern cvar_t scr_sbaralpha; //johnfitz
|
||||
extern convar scr_sbaralpha; //johnfitz
|
||||
|
||||
void SCR_UpdateWholeScreen (void);
|
||||
|
||||
@@ -70,12 +70,12 @@ typedef enum {
|
||||
CANVAS_TOPRIGHT,
|
||||
CANVAS_INVALID = -1
|
||||
} canvastype;
|
||||
extern cvar_t scr_menuscale;
|
||||
extern cvar_t scr_sbarscale;
|
||||
extern cvar_t scr_conwidth;
|
||||
extern cvar_t scr_conscale;
|
||||
extern cvar_t scr_scale;
|
||||
extern cvar_t scr_crosshairscale;
|
||||
extern convar scr_menuscale;
|
||||
extern convar scr_sbarscale;
|
||||
extern convar scr_conwidth;
|
||||
extern convar scr_conscale;
|
||||
extern convar scr_scale;
|
||||
extern convar scr_crosshairscale;
|
||||
//johnfitz
|
||||
|
||||
extern int scr_tileclear_updates; //johnfitz
|
||||
|
||||
+6
-6
@@ -189,12 +189,12 @@ typedef struct client_s
|
||||
|
||||
//============================================================================
|
||||
|
||||
extern cvar_t teamplay;
|
||||
extern cvar_t skill;
|
||||
extern cvar_t deathmatch;
|
||||
extern cvar_t coop;
|
||||
extern cvar_t fraglimit;
|
||||
extern cvar_t timelimit;
|
||||
extern convar teamplay;
|
||||
extern convar skill;
|
||||
extern convar deathmatch;
|
||||
extern convar coop;
|
||||
extern convar fraglimit;
|
||||
extern convar timelimit;
|
||||
|
||||
extern server_static_t svs; // persistant server info
|
||||
extern server_t sv; // local server
|
||||
|
||||
+636
-724
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -183,7 +183,7 @@ static int mp3_decode(snd_stream_t *stream, byte *buf, int len)
|
||||
do
|
||||
{
|
||||
x = (p->Synth.pcm.length - p->cursamp) * stream->info.channels;
|
||||
donow = q_min(len, x);
|
||||
donow = std::min(len, x);
|
||||
i = 0;
|
||||
while (i < donow)
|
||||
{
|
||||
|
||||
+36
-36
@@ -44,13 +44,13 @@ void SV_Protocol_f (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (Cmd_Argc())
|
||||
switch (command::argc())
|
||||
{
|
||||
case 1:
|
||||
Con_Printf ("\"sv_protocol\" is \"%i\"\n", sv_protocol);
|
||||
break;
|
||||
case 2:
|
||||
i = atoi(Cmd_Argv(1));
|
||||
case 2:
|
||||
i = atoi(command::argv(1)->c_str());
|
||||
if (i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE && i != PROTOCOL_RMQ)
|
||||
Con_Printf ("sv_protocol must be %i or %i or %i\n", PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE, PROTOCOL_RMQ);
|
||||
else
|
||||
@@ -75,38 +75,38 @@ void SV_Init (void)
|
||||
{
|
||||
int i;
|
||||
const char *p;
|
||||
extern cvar_t sv_maxvelocity;
|
||||
extern cvar_t sv_gravity;
|
||||
extern cvar_t sv_nostep;
|
||||
extern cvar_t sv_freezenonclients;
|
||||
extern cvar_t sv_friction;
|
||||
extern cvar_t sv_edgefriction;
|
||||
extern cvar_t sv_stopspeed;
|
||||
extern cvar_t sv_maxspeed;
|
||||
extern cvar_t sv_accelerate;
|
||||
extern cvar_t sv_idealpitchscale;
|
||||
extern cvar_t sv_aim;
|
||||
extern cvar_t sv_altnoclip; //johnfitz
|
||||
extern convar sv_maxvelocity;
|
||||
extern convar sv_gravity;
|
||||
extern convar sv_nostep;
|
||||
extern convar sv_freezenonclients;
|
||||
extern convar sv_friction;
|
||||
extern convar sv_edgefriction;
|
||||
extern convar sv_stopspeed;
|
||||
extern convar sv_maxspeed;
|
||||
extern convar sv_accelerate;
|
||||
extern convar sv_idealpitchscale;
|
||||
extern convar sv_aim;
|
||||
extern convar sv_altnoclip; //johnfitz
|
||||
|
||||
sv.edicts = NULL; // ericw -- sv.edicts switched to use malloc()
|
||||
|
||||
Cvar_RegisterVariable (&sv_maxvelocity);
|
||||
Cvar_RegisterVariable (&sv_gravity);
|
||||
Cvar_RegisterVariable (&sv_friction);
|
||||
Cvar_SetCallback (&sv_gravity, Host_Callback_Notify);
|
||||
Cvar_SetCallback (&sv_friction, Host_Callback_Notify);
|
||||
Cvar_RegisterVariable (&sv_edgefriction);
|
||||
Cvar_RegisterVariable (&sv_stopspeed);
|
||||
Cvar_RegisterVariable (&sv_maxspeed);
|
||||
Cvar_SetCallback (&sv_maxspeed, Host_Callback_Notify);
|
||||
Cvar_RegisterVariable (&sv_accelerate);
|
||||
Cvar_RegisterVariable (&sv_idealpitchscale);
|
||||
Cvar_RegisterVariable (&sv_aim);
|
||||
Cvar_RegisterVariable (&sv_nostep);
|
||||
Cvar_RegisterVariable (&sv_freezenonclients);
|
||||
Cvar_RegisterVariable (&sv_altnoclip); //johnfitz
|
||||
sv_maxvelocity.inscribe();
|
||||
sv_gravity.inscribe();
|
||||
sv_friction.inscribe();
|
||||
sv_gravity.set_callback(Host_Callback_Notify);
|
||||
sv_friction.set_callback(Host_Callback_Notify);
|
||||
sv_edgefriction.inscribe();
|
||||
sv_stopspeed.inscribe();
|
||||
sv_maxspeed.inscribe();
|
||||
sv_maxspeed.set_callback(Host_Callback_Notify);
|
||||
sv_accelerate.inscribe();
|
||||
sv_idealpitchscale.inscribe();
|
||||
sv_aim.inscribe();
|
||||
sv_nostep.inscribe();
|
||||
sv_freezenonclients.inscribe();
|
||||
sv_altnoclip.inscribe(); //johnfitz
|
||||
|
||||
Cmd_AddCommand ("sv_protocol", &SV_Protocol_f); //johnfitz
|
||||
command::add ("sv_protocol", &SV_Protocol_f); //johnfitz
|
||||
|
||||
for (i=0 ; i<MAX_MODELS ; i++)
|
||||
sprintf (localmodels[i], "*%i", i);
|
||||
@@ -799,7 +799,7 @@ stats:
|
||||
if (msg->cursize > 1024 && dev_peakstats.packetsize <= 1024)
|
||||
Con_DWarning ("%i byte packet exceeds standard limit of 1024 (max = %d).\n", msg->cursize, msg->maxsize);
|
||||
dev_stats.packetsize = msg->cursize;
|
||||
dev_peakstats.packetsize = q_max(msg->cursize, dev_peakstats.packetsize);
|
||||
dev_peakstats.packetsize = std::max(msg->cursize, dev_peakstats.packetsize);
|
||||
//johnfitz
|
||||
}
|
||||
|
||||
@@ -1415,7 +1415,7 @@ void SV_SendReconnect (void)
|
||||
NET_SendToAll (&msg, 5.0);
|
||||
|
||||
if (!isDedicated)
|
||||
Cmd_ExecuteString ("reconnect\n", src_command);
|
||||
command::execute_string ("reconnect\n", command::source::command);
|
||||
}
|
||||
|
||||
|
||||
@@ -1463,7 +1463,7 @@ void SV_SpawnServer (const char *server)
|
||||
|
||||
// let's not have any servers with no name
|
||||
if (hostname.string[0] == 0)
|
||||
Cvar_Set ("hostname", "UNNAMED");
|
||||
convar::set ("hostname", "UNNAMED");
|
||||
scr_centertime_off = 0;
|
||||
|
||||
Con_DPrintf ("SpawnServer: %s\n",server);
|
||||
@@ -1481,14 +1481,14 @@ void SV_SpawnServer (const char *server)
|
||||
// make cvars consistant
|
||||
//
|
||||
if (coop.value)
|
||||
Cvar_Set ("deathmatch", "0");
|
||||
convar::set ("deathmatch", "0");
|
||||
current_skill = (int)(skill.value + 0.5);
|
||||
if (current_skill < 0)
|
||||
current_skill = 0;
|
||||
if (current_skill > 3)
|
||||
current_skill = 3;
|
||||
|
||||
Cvar_SetValue ("skill", (float)current_skill);
|
||||
convar::set_value ("skill", (float)current_skill);
|
||||
|
||||
//
|
||||
// set up the new server
|
||||
|
||||
+6
-6
@@ -41,12 +41,12 @@ solid_edge items only clip against bsp models.
|
||||
|
||||
*/
|
||||
|
||||
cvar_t sv_friction = {"sv_friction","4",CVAR_NOTIFY|CVAR_SERVERINFO};
|
||||
cvar_t sv_stopspeed = {"sv_stopspeed","100",CVAR_NONE};
|
||||
cvar_t sv_gravity = {"sv_gravity","800",CVAR_NOTIFY|CVAR_SERVERINFO};
|
||||
cvar_t sv_maxvelocity = {"sv_maxvelocity","2000",CVAR_NONE};
|
||||
cvar_t sv_nostep = {"sv_nostep","0",CVAR_NONE};
|
||||
cvar_t sv_freezenonclients = {"sv_freezenonclients","0",CVAR_NONE};
|
||||
convar sv_friction{"sv_friction","4", {.notify = true,. server_info = true}};
|
||||
convar sv_stopspeed{"sv_stopspeed","100"};
|
||||
convar sv_gravity{"sv_gravity","800",{.notify = true,. server_info = true}};
|
||||
convar sv_maxvelocity{"sv_maxvelocity","2000"};
|
||||
convar sv_nostep{"sv_nostep","0"};
|
||||
convar sv_freezenonclients{"sv_freezenonclients","0"};
|
||||
|
||||
|
||||
#define MOVE_EPSILON 0.01
|
||||
|
||||
+8
-8
@@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
edict_t *sv_player;
|
||||
|
||||
extern cvar_t sv_friction;
|
||||
cvar_t sv_edgefriction = {"edgefriction", "2", CVAR_NONE};
|
||||
extern cvar_t sv_stopspeed;
|
||||
extern convar sv_friction;
|
||||
convar sv_edgefriction{"edgefriction", "2"};
|
||||
extern convar sv_stopspeed;
|
||||
|
||||
static vec3_t forward, right, up;
|
||||
|
||||
@@ -40,8 +40,8 @@ qboolean onground;
|
||||
|
||||
usercmd_t cmd;
|
||||
|
||||
cvar_t sv_idealpitchscale = {"sv_idealpitchscale","0.8",CVAR_NONE};
|
||||
cvar_t sv_altnoclip = {"sv_altnoclip","1",CVAR_ARCHIVE}; //johnfitz
|
||||
convar sv_idealpitchscale{"sv_idealpitchscale","0.8"};
|
||||
convar sv_altnoclip{"sv_altnoclip","1",{.archive = true}}; //johnfitz
|
||||
|
||||
/*
|
||||
===============
|
||||
@@ -163,8 +163,8 @@ void SV_UserFriction (void)
|
||||
SV_Accelerate
|
||||
==============
|
||||
*/
|
||||
cvar_t sv_maxspeed = {"sv_maxspeed", "320", CVAR_NOTIFY|CVAR_SERVERINFO};
|
||||
cvar_t sv_accelerate = {"sv_accelerate", "10", CVAR_NONE};
|
||||
convar sv_maxspeed{"sv_maxspeed", "320", {.notify = true,. server_info = true}};
|
||||
convar sv_accelerate{"sv_accelerate", "10"};
|
||||
void SV_Accelerate (float wishspeed, const vec3_t wishdir)
|
||||
{
|
||||
int i;
|
||||
@@ -570,7 +570,7 @@ nextmsg:
|
||||
ret = 1;
|
||||
|
||||
if (ret == 1)
|
||||
Cmd_ExecuteString (s, src_client);
|
||||
command::execute_string (s, command::source::client);
|
||||
else
|
||||
Con_DPrintf("%s tried to %s\n", host_client->name, s);
|
||||
break;
|
||||
|
||||
@@ -49,7 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
qboolean isDedicated;
|
||||
cvar_t sys_throttle = {"sys_throttle", "0.02", CVAR_ARCHIVE};
|
||||
convar sys_throttle = {"sys_throttle", "0.02", {.archive = true}};
|
||||
|
||||
#define MAX_HANDLES 32 /* johnfitz -- was 10 */
|
||||
static FILE *sys_handles[MAX_HANDLES];
|
||||
|
||||
+557
-621
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#ifndef _QUAKE_VIEW_H
|
||||
#define _QUAKE_VIEW_H
|
||||
|
||||
extern cvar_t vid_gamma;
|
||||
extern cvar_t vid_contrast;
|
||||
extern convar vid_gamma;
|
||||
extern convar vid_contrast;
|
||||
|
||||
extern float v_blend[4];
|
||||
|
||||
|
||||
+3
-3
@@ -238,7 +238,7 @@ void *Z_Realloc(void *ptr, int size)
|
||||
Sys_Error ("Z_Realloc: failed on allocation of %i bytes", size);
|
||||
|
||||
if (ptr != old_ptr)
|
||||
memmove (ptr, old_ptr, q_min(old_size, size));
|
||||
memmove (ptr, old_ptr, std::min(old_size, size));
|
||||
if (old_size < size)
|
||||
memset ((byte *)ptr + old_size, 0, size - old_size);
|
||||
|
||||
@@ -838,7 +838,7 @@ void Cache_Init (void)
|
||||
cache_head.next = cache_head.prev = &cache_head;
|
||||
cache_head.lru_next = cache_head.lru_prev = &cache_head;
|
||||
|
||||
Cmd_AddCommand ("flush", Cache_Flush);
|
||||
command::add ("flush", Cache_Flush);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -984,6 +984,6 @@ void Memory_Init (void *buf, int size)
|
||||
mainzone = (memzone_t *) Hunk_AllocName (zonesize, "zone" );
|
||||
Memory_InitZone (mainzone, zonesize);
|
||||
|
||||
Cmd_AddCommand ("hunk_print", Hunk_Print_f); //johnfitz
|
||||
command::add ("hunk_print", Hunk_Print_f); //johnfitz
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user