From 54d5f7e577db0639e42b18beae4b5c87af6d6843 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Fri, 4 Mar 2011 18:35:17 +0100 Subject: Implemented persistent world and map variables The gameserver now receive a copy of all world state variables when they are accepted by the accountserver and receive a copy of all map state variables of a map when they register it successfully. Implemented LUA script bindings for getting and setting these variables. When such a variable is set, the accountserver is notified about this change. Changes to world state variables are then propagated to all gameservers by the accountserver. Be aware that when a gameserver is updating a map, there is no check if it is actually responsible for said map. But I consider this not a security flaw, because authenticated game servers are considered to be trustworthy in a lot of other situations, too. Also renamed "quest" to "character variable" in the sourcecode. Reviewed-by: Bertram --- src/scripting/lua.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 76280242..f55b96d1 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1080,6 +1080,92 @@ static int chr_get_quest(lua_State *s) return 0; } + +/** + * gets the value of a persistent map variable. + * mana.getvar_map(string): string + */ + static int getvar_map(lua_State *s) +{ + const char *m = luaL_checkstring(s, 1); + if (m[0] == 0) + { + raiseScriptError(s, "getvar_map called for unnamed variable."); + return 0; + } + + lua_pushlightuserdata(s, (void *)®istryKey); + lua_gettable(s, LUA_REGISTRYINDEX); + Script *script = static_cast