Skip to content

Commit 5bc1f62

Browse files
committed
SERVER: Cleanup code
1 parent 8c52831 commit 5bc1f62

1 file changed

Lines changed: 38 additions & 93 deletions

File tree

source/server/gamemodes/lockdown.qc

Lines changed: 38 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -28,99 +28,44 @@
2828
float lock_ran_post_init_logic;
2929
float lock_ran_endgame;
3030
float lock_last_perk_shuffle_round;
31+
entity lock_perks[32];
32+
vector lock_positions[32];
33+
vector lock_angs[32];
3134

32-
void() Gamemode_Lockdown_RandomizePerkLocations =
35+
float(float count, string cvar) Gamemode_Lockdown_CollectPerks =
3336
{
34-
entity perks[32];
35-
vector positions[32];
36-
vector angs[32];
37-
38-
float count;
39-
count = 0;
40-
4137
entity e;
4238

43-
// Collect all perk machines
44-
e = find(world, classname, "perk_revive");
45-
while (e != world) {
46-
perks[count] = e;
47-
positions[count] = e.origin;
48-
angs[count] = e.angles;
49-
count = count + 1;
50-
e = find(e, classname, "perk_revive");
51-
}
52-
53-
e = find(world, classname, "perk_juggernog");
39+
e = find(world, classname, cvar);
5440
while (e != world) {
55-
perks[count] = e;
56-
positions[count] = e.origin;
57-
angs[count] = e.angles;
41+
lock_perks[count] = e;
42+
lock_positions[count] = e.origin;
43+
lock_angs[count] = e.angles;
5844
count = count + 1;
59-
e = find(e, classname, "perk_juggernog");
60-
}
61-
62-
e = find(world, classname, "perk_speed");
63-
while (e != world) {
64-
perks[count] = e;
65-
positions[count] = e.origin;
66-
angs[count] = e.angles;
67-
count = count + 1;
68-
e = find(e, classname, "perk_speed");
69-
}
7045

71-
e = find(world, classname, "perk_double");
72-
while (e != world) {
73-
perks[count] = e;
74-
positions[count] = e.origin;
75-
angs[count] = e.angles;
76-
count = count + 1;
77-
e = find(e, classname, "perk_double");
78-
}
79-
80-
e = find(world, classname, "perk_flopper");
81-
while (e != world) {
82-
perks[count] = e;
83-
positions[count] = e.origin;
84-
angs[count] = e.angles;
85-
count = count + 1;
86-
e = find(e, classname, "perk_flopper");
46+
e = find(e, classname, cvar);
8747
}
8848

89-
e = find(world, classname, "perk_staminup");
90-
while (e != world) {
91-
perks[count] = e;
92-
positions[count] = e.origin;
93-
angs[count] = e.angles;
94-
count = count + 1;
95-
e = find(e, classname, "perk_staminup");
96-
}
49+
return count;
50+
};
9751

98-
e = find(world, classname, "perk_deadshot");
99-
while (e != world) {
100-
perks[count] = e;
101-
positions[count] = e.origin;
102-
angs[count] = e.angles;
103-
count = count + 1;
104-
e = find(e, classname, "perk_deadshot");
105-
}
52+
void() Gamemode_Lockdown_RandomizePerkLocations =
53+
{
54+
float count;
55+
count = 0;
10656

107-
e = find(world, classname, "perk_mule");
108-
while (e != world) {
109-
perks[count] = e;
110-
positions[count] = e.origin;
111-
angs[count] = e.angles;
112-
count = count + 1;
113-
e = find(e, classname, "perk_mule");
114-
}
57+
entity e;
11558

116-
e = find(world, classname, "perk_pap");
117-
while (e != world) {
118-
perks[count] = e;
119-
positions[count] = e.origin;
120-
angs[count] = e.angles;
121-
count = count + 1;
122-
e = find(e, classname, "perk_pap");
123-
}
59+
// Collect all perk machines
60+
count = Gamemode_Lockdown_CollectPerks(count, "perk_revive");
61+
count = Gamemode_Lockdown_CollectPerks(count, "perk_juggernog");
62+
count = Gamemode_Lockdown_CollectPerks(count, "perk_speed");
63+
count = Gamemode_Lockdown_CollectPerks(count, "perk_double");
64+
count = Gamemode_Lockdown_CollectPerks(count, "perk_flopper");
65+
count = Gamemode_Lockdown_CollectPerks(count, "perk_staminup");
66+
count = Gamemode_Lockdown_CollectPerks(count, "perk_deadshot");
67+
count = Gamemode_Lockdown_CollectPerks(count, "perk_mule");
68+
count = Gamemode_Lockdown_CollectPerks(count, "perk_pap");
12469

12570
// Shuffle positions of all perks
12671
float i;
@@ -129,22 +74,22 @@ void() Gamemode_Lockdown_RandomizePerkLocations =
12974
j = floor(random() * (i + 1));
13075

13176
vector tmp_v;
132-
tmp_v = positions[i];
133-
positions[i] = positions[j];
134-
positions[j] = tmp_v;
77+
tmp_v = lock_positions[i];
78+
lock_positions[i] = lock_positions[j];
79+
lock_positions[j] = tmp_v;
13580

136-
tmp_v = angs[i];
137-
angs[i] = angs[j];
138-
angs[j] = tmp_v;
81+
tmp_v = lock_angs[i];
82+
lock_angs[i] = lock_angs[j];
83+
lock_angs[j] = tmp_v;
13984
}
14085

14186
// Apply shuffled positions
14287
for (i = 0; i < count; i = i + 1) {
14388
entity p;
144-
p = perks[i];
89+
p = lock_perks[i];
14590

146-
setorigin(p, positions[i]);
147-
p.angles = angs[i];
91+
setorigin(p, lock_positions[i]);
92+
p.angles = lock_angs[i];
14893
p.oldorigin = p.origin;
14994

15095
// Fix Pack-a-Punch attachments or they'll
@@ -191,9 +136,9 @@ void() Gamemode_Lockdown_RandomizePerkLocations =
191136
p.box2 = tempv;
192137
}
193138

194-
setorigin(perks[i], positions[i]);
195-
perks[i].angles = angs[i];
196-
perks[i].oldorigin = perks[i].origin;
139+
setorigin(lock_perks[i], lock_positions[i]);
140+
lock_perks[i].angles = lock_angs[i];
141+
lock_perks[i].oldorigin = lock_perks[i].origin;
197142
}
198143
}
199144

0 commit comments

Comments
 (0)