Skip to content

Commit 4da8210

Browse files
committed
Merge branch 'master' of https://github.com/VortexQuake2/Vortex
2 parents 1306a06 + 41662e0 commit 4da8210

28 files changed

+894
-367
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Cmake script based off several sources, including cleancodequake2.
22

33
# Specify minimum version of CMake required
4-
cmake_minimum_required(VERSION 3.0)
4+
cmake_minimum_required(VERSION 3.25)
55

66
# Project name
77
project(VortexQuake2)
@@ -17,7 +17,7 @@ option(VRX_Q2PRO "Use map/gamemap differentiation (for q2pro)." TRUE)
1717
option(VRX_OLD_NOLAG "Use old NOLAG style. Not recommended." FALSE)
1818
option(VRX_OLD_VOTE "Use old vote system." FALSE)
1919

20-
set(CMAKE_C_STANDARD 99)
20+
set(CMAKE_C_STANDARD 11)
2121
set(CMAKE_C_STANDARD_REQUIRED TRUE)
2222

2323
# Source files

sql/vrx-5.7.sql

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,83 @@ create table if not exists abilities
22
(
33
char_idx int not null,
44
aindex int not null,
5-
level int null,
6-
max_level int null,
7-
hard_max int null,
8-
modifier int null,
9-
disable int null,
10-
general_skill int null,
5+
level int not null,
6+
max_level int not null,
7+
hard_max int not null,
8+
modifier int not null,
9+
disable int not null,
10+
general_skill int not null,
1111
primary key (char_idx, aindex)
1212
);
1313

14+
create table if not exists prestige
15+
(
16+
char_idx int not null,
17+
pindex int not null,
18+
param int not null,
19+
level int not null,
20+
primary key (char_idx, pindex, param)
21+
);
22+
1423
create table if not exists character_data
1524
(
1625
char_idx int not null,
17-
respawns int null,
18-
health int null,
19-
maxhealth int null,
20-
armour int null,
21-
maxarmour int null,
22-
nerfme int null,
23-
adminlevel int null,
24-
bosslevel int null,
26+
respawns int not null default 0,
27+
health int not null default 100,
28+
maxhealth int not null default 100,
29+
armour int not null default 0,
30+
maxarmour int not null default 0,
31+
nerfme int not null default 0,
32+
adminlevel int not null default 0,
33+
bosslevel int not null default 0,
34+
prestigelevel int not null default 0,
35+
prestigepoints int not null default 0,
2536
primary key (char_idx)
2637
);
2738

2839
create table if not exists ctf_stats
2940
(
3041
char_idx int not null,
31-
flag_pickups int null,
32-
flag_captures int null,
33-
flag_returns int null,
34-
flag_kills int null,
35-
offense_kills int null,
36-
defense_kills int null,
37-
assists int null,
42+
flag_pickups int not null default 0,
43+
flag_captures int not null default 0,
44+
flag_returns int not null default 0,
45+
flag_kills int not null default 0,
46+
offense_kills int not null default 0,
47+
defense_kills int not null default 0,
48+
assists int not null default 0,
3849
primary key (char_idx)
3950
);
4051

4152
create table if not exists game_stats
4253
(
4354
char_idx int not null,
44-
shots int null,
45-
shots_hit int null,
46-
frags int null,
47-
fragged int null,
48-
num_sprees int null,
49-
max_streak int null,
50-
spree_wars int null,
51-
broken_sprees int null,
52-
broken_spreewars int null,
53-
suicides int null,
54-
teleports int null,
55-
num_2fers int null,
55+
shots int not null default 0,
56+
shots_hit int not null default 0,
57+
frags int not null default 0,
58+
fragged int not null default 0,
59+
num_sprees int not null default 0,
60+
max_streak int not null default 0,
61+
spree_wars int not null default 0,
62+
broken_sprees int not null default 0,
63+
broken_spreewars int not null default 0,
64+
suicides int not null default 0,
65+
teleports int not null default 0,
66+
num_2fers int not null default 0,
5667
primary key (char_idx)
5768
);
5869

