MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ~Town

Method ~Town

src/town_cmd.cpp:115–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115Town::~Town()
116{
117 if (CleaningPool()) return;
118
119 /* Delete town authority window
120 * and remove from list of sorted towns */
121 CloseWindowById(WC_TOWN_VIEW, this->index);
122 CloseWindowById(WC_TOWN_CARGO_GRAPH, this->index);
123
124#ifdef WITH_ASSERT
125 /* Check no industry is related to us. */
126 for (const Industry *i : Industry::Iterate()) {
127 assert(i->town != this);
128 }
129
130 /* ... and no object is related to us. */
131 for (const Object *o : Object::Iterate()) {
132 assert(o->town != this);
133 }
134
135 /* Check no tile is related to us. */
136 for (const auto tile : Map::Iterate()) {
137 switch (GetTileType(tile)) {
138 case MP_HOUSE:
139 assert(GetTownIndex(tile) != this->index);
140 break;
141
142 case MP_ROAD:
143 assert(!HasTownOwnedRoad(tile) || GetTownIndex(tile) != this->index);
144 break;
145
146 case MP_TUNNELBRIDGE:
147 assert(!TestTownOwnsBridge(tile, this));
148 break;
149
150 default:
151 break;
152 }
153 }
154#endif /* WITH_ASSERT */
155
156 /* Clear the persistent storage list. */
157 for (auto &psa : this->psa_list) {
158 delete psa;
159 }
160 this->psa_list.clear();
161
162 Source src{this->index, SourceType::Town};
163 DeleteSubsidyWith(src);
164 DeleteNewGRFInspectWindow(GSF_FAKE_TOWNS, this->index);
165 CargoPacket::InvalidateAllFrom(src);
166 MarkWholeScreenDirty();
167}
168
169
170/**

Callers

nothing calls this directly

Calls 9

CloseWindowByIdFunction · 0.85
GetTileTypeFunction · 0.85
GetTownIndexFunction · 0.85
HasTownOwnedRoadFunction · 0.85
TestTownOwnsBridgeFunction · 0.85
DeleteSubsidyWithFunction · 0.85
MarkWholeScreenDirtyFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected