Skip to content

Commit

Permalink
game: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Sep 22, 2024
1 parent 8fb4ee1 commit e13f7d9
Show file tree
Hide file tree
Showing 3 changed files with 536 additions and 337 deletions.
44 changes: 32 additions & 12 deletions src/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ edict_t *g_edicts;

cvar_t *deathmatch;
cvar_t *coop;
cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
cvar_t *coop_pickup_weapons;
cvar_t *coop_elevator_delay;
cvar_t *dmflags;
cvar_t *skill;
cvar_t *fraglimit;
cvar_t *timelimit;
cvar_t *capturelimit;
cvar_t *instantweap;
cvar_t *password;
cvar_t *spectator_password;
cvar_t *needpass;
Expand Down Expand Up @@ -94,6 +97,21 @@ cvar_t *flood_persecond;
cvar_t *flood_waitdelay;

cvar_t *sv_maplist;
cvar_t *sv_stopspeed;

cvar_t *gib_on;
cvar_t *g_showlogic;
cvar_t *gamerules;
cvar_t *huntercam;
cvar_t *strong_mines;
cvar_t *randomrespawn;

cvar_t *g_disruptor;

cvar_t *aimfix;
cvar_t *g_machinegun_norecoil;
cvar_t *g_quick_weap;
cvar_t *g_swap_speed;

cvar_t *advancedstaff;
cvar_t *sv_friction;
Expand Down Expand Up @@ -148,7 +166,7 @@ void ReadGame(const char *filename);
void WriteLevel(const char *filename);
void ReadLevel(const char *filename);
void InitGame(void);
void G_RunFrame(void);
static void G_RunFrame(void);
void ConstructEntities(void);
void G_ClearMessageQueues();

