(svn r24008) -Cleanup/doc: try not to mention (No)AI in script APIs

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 12 years ago
parent e6a828def1
commit 22637f139f

@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file script_accounting.hpp Everything to handle AI accounting things. */
/** @file script_accounting.hpp Everything to handle script accounting things. */
#ifndef SCRIPT_ACCOUNTING_HPP
#define SCRIPT_ACCOUNTING_HPP

@ -20,7 +20,7 @@
*
* @note The random functions are not called Random and RandomRange, because
* RANDOM_DEBUG does some tricky stuff, which messes with those names.
* @note In MP we cannot use Random because that will cause desyncs (AIs are
* @note In MP we cannot use Random because that will cause desyncs (scripts are
* ran on the server only, not on all clients). This means that
* we use InteractiveRandom in MP. Rand() takes care of this for you.
*/

@ -36,7 +36,7 @@
/**
* Helper function to connect a just built bridge to nearby roads.
* @param instance The AI we have to built the road for.
* @param instance The script instance we have to built the road for.
*/
static void _DoCommandReturnBuildBridge2(class ScriptInstance *instance)
{
@ -52,7 +52,7 @@ static void _DoCommandReturnBuildBridge2(class ScriptInstance *instance)
/**
* Helper function to connect a just built bridge to nearby roads.
* @param instance The AI we have to built the road for.
* @param instance The script instance we have to built the road for.
*/
static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
{

@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file script_controller.cpp Implementation of AIControler. */
/** @file script_controller.cpp Implementation of ScriptControler. */
#include "../../stdafx.h"
#include "../../string_func.h"

@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file script_controller.hpp The controller of the AI. */
/** @file script_controller.hpp The controller of the script. */
#ifndef SCRIPT_CONTROLLER_HPP
#define SCRIPT_CONTROLLER_HPP
@ -39,21 +39,21 @@ public:
~ScriptController();
/**
* This function is called to start your AI. Your AI starts here. If you
* return from this function, your AI dies, so make sure that doesn't
* This function is called to start your script. Your script starts here. If you
* return from this function, your script dies, so make sure that doesn't
* happen.
* @note Cannot be called from within your AI.
* @note Cannot be called from within your script.
*/
void Start();
/**
* Find at which tick your AI currently is.
* Find at which tick your script currently is.
* @return returns the current tick.
*/
static uint GetTick();
/**
* Get the number of operations the AI may still execute this tick.
* Get the number of operations the script may still execute this tick.
* @return The amount of operations left to execute.
* @note This number can go negative when certain uninteruptable
* operations are executed. The amount of operations that you go
@ -82,21 +82,21 @@ public:
static uint GetVersion();
/**
* Change the minimum amount of time the AI should be put in suspend mode
* Change the minimum amount of time the script should be put in suspend mode
* when you execute a command. Normally in SP this is 1, and in MP it is
* what ever delay the server has been programmed to delay commands
* (normally between 1 and 5). To give a more 'real' effect to your AI,
* (normally between 1 and 5). To give a more 'real' effect to your script,
* you can control that number here.
* @param ticks The minimum amount of ticks to wait.
* @pre Ticks should be positive. Too big values will influence performance of the AI.
* @pre Ticks should be positive. Too big values will influence performance of the script.
* @note If the number is lower than the MP setting, the MP setting wins.
*/
static void SetCommandDelay(int ticks);
/**
* Sleep for X ticks. The code continues after this line when the X AI ticks
* are passed. Mind that an AI tick is different from in-game ticks and
* differ per AI speed.
* Sleep for X ticks. The code continues after this line when the X script ticks
* are passed. Mind that an script tick is different from in-game ticks and
* differ per script speed.
* @param ticks the ticks to wait
* @pre ticks > 0.
* @post the value of GetTick() will be changed exactly 'ticks' in value after
@ -131,7 +131,7 @@ private:
int loaded_library_count; ///< The amount of libraries.
/**
* Register all classes that are known inside the NoAI API.
* Register all classes that are known inside the script API.
*/
void RegisterClasses();
};

@ -16,7 +16,7 @@
#include <map>
/**
* Helper to write precondition enforcers for the AI API in an abbreviated manner.
* Helper to write precondition enforcers for the script API in an abbreviated manner.
* @param returnval The value to return on failure.
* @param condition The condition that must be obeyed.
*/
@ -27,7 +27,7 @@
}
/**
* Helper to write precondition enforcers for the AI API in an abbreviated manner.
* Helper to write precondition enforcers for the script API in an abbreviated manner.
* @param returnval The value to return on failure.
* @param condition The condition that must be obeyed.
* @param error_code The error code passed to ScriptObject::SetLastError.
@ -83,7 +83,7 @@ public:
ERR_PRECONDITION_STRING_TOO_LONG, // []
/** The company you use is invalid */
ERR_PRECONDITION_INVALID_COMPANY, // []
/** An error returned by a NewGRF. No possibility to get the exact error in an AI readable format */
/** An error returned by a NewGRF. No possibility to get the exact error in an script readable format */
ERR_NEWGRF_SUPPLIED_ERROR, // []
/** Base for general errors */
@ -149,31 +149,31 @@ public:
* Get the error based on the OpenTTD StringID.
* @api -all
* @param internal_string_id The string to convert.
* @return The NoAI equivalent error message.
* @return The script equivalent error message.
*/
static ScriptErrorType StringToError(StringID internal_string_id);
/**
* Map an internal OpenTTD error message to its NoAI equivalent.
* Map an internal OpenTTD error message to its script equivalent.
* @api -all
* @param internal_string_id The OpenTTD StringID used for an error.
* @param ai_error_msg The NoAI equivalent error message.
* @param ai_error_msg The script equivalent error message.
*/
static void RegisterErrorMap(StringID internal_string_id, ScriptErrorType ai_error_msg);
/**
* Map an internal OpenTTD error message to its NoAI equivalent.
* Map an internal OpenTTD error message to its script equivalent.
* @api -all
* @param ai_error_msg The NoAI error message representation.
* @param ai_error_msg The script error message representation.
* @param message The string representation of this error message, used for debug purposes.
*/
static void RegisterErrorMapString(ScriptErrorType ai_error_msg, const char *message);
private:
typedef std::map<StringID, ScriptErrorType> ScriptErrorMap; ///< The type for mapping between error (internal OpenTTD) StringID to the AI error type.
typedef std::map<StringID, ScriptErrorType> ScriptErrorMap; ///< The type for mapping between error (internal OpenTTD) StringID to the script error type.
typedef std::map<ScriptErrorType, const char *> ScriptErrorMapString; ///< The type for mapping between error type and textual representation.
static ScriptErrorMap error_map; ///< The mapping between error (internal OpenTTD) StringID to the AI error type.
static ScriptErrorMap error_map; ///< The mapping between error (internal OpenTTD) StringID to the script error type.
static ScriptErrorMapString error_map_string; ///< The mapping between error type and textual representation.
};

