Fix incorrect tile and trackdir in reserve through program execution
[openttd-joker.git] / src / overlay_cmd.cpp
blob059121d8f314e8f28155d216b97fccf2c35225b6
1 /* $Id$ */
3 /** @file overlay_cmd.cpp Handling of overlays. */
5 #include "stdafx.h"
6 #include "tile_type.h"
7 #include "tile_cmd.h"
8 #include "overlay.h"
9 #include "station_func.h"
10 #include "viewport_func.h"
11 #include "overlay_cmd.h"
13 Overlays* Overlays::instance = NULL;
15 Overlays* Overlays::Instance()
17 if (instance == NULL)
18 instance = new Overlays();
19 return instance;
22 void Overlays::AddStation(const Station* st)
24 this->catchmentOverlay.insert(st);
27 void Overlays::RemoveStation(const Station* st)
29 this->catchmentOverlay.erase(st);
32 void Overlays::ToggleStation(const Station* st)
34 if(this->HasStation(st)) {
35 this->RemoveStation(st);
36 } else {
37 this->AddStation(st);
41 void Overlays::Clear()
43 this->catchmentOverlay.clear();
46 bool Overlays::IsTileInCatchmentArea(const TileInfo* ti, CatchmentType type)
48 for(std::set<const Station *>::iterator iter = catchmentOverlay.begin();iter != catchmentOverlay.end();) {
49 const Station *st = *iter;
50 if( st->IsTileInCatchmentArea(ti, type))
51 return true;
52 iter++;
54 return false;
57 bool Overlays::HasStation(const Station* st)
59 return (this->catchmentOverlay.find(st) != this->catchmentOverlay.end());
62 Overlays::~Overlays()
64 this->catchmentOverlay.clear();