(svn r5349) -Backport: r5315

-Fix: Prohibit altering a road tile while road works are in progress
This fixes some glitches like "turning" the excavation by adding/removing road bits or removing the road piece
This commit is contained in:
tron 2006-06-24 09:12:15 +00:00
parent f0fd9921a2
commit 20b5c17faa
6 changed files with 56 additions and 0 deletions

View File

@ -1450,6 +1450,7 @@ STR_RAILROAD_TRACK_WITH_COMBOSIGNALS :Railway track w
##id 0x1800
STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION :{WHITE}Land sloped in wrong direction for road
STR_1801_MUST_REMOVE_ROAD_FIRST :{WHITE}Must remove road first
STR_ROAD_WORKS_IN_PROGRESS :{WHITE}Road works in progress
STR_1802_ROAD_CONSTRUCTION :{WHITE}Road Construction
STR_1803_SELECT_ROAD_BRIDGE :{WHITE}Select Road Bridge
STR_1804_CAN_T_BUILD_ROAD_HERE :{WHITE}Can't build road here...

View File

@ -1452,6 +1452,7 @@ STR_RAILROAD_TRACK_WITH_COMBOSIGNALS :Gleis mit kombi
##id 0x1800
STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION :{WHITE}Das Land neigt sich in die falsche Richtung
STR_1801_MUST_REMOVE_ROAD_FIRST :{WHITE}Straße muss erst entfernt werden
STR_ROAD_WORKS_IN_PROGRESS :{WHITE}Straßenarbeiten sind im Gange
STR_1802_ROAD_CONSTRUCTION :{WHITE}Straßenbau
STR_1803_SELECT_ROAD_BRIDGE :{WHITE}Brücke wählen
STR_1804_CAN_T_BUILD_ROAD_HERE :{WHITE}Kann hier keine Straße bauen...

View File

@ -4,6 +4,7 @@
#include "openttd.h"
#include "debug.h"
#include "functions.h"
#include "road_map.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "map.h"
@ -344,6 +345,8 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
(track == TRACK_DIAG1 && m5 == 0x05) ||
(track == TRACK_DIAG2 && m5 == 0x0A) // correct direction?
)) {
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
if (flags & DC_EXEC) {
_m[tile].m3 = GetTileOwner(tile);
SetTileOwner(tile, _current_player);

View File

@ -2,6 +2,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "road_map.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
@ -210,6 +211,8 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if ((ti.map5 & 0xF0) == 0) { // normal road
byte c = pieces, t2;
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
if (ti.tileh != 0 && (ti.map5 == 5 || ti.map5 == 10)) {
c |= (c & 0xC) >> 2;
c |= (c & 0x3) << 2;
@ -372,6 +375,8 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (ti.type == MP_STREET) {
if (!(ti.map5 & 0xF0)) {
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
if ((pieces & (byte)ti.map5) == pieces)
return_cmd_error(STR_1007_ALREADY_BUILT);
existing = ti.map5;

43
road_map.h Normal file
View File

@ -0,0 +1,43 @@
/* $Id$ */
#ifndef ROAD_MAP_H
#define ROAD_MAP_H
#include "macros.h"
#include "tile.h"
typedef enum RoadTileType {
ROAD_TILE_NORMAL,
ROAD_TILE_CROSSING,
ROAD_TILE_DEPOT
} RoadTileType;
static inline RoadTileType GetRoadTileType(TileIndex t)
{
assert(IsTileType(t, MP_STREET));
return (RoadTileType)GB(_m[t].m5, 4, 4);
}
typedef enum Roadside {
ROADSIDE_BARREN = 0,
ROADSIDE_GRASS = 1,
ROADSIDE_PAVED = 2,
ROADSIDE_STREET_LIGHTS = 3,
ROADSIDE_TREES = 5,
ROADSIDE_GRASS_ROAD_WORKS = 6,
ROADSIDE_PAVED_ROAD_WORKS = 7
} Roadside;
static inline Roadside GetRoadside(TileIndex tile)
{
return (Roadside)GB(_m[tile].m4, 4, 3);
}
static inline bool HasRoadWorks(TileIndex t)
{
return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
}
#endif

View File

@ -8,6 +8,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
#include "road_map.h"
#include "slope.h"
#include "table/sprites.h"
#include "table/strings.h"
@ -354,6 +355,8 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
m5 = 0xE0;
} else if (ti.type == MP_STREET) {
if (GetRoadTileType(ti.tile) != ROAD_TILE_NORMAL) goto not_valid_below;
if (HasRoadWorks(ti.tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
if (direction == 0) {
if (ti.map5 != 5) goto not_valid_below;
} else {