5970
create table if not exists point_data
6071
(
6172
char_idx int not null,
62-
exp int null,
63-
exptnl int null,
64-
level int null,
65-
classnum int null,
66-
skillpoints int null,
67-
credits int null,
68-
weap_points int null,
69-
resp_weapon int null,
70-
tpoints int null,
73+
exp int not null,
74+
exptnl int not null,
75+
level int not null default 0,
76+
classnum int not null default 0,
77+
skillpoints int not null default 0,
78+
credits int not null default 0,
79+
weap_points int not null default 0,
80+
resp_weapon int not null default 0,
81+
tpoints int not null default 0,
7182
primary key (char_idx)
7283
);
7384

src/characters/io/v_characterio.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ void vrx_setup_sqlite_io() {
116116
.handle_status = NULL,
117117
.character_exists = &vrx_sqlite_character_exists,
118118
.is_loading = &vrx_sqlite_isloading,
119-
.set_owner = &cdb_set_owner
119+
.set_owner = &cdb_set_owner,
120+
.type = SAVEMETHOD_SQLITE
120121
};
121122

122123
cdb_start_connection();
@@ -170,7 +171,8 @@ void vrx_setup_mysql_io() {
170171
.load_player = &vrx_mysql_load_character,
171172
.is_loading = &vrx_mysql_isloading,
172173
.handle_status = &gds_handle_status,
173-
.set_owner = &gds_queue_add_setowner
174+
.set_owner = &gds_queue_add_setowner,
175+
.type = SAVEMETHOD_MYSQL
174176
};
175177

176178
gds_connect();

src/characters/io/v_characterio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ typedef struct {
1313
qboolean (*is_loading) (edict_t* ent); // if it's already loading... don't bother calling load_player again.
1414
void (*handle_status)(edict_t* ent); // if not null, this is a multithreaded io system.
1515
void (*set_owner)(edict_t* ent, char* charname, char* mpw);
16+
int type;
1617
} char_io_t;
1718

1819
extern char_io_t vrx_char_io;

src/characters/io/v_sqlite_unidb.c

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
// *********************************
1515
// Definitions
1616
// *********************************
17-
#define TOTAL_TABLES 14
17+
#define TOTAL_TABLES 15
1818
#define TOTAL_INSERTONCE 5
19-
#define TOTAL_RESETTABLES 6
19+
#define TOTAL_RESETTABLES 7
2020

2121
void cdb_start_connection();
2222

@@ -34,15 +34,16 @@ const char* VSFU_CREATEDBQUERY[TOTAL_TABLES] =
3434
"CREATE TABLE [userdata] ( [char_idx] INTEGER,[title] CHAR(24), [playername] CHAR(64), [password] CHAR(24), [email] CHAR(64), [owner] CHAR(24), [member_since] CHAR(30), [last_played] CHAR(30), [playtime_total] INTEGER,[playingtime] INTEGER)",
3535
"CREATE TABLE [weapon_meta] ([char_idx] INTEGER,[index] INTEGER, [disable] INTEGER)",
3636
"CREATE TABLE [weapon_mods] ([char_idx] INTEGER,[weapon_index] INTEGER, [modindex] INTEGER, [level] INTEGER, [soft_max] INTEGER, [hard_max] INTEGER)",
37-
"CREATE TABLE [character_data] ([char_idx] INTEGER, [respawns] INTEGER, [health] INTEGER, [maxhealth] INTEGER, [armour] INTEGER, [maxarmour] INTEGER, [nerfme] INTEGER, [adminlevel] INTEGER, [bosslevel] INTEGER)",
37+
"CREATE TABLE [character_data] ([char_idx] INTEGER, [respawns] INTEGER, [health] INTEGER, [maxhealth] INTEGER, [armour] INTEGER, [maxarmour] INTEGER, [nerfme] INTEGER, [adminlevel] INTEGER, [bosslevel] INTEGER, [prestigelevel] INTEGER, [prestigepoints] INTEGER)",
38+
"create table [prestige](char_idx int not null, pindex int not null, param int not null, level int not null, primary key (char_idx, pindex, param))",
3839
"create table stash( char_idx int not null, lock_char_id int null, primary key (char_idx));",
3940
"create table stash_runes_meta( char_idx int not null, stash_index int not null, itemtype int null, itemlevel int null, quantity int null, untradeable int null, id char(16) null, name char(24) null, nummods int null, setcode int null, classnum int null, primary key (char_idx, stash_index));",
4041
"create table stash_runes_mods( char_idx int not null, stash_index int not null, rune_mod_index int not null, type int null, mod_index int null, value int null, [set] int null, primary key (char_idx, stash_index, rune_mod_index));"
4142
};
4243

