summaryrefslogtreecommitdiff
path: root/src/game/game_core.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 20:59:36 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 20:59:36 +0000
commit77b7366c2947a3f2545d5542021be1cc203a74e8 (patch)
tree5fac077be3e90460822aa50987f903fb8f86a7aa /src/game/game_core.cpp
parente7cd301d3c9990b4ef9f0748789bb5e0318c0d24 (diff)
downloadopenttd-77b7366c2947a3f2545d5542021be1cc203a74e8.tar.xz
(svn r23622) -Add: a set of events to trigger in a GameScript
Diffstat (limited to 'src/game/game_core.cpp')
-rw-r--r--src/game/game_core.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp
index 13f9cb47d..9fd579599 100644
--- a/src/game/game_core.cpp
+++ b/src/game/game_core.cpp
@@ -109,6 +109,31 @@
}
}
+/* static */ void Game::NewEvent(ScriptEvent *event)
+{
+ /* AddRef() and Release() need to be called at least once, so do it here */
+ event->AddRef();
+
+ /* Clients should ignore events */
+ if (_networking && !_network_server) {
+ event->Release();
+ return;
+ }
+
+ /* Check if Game instance is alive */
+ if (Game::instance == NULL) {
+ event->Release();
+ return;
+ }
+
+ /* Queue the event */
+ Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
+ Game::instance->InsertEvent(event);
+ cur_company.Restore();
+
+ event->Release();
+}
+
/* static */ void Game::ResetConfig()
{
/* Check for both newgame as current game if we can reload the GameInfo insde