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/>.
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"
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.
22 * local costs = ScriptAccounting();
23 * BuildRoad(from_here, to_here);
24 * BuildRoad(from_there, to_there);
25 * print("Costs for route is: " + costs.GetCosts());
29 class ScriptAccounting
: public ScriptObject
{
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.
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.
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.
54 * Reset the costs to zero.
55 * @note when nesting ScriptAccounting instances all instances' ResetCosts
56 * will always effect on the 'top' instance.
61 Money last_costs
; ///< The last cost we did return.
64 #endif /* SCRIPT_ACCOUNTING_HPP */