Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store server ID in match table #613

Merged
merged 2 commits into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions misc/import_stats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CREATE TABLE `get5_stats_matches`
`team1_score` smallint(5) unsigned NOT NULL DEFAULT '0',
`team2_name` varchar(64) NOT NULL DEFAULT '',
`team2_score` smallint(5) unsigned NOT NULL DEFAULT '0',
`server_id` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`matchid`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
Expand Down
5 changes: 5 additions & 0 deletions scripting/get5/natives.sp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("Get5_GetTeamScores", Native_GetTeamScores);
CreateNative("Get5_GetMatchID", Native_GetMatchID);
CreateNative("Get5_SetMatchID", Native_SetMatchID);
CreateNative("Get5_GetServerID", Native_GetServerID);
CreateNative("Get5_AddLiveCvar", Native_AddLiveCvar);
CreateNative("Get5_IncreasePlayerStat", Native_IncreasePlayerStat);
CreateNative("Get5_GetMatchStats", Native_GetMatchStats);
Expand Down Expand Up @@ -193,6 +194,10 @@ public int Native_SetMatchID(Handle plugin, int numParams) {
return 0;
}

public int Native_GetServerID(Handle plugin, int numParams) {
return g_ServerIdCvar.IntValue;
}

public int Native_AddLiveCvar(Handle plugin, int numParams) {
char cvarName[MAX_CVAR_LENGTH];
char cvarValue[MAX_CVAR_LENGTH];
Expand Down
14 changes: 8 additions & 6 deletions scripting/get5_mysqlstats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public void Get5_OnSeriesInit() {
char team1Name[64];
char team2Name[64];

int serverId = Get5_GetServerID();

char seriesTypeSz[sizeof(seriesType) * 2 + 1];
char team1NameSz[sizeof(team1Name) * 2 + 1];
char team2NameSz[sizeof(team2Name) * 2 + 1];
Expand All @@ -103,9 +105,9 @@ public void Get5_OnSeriesInit() {
SetMatchID(g_ForceMatchIDCvar.IntValue);
g_ForceMatchIDCvar.IntValue = 0;
Format(queryBuffer, sizeof(queryBuffer), "INSERT INTO `get5_stats_matches` \
(matchid, series_type, team1_name, team2_name, start_time) VALUES \
(%d, '%s', '%s', '%s', NOW())",
g_MatchID, seriesTypeSz, team1NameSz, team2NameSz);
(matchid, series_type, team1_name, team2_name, start_time, server_id) VALUES \
(%d, '%s', '%s', '%s', NOW(), %d)",
g_MatchID, seriesTypeSz, team1NameSz, team2NameSz, serverId);
LogDebug(queryBuffer);
db.Query(SQLErrorCheckCallback, queryBuffer);

Expand All @@ -114,9 +116,9 @@ public void Get5_OnSeriesInit() {
} else {

Format(queryBuffer, sizeof(queryBuffer), "INSERT INTO `get5_stats_matches` \
(series_type, team1_name, team2_name, start_time) VALUES \
('%s', '%s', '%s', NOW())",
seriesTypeSz, team1NameSz, team2NameSz);
(series_type, team1_name, team2_name, start_time, server_id) VALUES \
('%s', '%s', '%s', NOW(), %d)",
seriesTypeSz, team1NameSz, team2NameSz, serverId);
LogDebug(queryBuffer);
db.Query(MatchInitCallback, queryBuffer);

Expand Down
4 changes: 4 additions & 0 deletions scripting/include/get5.inc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ native void Get5_GetMatchID(char[] id, int length);
// Sets the current matchid.
native void Get5_SetMatchID(const char[] id);

// Returns the server ID as defined by get5_server_id.
native int Get5_GetServerID();

// Adds a cvar to be set when going live. If the cvar is already in the cvars for the match, the new
// value will replace the old value if the override parameter is true.
// Note: this should only be used when a match config loaded.
Expand Down Expand Up @@ -224,6 +227,7 @@ public __pl_get5_SetNTVOptional() {
MarkNativeAsOptional("Get5_GetTeamScores");
MarkNativeAsOptional("Get5_GetMatchID");
MarkNativeAsOptional("Get5_SetMatchID");
MarkNativeAsOptional("Get5_GetServerID");
MarkNativeAsOptional("Get5_AddLiveCvar");
MarkNativeAsOptional("Get5_IncreasePlayerStat");
MarkNativeAsOptional("Get5_GetMatchStats");
Expand Down