# signs.cpp

Go to the documentation of this file.

    00001 /* $Id: signs.cpp 15711 2009-03-14 18:16:29Z rubidium $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "landscape.h"
    00007 #include "signs_base.h"
    00008 #include "signs_func.h"
    00009 #include "strings_func.h"
    00010 #include "viewport_func.h"
    00011 #include "zoom_func.h"
    00012 #include "functions.h"
    00013 #include "oldpool_func.h"
    00014
    00015 #include "table/strings.h"
    00016
    00017 /* Initialize the sign-pool */
    00018 DEFINE_OLD_POOL_GENERIC(Sign, Sign)
    00019
    00020 Sign::Sign(Owner owner)
    00021 {
    00022   this->owner = owner;
    00023 }
    00024
    00025 Sign::~Sign()
    00026 {
    00027   free(this->name);
    00028
    00029   if (CleaningPool()) return;
    00030
    00031   DeleteRenameSignWindow(this->index);
    00032   this->owner = INVALID_OWNER;
    00033 }
    00034
    00041 void UpdateSignVirtCoords(Sign *si)
    00042 {
    00043   Point pt = RemapCoords(si->x, si->y, si->z);
    00044   SetDParam(0, si->index);
    00045   UpdateViewportSignPos(&si->sign, pt.x, pt.y - 6, STR_2806);
    00046 }
    00047
    00049 void UpdateAllSignVirtCoords()
    00050 {
    00051   Sign *si;
    00052
    00053   FOR_ALL_SIGNS(si) UpdateSignVirtCoords(si);
    00054 }
    00055
    00064 void MarkSignDirty(Sign *si)
    00065 {
    00066   /* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
    00067    *  and there is no way for us to know which is the biggest. So make the
    00068    *  biggest area dirty, and we are safe for sure. */
    00069   MarkAllViewportsDirty(
    00070     si->sign.left - 6,
    00071     si->sign.top  - 3,
    00072     si->sign.left + ScaleByZoom(si->sign.width_1 + 12, ZOOM_LVL_MAX),
    00073     si->sign.top  + ScaleByZoom(12, ZOOM_LVL_MAX));
    00074 }
    00075
    00081 void InitializeSigns()
    00082 {
    00083   _Sign_pool.CleanPool();
    00084   _Sign_pool.AddBlockToPool();
    00085 }