mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
This commit is contained in:
parent
f84edec772
commit
ec1117869c
10
water_cmd.c
10
water_cmd.c
@ -148,7 +148,7 @@ static int32 DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
MakeLock(tile, dir);
|
MakeLock(tile, _current_player, dir);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
MarkTileDirtyByTile(tile - delta);
|
MarkTileDirtyByTile(tile - delta);
|
||||||
MarkTileDirtyByTile(tile + delta);
|
MarkTileDirtyByTile(tile + delta);
|
||||||
@ -161,6 +161,8 @@ static int32 RemoveShiplift(TileIndex tile, uint32 flags)
|
|||||||
{
|
{
|
||||||
TileIndexDiff delta = TileOffsByDir(GetLockDirection(tile));
|
TileIndexDiff delta = TileOffsByDir(GetLockDirection(tile));
|
||||||
|
|
||||||
|
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
// make sure no vehicle is on the tile.
|
// make sure no vehicle is on the tile.
|
||||||
if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
|
if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
@ -249,7 +251,11 @@ int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
cost += ret;
|
cost += ret;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
if (TileHeight(tile) == 0) {
|
||||||
MakeWater(tile);
|
MakeWater(tile);
|
||||||
|
} else {
|
||||||
|
MakeCanal(tile, _current_player);
|
||||||
|
}
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
MarkTilesAroundDirty(tile);
|
MarkTilesAroundDirty(tile);
|
||||||
}
|
}
|
||||||
@ -279,6 +285,8 @@ static int32 ClearTile_Water(TileIndex tile, byte flags)
|
|||||||
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
|
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetTileOwner(tile) != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) DoClearSquare(tile);
|
if (flags & DC_EXEC) DoClearSquare(tile);
|
||||||
return _price.clear_water;
|
return _price.clear_water;
|
||||||
|
|
||||||
|
22
water_map.h
22
water_map.h
@ -95,6 +95,16 @@ static inline void MakeShore(TileIndex t)
|
|||||||
_m[t].m5 = 1;
|
_m[t].m5 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void MakeCanal(TileIndex t, Owner o)
|
||||||
|
{
|
||||||
|
SetTileType(t, MP_WATER);
|
||||||
|
SetTileOwner(t, o);
|
||||||
|
_m[t].m2 = 0;
|
||||||
|
_m[t].m3 = 0;
|
||||||
|
_m[t].m4 = 0;
|
||||||
|
_m[t].m5 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a)
|
static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a)
|
||||||
{
|
{
|
||||||
SetTileType(t, MP_WATER);
|
SetTileType(t, MP_WATER);
|
||||||
@ -105,23 +115,23 @@ static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a)
|
|||||||
_m[t].m5 = base + a * 2;
|
_m[t].m5 = base + a * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void MakeLockTile(TileIndex t, byte section)
|
static inline void MakeLockTile(TileIndex t, Owner o, byte section)
|
||||||
{
|
{
|
||||||
SetTileType(t, MP_WATER);
|
SetTileType(t, MP_WATER);
|
||||||
SetTileOwner(t, OWNER_WATER);
|
SetTileOwner(t, o);
|
||||||
_m[t].m2 = 0;
|
_m[t].m2 = 0;
|
||||||
_m[t].m3 = 0;
|
_m[t].m3 = 0;
|
||||||
_m[t].m4 = 0;
|
_m[t].m4 = 0;
|
||||||
_m[t].m5 = section;
|
_m[t].m5 = section;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void MakeLock(TileIndex t, DiagDirection d)
|
static inline void MakeLock(TileIndex t, Owner o, DiagDirection d)
|
||||||
{
|
{
|
||||||
TileIndexDiff delta = TileOffsByDir(d);
|
TileIndexDiff delta = TileOffsByDir(d);
|
||||||
|
|
||||||
MakeLockTile(t, LOCK_MIDDLE + d);
|
MakeLockTile(t, o, LOCK_MIDDLE + d);
|
||||||
MakeLockTile(t - delta, LOCK_LOWER + d);
|
MakeLockTile(t - delta, o, LOCK_LOWER + d);
|
||||||
MakeLockTile(t + delta, LOCK_UPPER + d);
|
MakeLockTile(t + delta, o, LOCK_UPPER + d);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user