4344
// SAVING
4445

45-
const char* CreateCharacterData = "INSERT INTO character_data VALUES (%d,0,0,0,0,0,0,0,0)";
46+
const char* CreateCharacterData = "INSERT INTO character_data VALUES (%d,0,0,0,0,0,0,0,0,0,0)";
4647
const char* CreateCtfStats = "INSERT INTO ctf_stats VALUES (%d,0,0,0,0,0,0,0)";
4748
const char* CreateGameStats = "INSERT INTO game_stats VALUES (%d,0,0,0,0,0,0,0,0,0,0,0,0)";
4849
const char* CreatePointData = "INSERT INTO point_data VALUES (%d,0,0,0,0,0,0,0,0,0)";
@@ -53,6 +54,7 @@ const char* VSFU_RESETTABLES[TOTAL_RESETTABLES] =
5354
{
5455
"DELETE FROM abilities WHERE char_idx=%d;",
5556
"DELETE FROM talents WHERE char_idx=%d;",
57+
"DELETE FROM prestige WHERE char_idx=%d;",
5658
"DELETE FROM runes_meta WHERE char_idx=%d;",
5759
"DELETE FROM runes_mods WHERE char_idx=%d;",
5860
"DELETE FROM weapon_meta WHERE char_idx=%d;",
@@ -80,7 +82,9 @@ const char* VSFU_INSERTRMOD = "INSERT INTO runes_mods VALUES (%d,%d,%d,%d,%d,%d)
8082
const char* VSFU_INSERTRMODEX = "INSERT INTO runes_mods VALUES (%d,%d,0,%d,%d,%d,%d);";
8183

8284

83-
const char* VSFU_UPDATECDATA = "UPDATE character_data SET respawns=%d, health=%d, maxhealth=%d, armour=%d, maxarmour=%d, nerfme=%d, adminlevel=%d, bosslevel=%d WHERE char_idx=%d;";
85+
const char* VSFU_UPDATECDATA = "UPDATE character_data SET respawns=%d, health=%d, maxhealth=%d, armour=%d, "
86+
"maxarmour=%d, nerfme=%d, adminlevel=%d, bosslevel=%d, prestigelevel=%d, prestigepoints=%d"
87+
" WHERE char_idx=%d;";
8488

8589
const char* VSFU_UPDATESTATS = "UPDATE game_stats SET shots=%d, shots_hit=%d, frags=%d, fragged=%d, num_sprees=%d, max_streak=%d, spree_wars=%d, broken_sprees=%d, broken_spreewars=%d, suicides=%d, teleports=%d, num_2fers=%d WHERE char_idx=%d;";
8690

@@ -326,7 +330,10 @@ qboolean cdb_save_player(edict_t* player)
326330
MAX_ARMOR(player),
327331
player->myskills.nerfme,
328332
player->myskills.administrator, // flags
329-
player->myskills.boss, id));
333+
player->myskills.boss,
334+
player->myskills.prestige.total,
335+
player->myskills.prestige.points,
336+
id));
330337

331338

332339
//*****************************
@@ -437,6 +444,34 @@ qboolean cdb_save_player(edict_t* player)
437444
player->myskills.defense_kills,
438445
player->myskills.assists, id));
439446

