Use enumerateObjectsUsingBlock: where appropriate
FossilOrigin-Name: fd4460c7b65410b1f78e2f0df253cb5dd3cb73cff37ac75a012f8cbee1cadddd
This commit is contained in:
parent
12bf5923b0
commit
4bdb80410d
5 changed files with 29 additions and 37 deletions
|
@ -80,15 +80,13 @@ extern int democlientnum;
|
||||||
void
|
void
|
||||||
renderclients()
|
renderclients()
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
[players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) {
|
||||||
for (id player in players) {
|
|
||||||
if (player != [OFNull null] &&
|
if (player != [OFNull null] &&
|
||||||
(!demoplayback || i != democlientnum))
|
(!demoplayback || i != democlientnum))
|
||||||
renderclient(player,
|
renderclient(player,
|
||||||
isteam(player1.team, [player team]),
|
isteam(player1.team, [player team]),
|
||||||
@"monster/ogro", false, 1.0f);
|
@"monster/ogro", false, 1.0f);
|
||||||
i++;
|
}];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// creation of scoreboard pseudo-menu
|
// creation of scoreboard pseudo-menu
|
||||||
|
|
|
@ -198,22 +198,21 @@ extern int democlientnum;
|
||||||
void
|
void
|
||||||
otherplayers()
|
otherplayers()
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
[players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) {
|
||||||
for (id player in players) {
|
if (player == [OFNull null])
|
||||||
if (player != [OFNull null]) {
|
return;
|
||||||
|
|
||||||
const int lagtime = lastmillis - [player lastupdate];
|
const int lagtime = lastmillis - [player lastupdate];
|
||||||
if (lagtime > 1000 && [player state] == CS_ALIVE) {
|
if (lagtime > 1000 && [player state] == CS_ALIVE) {
|
||||||
[player setState:CS_LAGGED];
|
[player setState:CS_LAGGED];
|
||||||
i++;
|
return;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lagtime && [player state] != CS_DEAD &&
|
if (lagtime && [player state] != CS_DEAD &&
|
||||||
(!demoplayback || i != democlientnum))
|
(!demoplayback || i != democlientnum))
|
||||||
// use physics to extrapolate player position
|
// use physics to extrapolate player position
|
||||||
moveplayer(player, 2, false);
|
moveplayer(player, 2, false);
|
||||||
}
|
}];
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -429,17 +429,16 @@ serverslice(int seconds,
|
||||||
checkintermission();
|
checkintermission();
|
||||||
if (interm && seconds > interm) {
|
if (interm && seconds > interm) {
|
||||||
interm = 0;
|
interm = 0;
|
||||||
size_t i = 0;
|
[clients enumerateObjectsUsingBlock:^(
|
||||||
for (Client *client in clients) {
|
Client *client, size_t i, bool *stop) {
|
||||||
if (client.type != ST_EMPTY) {
|
if (client.type != ST_EMPTY) {
|
||||||
// ask a client to trigger map reload
|
// ask a client to trigger map reload
|
||||||
send2(true, i, SV_MAPRELOAD, 0);
|
send2(true, i, SV_MAPRELOAD, 0);
|
||||||
mapreload = true;
|
mapreload = true;
|
||||||
break;
|
*stop = true;
|
||||||
}
|
return;
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
resetserverifempty();
|
resetserverifempty();
|
||||||
|
|
|
@ -274,10 +274,10 @@ refreshservers()
|
||||||
if (lastmillis - lastinfo >= 5000)
|
if (lastmillis - lastinfo >= 5000)
|
||||||
pingservers();
|
pingservers();
|
||||||
[servers sort];
|
[servers sort];
|
||||||
int maxmenu = 16;
|
|
||||||
|
|
||||||
size_t i = 0;
|
__block int maxmenu = 16;
|
||||||
for (ServerInfo *si in servers) {
|
[servers enumerateObjectsUsingBlock:^(
|
||||||
|
ServerInfo *si, size_t i, bool *stop) {
|
||||||
if (si.address.host != ENET_HOST_ANY && si.ping != 9999) {
|
if (si.address.host != ENET_HOST_ANY && si.ping != 9999) {
|
||||||
if (si.protocol != PROTOCOL_VERSION)
|
if (si.protocol != PROTOCOL_VERSION)
|
||||||
si.full = [[OFString alloc]
|
si.full = [[OFString alloc]
|
||||||
|
@ -306,9 +306,7 @@ refreshservers()
|
||||||
|
|
||||||
if (!--maxmenu)
|
if (!--maxmenu)
|
||||||
return;
|
return;
|
||||||
|
}];
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -345,7 +345,7 @@ shootv(int gun, OFVector3D &from, OFVector3D &to, DynamicEntity *d, bool local)
|
||||||
|
|
||||||
void
|
void
|
||||||
hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at,
|
hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at,
|
||||||
OFVector3D &from, OFVector3D &to)
|
const OFVector3D &from, const OFVector3D &to)
|
||||||
{
|
{
|
||||||
hit(target, damage, d, at);
|
hit(target, damage, d, at);
|
||||||
vdist(dist, v, from, to);
|
vdist(dist, v, from, to);
|
||||||
|
@ -355,7 +355,7 @@ hitpush(int target, int damage, DynamicEntity *d, DynamicEntity *at,
|
||||||
|
|
||||||
void
|
void
|
||||||
raydamage(
|
raydamage(
|
||||||
DynamicEntity *o, OFVector3D &from, OFVector3D &to, DynamicEntity *d, int i)
|
DynamicEntity *o, const OFVector3D &from, const OFVector3D &to, DynamicEntity *d, int i)
|
||||||
{
|
{
|
||||||
if (o.state != CS_ALIVE)
|
if (o.state != CS_ALIVE)
|
||||||
return;
|
return;
|
||||||
|
@ -424,12 +424,10 @@ shoot(DynamicEntity *d, const OFVector3D &targ)
|
||||||
if (guns[d.gunselect].projspeed)
|
if (guns[d.gunselect].projspeed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size_t i = 0;
|
[players enumerateObjectsUsingBlock:^(id player, size_t i, bool *stop) {
|
||||||
for (id player in players) {
|
|
||||||
if (player != [OFNull null])
|
if (player != [OFNull null])
|
||||||
raydamage(player, from, to, d, i);
|
raydamage(player, from, to, d, i);
|
||||||
i++;
|
}];
|
||||||
}
|
|
||||||
|
|
||||||
for (DynamicEntity *monster in getmonsters())
|
for (DynamicEntity *monster in getmonsters())
|
||||||
if (monster != d)
|
if (monster != d)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue