From 4cf0f941917536d24bf3f20c642a5d0f402369e0 Mon Sep 17 00:00:00 2001 From: Bukz Date: Sat, 23 Apr 2011 10:11:35 +0000 Subject: [PATCH] onNewMap native alias git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6306 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/docs.cfg | 1 + docs/reference.xml | 4 ++++ source/src/world.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/docs.cfg b/config/docs.cfg index 1910bc85..4b3fffde 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -339,6 +339,7 @@ docremark [The servers are written to the config/servers.cfg file. This menu can docident [version] [Gets an integer representing the game version. READ ONLY]; docremark [As example, version 1.0 is represented as value 1000.]; docident [writecfg] [writes current configuration to config/saved.cfg - automatic on quit]; +docident [onNewMap] [If this alias exists, it will be automatically executed when you start a new map.]; docsection [Gameplay] docident [add2alias] [This will append the passed 2nd argument to any existing content of the alias named in the 1st argument. Several popular aliases have predefined shortcuts using this scriptalias: addOnQuit, addOnLoadOnce, addOnLoadAlways. Check config/scripts.cfg for possible omissions in that list.]; docexample [foo = "one" add2alias foo two echo foo] [Output: one two]; diff --git a/docs/reference.xml b/docs/reference.xml index 142360be..211fcaca 100644 --- a/docs/reference.xml +++ b/docs/reference.xml @@ -3526,6 +3526,10 @@ Output: If disabled, an updated editing binds system is used, see the comments in "/config/resetbinds.cfg" for more info. + + + If this alias exists, it will be automatically executed when you start a new map. + diff --git a/source/src/world.cpp b/source/src/world.cpp index b27f0361..8d64396e 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -496,7 +496,13 @@ bool empty_world(int factor, bool force) // main empty world creation routine void mapenlarge() { if(empty_world(-1, false)) addmsg(SV_NEWMAP, "ri", -1); } void mapshrink() { if(empty_world(-2, false)) addmsg(SV_NEWMAP, "ri", -2); } -void newmap(int i) { if(empty_world(i, false)) addmsg(SV_NEWMAP, "ri", max(i, 0)); } +void newmap(int i) { + if(empty_world(i, false)) + { + addmsg(SV_NEWMAP, "ri", max(i, 0)); + if(identexists("onNewMap")) execute("onNewMap"); + } +} COMMAND(mapenlarge, ARG_NONE); COMMAND(mapshrink, ARG_NONE);