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 "company_func.h"
13 #include "signs_base.h"
14 #include "signs_func.h"
15 #include "strings_func.h"
16 #include "core/pool_func.hpp"
17 #include "viewport_kdtree.h"
19 #include "table/strings.h"
21 #include "safeguards.h"
23 /** Initialize the sign-pool */
24 SignPool
_sign_pool("Sign");
25 INSTANTIATE_POOL_METHODS(Sign
)
30 Sign::Sign(Owner owner
)
35 /** Destroy the sign */
38 if (CleaningPool()) return;
40 DeleteRenameSignWindow(this->index
);
44 * Update the coordinate of one sign
46 void Sign::UpdateVirtCoord()
48 Point pt
= RemapCoords(this->x
, this->y
, this->z
);
50 if (this->sign
.kdtree_valid
) _viewport_sign_kdtree
.Remove(ViewportSignKdtreeItem::MakeSign(this->index
));
52 SetDParam(0, this->index
);
53 this->sign
.UpdatePosition(pt
.x
, pt
.y
- 6 * ZOOM_BASE
, STR_WHITE_SIGN
);
55 _viewport_sign_kdtree
.Insert(ViewportSignKdtreeItem::MakeSign(this->index
));
58 /** Update the coordinates of all signs */
59 void UpdateAllSignVirtCoords()
61 for (Sign
*si
: Sign::Iterate()) {
62 si
->UpdateVirtCoord();
67 * Check if the current company can rename a given sign.
68 * @param *si The sign in question.
69 * @return true if the sign can be renamed, else false.
71 bool CompanyCanRenameSign(const Sign
*si
)
73 if (si
->owner
== OWNER_DEITY
&& _current_company
!= OWNER_DEITY
&& _game_mode
!= GM_EDITOR
) return false;