Expand Down Expand Up @@ -316,7 +334,7 @@ void G_SoundEvent(byte EventId, float leveltime, edict_t* ent, int channel, int

/* =================================================================== */

void
static void
ShutdownGame(void)
{
void G_ReleaseResourceManagers();
Expand Down Expand Up @@ -425,14 +443,14 @@ Com_Printf(const char *msg, ...)

/* ====================================================================== */

void
static void
ClientEndServerFrames(void)
{
int i;
edict_t *ent;

/* calc the player views now that all
pushing and damage has been added */
pushing and damage has been added */
for (i = 0; i < maxclients->value; i++)
{
ent = g_edicts + 1 + i;
Expand All @@ -449,7 +467,7 @@ ClientEndServerFrames(void)
/*
* Returns the created target changelevel
*/
edict_t *
static edict_t *
CreateTargetChangeLevel(char *map)
{
edict_t *ent;
Expand Down Expand Up @@ -537,8 +555,10 @@ EndDMLevel(void)
ent = G_Find(NULL, FOFS(classname), "target_changelevel");

if (!ent)
{ /* the map designer didn't include a changelevel,
so create a fake ent that goes back to the same level */
{
/* the map designer didn't include a changelevel,
so create a fake ent that goes back to the same
level */
BeginIntermission(CreateTargetChangeLevel(level.mapname));
return;
}
Expand All @@ -547,7 +567,7 @@ EndDMLevel(void)
}
}

void
static void
CheckNeedPass(void)
{
int need;
Expand Down Expand Up @@ -595,7 +615,7 @@ CheckDMRules(void)
{
if (level.time >= timelimit->value * 60)
{
G_BroadcastObituary(PRINT_HIGH, GM_TIMELIMIT, 0, 0);
gi.bprintf(PRINT_HIGH, "Timelimit hit.\n");
EndDMLevel();
return;
}
Expand All @@ -614,15 +634,15 @@ CheckDMRules(void)

if (cl->resp.score >= fraglimit->value)
{
G_BroadcastObituary (PRINT_HIGH, GM_FRAGLIMIT, 0, 0);
gi.bprintf(PRINT_HIGH, "Fraglimit hit.\n");
EndDMLevel();
return;
}
}
}
}

void
static void
ExitLevel(void)
{
char command[256];
Expand Down Expand Up @@ -805,7 +825,7 @@ UpdatePlayerBuoys(void)
/*
* Advances the world by 0.1 seconds
*/
void
static void
G_RunFrame(void)
{
void UpdateSkeletons();
Expand Down
112 changes: 69 additions & 43 deletions src/game/header/local.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,14 @@ typedef struct
extern edict_t *g_edicts;

#define FOFS(x) (size_t)&(((edict_t *)NULL)->x)
#define STOFS(x) (size_t)&(((spawn_temp_t *)NULL)->x)
#define LLOFS(x) (size_t)&(((level_locals_t *)NULL)->x)
#define CLOFS(x) (size_t)&(((gclient_t *)NULL)->x)
#define STOFS(x) (size_t)&(((spawn_temp_t *)NULL)->x)
#define LLOFS(x) (size_t)&(((level_locals_t *)NULL)->x)
#define CLOFS(x) (size_t)&(((gclient_t *)NULL)->x)
#define BYOFS(x) (size_t)&(((buoy_t *)NULL)->x)

#define random() ((randk() & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5))

extern game_locals_t game;
extern level_locals_t level;
extern game_import_t gi;
Expand All @@ -721,19 +724,29 @@ extern int snd_fry;
extern cvar_t *maxentities;
extern cvar_t *deathmatch;
extern cvar_t *coop;
extern cvar_t *coop_baseq2; /* treat spawnflags according to baseq2 rules */
extern cvar_t *coop_pickup_weapons;
extern cvar_t *coop_elevator_delay;
extern cvar_t *coop_pickup_weapons;
extern cvar_t *dmflags;
extern cvar_t *advancedstaff;
extern cvar_t *skill;
extern cvar_t *fraglimit;
extern cvar_t *timelimit;
extern cvar_t *capturelimit;
extern cvar_t *instantweap;
extern cvar_t *password;
extern cvar_t *spectator_password;
extern cvar_t *needpass;
extern cvar_t *g_select_empty;
extern cvar_t *dedicated;
extern cvar_t *g_footsteps;
extern cvar_t *g_monsterfootsteps;
extern cvar_t *g_fix_triggered;
extern cvar_t *g_commanderbody_nogod;

extern cvar_t *filterban;

extern cvar_t *sv_gravity;
extern cvar_t *sv_friction;
extern cvar_t *sv_maxvelocity;

extern cvar_t *gun_x, *gun_y, *gun_z;
Expand All @@ -747,6 +760,45 @@ extern cvar_t *bob_pitch;
extern cvar_t *bob_roll;

extern cvar_t *sv_cheats;
extern cvar_t *maxclients;
extern cvar_t *maxspectators;

extern cvar_t *flood_msgs;
extern cvar_t *flood_persecond;
extern cvar_t *flood_waitdelay;

extern cvar_t *sv_maplist;

extern cvar_t *sv_stopspeed;

extern cvar_t *g_showlogic;
extern cvar_t *gamerules;
extern cvar_t *huntercam;
extern cvar_t *strong_mines;
extern cvar_t *randomrespawn;

extern cvar_t *g_disruptor;

extern cvar_t *aimfix;
extern cvar_t *g_machinegun_norecoil;
extern cvar_t *g_quick_weap;
extern cvar_t *g_swap_speed;
extern cvar_t *autorotate;
extern cvar_t *blood;

extern cvar_t *checkanim; // specifies whether monsters should check to see if most of the
// distance of a move animation is unobstructed before setting it
extern cvar_t *allowillegalskins;

extern cvar_t *monster_speeds;
extern cvar_t *pvs_cull;

extern cvar_t *game_test; // sfs--for testing the speed impact of code changes
extern cvar_t *dm_no_bodies;

extern cvar_t *player_dll;
extern cvar_t *advancedstaff;
extern cvar_t *sv_friction;
extern cvar_t *sv_nomonsters;
extern cvar_t *blood_level;
extern cvar_t *showbuoys;
Expand Down Expand Up @@ -775,28 +827,7 @@ extern cvar_t *sv_jumpcinematic;

extern cvar_t *sv_freezemonsters;

extern cvar_t *maxclients;
extern cvar_t *maxspectators;
extern cvar_t *sv_maplist;

extern cvar_t *autorotate;
extern cvar_t *blood;

extern cvar_t *checkanim; // specifies whether monsters should check to see if most of the
// distance of a move animation is unobstructed before setting it
extern cvar_t *allowillegalskins;

extern cvar_t *monster_speeds;
extern cvar_t *pvs_cull;

extern cvar_t *game_test; // sfs--for testing the speed impact of code changes
extern cvar_t *dm_no_bodies;

extern cvar_t *player_dll;

extern cvar_t *flood_msgs;
extern cvar_t *flood_persecond;
extern cvar_t *flood_waitdelay;
extern cvar_t *flood_killdelay;

extern edict_t *g_edicts;
Expand All @@ -810,29 +841,26 @@ extern int self_spawn;
// ************************************************************************************************

#define DROPPED_ITEM 0x00008000
#define DROPPED_PLAYER_ITEM 0x00010000

// fields are needed for spawning from the entity string
// and saving / loading games
#define DROPPED_PLAYER_ITEM 0x00010000

#define FFL_SPAWNTEMP 1

// ************************************************************************************************
// fieldtype_t
// -----------
// ************************************************************************************************
/* fields are needed for spawning from the entity
string and saving / loading games */
#define FFL_SPAWNTEMP 1
#define FFL_NOSPAWN 2

typedef enum
{
F_INT,
F_FLOAT,
F_LSTRING, /* string on disk, pointer in memory, TAG_LEVEL */
F_GSTRING, /* string on disk, pointer in memory, TAG_GAME */
F_LSTRING, /* string on disk, pointer in memory, TAG_LEVEL */
F_GSTRING, /* string on disk, pointer in memory, TAG_GAME */
F_VECTOR,
F_ANGLEHACK,
F_EDICT, /* index on disk, pointer in memory */
F_ITEM, /* index on disk, pointer in memory */
F_CLIENT, /* index on disk, pointer in memory */
F_EDICT, /* index on disk, pointer in memory */
F_ITEM, /* index on disk, pointer in memory */
F_CLIENT, /* index on disk, pointer in memory */
F_FUNCTION,
F_MMOVE,
F_RGBA,
F_RGB,
F_IGNORE
Expand All @@ -848,7 +876,6 @@ typedef struct
} field_t;

extern field_t fields[];
// extern gitem_t itemlist[];


/* g_cmds.c */
Expand Down Expand Up @@ -917,7 +944,6 @@ edict_t *findradius2(edict_t *from, vec3_t org, float rad);
void ED_CallSpawn(edict_t *ent);
void DynamicSpawnInit(void);


/* g_combat.c */
qboolean OnSameTeam(edict_t *ent1, edict_t *ent2);
qboolean CanDamage(edict_t *targ, edict_t *inflictor);
Expand Down
Loading

0 comments on commit e13f7d9

Please sign in to comment.