Mercurial > hg > openttd
changeset 8790:5ef0059ccfc0 draft
(svn r12501) -Codechange: split signs.h.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 31 Mar 2008 07:25:49 +0000 |
parents | 3c4f7c030d5e |
children | 2693434c1f4c |
files | projects/openttd_vs80.vcproj projects/openttd_vs90.vcproj source.list src/main_gui.cpp src/network/network_internal.h src/oldloader.cpp src/openttd.cpp src/signs.cpp src/signs.h src/signs_base.h src/signs_func.h src/signs_gui.cpp src/signs_type.h src/strings.cpp src/terraform_gui.cpp src/viewport.cpp |
diffstat | 16 files changed, 126 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -1320,7 +1320,15 @@ > </File> <File - RelativePath=".\..\src\signs.h" + RelativePath=".\..\src\signs_base.h" + > + </File> + <File + RelativePath=".\..\src\signs_func.h" + > + </File> + <File + RelativePath=".\..\src\signs_type.h" > </File> <File
--- a/projects/openttd_vs90.vcproj +++ b/projects/openttd_vs90.vcproj @@ -1317,7 +1317,15 @@ > </File> <File - RelativePath=".\..\src\signs.h" + RelativePath=".\..\src\signs_base.h" + > + </File> + <File + RelativePath=".\..\src\signs_func.h" + > + </File> + <File + RelativePath=".\..\src\signs_type.h" > </File> <File
--- a/source.list +++ b/source.list @@ -238,7 +238,9 @@ ship.h signal_func.h signal_type.h -signs.h +signs_base.h +signs_func.h +signs_type.h slope_func.h slope_type.h sound_func.h
--- 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"
--- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -45,7 +45,7 @@ /** 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
--- 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"
--- 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"
--- 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"
deleted file mode 100644 --- 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<Sign, SignID, &_Sign_pool> { - 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 */
new file mode 100644 --- /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<Sign, SignID, &_Sign_pool> { + 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 */
new file mode 100644 --- /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 */
--- 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"
new file mode 100644 --- /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 */
--- 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"