diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-08-06 14:47:18 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-08-06 14:47:18 +0200 |
commit | 1ccf0958ece7fbfde3761207f3238719e0585105 (patch) | |
tree | c2b2b0ba5bfedca8f793d35e5d3216e9c301cbf3 | |
parent | 1bbf0a238b62f2c977800f539386df5af9424fff (diff) | |
parent | af59c9d650bc254683618e7b334795e5a75886b2 (diff) | |
download | manaserv-1ccf0958ece7fbfde3761207f3238719e0585105.tar.gz manaserv-1ccf0958ece7fbfde3761207f3238719e0585105.tar.bz2 manaserv-1ccf0958ece7fbfde3761207f3238719e0585105.tar.xz manaserv-1ccf0958ece7fbfde3761207f3238719e0585105.zip |
Merge branch 'master' into lpc2012
Conflicts:
src/game-server/item.cpp
-rw-r--r-- | scripts/lua/libmana.lua | 2 | ||||
-rw-r--r-- | src/account-server/main-account.cpp | 12 | ||||
-rw-r--r-- | src/game-server/item.cpp | 16 | ||||
-rw-r--r-- | src/game-server/item.h | 21 | ||||
-rw-r--r-- | src/game-server/monstermanager.cpp | 20 | ||||
-rw-r--r-- | src/scripting/lua.cpp | 7 |
6 files changed, 38 insertions, 40 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua index 5d3164d9..0636e491 100644 --- a/scripts/lua/libmana.lua +++ b/scripts/lua/libmana.lua @@ -87,7 +87,7 @@ local function mapupdate(mapid) check_schedule(mapid) end --- Registers a function so that is is executed during map initialization. +-- Registers a function so that it is executed during map initialization. function atinit(f) local map_id = get_map_id() init_fun[map_id] = init_fun[map_id] or {} diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 65c5efd1..ab4df75e 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -365,19 +365,11 @@ int main(int argc, char *argv[]) statTimer.start(); banTimer.start(); - // ------------------------------------------------------------------------- - // FIXME: for testing purposes only... - // writing accountserver startup time and svn revision to database as global - // world state variable - const time_t startup = time(NULL); + // Write startup time to database as system world state variable std::stringstream timestamp; - timestamp << startup; + timestamp << time(NULL); storage->setWorldStateVar("accountserver_startup", timestamp.str(), Storage::SystemMap); - const std::string revision = "$Revision$"; - storage->setWorldStateVar("accountserver_version", revision, - Storage::SystemMap); - // ------------------------------------------------------------------------- while (running) { diff --git a/src/game-server/item.cpp b/src/game-server/item.cpp index cfb1cd9a..d568fb29 100644 --- a/src/game-server/item.cpp +++ b/src/game-server/item.cpp @@ -100,7 +100,12 @@ void ItemEffectScript::dispell(Being *itemUser) ItemClass::~ItemClass() { - resetEffects(); + while (mEffects.begin() != mEffects.end()) + { + delete mEffects.begin()->second; + mEffects.erase(mEffects.begin()); + } + for (std::vector<AttackInfo *>::iterator it = mAttackInfos.begin(), it_end = mAttackInfos.end(); it != it_end; ++it) @@ -109,6 +114,15 @@ ItemClass::~ItemClass() } } +void ItemClass::addEffect(ItemEffectInfo *effect, + ItemTriggerType id, + ItemTriggerType dispell) +{ + mEffects.insert(std::make_pair(id, effect)); + if (dispell) + mDispells.insert(std::make_pair(dispell, effect)); +} + bool ItemClass::useTrigger(Being *itemUser, ItemTriggerType trigger) { if (!trigger) diff --git a/src/game-server/item.h b/src/game-server/item.h index 84583aa6..7004a2d8 100644 --- a/src/game-server/item.h +++ b/src/game-server/item.h @@ -265,26 +265,7 @@ class ItemClass */ void addEffect(ItemEffectInfo *effect, ItemTriggerType id, - ItemTriggerType dispell = ITT_NULL) - { - mEffects.insert(std::make_pair(id, effect)); - if (dispell) - mDispells.insert(std::make_pair(dispell, effect)); - } - - void resetEffects() - { - while (mEffects.begin() != mEffects.end()) - { - delete mEffects.begin()->second; - mEffects.erase(mEffects.begin()); - } - while (mDispells.begin() != mDispells.end()) - { - delete mDispells.begin()->second; - mDispells.erase(mDispells.begin()); - } - } + ItemTriggerType dispell = ITT_NULL); unsigned short mDatabaseID; /**< Item reference information */ std::string mName; /**< name used to identify the item class */ diff --git a/src/game-server/monstermanager.cpp b/src/game-server/monstermanager.cpp index e0b45bad..cfe540d8 100644 --- a/src/game-server/monstermanager.cpp +++ b/src/game-server/monstermanager.cpp @@ -98,12 +98,26 @@ void MonsterManager::initialize() if (xmlStrEqual(subnode->name, BAD_CAST "drop")) { MonsterDrop drop; - drop.item = itemManager->getItem( - XML::getProperty(subnode, "item", 0)); + std::string item = XML::getProperty(subnode, "item", + std::string()); + ItemClass *itemClass; + if (utils::isNumeric(item)) + itemClass = itemManager->getItem(utils::stringToInt(item)); + else + itemClass = itemManager->getItemByName(item); + + if (!itemClass) + { + LOG_WARN("Monster Manager: Invalid item name \"" << item + << "\""); + break; + } + + drop.item = itemClass; drop.probability = XML::getFloatProperty(subnode, "percent", 0.0) * 100 + 0.5; - if (drop.item && drop.probability) + if (drop.probability) drops.push_back(drop); } else if (xmlStrEqual(subnode->name, BAD_CAST "attributes")) diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index dfb69d49..1828e515 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -556,7 +556,7 @@ static int chr_get_equipment(lua_State *s) } /** - * chr_inv_change(Character*, (int id || string name, + * chr_inv_change(Character*, (int id || string name || itemclass item, * int nb)...): bool success * Callback for inserting/removing items in inventory. * The function can be called several times in a row, but it is better to @@ -564,10 +564,7 @@ static int chr_get_equipment(lua_State *s) * (negative amount) should be passed first, then insertions (positive amount). * If a removal fails, all the previous operations are canceled (except for * items dropped on the floor, hence why removals should be passed first), and - * the function returns false. Otherwise the function will return true. - * Note that previously when the item identifier was zero, money was modified; - * however currency is now handled through attributes. This breaks backwards - * compatibility with old scripts, and so logs a warning. + * the function returns false. * Note: If an insertion fails, extra items are dropped on the floor. */ static int chr_inv_change(lua_State *s) |