Skip to content

Commit c7632f5

Browse files
committed
WIP first pass event logging
1 parent 7f1ef00 commit c7632f5

11 files changed

Lines changed: 568 additions & 0 deletions

File tree

code/game/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ add_library(qagame MODULE
5959
"g_q3f_controllable.c"
6060
"g_q3f_crc.c"
6161
"g_q3f_engineer.c"
62+
"g_q3f_eventlog.c"
63+
"g_q3f_eventlog.h"
6264
"g_q3f_flag.c"
6365
"g_q3f_flag.h"
6466
"g_q3f_grenades.c"

code/game/g_client.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ If you have questions concerning this license or the applicable additional terms
3737
#include "g_q3f_admin.h"
3838
#include "g_q3f_team.h"
3939
#include "g_q3f_flag.h"
40+
#include "g_q3f_eventlog.h"
4041

4142
#include "g_bot_interface.h"
4243
#ifdef BUILD_LUA
@@ -1574,6 +1575,7 @@ qboolean ClientSpawn(gentity_t *ent) {
15741575
int flags, savedPing, i;
15751576
g_q3f_playerclass_t *cls;
15761577
qboolean beginclass = qfalse;
1578+
int oldclass = Q3F_CLASS_NULL;
15771579
g_q3f_location_t *deathloc, *gren1loc, *gren2loc;
15781580
int eventSequence;
15791581
char userinfo[MAX_INFO_STRING];
@@ -1587,6 +1589,7 @@ qboolean ClientSpawn(gentity_t *ent) {
15871589
// Golliwog: If class has changed, perform class term/init functions
15881590
if( client->ps.persistant[PERS_CURRCLASS] != client->sess.sessionClass )
15891591
{
1592+
oldclass = client->ps.persistant[PERS_CURRCLASS];
15901593
// RR2DO2: check for classlimits
15911594
if( g_q3f_teamlist[ent->client->sess.sessionTeam].classmaximums[client->sess.sessionClass] == -1 ||
15921595
g_q3f_teamlist[ent->client->sess.sessionTeam].classmaximums[client->sess.sessionClass] > G_Q3F_ClassCount(ent->client->sess.sessionTeam, client->sess.sessionClass) ||
@@ -1783,6 +1786,15 @@ qboolean ClientSpawn(gentity_t *ent) {
17831786
G_LuaHook_ClientSpawn(ent - g_entities);
17841787
#endif
17851788

1789+
if (!Q3F_IsSpectator(client)) {
1790+
G_EventLog_PlayerStart(ent);
1791+
if (beginclass) {
1792+
int timeplayed = client->pers.class_time > 0 ? level.time - client->pers.class_time : 0;
1793+
G_EventLog_ChangeClass(ent, oldclass, client->ps.persistant[PERS_CURRCLASS], timeplayed);
1794+
client->pers.class_time = level.time;
1795+
}
1796+
}
1797+
17861798
// run a client frame to drop exactly to the floor,
17871799
// initialize animations and other things
17881800
client->ps.commandTime = level.time - 100;

code/game/g_cmds.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ If you have questions concerning this license or the applicable additional terms
4141
#include "g_q3f_admin.h"
4242
#include "bg_q3f_util.h"
4343
#include "g_q3f_mapselect.h"
44+
#include "g_q3f_eventlog.h"
4445

4546
#include "g_bot_interface.h"
4647
#ifdef BUILD_LUA
@@ -610,6 +611,7 @@ void Cmd_Kill_f( gentity_t *ent ) {
610611
AddScore(ent->client->diseaseEnt, ent->client->diseaseEnt->r.currentOrigin, G_Q3F_IsAllied( ent->client->diseaseEnt, ent ) ? -1 : 1 );
611612
}
612613
// RR2DO2
614+
G_EventLog_Death(ent, ent, ent, MOD_SUICIDE);
613615
player_die (ent, ent, ent, 100000, MOD_SUICIDE);
614616

615617
// no suicide delay in warmup
@@ -774,6 +776,7 @@ qboolean SetTeam( gentity_t *ent, const char *s ) {
774776
// Kill him (makes sure he loses flags, etc)
775777
ent->flags &= ~FL_GODMODE;
776778
ent->client->ps.stats[STAT_HEALTH] = ent->health = 0;
779+
G_EventLog_Death(ent, ent, ent, MOD_SWITCHTEAM);
777780
player_die (ent, ent, ent, 100000, MOD_SWITCHTEAM);
778781

779782
/* Ensiform - Adding this because 'keepondeath' items should not still be carried across team changes */

code/game/g_combat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ If you have questions concerning this license or the applicable additional terms
4040
#include "g_q3f_weapon.h"
4141
#include "g_q3f_team.h"
4242
#include "g_q3f_admin.h"
43+
#include "g_q3f_eventlog.h"
4344

4445
#define __STDC_FORMAT_MACROS // older compilers need this
4546
#include <inttypes.h>
@@ -1034,13 +1035,16 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
10341035

10351036
// do the damage
10361037
if (take) {
1038+
if ( (attacker->s.eType == ET_PLAYER || targ->s.eType == ET_PLAYER) && (take + asave > 0) )
1039+
G_EventLog_Damage(attacker, targ, inflictor, mod, take > (int)targ->health ? (int)targ->health : Q_ftol(take + asave));
10371040
targ->health = (int) targ->health - take;
10381041

10391042
if ( targ->client ) {
10401043
targ->client->ps.stats[STAT_HEALTH] = targ->health;
10411044
}
10421045

10431046
if ( targ->health <= 0 ) {
1047+
G_EventLog_Death(attacker, targ, inflictor, mod);
10441048
if ( targ->client )
10451049
targ->flags |= FL_NO_KNOCKBACK;
10461050

code/game/g_local.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ typedef struct {
361361
qboolean initializing; // Golliwog: true if the client is initializing.
362362
int gender;
363363
qboolean isReady; // RR2DO2: for ready-startup
364+
int class_time;
365+
int goal_time;
364366

365367
//unlagged - these correspond with variables in the userinfo string
366368
int unlagged;

code/game/g_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ If you have questions concerning this license or the applicable additional terms
3939
#include "g_q3f_flag.h"
4040
#include "g_q3f_admin.h"
4141
#include "g_q3f_mapselect.h"
42+
#include "g_q3f_eventlog.h"
4243

4344
#include "g_bot_interface.h"
4445

@@ -861,6 +862,8 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
861862
G_DebugLog( "Started map.\n" );
862863
#endif
863864

865+
G_EventLog_Init();
866+
864867
#ifdef BUILD_LUA
865868
G_LuaHook_InitGame( levelTime, randomSeed, restart );
866869
#endif // BUILD_LUA
@@ -893,8 +896,11 @@ void G_ShutdownGame( int restart )
893896
G_LogPrintf("ShutdownGame:\n" );
894897
G_LogPrintf("------------------------------------------------------------\n" );
895898
trap_FS_FCloseFile( level.logFile );
899+
level.logFile = NULL_FILE;
896900
}
897901

902+
G_EventLog_Shutdown();
903+
898904
if (!restart)
899905
{
900906
G_SetMatchState( MATCH_STATE_NORMAL );

0 commit comments

Comments
 (0)