src/ai/ai_factory.hpp
branchnoai
changeset 9442 1b606e5fac13
parent 9433 d439c1c469f4
child 9443 c29c91993080
equal deleted inserted replaced
9441:03da911c8d5f 9442:1b606e5fac13
    28 	/**
    28 	/**
    29 	 * This registers your AI to the main system so we know about you.
    29 	 * This registers your AI to the main system so we know about you.
    30 	 */
    30 	 */
    31 	void RegisterFactory(const char *name)
    31 	void RegisterFactory(const char *name)
    32 	{
    32 	{
    33 		this->name = name;
       
    34 		/* Don't register nameless Factories */
    33 		/* Don't register nameless Factories */
    35 		if (name == NULL) return;
    34 		if (name == NULL) return;
    36 
    35 
       
    36 		this->name = name;
    37 		std::pair<Factories::iterator, bool> P = GetFactories().insert(Factories::value_type(name, this));
    37 		std::pair<Factories::iterator, bool> P = GetFactories().insert(Factories::value_type(name, this));
    38 		assert(P.second);
    38 		assert(P.second);
    39 	}
    39 	}
    40 
    40 
    41 public:
    41 public:
       
    42 	AIFactoryBase() :
       
    43 		name(NULL)
       
    44 	{}
    42 	virtual ~AIFactoryBase() { if (this->name != NULL) GetFactories().erase(this->name); }
    45 	virtual ~AIFactoryBase() { if (this->name != NULL) GetFactories().erase(this->name); }
    43 
    46 
    44 	/**
    47 	/**
    45 	 * Run all initializers.
    48 	 * Run all initializers.
    46 	 */
    49 	 */