Changeset - r149:2fc05d1c9173
[Not reviewed]
master
0 8 0
darkvater - 20 years ago 2004-09-03 17:57:27
darkvater@openttd.org
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
-Fix: [993493] Buildings on water
-Feature: Water floods everything, including vehicles.
8 files changed with 75 insertions and 27 deletions:
0 comments (0 inline, 0 general)
clear_cmd.c
Show inline comments
 
@@ -431,7 +431,7 @@ int32 CmdSellLandArea(int x, int y, uint
 

	
 
	tile = TILE_FROM_XY(x,y);
 

	
 
	if (!CheckTileOwnership(tile))
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 

	
 
	if (!EnsureNoVehicle(tile))
industry_cmd.c
Show inline comments
 
@@ -378,7 +378,14 @@ static int32 ClearTile_Industry(uint til
 
{
 
	Industry *i = DEREF_INDUSTRY(_map2[tile]);
 

	
 
 if ((_current_player == OWNER_WATER || _game_mode != GM_EDITOR) && !_cheats.magic_bulldozer.value) {
 
	/*	* water can destroy industries
 
			* in editor you can bulldoze industries
 
			* with magic_bulldozer cheat you can destroy industries
 
			* (area around OILRIG is water, so water shouldn't flood it
 
	*/
 
	if ((_current_player != OWNER_WATER && _game_mode != GM_EDITOR &&
 
			!_cheats.magic_bulldozer.value) ||
 
			(_current_player == OWNER_WATER && i->type == IT_OIL_RIG) ) {
 
 		SET_DPARAM16(0, STR_4802_COAL_MINE + i->type);
 
		return_cmd_error(STR_4800_IN_THE_WAY);
 
	}
lang/english.txt
Show inline comments
 
@@ -2520,6 +2520,7 @@ STR_B002_OIL_REFINERY_EXPLOSION			:{BLAC
 
STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS:{BLACK}{BIGFONT}Factory destroyed in suspicious circumstances near {TOWN}!
 
STR_B004_UFO_LANDS_NEAR					:{BLACK}{BIGFONT}'UFO' lands near {TOWN}!
 
STR_B005_COAL_MINE_SUBSIDENCE_LEAVES	:{BLACK}{BIGFONT}Coal mine subsidence leaves trail of destruction near {TOWN}!
 
STR_B006_FLOOD_VEHICLE_DESTROYED		:{BLACK}{BIGFONT}Floods!{}At least {COMMA16} presumed missing or dead after deadly floods!
 

	
 
STR_BRIBE_FAILED					:{WHITE}Your attempted bribery has been
 
STR_BRIBE_FAILED_2				:{WHITE}discovered by a regional investigator
rail_cmd.c
Show inline comments
 
@@ -1151,7 +1151,7 @@ int32 CmdConvertRail(int ex, int ey, uin
 

	
 
static int32 RemoveTrainDepot(uint tile, uint32 flags)
 
{
 
	if (!CheckTileOwnership(tile) && !(_current_player==17))
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 

	
 
	if (!EnsureNoVehicle(tile))
road_cmd.c
Show inline comments
 
@@ -630,7 +630,7 @@ int32 CmdBuildRoadDepot(int x, int y, ui
 

	
 
static int32 RemoveRoadDepot(uint tile, uint32 flags)
 
{
 
	if (!CheckTileOwnership(tile))
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 

	
 
	if (!EnsureNoVehicle(tile))
station_cmd.c
Show inline comments
 
@@ -905,7 +905,7 @@ int32 CmdRemoveFromRailroadStation(int x
 
	// make sure the specified tile belongs to the current player, and that it is a railroad station.
 
	if (!IS_TILETYPE(tile, MP_STATION) || _map5[tile] >= 8 || !_patches.nonuniform_stations) return CMD_ERROR;
 
	st = DEREF_STATION(_map2[tile]);
 
	if (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile)) return CMD_ERROR;
 
	if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile))) return CMD_ERROR;
 

	
 
	// if we reached here, it means we can actually delete it. do that.
 
	if (flags & DC_EXEC) {
 
@@ -948,12 +948,15 @@ uint GetStationPlatforms(Station *st, ui
 
}
 

	
 

	
 
static int32 RemoveRailroadStation(Station *st, uint32 flags)
 
static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
 
{
 
	uint tile;
 
	int w,h;
 
	int32 cost;
 

	
 
	/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
 
	if (_current_player == OWNER_WATER && _patches.nonuniform_stations)
 
		return DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION);
 

	
 
	/* Current player owns the station? */
 
	if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
 
		return CMD_ERROR;
 
@@ -2434,7 +2437,7 @@ static int32 ClearTile_Station(uint tile
 
	st = DEREF_STATION(_map2[tile]);
 

	
 
	if (m5 < 8)
 
		return RemoveRailroadStation(st, flags);
 
		return RemoveRailroadStation(st, tile, flags);
 

	
 
	// original airports < 67, new airports between 83 - 114
 
	if (m5 < 0x43 || ( m5 >= 83 && m5 <= 114) )
unmovable_cmd.c
Show inline comments
 
@@ -114,39 +114,24 @@ static uint GetSlopeTileh_Unmovable(Tile
 
static int32 ClearTile_Unmovable(uint tile, byte flags)
 
{
 
	byte m5 = _map5[tile];
 
	//Town *t;
 
		
 
	if (m5 & 0x80) {
 
		if (_current_player == OWNER_WATER) 
 
			return DoCommandByTile(tile, OWNER_WATER, 0, flags, CMD_DESTROY_COMPANY_HQ);
 
			return DoCommandByTile(tile, OWNER_WATER, 0, DC_EXEC, CMD_DESTROY_COMPANY_HQ);
 
		return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
 
	}	
 

	
 
	if (m5 == 3)	// company owned land
 
		return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
 

	
 
	//t = ClosestTownFromTile(tile, _patches.dist_local_authority + 20); 	// needed for town penalty
 

	
 
	// checks if you're allowed to remove unmovable things. no remove under rating "%difficulty setting"
 
	if (_game_mode != GM_EDITOR) {	
 
		if (flags & DC_AUTO || !_cheats.magic_bulldozer.value)
 
			return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
 

	
 
		/*if (!CheckforTownRating(tile, flags, t, UNMOVEABLE_REMOVE)) 
 
			return CMD_ERROR;
 
		*/
 

	
 
	}
 
	// checks if you're allowed to remove unmovable things
 
	if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
 
		return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
 
	
 
	if (flags & DC_EXEC) {	
 
		DoClearSquare(tile);
 
		// decreases the town rating by 250;
 
		/*if (_game_mode != GM_EDITOR) 
 
			ChangeTownRating(t, -250, -100);
 
		*/
 
	}
 

	
 
	// return _price.build_industry*0.34; 
 
	return 0;
 
}
 

	
water_cmd.c
Show inline comments
 
@@ -4,6 +4,9 @@
 
#include "viewport.h"
 
#include "command.h"
 
#include "town.h"
 
#include "news.h"
 

	
 
static void FloodVehicle(Vehicle *v);
 

	
 
bool IsShipDepotTile(TileIndex tile)
 
{
 
@@ -506,11 +509,60 @@ static void TileLoopWaterHelper(uint til
 
		}
 

	
 
		_current_player = OWNER_WATER;
 
		{
 
			Vehicle *v = FindVehicleBetween(tile, tile, 0);
 
			if (v != NULL) {FloodVehicle(v);}
 
		}
 
		if (DoCommandByTile(tile,0,0,DC_EXEC, CMD_LANDSCAPE_CLEAR) != CMD_ERROR)
 
			ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR,OWNER_WATER,0);
 
	}
 
}
 

	
 
static void FloodVehicle(Vehicle *v)
 
{
 
	Vehicle *u;
 
	uint16 pass;
 
	if (!(v->vehstatus & VS_CRASHED)) {
 

	
 
		if (v->type == VEH_Road) {	// flood bus/truck
 
			pass = 1;	// driver
 
			if (v->cargo_type == CT_PASSENGERS)
 
				pass += v->cargo_count;
 

	
 
			v->vehstatus |= VS_CRASHED;
 
			v->u.road.crashed_ctr = 2000;	// max 2220, disappear pretty fast
 
			InvalidateWindow(WC_ROADVEH_LIST, v->owner);
 
		}
 
		
 
		else if (v->type == VEH_Train) {
 
			v = GetFirstVehicleInChain(v);
 
			u = v;
 
			pass = 4;	// driver
 

	
 
			// crash all wagons, and count passangers
 
			BEGIN_ENUM_WAGONS(v)
 
				if (v->cargo_type == CT_PASSENGERS) pass += v->cargo_count;
 
				v->vehstatus |= VS_CRASHED;
 
			END_ENUM_WAGONS(v)
 

	
 
			v = u;
 
			v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
 
			InvalidateWindow(WC_TRAINS_LIST, v->owner);						
 
		}
 

	
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		
 
		SET_DPARAM16(0, pass);
 
		AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
 
			NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
 
			v->index,
 
			0);
 
	}
 
	CreateEffectVehicleRel(v,4,4,8,EV_CRASHED_SMOKE);	// show cool destruction effects
 
	SndPlayVehicleFx(16, v); // create sound
 
}
 

	
 
// called from tunnelbridge_cmd
 
void TileLoop_Water(uint tile)
 
{
0 comments (0 inline, 0 general)