Skip to content

Commit

Permalink
Added sv_allowRcon, updated cvar typedefs from cod4x, added cvar flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
voron00 committed Oct 21, 2017
1 parent 2bc0d0d commit 471dc76
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 20 deletions.
66 changes: 56 additions & 10 deletions functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,52 @@ typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4];
typedef vec_t vec5_t[5];

typedef struct
typedef unsigned char byte;

typedef union
{
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
int i;
byte rgba[4];
} ucolor_t;

typedef enum
{
CVAR_BOOL,
CVAR_FLOAT,
CVAR_VEC2,
CVAR_VEC3,
CVAR_VEC4,
CVAR_INT,
CVAR_ENUM,
CVAR_STRING,
CVAR_COLOR
} cvarType_t;

typedef union value_s
{
float floatval;
float value;
int integer;
char* string;
byte boolean;
vec3_t vec3;
vec4_t vec4;
} value_t;

typedef struct cvar_s
{
char *name;
char *description;
short int flags;
unsigned char type;
unsigned char modified;
byte type;
byte modified;
union
{
float floatval;
float value;
int integer;
char* string;
unsigned char boolean;
byte boolean;
vec2_t vec2;
vec3_t vec3;
vec4_t vec4;
Expand All @@ -220,7 +244,7 @@ typedef struct cvar_s
float latchedFloatval;
int latchedInteger;
char* latchedString;
unsigned char latchedBoolean;
byte latchedBoolean;
vec2_t latchedVec2;
vec3_t latchedVec3;
vec4_t latchedVec4;
Expand All @@ -231,7 +255,7 @@ typedef struct cvar_s
float resetFloatval;
int resetInteger;
char* resetString;
unsigned char resetBoolean;
byte resetBoolean;
vec2_t resetVec2;
vec3_t resetVec3;
vec4_t resetVec4;
Expand All @@ -252,6 +276,28 @@ typedef struct cvar_s
struct cvar_s *hashNext;
} cvar_t;

extern int cvar_modifiedFlags;

//defines Cvarflags
#define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc
// used for system variables, not for player
// specific configurations
#define CVAR_USERINFO 2 // sent to server on connect or change
#define CVAR_SERVERINFO 4 // sent in response to front end requests
#define CVAR_SYSTEMINFO 8 // these cvars will be duplicated on all clients
#define CVAR_INIT 16 // don't allow change from console at all,
// but can be set from the command line
#define CVAR_LATCH 32 // will only change when C code next does
// a Cvar_Get(), so it can't be changed
// without proper initialization. modified
// will be set, even though the value hasn't
// changed yet
#define CVAR_ROM 64 // display only, cannot be set by user at all
#define CVAR_CHEAT 128 // can not be changed if cheats are disabled
#define CVAR_TEMP 256 // can be set even when cheats are disabled, but is not archived
#define CVAR_NORESTART 1024 // do not clear when a cvar_restart is issued
#define CVAR_USER_CREATED 16384 // created by a set command

struct VariableStackBuffer
{
const char *pos;
Expand Down
4 changes: 2 additions & 2 deletions gsc_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void Sys_AnsiColorPrint( const char *msg )
}
}

extern cvar_t *colored_prints;
extern cvar_t *con_coloredPrints;
int stackPrintParam(int param)
{
if (param >= Scr_GetNumParam())
Expand All @@ -127,7 +127,7 @@ int stackPrintParam(int param)
case STACK_STRING:
char *str;
stackGetParamString(param, &str); // no error checking, since we know it's a string
if (colored_prints->boolean)
if (con_coloredPrints->boolean)
Sys_AnsiColorPrint(str);
else
printf("%s", str);
Expand Down
21 changes: 13 additions & 8 deletions libcod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cvar_t *sv_allowDownload;
cvar_t *sv_pure;
cvar_t *developer;
cvar_t *rcon_password;
cvar_t *colored_prints;
cvar_t *con_coloredPrints;

#if COD_VERSION == COD2_1_2 || COD_VERSION == COD2_1_3
cvar_t *sv_wwwDownload;
Expand Down Expand Up @@ -811,8 +811,12 @@ bool SVC_RateLimitAddress( netadr_t from, int burst, int period )
return SVC_RateLimit( bucket, burst, period );
}

cvar_t *sv_allowRcon;
void hook_SVC_RemoteCommand(netadr_t from, msg_t *msg)
{
if (!sv_allowRcon->boolean)
return;

// Prevent using rcon as an amplifier and make dictionary attacks impractical
if ( SVC_RateLimitAddress( from, 10, 1000 ) )
{
Expand Down Expand Up @@ -1220,13 +1224,14 @@ class cCallOfDuty2Pro
#endif

// Register custom cvars
sv_cracked = Cvar_RegisterBool("sv_cracked", 0, 0x1000u);
sv_noauthorize = Cvar_RegisterBool("sv_noauthorize", 0, 0x1000u);
colored_prints = Cvar_RegisterBool("colored_prints", 1, 0x1000u);
g_playerCollision = Cvar_RegisterBool("g_playerCollision", 1, 0x1000u);
g_playerEject = Cvar_RegisterBool("g_playerEject", 1, 0x1000u);
fs_library = Cvar_RegisterString("fs_library", "", 0x1000u);
sv_downloadMessage = Cvar_RegisterString("sv_downloadMessage", "", 0x1000u);
sv_cracked = Cvar_RegisterBool("sv_cracked", 0, CVAR_ARCHIVE);
sv_noauthorize = Cvar_RegisterBool("sv_noauthorize", 0, CVAR_ARCHIVE);
con_coloredPrints = Cvar_RegisterBool("con_coloredPrints", 1, CVAR_ARCHIVE);
g_playerCollision = Cvar_RegisterBool("g_playerCollision", 1, CVAR_ARCHIVE);
g_playerEject = Cvar_RegisterBool("g_playerEject", 1, CVAR_ARCHIVE);
sv_allowRcon = Cvar_RegisterBool("sv_allowRcon", 1, CVAR_ARCHIVE);
fs_library = Cvar_RegisterString("fs_library", "", CVAR_ARCHIVE);
sv_downloadMessage = Cvar_RegisterString("sv_downloadMessage", "", CVAR_ARCHIVE);

setenv("LD_PRELOAD", "", 1); // dont inherit lib of parent
printf("> [PLUGIN LOADED]\n");
Expand Down

0 comments on commit 471dc76

Please sign in to comment.