diff options
author | rubidium <rubidium@openttd.org> | 2007-07-20 18:35:33 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-20 18:35:33 +0000 |
commit | 3f983ff1f227420eed715f4333a3055e9196eeef (patch) | |
tree | 02fc298d90a4b143959d1113151503aaed2707a1 | |
parent | 7aa6d30922bf2aa253e5fe11c2e92cef7ac3e91d (diff) | |
download | openttd-3f983ff1f227420eed715f4333a3055e9196eeef.tar.xz |
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
-rw-r--r-- | src/signs.cpp | 13 | ||||
-rw-r--r-- | src/signs.h | 9 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/signs.cpp b/src/signs.cpp index 3d342ac89..f2a7cefa8 100644 --- a/src/signs.cpp +++ b/src/signs.cpp @@ -14,7 +14,8 @@ #include "command.h" #include "variables.h" -static Sign *_new_sign; +SignID _new_sign_id; +uint _total_signs; /** * Called if a new block is added to the sign-pool @@ -145,7 +146,8 @@ CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) MarkSignDirty(si); InvalidateWindow(WC_SIGN_LIST, 0); _sign_sort_dirty = true; - _new_sign = si; + _new_sign_id = si->index; + _total_signs++; } return CommandCost(); @@ -199,6 +201,7 @@ CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) InvalidateWindow(WC_SIGN_LIST, 0); _sign_sort_dirty = true; + _total_signs--; } } @@ -215,7 +218,7 @@ CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { - ShowRenameSignWindow(_new_sign); + ShowRenameSignWindow(GetSign(_new_sign_id)); ResetObjectToPlace(); } } @@ -238,6 +241,7 @@ void PlaceProc_Sign(TileIndex tile) */ void InitializeSigns() { + _total_signs = 0; CleanPool(&_Sign_pool); AddBlockToPool(&_Sign_pool); } @@ -275,6 +279,7 @@ static void Save_SIGN() */ static void Load_SIGN() { + _total_signs = 0; int index; while ((index = SlIterateArray()) != -1) { Sign *si; @@ -284,6 +289,8 @@ static void Load_SIGN() si = GetSign(index); SlObject(si, _sign_desc); + + _total_signs++; } _sign_sort_dirty = true; diff --git a/src/signs.h b/src/signs.h index 82a022abf..53551586f 100644 --- a/src/signs.h +++ b/src/signs.h @@ -18,6 +18,12 @@ struct Sign { SignID index; }; +enum { + INVALID_SIGN = 0xFFFF, +}; + +extern SignID _new_sign_id; + DECLARE_OLD_POOL(Sign, Sign, 2, 16000) static inline SignID GetMaxSignIndex() @@ -32,7 +38,8 @@ static inline SignID GetMaxSignIndex() static inline uint GetNumSigns() { - return GetSignPoolSize(); + extern uint _total_signs; + return _total_signs; } /** |