Skip to content

Commit

Permalink
prepare beta release
Browse files Browse the repository at this point in the history
  • Loading branch information
Salvatore-Als committed Nov 21, 2023
1 parent 3e759e2 commit b538bd2
Show file tree
Hide file tree
Showing 25 changed files with 99 additions and 172 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ build/
external/web/node_modules/
external/discord/node_modules/
external/discord/.env
fiveserver.config.js
fiveserver.config.js
.vs/
1 change: 0 additions & 1 deletion .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"ExpandedNodes": [
""
],
"SelectedNode": "\\.gitmodules",
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .vs/cs2-rank/v17/.wsuo
Binary file not shown.
Binary file removed .vs/cs2-rank/v17/workspaceFileList.bin
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
2 changes: 1 addition & 1 deletion AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class MMSPluginConfig(object):

# Debugging
if builder.options.debug == '1':
cxx.defines += ['DEBUG', '_DEBUG']
cxx.defines += ['DEBUG', '_DEBUG', '_ITERATOR_DEBUG_LEVEL=0']
if cxx.behavior == 'gcc':
cxx.cflags += ['-g3']
elif cxx.behavior == 'msvc':
Expand Down
2 changes: 1 addition & 1 deletion AMBuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os

MMSPlugin.plugin_name = 'vgrank'
MMSPlugin.plugin_name = 'cs2rank'

# Here only one sdk should be available to generate only one executable in the end,
# as multi-sdk loading isn't supported out of the box by metamod, and would require specifying the full path in the vdf
Expand Down
2 changes: 1 addition & 1 deletion PackageScript
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ with open(os.path.join(builder.buildPath, 'pdblog.txt'), 'wt') as fp:


gamedata_folder = builder.AddFolder(os.path.join('addons', MMSPlugin.plugin_name, 'gamedata'))
builder.AddCopy(os.path.join('gamedata', 'vgrank.games.txt'), gamedata_folder)
builder.AddCopy(os.path.join('gamedata', 'cs2rank.games.txt'), gamedata_folder)

config_folder = builder.AddFolder(os.path.join('addons', MMSPlugin.plugin_name, 'configs'))
builder.AddCopy(os.path.join('configs', 'points.cfg'), config_folder)
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if not exist build mkdir build
cd build
@echo on

python ../configure.py --sdks cs2 --targets=x86_64 --plugin-name=vgrank --plugin-alias=vgrank
python ../configure.py --sdks cs2 --targets=x86_64 --plugin-name=cs2rank --plugin-alias=cs2rank --enable-debug

ambuild
exit
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ echo "export MMSOURCE112=/home/metamod/metamod-source" >> ~/.bashrc

rm -R build
mkdir build && cd build
CC=clang CXX=clang++ python3 ../configure.py -s cs2 --targets=x86_64 --plugin-name=vgrank --plugin-alias=vgrank
CC=clang CXX=clang++ python3 ../configure.py -s cs2 --targets=x86_64 --plugin-name=cs2rank --plugin-alias=cs2rank
ambuild

28 changes: 14 additions & 14 deletions external/discord/src/services/mysqlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class MysqlService {
return null;
}

const query: string = "SELECT *, CAST(authid AS CHAR) AS authid FROM verygames_rank_users WHERE authid = ? AND reference = ? ORDER BY points DESC";
const query: string = "SELECT *, CAST(authid AS CHAR) AS authid FROM cs2_rank_users WHERE authid = ? AND reference = ? ORDER BY points DESC";
const players: IPlayer[] = await this._mysqlProvider.query<IPlayer[]>(query, [authid, groupReference]);

let player: IPlayer = players[0];
Expand All @@ -61,7 +61,7 @@ export default class MysqlService {
return null;
}

const query: string = "SELECT *, CAST(authid AS CHAR) AS authid FROM verygames_rank_users WHERE name LIKE ? AND reference = ? ORDER BY points DESC";
const query: string = "SELECT *, CAST(authid AS CHAR) AS authid FROM cs2_rank_users WHERE name LIKE ? AND reference = ? ORDER BY points DESC";
const players: IPlayer[] = await this._mysqlProvider.query<IPlayer[]>(query, [`%${name}%`, groupReference]);

