2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2004-11-25 10:47:30 +00:00
|
|
|
#include "table/strings.h"
|
2004-12-15 22:18:54 +00:00
|
|
|
#include "map.h"
|
2005-01-29 12:19:05 +00:00
|
|
|
#include "tile.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "command.h"
|
|
|
|
#include "viewport.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "gui.h"
|
2004-11-14 01:25:05 +00:00
|
|
|
#include "station.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "economy.h"
|
|
|
|
#include "town.h"
|
2004-11-14 16:42:08 +00:00
|
|
|
#include "sprite.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-05-12 23:46:01 +00:00
|
|
|
/** Destroy a HQ.
|
|
|
|
* During normal gameplay you can only implicitely destroy a HQ when you are
|
|
|
|
* rebuilding it. Otherwise, only water can destroy it.
|
|
|
|
* @param tile tile coordinates where HQ is located to destroy
|
|
|
|
* @param flags docommand flags of calling function
|
|
|
|
*/
|
|
|
|
int32 DestroyCompanyHQ(TileIndex tile, uint32 flags)
|
|
|
|
{
|
|
|
|
Player *p;
|
|
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
|
|
|
|
|
|
|
|
/* Find player that has HQ flooded, and reset their location_of_house */
|
|
|
|
if (_current_player == OWNER_WATER) {
|
|
|
|
bool dodelete = false;
|
|
|
|
|
|
|
|
FOR_ALL_PLAYERS(p) {
|
|
|
|
if (p->location_of_house == tile) {
|
|
|
|
dodelete = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!dodelete) return CMD_ERROR;
|
|
|
|
} else /* Destruction was initiated by player */
|
2005-06-21 16:28:17 +00:00
|
|
|
p = GetPlayer(_current_player);
|
2005-05-12 23:46:01 +00:00
|
|
|
|
|
|
|
if (p->location_of_house == 0) return CMD_ERROR;
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
2005-06-25 16:44:57 +00:00
|
|
|
DoClearSquare(p->location_of_house + TileDiffXY(0, 0));
|
|
|
|
DoClearSquare(p->location_of_house + TileDiffXY(0, 1));
|
|
|
|
DoClearSquare(p->location_of_house + TileDiffXY(1, 0));
|
|
|
|
DoClearSquare(p->location_of_house + TileDiffXY(1, 1));
|
2005-05-12 23:46:01 +00:00
|
|
|
p->location_of_house = 0; // reset HQ position
|
|
|
|
InvalidateWindow(WC_COMPANY, (int)p->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
// cost of relocating company is 1% of company value
|
|
|
|
return CalculateCompanyValue(p) / 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Build or relocate the HQ. This depends if the HQ is already built or not
|
|
|
|
* @param x,y the coordinates where the HQ will be built or relocated to
|
|
|
|
* @param p1 relocate HQ (set to some value, usually 1 or true)
|
|
|
|
* @param p2 unused
|
|
|
|
*/
|
2005-06-24 12:38:35 +00:00
|
|
|
extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
|
2005-05-12 23:46:01 +00:00
|
|
|
int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|
|
|
{
|
2005-06-25 06:15:43 +00:00
|
|
|
TileIndex tile = TileVirtXY(x, y);
|
2005-06-21 16:28:17 +00:00
|
|
|
Player *p = GetPlayer(_current_player);
|
2005-05-12 23:46:01 +00:00
|
|
|
int cost;
|
|
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
|
|
|
|
|
|
|
|
cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
|
|
|
|
if (CmdFailed(cost)) return CMD_ERROR;
|
|
|
|
|
|
|
|
if (p1) { /* Moving HQ */
|
|
|
|
int32 ret;
|
|
|
|
|
|
|
|
if (p->location_of_house == 0) return CMD_ERROR;
|
|
|
|
|
|
|
|
ret = DestroyCompanyHQ(p->location_of_house, flags);
|
|
|
|
|
|
|
|
if (CmdFailed(ret)) return CMD_ERROR;
|
|
|
|
|
|
|
|
cost += ret;
|
|
|
|
} else { /* Building new HQ */
|
|
|
|
if (p->location_of_house != 0) return CMD_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
int score = UpdateCompanyRatingAndValue(p, false);
|
|
|
|
|
|
|
|
p->location_of_house = tile;
|
|
|
|
|
2005-06-25 16:44:57 +00:00
|
|
|
ModifyTile(tile + TileDiffXY(0, 0), MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, 0x80);
|
|
|
|
ModifyTile(tile + TileDiffXY(0, 1), MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, 0x81);
|
|
|
|
ModifyTile(tile + TileDiffXY(1, 0), MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, 0x82);
|
|
|
|
ModifyTile(tile + TileDiffXY(1, 1), MP_SETTYPE(MP_UNMOVABLE) | MP_MAPOWNER_CURRENT | MP_MAP5, 0x83);
|
2005-05-12 23:46:01 +00:00
|
|
|
UpdatePlayerHouse(p, score);
|
|
|
|
InvalidateWindow(WC_COMPANY, (int)p->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cost;
|
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
typedef struct DrawTileUnmovableStruct {
|
|
|
|
uint16 image;
|
|
|
|
byte subcoord_x;
|
|
|
|
byte subcoord_y;
|
|
|
|
byte width;
|
|
|
|
byte height;
|
|
|
|
byte z_size;
|
|
|
|
byte unused;
|
|
|
|
} DrawTileUnmovableStruct;
|
|
|
|
|
|
|
|
#include "table/unmovable_land.h"
|
|
|
|
|
|
|
|
static void DrawTile_Unmovable(TileInfo *ti)
|
|
|
|
{
|
|
|
|
uint32 image, ormod;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
if (!(ti->map5 & 0x80)) {
|
|
|
|
if (ti->map5 == 2) {
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// statue
|
|
|
|
DrawGroundSprite(0x58C);
|
|
|
|
|
2005-06-04 11:56:32 +00:00
|
|
|
image = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
|
2004-08-09 17:04:08 +00:00
|
|
|
image += 0x8A48;
|
2004-11-23 22:36:11 +00:00
|
|
|
if (_display_opt & DO_TRANS_BUILDINGS)
|
2004-08-09 17:04:08 +00:00
|
|
|
image = (image & 0x3FFF) | 0x3224000;
|
|
|
|
AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 25, ti->z);
|
|
|
|
} else if (ti->map5 == 3) {
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// "owned by" sign
|
|
|
|
DrawClearLandTile(ti, 0);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
AddSortableSpriteToDraw(
|
2005-06-04 11:56:32 +00:00
|
|
|
PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)) + 0x92B6,
|
2004-08-09 17:04:08 +00:00
|
|
|
ti->x+8, ti->y+8,
|
2004-09-10 19:02:27 +00:00
|
|
|
1, 1,
|
|
|
|
10,
|
2004-08-09 17:04:08 +00:00
|
|
|
GetSlopeZ(ti->x+8, ti->y+8)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// lighthouse or transmitter
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
const DrawTileUnmovableStruct *dtus;
|
|
|
|
|
|
|
|
if (ti->tileh) DrawFoundation(ti, ti->tileh);
|
|
|
|
DrawClearLandTile(ti, 2);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
|
|
|
dtus = &_draw_tile_unmovable_data[ti->map5];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
image = dtus->image;
|
2004-11-23 22:36:11 +00:00
|
|
|
if (_display_opt & DO_TRANS_BUILDINGS)
|
2004-08-09 17:04:08 +00:00
|
|
|
image = (image & 0x3FFF) | 0x3224000;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
|
|
|
AddSortableSpriteToDraw(image,
|
2004-08-09 17:04:08 +00:00
|
|
|
ti->x | dtus->subcoord_x,
|
|
|
|
ti->y | dtus->subcoord_y,
|
|
|
|
dtus->width, dtus->height,
|
|
|
|
dtus->z_size, ti->z);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const DrawTileSeqStruct *dtss;
|
2004-11-14 01:25:05 +00:00
|
|
|
const DrawTileSprites *t;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (ti->tileh) DrawFoundation(ti, ti->tileh);
|
|
|
|
|
2005-06-04 11:56:32 +00:00
|
|
|
ormod = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-11-14 01:25:05 +00:00
|
|
|
t = &_unmovable_display_datas[ti->map5 & 0x7F];
|
|
|
|
DrawGroundSprite(t->ground_sprite | ormod);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-11-14 01:25:05 +00:00
|
|
|
foreach_draw_tile_seq(dtss, t->seq) {
|
2004-08-09 17:04:08 +00:00
|
|
|
image = dtss->image;
|
|
|
|
if (_display_opt & DO_TRANS_BUILDINGS) {
|
|
|
|
image = (image & 0x3FFF) | 0x03224000;
|
2004-11-23 22:36:11 +00:00
|
|
|
} else {
|
|
|
|
image |= ormod;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
AddSortableSpriteToDraw(image, ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
|
|
|
dtss->width, dtss->height, dtss->unk, ti->z + dtss->delta_z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-10 19:02:27 +00:00
|
|
|
static uint GetSlopeZ_Unmovable(TileInfo *ti)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + ti->z;
|
|
|
|
}
|
|
|
|
|
2004-09-10 19:02:27 +00:00
|
|
|
static uint GetSlopeTileh_Unmovable(TileInfo *ti)
|
2004-08-13 18:27:33 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static int32 ClearTile_Unmovable(TileIndex tile, byte flags)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
byte m5 = _map5[tile];
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-09-01 21:54:12 +00:00
|
|
|
if (m5 & 0x80) {
|
2005-05-12 23:46:01 +00:00
|
|
|
if (_current_player == OWNER_WATER) return DestroyCompanyHQ(tile, DC_EXEC);
|
2004-08-09 17:04:08 +00:00
|
|
|
return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (m5 == 3) // company owned land
|
|
|
|
return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
|
|
|
|
|
2004-09-03 17:57:27 +00:00
|
|
|
// checks if you're allowed to remove unmovable things
|
|
|
|
if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
|
|
|
|
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
2004-08-09 17:04:08 +00:00
|
|
|
DoClearSquare(tile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void GetAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
byte m5 = _map5[tile];
|
|
|
|
uint level; // HQ level (depends on company performance) in the range 1..5.
|
|
|
|
|
|
|
|
if (!(m5 & 0x80)) {
|
|
|
|
/* not used */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HQ accepts passenger and mail; but we have to divide the values
|
|
|
|
* between 4 tiles it occupies! */
|
|
|
|
|
|
|
|
level = (m5 & ~0x80) / 4 + 1;
|
|
|
|
|
|
|
|
// Top town building generates 10, so to make HQ interesting, the top
|
|
|
|
// type makes 20.
|
2004-11-21 10:49:40 +00:00
|
|
|
ac[CT_PASSENGERS] = max(1, level);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// Top town building generates 4, HQ can make up to 8. The
|
|
|
|
// proportion passengers:mail is different because such a huge
|
|
|
|
// commercial building generates unusually high amount of mail
|
|
|
|
// correspondence per physical visitor.
|
2004-11-21 10:49:40 +00:00
|
|
|
ac[CT_MAIL] = max(1, level / 2);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const StringID _unmovable_tile_str[] = {
|
|
|
|
STR_5803_COMPANY_HEADQUARTERS,
|
|
|
|
STR_5801_TRANSMITTER,
|
|
|
|
STR_5802_LIGHTHOUSE,
|
|
|
|
STR_2016_STATUE,
|
|
|
|
STR_5805_COMPANY_OWNED_LAND,
|
2004-09-10 19:02:27 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int i = _map5[tile];
|
|
|
|
if (i & 0x80) i = -1;
|
|
|
|
td->str = _unmovable_tile_str[i + 1];
|
2005-06-04 11:56:32 +00:00
|
|
|
td->owner = GetTileOwner(tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void AnimateTile_Unmovable(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
/* not used */
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void TileLoop_Unmovable(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
byte m5 = _map5[tile];
|
|
|
|
byte level; // HQ level (depends on company performance) in the range 1..5.
|
|
|
|
uint32 r;
|
|
|
|
|
|
|
|
if (!(m5 & 0x80)) {
|
|
|
|
/* not used */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HQ accepts passenger and mail; but we have to divide the values
|
|
|
|
* between 4 tiles it occupies! */
|
|
|
|
|
|
|
|
level = (m5 & ~0x80) / 4 + 1;
|
|
|
|
assert(level < 6);
|
|
|
|
|
|
|
|
r = Random();
|
|
|
|
// Top town buildings generate 250, so the top HQ type makes 256.
|
|
|
|
if ((byte) r < (256 / 4 / (6 - level))) {
|
|
|
|
uint amt = ((byte) r >> 3) / 4 + 1;
|
|
|
|
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
|
|
|
MoveGoodsToStation(tile, 2, 2, CT_PASSENGERS, amt);
|
|
|
|
}
|
|
|
|
|
|
|
|
r >>= 8;
|
|
|
|
// Top town building generates 90, HQ can make up to 196. The
|
|
|
|
// proportion passengers:mail is about the same as in the acceptance
|
|
|
|
// equations.
|
|
|
|
if ((byte) r < (196 / 4 / (6 - level))) {
|
|
|
|
uint amt = ((byte) r >> 3) / 4 + 1;
|
|
|
|
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
|
|
|
MoveGoodsToStation(tile, 2, 2, CT_MAIL, amt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void ClickTile_Unmovable(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
if (_map5[tile] & 0x80) {
|
2005-06-04 11:56:32 +00:00
|
|
|
ShowPlayerCompany(GetTileOwner(tile));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-06 11:39:00 +00:00
|
|
|
static const TileIndexDiffC _tile_add[] = {
|
|
|
|
{ 1, 0},
|
|
|
|
{ 0, 1},
|
|
|
|
{-1, 0},
|
|
|
|
{ 0, -1}
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* checks, if a radio tower is within a 9x9 tile square around tile */
|
2005-06-24 12:38:35 +00:00
|
|
|
static bool checkRadioTowerNearby(TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-06-25 16:44:57 +00:00
|
|
|
TileIndex tile_s = tile - TileDiffXY(4, 4);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
|
|
|
|
// already a radio tower here?
|
2005-01-16 11:24:58 +00:00
|
|
|
if (IsTileType(tile, MP_UNMOVABLE) && _map5[tile] == 0)
|
2004-08-09 17:04:08 +00:00
|
|
|
return false;
|
|
|
|
END_TILE_LOOP(tile, 9, 9, tile_s)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-01-22 20:23:18 +00:00
|
|
|
void GenerateUnmovables(void)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
int i,j;
|
2005-06-24 12:38:35 +00:00
|
|
|
TileIndex tile;
|
2004-08-09 17:04:08 +00:00
|
|
|
uint32 r;
|
|
|
|
int dir;
|
2005-02-07 10:41:45 +00:00
|
|
|
uint h;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (_opt.landscape == LT_CANDY)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* add radio tower */
|
2005-01-28 15:31:04 +00:00
|
|
|
i = ScaleByMapSize(1000);
|
|
|
|
j = ScaleByMapSize(40); // maximum number of radio towers on the map
|
2004-08-09 17:04:08 +00:00
|
|
|
do {
|
|
|
|
r = Random();
|
2005-01-03 18:59:58 +00:00
|
|
|
tile = r % MapSize();
|
2004-08-09 17:04:08 +00:00
|
|
|
// TILE_MASK seems to be not working correctly. Radio masts accumulate in one area.
|
|
|
|
// tile = TILE_MASK(r);
|
2005-01-16 11:24:58 +00:00
|
|
|
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
|
2004-08-09 17:04:08 +00:00
|
|
|
if(!checkRadioTowerNearby(tile))
|
|
|
|
continue;
|
2005-01-18 18:41:56 +00:00
|
|
|
SetTileType(tile, MP_UNMOVABLE);
|
2004-08-09 17:04:08 +00:00
|
|
|
_map5[tile] = 0;
|
2005-06-04 12:13:24 +00:00
|
|
|
SetTileOwner(tile, OWNER_NONE);
|
2004-08-09 17:04:08 +00:00
|
|
|
if (--j == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (--i);
|
|
|
|
|
|
|
|
if (_opt.landscape == LT_DESERT)
|
|
|
|
return;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
/* add lighthouses */
|
2005-01-28 15:31:04 +00:00
|
|
|
i = ScaleByMapSize1D((Random() & 3) + 7);
|
2004-08-09 17:04:08 +00:00
|
|
|
do {
|
|
|
|
restart:
|
|
|
|
r = Random();
|
|
|
|
dir = r >> 30;
|
2005-01-03 12:56:22 +00:00
|
|
|
r %= (dir == 0 || dir == 2) ? MapMaxY() : MapMaxX();
|
2004-09-10 19:02:27 +00:00
|
|
|
tile =
|
2005-06-25 16:44:57 +00:00
|
|
|
(dir == 0) ? TileXY(0, r) : 0 + // left
|
|
|
|
(dir == 1) ? TileXY(r, 0) : 0 + // top
|
|
|
|
(dir == 2) ? TileXY(MapMaxX(), r) : 0 + // right
|
|
|
|
(dir == 3) ? TileXY(r, MapMaxY()) : 0; // bottom
|
2004-08-09 17:04:08 +00:00
|
|
|
j = 20;
|
|
|
|
do {
|
|
|
|
if (--j == 0)
|
|
|
|
goto restart;
|
2005-01-06 11:39:00 +00:00
|
|
|
tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
|
2005-01-16 11:24:58 +00:00
|
|
|
} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
assert(tile == TILE_MASK(tile));
|
|
|
|
|
2005-01-18 18:41:56 +00:00
|
|
|
SetTileType(tile, MP_UNMOVABLE);
|
2004-08-09 17:04:08 +00:00
|
|
|
_map5[tile] = 1;
|
2005-06-04 12:13:24 +00:00
|
|
|
SetTileOwner(tile, OWNER_NONE);
|
2004-08-09 17:04:08 +00:00
|
|
|
} while (--i);
|
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void ChangeTileOwner_Unmovable(TileIndex tile, byte old_player, byte new_player)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-06-04 11:56:32 +00:00
|
|
|
if (!IsTileOwner(tile, old_player)) return;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
if (_map5[tile]==3 && new_player != 255) {
|
2005-06-04 12:13:24 +00:00
|
|
|
SetTileOwner(tile, new_player);
|
2004-08-09 17:04:08 +00:00
|
|
|
} else {
|
|
|
|
DoClearSquare(tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const TileTypeProcs _tile_type_unmovable_procs = {
|
2005-03-12 01:02:17 +00:00
|
|
|
DrawTile_Unmovable, /* draw_tile_proc */
|
|
|
|
GetSlopeZ_Unmovable, /* get_slope_z_proc */
|
|
|
|
ClearTile_Unmovable, /* clear_tile_proc */
|
|
|
|
GetAcceptedCargo_Unmovable, /* get_accepted_cargo_proc */
|
|
|
|
GetTileDesc_Unmovable, /* get_tile_desc_proc */
|
|
|
|
GetTileTrackStatus_Unmovable, /* get_tile_track_status_proc */
|
|
|
|
ClickTile_Unmovable, /* click_tile_proc */
|
|
|
|
AnimateTile_Unmovable, /* animate_tile_proc */
|
|
|
|
TileLoop_Unmovable, /* tile_loop_clear */
|
|
|
|
ChangeTileOwner_Unmovable, /* change_tile_owner_clear */
|
|
|
|
NULL, /* get_produced_cargo_proc */
|
|
|
|
NULL, /* vehicle_enter_tile_proc */
|
|
|
|
NULL, /* vehicle_leave_tile_proc */
|
|
|
|
GetSlopeTileh_Unmovable, /* get_slope_tileh_proc */
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|