2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file signs.cpp Handling of signs. */
11 #include "landscape.h"
12 #include "signs_base.h"
13 #include "signs_func.h"
14 #include "strings_func.h"
15 #include "core/pool_func.hpp"
16 #include "viewport_kdtree.h"
18 #include "table/strings.h"
20 #include "safeguards.h"
22 /** Initialize the sign-pool */
23 SignPool
_sign_pool("Sign");
24 INSTANTIATE_POOL_METHODS(Sign
)
29 Sign::Sign(Owner owner
)
34 /** Destroy the sign */
37 if (CleaningPool()) return;
39 DeleteRenameSignWindow(this->index
);
43 * Update the coordinate of one sign
45 void Sign::UpdateVirtCoord()
47 Point pt
= RemapCoords(this->x
, this->y
, this->z
);
49 if (this->sign
.kdtree_valid
) _viewport_sign_kdtree
.Remove(ViewportSignKdtreeItem::MakeSign(this->index
));
51 SetDParam(0, this->index
);
52 this->sign
.UpdatePosition(pt
.x
, pt
.y
- 6 * ZOOM_LVL_BASE
, STR_WHITE_SIGN
);
54 _viewport_sign_kdtree
.Insert(ViewportSignKdtreeItem::MakeSign(this->index
));
57 /** Update the coordinates of all signs */
58 void UpdateAllSignVirtCoords()
60 for (Sign
*si
: Sign::Iterate()) {
61 si
->UpdateVirtCoord();