let player: IPlayer = players[0];
Expand All @@ -81,42 +81,42 @@ export default class MysqlService {
let result: ITopPlayer[] = null;

if (mapId != null) {
query = "SELECT CAST(authid AS CHAR) AS authid, name, points FROM verygames_rank_users WHERE points >= ? AND reference = ? AND `map` = ? ORDER BY points DESC";
query = "SELECT CAST(authid AS CHAR) AS authid, name, points FROM cs2_rank_users WHERE points >= ? AND reference = ? AND `map` = ? ORDER BY points DESC";
result = await this._mysqlProvider.query<ITopPlayer[]>(query, [Number(process.env.MINIMUM_POINTS), groupReference, mapId]);
} else {
query = "SELECT CAST(authid AS CHAR) AS authid, name, points FROM verygames_rank_users WHERE points >= ? AND reference = ? ORDER BY points DESC";
query = "SELECT CAST(authid AS CHAR) AS authid, name, points FROM cs2_rank_users WHERE points >= ? AND reference = ? ORDER BY points DESC";
result = await this._mysqlProvider.query<ITopPlayer[]>(query, [Number(process.env.MINIMUM_POINTS), groupReference]);
}

return result;
}

async getGroups(): Promise<IGroup[]> {
const query: string = 'SELECT id, reference, custom_name FROM verygames_rank_references';
const query: string = 'SELECT id, reference, custom_name FROM cs2_rank_references';
const result: IGroup[] = await this._mysqlProvider.query<IGroup[]>(query);
return result;
}

public async getLinkedAccounts(): Promise<ILinkedAccout[]> {
const query: string = "SELECT * FROM verygames_rank_accounts";
const query: string = "SELECT * FROM cs2_rank_accounts";
const result: ILinkedAccout[] = await this._mysqlProvider.query<ILinkedAccout[]>(query);
return result;
}

public async getMaps(): Promise<IMap[]> {
const query: string = "SELECT * FROM verygames_rank_maps";
const query: string = "SELECT * FROM cs2_rank_maps";
const result: IMap[] = await this._mysqlProvider.query<IMap[]>(query);
return result;
}

public async createLinkedAccount(authid: string, discordId: string): Promise<void> {
const query: string = "INSERT INTO verygames_rank_accounts (authid, discordid) VALUES (?, ?)";
const query: string = "INSERT INTO cs2_rank_accounts (authid, discordid) VALUES (?, ?)";
const result: void = await this._mysqlProvider.query<void>(query, [authid, discordId]);
return result;
}

