2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/** @file unmovable_cmd.cpp */
|
|
|
|
|
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"
|
2005-07-20 22:05:13 +00:00
|
|
|
#include "table/sprites.h"
|
2005-07-22 07:02:20 +00:00
|
|
|
#include "functions.h"
|
2007-04-12 13:07:15 +00:00
|
|
|
#include "landscape.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"
|
2006-03-23 20:47:56 +00:00
|
|
|
#include "unmovable_map.h"
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "variables.h"
|
2006-04-24 21:10:56 +00:00
|
|
|
#include "table/unmovable_land.h"
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
#include "genworld.h"
|
2007-02-26 18:25:03 +00:00
|
|
|
#include "bridge.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.
|
2007-04-18 00:41:09 +00:00
|
|
|
* @param pid Player requesting the destruction of his HQ
|
2005-05-12 23:46:01 +00:00
|
|
|
* @param flags docommand flags of calling function
|
2007-04-18 00:41:09 +00:00
|
|
|
* @return cost of the operation
|
2005-05-12 23:46:01 +00:00
|
|
|
*/
|
2007-06-18 10:48:15 +00:00
|
|
|
static CommandCost DestroyCompanyHQ(PlayerID pid, uint32 flags)
|
2005-05-12 23:46:01 +00:00
|
|
|
{
|
2006-06-24 08:08:28 +00:00
|
|
|
Player* p = GetPlayer(pid);
|
2005-05-12 23:46:01 +00:00
|
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
|
|
|
|
|
2006-06-24 08:08:28 +00:00
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
TileIndex t = p->location_of_house;
|
|
|
|
|
|
|
|
DoClearSquare(t + TileDiffXY(0, 0));
|
|
|
|
DoClearSquare(t + TileDiffXY(0, 1));
|
|
|
|
DoClearSquare(t + TileDiffXY(1, 0));
|
|
|
|
DoClearSquare(t + TileDiffXY(1, 1));
|
|
|
|
p->location_of_house = 0; // reset HQ position
|
|
|
|
InvalidateWindow(WC_COMPANY, pid);
|
|
|
|
}
|
2005-05-12 23:46:01 +00:00
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* cost of relocating company is 1% of company value */
|
2007-06-18 21:44:47 +00:00
|
|
|
return CommandCost(CalculateCompanyValue(p) / 100);
|
2005-05-12 23:46:01 +00:00
|
|
|
}
|
|
|
|
|
2006-03-31 08:59:19 +00:00
|
|
|
void UpdateCompanyHQ(Player *p, uint score)
|
|
|
|
{
|
|
|
|
byte val;
|
|
|
|
TileIndex tile = p->location_of_house;
|
|
|
|
|
2006-06-27 21:25:53 +00:00
|
|
|
if (tile == 0) return;
|
2006-03-31 08:59:19 +00:00
|
|
|
|
2006-03-31 09:09:26 +00:00
|
|
|
(val = 0, score < 170) ||
|
|
|
|
(val++, score < 350) ||
|
|
|
|
(val++, score < 520) ||
|
|
|
|
(val++, score < 720) ||
|
|
|
|
(val++, true);
|
2006-03-31 08:59:19 +00:00
|
|
|
|
2006-03-31 09:09:26 +00:00
|
|
|
EnlargeCompanyHQ(tile, val);
|
2006-03-31 08:59:19 +00:00
|
|
|
|
|
|
|
MarkTileDirtyByTile(tile + TileDiffXY(0, 0));
|
|
|
|
MarkTileDirtyByTile(tile + TileDiffXY(0, 1));
|
|
|
|
MarkTileDirtyByTile(tile + TileDiffXY(1, 0));
|
|
|
|
MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
|
|
|
|
}
|
|
|
|
|
2007-06-18 10:48:15 +00:00
|
|
|
extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true);
|
2007-04-04 04:08:47 +00:00
|
|
|
|
2005-05-12 23:46:01 +00:00
|
|
|
/** Build or relocate the HQ. This depends if the HQ is already built or not
|
2006-04-10 07:15:58 +00:00
|
|
|
* @param tile tile where the HQ will be built or relocated to
|
2007-04-04 04:08:47 +00:00
|
|
|
* @param flags type of operation
|
2005-09-30 08:57:12 +00:00
|
|
|
* @param p1 unused
|
2005-05-12 23:46:01 +00:00
|
|
|
* @param p2 unused
|
|
|
|
*/
|
2007-06-18 10:48:15 +00:00
|
|
|
CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
2005-05-12 23:46:01 +00:00
|
|
|
{
|
2005-06-21 16:28:17 +00:00
|
|
|
Player *p = GetPlayer(_current_player);
|
2007-06-18 10:48:15 +00:00
|
|
|
CommandCost cost;
|
2005-05-12 23:46:01 +00:00
|
|
|
|
|
|
|
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
|
|
|
|
|
2007-06-18 19:53:50 +00:00
|
|
|
cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
|
|
|
|
if (CmdFailed(cost)) return cost;
|
2005-05-12 23:46:01 +00:00
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
if (p->location_of_house != 0) { // Moving HQ
|
2007-06-18 19:53:50 +00:00
|
|
|
cost.AddCost(DestroyCompanyHQ(_current_player, flags));
|
2005-05-12 23:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
int score = UpdateCompanyRatingAndValue(p, false);
|
|
|
|
|
|
|
|
p->location_of_house = tile;
|
|
|
|
|
2006-03-31 08:44:53 +00:00
|
|
|
MakeCompanyHQ(tile, _current_player);
|
|
|
|
|
2006-03-31 08:59:19 +00:00
|
|
|
UpdateCompanyHQ(p, score);
|
2006-02-13 21:15:00 +00:00
|
|
|
InvalidateWindow(WC_COMPANY, p->index);
|
2005-05-12 23:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cost;
|
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void DrawTile_Unmovable(TileInfo *ti)
|
|
|
|
{
|
2007-01-14 19:57:49 +00:00
|
|
|
SpriteID image;
|
|
|
|
SpriteID pal;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2006-04-03 12:20:55 +00:00
|
|
|
switch (GetUnmovableType(ti->tile)) {
|
|
|
|
case UNMOVABLE_TRANSMITTER:
|
2006-06-27 21:25:53 +00:00
|
|
|
case UNMOVABLE_LIGHTHOUSE: {
|
|
|
|
const DrawTileUnmovableStruct* dtus;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2006-06-27 21:25:53 +00:00
|
|
|
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
|
|
|
DrawClearLandTile(ti, 2);
|
2006-04-03 12:20:55 +00:00
|
|
|
|
2006-06-27 21:25:53 +00:00
|
|
|
dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
|
2006-04-03 12:20:55 +00:00
|
|
|
|
2006-06-27 21:25:53 +00:00
|
|
|
image = dtus->image;
|
2007-04-05 07:49:04 +00:00
|
|
|
if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
|
2007-01-14 19:57:49 +00:00
|
|
|
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
|
|
|
|
pal = PALETTE_TO_TRANSPARENT;
|
|
|
|
} else {
|
|
|
|
pal = PAL_NONE;
|
|
|
|
}
|
2006-06-27 21:25:53 +00:00
|
|
|
|
|
|
|
AddSortableSpriteToDraw(
|
2007-01-14 19:57:49 +00:00
|
|
|
image, pal, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
|
2006-06-27 21:25:53 +00:00
|
|
|
dtus->width, dtus->height, dtus->z_size, ti->z
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
2006-04-03 12:20:55 +00:00
|
|
|
|
|
|
|
case UNMOVABLE_STATUE:
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
|
|
|
|
|
|
|
|
image = SPR_STATUE_COMPANY;
|
2007-04-05 07:49:04 +00:00
|
|
|
if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
|
2007-01-14 19:57:49 +00:00
|
|
|
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
|
|
|
|
pal = PALETTE_TO_TRANSPARENT;
|
|
|
|
} else {
|
|
|
|
pal = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
|
|
|
|
}
|
|
|
|
AddSortableSpriteToDraw(image, pal, ti->x, ti->y, 16, 16, 25, ti->z);
|
2006-04-03 12:20:55 +00:00
|
|
|
break;
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2006-04-03 12:20:55 +00:00
|
|
|
case UNMOVABLE_OWNED_LAND:
|
2004-08-09 17:04:08 +00:00
|
|
|
DrawClearLandTile(ti, 0);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-01-14 19:57:49 +00:00
|
|
|
image = SPR_BOUGHT_LAND;
|
2007-03-08 15:50:07 +00:00
|
|
|
pal = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
|
2004-08-09 17:04:08 +00:00
|
|
|
AddSortableSpriteToDraw(
|
2007-01-14 19:57:49 +00:00
|
|
|
image, pal,
|
2006-04-23 19:35:36 +00:00
|
|
|
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 10, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
|
2004-08-09 17:04:08 +00:00
|
|
|
);
|
2006-12-27 12:38:02 +00:00
|
|
|
DrawBridgeMiddle(ti);
|
2006-04-03 12:20:55 +00:00
|
|
|
break;
|
2006-06-27 21:25:53 +00:00
|
|
|
|
|
|
|
default: {
|
|
|
|
const DrawTileSeqStruct* dtss;
|
|
|
|
const DrawTileSprites* t;
|
2007-01-14 19:57:49 +00:00
|
|
|
SpriteID palette;
|
2006-06-27 21:25:53 +00:00
|
|
|
|
|
|
|
assert(IsCompanyHQ(ti->tile));
|
|
|
|
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
|
|
|
|
2007-01-14 19:57:49 +00:00
|
|
|
palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
|
2006-06-27 21:25:53 +00:00
|
|
|
|
|
|
|
t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)];
|
2007-01-14 19:57:49 +00:00
|
|
|
DrawGroundSprite(t->ground_sprite, palette);
|
2006-06-27 21:25:53 +00:00
|
|
|
|
|
|
|
foreach_draw_tile_seq(dtss, t->seq) {
|
|
|
|
image = dtss->image;
|
2007-04-05 07:49:04 +00:00
|
|
|
if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
|
2007-01-14 19:57:49 +00:00
|
|
|
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
|
|
|
|
pal = PALETTE_TO_TRANSPARENT;
|
2006-06-27 21:25:53 +00:00
|
|
|
} else {
|
2007-01-14 19:57:49 +00:00
|
|
|
pal = palette;
|
2006-04-03 12:20:55 +00:00
|
|
|
}
|
2006-06-27 21:25:53 +00:00
|
|
|
AddSortableSpriteToDraw(
|
2007-01-14 19:57:49 +00:00
|
|
|
image, pal,
|
2006-08-06 08:23:19 +00:00
|
|
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
|
|
|
dtss->size_x, dtss->size_y,
|
|
|
|
dtss->size_z, ti->z + dtss->delta_z
|
2006-06-27 21:25:53 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-06 16:32:49 +00:00
|
|
|
static uint GetSlopeZ_Unmovable(TileIndex tile, uint x, uint y)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-08-06 16:32:49 +00:00
|
|
|
if (IsOwnedLand(tile)) {
|
|
|
|
uint z;
|
2007-01-10 18:56:51 +00:00
|
|
|
Slope tileh = GetTileSlope(tile, &z);
|
2006-08-06 16:32:49 +00:00
|
|
|
|
|
|
|
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
|
2006-03-21 20:02:05 +00:00
|
|
|
} else {
|
2006-08-06 16:32:49 +00:00
|
|
|
return GetTileMaxZ(tile);
|
2006-03-21 20:02:05 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2006-04-23 13:48:16 +00:00
|
|
|
static Slope GetSlopeTileh_Unmovable(TileIndex tile, Slope tileh)
|
2004-08-13 18:27:33 +00:00
|
|
|
{
|
2006-04-23 13:48:16 +00:00
|
|
|
return IsOwnedLand(tile) ? tileh : SLOPE_FLAT;
|
2004-08-13 18:27:33 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 10:48:15 +00:00
|
|
|
static CommandCost ClearTile_Unmovable(TileIndex tile, byte flags)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-04-03 12:20:55 +00:00
|
|
|
if (IsCompanyHQ(tile)) {
|
2006-06-24 08:08:28 +00:00
|
|
|
if (_current_player == OWNER_WATER) {
|
|
|
|
return DestroyCompanyHQ(GetTileOwner(tile), DC_EXEC);
|
|
|
|
} else {
|
|
|
|
return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
|
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-03-23 20:47:56 +00:00
|
|
|
if (IsOwnedLand(tile)) {
|
2006-04-10 07:15:58 +00:00
|
|
|
return DoCommand(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
|
2006-03-23 20:47:56 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* checks if you're allowed to remove unmovable things */
|
2004-09-03 17:57:27 +00:00
|
|
|
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
|
|
|
|
2007-03-08 14:34:32 +00:00
|
|
|
if (IsStatue(tile)) {
|
|
|
|
TownID town = GetStatueTownID(tile);
|
|
|
|
CLRBIT(GetTown(town)->statues, _current_player);
|
|
|
|
InvalidateWindow(WC_TOWN_AUTHORITY, town);
|
|
|
|
}
|
|
|
|
|
2004-09-10 19:02:27 +00:00
|
|
|
if (flags & DC_EXEC) {
|
2004-08-09 17:04:08 +00:00
|
|
|
DoClearSquare(tile);
|
|
|
|
}
|
|
|
|
|
2007-06-18 19:53:50 +00:00
|
|
|
return CommandCost();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
static void GetAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
uint level; // HQ level (depends on company performance) in the range 1..5.
|
|
|
|
|
2006-04-03 12:20:55 +00:00
|
|
|
if (!IsCompanyHQ(tile)) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* HQ accepts passenger and mail; but we have to divide the values
|
|
|
|
* between 4 tiles it occupies! */
|
|
|
|
|
2006-04-03 12:20:55 +00:00
|
|
|
level = GetCompanyHQSize(tile) + 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* Top town building generates 10, so to make HQ interesting, the top
|
|
|
|
* type makes 20. */
|
2007-01-11 11:05:01 +00:00
|
|
|
ac[CT_PASSENGERS] = max(1U, level);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-04-04 04:08:47 +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. */
|
2007-01-11 11:05:01 +00:00
|
|
|
ac[CT_MAIL] = max(1U, level / 2);
|
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
|
|
|
{
|
2006-03-23 20:47:56 +00:00
|
|
|
switch (GetUnmovableType(tile)) {
|
|
|
|
case UNMOVABLE_TRANSMITTER: td->str = STR_5801_TRANSMITTER; break;
|
|
|
|
case UNMOVABLE_LIGHTHOUSE: td->str = STR_5802_LIGHTHOUSE; break;
|
|
|
|
case UNMOVABLE_STATUE: td->str = STR_2016_STATUE; break;
|
|
|
|
case UNMOVABLE_OWNED_LAND: td->str = STR_5805_COMPANY_OWNED_LAND; break;
|
|
|
|
default: td->str = STR_5803_COMPANY_HEADQUARTERS; break;
|
|
|
|
}
|
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
|
|
|
{
|
2005-07-21 06:31:02 +00:00
|
|
|
uint level; // HQ level (depends on company performance) in the range 1..5.
|
2004-08-09 17:04:08 +00:00
|
|
|
uint32 r;
|
|
|
|
|
2006-04-03 12:20:55 +00:00
|
|
|
if (!IsCompanyHQ(tile)) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* HQ accepts passenger and mail; but we have to divide the values
|
|
|
|
* between 4 tiles it occupies! */
|
|
|
|
|
2006-04-03 12:20:55 +00:00
|
|
|
level = GetCompanyHQSize(tile) + 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
assert(level < 6);
|
|
|
|
|
|
|
|
r = Random();
|
2007-04-04 04:08:47 +00:00
|
|
|
/* Top town buildings generate 250, so the top HQ type makes 256. */
|
2005-07-21 06:31:02 +00:00
|
|
|
if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
|
|
|
|
uint amt = GB(r, 0, 8) / 8 / 4 + 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
|
|
|
MoveGoodsToStation(tile, 2, 2, CT_PASSENGERS, amt);
|
|
|
|
}
|
|
|
|
|
2007-04-04 04:08:47 +00:00
|
|
|
/* Top town building generates 90, HQ can make up to 196. The
|
|
|
|
* proportion passengers:mail is about the same as in the acceptance
|
|
|
|
* equations. */
|
2005-07-21 06:31:02 +00:00
|
|
|
if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
|
|
|
|
uint amt = GB(r, 8, 8) / 8 / 4 + 1;
|
2004-08-09 17:04:08 +00:00
|
|
|
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
|
|
|
|
MoveGoodsToStation(tile, 2, 2, CT_MAIL, amt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-24 22:41:50 +00:00
|
|
|
static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_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
|
|
|
{
|
2006-04-03 12:20:55 +00:00
|
|
|
if (IsCompanyHQ(tile)) ShowPlayerCompany(GetTileOwner(tile));
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* checks, if a radio tower is within a 9x9 tile square around tile */
|
2006-06-28 06:17:41 +00:00
|
|
|
static bool IsRadioTowerNearby(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)
|
2006-06-28 06:17:41 +00:00
|
|
|
if (IsTransmitterTile(tile)) return true;
|
2004-08-09 17:04:08 +00:00
|
|
|
END_TILE_LOOP(tile, 9, 9, tile_s)
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
2006-06-28 06:17:41 +00:00
|
|
|
return false;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void GenerateUnmovables()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
int i, li, j, loop_count;
|
2005-06-24 12:38:35 +00:00
|
|
|
TileIndex tile;
|
2005-02-07 10:41:45 +00:00
|
|
|
uint h;
|
2006-03-08 12:26:56 +00:00
|
|
|
uint maxx;
|
|
|
|
uint maxy;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-22 03:42:43 +00:00
|
|
|
if (_opt.landscape == LT_TOYLAND) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* add radio tower */
|
2005-01-28 15:31:04 +00:00
|
|
|
i = ScaleByMapSize(1000);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
j = ScaleByMapSize(15); // maximum number of radio towers on the map
|
|
|
|
li = ScaleByMapSize1D((Random() & 3) + 7);
|
|
|
|
SetGeneratingWorldProgress(GWP_UNMOVABLE, j + li);
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
do {
|
2005-07-13 19:51:31 +00:00
|
|
|
tile = RandomTile();
|
2006-04-23 19:35:36 +00:00
|
|
|
if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h >= TILE_HEIGHT * 4) {
|
2006-06-28 06:17:41 +00:00
|
|
|
if (IsRadioTowerNearby(tile)) continue;
|
2006-03-23 20:47:56 +00:00
|
|
|
MakeTransmitter(tile);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
|
2006-02-01 06:32:03 +00:00
|
|
|
if (--j == 0) break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
} while (--i);
|
|
|
|
|
2007-03-22 03:42:43 +00:00
|
|
|
if (_opt.landscape == LT_TROPIC) return;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
/* add lighthouses */
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
i = li;
|
2006-03-08 12:26:56 +00:00
|
|
|
maxx = MapMaxX();
|
|
|
|
maxy = MapMaxY();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
loop_count = 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
do {
|
2006-03-08 12:26:56 +00:00
|
|
|
uint32 r;
|
|
|
|
DiagDirection dir;
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
int perimeter;
|
2006-03-08 12:26:56 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
restart:
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
/* Avoid infinite loops */
|
|
|
|
if (++loop_count > 1000) break;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
r = Random();
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
|
|
|
|
/* Scatter the lighthouses more evenly around the perimeter */
|
|
|
|
perimeter = (GB(r, 16, 16) % (2 * (maxx + maxy))) - maxy;
|
|
|
|
for (dir = DIAGDIR_NE; perimeter > 0; dir++) {
|
|
|
|
perimeter -= (DiagDirToAxis(dir) == AXIS_X) ? maxx : maxy;
|
|
|
|
}
|
|
|
|
|
2006-03-08 12:26:56 +00:00
|
|
|
switch (dir) {
|
|
|
|
default:
|
|
|
|
case DIAGDIR_NE: tile = TileXY(maxx, r % maxy); break;
|
|
|
|
case DIAGDIR_SE: tile = TileXY(r % maxx, 0); break;
|
|
|
|
case DIAGDIR_SW: tile = TileXY(0, r % maxy); break;
|
|
|
|
case DIAGDIR_NW: tile = TileXY(r % maxx, maxy); break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
j = 20;
|
|
|
|
do {
|
2006-02-01 06:32:03 +00:00
|
|
|
if (--j == 0) goto restart;
|
2006-09-05 23:21:41 +00:00
|
|
|
tile = TILE_MASK(tile + TileOffsByDiagDir(dir));
|
2006-04-23 13:48:16 +00:00
|
|
|
} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == SLOPE_FLAT && h <= TILE_HEIGHT * 2));
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
assert(tile == TILE_MASK(tile));
|
|
|
|
|
2006-03-23 20:47:56 +00:00
|
|
|
MakeLighthouse(tile);
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
|
2004-08-09 17:04:08 +00:00
|
|
|
} while (--i);
|
|
|
|
}
|
|
|
|
|
2005-09-18 20:56:44 +00:00
|
|
|
static void ChangeTileOwner_Unmovable(TileIndex tile, PlayerID old_player, PlayerID 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
|
|
|
|
2006-10-14 15:49:43 +00:00
|
|
|
if (IsOwnedLand(tile) && new_player != PLAYER_SPECTATOR) {
|
2005-06-04 12:13:24 +00:00
|
|
|
SetTileOwner(tile, new_player);
|
2005-07-08 22:25:24 +00:00
|
|
|
} else {
|
2004-08-09 17:04:08 +00:00
|
|
|
DoClearSquare(tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
extern 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 */
|
|
|
|
GetSlopeTileh_Unmovable, /* get_slope_tileh_proc */
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|