(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
--- 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);
}
--- 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--
--- 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<char>(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));
--- 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.
--- 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");