-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bede188
commit 59658a8
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ server-init.cfg | |
.deps | ||
.libs | ||
src/mod/discord/discord.so | ||
src/.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* remod: statswriter.cpp | ||
* date: 2025 | ||
* author: degrave | ||
* | ||
* JSON stats writer | ||
*/ | ||
|
||
#include "remod.h" | ||
#include "tools.h" | ||
|
||
EXTENSION(STATSWRITER); | ||
|
||
namespace remod { | ||
namespace statswriter { | ||
struct playerinfo { | ||
const char *name; | ||
const char *authname; | ||
unsigned int connect_seconds; | ||
const char *team; | ||
int privilege; | ||
int frags, flags, deaths, teamkills, shotdamage, damage; | ||
float effectiveness; | ||
int suicides; | ||
struct { | ||
int shotdamage; | ||
int damage; | ||
} guninfo[NUMGUNS]; | ||
}; | ||
struct teaminfo { | ||
const char *team; | ||
int score; | ||
}; | ||
struct gameinfo { | ||
int mode; | ||
const char *mapname; | ||
}; | ||
struct stats { | ||
vector<playerinfo> players; | ||
vector<teaminfo> teams; | ||
struct gameinfo game; | ||
}; | ||
|
||
void write_game(stream *statsfile, gameinfo game) { | ||
statsfile->printf("\"game\":{\"mode\": %d, \"map\": \"%s\"}", game.mode, | ||
game.mapname); | ||
} | ||
|
||
void write_teams(stream *statsfile, gameinfo game) { | ||
// TODO | ||
} | ||
|
||
void write_players(stream *statsfile, gameinfo game) { | ||
// TODO | ||
} | ||
|
||
void write(const char *path, stats stats) { | ||
stream *statsfile = openfile(path, "wb"); | ||
if (!statsfile) { | ||
conoutf("could not write stats to \"%s\"", path); | ||
return; | ||
} | ||
|
||
statsfile->printf("{"); | ||
write_game(statsfile, stats.game); | ||
statsfile->printf("}"); | ||
}; | ||
|
||
} // namespace statswriter | ||
} // namespace remod |