public async getMapByName(name: string): Promise<IMap> {
const query: string = "SELECT * FROM verygames_rank_maps WHERE name LIKE ?";
const query: string = "SELECT * FROM cs2_rank_maps WHERE name LIKE ?";
const maps: IMap[] = await this._mysqlProvider.query<IMap[]>(query, [`%${name}%`]);

if (!maps?.length) {
Expand All @@ -128,7 +128,7 @@ export default class MysqlService {

private async createDiscordTable(): Promise<void> {
return new Promise(async (resolve, reject) => {
const query: string = "CREATE TABLE verygames_rank_accounts (id INT AUTO_INCREMENT PRIMARY KEY, authid VARCHAR(255) UNIQUE, discordid VARCHAR(255) UNIQUE)";
const query: string = "CREATE TABLE cs2_rank_accounts (id INT AUTO_INCREMENT PRIMARY KEY, authid VARCHAR(255) UNIQUE, discordid VARCHAR(255) UNIQUE)";
this._mysqlProvider.query<IGroup[]>(query)
.then(() => {
resolve();
Expand All @@ -144,11 +144,11 @@ export default class MysqlService {

if (mapId != null) {
this._loggerService.debug(`[Mysql Service] Get rank by mapId ${mapId}`);
query = "SELECT COUNT(*) as count FROM verygames_rank_users WHERE points > ? AND reference = ? AND `map` = ?";
query = "SELECT COUNT(*) as count FROM cs2_rank_users WHERE points > ? AND reference = ? AND `map` = ?";
results = await this._mysqlProvider.query<MysqlCountResult[]>(query, [points ?? 10, groupReference, mapId]);
} else {
this._loggerService.debug(`[Mysql Service] Get rank`);
query = "SELECT COUNT(*) as count FROM verygames_rank_users WHERE reference = ? GROUP BY authid HAVING SUM(points) > ?";
query = "SELECT COUNT(*) as count FROM cs2_rank_users WHERE reference = ? GROUP BY authid HAVING SUM(points) > ?";
results = await this._mysqlProvider.query<MysqlCountResult[]>(query, [groupReference, points ?? 10]);
}

Expand All @@ -157,7 +157,7 @@ export default class MysqlService {
}

private async getPointByAuthId(authid: string, groupReference: string): Promise<number> {
const query: string = "SELECT points FROM verygames_rank_users WHERE authid = ? AND reference = ?";
const query: string = "SELECT points FROM cs2_rank_users WHERE authid = ? AND reference = ?";
const result: IPlayer = await this._mysqlProvider.query<IPlayer>(query, [authid, groupReference]);

if (!result) {
Expand All @@ -168,7 +168,7 @@ export default class MysqlService {
}

private async getPointByName(name: string, groupReference: string): Promise<number> {
const query: string = "SELECT points FROM verygames_rank_users WHERE name LIKE ? AND reference = ?";
const query: string = "SELECT points FROM cs2_rank_users WHERE name LIKE ? AND reference = ?";
const players: IPlayer[] = await this._mysqlProvider.query<IPlayer[]>(query, [`%${name}%`, groupReference]);

if (!players?.length) {
Expand Down
4 changes: 2 additions & 2 deletions external/web/src/getRank.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getPlayers() {

$offset = ($page - 1) * PLAYERS_PER_PAGE;

$sth = $dbh->prepare('SELECT * FROM verygames_rank_users WHERE points >= :minPoints AND reference = :reference ORDER BY points DESC LIMIT :offset, :limit');
$sth = $dbh->prepare('SELECT * FROM cs2_rank_users WHERE points >= :minPoints AND reference = :reference ORDER BY points DESC LIMIT :offset, :limit');
$sth->bindValue(':reference', $reference, PDO::PARAM_STR);
$sth->bindValue(':minPoints', MINIMUM_POINTS, PDO::PARAM_INT);
$sth->bindValue(':offset', $offset, PDO::PARAM_INT);
Expand Down Expand Up @@ -100,7 +100,7 @@ function getTotalPage() {

$offset = ($page - 1) * PLAYERS_PER_PAGE;

$sth = $dbh->prepare('SELECT CEIL(COUNT(*) / :itemsPerPage) as result FROM verygames_rank_users WHERE reference = :reference');
$sth = $dbh->prepare('SELECT CEIL(COUNT(*) / :itemsPerPage) as result FROM cs2_rank_users WHERE reference = :reference');
$sth->bindValue(':reference', $reference, PDO::PARAM_INT);
$sth->bindValue(':itemsPerPage', PLAYERS_PER_PAGE, PDO::PARAM_INT);
$sth->execute();
Expand Down
2 changes: 1 addition & 1 deletion external/web/src/getReferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getReferences() {

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sth = $dbh->prepare('SELECT id, reference, custom_name FROM verygames_rank_references');
$sth = $dbh->prepare('SELECT id, reference, custom_name FROM cs2_rank_references');
$sth->execute();

$rows = $sth->fetchAll();
Expand Down
File renamed without changes.
16 changes: 1 addition & 15 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,8 @@ This is a rank plugin designed to work with Metamod, incorporating a MySQL datab
# Want to contribute ?
- Just make a PR :)

#### Beta Fix
- [x] Refactor player class
- [x] Remove points lost when disconnecting or changing teams for Spectator
- [x] Add a config `enable_ffa` to disable the points lost during a teamkill (it's better than used a game mode detection)
- [ ] Fix escape string for player's name ?
- [x] Add a map reference
- [x] Add rank per map
- [x] Add top per map
- [x] Add sessions per map
- [x] Add reset rank per map
- [x] WEB: Fix date view
- [x] WEB: Fix CT kills percentage
#### TODO
- [ ] WEB : Manage top per map
- [x] DISCORD : Manage rank per map
- [x] DISCORD : Manage top per map
- [x] DISCORD : Add /rankmaps to display the available map

#### Feature
- Rank
Expand Down
16 changes: 8 additions & 8 deletions src/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
#include "networksystem/inetworkserializer.h"
#include <iserver.h>

#define DEBUG_PREFIX "VG Rank - "
#define PREFIX " {RED}[VG Rank] "
#define PLUGIN_NAME "VeryGames Rank"
#define PLUGIN_NAME_DEBUG "DEBUG - VeryGames Rank"
#define DEBUG_PREFIX "CS2 Rank - "
#define PREFIX " {RED}[CS2 Rank] "
#define PLUGIN_NAME "CS2 Rank"
#define PLUGIN_NAME_DEBUG "DEBUG - CS2 Rank"
#define PLUGIN_DESCRIPTION "Rank system"

#define GAMEDATA_PATH "addons/vgrank/gamedata/vgrank.games.txt"
#define POINTS_CONFIG_PATH "addons/vgrank/configs/points.cfg"
#define PHRASES_CONFIG_PATH "addons/vgrank/configs/phrases.cfg"
#define CORE_CONFIG_PATH "addons/vgrank/configs/core.cfg"
#define GAMEDATA_PATH "addons/cs2rank/gamedata/cs2rank.games.txt"
#define POINTS_CONFIG_PATH "addons/cs2rank/configs/points.cfg"
#define PHRASES_CONFIG_PATH "addons/cs2rank/configs/phrases.cfg"
#define CORE_CONFIG_PATH "addons/cs2rank/configs/core.cfg"

#define MAX_QUERY_SIZES 8064

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ const char *CPlugin::GetLicense()

const char *CPlugin::GetVersion()
{
return "a1.0";
return "b2.0";
}

const char *CPlugin::GetDate()
Expand Down
Loading

0 comments on commit b538bd2

Please sign in to comment.