diff --git a/docs/script-additions.html b/docs/script-additions.html index a7e3f78e50..46d0661a4a 100644 --- a/docs/script-additions.html +++ b/docs/script-additions.html @@ -95,5 +95,20 @@
Checks whether the given road type is buildable by towns.
+ +

Inflation: GSInflation Class and AIInflation Class

+
+

Static Public Member Functions:

+
+
static int64 GetPriceFactor ()
+
Get the inflation factor for prices.
+
Returns the inflation factor as a fixed point value (16 bits).
+
+
+
static int64 GetPaymentFactor ()
+
Get the inflation factor for payments.
+
Returns the inflation factor as a fixed point value (16 bits).
+
+
diff --git a/src/script/api/CMakeLists.txt b/src/script/api/CMakeLists.txt index 594d3c46a7..4ed00fb20e 100644 --- a/src/script/api/CMakeLists.txt +++ b/src/script/api/CMakeLists.txt @@ -175,6 +175,7 @@ add_files( script_industrylist.hpp script_industrytype.hpp script_industrytypelist.hpp + script_inflation.hpp script_info_docs.hpp script_infrastructure.hpp script_list.hpp @@ -246,6 +247,7 @@ add_files( script_industrylist.cpp script_industrytype.cpp script_industrytypelist.cpp + script_inflation.cpp script_infrastructure.cpp script_list.cpp script_log.cpp diff --git a/src/script/api/script_inflation.cpp b/src/script/api/script_inflation.cpp new file mode 100644 index 0000000000..6b813f2b10 --- /dev/null +++ b/src/script/api/script_inflation.cpp @@ -0,0 +1,24 @@ +/* + * This file is part of OpenTTD. + * 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. + * 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. + * 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 . + */ + +/** @file script_inflation.cpp Implementation of ScriptInflation. */ + +#include "../../stdafx.h" +#include "script_inflation.hpp" +#include "../../economy_func.h" + +#include "../../safeguards.h" + +/* static */ int64 ScriptInflation::GetPriceFactor() +{ + return _economy.inflation_prices; +} + +/* static */ int64 ScriptInflation::GetPaymentFactor() +{ + return _economy.inflation_payment; +} diff --git a/src/script/api/script_inflation.hpp b/src/script/api/script_inflation.hpp new file mode 100644 index 0000000000..a61fe4e595 --- /dev/null +++ b/src/script/api/script_inflation.hpp @@ -0,0 +1,35 @@ +/* + * This file is part of OpenTTD. + * 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. + * 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. + * 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 . + */ + +/** @file script_inflation.hpp Inflation related code. */ + +#ifndef SCRIPT_INFLATION_HPP +#define SCRIPT_INFLATION_HPP + +#include "script_object.hpp" + +/** + * Class that handles inflation related functions. + * @api ai game + * + */ +class ScriptInflation : public ScriptObject { +public: + /** + * Get the inflation factor for prices. + * @return Inflation factor, 16 bit fixed point. + */ + static int64 GetPriceFactor(); + + /** + * Get the inflation factor for payments. + * @return Inflation factor, 16 bit fixed point. + */ + static int64 GetPaymentFactor(); +}; + +#endif /* SCRIPT_INFLATION_HPP */