From a0895d57fa4cc30e49bef6a689b1a73cf4c3d02a Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 31 Mar 2008 07:25:49 +0000 Subject: (svn r12501) -Codechange: split signs.h. --- src/main_gui.cpp | 2 +- src/network/network_internal.h | 2 +- src/oldloader.cpp | 2 +- src/openttd.cpp | 3 +- src/signs.cpp | 3 +- src/signs.h | 74 ------------------------------------------ src/signs_base.h | 56 ++++++++++++++++++++++++++++++++ src/signs_func.h | 21 ++++++++++++ src/signs_gui.cpp | 3 +- src/signs_type.h | 15 +++++++++ src/strings.cpp | 2 +- src/terraform_gui.cpp | 2 +- src/viewport.cpp | 3 +- 13 files changed, 105 insertions(+), 83 deletions(-) delete mode 100644 src/signs.h create mode 100644 src/signs_base.h create mode 100644 src/signs_func.h create mode 100644 src/signs_type.h (limited to 'src') diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 3bf1ed798..e43bfd7ba 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -16,7 +16,7 @@ #include "news_func.h" #include "town.h" #include "console.h" -#include "signs.h" +#include "signs_func.h" #include "waypoint.h" #include "variables.h" #include "train.h" diff --git a/src/network/network_internal.h b/src/network/network_internal.h index ae4c56c5a..f44d36133 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -45,7 +45,7 @@ enum { /** How many vehicle/station types we put over the network */ NETWORK_VEHICLE_TYPES = 5, NETWORK_STATION_TYPES = 5, -} +}; struct NetworkPlayerInfo { char company_name[NETWORK_NAME_LENGTH]; ///< Company name diff --git a/src/oldloader.cpp b/src/oldloader.cpp index a5bf88f71..a84cb66fe 100644 --- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -13,7 +13,7 @@ #include "roadveh.h" #include "ship.h" #include "train.h" -#include "signs.h" +#include "signs_base.h" #include "debug.h" #include "depot.h" #include "newgrf_config.h" diff --git a/src/openttd.cpp b/src/openttd.cpp index 81cfef80d..a82636b6f 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -44,7 +44,8 @@ #include "console.h" #include "screenshot.h" #include "network/network.h" -#include "signs.h" +#include "signs_base.h" +#include "signs_func.h" #include "depot.h" #include "waypoint.h" #include "ai/ai.h" diff --git a/src/signs.cpp b/src/signs.cpp index 7444bf024..4b3146b22 100644 --- a/src/signs.cpp +++ b/src/signs.cpp @@ -6,7 +6,8 @@ #include "openttd.h" #include "landscape.h" #include "player_func.h" -#include "signs.h" +#include "signs_base.h" +#include "signs_func.h" #include "saveload.h" #include "command_func.h" #include "variables.h" diff --git a/src/signs.h b/src/signs.h deleted file mode 100644 index ebf32f243..000000000 --- a/src/signs.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $Id$ */ - -/** @file signs.h */ - -#ifndef SIGNS_H -#define SIGNS_H - -#include "oldpool.h" - -typedef uint16 SignID; -struct Sign; -DECLARE_OLD_POOL(Sign, Sign, 2, 16000) - -struct Sign : PoolItem { - char *name; - ViewportSign sign; - int32 x; - int32 y; - byte z; - PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. - - /** - * Creates a new sign - */ - Sign(PlayerID owner = INVALID_PLAYER); - - /** Destroy the sign */ - ~Sign(); - - inline bool IsValid() const { return this->owner != INVALID_PLAYER; } -}; - -enum { - INVALID_SIGN = 0xFFFF, -}; - -extern SignID _new_sign_id; - - -static inline SignID GetMaxSignIndex() -{ - /* TODO - This isn't the real content of the function, but - * with the new pool-system this will be replaced with one that - * _really_ returns the highest index. Now it just returns - * the next safe value we are sure about everything is below. - */ - return GetSignPoolSize() - 1; -} - -static inline uint GetNumSigns() -{ - extern uint _total_signs; - return _total_signs; -} - -static inline bool IsValidSignID(uint index) -{ - return index < GetSignPoolSize() && GetSign(index)->IsValid(); -} - -#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? GetSign(ss->index + 1U) : NULL) if (ss->IsValid()) -#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) - -extern bool _sign_sort_dirty; - -void UpdateAllSignVirtCoords(); -void PlaceProc_Sign(TileIndex tile); - -/* signs_gui.cpp */ -void ShowRenameSignWindow(const Sign *si); - -void ShowSignList(); - -#endif /* SIGNS_H */ diff --git a/src/signs_base.h b/src/signs_base.h new file mode 100644 index 000000000..3fd945b5a --- /dev/null +++ b/src/signs_base.h @@ -0,0 +1,56 @@ +/* $Id$ */ + +/** @file signs_base.h Base class for signs. */ + +#ifndef SIGNS_BASE_H +#define SIGNS_BASE_H + +#include "signs_type.h" +#include "oldpool.h" + +DECLARE_OLD_POOL(Sign, Sign, 2, 16000) + +struct Sign : PoolItem { + char *name; + ViewportSign sign; + int32 x; + int32 y; + byte z; + PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. + + /** + * Creates a new sign + */ + Sign(PlayerID owner = INVALID_PLAYER); + + /** Destroy the sign */ + ~Sign(); + + inline bool IsValid() const { return this->owner != INVALID_PLAYER; } +}; + +static inline SignID GetMaxSignIndex() +{ + /* TODO - This isn't the real content of the function, but + * with the new pool-system this will be replaced with one that + * _really_ returns the highest index. Now it just returns + * the next safe value we are sure about everything is below. + */ + return GetSignPoolSize() - 1; +} + +static inline uint GetNumSigns() +{ + extern uint _total_signs; + return _total_signs; +} + +static inline bool IsValidSignID(uint index) +{ + return index < GetSignPoolSize() && GetSign(index)->IsValid(); +} + +#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? GetSign(ss->index + 1U) : NULL) if (ss->IsValid()) +#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) + +#endif /* SIGNS_BASE_H */ diff --git a/src/signs_func.h b/src/signs_func.h new file mode 100644 index 000000000..5a38ba748 --- /dev/null +++ b/src/signs_func.h @@ -0,0 +1,21 @@ +/* $Id$ */ + +/** @file signs_func.h Functions related to signs. */ + +#ifndef SIGNS_FUNC_H +#define SIGNS_FUNC_H + +#include "signs_type.h" + +extern SignID _new_sign_id; +extern bool _sign_sort_dirty; + +void UpdateAllSignVirtCoords(); +void PlaceProc_Sign(TileIndex tile); + +/* signs_gui.cpp */ +void ShowRenameSignWindow(const Sign *si); + +void ShowSignList(); + +#endif /* SIGNS_FUNC_H */ diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index ce533954c..2e01f260a 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -8,7 +8,8 @@ #include "textbuf_gui.h" #include "window_gui.h" #include "player_gui.h" -#include "signs.h" +#include "signs_base.h" +#include "signs_func.h" #include "debug.h" #include "variables.h" #include "command_func.h" diff --git a/src/signs_type.h b/src/signs_type.h new file mode 100644 index 000000000..7f1dc5f4f --- /dev/null +++ b/src/signs_type.h @@ -0,0 +1,15 @@ +/* $Id$ */ + +/** @file signs_type.h Types related to signs */ + +#ifndef SIGNS_TYPE_H +#define SIGNS_TYPE_H + +typedef uint16 SignID; +struct Sign; + +enum { + INVALID_SIGN = 0xFFFF, +}; + +#endif /* SIGNS_TYPE_H */ diff --git a/src/strings.cpp b/src/strings.cpp index 62e822438..2fcb7055c 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -20,7 +20,7 @@ #include "group.h" #include "debug.h" #include "newgrf_townname.h" -#include "signs.h" +#include "signs_base.h" #include "newgrf_engine.h" #include "spritecache.h" #include "fontcache.h" diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 935f39afc..a215bd475 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -13,7 +13,7 @@ #include "viewport_func.h" #include "gfx_func.h" #include "command_func.h" -#include "signs.h" +#include "signs_func.h" #include "variables.h" #include "functions.h" #include "sound_func.h" diff --git a/src/viewport.cpp b/src/viewport.cpp index 96e8dff88..659834fd1 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -12,7 +12,8 @@ #include "viewport_func.h" #include "station_base.h" #include "town.h" -#include "signs.h" +#include "signs_base.h" +#include "signs_func.h" #include "waypoint.h" #include "variables.h" #include "train.h" -- cgit v1.2.3-70-g09d2