182 } |
183 } |
183 } |
184 } |
184 |
185 |
185 static uint GetSlopeZ_Unmovable(const TileInfo* ti) |
186 static uint GetSlopeZ_Unmovable(const TileInfo* ti) |
186 { |
187 { |
187 if (_m[ti->tile].m5 == 3) { |
188 if (IsOwnedLand(ti->tile)) { |
188 return ti->z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh); |
189 return ti->z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh); |
189 } else { |
190 } else { |
190 return ti->z + (ti->tileh == 0 ? 0 : 8); |
191 return ti->z + (ti->tileh == 0 ? 0 : 8); |
191 } |
192 } |
192 } |
193 } |
193 |
194 |
194 static uint GetSlopeTileh_Unmovable(const TileInfo *ti) |
195 static uint GetSlopeTileh_Unmovable(const TileInfo *ti) |
195 { |
196 { |
196 return _m[ti->tile].m5 == 3 ? ti->tileh : 0; |
197 return IsOwnedLand(ti->tile) ? ti->tileh : 0; |
197 } |
198 } |
198 |
199 |
199 static int32 ClearTile_Unmovable(TileIndex tile, byte flags) |
200 static int32 ClearTile_Unmovable(TileIndex tile, byte flags) |
200 { |
201 { |
201 byte m5 = _m[tile].m5; |
202 if (_m[tile].m5 & 0x80) { |
202 |
|
203 if (m5 & 0x80) { |
|
204 if (_current_player == OWNER_WATER) return DestroyCompanyHQ(tile, DC_EXEC); |
203 if (_current_player == OWNER_WATER) return DestroyCompanyHQ(tile, DC_EXEC); |
205 return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN); |
204 return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN); |
206 } |
205 } |
207 |
206 |
208 if (m5 == 3) // company owned land |
207 if (IsOwnedLand(tile)) { |
209 return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA); |
208 return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA); |
|
209 } |
210 |
210 |
211 // checks if you're allowed to remove unmovable things |
211 // checks if you're allowed to remove unmovable things |
212 if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) ) |
212 if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) ) |
213 return_cmd_error(STR_5800_OBJECT_IN_THE_WAY); |
213 return_cmd_error(STR_5800_OBJECT_IN_THE_WAY); |
214 |
214 |
243 // commercial building generates unusually high amount of mail |
243 // commercial building generates unusually high amount of mail |
244 // correspondence per physical visitor. |
244 // correspondence per physical visitor. |
245 ac[CT_MAIL] = max(1, level / 2); |
245 ac[CT_MAIL] = max(1, level / 2); |
246 } |
246 } |
247 |
247 |
248 static const StringID _unmovable_tile_str[] = { |
|
249 STR_5803_COMPANY_HEADQUARTERS, |
|
250 STR_5801_TRANSMITTER, |
|
251 STR_5802_LIGHTHOUSE, |
|
252 STR_2016_STATUE, |
|
253 STR_5805_COMPANY_OWNED_LAND, |
|
254 }; |
|
255 |
248 |
256 static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td) |
249 static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td) |
257 { |
250 { |
258 int i = _m[tile].m5; |
251 switch (GetUnmovableType(tile)) { |
259 if (i & 0x80) i = -1; |
252 case UNMOVABLE_TRANSMITTER: td->str = STR_5801_TRANSMITTER; break; |
260 td->str = _unmovable_tile_str[i + 1]; |
253 case UNMOVABLE_LIGHTHOUSE: td->str = STR_5802_LIGHTHOUSE; break; |
|
254 case UNMOVABLE_STATUE: td->str = STR_2016_STATUE; break; |
|
255 case UNMOVABLE_OWNED_LAND: td->str = STR_5805_COMPANY_OWNED_LAND; break; |
|
256 default: td->str = STR_5803_COMPANY_HEADQUARTERS; break; |
|
257 } |
261 td->owner = GetTileOwner(tile); |
258 td->owner = GetTileOwner(tile); |
262 } |
259 } |
263 |
260 |
264 static void AnimateTile_Unmovable(TileIndex tile) |
261 static void AnimateTile_Unmovable(TileIndex tile) |
265 { |
262 { |
319 static bool checkRadioTowerNearby(TileIndex tile) |
316 static bool checkRadioTowerNearby(TileIndex tile) |
320 { |
317 { |
321 TileIndex tile_s = tile - TileDiffXY(4, 4); |
318 TileIndex tile_s = tile - TileDiffXY(4, 4); |
322 |
319 |
323 BEGIN_TILE_LOOP(tile, 9, 9, tile_s) |
320 BEGIN_TILE_LOOP(tile, 9, 9, tile_s) |
324 // already a radio tower here? |
321 if (IsTransmitterTile(tile)) return false; |
325 if (IsTileType(tile, MP_UNMOVABLE) && _m[tile].m5 == 0) |
|
326 return false; |
|
327 END_TILE_LOOP(tile, 9, 9, tile_s) |
322 END_TILE_LOOP(tile, 9, 9, tile_s) |
328 return true; |
323 return true; |
329 } |
324 } |
330 |
325 |
331 void GenerateUnmovables(void) |
326 void GenerateUnmovables(void) |
343 j = ScaleByMapSize(40); // maximum number of radio towers on the map |
338 j = ScaleByMapSize(40); // maximum number of radio towers on the map |
344 do { |
339 do { |
345 tile = RandomTile(); |
340 tile = RandomTile(); |
346 if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) { |
341 if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) { |
347 if (!checkRadioTowerNearby(tile)) continue; |
342 if (!checkRadioTowerNearby(tile)) continue; |
348 SetTileType(tile, MP_UNMOVABLE); |
343 MakeTransmitter(tile); |
349 SetTileOwner(tile, OWNER_NONE); |
|
350 _m[tile].m5 = 0; |
|
351 if (--j == 0) break; |
344 if (--j == 0) break; |
352 } |
345 } |
353 } while (--i); |
346 } while (--i); |
354 |
347 |
355 if (_opt.landscape == LT_DESERT) return; |
348 if (_opt.landscape == LT_DESERT) return; |
378 tile = TILE_MASK(tile + TileOffsByDir(dir)); |
371 tile = TILE_MASK(tile + TileOffsByDir(dir)); |
379 } while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16)); |
372 } while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16)); |
380 |
373 |
381 assert(tile == TILE_MASK(tile)); |
374 assert(tile == TILE_MASK(tile)); |
382 |
375 |
383 SetTileType(tile, MP_UNMOVABLE); |
376 MakeLighthouse(tile); |
384 SetTileOwner(tile, OWNER_NONE); |
|
385 _m[tile].m5 = 1; |
|
386 } while (--i); |
377 } while (--i); |
387 } |
378 } |
388 |
379 |
389 static void ChangeTileOwner_Unmovable(TileIndex tile, PlayerID old_player, PlayerID new_player) |
380 static void ChangeTileOwner_Unmovable(TileIndex tile, PlayerID old_player, PlayerID new_player) |
390 { |
381 { |