diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-11-01 04:07:56 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-11-01 04:07:56 +0100 |
commit | 22142fd2cc8dd262ca1202ffeb5f4ef714870c4c (patch) | |
tree | ca0a1eaeb781baec2c4e5b22cf9df60fa89f2982 /src/game-server | |
parent | 5bd0ddb6e2d1b002372541f911a2764ed2e54e6c (diff) | |
parent | a5895b1655be3e81f451844a911eab8b798fa7ab (diff) | |
download | manaserv-22142fd2cc8dd262ca1202ffeb5f4ef714870c4c.tar.gz manaserv-22142fd2cc8dd262ca1202ffeb5f4ef714870c4c.tar.bz2 manaserv-22142fd2cc8dd262ca1202ffeb5f4ef714870c4c.tar.xz manaserv-22142fd2cc8dd262ca1202ffeb5f4ef714870c4c.zip |
Merge github.com:mana/manaserv
Conflicts:
src/game-server/character.cpp
src/scripting/lua.cpp
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/character.cpp | 8 | ||||
-rw-r--r-- | src/game-server/commandhandler.cpp | 11 | ||||
-rw-r--r-- | src/game-server/itemmanager.cpp | 5 | ||||
-rw-r--r-- | src/game-server/mapcomposite.cpp | 39 | ||||
-rw-r--r-- | src/game-server/monster.cpp | 4 | ||||
-rw-r--r-- | src/game-server/statusmanager.cpp | 4 |
6 files changed, 51 insertions, 20 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 0cdd57b1..41d05455 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -301,9 +301,11 @@ void Character::setGender(int gender) { switch (gender) { - case GENDER_MALE: - case GENDER_FEMALE: - mGender = (BeingGender)gender; + case 0: + mGender = GENDER_MALE; + break; + case 1: + mGender = GENDER_FEMALE; break; default: mGender = GENDER_UNSPECIFIED; diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index 0cde9891..6064811e 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -60,7 +60,7 @@ static void handleRecall(Character*, std::string&); static void handleBan(Character*, std::string&); static void handleItem(Character*, std::string&); static void handleDrop(Character*, std::string&); -//static void handleMoney(Character*, std::string&); +static void handleMoney(Character*, std::string&); static void handleSpawn(Character*, std::string&); static void handleAttribute(Character*, std::string&); static void handleReload(Character*, std::string&); @@ -102,8 +102,8 @@ static CmdRef const cmdRef[] = "Creates a number of items in the inventory of a character", &handleItem}, {"drop", "<item id> <amount>", "Drops a stack of items on the ground at your current location", &handleDrop}, -/* {"money", "<character> <amount>", - "Changes the money a character possesses", &handleMoney},*/ + {"money", "<character> <amount>", + "Changes the money a character possesses", &handleMoney}, {"spawn", "<monster id> <number>", "Creates a number of monsters near your location", &handleSpawn}, {"attribute", "<character> <attribute> <value>", @@ -594,7 +594,7 @@ static void handleDrop(Character *player, std::string &args) str << "User created item " << ic->getDatabaseID(); accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_DROP, str.str()); } -/* + static void handleMoney(Character *player, std::string &args) { Character *other; @@ -639,13 +639,12 @@ static void handleMoney(Character *player, std::string &args) value = utils::stringToInt(valuestr); // change how much money the player has - Inventory(other).changeMoney(value); + other->setAttribute(ATTR_GP , other->getAttribute(ATTR_GP) + value); // log transaction std::string msg = "User created " + valuestr + " money"; accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_MONEY, msg); } -*/ static void handleSpawn(Character *player, std::string &args) { diff --git a/src/game-server/itemmanager.cpp b/src/game-server/itemmanager.cpp index be405b87..ffbdce89 100644 --- a/src/game-server/itemmanager.cpp +++ b/src/game-server/itemmanager.cpp @@ -432,7 +432,10 @@ void ItemManager::readEffectNode(xmlNodePtr effectNode, ItemClass *item) } LOG_INFO("Loading item script: " << filename.str()); - Script *script = Script::create("lua"); + + std::string engineName = + Script::determineEngineByFilename(filename.str()); + Script *script = Script::create(engineName); if (!script->loadFile(filename.str())) { // Delete the script as it's invalid. diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp index ecd39569..4d0581ad 100644 --- a/src/game-server/mapcomposite.cpp +++ b/src/game-server/mapcomposite.cpp @@ -727,14 +727,23 @@ void MapComposite::initializeContent() } else if (utils::compareStrI(type, "NPC") == 0) { + int npcId = utils::stringToInt(object->getProperty("NPC_ID")); + std::string scriptText = object->getProperty("SCRIPT"); + if (!mScript) { - mScript = Script::create("lua"); + // Determine script engine by xml property + std::string scriptEngineName = object->getProperty("ENGINE"); + if (scriptEngineName.empty()) + { + // Set engine to default value and print warning + scriptEngineName = Configuration::getValue("defaultScriptEngine", "lua"); + LOG_WARN("No script engine specified for map script \"" + + mName + "\", falling back to default"); + } + mScript = Script::create(scriptEngineName); } - int npcId = utils::stringToInt(object->getProperty("NPC_ID")); - std::string scriptText = object->getProperty("SCRIPT"); - if (npcId && !scriptText.empty()) { mScript->loadNPC(object->getName(), npcId, @@ -748,14 +757,28 @@ void MapComposite::initializeContent() } else if (utils::compareStrI(type, "SCRIPT") == 0) { + std::string scriptFilename = object->getProperty("FILENAME"); + std::string scriptText = object->getProperty("TEXT"); + if (!mScript) { - mScript = Script::create("lua"); + // Determine script engine by xml property + std::string scriptEngineName = object->getProperty("ENGINE"); + if (!scriptFilename.empty() && scriptEngineName.empty()) + { + // Engine property is empty - determine by filename + scriptEngineName = Script::determineEngineByFilename(scriptFilename); + } + else if (scriptEngineName.empty()) + { + // Set engine to default value and print warning + scriptEngineName = Configuration::getValue("defaultScriptEngine", "lua"); + LOG_WARN("No script engine specified for map script \"" + + mName + "\", falling back to default"); + } + mScript = Script::create(scriptEngineName); } - std::string scriptFilename = object->getProperty("FILENAME"); - std::string scriptText = object->getProperty("TEXT"); - if (!scriptFilename.empty()) { mScript->loadFile(scriptFilename); diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index 0f387917..a976b81c 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -335,7 +335,9 @@ void Monster::loadScript(const std::string &scriptName) if (ResourceManager::exists(filename.str())) { LOG_INFO("Loading monster script: " << filename.str()); - mScript = Script::create("lua"); + std::string engineName = + Script::determineEngineByFilename(filename.str()); + mScript = Script::create(engineName); mScript->loadFile(filename.str()); } else diff --git a/src/game-server/statusmanager.cpp b/src/game-server/statusmanager.cpp index 77519754..66c2642a 100644 --- a/src/game-server/statusmanager.cpp +++ b/src/game-server/statusmanager.cpp @@ -89,7 +89,9 @@ void StatusManager::reload() if (ResourceManager::exists(filename.str())) // file exists! { LOG_INFO("Loading status script: " << filename.str()); - Script *s = Script::create("lua"); + std::string engineName = + Script::determineEngineByFilename(filename.str()); + Script *s = Script::create(engineName); s->loadFile(filename.str()); statusEffect->setScript(s); } else { |