447+
// prestige
448+
QUERY(va("INSERT INTO prestige(char_idx, pindex, param, level) VALUES (%d, %d, %d, %d);",
449+
id, PRESTIGE_CREDITS, 0, player->myskills.prestige.creditLevel));
450+
451+
QUERY(va("INSERT INTO prestige(char_idx, pindex, param, level) VALUES (%d, %d, %d, %d);",
452+
id, PRESTIGE_ABILITY_POINTS, 0, player->myskills.prestige.abilityPoints));
453+
454+
QUERY(va("INSERT INTO prestige(char_idx, pindex, param, level) VALUES (%d, %d, %d, %d);",
455+
id, PRESTIGE_WEAPON_POINTS, 0, player->myskills.prestige.weaponPoints));
456+
457+
// softmax bump points - param is the ab index, level is the bump
458+
for (i = 0; i < MAX_ABILITIES; i++)
459+
{
460+
if (player->myskills.prestige.softmaxBump[i] > 0) {
461+
QUERY(va("INSERT INTO prestige(char_idx, pindex, param, level) VALUES (%d, %d, %d, %d);",
462+
id, PRESTIGE_SOFTMAX_BUMP, i, player->myskills.prestige.softmaxBump[i]));
463+
}
464+
}
465+
466+
// class skills - param is the ab index, level is always 0
467+
for (i = 0; i < MAX_ABILITIES; i++)
468+
{
469+
if (player->myskills.prestige.classSkill[i / 32] & (1 << (i % 32)))
470+
{
471+
QUERY(va("INSERT INTO prestige(char_idx, pindex, param, level) VALUES (%d, %d, %d, %d);",
472+
id, PRESTIGE_CLASS_SKILL, i, 0));
473+
}
474+
}
440475

441476
} // end saving
442477

@@ -749,6 +784,10 @@ qboolean cdb_load_player(edict_t* player)
749784
//boss flag
750785
player->myskills.boss = sqlite3_column_int(statement, 8);
751786

787+
// prestige
788+
player->myskills.prestige.total = sqlite3_column_int(statement, 9);
789+
player->myskills.prestige.points = sqlite3_column_int(statement, 10);
790+
752791
//*****************************
753792
//stats
754793
//*****************************
@@ -804,10 +843,42 @@ qboolean cdb_load_player(edict_t* player)
804843

805844
sqlite3_finalize(statement);
806845

846+
// prestige
847+
format = va("SELECT * FROM prestige WHERE char_idx=%d", id);
848+
849+
r = sqlite3_prepare_v2(db, format, strlen(format), &statement, NULL);
850+
while(sqlite3_step(statement) == SQLITE_ROW) {
851+
int pindex = sqlite3_column_int(statement, 1);
852+
int param = sqlite3_column_int(statement, 2);
853+
int level = sqlite3_column_int(statement, 3);
854+
855+
switch (pindex)
856+
{
857+
case PRESTIGE_CREDITS:
858+
player->myskills.prestige.creditLevel = level;
859+
break;
860+
case PRESTIGE_ABILITY_POINTS:
861+
player->myskills.prestige.abilityPoints = level;
862+
break;
863+
case PRESTIGE_WEAPON_POINTS:
864+
player->myskills.prestige.weaponPoints = level;
865+
break;
866+
case PRESTIGE_SOFTMAX_BUMP:
867+
player->myskills.prestige.softmaxBump[param] = level;
868+
break;
869+
case PRESTIGE_CLASS_SKILL:
870+
player->myskills.prestige.classSkill[param / 32] |= (1 << (param % 32));
871+
break;
872+
default: break;
873+
}
874+
}
875+
876+
877+
807878
//Apply runes
808-
V_ResetAllStats(player);
879+
vrx_runes_unapply(player);
809880
for (i = 0; i < 4; ++i)
810-
V_ApplyRune(player, &player->myskills.items[i]);
881+
vrx_runes_apply(player, &player->myskills.items[i]);
811882

812883
//Apply health
813884
if (player->myskills.current_health > MAX_HEALTH(player))

src/characters/player_points.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,14 @@ int vrx_get_credits(const edict_t *ent, float level_diff, int bonus, qboolean cl
208208
else
209209
add_credits = level_diff * (vrx_creditmult->value * vrx_pvmcreditmult->value * (CREDITS_OTHER_BASE));
210210

211-
// vrxchile v1.5 no credit cap
212-
//if (add_credits > 250)
213-
// add_credits = 250;
214-
215211
add_credits += bonus;
212+
add_credits = (int) (add_credits * PRESTIGE_CREDIT_BUFF_MULTIPLIER);
216213
return add_credits;
217214
}
218215

219216
void vrx_add_credits(edict_t *ent, int add_credits) {
217+
if (add_credits < 0)
218+
return;
220219

221220
//FIXME: remove this after allocating more space
222221
if (ent->myskills.credits + add_credits > MAX_CREDITS)

0 commit comments

Comments
 (0)