summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--scripts/lua/libmana-constants.lua1
-rw-r--r--src/common/manaserv_protocol.h2
-rw-r--r--src/game-server/character.cpp8
-rw-r--r--src/game-server/commandhandler.cpp11
-rw-r--r--src/game-server/itemmanager.cpp5
-rw-r--r--src/game-server/mapcomposite.cpp39
-rw-r--r--src/game-server/monster.cpp4
-rw-r--r--src/game-server/statusmanager.cpp4
-rw-r--r--src/scripting/lua.cpp2
-rw-r--r--src/scripting/script.cpp18
-rw-r--r--src/scripting/script.h1
-rw-r--r--src/sql/mysql/updates/update_14_to_16.sql (renamed from src/sql/mysql/updates/update_15_to_16.sql)0
-rw-r--r--src/sql/sqlite/updates/update_14_to_16.sql (renamed from src/sql/sqlite/updates/update_15_to_16.sql)0
14 files changed, 73 insertions, 23 deletions
diff --git a/AUTHORS b/AUTHORS
index 8594740d..4db57875 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -6,6 +6,7 @@ Erik Schilling <ablu.erikschilling@googlemail.com>
Eugenio Favalli <elvenprogrammer@gmail.com>
Guillaume Melquiond <guillaume.melquiond@gmail.com>
Huynh Ngoc Chau Tran aka kindjal <nthuynh at users dot sourceforge dot net>
+jurkan <jurkan@gmx.de>
Philipp Sehmisch <tmw@crushnet.org>
seeseekey <seeseekey@googlemail.com>
Yohann Ferreira <Bertram@cegetel.net>
diff --git a/scripts/lua/libmana-constants.lua b/scripts/lua/libmana-constants.lua
index 912216c9..08d26c5c 100644
--- a/scripts/lua/libmana-constants.lua
+++ b/scripts/lua/libmana-constants.lua
@@ -39,6 +39,7 @@ DIRECTION_RIGHT = 8;
GENDER_MALE = 0;
GENDER_FEMALE = 1;
+GENDER_UNSPECIFIED = 2;
DAMAGE_PHYSICAL = 0;
DAMAGE_MAGICAL = 1;
diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h
index 4cca9513..8946a394 100644
--- a/src/common/manaserv_protocol.h
+++ b/src/common/manaserv_protocol.h
@@ -433,8 +433,6 @@ enum BeingDirection
/**
* Beings Genders
- * WARNING: Has to be in sync with the same enum in the Being class
- * of the client!
*/
enum BeingGender
{
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 {
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 03d08771..1bb75137 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -477,7 +477,7 @@ static int chr_inv_count(lua_State *s)
}
/**
- * mana.chr_get_level(): int level
+ * mana.chr_get_level(Character*): int level
* Tells the character current level.
*/
static int chr_get_level(lua_State *s)
diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp
index 490abf09..b6121bb8 100644
--- a/src/scripting/script.cpp
+++ b/src/scripting/script.cpp
@@ -20,6 +20,7 @@
#include "scripting/script.h"
+#include "common/configuration.h"
#include "common/resourcemanager.h"
#include "game-server/being.h"
#include "utils/logger.h"
@@ -172,3 +173,20 @@ bool Script::performCraft(Being* crafter, std::list<InventoryItem> recipe)
}
return true;
}
+
+std::string Script::determineEngineByFilename(const std::string &filename)
+{
+ std::string ext = filename.substr(filename.find_last_of(".") + 1);
+
+ if (ext == "lua")
+ {
+ return "lua";
+ }
+ else
+ {
+ // Set to default engine and print warning
+ LOG_WARN("Unknown file extension for script \""
+ + filename + "\", falling back to default script engine");
+ return Configuration::getValue("defaultScriptEngine", "lua");
+ }
+}
diff --git a/src/scripting/script.h b/src/scripting/script.h
index 44a8b7ac..e2ab3afa 100644
--- a/src/scripting/script.h
+++ b/src/scripting/script.h
@@ -143,6 +143,7 @@ class Script
static bool performSpecialAction(int specialId, Being *caster);
static bool performCraft(Being* crafter, std::list<InventoryItem> recipe);
+ static std::string determineEngineByFilename(const std::string &filename);
protected:
static Script *globalEventScript;
diff --git a/src/sql/mysql/updates/update_15_to_16.sql b/src/sql/mysql/updates/update_14_to_16.sql
index df94f995..df94f995 100644
--- a/src/sql/mysql/updates/update_15_to_16.sql
+++ b/src/sql/mysql/updates/update_14_to_16.sql
diff --git a/src/sql/sqlite/updates/update_15_to_16.sql b/src/sql/sqlite/updates/update_14_to_16.sql
index aa5d4646..aa5d4646 100644
--- a/src/sql/sqlite/updates/update_15_to_16.sql
+++ b/src/sql/sqlite/updates/update_14_to_16.sql