Skip to content

Commit 95a6cee

Browse files
committed
SERVER: Introduce FTE reimplementation of Vril achievement builtin; early-out achievements
1 parent 889d831 commit 95a6cee

4 files changed

Lines changed: 75 additions & 29 deletions

File tree

progs/ssqc.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ defs/standard.qc
2020
#endif
2121
shared_defs.qc
2222
defs/custom.qc
23+
fte_builtins.qc
2324
map_rotation.qc
2425
utilities/sound_helper.qc
2526
weapon_stats.qc

source/server/clientfuncs.qc

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ void(string chaptertitle, string location, string date, string person, entity wh
484484

485485
void (float achievement_id, optional entity who) GiveAchievement =
486486
{
487+
return;
488+
489+
// Achievements have been removed, adding back TBD
490+
#if 0
487491
#ifndef FTE
488492

489493
// temp
@@ -495,41 +499,16 @@ void (float achievement_id, optional entity who) GiveAchievement =
495499
// this is an achievement specific to an individual
496500
if ((who && who != world) || player_count == 1) {
497501
if (player_count == 1) who = find(world, classname, "player");
498-
499-
#ifndef FTE
500-
501-
achievement(who, achievement_id);
502-
503-
#else
504-
505-
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
506-
WriteByte(MSG_MULTICAST, CSQC_EVENT_GIVEACHIEVEMENT);
507-
WriteByte(MSG_MULTICAST, achievement_id);
508-
msg_entity = who;
509-
multicast('0 0 0', MULTICAST_ONE);
510-
511-
#endif // FTE
512-
502+
nzp_achievement(who, achievement_id);
513503
} else {
514-
515-
#ifndef FTE
516-
517504
entity players;
518505
players = find(world, classname, "player");
519506
while(players != world) {
520-
achievement(players, achievement_id);
507+
nzp_achievement(players, achievement_id);
521508
players = find(players, classname, "player");
522509
}
523-
524-
#else
525-
526-
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
527-
WriteByte(MSG_MULTICAST, CSQC_EVENT_GIVEACHIEVEMENT);
528-
WriteByte(MSG_MULTICAST, achievement_id);
529-
multicast('0 0 0', MULTICAST_ALL);
530-
531-
#endif // FTE
532510
}
511+
#endif
533512
}
534513

535514
#ifdef FTE

source/server/defs/standard.qc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ string (string s)
233233
string (string s) precache_sound2 = #76; // registered version only
234234
string (string s) precache_file2 = #77; // registered version only
235235
void (entity e) setspawnparms = #78; // set parm1... to the
236-
void (entity plr, float achievement) achievement = #79;
236+
void (entity client, float achievement_id) nzp_achievement = #79;
237237
float (string s) stof = #81; // 2001-09-20 QuakeC string manipulation by FrikaC
238238
//void (vector where, float set) multicast = #82;
239239
vector (entity what) Get_Waypoint_Near = #83;

source/server/fte_builtins.qc

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
server/fte_builtins.qc
3+
4+
FTE Implementation of Vril-Engine prog builtins
5+
6+
Copyright (C) 2021-2025 NZ:P Team
7+
8+
This program is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU General Public License
10+
as published by the Free Software Foundation; either version 2
11+
of the License, or (at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16+
17+
See the GNU General Public License for more details.
18+
19+
You should have received a copy of the GNU General Public License
20+
along with this program; if not, write to:
21+
22+
Free Software Foundation, Inc.
23+
59 Temple Place - Suite 330
24+
Boston, MA 02111-1307, USA
25+
26+
*/
27+
#ifdef FTE
28+
29+
//
30+
// NUM_FOR_EDICT(edict)
31+
// Accurate reimplementation of Vril
32+
// NUM_FOR_EDICT with edict_num acting
33+
// as a guard.
34+
//
35+
float NUM_FOR_EDICT(entity edict)
36+
{
37+
float entnum = num_for_edict(edict);
38+
edict_num(entnum);
39+
40+
return entnum;
41+
}
42+
43+
//
44+
// nzp_achievement(client, achievement_id)
45+
// Awards achievement by sending approval to client.
46+
//
47+
void(entity client, float achievement_id) nzp_achievement =
48+
{
49+
float entnum;
50+
entnum = NUM_FOR_EDICT(client);
51+
52+
if (entnum < 1 || entnum > cvar("maxclients")) {
53+
if (cvar("developer")) {
54+
print("tried to unlock ach to a non-client\n");
55+
return;
56+
}
57+
}
58+
59+
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
60+
WriteByte(MSG_MULTICAST, CSQC_EVENT_GIVEACHIEVEMENT);
61+
WriteByte(MSG_MULTICAST, achievement_id);
62+
msg_entity = client;
63+
multicast('0 0 0', MULTICAST_ONE);
64+
};
65+
66+
#endif // FTE

0 commit comments

Comments
 (0)