OpenTTD

signs.cpp
Go to the documentation of this file.
1 /* $Id: signs.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
9
12 #include "stdafx.h"
13 #include "landscape.h"
14 #include "signs_base.h"
15 #include "signs_func.h"
16 #include "strings_func.h"
17 #include "core/pool_func.hpp"
18
19 #include "table/strings.h"
20
21 #include "safeguards.h"
22
24 SignPool _sign_pool("Sign");
25 INSTANTIATE_POOL_METHODS(Sign)
26
27
30 Sign::Sign(Owner owner)
31 {
32 this->owner = owner;
33 }
34
36 Sign::~Sign()
37 {
38 free(this->name);
39
40 if (CleaningPool()) return;
41
42 DeleteRenameSignWindow(this->index);
43 }
44
48 void Sign::UpdateVirtCoord()
49 {
50 Point pt = RemapCoords(this->x, this->y, this->z);
51 SetDParam(0, this->index);
52 this->sign.UpdatePosition(pt.x, pt.y - 6 * ZOOM_LVL_BASE, STR_WHITE_SIGN);
53 }
54
56 void UpdateAllSignVirtCoords()
57 {
58 Sign *si;
59
60 FOR_ALL_SIGNS(si) {
61 si->UpdateVirtCoord();
62 }
63 }
strings_func.h
Functions related to OTTD&#39;s strings.
DeleteRenameSignWindow
void DeleteRenameSignWindow(SignID sign)
Close the sign window associated with the given sign.
Definition: signs_gui.cpp:580
RemapCoords
static Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap...
Definition: landscape.h:83
Pool::PoolItem<&_sign_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:147
signs_func.h
Functions related to signs.
ViewportSign::UpdatePosition
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
Definition: viewport.cpp:1314
pool_func.hpp
Some methods of Pool are placed here in order to reduce compilation time and binary size...
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
_sign_pool
SignPool _sign_pool("Sign")
Initialize the sign-pool.
safeguards.h
A number of safeguards to prevent using unsafe methods.
UpdateAllSignVirtCoords
void UpdateAllSignVirtCoords()
Update the coordinates of all signs.
Definition: signs.cpp:56
Sign::UpdateVirtCoord
void UpdateVirtCoord()
Update the coordinate of one sign.
Definition: signs.cpp:48
Pool
Base class for all pools.
Definition: pool_type.hpp:83
INSTANTIATE_POOL_METHODS
#define INSTANTIATE_POOL_METHODS(name)
Force instantiation of pool methods so we don&#39;t get linker errors.
Definition: pool_func.hpp:224
Pool::PoolItem<&_sign_pool >::CleaningPool
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
Definition: pool_type.hpp:225
Sign::~Sign
~Sign()
Destroy the sign.
Definition: signs.cpp:36
Sign
Definition: signs_base.h:23
landscape.h
Functions related to OTTD&#39;s landscape.
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:28
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:114
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
signs_base.h
Base class for signs.
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:201