mirror of https://github.com/OpenTTD/OpenTTD
(svn r20473) -Codechange: pass Town instead of TownID to BuildObject
parent
61df1a372c
commit
089fc97387
|
@ -28,11 +28,11 @@ void UpdateCompanyHQ(TileIndex tile, uint score);
|
||||||
* @param type The type of object to build.
|
* @param type The type of object to build.
|
||||||
* @param tile The tile to build the northern tile of the object on.
|
* @param tile The tile to build the northern tile of the object on.
|
||||||
* @param owner The owner of the object.
|
* @param owner The owner of the object.
|
||||||
* @param index A (generic) index to be stored on the tile, e.g. TownID for statues.
|
* @param town Town the tile is related with.
|
||||||
* @pre All preconditions for building the object at that location
|
* @pre All preconditions for building the object at that location
|
||||||
* are met, e.g. slope and clearness of tiles are checked.
|
* are met, e.g. slope and clearness of tiles are checked.
|
||||||
*/
|
*/
|
||||||
void BuildObject(ObjectType type, TileIndex tile, CompanyID owner = OWNER_NONE, uint index = 0);
|
void BuildObject(ObjectType type, TileIndex tile, CompanyID owner = OWNER_NONE, struct Town *town = NULL);
|
||||||
|
|
||||||
|
|
||||||
/** Various object behaviours. */
|
/** Various object behaviours. */
|
||||||
|
|
|
@ -46,14 +46,14 @@
|
||||||
return ObjectSpec::Get(GetObjectType(tile));
|
return ObjectSpec::Get(GetObjectType(tile));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, uint index)
|
void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, Town *town)
|
||||||
{
|
{
|
||||||
const ObjectSpec *spec = ObjectSpec::Get(type);
|
const ObjectSpec *spec = ObjectSpec::Get(type);
|
||||||
|
|
||||||
TileArea ta(tile, GB(spec->size, 0, 4), GB(spec->size, 4, 4));
|
TileArea ta(tile, GB(spec->size, 0, 4), GB(spec->size, 4, 4));
|
||||||
TILE_AREA_LOOP(t, ta) {
|
TILE_AREA_LOOP(t, ta) {
|
||||||
TileIndex offset = t - tile;
|
TileIndex offset = t - tile;
|
||||||
MakeObject(t, type, owner, TileY(offset) << 4 | TileX(offset), index, WATER_CLASS_INVALID);
|
MakeObject(t, type, owner, TileY(offset) << 4 | TileX(offset), town == NULL ? 0 : town->index, WATER_CLASS_INVALID);
|
||||||
MarkTileDirtyByTile(t);
|
MarkTileDirtyByTile(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,9 +299,9 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags)
|
||||||
|
|
||||||
case OBJECT_STATUE:
|
case OBJECT_STATUE:
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
TownID town = GetStatueTownID(tile);
|
Town *t = Town::Get(GetStatueTownID(tile));
|
||||||
ClrBit(Town::Get(town)->statues, GetTileOwner(tile));
|
ClrBit(t->statues, GetTileOwner(tile));
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, town);
|
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -492,8 +492,7 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow
|
||||||
if (IsOwnedLand(tile) && new_owner != INVALID_OWNER) {
|
if (IsOwnedLand(tile) && new_owner != INVALID_OWNER) {
|
||||||
SetTileOwner(tile, new_owner);
|
SetTileOwner(tile, new_owner);
|
||||||
} else if (IsStatueTile(tile)) {
|
} else if (IsStatueTile(tile)) {
|
||||||
TownID town = GetStatueTownID(tile);
|
Town *t = Town::Get(GetStatueTownID(tile));
|
||||||
Town *t = Town::Get(town);
|
|
||||||
ClrBit(t->statues, old_owner);
|
ClrBit(t->statues, old_owner);
|
||||||
if (new_owner != INVALID_OWNER && !HasBit(t->statues, new_owner)) {
|
if (new_owner != INVALID_OWNER && !HasBit(t->statues, new_owner)) {
|
||||||
/* Transfer ownership to the new company */
|
/* Transfer ownership to the new company */
|
||||||
|
@ -503,7 +502,7 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, town);
|
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||||
} else {
|
} else {
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2507,7 +2507,7 @@ static CommandCost TownActionBuildStatue(Town *t, DoCommandFlag flags)
|
||||||
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
Backup<CompanyByte> cur_company(_current_company, OWNER_NONE, FILE_LINE);
|
||||||
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
BuildObject(OBJECT_STATUE, tile, _current_company, t->index);
|
BuildObject(OBJECT_STATUE, tile, _current_company, t);
|
||||||
SetBit(t->statues, _current_company); // Once found and built, "inform" the Town.
|
SetBit(t->statues, _current_company); // Once found and built, "inform" the Town.
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue