diff -r 7629656423cc -r 4c5eedbc3ba9 src/ai/api/ai_accounting.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ai/api/ai_accounting.hpp Sun Mar 18 18:02:27 2007 +0000 @@ -0,0 +1,60 @@ +/* $Id$ */ + +/** @file ai_accounting.hpp everything to handle AI accounting things */ + +#ifndef AI_ACCOUNTING_HPP +#define AI_ACCOUNTING_HPP + +#include "ai_object.hpp" + +/** + * Class that handles all AI accounting related functions. + * Example: + * { + * local costs = AIAccounting(); + * BuildRoad(from_here, to_here); + * BuildRoad(from_there, to_there); + * print("Costs for route is: " + costs.GetCosts()); + * } + */ +class AIAccounting : public AIObject { +private: + int32 last_costs; +public: + /** + * Creating instance of this class starts counting the costs of commands + * from zero. + * @note when the instance is destroyed, he restores the costs that was + * current when the instance was created! + */ + AIAccounting(); + + /** + * Destroying this instance reset the costs to the value it was + * in when the instance was created. + */ + ~AIAccounting(); + + /** + * Get the current value of the costs. + */ + int32 GetCosts(); + + /** + * Reset the costs to zero. + */ + void ResetCosts(); +}; + +#ifdef DEFINE_SQUIRREL_CLASS +void SQAIAccountingRegister(Squirrel *engine) { + DefSQClass SQAIAccounting("AIAccounting"); + SQAIAccounting.PreRegister(engine); + SQAIAccounting.AddConstructor(engine); + SQAIAccounting.DefSQFunction(engine, &AIAccounting::GetCosts, "GetCosts"); + SQAIAccounting.DefSQFunction(engine, &AIAccounting::ResetCosts, "ResetCosts"); + SQAIAccounting.PostRegister(engine); +} +#endif /* SQUIRREL_CLASS */ + +#endif /* AI_ACCOUNTING_HPP */