Skip to content

Commit

Permalink
Moved discord.c, removed old commennted code, added Highscores from O…
Browse files Browse the repository at this point in the history
…penFFA
  • Loading branch information
darkshade9 committed Feb 28, 2024
1 parent 872e139 commit 51422fa
Show file tree
Hide file tree
Showing 11 changed files with 486 additions and 407 deletions.
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -502,14 +502,14 @@ if get_option('discord-sdk')
# Discord does not have an SDK for this platform yet, setting USE_DISCORD to false
config.set10('USE_DISCORD', false)
else
config.set10('USE_DISCORD', false) # Disabling Discord for now
config.set10('USE_DISCORD', true) # Disabling Discord for now
discord_inc_path = join_paths('extern/discord/lib/', host_machine.cpu_family())
dis_inc = include_directories(discord_inc_path)
discord_dep_path = join_paths(meson.current_source_dir(), discord_inc_path)
discord_dep = cc.find_library('discord_game_sdk', dirs : discord_dep_path)
client_deps += discord_dep

action_src += ['src/client/discord.c']
client_src += ['src/client/discord.c']
endif
#endif
endif
Expand Down
240 changes: 0 additions & 240 deletions src/action/e_game.c

This file was deleted.

30 changes: 29 additions & 1 deletion src/action/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,33 @@ static void Cmd_CPSI_f (edict_t * ent)
}
}

void Cmd_HighScores_f(edict_t *ent)
{
int i;
char date[MAX_QPATH];
struct tm *tm;
highscore_t *s;

if (!level.numscores) {
gi.cprintf(ent, PRINT_HIGH, "No high scores available.\n");
return;
}

gi.cprintf(ent, PRINT_HIGH,
"\n"
" # Name FPH Date\n"
"-- --------------- ---- ----------------\n");
for (i = 0; i < level.numscores; i++) {
s = &level.scores[i];

tm = localtime(&s->time);
if (!tm || !strftime(date, sizeof(date), "%Y-%m-%d %H:%M", tm))
strcpy(date, "???");
gi.cprintf(ent, PRINT_HIGH, "%2d %-15.15s %4d %s\n",
i + 1, s->name, s->score, date);
}
}

#define CMDF_CHEAT 1 //Need cheat to be enabled
#define CMDF_PAUSE 2 //Cant use while pause

Expand Down Expand Up @@ -1952,7 +1979,8 @@ static cmdList_t commandList[] =
{ "jmod", Cmd_Jmod_f, 0 },
// Espionage, aliased command so it's easy to remember
{ "volunteer", Cmd_Volunteer_f, 0},
{ "leader", Cmd_Volunteer_f, 0}
{ "leader", Cmd_Volunteer_f, 0},
{ "highscores", Cmd_HighScores_f, 0},
};

#define MAX_COMMAND_HASH 64
Expand Down
23 changes: 23 additions & 0 deletions src/action/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,17 @@ bind 6 "use Sniper Rifle"

#define MAX_SPAWNS 512 // max DM spawn points supported

// High Scores support from OpenFFA
#define MAX_HIGH_SCORES 10

typedef struct highscore_s
{
char name[MAX_CLIENT_NAME];
int score;
time_t time;
} highscore_t;


//AQ2:TNG End adding flags

typedef struct itemList_s
Expand Down Expand Up @@ -760,6 +771,9 @@ typedef struct
//q2pro protocol extensions
cs_remap_t csr;
precache_t *precaches;

// High Scores support from OpenFFA
char dir[MAX_OSPATH]; // where variable data is stored
}
game_locals_t;

Expand Down Expand Up @@ -788,6 +802,11 @@ typedef struct
vec3_t intermission_origin;
vec3_t intermission_angle;

// high scores from OpenFFA
highscore_t scores[MAX_HIGH_SCORES];
int numscores;
time_t record; // not zero if scores updated

char *changemap;

char statusbar[1024]; //MAX is 1536 = (MAX_QPATH * (CS_AIRACCEL - CS_STATUSBAR))
Expand Down Expand Up @@ -1267,6 +1286,7 @@ extern cvar_t *sv_killgib; // Enable or disable gibbing on kill command
// 2024
extern cvar_t *warmup_unready;
extern cvar_t *training_mode; // Sets training mode vars
extern cvar_t *g_highscores_dir; // Sets the highscores directory

#if AQTION_EXTENSION
extern int (*engine_Client_GetVersion)(edict_t *ent);
Expand Down Expand Up @@ -1636,6 +1656,9 @@ void ProduceShotgunDamageReport(edict_t*);

//tng_stats.c
void StatBotCheck(void);
void G_RegisterScore(void);
int G_CalcRanks(gclient_t **ranks);
void G_LoadScores(void);
#if USE_AQTION
void LogKill(edict_t *self, edict_t *inflictor, edict_t *attacker);
void LogWorldKill(edict_t *self);
Expand Down
4 changes: 4 additions & 0 deletions src/action/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ cvar_t *sv_killgib; // Gibs on 'kill' command
// 2024
cvar_t *warmup_unready; // Toggles warmup if captains unready
cvar_t *training_mode; // Sets training mode vars
cvar_t *g_highscores_dir; // Sets the highscores directory

#if AQTION_EXTENSION
cvar_t *use_newirvision;
Expand Down Expand Up @@ -833,6 +834,9 @@ void EndDMLevel (void)
gi.bprintf (PRINT_HIGH, "Game ending at: %s\n", ltm);
IRC_printf (IRC_T_GAME, "Game ending at: %s", ltm);

// High scores from OpenFFA
G_RegisterScore();

// JBravo: Stop q2pro MVD2 recording
if (use_mvd2->value)
{
Expand Down
1 change: 1 addition & 0 deletions src/action/g_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ void InitGame( void )
gi.cvar_forceset("dmweapon", "Combat Knife");
gi.cvar_forceset("bholelimit", "30");
}
g_highscores_dir = gi.cvar("g_highscores_dir", "highscores", 0);

// new AQtion Extension cvars
#if AQTION_EXTENSION
Expand Down
3 changes: 3 additions & 0 deletions src/action/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,9 @@ void SpawnEntities (const char *mapname, const char *entities, const char *spawn

G_LoadLocations();

// High score load file
G_LoadScores();

SVCmd_CheckSB_f(); //rekkie -- silence ban

UnBan_TeamKillers();
Expand Down
Loading

0 comments on commit 51422fa

Please sign in to comment.