diff options
author | Philipp Sehmisch <mana@crushnet.org> | 2011-03-04 18:35:17 +0100 |
---|---|---|
committer | Philipp Sehmisch <mana@crushnet.org> | 2011-03-04 18:36:17 +0100 |
commit | 54d5f7e577db0639e42b18beae4b5c87af6d6843 (patch) | |
tree | 2a667f208be4191a54d08131d7c3984cdfd74132 /src/game-server/mapcomposite.h | |
parent | bc5a0495ba7fbf992a1733850cbbe1cfb14c7c8d (diff) | |
download | manaserv-54d5f7e577db0639e42b18beae4b5c87af6d6843.tar.gz manaserv-54d5f7e577db0639e42b18beae4b5c87af6d6843.tar.bz2 manaserv-54d5f7e577db0639e42b18beae4b5c87af6d6843.tar.xz manaserv-54d5f7e577db0639e42b18beae4b5c87af6d6843.zip |
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
Diffstat (limited to 'src/game-server/mapcomposite.h')
-rw-r--r-- | src/game-server/mapcomposite.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/game-server/mapcomposite.h b/src/game-server/mapcomposite.h index 3de83c77..351a0572 100644 --- a/src/game-server/mapcomposite.h +++ b/src/game-server/mapcomposite.h @@ -23,6 +23,7 @@ #include <string> #include <vector> +#include <map> class Actor; class Being; @@ -332,6 +333,24 @@ class MapComposite */ const std::vector< Thing * > &getEverything() const; + /** + * Gets the cached value of a map-bound script variable + */ + std::string getVariable(const std::string &key); + + /** + * Changes a script variable and notifies the database server + * about the change + */ + void setVariable (const std::string &key, const std::string &value); + + /** + * Changes a script variable without notifying the database server + * about the change + */ + void setVariableFromDbserver (const std::string &key, const std::string &value) + { mScriptVariables[key] = value ;} + private: MapComposite(const MapComposite &); @@ -340,7 +359,7 @@ class MapComposite Script *mScript; /**< Script associated to this map. */ std::string mName; /**< Name of the map. */ unsigned short mID; /**< ID of the map. */ - + std::map< std::string, std::string > mScriptVariables; /** Cached persistent variables */ PvPRules mPvPRules; }; |