src/ai/api/ai_controller.hpp
branchnoai
changeset 10958 65088d587094
parent 10871 326ee226e9d7
child 11043 e44adcf4ed4d
--- a/src/ai/api/ai_controller.hpp	Fri Jun 13 19:57:25 2008 +0000
+++ b/src/ai/api/ai_controller.hpp	Fri Jun 13 20:19:00 2008 +0000
@@ -5,13 +5,17 @@
 #ifndef AI_CONTROLLER_HPP
 #define AI_CONTROLLER_HPP
 
+#include <map>
+#ifndef AI_SQUIRREL_HPP
+struct ltstr { bool operator()(const char *s1, const char *s2) const { return strcmp(s1, s2) < 0; } };
+#endif /* AI_SQUIRREL_HPP */
+
 /**
  * The Controller, the class each AI should extend. It creates the AI, makes
  *  sure the logic kicks in correctly, and that GetTick() has a valid value.
  */
 class AIController {
-private:
-	uint tick;
+	friend class AISquirrel;
 
 public:
 	static const char *GetClassName() { return "AIController"; }
@@ -70,13 +74,37 @@
 	static void Print(bool error_msg, const char *message);
 
 private:
+	typedef std::map<const char *, const char *, ltstr> LoadedLibraryList;
+
+	uint tick;
 	class Squirrel *engine;
 	HSQOBJECT *SQ_instance;
+	LoadedLibraryList loaded_library;
+	int loaded_library_count;
+	const char *script;
+	const char *class_name;
 
 	/**
 	 * Register all classes that are known inside the NoAI API.
 	 */
 	void RegisterClasses();
+
+	/**
+	 * Check if a library is already loaded. If found, fake_class_name is filled
+	 *  with the fake class name as given via AddLoadedLibrary. If not found,
+	 *  next_number is set to the next number available for the fake namespace.
+	 * @param library_name The library to check if already loaded.
+	 * @param next_number The next available number for a library if not already loaded.
+	 * @param fake_class_name The name the library has if already loaded.
+	 * @param fake_class_name_len The maximum length of fake_class_name.
+	 * @return True if the library is already loaded.
+	 */
+	bool LoadedLibrary(const char *library_name, int *next_number, char *fake_class_name, int fake_class_name_len);
+
+	/**
+	 * Add a library as loaded.
+	 */
+	void AddLoadedLibrary(const char *library_name, const char *fake_class_name);
 };
 
 #endif /* AI_CONTROLLER_HPP */