mirror of https://github.com/OpenTTD/OpenTTD
Codechange: explicitly initialise Sign member variables
parent
11a8b71504
commit
704f5e2500
|
@ -24,14 +24,6 @@
|
||||||
SignPool _sign_pool("Sign");
|
SignPool _sign_pool("Sign");
|
||||||
INSTANTIATE_POOL_METHODS(Sign)
|
INSTANTIATE_POOL_METHODS(Sign)
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new sign
|
|
||||||
*/
|
|
||||||
Sign::Sign(Owner owner)
|
|
||||||
{
|
|
||||||
this->owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Destroy the sign */
|
/** Destroy the sign */
|
||||||
Sign::~Sign()
|
Sign::~Sign()
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,14 +19,15 @@ typedef Pool<Sign, SignID, 16> SignPool;
|
||||||
extern SignPool _sign_pool;
|
extern SignPool _sign_pool;
|
||||||
|
|
||||||
struct Sign : SignPool::PoolItem<&_sign_pool> {
|
struct Sign : SignPool::PoolItem<&_sign_pool> {
|
||||||
std::string name;
|
std::string name{};
|
||||||
TrackedViewportSign sign;
|
TrackedViewportSign sign{};
|
||||||
int32_t x;
|
int32_t x = 0;
|
||||||
int32_t y;
|
int32_t y = 0;
|
||||||
int32_t z;
|
int32_t z = 0;
|
||||||
Owner owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
|
Owner owner = INVALID_OWNER; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
|
||||||
|
|
||||||
Sign(Owner owner = INVALID_OWNER);
|
Sign() {}
|
||||||
|
Sign(Owner owner, int32_t x, int32_t y, int32_t z, const std::string &name) : name(name), x(x), y(y), z(z), owner(owner) {}
|
||||||
~Sign();
|
~Sign();
|
||||||
|
|
||||||
void UpdateVirtCoord();
|
void UpdateVirtCoord();
|
||||||
|
|
|
@ -42,16 +42,11 @@ std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlags flags, TileIndex til
|
||||||
|
|
||||||
/* When we execute, really make the sign */
|
/* When we execute, really make the sign */
|
||||||
if (flags.Test(DoCommandFlag::Execute)) {
|
if (flags.Test(DoCommandFlag::Execute)) {
|
||||||
Sign *si = new Sign(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company);
|
|
||||||
int x = TileX(tile) * TILE_SIZE;
|
int x = TileX(tile) * TILE_SIZE;
|
||||||
int y = TileY(tile) * TILE_SIZE;
|
int y = TileY(tile) * TILE_SIZE;
|
||||||
|
|
||||||
si->x = x;
|
Sign *si = new Sign(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company, x, y, GetSlopePixelZ(x, y), text);
|
||||||
si->y = y;
|
|
||||||
si->z = GetSlopePixelZ(x, y);
|
|
||||||
if (!text.empty()) {
|
|
||||||
si->name = text;
|
|
||||||
}
|
|
||||||
si->UpdateVirtCoord();
|
si->UpdateVirtCoord();
|
||||||
InvalidateWindowData(WC_SIGN_LIST, 0, 0);
|
InvalidateWindowData(WC_SIGN_LIST, 0, 0);
|
||||||
return { CommandCost(), si->index };
|
return { CommandCost(), si->index };
|
||||||
|
|
Loading…
Reference in New Issue