Changeset - r19387:3bdce61e5d37
[Not reviewed]
master
0 1 0
frosch - 12 years ago 2012-05-30 14:54:44
frosch@openttd.org
(svn r24302) -Fix: [Script] ScriptTown::GetGrowthRate() returned wrong values after usage of SetGrowthRate().
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_town.cpp
Show inline comments
 
@@ -131,49 +131,49 @@
 
		case TOWN_GROWTH_DESERT:
 
			if (GetTropicZone(t->xy) == TROPICZONE_DESERT && t->cache.population > 60) return 1;
 
			return 0;
 

	
 
		default: return t->goal[towneffect_id];
 
	}
 
}
 

	
 
/* static */ bool ScriptTown::SetGrowthRate(TownID town_id, uint16 days_between_town_growth)
 
{
 
	days_between_town_growth = days_between_town_growth * DAY_TICKS / TOWN_GROWTH_TICKS;
 

	
 
	EnforcePrecondition(false, IsValidTown(town_id));
 
	EnforcePrecondition(false, (days_between_town_growth & TOWN_GROW_RATE_CUSTOM) == 0);
 

	
 
	return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, days_between_town_growth, CMD_TOWN_GROWTH_RATE);
 
}
 

	
 
/* static */ int32 ScriptTown::GetGrowthRate(TownID town_id)
 
{
 
	if (!IsValidTown(town_id)) return false;
 

	
 
	const Town *t = ::Town::Get(town_id);
 

	
 
	return (t->growth_rate * TOWN_GROWTH_TICKS + DAY_TICKS) / DAY_TICKS;
 
	return ((t->growth_rate & ~TOWN_GROW_RATE_CUSTOM) * TOWN_GROWTH_TICKS + DAY_TICKS) / DAY_TICKS;
 
}
 

	
 
/* static */ int32 ScriptTown::GetDistanceManhattanToTile(TownID town_id, TileIndex tile)
 
{
 
	return ScriptMap::DistanceManhattan(tile, GetLocation(town_id));
 
}
 

	
 
/* static */ int32 ScriptTown::GetDistanceSquareToTile(TownID town_id, TileIndex tile)
 
{
 
	return ScriptMap::DistanceSquare(tile, GetLocation(town_id));
 
}
 

	
 
/* static */ bool ScriptTown::IsWithinTownInfluence(TownID town_id, TileIndex tile)
 
{
 
	if (!IsValidTown(town_id)) return false;
 

	
 
	const Town *t = ::Town::Get(town_id);
 
	return ((uint32)GetDistanceSquareToTile(town_id, tile) <= t->cache.squared_town_zone_radius[0]);
 
}
 

	
 
/* static */ bool ScriptTown::HasStatue(TownID town_id)
 
{
 
	if (ScriptObject::GetCompany() == OWNER_DEITY) return false;
 
	if (!IsValidTown(town_id)) return false;
0 comments (0 inline, 0 general)