src/ai/api/ai_controller.cpp
author truebrain
Mon, 30 Jun 2008 12:15:10 +0000
branchnoai
changeset 11097 6967c52c78c5
parent 11079 925e3823a101
child 11098 37d15a8951b8
permissions -rw-r--r--
(svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
9441
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
     1
/* $Id$ */
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
     2
9833
89a64246458f (svn r12496) [NoAI] -Documentation: give the .cpp files a nice uniform format too
truebrain
parents: 9782
diff changeset
     3
/** @file ai_controller.cpp Implementation of AIControler. */
9441
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
     4
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
     5
#include "../../stdafx.h"
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
     6
#include "../../openttd.h"
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9444
diff changeset
     7
#include "../../player_func.h"
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
     8
#include "../../core/alloc_func.hpp"
10958
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
     9
#include "../../string_func.h"
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    10
#include "table/strings.h"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    11
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    12
#include <squirrel.h>
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    13
#include "../../squirrel.hpp"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    14
#include "../../squirrel_helper.hpp"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    15
#include "../../squirrel_class.hpp"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    16
#include "../../squirrel_std.hpp"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    17
#include "ai_controller.hpp"
9444
fd27df7ca2a0 (svn r9260) [NoAI] -Codechange: do the AI threading properly using a mutex and condition signalling.
rubidium
parents: 9441
diff changeset
    18
#include "../ai_threads.h"
10889
ecb77cfc4a10 (svn r13440) [NoAI] -Add: introducing ai/library, a method to load libraries into your AI.
truebrain
parents: 10885
diff changeset
    19
#include "../ai_info.hpp"
9441
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
    20
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    21
/* Convert all AI related classes to Squirrel data.
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    22
 * Note: this line a marker in squirrel_export.sh. Do not change! */
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    23
#include "ai_abstractlist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    24
#include "ai_accounting.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    25
#include "ai_airport.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    26
#include "ai_base.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    27
#include "ai_bridge.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    28
#include "ai_bridgelist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    29
#include "ai_cargo.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    30
#include "ai_cargolist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    31
#include "ai_company.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    32
#include "ai_controller.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    33
#include "ai_date.hpp.sq"
11053
d8d48e076a3f (svn r13610) [NoAI] -Add: AIDepotList giving you a list of the locations of your depots (including hangars).
rubidium
parents: 11051
diff changeset
    34
#include "ai_depotlist.hpp.sq"
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    35
#include "ai_engine.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    36
#include "ai_enginelist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    37
#include "ai_error.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    38
#include "ai_event.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    39
#include "ai_event_types.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    40
#include "ai_execmode.hpp.sq"
10852
f02afc46afa8 (svn r13403) [NoAI] -Add: wrapper to read the game settings directly without *any* promises on the results being stable in the future when OpenTTD changes the semantics.
rubidium
parents: 10650
diff changeset
    41
#include "ai_gamesettings.hpp.sq"
11057
188a9ca6d8de (svn r13614) [NoAI] -Add: AIGroup which allows an AI to manage its vehicle in the context of groups.
rubidium
parents: 11053
diff changeset
    42
#include "ai_group.hpp.sq"
11079
925e3823a101 (svn r13636) [NoAI] -Add: added AIGroupList, to list your groups (Yexo)
truebrain
parents: 11057
diff changeset
    43
#include "ai_grouplist.hpp.sq"
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    44
#include "ai_industry.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    45
#include "ai_industrylist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    46
#include "ai_list.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    47
#include "ai_log.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    48
#include "ai_map.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    49
#include "ai_marine.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    50
#include "ai_order.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    51
#include "ai_road.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    52
#include "ai_sign.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    53
#include "ai_station.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    54
#include "ai_stationlist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    55
#include "ai_subsidy.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    56
#include "ai_subsidylist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    57
#include "ai_testmode.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    58
#include "ai_tile.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    59
#include "ai_tilelist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    60
#include "ai_town.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    61
#include "ai_townlist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    62
#include "ai_transactionmode.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    63
#include "ai_tunnel.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    64
#include "ai_vehicle.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    65
#include "ai_vehiclelist.hpp.sq"
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    66
11097
6967c52c78c5 (svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
truebrain
parents: 11079
diff changeset
    67
/* static */ void AIController::SetCommandDelay(int ticks)
6967c52c78c5 (svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
truebrain
parents: 11079
diff changeset
    68
{
6967c52c78c5 (svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
truebrain
parents: 11079
diff changeset
    69
	if (ticks <= 0) return;
6967c52c78c5 (svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
truebrain
parents: 11079
diff changeset
    70
	AIObject::SetDoCommandDelay(ticks);
6967c52c78c5 (svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
truebrain
parents: 11079
diff changeset
    71
}
6967c52c78c5 (svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
truebrain
parents: 11079
diff changeset
    72
11043
e44adcf4ed4d (svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower.
truebrain
parents: 10973
diff changeset
    73
/* static */ void AIController::Sleep(int ticks)
9441
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
    74
{
11043
e44adcf4ed4d (svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower.
truebrain
parents: 10973
diff changeset
    75
	if (ticks <= 0) {
e44adcf4ed4d (svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower.
truebrain
parents: 10973
diff changeset
    76
		AILog::Warning("Sleep() value should be > 0. Assuming value 1.");
e44adcf4ed4d (svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower.
truebrain
parents: 10973
diff changeset
    77
		ticks = 1;
e44adcf4ed4d (svn r13599) [NoAI] -Fix: AIController::Sleep() should always have a value > 0. Warn people if the value is 0 or lower.
truebrain
parents: 10973
diff changeset
    78
	}
9441
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
    79
	AI_SuspendPlayer(_current_player, ticks);
03da911c8d5f (svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
diff changeset
    80
}
9782
e8d8d8894f23 (svn r12277) [NoAI] -Change: overlay GlobalPointer with local instance access and create sub-node to contain data
truebrain
parents: 9724
diff changeset
    81
e8d8d8894f23 (svn r12277) [NoAI] -Change: overlay GlobalPointer with local instance access and create sub-node to contain data
truebrain
parents: 9724
diff changeset
    82
/* static */ void AIController::Print(bool error_msg, const char *message)
e8d8d8894f23 (svn r12277) [NoAI] -Change: overlay GlobalPointer with local instance access and create sub-node to contain data
truebrain
parents: 9724
diff changeset
    83
{
9851
a5f5a7cf2b61 (svn r12519) [NoAI] -Add: added AILog with Info(), Warning(), and Error()
truebrain
parents: 9833
diff changeset
    84
	AILog::Log(error_msg ? AILog::LOG_SQ_ERROR : AILog::LOG_SQ_INFO, message);
9782
e8d8d8894f23 (svn r12277) [NoAI] -Change: overlay GlobalPointer with local instance access and create sub-node to contain data
truebrain
parents: 9724
diff changeset
    85
}
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    86
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    87
void AIController::RegisterClasses()
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    88
{
10902
57b380ee1607 (svn r13453) [NoAI] -Fix: allow import inside a library (or class, for that matter)
truebrain
parents: 10889
diff changeset
    89
	this->engine->AddMethod("import", &AILibrary::Import, 4, "?ssi");
10889
ecb77cfc4a10 (svn r13440) [NoAI] -Add: introducing ai/library, a method to load libraries into your AI.
truebrain
parents: 10885
diff changeset
    90
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    91
	/* Register all classes */
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    92
	squirrel_register_std(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    93
	SQAIAbstractList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    94
	SQAIAccounting_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    95
	SQAIAirport_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    96
	SQAIBase_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    97
	SQAIBridge_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    98
	SQAIBridgeList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
    99
	SQAIBridgeList_Length_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   100
	SQAICargo_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   101
	SQAICargoList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   102
	SQAICompany_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   103
	SQAIController_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   104
	SQAIDate_Register(this->engine);
11053
d8d48e076a3f (svn r13610) [NoAI] -Add: AIDepotList giving you a list of the locations of your depots (including hangars).
rubidium
parents: 11051
diff changeset
   105
	SQAIDepotList_Register(this->engine);
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   106
	SQAIEngine_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   107
	SQAIEngineList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   108
	SQAIError_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   109
	SQAIEvent_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   110
	SQAIEventCompanyBankrupt_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   111
	SQAIEventCompanyInTrouble_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   112
	SQAIEventCompanyMerger_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   113
	SQAIEventCompanyNew_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   114
	SQAIEventController_Register(this->engine);
10971
aaf89f8c59b9 (svn r13525) [NoAI] -Add: added AIEventEngineAvailable and AIEventStationFirstVehicle
glx
parents: 10958
diff changeset
   115
	SQAIEventEngineAvailable_Register(this->engine);
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   116
	SQAIEventEnginePreview_Register(this->engine);
10879
79c0d0e0e155 (svn r13430) [NoAI] -Add: added AIEventIndustry(Open|CLose)
glx
parents: 10871
diff changeset
   117
	SQAIEventIndustryClose_Register(this->engine);
79c0d0e0e155 (svn r13430) [NoAI] -Add: added AIEventIndustry(Open|CLose)
glx
parents: 10871
diff changeset
   118
	SQAIEventIndustryOpen_Register(this->engine);
10973
8577bc56132c (svn r13527) [NoAI] -Fix (r13525): squirrel_export doesn't like extra semicolon
glx
parents: 10971
diff changeset
   119
	SQAIEventStationFirstVehicle_Register(this->engine);
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   120
	SQAIEventSubsidyAwarded_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   121
	SQAIEventSubsidyExpired_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   122
	SQAIEventSubsidyOffer_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   123
	SQAIEventSubsidyOfferExpired_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   124
	SQAIEventTest_Register(this->engine);
11051
00251d01f070 (svn r13608) [NoAI] -Change [API CHANGE]: renamed AI_ET_CRASHED_VEHICLE to AI_ET_VEHICLE_CRASHED to be more uniform with other events (Yexo)
truebrain
parents: 11043
diff changeset
   125
	SQAIEventVehicleCrashed_Register(this->engine);
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   126
	SQAIEventVehicleLost_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   127
	SQAIEventVehicleUnprofitable_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   128
	SQAIEventVehicleWaitingInDepot_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   129
	SQAIExecMode_Register(this->engine);
10852
f02afc46afa8 (svn r13403) [NoAI] -Add: wrapper to read the game settings directly without *any* promises on the results being stable in the future when OpenTTD changes the semantics.
rubidium
parents: 10650
diff changeset
   130
	SQAIGameSettings_Register(this->engine);
11057
188a9ca6d8de (svn r13614) [NoAI] -Add: AIGroup which allows an AI to manage its vehicle in the context of groups.
rubidium
parents: 11053
diff changeset
   131
	SQAIGroup_Register(this->engine);
11079
925e3823a101 (svn r13636) [NoAI] -Add: added AIGroupList, to list your groups (Yexo)
truebrain
parents: 11057
diff changeset
   132
	SQAIGroupList_Register(this->engine);
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   133
	SQAIIndustry_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   134
	SQAIIndustryList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   135
	SQAIIndustryList_CargoAccepting_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   136
	SQAIIndustryList_CargoProducing_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   137
	SQAIList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   138
	SQAILog_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   139
	SQAIMap_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   140
	SQAIMarine_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   141
	SQAIOrder_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   142
	SQAIRoad_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   143
	SQAISign_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   144
	SQAIStation_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   145
	SQAIStationList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   146
	SQAIStationList_Vehicle_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   147
	SQAISubsidy_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   148
	SQAISubsidyList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   149
	SQAITestMode_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   150
	SQAITile_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   151
	SQAITileList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   152
	SQAITileList_IndustryAccepting_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   153
	SQAITileList_IndustryProducing_Register(this->engine);
10864
9a6616a1dce6 (svn r13415) [NoAI] -Add: added AITileList_StationType, giving all the tiles on which a station of your requested type is, for a given station
truebrain
parents: 10852
diff changeset
   154
	SQAITileList_StationType_Register(this->engine);
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   155
	SQAITown_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   156
	SQAITownList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   157
	SQAITransactionMode_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   158
	SQAITunnel_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   159
	SQAIVehicle_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   160
	SQAIVehicleList_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   161
	SQAIVehicleList_Station_Register(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   162
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   163
	this->engine->SetGlobalPointer(this->engine);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   164
}
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   165
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   166
static void PrintFunc(bool error_msg, const SQChar *message)
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   167
{
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   168
	/* Convert to OpenTTD internal capable string */
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   169
	AIController::Print(error_msg, FS2OTTD(message));
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   170
}
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   171
10958
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   172
AIController::AIController(const char *script, const char *class_name) :
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   173
	tick(0),
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   174
	engine(NULL),
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   175
	SQ_instance(NULL),
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   176
	loaded_library_count(0)
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   177
{
10958
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   178
	this->script = strdup(script);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   179
	this->class_name = strdup(class_name);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   180
}
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   181
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   182
void AIController::Start()
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   183
{
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   184
	assert(this->engine == NULL);
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   185
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   186
	/* Create the Squirrel Engine and assign all required classes and settings */
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   187
	this->engine = new Squirrel();
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   188
	this->engine->SetPrintFunction(&PrintFunc);
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   189
	this->RegisterClasses();
10958
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   190
	if (!this->engine->LoadScript(this->script)) {
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   191
		delete this->engine;
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   192
		this->engine = NULL;
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   193
		return;
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   194
	}
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   195
	/* Create the main-class */
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   196
	this->SQ_instance = MallocT<SQObject>(sizeof(SQObject));
10958
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   197
	if (!this->engine->CreateClassInstance(this->class_name, this, this->SQ_instance)) {
10650
30fc5395b1b8 (svn r13194) [NoAI] -Change [API CHANGE]: split 'main.nut' in 'info.nut' and 'main.nut'. The first contains the information about the AI, the second the AI. This avoid several problems we had. It also speeds up OpenTTD start-up.
truebrain
parents: 10643
diff changeset
   198
		delete this->engine;
30fc5395b1b8 (svn r13194) [NoAI] -Change [API CHANGE]: split 'main.nut' in 'info.nut' and 'main.nut'. The first contains the information about the AI, the second the AI. This avoid several problems we had. It also speeds up OpenTTD start-up.
truebrain
parents: 10643
diff changeset
   199
		this->engine = NULL;
30fc5395b1b8 (svn r13194) [NoAI] -Change [API CHANGE]: split 'main.nut' in 'info.nut' and 'main.nut'. The first contains the information about the AI, the second the AI. This avoid several problems we had. It also speeds up OpenTTD start-up.
truebrain
parents: 10643
diff changeset
   200
		return;
30fc5395b1b8 (svn r13194) [NoAI] -Change [API CHANGE]: split 'main.nut' in 'info.nut' and 'main.nut'. The first contains the information about the AI, the second the AI. This avoid several problems we had. It also speeds up OpenTTD start-up.
truebrain
parents: 10643
diff changeset
   201
	}
10885
415791bee9d7 (svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
truebrain
parents: 10879
diff changeset
   202
415791bee9d7 (svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
truebrain
parents: 10879
diff changeset
   203
	/* Run the constructor first */
415791bee9d7 (svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
truebrain
parents: 10879
diff changeset
   204
	if (this->engine->MethodExists(*this->SQ_instance, "constructor")) {
415791bee9d7 (svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
truebrain
parents: 10879
diff changeset
   205
		this->engine->CallMethod(*this->SQ_instance, "constructor");
415791bee9d7 (svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
truebrain
parents: 10879
diff changeset
   206
	}
11097
6967c52c78c5 (svn r13654) [NoAI] -Change [API CHANGE]: moved AISetting::SetCommandDelay to AIController::SetCommandDelay, as it was silly to have it in a seperate class, while it was part of the controller.
truebrain
parents: 11079
diff changeset
   207
10885
415791bee9d7 (svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
truebrain
parents: 10879
diff changeset
   208
	/* When that is done, start the Start() function */
415791bee9d7 (svn r13436) [NoAI] -Change: call the constructor of the SQ when the ->Start() is called of AIController. This makes sure the SQ code is always executed inside the thread, and not inside the main-thread. This has no change what so ever for AIs.
truebrain
parents: 10879
diff changeset
   209
	this->engine->CallMethod(*this->SQ_instance, "Start");
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   210
}
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   211
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   212
AIController::~AIController()
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   213
{
10650
30fc5395b1b8 (svn r13194) [NoAI] -Change [API CHANGE]: split 'main.nut' in 'info.nut' and 'main.nut'. The first contains the information about the AI, the second the AI. This avoid several problems we had. It also speeds up OpenTTD start-up.
truebrain
parents: 10643
diff changeset
   214
	if (this->engine != NULL) delete this->engine;
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   215
	free(this->SQ_instance);
10958
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   216
	free((void *)this->script);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   217
	free((void *)this->class_name);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   218
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   219
	for (LoadedLibraryList::iterator iter = this->loaded_library.begin(); iter != this->loaded_library.end(); iter++) {
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   220
		free((void *)(*iter).second);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   221
		free((void *)(*iter).first);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   222
	}
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   223
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   224
	this->loaded_library.clear();
10643
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   225
}
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   226
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   227
void AIController::IncreaseTick()
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   228
{
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   229
	this->tick++;
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   230
}
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   231
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   232
uint AIController::GetTick()
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   233
{
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   234
	return this->tick;
970417eef395 (svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents: 9851
diff changeset
   235
}
10958
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   236
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   237
bool AIController::LoadedLibrary(const char *library_name, int *next_number, char *fake_class_name, int fake_class_name_len)
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   238
{
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   239
	LoadedLibraryList::iterator iter = this->loaded_library.find(library_name);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   240
	if (iter == this->loaded_library.end()) {
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   241
		*next_number = ++this->loaded_library_count;
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   242
		return false;
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   243
	}
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   244
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   245
	ttd_strlcpy(fake_class_name, (*iter).second, fake_class_name_len);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   246
	return true;
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   247
}
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   248
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   249
void AIController::AddLoadedLibrary(const char *library_name, const char *fake_class_name)
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   250
{
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   251
	this->loaded_library[strdup(library_name)] = strdup(fake_class_name);
65088d587094 (svn r13512) [NoAI] -Fix: don't load a library over and over, but keep track of which libraries we have loaded (per AI) and re-use it where possible (reduces memory-footprint)
truebrain
parents: 10902
diff changeset
   252
}