1
0
Fork 0

Codechange: explicitly initialise Sign member variables

pull/13619/head^2
Rubidium 2025-02-18 19:37:17 +01:00 committed by rubidium42
parent 11a8b71504
commit 704f5e2500
3 changed files with 10 additions and 22 deletions

View File

@ -24,14 +24,6 @@
SignPool _sign_pool("Sign");
INSTANTIATE_POOL_METHODS(Sign)
/**
* Creates a new sign
*/
Sign::Sign(Owner owner)
{
this->owner = owner;
}
/** Destroy the sign */
Sign::~Sign()
{

View File

@ -19,14 +19,15 @@ typedef Pool<Sign, SignID, 16> SignPool;
extern SignPool _sign_pool;
struct Sign : SignPool::PoolItem<&_sign_pool> {
std::string name;
TrackedViewportSign sign;
int32_t x;
int32_t y;
int32_t z;
Owner owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
std::string name{};
TrackedViewportSign sign{};
int32_t x = 0;
int32_t y = 0;
int32_t z = 0;
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();
void UpdateVirtCoord();

View File

@ -42,16 +42,11 @@ std::tuple<CommandCost, SignID> CmdPlaceSign(DoCommandFlags flags, TileIndex til
/* When we execute, really make the sign */
if (flags.Test(DoCommandFlag::Execute)) {
Sign *si = new Sign(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company);
int x = TileX(tile) * TILE_SIZE;
int y = TileY(tile) * TILE_SIZE;
si->x = x;
si->y = y;
si->z = GetSlopePixelZ(x, y);
if (!text.empty()) {
si->name = text;
}
Sign *si = new Sign(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company, x, y, GetSlopePixelZ(x, y), text);
si->UpdateVirtCoord();
InvalidateWindowData(WC_SIGN_LIST, 0, 0);
return { CommandCost(), si->index };