Quote:
Originally Posted by konichiwa
I would like to suggest something similar to Proposal #3 but in a different approach, by introducing a generic reference type instead of limiting them to array only.
Code:
// & as the reference operator
new &g_Players[];
MakePlayerList() {
new players[];
for (new i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i))
players += [i];
}
// players (dynamic array) had to be allocated in heap and garbage collected
// g_players (references) can be locally scoped
g_Players = players;
}
This would have few interesting implications.
Code:
// foreach loop with in-place update possible
foreach (new i:&p in players) {
if (IsClientTrolling(i)) {
KickClient(i)
p = 0
}
}
dv would most likely kill me for giving him more questions than answers though.
|
I like that idea very very much, especially the foreach with in-place update.