# HG changeset patch # User truebrain # Date 1213362451 0 # Node ID d16212cc2394fce92be73f70a8fc36539303802f # Parent 7ccfbff5698db69ca510b4e71f890fddd01a7faf (svn r13506) [NoAI] -Change [API CHANGE]: like AIVehicle, AIStation, .. restrict AISign to only your own signs [NoAI] -Remove [API CHANGE]: the change above makes AISign::GetOwner() obsolete, and is therefor removed diff -r 7ccfbff5698d -r d16212cc2394 bin/ai/regression/regression.nut --- a/bin/ai/regression/regression.nut Thu Jun 12 21:54:34 2008 +0000 +++ b/bin/ai/regression/regression.nut Fri Jun 13 13:07:31 2008 +0000 @@ -879,8 +879,6 @@ print(" IsValidSign(): " + AISign.IsValidSign(i)); print(" GetText(): " + AISign.GetText(i)); print(" GetLocation(): " + AISign.GetLocation(i)); - print(" GetOwner(): " + AISign.GetOwner(i)); - print(" IsMine(): " + AICompany.IsMine(AISign.GetOwner(i))); } print(" Valid Signs: " + j); } diff -r 7ccfbff5698d -r d16212cc2394 bin/ai/regression/regression.txt --- a/bin/ai/regression/regression.txt Thu Jun 12 21:54:34 2008 +0000 +++ b/bin/ai/regression/regression.txt Fri Jun 13 13:07:31 2008 +0000 @@ -5983,32 +5983,22 @@ IsValidSign(): false GetText(): (null : 0x00000000) GetLocation(): -1 - GetOwner(): -1 - IsMine(): false Sign 0 IsValidSign(): true GetText(): Some Sign GetLocation(): 33410 - GetOwner(): 1 - IsMine(): true Sign 1 IsValidSign(): false GetText(): (null : 0x00000000) GetLocation(): -1 - GetOwner(): -1 - IsMine(): false Sign 2 IsValidSign(): false GetText(): (null : 0x00000000) GetLocation(): -1 - GetOwner(): -1 - IsMine(): false Sign 3 IsValidSign(): false GetText(): (null : 0x00000000) GetLocation(): -1 - GetOwner(): -1 - IsMine(): false Valid Signs: 1 --Station-- diff -r 7ccfbff5698d -r d16212cc2394 src/ai/api/ai_sign.cpp --- a/src/ai/api/ai_sign.cpp Thu Jun 12 21:54:34 2008 +0000 +++ b/src/ai/api/ai_sign.cpp Fri Jun 13 13:07:31 2008 +0000 @@ -11,6 +11,7 @@ #include "../../string_func.h" #include "../../strings_func.h" #include "../../tile_map.h" +#include "../../player_func.h" /* static */ SignID AISign::GetMaxSignID() { @@ -19,12 +20,13 @@ /* static */ bool AISign::IsValidSign(SignID sign_id) { - return ::IsValidSignID(sign_id); + return ::IsValidSignID(sign_id) && ::GetSign(sign_id)->owner == _current_player; } /* static */ char *AISign::GetText(SignID sign_id) { if (!IsValidSign(sign_id)) return NULL; + static const int len = 64; char *sign_name = MallocT(len); @@ -37,17 +39,11 @@ /* static */ TileIndex AISign::GetLocation(SignID sign_id) { if (!IsValidSign(sign_id)) return INVALID_TILE; + const Sign *sign = ::GetSign(sign_id); return ::TileVirtXY(sign->x, sign->y); } -/* static */ AICompany::CompanyID AISign::GetOwner(SignID sign_id) -{ - if (!IsValidSign(sign_id)) return AICompany::INVALID_COMPANY; - const Sign *sign = ::GetSign(sign_id); - return (AICompany::CompanyID)(byte)sign->owner; -} - /* static */ bool AISign::RemoveSign(SignID sign_id) { EnforcePrecondition(false, IsValidSign(sign_id)); diff -r 7ccfbff5698d -r d16212cc2394 src/ai/api/ai_sign.hpp --- a/src/ai/api/ai_sign.hpp Thu Jun 12 21:54:34 2008 +0000 +++ b/src/ai/api/ai_sign.hpp Fri Jun 13 13:07:31 2008 +0000 @@ -59,14 +59,6 @@ static TileIndex GetLocation(SignID sign_id); /** - * Get the owner of a sign. - * @param sign_id The sign to get the owner of. - * @pre IsValidSign(sign_id). - * @return The owner of the sign. - */ - static AICompany::CompanyID GetOwner(SignID sign_id); - - /** * Builds a sign on the map. * @param location The place to build the sign. * @param text The text to place on the sign. diff -r 7ccfbff5698d -r d16212cc2394 src/ai/api/ai_sign.hpp.sq --- a/src/ai/api/ai_sign.hpp.sq Thu Jun 12 21:54:34 2008 +0000 +++ b/src/ai/api/ai_sign.hpp.sq Fri Jun 13 13:07:31 2008 +0000 @@ -33,7 +33,6 @@ SQAISign.DefSQStaticMethod(engine, &AISign::IsValidSign, "IsValidSign", 2, "xi"); SQAISign.DefSQStaticMethod(engine, &AISign::GetText, "GetText", 2, "xi"); SQAISign.DefSQStaticMethod(engine, &AISign::GetLocation, "GetLocation", 2, "xi"); - SQAISign.DefSQStaticMethod(engine, &AISign::GetOwner, "GetOwner", 2, "xi"); SQAISign.DefSQStaticMethod(engine, &AISign::BuildSign, "BuildSign", 3, "xis"); SQAISign.DefSQStaticMethod(engine, &AISign::RemoveSign, "RemoveSign", 2, "xi");