(svn r21654) -Add: [NoAI] AITown::IsCity() so AIs can find out which towns grow faster than others (Lord Aro)

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
yexo 14 years ago
parent 0d613156e7
commit 399a9641fe

@ -1477,6 +1477,7 @@ function Regression::Town()
print(" GetLocation(): " + AITown.GetLocation(i)); print(" GetLocation(): " + AITown.GetLocation(i));
print(" GetHouseCount(): " + AITown.GetHouseCount(i)); print(" GetHouseCount(): " + AITown.GetHouseCount(i));
print(" GetRating(): " + AITown.GetRating(i, AICompany.COMPANY_SELF)); print(" GetRating(): " + AITown.GetRating(i, AICompany.COMPANY_SELF));
print(" IsCity(): " + AITown.IsCity(i));
} }
print(" Valid Towns: " + j); print(" Valid Towns: " + j);
print(" GetTownCount(): " + AITown.GetTownCount()); print(" GetTownCount(): " + AITown.GetTownCount());

@ -7980,6 +7980,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 15508 GetLocation(): 15508
GetHouseCount(): 30 GetHouseCount(): 30
GetRating(): 0 GetRating(): 0
IsCity(): true
Town 1 Town 1
IsValidTown(): true IsValidTown(): true
GetName(): Trenningville GetName(): Trenningville
@ -7987,6 +7988,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 46751 GetLocation(): 46751
GetHouseCount(): 17 GetHouseCount(): 17
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 2 Town 2
IsValidTown(): true IsValidTown(): true
GetName(): Tonston GetName(): Tonston
@ -7994,6 +7996,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 28365 GetLocation(): 28365
GetHouseCount(): 19 GetHouseCount(): 19
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 3 Town 3
IsValidTown(): true IsValidTown(): true
GetName(): Tunford GetName(): Tunford
@ -8001,6 +8004,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 41895 GetLocation(): 41895
GetHouseCount(): 11 GetHouseCount(): 11
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 4 Town 4
IsValidTown(): true IsValidTown(): true
GetName(): Wruntown GetName(): Wruntown
@ -8008,6 +8012,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 41450 GetLocation(): 41450
GetHouseCount(): 18 GetHouseCount(): 18
GetRating(): 0 GetRating(): 0
IsCity(): true
Town 5 Town 5
IsValidTown(): true IsValidTown(): true
GetName(): Fratston GetName(): Fratston
@ -8015,6 +8020,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 55007 GetLocation(): 55007
GetHouseCount(): 11 GetHouseCount(): 11
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 6 Town 6
IsValidTown(): true IsValidTown(): true
GetName(): Muningville GetName(): Muningville
@ -8022,6 +8028,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 38200 GetLocation(): 38200
GetHouseCount(): 28 GetHouseCount(): 28
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 7 Town 7
IsValidTown(): true IsValidTown(): true
GetName(): Hutford GetName(): Hutford
@ -8029,6 +8036,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 59234 GetLocation(): 59234
GetHouseCount(): 33 GetHouseCount(): 33
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 8 Town 8
IsValidTown(): true IsValidTown(): true
GetName(): Satown GetName(): Satown
@ -8036,6 +8044,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 51267 GetLocation(): 51267
GetHouseCount(): 20 GetHouseCount(): 20
GetRating(): 0 GetRating(): 0
IsCity(): true
Town 9 Town 9
IsValidTown(): true IsValidTown(): true
GetName(): Frindinghattan GetName(): Frindinghattan
@ -8043,6 +8052,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 5825 GetLocation(): 5825
GetHouseCount(): 18 GetHouseCount(): 18
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 10 Town 10
IsValidTown(): true IsValidTown(): true
GetName(): Nuntburg GetName(): Nuntburg
@ -8050,6 +8060,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 6446 GetLocation(): 6446
GetHouseCount(): 26 GetHouseCount(): 26
GetRating(): 6 GetRating(): 6
IsCity(): false
Town 11 Town 11
IsValidTown(): true IsValidTown(): true
GetName(): Fort Frindston GetName(): Fort Frindston
@ -8057,6 +8068,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 14935 GetLocation(): 14935
GetHouseCount(): 13 GetHouseCount(): 13
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 12 Town 12
IsValidTown(): true IsValidTown(): true
GetName(): Gintborough GetName(): Gintborough
@ -8064,6 +8076,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 32740 GetLocation(): 32740
GetHouseCount(): 28 GetHouseCount(): 28
GetRating(): 0 GetRating(): 0
IsCity(): true
Town 13 Town 13
IsValidTown(): true IsValidTown(): true
GetName(): Great Hinninghall GetName(): Great Hinninghall
@ -8071,6 +8084,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 9595 GetLocation(): 9595
GetHouseCount(): 14 GetHouseCount(): 14
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 14 Town 14
IsValidTown(): true IsValidTown(): true
GetName(): Prundinghall GetName(): Prundinghall
@ -8078,6 +8092,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 51298 GetLocation(): 51298
GetHouseCount(): 18 GetHouseCount(): 18
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 15 Town 15
IsValidTown(): true IsValidTown(): true
GetName(): Beningville GetName(): Beningville
@ -8085,6 +8100,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 42338 GetLocation(): 42338
GetHouseCount(): 33 GetHouseCount(): 33
GetRating(): 6 GetRating(): 6
IsCity(): false
Town 16 Town 16
IsValidTown(): true IsValidTown(): true
GetName(): Kennville GetName(): Kennville
@ -8092,6 +8108,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 17345 GetLocation(): 17345
GetHouseCount(): 33 GetHouseCount(): 33
GetRating(): 0 GetRating(): 0
IsCity(): true
Town 17 Town 17
IsValidTown(): true IsValidTown(): true
GetName(): Quarfingfield GetName(): Quarfingfield
@ -8099,6 +8116,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 24252 GetLocation(): 24252
GetHouseCount(): 13 GetHouseCount(): 13
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 18 Town 18
IsValidTown(): true IsValidTown(): true
GetName(): Nefingbridge GetName(): Nefingbridge
@ -8106,6 +8124,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 10574 GetLocation(): 10574
GetHouseCount(): 13 GetHouseCount(): 13
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 19 Town 19
IsValidTown(): true IsValidTown(): true
GetName(): Mendston GetName(): Mendston
@ -8113,6 +8132,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 6511 GetLocation(): 6511
GetHouseCount(): 14 GetHouseCount(): 14
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 20 Town 20
IsValidTown(): true IsValidTown(): true
GetName(): Chenfingbourne GetName(): Chenfingbourne
@ -8120,6 +8140,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 22585 GetLocation(): 22585
GetHouseCount(): 15 GetHouseCount(): 15
GetRating(): 6 GetRating(): 6
IsCity(): true
Town 21 Town 21
IsValidTown(): true IsValidTown(): true
GetName(): Franinghead GetName(): Franinghead
@ -8127,6 +8148,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 9634 GetLocation(): 9634
GetHouseCount(): 27 GetHouseCount(): 27
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 22 Town 22
IsValidTown(): true IsValidTown(): true
GetName(): Natborough GetName(): Natborough
@ -8134,6 +8156,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 51891 GetLocation(): 51891
GetHouseCount(): 12 GetHouseCount(): 12
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 23 Town 23
IsValidTown(): true IsValidTown(): true
GetName(): Larborough GetName(): Larborough
@ -8141,6 +8164,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 59622 GetLocation(): 59622
GetHouseCount(): 27 GetHouseCount(): 27
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 24 Town 24
IsValidTown(): true IsValidTown(): true
GetName(): Little Frutford GetName(): Little Frutford
@ -8148,6 +8172,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 19596 GetLocation(): 19596
GetHouseCount(): 34 GetHouseCount(): 34
GetRating(): 4 GetRating(): 4
IsCity(): true
Town 25 Town 25
IsValidTown(): true IsValidTown(): true
GetName(): Grinnway GetName(): Grinnway
@ -8155,6 +8180,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 16433 GetLocation(): 16433
GetHouseCount(): 15 GetHouseCount(): 15
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 26 Town 26
IsValidTown(): true IsValidTown(): true
GetName(): Beburg GetName(): Beburg
@ -8162,6 +8188,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 39505 GetLocation(): 39505
GetHouseCount(): 18 GetHouseCount(): 18
GetRating(): 0 GetRating(): 0
IsCity(): false
Town 27 Town 27
IsValidTown(): true IsValidTown(): true
GetName(): Fudhattan GetName(): Fudhattan
@ -8169,6 +8196,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetLocation(): 45525 GetLocation(): 45525
GetHouseCount(): 19 GetHouseCount(): 19
GetRating(): 0 GetRating(): 0
IsCity(): false
Valid Towns: 28 Valid Towns: 28
GetTownCount(): 28 GetTownCount(): 28

