diff options
author | truelight <truelight@openttd.org> | 2006-08-22 15:33:35 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2006-08-22 15:33:35 +0000 |
commit | 0461d896123b918b492a3d16439bb46b041528cd (patch) | |
tree | 618708068f10739a382af83313db9c96b4744ef5 /signs.c | |
parent | 4c2abf1de53e28a5c3c6c6920efabc4653693c4c (diff) | |
download | openttd-0461d896123b918b492a3d16439bb46b041528cd.tar.xz |
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
-Codechange: use IsValidXXX where ever possible
Note: both changes to prepare for new pool system, which needs those changes.
For every pool there are 2 ugly lines, which will be removed when done
implementing new pool system.
Based on FS#13 by blathijs, partly implemented.
Diffstat (limited to 'signs.c')
-rw-r--r-- | signs.c | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -25,8 +25,9 @@ static void SignPoolNewBlock(uint start_item) { SignStruct *ss; - FOR_ALL_SIGNS_FROM(ss, start_item) - ss->index = start_item++; + /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. + * TODO - This is just a temporary stage, this will be removed. */ + for (ss = GetSign(start_item); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) ss->index = start_item++; } /* Initialize the sign-pool */ @@ -53,9 +54,7 @@ void UpdateAllSignVirtCoords(void) { SignStruct *ss; - FOR_ALL_SIGNS(ss) - if (ss->str != 0) - UpdateSignVirtCoords(ss); + FOR_ALL_SIGNS(ss) UpdateSignVirtCoords(ss); } @@ -83,8 +82,11 @@ static void MarkSignDirty(SignStruct *ss) static SignStruct *AllocateSign(void) { SignStruct *ss; - FOR_ALL_SIGNS(ss) { - if (ss->str == 0) { + + /* We don't use FOR_ALL here, because FOR_ALL skips invalid items. + * TODO - This is just a temporary stage, this will be removed. */ + for (ss = GetSign(0); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) { + if (!IsValidSign(ss)) { uint index = ss->index; memset(ss, 0, sizeof(SignStruct)); @@ -246,11 +248,8 @@ static void Save_SIGN(void) SignStruct *ss; FOR_ALL_SIGNS(ss) { - /* Don't save empty signs */ - if (ss->str != 0) { - SlSetArrayIndex(ss->index); - SlObject(ss, _sign_desc); - } + SlSetArrayIndex(ss->index); + SlObject(ss, _sign_desc); } } |