@ -14,7 +14,7 @@
#include <queue>
/** The queue of events for an AI. */
/** The queue of events for a script. */
struct ScriptEventData {
std::queue<ScriptEvent *> stack; ///< The actual queue.
};

@ -79,7 +79,7 @@ protected:
* Class that handles all event related functions.
* @api ai game
* @note it is not needed to create an instance of ScriptEvent to access it, as
* all members are static, and all data is stored AI-wide.
* all members are static, and all data is stored script instance-wide.
*/
class ScriptEventController : public ScriptObject {
public:

@ -31,9 +31,9 @@ ScriptExecMode::ScriptExecMode()
ScriptExecMode::~ScriptExecMode()
{
if (this->GetDoCommandModeInstance() != this) {
/* Ignore this error if the AI already died. */
/* Ignore this error if the script already died. */
if (!ScriptObject::GetActiveInstance()->IsDead()) {
throw Script_FatalError("ScriptExecMode object was removed while it was not the latest AI*Mode object created.");
throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
}
}
this->SetDoCommandMode(this->last_mode, this->last_instance);

@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file script_execmode.hpp Switch the AI to Execute Mode. */
/** @file script_execmode.hpp Switch the script to Execute Mode. */
#ifndef SCRIPT_EXECMODE_HPP
#define SCRIPT_EXECMODE_HPP

@ -30,9 +30,9 @@
* @note The names of the setting for ScriptGameSettings::IsValid and
* ScriptGameSettings::GetValue are the same ones as those that are shown by
* the list_settings command in the in-game console. Settings that are
* string based are NOT supported and AIGAmeSettings::IsValid will return
* string based are NOT supported and GameSettings::IsValid will return
* false for them. These settings will not be supported either because
* they have no relevance for the AI (default client names, server IPs,
* they have no relevance for the script (default client names, server IPs,
* etc.).
*/
class ScriptGameSettings : public ScriptObject {
@ -73,7 +73,7 @@ public:
static bool SetValue(const char *setting, int value);
/**
* Checks whether the given vehicle-type is disabled for AIs.
* Checks whether the given vehicle-type is disabled for companies.
* @param vehicle_type The vehicle-type to check.
* @return True if the vehicle-type is disabled.
* @api -game

@ -64,8 +64,8 @@ public:
class ScriptListSorterValueAscending : public ScriptListSorter {
private:
ScriptList::ScriptListBucket::iterator bucket_iter; ///< The iterator over the list to find the buckets.
ScriptList::AIItemList *bucket_list; ///< The current bucket list we're iterator over.
ScriptList::AIItemList::iterator bucket_list_iter; ///< The iterator over the bucket list.
ScriptList::ScriptItemList *bucket_list; ///< The current bucket list we're iterator over.
ScriptList::ScriptItemList::iterator bucket_list_iter; ///< The iterator over the bucket list.
public:
/**
@ -150,8 +150,8 @@ public:
class ScriptListSorterValueDescending : public ScriptListSorter {
private:
ScriptList::ScriptListBucket::iterator bucket_iter; ///< The iterator over the list to find the buckets.
ScriptList::AIItemList *bucket_list; ///< The current bucket list we're iterator over.
ScriptList::AIItemList::iterator bucket_list_iter; ///< The iterator over the bucket list.
ScriptList::ScriptItemList *bucket_list; ///< The current bucket list we're iterator over.
ScriptList::ScriptItemList::iterator bucket_list_iter; ///< The iterator over the bucket list.
public:
/**
@ -593,9 +593,9 @@ void ScriptList::RemoveTop(int32 count)
default: NOT_REACHED();
case SORT_BY_VALUE:
for (ScriptListBucket::iterator iter = this->buckets.begin(); iter != this->buckets.end(); iter = this->buckets.begin()) {
AIItemList *items = &(*iter).second;
ScriptItemList *items = &(*iter).second;
size_t size = items->size();
for (AIItemList::iterator iter = items->begin(); iter != items->end(); iter = items->begin()) {
for (ScriptItemList::iterator iter = items->begin(); iter != items->end(); iter = items->begin()) {
if (--count < 0) return;
this->RemoveItem(*iter);
/* When the last item is removed from the bucket, the bucket itself is removed.
@ -630,9 +630,9 @@ void ScriptList::RemoveBottom(int32 count)
default: NOT_REACHED();
case SORT_BY_VALUE:
for (ScriptListBucket::reverse_iterator iter = this->buckets.rbegin(); iter != this->buckets.rend(); iter = this->buckets.rbegin()) {
AIItemList *items = &(*iter).second;
ScriptItemList *items = &(*iter).second;
size_t size = items->size();
for (AIItemList::reverse_iterator iter = items->rbegin(); iter != items->rend(); iter = items->rbegin()) {
for (ScriptItemList::reverse_iterator iter = items->rbegin(); iter != items->rend(); iter = items->rbegin()) {
if (--count < 0) return;
this->RemoveItem(*iter);
/* When the last item is removed from the bucket, the bucket itself is removed.

@ -44,9 +44,9 @@ private:
int modifications; ///< Number of modification that has been done. To prevent changing data while valuating.
public:
typedef std::set<int32> AIItemList; ///< The list of items inside the bucket
typedef std::map<int32, AIItemList> ScriptListBucket; ///< The bucket list per value
typedef std::map<int32, int32> ScriptListMap; ///< List per item
typedef std::set<int32> ScriptItemList; ///< The list of items inside the bucket
typedef std::map<int32, ScriptItemList> ScriptListBucket; ///< The bucket list per value
typedef std::map<int32, int32> ScriptListMap; ///< List per item
ScriptListMap items; ///< The items in the list
ScriptListBucket buckets; ///< The items in the list, sorted by value

@ -20,13 +20,13 @@
*/
class ScriptLog : public ScriptObject {
/* ScriptController needs access to Enum and Log, in order to keep the flow from
* OpenTTD core to NoAI API clear and simple. */
* OpenTTD core to script API clear and simple. */
friend class ScriptController;
public:
/**
* Log levels; The value is also feed to DEBUG() lvl.
* This has no use for you, as AI writer.
* This has no use for you, as script writer.
* @api -all
*/
enum ScriptLogType {
@ -38,8 +38,8 @@ public:
};
/**
* Internal representation of the log-data inside the AI.
* This has no use for you, as AI writer.
* Internal representation of the log-data inside the script.
* This has no use for you, as script writer.
* @api -all
*/
struct LogData {

@ -303,13 +303,13 @@ ScriptObject::ActiveInstance::~ActiveInstance()
if (callback != NULL) callback(GetActiveInstance());
return true;
} else if (_networking) {
/* Suspend the AI till the command is really executed. */
/* Suspend the script till the command is really executed. */
throw Script_Suspend(-(int)GetDoCommandDelay(), callback);
} else {
IncreaseDoCommandCosts(res.GetCost());
/* Suspend the AI player for 1+ ticks, so it simulates multiplayer. This
* both avoids confusion when a developer launched his AI in a
/* Suspend the script player for 1+ ticks, so it simulates multiplayer. This
* both avoids confusion when a developer launched his script in a
* multiplayer game, but also gives time for the GUI and human player
* to interact with the game. */
throw Script_Suspend(GetDoCommandDelay(), callback);

@ -67,7 +67,7 @@ public:
protected:
/**
* Executes a raw DoCommand for the AI.
* Executes a raw DoCommand for the script.
*/
static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text = NULL, Script_SuspendCallbackProc *callback = NULL);
@ -117,17 +117,17 @@ protected:
static RailType GetRailType();
/**
* Set the current mode of your AI to this proc.
* Set the current mode of your script to this proc.
*/
static void SetDoCommandMode(ScriptModeProc *proc, ScriptObject *instance);
/**
* Get the current mode your AI is currently under.
* Get the current mode your script is currently under.
*/
static ScriptModeProc *GetDoCommandMode();
/**
* Get the instance of the current mode your AI is currently under.
* Get the instance of the current mode your script is currently under.
*/
static ScriptObject *GetDoCommandModeInstance();
@ -223,7 +223,7 @@ protected:
static int GetCallbackVariable(int index);
/**
* Can we suspend the AI at this moment?
* Can we suspend the script at this moment?
*/
static bool CanSuspend();

@ -544,7 +544,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr
* command has completed before we know the next bits to change we need to
* call the function multiple times. Each time it'll reduce the difference
* between the wanted and the current order.
* @param instance The AI we are doing the callback for.
* @param instance The script instance we are doing the callback for.
*/
static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
{

@ -123,7 +123,7 @@ public:
* Index in the list of orders for a vehicle. The first order has index 0, the second
* order index 1, etc. The current order can be queried by using ORDER_CURRENT. Do not
* use ORDER_INVALID yourself, it's used as return value by for example ResolveOrderPosition.
* @note Automatic orders are hidden from AIs, so OrderPosition 0 will always be the first
* @note Automatic orders are hidden from scripts, so OrderPosition 0 will always be the first
* manual order.
*/
enum OrderPosition {
@ -510,7 +510,7 @@ public:
* @param order_flags The new flags given to the order.
* @pre IsValidVehicleOrder(vehicle_id, order_position).
* @pre AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_position), order_flags).
* @pre (order_flags & AIOF_GOTO_NEAREST_DEPOT) == (GetOrderFlags(vehicle_id, order_position) & AIOF_GOTO_NEAREST_DEPOT).
* @pre (order_flags & OF_GOTO_NEAREST_DEPOT) == (GetOrderFlags(vehicle_id, order_position) & OF_GOTO_NEAREST_DEPOT).
* @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
* @return True if and only if the order was changed.
* @api -game

@ -31,9 +31,9 @@ ScriptTestMode::ScriptTestMode()
ScriptTestMode::~ScriptTestMode()
{
if (this->GetDoCommandModeInstance() != this) {
/* Ignore this error if the AI already died. */
/* Ignore this error if the script already died. */
if (!ScriptObject::GetActiveInstance()->IsDead()) {
throw Script_FatalError("AITestmode object was removed while it was not the latest AI*Mode object created.");
throw Script_FatalError("Testmode object was removed while it was not the latest *Mode object created.");
}
}
this->SetDoCommandMode(this->last_mode, this->last_instance);

@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file script_testmode.hpp Switch the AI to Test Mode. */
/** @file script_testmode.hpp Switch the script instance to Test Mode. */
#ifndef SCRIPT_TESTMODE_HPP
#define SCRIPT_TESTMODE_HPP

@ -47,7 +47,7 @@
/**
* Helper function to connect a just built tunnel to nearby roads.
* @param instance The AI we have to built the road for.
* @param instance The script instance we have to built the road for.
*/
static void _DoCommandReturnBuildTunnel2(class ScriptInstance *instance)
{
@ -63,7 +63,7 @@ static void _DoCommandReturnBuildTunnel2(class ScriptInstance *instance)
/**
* Helper function to connect a just built tunnel to nearby roads.
* @param instance The AI we have to built the road for.
* @param instance The script instance we have to built the road for.
*/
static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance)
{

@ -95,7 +95,7 @@ typedef uint16 GoalID; ///< The ID of a goal.
typedef uint16 GroupID; ///< The ID of a group.
typedef uint16 IndustryID; ///< The ID of an industry.
typedef uint8 IndustryType; ///< The ID of an industry-type.
typedef OverflowSafeInt64 Money; ///< Money, stored in a 32bit/64bit safe way. For AIs money is always in pounds.
typedef OverflowSafeInt64 Money; ///< Money, stored in a 32bit/64bit safe way. For scripts money is always in pounds.
typedef uint16 SignID; ///< The ID of a sign.
typedef uint16 StationID; ///< The ID of a station.
typedef uint16 StringID; ///< The ID of a string.
@ -105,7 +105,7 @@ typedef uint16 TownID; ///< The ID of a town.
typedef uint32 VehicleID; ///< The ID of a vehicle.
/* Types we defined ourself, as the OpenTTD core doesn't have them (yet) */
typedef uint ScriptErrorType; ///< The types of errors inside the NoAI framework.
typedef uint ScriptErrorType;///< The types of errors inside the script framework.
typedef BridgeType BridgeID; ///< The ID of a bridge.
#endif /* SCRIPT_TYPES_HPP */

Loading…
Cancel
Save