@ -129,6 +129,13 @@
return ::HasBit(::Town::Get(town_id)->statues, _current_company); return ::HasBit(::Town::Get(town_id)->statues, _current_company);
} }
/* static */ bool AITown::IsCity(TownID town_id)
{
if (!IsValidTown(town_id)) return false;
return ::Town::Get(town_id)->larger_town;
}
/* static */ int AITown::GetRoadReworkDuration(TownID town_id) /* static */ int AITown::GetRoadReworkDuration(TownID town_id)
{ {
if (!IsValidTown(town_id)) return -1; if (!IsValidTown(town_id)) return -1;

@ -226,6 +226,14 @@ public:
*/ */
static bool HasStatue(TownID town_id); static bool HasStatue(TownID town_id);
/**
* Find out if the town is a city.
* @param town_id The town to check.
* @pre IsValidTown(town_id).
* @return True if the town is a city.
*/
static bool IsCity(TownID town_id);
/** /**
* Find out how long the town is undergoing road reconstructions. * Find out how long the town is undergoing road reconstructions.
* @param town_id The town to check. * @param town_id The town to check.

@ -71,6 +71,7 @@ void SQAITown_Register(Squirrel *engine)
SQAITown.DefSQStaticMethod(engine, &AITown::GetDistanceSquareToTile, "GetDistanceSquareToTile", 3, ".ii"); SQAITown.DefSQStaticMethod(engine, &AITown::GetDistanceSquareToTile, "GetDistanceSquareToTile", 3, ".ii");
SQAITown.DefSQStaticMethod(engine, &AITown::IsWithinTownInfluence, "IsWithinTownInfluence", 3, ".ii"); SQAITown.DefSQStaticMethod(engine, &AITown::IsWithinTownInfluence, "IsWithinTownInfluence", 3, ".ii");
SQAITown.DefSQStaticMethod(engine, &AITown::HasStatue, "HasStatue", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &AITown::HasStatue, "HasStatue", 2, ".i");
SQAITown.DefSQStaticMethod(engine, &AITown::IsCity, "IsCity", 2, ".i");
SQAITown.DefSQStaticMethod(engine, &AITown::GetRoadReworkDuration, "GetRoadReworkDuration", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &AITown::GetRoadReworkDuration, "GetRoadReworkDuration", 2, ".i");
SQAITown.DefSQStaticMethod(engine, &AITown::GetExclusiveRightsCompany, "GetExclusiveRightsCompany", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &AITown::GetExclusiveRightsCompany, "GetExclusiveRightsCompany", 2, ".i");
SQAITown.DefSQStaticMethod(engine, &AITown::GetExclusiveRightsDuration, "GetExclusiveRightsDuration", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &AITown::GetExclusiveRightsDuration, "GetExclusiveRightsDuration", 2, ".i");

Loading…
Cancel
Save