Update: Translations from eints
[openttd-github.git] / src / script / api / script_accounting.hpp
blob04c022e7357e7750913016d117e6d0bf3d8ac27c
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * 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/>.
6 */
8 /** @file script_accounting.hpp Everything to handle script accounting things. */
10 #ifndef SCRIPT_ACCOUNTING_HPP
11 #define SCRIPT_ACCOUNTING_HPP
13 #include "script_object.hpp"
15 /**
16 * Class that keeps track of the costs, so you can request how much a block of
17 * commands did cost in total. Works in both Execute as in Test mode.
18 * @api ai game
19 * Example:
20 * <pre>
21 * {
22 * local costs = ScriptAccounting();
23 * BuildRoad(from_here, to_here);
24 * BuildRoad(from_there, to_there);
25 * print("Costs for route is: " + costs.GetCosts());
26 * }
27 * </pre>
29 class ScriptAccounting : public ScriptObject {
30 public:
31 /**
32 * Creating instance of this class starts counting the costs of commands
33 * from zero. Saves the current value of GetCosts so we can return to
34 * the old value when the instance gets deleted.
36 ScriptAccounting();
38 /**
39 * Restore the ScriptAccounting that was on top when we created this instance.
40 * So basically restore the value of GetCosts to what it was before we
41 * created this instance.
43 ~ScriptAccounting();
45 /**
46 * Get the current value of the costs.
47 * @return The current costs.
48 * @note when nesting ScriptAccounting instances all instances' GetCosts
49 * will always return the value of the 'top' instance.
51 Money GetCosts();
53 /**
54 * Reset the costs to zero.
55 * @note when nesting ScriptAccounting instances all instances' ResetCosts
56 * will always effect on the 'top' instance.
58 void ResetCosts();
60 private:
61 Money last_costs; ///< The last cost we did return.
64 #endif /* SCRIPT_ACCOUNTING_HPP */