Skip to content

Commit 21e0d41

Browse files
committed
Update Traitors challenge: Added a new convar to insert player slot index before player name. This will help to specify players.
1 parent 4780926 commit 21e0d41

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

reactivedrop/content/traitors_challenge/resource/challenges/traitors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"allowed_mode" "coop"
55
"convars" {
66
"rd_player_bots_allowed" "0"
7+
"cl_add_index_to_name" "1"
8+
"rd_draw_restricted_rectangles_coop" "1"
79

810
"rd_auto_fast_restart" "1"
911
"rd_ready_mark_override" "1"

reactivedrop/content/traitors_challenge/scripts/vscripts/challenge_traitors.nut

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ function DebugKillAliens(interval = 1) {
182182
hEntitiy.TakeDamage(99, DAMAGE_TYPE.DMG_FALL, null);
183183
}
184184
}
185-
186185
}
187186

188187
function DropWeapon() {
@@ -308,7 +307,6 @@ function DropWeapon() {
308307
}
309308
}
310309
}
311-
312310
}
313311

314312
function FixT75(interval = 1) {
@@ -319,7 +317,6 @@ function FixT75(interval = 1) {
319317
while (hT75 = Entities.FindByClassname(hT75, "asw_t75")) {
320318
hT75.__KeyValueFromInt("solid", 0);
321319
}
322-
323320
}
324321

325322
function RefreshSkillMenu(interval = 1) {
@@ -949,15 +946,6 @@ function DisplayGameInstructions() {
949946
}
950947

951948
function InitializeMarineList() {
952-
local i = 1;
953-
local hPlayer = null;
954-
while ((hPlayer = Entities.FindByClassname(hPlayer, "player")) != null) {
955-
NetProps.SetPropString(hPlayer, "m_szNetname", i.tostring() +
956-
"-" + hPlayer.GetPlayerName());
957-
i++;
958-
}
959-
960-
961949
// 遍历士兵,同时移除机器人(防止有人在进入游戏瞬间掉线。这个概率很低,但需要排除)
962950
local hMarine = null;
963951
while ((hMarine = Entities.FindByClassname(hMarine, "asw_marine")) != null) {

src/game/client/c_playerresource.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const float PLAYER_RESOURCE_THINK_INTERVAL = 0.2f;
2323
#define PLAYER_DEBUG_NAME "WWWWWWWWWWWWWWW"
2424

2525
ConVar cl_names_debug( "cl_names_debug", "0", FCVAR_DEVELOPMENTONLY );
26-
26+
ConVar cl_add_index_to_name("cl_add_index_to_name", "0", FCVAR_REPLICATED);
2727

2828
void RecvProxy_ChangedTeam( const CRecvProxyData *pData, void *pStruct, void *pOut )
2929
{
@@ -143,6 +143,7 @@ void C_PlayerResource::OnDataChanged(DataUpdateType_t updateType)
143143

144144
void C_PlayerResource::UpdatePlayerName( int slot )
145145
{
146+
static char szNameTemp[MAX_PLAYERS + 1][MAX_PLAYER_NAME_LENGTH];
146147
if ( slot < 1 || slot > MAX_PLAYERS )
147148
{
148149
Error( "UpdatePlayerName with bogus slot %d\n", slot );
@@ -155,11 +156,20 @@ void C_PlayerResource::UpdatePlayerName( int slot )
155156
{
156157
g_RDTextFiltering.FilterTextName( sPlayerInfo.name, g_RDTextFiltering.GetClientSteamID( slot ) );
157158
pchPlayerName = sPlayerInfo.name;
159+
V_snprintf(szNameTemp[slot], MAX_PLAYER_NAME_LENGTH - 1, "%d-%s", slot, pchPlayerName);
158160
}
159-
160-
if ( !m_szName[slot] || Q_stricmp( m_szName[slot], pchPlayerName ) )
161+
if (cl_add_index_to_name.GetBool()) {
162+
if (!m_szName[slot] || Q_stricmp(m_szName[slot], szNameTemp[slot]))
163+
{
164+
m_szName[slot] = AllocPooledString(szNameTemp[slot]);
165+
}
166+
}
167+
else
161168
{
162-
m_szName[slot] = AllocPooledString( pchPlayerName );
169+
if (!m_szName[slot] || Q_stricmp(m_szName[slot], pchPlayerName))
170+
{
171+
m_szName[slot] = AllocPooledString(pchPlayerName);
172+
}
163173
}
164174
}
165175

0 commit comments

Comments
 (0)