Skip to content

Commit

Permalink
Refactor loop in l4d2_queue.sp to improve readability and maintainabi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
altair-sossai committed Oct 30, 2024
1 parent 74e27ec commit ab818ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Binary file modified addons/sourcemod/plugins/optional/l4d2_queue.smx
Binary file not shown.
8 changes: 5 additions & 3 deletions addons/sourcemod/scripting/l4d2_queue.sp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ void PrintQueue(int target)
char output[512];

bool isNewGame = IsNewGame();

for (int i = 0, c = 1, position = 1; i < h_Queue.Length; i++, c = c == MAX_MESSAGE_NAMES ? 1 : c + 1)
for (int i = 0, count = 0, position = 1; i < h_Queue.Length; i++)
{
h_Queue.GetArray(i, player);

Expand All @@ -228,16 +228,18 @@ void PrintQueue(int target)
else
Format(output, sizeof(output), "%s %s%dº {default}%N", output, color, position, client);

count++;
position++;

if (c == MAX_MESSAGE_NAMES)
if (count == MAX_MESSAGE_NAMES)
{
if (target == 0)
CPrintToChatAll(output);
else
CPrintToChat(target, output);

output = "";
count = 0;
}
}

Expand Down

0 comments on commit ab818ca

Please sign in to comment.