unmovable_cmd.c
author Darkvater
Sat, 14 Oct 2006 15:49:43 +0000
changeset 4848 56549aa3e234
parent 4559 c853d2440065
child 5573 afa6f92a71fd
permissions -rw-r--r--
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
put it into player.h where it belongs (instead of map.h)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1796
diff changeset
     4
#include "openttd.h"
507
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 497
diff changeset
     5
#include "table/strings.h"
2148
47ba4a1b1c3b (svn r2658) -Codechange: Use MAKE_TRANSPARENT to display a transparented sprite
celestar
parents: 2051
diff changeset
     6
#include "table/sprites.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     7
#include "functions.h"
679
e959706a3e4d (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 507
diff changeset
     8
#include "map.h"
1209
a1ac96655b79 (svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents: 1202
diff changeset
     9
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "player.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gui.h"
384
bf1303e754ff (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 222
diff changeset
    14
#include "station.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "economy.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "town.h"
405
6830ae7a0d5d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 384
diff changeset
    17
#include "sprite.h"
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
    18
#include "unmovable_map.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2150
diff changeset
    19
#include "variables.h"
3654
4a3f8056a61c (svn r4568) CodeChange : Bring definitions and uses of DrawTypesStructures toguether.
belugas
parents: 3645
diff changeset
    20
#include "table/unmovable_land.h"
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
    21
#include "genworld.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    23
/** Destroy a HQ.
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    24
 * During normal gameplay you can only implicitely destroy a HQ when you are
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    25
 * rebuilding it. Otherwise, only water can destroy it.
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    26
 * @param tile tile coordinates where HQ is located to destroy
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    27
 * @param flags docommand flags of calling function
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    28
 */
4060
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    29
static int32 DestroyCompanyHQ(PlayerID pid, uint32 flags)
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    30
{
4060
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    31
	Player* p = GetPlayer(pid);
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    32
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    33
	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    34
4060
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    35
	if (flags & DC_EXEC) {
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    36
		TileIndex t = p->location_of_house;
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    37
4060
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    38
		DoClearSquare(t + TileDiffXY(0, 0));
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    39
		DoClearSquare(t + TileDiffXY(0, 1));
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    40
		DoClearSquare(t + TileDiffXY(1, 0));
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    41
		DoClearSquare(t + TileDiffXY(1, 1));
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    42
		p->location_of_house = 0; // reset HQ position
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    43
		InvalidateWindow(WC_COMPANY, pid);
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    44
	}
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    45
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    46
	// cost of relocating company is 1% of company value
4060
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    47
	return CalculateCompanyValue(p) / 100;
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    48
}
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    49
3386
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    50
void UpdateCompanyHQ(Player *p, uint score)
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    51
{
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    52
	byte val;
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    53
	TileIndex tile = p->location_of_house;
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    54
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
    55
	if (tile == 0) return;
3386
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    56
3388
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3386
diff changeset
    57
	(val = 0, score < 170) ||
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3386
diff changeset
    58
	(val++, score < 350) ||
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3386
diff changeset
    59
	(val++, score < 520) ||
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3386
diff changeset
    60
	(val++, score < 720) ||
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3386
diff changeset
    61
	(val++, true);
3386
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    62
3388
c802170b5dd4 (svn r4196) -Codechange: Add and make use of an accessor that modifies the size of the Company HQ
celestar
parents: 3386
diff changeset
    63
	EnlargeCompanyHQ(tile, val);
3386
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    64
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    65
	MarkTileDirtyByTile(tile + TileDiffXY(0, 0));
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    66
	MarkTileDirtyByTile(tile + TileDiffXY(0, 1));
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    67
	MarkTileDirtyByTile(tile + TileDiffXY(1, 0));
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    68
	MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    69
}
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
    70
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    71
/** Build or relocate the HQ. This depends if the HQ is already built or not
3491
4c8427796c64 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3427
diff changeset
    72
 * @param tile tile where the HQ will be built or relocated to
2473
bbc4e805214d (svn r2999) Do not pass if the HQ gets built for the first time or gets relocated as parameter - the command function has to check this anyway
tron
parents: 2436
diff changeset
    73
 * @param p1 unused
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    74
 * @param p2 unused
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    75
 */
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    76
extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
3491
4c8427796c64 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3427
diff changeset
    77
int32 CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    78
{
1962
51ee4f459268 (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents: 1902
diff changeset
    79
	Player *p = GetPlayer(_current_player);
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    80
	int cost;
3183
cf71bd234ebd (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3164
diff changeset
    81
	int32 ret;
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    82
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    83
	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    84
3183
cf71bd234ebd (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3164
diff changeset
    85
	ret = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
cf71bd234ebd (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3164
diff changeset
    86
	if (CmdFailed(ret)) return ret;
cf71bd234ebd (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3164
diff changeset
    87
	cost = ret;
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    88
2473
bbc4e805214d (svn r2999) Do not pass if the HQ gets built for the first time or gets relocated as parameter - the command function has to check this anyway
tron
parents: 2436
diff changeset
    89
	if (p->location_of_house != 0) { /* Moving HQ */
4060
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
    90
		cost += DestroyCompanyHQ(_current_player, flags);
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    91
	}
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    92
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    93
	if (flags & DC_EXEC) {
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    94
		int score = UpdateCompanyRatingAndValue(p, false);
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    95
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    96
		p->location_of_house = tile;
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
    97
3385
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3310
diff changeset
    98
		MakeCompanyHQ(tile, _current_player);
41ebb01a92f2 (svn r4193) -Codechange: Add and make use of an accessor function to create company HQs
celestar
parents: 3310
diff changeset
    99
3386
edda700ed8e5 (svn r4194) -Codechange: Renamed UpdatePlayerHouse to UpdateCompanyHQ because the rest of the code calls it Comapany HQ. Moved it to unmovable_cmd.c because CompanyHQ is an unmovable and has nothing to do with economy.
celestar
parents: 3385
diff changeset
   100
		UpdateCompanyHQ(p, score);
3017
915fae59d5e0 (svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents: 2951
diff changeset
   101
		InvalidateWindow(WC_COMPANY, p->index);
1796
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
   102
	}
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
   103
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
   104
	return cost;
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
   105
}
cae31916ae54 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1792
diff changeset
   106
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
static void DrawTile_Unmovable(TileInfo *ti)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
	uint32 image, ormod;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   110
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   111
	switch (GetUnmovableType(ti->tile)) {
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   112
		case UNMOVABLE_TRANSMITTER:
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   113
		case UNMOVABLE_LIGHTHOUSE: {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   114
			const DrawTileUnmovableStruct* dtus;
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   115
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   116
			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   117
			DrawClearLandTile(ti, 2);
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   118
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   119
			dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   120
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   121
			image = dtus->image;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   122
			if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   123
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   124
			AddSortableSpriteToDraw(
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   125
				image, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   126
				dtus->width, dtus->height, dtus->z_size, ti->z
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   127
			);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   128
			break;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   129
		}
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   130
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   131
		case UNMOVABLE_STATUE:
2893
a234907badf7 (svn r3447) - CodeChange: [ 1360866 ] station_land.h Naming ALL sprites. Also replaced the SPTR_STATUE_GROUND by the more obvious SPR_CONCRETE_GROUND in unmovable_cmd.c. No functional changes except for commenting out PALETTE_RECOLOR_SPRITE in table/sprites.h. (Belugas)
Darkvater
parents: 2817
diff changeset
   132
			DrawGroundSprite(SPR_CONCRETE_GROUND);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
1901
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   134
			image = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
2517
b90693227193 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
   135
			image += PALETTE_MODIFIER_COLOR | SPR_STATUE_COMPANY;
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   136
			if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
			AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 25, ti->z);
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   138
			break;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   139
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   140
		case UNMOVABLE_OWNED_LAND:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
			DrawClearLandTile(ti, 0);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   142
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
			AddSortableSpriteToDraw(
2517
b90693227193 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
   144
				PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)) + PALETTE_MODIFIER_COLOR + SPR_BOUGHT_LAND,
3645
86af43f87885 (svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents: 3636
diff changeset
   145
				ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 10, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
			);
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   147
			break;
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   148
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   149
		default: {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   150
			const DrawTileSeqStruct* dtss;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   151
			const DrawTileSprites* t;
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   152
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   153
			assert(IsCompanyHQ(ti->tile));
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   154
			if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   155
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   156
			ormod = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   157
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   158
			t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)];
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   159
			DrawGroundSprite(t->ground_sprite | ormod);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   160
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   161
			foreach_draw_tile_seq(dtss, t->seq) {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   162
				image = dtss->image;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   163
				if (_display_opt & DO_TRANS_BUILDINGS) {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   164
					MAKE_TRANSPARENT(image);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   165
				} else {
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   166
					image |= ormod;
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   167
				}
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   168
				AddSortableSpriteToDraw(
4230
cd86b1c47f33 (svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents: 4083
diff changeset
   169
					image,
cd86b1c47f33 (svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents: 4083
diff changeset
   170
					ti->x + dtss->delta_x, ti->y + dtss->delta_y,
cd86b1c47f33 (svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents: 4083
diff changeset
   171
					dtss->size_x, dtss->size_y,
cd86b1c47f33 (svn r5787) Rename width, height and unk of struct DrawTileSeqStruct to size_{x,y,z}
tron
parents: 4083
diff changeset
   172
					dtss->size_z, ti->z + dtss->delta_z
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   173
				);
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   174
			}
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   175
			break;
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4060
diff changeset
   176
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
4231
dea6a63dd058 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4230
diff changeset
   180
static uint GetSlopeZ_Unmovable(TileIndex tile, uint x, uint y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
{
4231
dea6a63dd058 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4230
diff changeset
   182
	if (IsOwnedLand(tile)) {
dea6a63dd058 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4230
diff changeset
   183
		uint z;
dea6a63dd058 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4230
diff changeset
   184
		uint tileh = GetTileSlope(tile, &z);
dea6a63dd058 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4230
diff changeset
   185
dea6a63dd058 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4230
diff changeset
   186
		return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
3282
4f91ee240e68 (svn r3996) -Fix: Slope and height information returned for some tile types is wrong
tron
parents: 3183
diff changeset
   187
	} else {
4231
dea6a63dd058 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4230
diff changeset
   188
		return GetTileMaxZ(tile);
3282
4f91ee240e68 (svn r3996) -Fix: Slope and height information returned for some tile types is wrong
tron
parents: 3183
diff changeset
   189
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   192
static Slope GetSlopeTileh_Unmovable(TileIndex tile, Slope tileh)
39
d177340ed556 (svn r40) Final slope graphics fix
dominik
parents: 0
diff changeset
   193
{
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   194
	return IsOwnedLand(tile) ? tileh : SLOPE_FLAT;
39
d177340ed556 (svn r40) Final slope graphics fix
dominik
parents: 0
diff changeset
   195
}
d177340ed556 (svn r40) Final slope graphics fix
dominik
parents: 0
diff changeset
   196
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   197
static int32 ClearTile_Unmovable(TileIndex tile, byte flags)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
{
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   199
	if (IsCompanyHQ(tile)) {
4060
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
   200
		if (_current_player == OWNER_WATER) {
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
   201
			return DestroyCompanyHQ(GetTileOwner(tile), DC_EXEC);
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
   202
		} else {
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
   203
			return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
215196195b2a (svn r5348) -Fix: A HQ could only be flooded at its northern tile, the other 3 were immune to water
tron
parents: 3657
diff changeset
   204
		}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   205
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   207
	if (IsOwnedLand(tile)) {
3491
4c8427796c64 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3427
diff changeset
   208
		return DoCommand(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   209
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 147
diff changeset
   211
	// checks if you're allowed to remove unmovable things
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 147
diff changeset
   212
	if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 147
diff changeset
   213
		return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   214
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   215
	if (flags & DC_EXEC) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
		DoClearSquare(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   222
static void GetAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
	uint level; // HQ level (depends on company performance) in the range 1..5.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   226
	if (!IsCompanyHQ(tile)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
	/* HQ accepts passenger and mail; but we have to divide the values
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
	 * between 4 tiles it occupies! */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   231
	level = GetCompanyHQSize(tile) + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
	// Top town building generates 10, so to make HQ interesting, the top
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
	// type makes 20.
473
0da86c59e3ae (svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents: 410
diff changeset
   235
	ac[CT_PASSENGERS] = max(1, level);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
	// Top town building generates 4, HQ can make up to 8. The
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
	// proportion passengers:mail is different because such a huge
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
	// commercial building generates unusually high amount of mail
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
	// correspondence per physical visitor.
473
0da86c59e3ae (svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents: 410
diff changeset
   241
	ac[CT_MAIL] = max(1, level / 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   243
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   245
static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
{
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   247
	switch (GetUnmovableType(tile)) {
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   248
		case UNMOVABLE_TRANSMITTER: td->str = STR_5801_TRANSMITTER; break;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   249
		case UNMOVABLE_LIGHTHOUSE:  td->str = STR_5802_LIGHTHOUSE; break;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   250
		case UNMOVABLE_STATUE:      td->str = STR_2016_STATUE; break;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   251
		case UNMOVABLE_OWNED_LAND:  td->str = STR_5805_COMPANY_OWNED_LAND; break;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   252
		default:                    td->str = STR_5803_COMPANY_HEADQUARTERS; break;
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   253
	}
1901
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   254
	td->owner = GetTileOwner(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   257
static void AnimateTile_Unmovable(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
	/* not used */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   262
static void TileLoop_Unmovable(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
{
2150
010d923a81a9 (svn r2660) Get rid of some more shifting/anding/casting
tron
parents: 2148
diff changeset
   264
	uint level; // HQ level (depends on company performance) in the range 1..5.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
	uint32 r;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   267
	if (!IsCompanyHQ(tile)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
	/* HQ accepts passenger and mail; but we have to divide the values
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
	 * between 4 tiles it occupies! */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   272
	level = GetCompanyHQSize(tile) + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
	assert(level < 6);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
	r = Random();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
	// Top town buildings generate 250, so the top HQ type makes 256.
2150
010d923a81a9 (svn r2660) Get rid of some more shifting/anding/casting
tron
parents: 2148
diff changeset
   277
	if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
010d923a81a9 (svn r2660) Get rid of some more shifting/anding/casting
tron
parents: 2148
diff changeset
   278
		uint amt = GB(r, 0, 8) / 8 / 4 + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
		if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
		MoveGoodsToStation(tile, 2, 2, CT_PASSENGERS, amt);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
	// Top town building generates 90, HQ can make up to 196. The
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
	// proportion passengers:mail is about the same as in the acceptance
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	// equations.
2150
010d923a81a9 (svn r2660) Get rid of some more shifting/anding/casting
tron
parents: 2148
diff changeset
   286
	if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
010d923a81a9 (svn r2660) Get rid of some more shifting/anding/casting
tron
parents: 2148
diff changeset
   287
		uint amt = GB(r, 8, 8) / 8 / 4 + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
		if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
		MoveGoodsToStation(tile, 2, 2, CT_MAIL, amt);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   294
static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   299
static void ClickTile_Unmovable(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
{
3427
98d955156735 (svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
celestar
parents: 3422
diff changeset
   301
	if (IsCompanyHQ(tile)) ShowPlayerCompany(GetTileOwner(tile));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
/* checks, if a radio tower is within a 9x9 tile square around tile */
4083
990d8f571180 (svn r5398) Rename checkRadioTowerNearby() to IsRadioTowerNearby() and flip its return value to make it a bit less ambiguous
tron
parents: 4077
diff changeset
   306
static bool IsRadioTowerNearby(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
{
1981
de031d2aed47 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1980
diff changeset
   308
	TileIndex tile_s = tile - TileDiffXY(4, 4);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
4083
990d8f571180 (svn r5398) Rename checkRadioTowerNearby() to IsRadioTowerNearby() and flip its return value to make it a bit less ambiguous
tron
parents: 4077
diff changeset
   311
		if (IsTransmitterTile(tile)) return true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
	END_TILE_LOOP(tile, 9, 9, tile_s)
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   313
4083
990d8f571180 (svn r5398) Rename checkRadioTowerNearby() to IsRadioTowerNearby() and flip its return value to make it a bit less ambiguous
tron
parents: 4077
diff changeset
   314
	return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1059
diff changeset
   317
void GenerateUnmovables(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
{
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   319
	int i, li, j, loop_count;
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
   320
	TileIndex tile;
1335
a635854c23b6 (svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents: 1225
diff changeset
   321
	uint h;
3164
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   322
	uint maxx;
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   323
	uint maxy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2893
diff changeset
   325
	if (_opt.landscape == LT_CANDY) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
	/* add radio tower */
1202
7d8b86bd8ba2 (svn r1706) Implement ScaleByMapSize() and ScaleByMapSize1D()
tron
parents: 1093
diff changeset
   328
	i = ScaleByMapSize(1000);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   329
	j = ScaleByMapSize(15); // maximum number of radio towers on the map
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   330
	li = ScaleByMapSize1D((Random() & 3) + 7);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   331
	SetGeneratingWorldProgress(GWP_UNMOVABLE, j + li);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   332
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
	do {
2051
44b6b091beb3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2049
diff changeset
   334
		tile = RandomTile();
3645
86af43f87885 (svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents: 3636
diff changeset
   335
		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4) {
4083
990d8f571180 (svn r5398) Rename checkRadioTowerNearby() to IsRadioTowerNearby() and flip its return value to make it a bit less ambiguous
tron
parents: 4077
diff changeset
   336
			if (IsRadioTowerNearby(tile)) continue;
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   337
			MakeTransmitter(tile);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   338
			IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2893
diff changeset
   339
			if (--j == 0) break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
	} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2893
diff changeset
   343
	if (_opt.landscape == LT_DESERT) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   344
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
	/* add lighthouses */
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   346
	i = li;
3164
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   347
	maxx = MapMaxX();
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   348
	maxy = MapMaxY();
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   349
	loop_count = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
	do {
3164
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   351
		uint32 r;
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   352
		DiagDirection dir;
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   353
		int perimeter;
3164
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   354
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
restart:
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   356
		/* Avoid infinite loops */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   357
		if (++loop_count > 1000) break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   358
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
		r = Random();
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   360
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   361
		/* Scatter the lighthouses more evenly around the perimeter */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   362
		perimeter = (GB(r, 16, 16) % (2 * (maxx + maxy))) - maxy;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   363
		for (dir = DIAGDIR_NE; perimeter > 0; dir++) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   364
			perimeter -= (DiagDirToAxis(dir) == AXIS_X) ? maxx : maxy;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   365
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   366
3164
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   367
		switch (dir) {
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   368
			default:
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   369
			case DIAGDIR_NE: tile = TileXY(maxx,     r % maxy); break;
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   370
			case DIAGDIR_SE: tile = TileXY(r % maxx, 0);        break;
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   371
			case DIAGDIR_SW: tile = TileXY(0,        r % maxy); break;
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   372
			case DIAGDIR_NW: tile = TileXY(r % maxx, maxy);     break;
22513656d02b (svn r3791) Replace home grown direction handling for placing lighthouses by standard DiagDir
tron
parents: 3017
diff changeset
   373
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
		j = 20;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
		do {
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2893
diff changeset
   376
			if (--j == 0) goto restart;
4559
c853d2440065 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4300
diff changeset
   377
			tile = TILE_MASK(tile + TileOffsByDiagDir(dir));
3636
d87b21df2944 (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   378
		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h <= TILE_HEIGHT * 2));
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   379
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
		assert(tile == TILE_MASK(tile));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
3310
7339b2b1e957 (svn r4073) Add functions to make and test for (most) unmovable tiles
tron
parents: 3282
diff changeset
   382
		MakeLighthouse(tile);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4231
diff changeset
   383
		IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
	} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   387
static void ChangeTileOwner_Unmovable(TileIndex tile, PlayerID old_player, PlayerID new_player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
{
1901
fb05044cf5c3 (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents: 1891
diff changeset
   389
	if (!IsTileOwner(tile, old_player)) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 160
diff changeset
   390
4848
56549aa3e234 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4559
diff changeset
   391
	if (IsOwnedLand(tile) && new_player != PLAYER_SPECTATOR) {
1902
5d653da1abb7 (svn r2408) Introduce SetTileOwner() and use it
tron
parents: 1901
diff changeset
   392
		SetTileOwner(tile, new_player);
2026
02dfa0aa2c2f (svn r2535) Tabs
tron
parents: 1981
diff changeset
   393
	} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
		DoClearSquare(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
const TileTypeProcs _tile_type_unmovable_procs = {
1493
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   399
	DrawTile_Unmovable,             /* draw_tile_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   400
	GetSlopeZ_Unmovable,            /* get_slope_z_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   401
	ClearTile_Unmovable,            /* clear_tile_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   402
	GetAcceptedCargo_Unmovable,     /* get_accepted_cargo_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   403
	GetTileDesc_Unmovable,          /* get_tile_desc_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   404
	GetTileTrackStatus_Unmovable,   /* get_tile_track_status_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   405
	ClickTile_Unmovable,            /* click_tile_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   406
	AnimateTile_Unmovable,          /* animate_tile_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   407
	TileLoop_Unmovable,             /* tile_loop_clear */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   408
	ChangeTileOwner_Unmovable,      /* change_tile_owner_clear */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   409
	NULL,                           /* get_produced_cargo_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   410
	NULL,                           /* vehicle_enter_tile_proc */
ea21c3f7feea (svn r1997) Fixed errorneous tab expansion on the indentation side which happenned in r1993. Pointed out by Tron.
pasky
parents: 1489
diff changeset
   411
	GetSlopeTileh_Unmovable,        /* get_slope_tileh_proc */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
};