mirror of
https://github.com/nzp-team/fteqw.git
synced 2025-01-18 14:31:52 +00:00
fix warnings, add cvar flag to force renderer callback on vid_restart, switched a few cvars from modified checking to callback usage
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2192 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
4430da6a00
commit
75648fd2ff
10 changed files with 93 additions and 56 deletions
|
@ -3063,7 +3063,6 @@ void Host_Frame (double time)
|
|||
}
|
||||
}
|
||||
|
||||
TP_CheckVars();
|
||||
RSpeedEnd(RSPEED_PROTOCOL);
|
||||
|
||||
// update video
|
||||
|
|
|
@ -292,7 +292,9 @@ void SCR_StringToRGB (char *rgbstring, float *rgb, float rgbinputscale)
|
|||
int i = atoi(rgbstring);
|
||||
i = bound(0, i, 255);
|
||||
|
||||
pal = host_basepal + (i * 3);
|
||||
pal = host_basepal;
|
||||
|
||||
pal += (i * 3);
|
||||
// convert r8g8b8 to rgb floats
|
||||
rgb[0] = (float)(pal[0]);
|
||||
rgb[1] = (float)(pal[1]);
|
||||
|
|
|
@ -922,7 +922,6 @@ void TP_ExecTrigger (char *s);
|
|||
qboolean TP_SuppressMessage(char *buf);
|
||||
|
||||
void TP_Init(void);
|
||||
void TP_CheckVars(void);
|
||||
void TP_CheckPickupSound(char *s, vec3_t org);
|
||||
void TP_ParsePlayerInfo(player_state_t *oldstate, player_state_t *state, player_info_t *info);
|
||||
void CL_Say (qboolean team, char *extra);
|
||||
|
|
|
@ -54,8 +54,10 @@ qboolean keydown[K_MAX];
|
|||
|
||||
qboolean deltaused[K_MAX][KEY_MODIFIERSTATES];
|
||||
|
||||
void Con_Selectioncolour_Callback(struct cvar_s *var, char *oldvalue);
|
||||
|
||||
extern cvar_t con_displaypossabilities;
|
||||
cvar_t con_selectioncolour = SCVAR("con_selectioncolour", "0");
|
||||
cvar_t con_selectioncolour = SCVARFC("con_selectioncolour", "0", CVAR_RENDERERCALLBACK, Con_Selectioncolour_Callback);
|
||||
extern cvar_t cl_chatmode;
|
||||
|
||||
static int KeyModifier (qboolean shift, qboolean alt, qboolean ctrl)
|
||||
|
@ -385,9 +387,14 @@ void Con_ExecuteLine(console_t *con, char *line)
|
|||
// may take some time
|
||||
}
|
||||
|
||||
int scmodified;
|
||||
vec3_t sccolor;
|
||||
|
||||
void Con_Selectioncolour_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
if (qrenderer != QR_NONE && qrenderer != -1)
|
||||
SCR_StringToRGB(var->string, sccolor, 1);
|
||||
}
|
||||
|
||||
void Key_ConsoleDrawSelectionBox(void)
|
||||
{
|
||||
extern cvar_t vid_conwidth, vid_conheight;
|
||||
|
@ -427,9 +434,6 @@ void Key_ConsoleDrawSelectionBox(void)
|
|||
}
|
||||
ypos++;
|
||||
|
||||
if (scmodified != con_selectioncolour.modified)
|
||||
SCR_StringToRGB(con_selectioncolour.string, sccolor, 1);
|
||||
|
||||
Draw_FillRGB(xpos2*8, ypos2*8, (xpos - xpos2)*8, (ypos - ypos2)*8, sccolor[0], sccolor[1], sccolor[2]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1953,6 +1953,8 @@ TRACE(("dbg: R_RestartRenderer_f\n"));
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cvar_ApplyCallbacks(CVAR_RENDERERCALLBACK);
|
||||
SCR_EndLoadingPlaque();
|
||||
|
||||
TRACE(("dbg: R_RestartRenderer_f success\n"));
|
||||
|
|
|
@ -92,6 +92,9 @@ static size_t strlcat (char *dst, const char *src, size_t size)
|
|||
}
|
||||
#endif
|
||||
|
||||
// callbacks used for TP cvars
|
||||
void TP_SkinCvar_Callback(struct cvar_s *var, char *oldvalue);
|
||||
|
||||
//a list of all the cvars
|
||||
//this is down to the fact that I keep defining them but forgetting to register. :/
|
||||
#define TP_CVARS \
|
||||
|
@ -101,8 +104,8 @@ static size_t strlcat (char *dst, const char *src, size_t size)
|
|||
TP_CVAR(cl_triggers, "1"); \
|
||||
TP_CVAR(tp_forceTriggers, "0"); \
|
||||
TP_CVAR(tp_loadlocs, "1"); \
|
||||
TP_CVAR(cl_teamskin, ""); \
|
||||
TP_CVAR(cl_enemyskin, ""); \
|
||||
TP_CVARC(cl_teamskin, "", TP_SkinCvar_Callback); \
|
||||
TP_CVARC(cl_enemyskin, "", TP_SkinCvar_Callback); \
|
||||
TP_CVAR(tp_soundtrigger, "~"); \
|
||||
\
|
||||
TP_CVAR(tp_name_none, ""); \
|
||||
|
@ -186,9 +189,10 @@ static size_t strlcat (char *dst, const char *src, size_t size)
|
|||
|
||||
//create the globals for all the TP cvars.
|
||||
#define TP_CVAR(name,def) cvar_t name = SCVAR(#name, def)
|
||||
#define TP_CVARC(name,def,call) cvar_t name = SCVARC(#name, def, call)
|
||||
TP_CVARS;
|
||||
#undef TP_CVAR
|
||||
|
||||
#undef TP_CVARC
|
||||
|
||||
extern cvar_t host_mapname;
|
||||
|
||||
|
@ -3114,14 +3118,9 @@ static void TP_MsgFilter_f (void)
|
|||
}
|
||||
}
|
||||
|
||||
void TP_CheckVars(void)
|
||||
void TP_SkinCvar_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
if (cl_enemyskin.modified || cl_teamskin.modified)
|
||||
{
|
||||
Skin_FlushPlayers();
|
||||
cl_enemyskin.modified = false;
|
||||
cl_teamskin.modified = false;
|
||||
}
|
||||
Skin_FlushPlayers();
|
||||
}
|
||||
|
||||
void TP_Init (void)
|
||||
|
@ -3130,8 +3129,10 @@ void TP_Init (void)
|
|||
|
||||
//register all the TeamPlay cvars.
|
||||
#define TP_CVAR(name,def) Cvar_Register (&name, TEAMPLAYVARS);
|
||||
#define TP_CVARC(name,def,callback) Cvar_Register (&name, TEAMPLAYVARS);
|
||||
TP_CVARS;
|
||||
#undef TP_CVAR
|
||||
#undef TP_CVARC
|
||||
|
||||
Cmd_AddCommand ("loadloc", TP_LoadLocFile_f);
|
||||
Cmd_AddCommand ("filter", TP_MsgFilter_f);
|
||||
|
|
|
@ -157,6 +157,8 @@ char *Cvar_FlagToName(int flag)
|
|||
return "renderlatch";
|
||||
case CVAR_SERVEROVERRIDE:
|
||||
return "serverlatch";
|
||||
case CVAR_RENDERERCALLBACK:
|
||||
return "rendercallback";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -761,6 +763,22 @@ void Cvar_ForceCheatVars(qboolean semicheats, qboolean absolutecheats)
|
|||
}
|
||||
}
|
||||
|
||||
void Cvar_ApplyCallbacks(int callbackflag)
|
||||
{
|
||||
cvar_group_t *grp;
|
||||
cvar_t *var;
|
||||
|
||||
for (grp=cvar_groups ; grp ; grp=grp->next)
|
||||
for (var=grp->cvars ; var ; var=var->next)
|
||||
{
|
||||
if (var->flags & callbackflag)
|
||||
{
|
||||
if (var->callback)
|
||||
var->callback(var, var->string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cvar_ApplyLatches(int latchflag)
|
||||
{
|
||||
cvar_group_t *grp;
|
||||
|
|
|
@ -75,6 +75,7 @@ typedef struct cvar_s
|
|||
|
||||
#define FCVARC(ConsoleName,ConsoleName2,Value,Flags,Callback) {ConsoleName, Value, NULL, Flags, 0, 0, 0, ConsoleName2, Callback}
|
||||
#define FCVAR(ConsoleName,ConsoleName2,Value,Flags) FCVARC(ConsoleName, ConsoleName2, Value, Flags, NULL)
|
||||
#define SCVARFC(ConsoleName, Value, Flags, Callback) FCVARC(ConsoleName, NULL, Value, Flags, Callback)
|
||||
#define SCVARF(ConsoleName,Value, Flags) FCVAR(ConsoleName, NULL, Value, Flags)
|
||||
#define SCVARC(ConsoleName,Value,Callback) FCVARC(ConsoleName, NULL, Value, 0, Callback)
|
||||
#define SCVAR(ConsoleName,Value) FCVAR(ConsoleName, NULL, Value, 0)
|
||||
|
@ -96,15 +97,16 @@ typedef struct cvar_group_s
|
|||
#define CVAR_LATCH 16 // save changes until server restart
|
||||
|
||||
//freestyle
|
||||
#define CVAR_POINTER 32 // q2 style. May be converted to q1 if needed. These are often specified on the command line and then converted into q1 when registered properly.
|
||||
#define CVAR_NOTFROMSERVER 64 // the console will ignore changes to cvars if set at from the server or any gamecode. This is to protect against security flaws - like qterm
|
||||
#define CVAR_USERCREATED 128 //write a 'set' or 'seta' in front of the var name.
|
||||
#define CVAR_CHEAT 256 //latch to the default, unless cheats are enabled.
|
||||
#define CVAR_SEMICHEAT 512 //if strict ruleset, force to 0/blank.
|
||||
#define CVAR_RENDERERLATCH 1024 //requires a vid_restart to reapply.
|
||||
#define CVAR_SERVEROVERRIDE 2048 //the server has overridden out local value - should probably be called SERVERLATCH
|
||||
#define CVAR_POINTER 32 // q2 style. May be converted to q1 if needed. These are often specified on the command line and then converted into q1 when registered properly.
|
||||
#define CVAR_NOTFROMSERVER 64 // the console will ignore changes to cvars if set at from the server or any gamecode. This is to protect against security flaws - like qterm
|
||||
#define CVAR_USERCREATED 128 //write a 'set' or 'seta' in front of the var name.
|
||||
#define CVAR_CHEAT 256 //latch to the default, unless cheats are enabled.
|
||||
#define CVAR_SEMICHEAT 512 //if strict ruleset, force to 0/blank.
|
||||
#define CVAR_RENDERERLATCH 1024 //requires a vid_restart to reapply.
|
||||
#define CVAR_SERVEROVERRIDE 2048 //the server has overridden out local value - should probably be called SERVERLATCH
|
||||
#define CVAR_RENDERERCALLBACK 4096 //force callback for cvars on renderer change
|
||||
|
||||
#define CVAR_LASTFLAG CVAR_SERVEROVERRIDE
|
||||
#define CVAR_LASTFLAG CVAR_RENDERERCALLBACK
|
||||
|
||||
#define CVAR_LATCHMASK (CVAR_LATCH|CVAR_RENDERERLATCH|CVAR_SERVEROVERRIDE|CVAR_CHEAT|CVAR_SEMICHEAT) //you're only allowed one of these.
|
||||
#define CVAR_NEEDDEFAULT CVAR_CHEAT
|
||||
|
@ -129,6 +131,9 @@ void Cvar_SetValue (cvar_t *var, float value);
|
|||
void Cvar_ApplyLatches(int latchflag);
|
||||
//sets vars to thier latched values
|
||||
|
||||
void Cvar_ApplyCallbacks(int callbackflag);
|
||||
//forces callbacks to be ran for given flags
|
||||
|
||||
float Cvar_VariableValue (const char *var_name);
|
||||
// returns 0 if not defined or non numeric
|
||||
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
// cvar callbacks
|
||||
void Log_Dir_Callback (struct cvar_s *var, char *oldvalue);
|
||||
void Log_Name_Callback (struct cvar_s *var, char *oldvalue);
|
||||
|
||||
// cvars
|
||||
#define CONLOGGROUP "Console logging"
|
||||
cvar_t log_name = SCVARF("log_name", "", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_dir = SCVARF("log_dir", "", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_name = SCVARFC("log_name", "", CVAR_NOTFROMSERVER, Log_Name_Callback);
|
||||
cvar_t log_dir = SCVARFC("log_dir", "", CVAR_NOTFROMSERVER, Log_Dir_Callback);
|
||||
cvar_t log_readable = SCVARF("log_readable", "0", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_enable = SCVARF("log_enable", "0", CVAR_NOTFROMSERVER);
|
||||
cvar_t log_developer = SCVARF("log_developer", "0", CVAR_NOTFROMSERVER);
|
||||
|
@ -54,6 +58,34 @@ char readable[256] =
|
|||
'x', 'y', 'z', '{', '|', '}', '~', '_'
|
||||
};
|
||||
|
||||
// Log_Dir_Callback: called when a log_dir is changed
|
||||
void Log_Dir_Callback (struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
char *t = var->string;
|
||||
|
||||
// sanity check for directory
|
||||
if (strstr(t, "..") || strstr(t, ":") || *t == '/' || *t == '\\')
|
||||
{
|
||||
Con_Printf(S_NOTICE "%s forced to default due to invalid characters.\n", var->name);
|
||||
// recursion is avoided by assuming the default value is sane
|
||||
Cvar_ForceSet(var, var->defaultstr);
|
||||
}
|
||||
}
|
||||
|
||||
// Log_Name_Callback: called when a log_dir is changed
|
||||
void Log_Name_Callback (struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
char *t = var->string;
|
||||
|
||||
// sanity check for directory
|
||||
if (strstr(t, "..") || strstr(t, ":") || strstr(t, "/") || strstr(t, "\\"))
|
||||
{
|
||||
Con_Printf(S_NOTICE "%s forced to default due to invalid characters.\n", var->name);
|
||||
// recursion is avoided by assuming the default value is sane
|
||||
Cvar_ForceSet(var, var->defaultstr);
|
||||
}
|
||||
}
|
||||
|
||||
// Con_Log: log string to console log
|
||||
void Con_Log (char *s)
|
||||
{
|
||||
|
@ -66,31 +98,6 @@ void Con_Log (char *s)
|
|||
if (!log_enable.value)
|
||||
return;
|
||||
|
||||
// cvar sanity checks
|
||||
if (log_dir.modified)
|
||||
{
|
||||
t = log_dir.string;
|
||||
if (strstr(t, "..") || strstr(t, ":") || *t == '/' || *t == '\\')
|
||||
{
|
||||
Con_Printf("log_dir forced to default due to invalid characters.\n");
|
||||
Cvar_ForceSet(&log_dir, log_dir.defaultstr);
|
||||
}
|
||||
|
||||
log_dir.modified = false;
|
||||
}
|
||||
|
||||
if (log_name.modified)
|
||||
{
|
||||
t = log_name.string;
|
||||
if (strstr(t, "..") || strstr(t, ":") || strstr(t, "/") || strstr(t, "\\"))
|
||||
{
|
||||
Con_Printf("log_name forced to default due to invalid characters.\n");
|
||||
Cvar_ForceSet(&log_name, log_name.defaultstr);
|
||||
}
|
||||
|
||||
log_name.modified = false;
|
||||
}
|
||||
|
||||
// get directory/filename
|
||||
d = gamedirfile;
|
||||
if (log_dir.string[0])
|
||||
|
|
|
@ -136,7 +136,7 @@ void R_Bloom_InitBackUpTexture( int width, int height )
|
|||
|
||||
r_screenbackuptexture_size = width;
|
||||
|
||||
r_bloombackuptexture = GL_LoadTexture32("***r_bloombackuptexture***", width, height, data, false, false );
|
||||
r_bloombackuptexture = GL_LoadTexture32("***r_bloombackuptexture***", width, height, (unsigned int*)data, false, false );
|
||||
|
||||
Z_Free ( data );
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ void R_Bloom_InitEffectTexture( void )
|
|||
|
||||
data = Z_Malloc( BLOOM_SIZE * BLOOM_SIZE * 4 );
|
||||
|
||||
r_bloomeffecttexture = GL_LoadTexture32("***r_bloomeffecttexture***", BLOOM_SIZE, BLOOM_SIZE, data, false, false );
|
||||
r_bloomeffecttexture = GL_LoadTexture32("***r_bloomeffecttexture***", BLOOM_SIZE, BLOOM_SIZE, (unsigned int*)data, false, false );
|
||||
|
||||
Z_Free ( data );
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ void R_Bloom_InitTextures( void )
|
|||
{
|
||||
r_screendownsamplingtexture_size = (int)(BLOOM_SIZE * 2);
|
||||
data = Z_Malloc( r_screendownsamplingtexture_size * r_screendownsamplingtexture_size * 4 );
|
||||
r_bloomdownsamplingtexture = GL_LoadTexture32("***r_bloomdownsamplingtexture***", r_screendownsamplingtexture_size, r_screendownsamplingtexture_size, data, false, false );
|
||||
r_bloomdownsamplingtexture = GL_LoadTexture32("***r_bloomdownsamplingtexture***", r_screendownsamplingtexture_size, r_screendownsamplingtexture_size, (unsigned int*)data, false, false );
|
||||
Z_Free ( data );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue