Changeset - r6257:cacff70f4f56
[Not reviewed]
master
0 5 0
truelight - 17 years ago 2007-03-08 14:34:32
truelight@openttd.org
(svn r9066) -Fix [FS#638]: store the owner of a statue, so when it gets removed, the town is notified of it
5 files changed with 41 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/openttd.cpp
Show inline comments
 
@@ -64,6 +64,7 @@
 
#include "road_map.h"
 
#include "water_map.h"
 
#include "industry_map.h"
 
#include "unmovable_map.h"
 

	
 
#include <stdarg.h>
 

	
 
@@ -1835,6 +1836,14 @@ bool AfterLoadGame()
 

	
 
	if (CheckSavegameVersion(49)) FOR_ALL_PLAYERS(p) p->face = ConvertFromOldPlayerFace(p->face);
 

	
 
	if (CheckSavegameVersion(52)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (IsStatueTile(t)) {
 
				_m[t].m2 = CalcClosestTownFromTile(t, (uint)-1)->index;
 
			}
 
		}
 
	}
 

	
 
	return true;
 
}
 

	
src/saveload.cpp
Show inline comments
 
@@ -28,7 +28,7 @@
 
#include "variables.h"
 
#include <setjmp.h>
 

	
 
extern const uint16 SAVEGAME_VERSION = 51;
 
extern const uint16 SAVEGAME_VERSION = 52;
 
uint16 _sl_version;       ///< the major savegame version identifier
 
byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -1465,7 +1465,7 @@ static void TownActionRoadRebuild(Town* 
 
		NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
 
}
 

	
 
static bool DoBuildStatueOfCompany(TileIndex tile)
 
static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
 
{
 
	PlayerID old;
 
	int32 r;
 
@@ -1485,7 +1485,7 @@ static bool DoBuildStatueOfCompany(TileI
 

	
 
	if (CmdFailed(r)) return false;
 

	
 
	MakeStatue(tile, _current_player);
 
	MakeStatue(tile, _current_player, town_id);
 
	MarkTileDirtyByTile(tile);
 

	
 
	return true;
 
@@ -1493,12 +1493,12 @@ static bool DoBuildStatueOfCompany(TileI
 

	
 
/**
 
 * Search callback function for TownActionBuildStatue
 
 * @param data that is passed by the caller.  In this case, nothing
 
 * @param town_id The town_id for which we want a statue
 
 * @return the result of the test
 
 */
 
static bool SearchTileForStatue(TileIndex tile, uint32 data)
 
static bool SearchTileForStatue(TileIndex tile, uint32 town_id)
 
{
 
	return DoBuildStatueOfCompany(tile);
 
	return DoBuildStatueOfCompany(tile, town_id);
 
}
 

	
 
/**
 
@@ -1510,7 +1510,7 @@ static void TownActionBuildStatue(Town* 
 
{
 
	TileIndex tile = t->xy;
 

	
 
	if (CircularTileSearch(tile, 9, SearchTileForStatue, 0))
 
	if (CircularTileSearch(tile, 9, SearchTileForStatue, t->index))
 
		SETBIT(t->statues, _current_player); ///< Once found and built, "inform" the Town
 
}
 

	
src/unmovable_cmd.cpp
Show inline comments
 
@@ -233,6 +233,12 @@ static int32 ClearTile_Unmovable(TileInd
 
	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 (IsStatue(tile)) {
 
		TownID town = GetStatueTownID(tile);
 
		CLRBIT(GetTown(town)->statues, _current_player);
 
		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		DoClearSquare(tile);
 
	}
src/unmovable_map.h
Show inline comments
 
@@ -54,6 +54,23 @@ static inline bool IsCompanyHQ(TileIndex
 
	return IS_INT_INSIDE(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
 
}
 

	
 
static inline bool IsStatue(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_UNMOVABLE));
 
	return GetUnmovableType(t) == UNMOVABLE_STATUE;
 
}
 

	
 
static inline bool IsStatueTile(TileIndex t)
 
{
 
	return IsTileType(t, MP_UNMOVABLE) && IsStatue(t);
 
}
 

	
 
static inline TownID GetStatueTownID(TileIndex t)
 
{
 
	assert(IsStatue(t));
 
	return _m[t].m2;
 
}
 

	
 
static inline byte GetCompanyHQSize(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
 
@@ -100,9 +117,10 @@ static inline void MakeLighthouse(TileIn
 
	MakeUnmovable(t, UNMOVABLE_LIGHTHOUSE, OWNER_NONE);
 
}
 

	
 
static inline void MakeStatue(TileIndex t, Owner o)
 
static inline void MakeStatue(TileIndex t, Owner o, TownID town_id)
 
{
 
	MakeUnmovable(t, UNMOVABLE_STATUE, o);
 
	_m[t].m2 = town_id;
 
}
 

	
 
static inline void MakeOwnedLand(TileIndex t, Owner o)
0 comments (0 inline, 0 general)