Fix some daylength issues, possible division by zero in main menu.
[openttd-joker.git] / src / script / api / script_log.hpp
blob4041819462a013885ac40f6e403dc5c93eae3c81
1 /* $Id: script_log.hpp 24957 2013-02-02 19:46:46Z rubidium $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
10 /** @file script_log.hpp Everything to handle and issue log messages. */
12 #ifndef SCRIPT_LOG_HPP
13 #define SCRIPT_LOG_HPP
15 #include "script_object.hpp"
17 /**
18 * Class that handles all log related functions.
19 * @api ai game
21 class ScriptLog : public ScriptObject {
22 /* ScriptController needs access to Enum and Log, in order to keep the flow from
23 * OpenTTD core to script API clear and simple. */
24 friend class ScriptController;
26 public:
27 /**
28 * Log levels; The value is also feed to DEBUG() lvl.
29 * This has no use for you, as script writer.
30 * @api -all
32 enum ScriptLogType {
33 LOG_SQ_ERROR = 0, ///< Squirrel printed an error.
34 LOG_ERROR = 1, ///< User printed an error.
35 LOG_SQ_INFO = 2, ///< Squirrel printed some info.
36 LOG_WARNING = 3, ///< User printed some warning.
37 LOG_INFO = 4, ///< User printed some info.
40 /**
41 * Internal representation of the log-data inside the script.
42 * This has no use for you, as script writer.
43 * @api -all
45 struct LogData {
46 char **lines; ///< The log-lines.
47 ScriptLog::ScriptLogType *type; ///< Per line, which type of log it was.
48 int count; ///< Total amount of log-lines possible.
49 int pos; ///< Current position in lines.
50 int used; ///< Total amount of used log-lines.
53 /**
54 * Print an Info message to the logs.
55 * @param message The message to log.
56 * @note Special characters such as U+0000-U+0019 and U+E000-U+E1FF are not supported and removed or replaced by a question mark. This includes newlines and tabs.
58 static void Info(const char *message);
60 /**
61 * Print a Warning message to the logs.
62 * @param message The message to log.
63 * @note Special characters such as U+0000-U+0019 and U+E000-U+E1FF are not supported and removed or replaced by a question mark. This includes newlines and tabs.
65 static void Warning(const char *message);
67 /**
68 * Print an Error message to the logs.
69 * @param message The message to log.
70 * @note Special characters such as U+0000-U+0019 and U+E000-U+E1FF are not supported and removed or replaced by a question mark. This includes newlines and tabs.
72 static void Error(const char *message);
74 /**
75 * Free the log pointer.
76 * @api -all
78 static void FreeLogPointer();
80 private:
81 /**
82 * Internal command to log the message in a common way.
84 static void Log(ScriptLog::ScriptLogType level, const char *message);
87 #endif /* SCRIPT_LOG_HPP */