# HG changeset patch # User rubidium # Date 1188506433 0 # Node ID 8ac3fcd8d570b5ddb8d3f34a89ae5ed48cdbe3c6 # Parent 05dd904bb306a4eb1ab1a1ca93d5481ad4aad164 (svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles. diff -r 05dd904bb306 -r 8ac3fcd8d570 src/cargopacket.h --- a/src/cargopacket.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/cargopacket.h Thu Aug 30 20:40:33 2007 +0000 @@ -43,7 +43,7 @@ * Is this a valid cargo packet ? * @return true if and only it is valid */ - bool IsValid() const { return this->count != 0; } + inline bool IsValid() const { return this->count != 0; } /** * Checks whether the cargo packet is from (exactly) the same source diff -r 05dd904bb306 -r 8ac3fcd8d570 src/depot.h --- a/src/depot.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/depot.h Thu Aug 30 20:40:33 2007 +0000 @@ -23,7 +23,7 @@ Depot(TileIndex xy = 0) : xy(xy) {} ~Depot(); - bool IsValid() const { return this->xy != 0; } + inline bool IsValid() const { return this->xy != 0; } }; static inline bool IsValidDepotID(DepotID index) diff -r 05dd904bb306 -r 8ac3fcd8d570 src/engine.h --- a/src/engine.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/engine.h Thu Aug 30 20:40:33 2007 +0000 @@ -284,7 +284,7 @@ EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {} ~EngineRenew() { this->from = INVALID_ENGINE; } - bool IsValid() const { return this->from != INVALID_ENGINE; } + inline bool IsValid() const { return this->from != INVALID_ENGINE; } }; #define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid()) diff -r 05dd904bb306 -r 8ac3fcd8d570 src/industry.h --- a/src/industry.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/industry.h Thu Aug 30 20:40:33 2007 +0000 @@ -123,7 +123,7 @@ Industry(TileIndex tile = 0) : xy(tile) {} ~Industry(); - bool IsValid() const { return this->xy != 0; } + inline bool IsValid() const { return this->xy != 0; } }; struct IndustryTileTable { diff -r 05dd904bb306 -r 8ac3fcd8d570 src/oldpool.h --- a/src/oldpool.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/oldpool.h Thu Aug 30 20:40:33 2007 +0000 @@ -225,15 +225,6 @@ { } - /** - * Is this a valid object or not? - * @return true if and only if it is valid - */ - virtual bool IsValid() const - { - return false; - } - private: /** * Allocate a pool item; possibly allocate a new block in the pool. diff -r 05dd904bb306 -r 8ac3fcd8d570 src/order.h --- a/src/order.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/order.h Thu Aug 30 20:40:33 2007 +0000 @@ -107,7 +107,11 @@ Order() : refit_cargo(CT_NO_REFIT) {} ~Order() { this->type = OT_NOTHING; } - bool IsValid() const; + /** + * Check if a Order really exists. + */ + inline bool IsValid() const { return this->type != OT_NOTHING; } + void Free(); void FreeChain(); }; @@ -140,14 +144,6 @@ return GetOrderPoolSize(); } -/** - * Check if a Order really exists. - */ -inline bool Order::IsValid() const -{ - return this->type != OT_NOTHING; -} - inline void Order::Free() { this->type = OT_NOTHING; diff -r 05dd904bb306 -r 8ac3fcd8d570 src/signs.h --- a/src/signs.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/signs.h Thu Aug 30 20:40:33 2007 +0000 @@ -26,7 +26,7 @@ /** Destroy the sign */ ~Sign(); - bool IsValid() const { return this->str != STR_NULL; } + inline bool IsValid() const { return this->str != STR_NULL; } }; enum { diff -r 05dd904bb306 -r 8ac3fcd8d570 src/station.cpp --- a/src/station.cpp Thu Aug 30 19:20:15 2007 +0000 +++ b/src/station.cpp Thu Aug 30 20:40:33 2007 +0000 @@ -237,14 +237,6 @@ return (had_vehicle_of_type & HVOT_BUOY) != 0; } -/** Determines whether a station exists - * @todo replace 0 by INVALID_TILE - */ -bool Station::IsValid() const -{ - return xy != 0; -} - /************************************************************************/ /* StationRect implementation */ @@ -437,12 +429,6 @@ xy = 0; } -/** Determines whether a RoadStop is a valid (i.e. existing) one */ -bool RoadStop::IsValid() const -{ - return xy != 0; -} - /** Checks whether there is a free bay in this road stop */ bool RoadStop::HasFreeBay() const { diff -r 05dd904bb306 -r 8ac3fcd8d570 src/station.h --- a/src/station.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/station.h Thu Aug 30 20:40:33 2007 +0000 @@ -65,7 +65,11 @@ RoadStop(TileIndex tile = 0); virtual ~RoadStop(); - bool IsValid() const; + /** + * Determines whether a road stop exists + * @return true if and only is the road stop exists + */ + inline bool IsValid() const { return this->xy != 0; } /* For accessing status */ bool HasFreeBay() const; @@ -175,7 +179,12 @@ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const; uint GetPlatformLength(TileIndex tile) const; bool IsBuoy() const; - bool IsValid() const; + + /** + * Determines whether a station exists + * @return true if and only is the station exists + */ + inline bool IsValid() const { return this->xy != 0; } }; enum StationType { diff -r 05dd904bb306 -r 8ac3fcd8d570 src/town.h --- a/src/town.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/town.h Thu Aug 30 20:40:33 2007 +0000 @@ -159,7 +159,7 @@ /** Destroy the town */ ~Town(); - bool IsValid() const { return this->xy != 0; } + inline bool IsValid() const { return this->xy != 0; } }; struct HouseSpec { diff -r 05dd904bb306 -r 8ac3fcd8d570 src/waypoint.cpp --- a/src/waypoint.cpp Thu Aug 30 19:20:15 2007 +0000 +++ b/src/waypoint.cpp Thu Aug 30 20:40:33 2007 +0000 @@ -418,12 +418,6 @@ this->xy = 0; } -bool Waypoint::IsValid() const -{ - return this->xy != 0; -} - - /** * Fix savegames which stored waypoints in their old format */ diff -r 05dd904bb306 -r 8ac3fcd8d570 src/waypoint.h --- a/src/waypoint.h Thu Aug 30 19:20:15 2007 +0000 +++ b/src/waypoint.h Thu Aug 30 20:40:33 2007 +0000 @@ -30,7 +30,7 @@ Waypoint(TileIndex tile = 0); ~Waypoint(); - bool IsValid() const; + inline bool IsValid() const { return this->xy != 0; } }; static inline bool IsValidWaypointID(WaypointID index)