Skip to content

Commit ec294f5

Browse files
committed
Refactor
1 parent bb66929 commit ec294f5

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

ssqc/client.qc

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,6 +3147,21 @@ void () UpdateAllClientsTeamScores = {
31473147
}
31483148
}
31493149

3150+
void (entity pov, entity target) SetSkinInfoFor = {
3151+
local float target_idx = target.colormap - 1;
3152+
local string color = TeamFortress_TeamGetColorFor(pov, target.team_no);
3153+
3154+
msg_entity = pov;
3155+
WriteByte(MSG_ONE, SVC_SETINFO);
3156+
WriteByte(MSG_ONE, target_idx);
3157+
WriteString(MSG_ONE, "topcolor");
3158+
WriteString(MSG_ONE, color);
3159+
WriteByte(MSG_ONE, SVC_SETINFO);
3160+
WriteByte(MSG_ONE, target_idx);
3161+
WriteString(MSG_ONE, "bottomcolor");
3162+
WriteString(MSG_ONE, color);
3163+
}
3164+
31503165
void () ClientConnect = {
31513166
if (!infokeyf(self,INFOKEY_P_CSQCACTIVE)) {
31523167
sprint(self, PRINT_HIGH, "FTE/CSQC is required for this server, please download the latest client package at www.fortressone.org\n");
@@ -3207,21 +3222,11 @@ void () ClientConnect = {
32073222
UpdateClientPrematch(self, !cb_prematch);
32083223
UpdateClient_VoteMap_AddAll(self);
32093224

3210-
local string color;
3225+
// Set skin colours
32113226
local entity te = find(world, classname, "player");
32123227
while (te != world) {
32133228
if (te != self) {
3214-
msg_entity = self;
3215-
color = TeamFortress_TeamGetColorFor(self, te.team_no);
3216-
3217-
WriteByte(MSG_ONE, SVC_SETINFO);
3218-
WriteByte(MSG_ONE, te.colormap-1); // ???? Copied from spy.qc
3219-
WriteString(MSG_ONE, "topcolor");
3220-
WriteString(MSG_ONE, color);
3221-
WriteByte(MSG_ONE, SVC_SETINFO);
3222-
WriteByte(MSG_ONE, te.colormap-1); // ???? Copied from spy.qc
3223-
WriteString(MSG_ONE, "bottomcolor");
3224-
WriteString(MSG_ONE, color);
3229+
SetSkinInfoFor(self, te);
32253230
}
32263231

32273232
te = find(te, classname, "player");

ssqc/tfort.qc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,28 +1173,16 @@ string(float pc) TeamFortress_GetSkin =
11731173
return skin;
11741174
};
11751175

1176-
11771176
void (entity player) TeamFortress_SetSkinInfos = {
11781177
local string st = TeamFortress_GetSkin(player.playerclass);
11791178
local string command = sprintf("skin %s\n", st);
11801179
stuffcmd(player, command);
11811180
forceinfokey(player, "skin", st); // please fix mvd recording
11821181

1183-
local string color;
11841182
local entity te = find(world, classname, "player");
11851183
while (te != world) {
11861184
if (te != player) {
1187-
msg_entity = te;
1188-
color = TeamFortress_TeamGetColorFor(te, player.team_no);
1189-
1190-
WriteByte(MSG_ONE, SVC_SETINFO);
1191-
WriteByte(MSG_ONE, player.colormap-1); // ???? Copied from spy.qc
1192-
WriteString(MSG_ONE, "topcolor");
1193-
WriteString(MSG_ONE, color);
1194-
WriteByte(MSG_ONE, SVC_SETINFO);
1195-
WriteByte(MSG_ONE, player.colormap-1); // ???? Copied from spy.qc
1196-
WriteString(MSG_ONE, "bottomcolor");
1197-
WriteString(MSG_ONE, color);
1185+
SetSkinInfoFor(te, player);
11981186
}
11991187

12001188
te = find(te, classname, "player");

0 commit comments

Comments
 (0)