From 31970d5255e43de6f06ef6ae4c67d781632ecd1f Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Fri, 26 Aug 2011 21:48:00 +0800 Subject: Prevented char from picking up items when inventory is full. Resolves: Mana-Mantis: #379. Reviewed-by: Bertram. --- src/game-server/gamehandler.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp index 58d289f..4c69da2 100644 --- a/src/game-server/gamehandler.cpp +++ b/src/game-server/gamehandler.cpp @@ -472,15 +472,20 @@ void GameHandler::handlePickup(GameClient &client, MessageIn &message) { Item *item = static_cast< Item * >(o); ItemClass *ic = item->getItemClass(); - Inventory(client.character).insert(ic->getDatabaseID(), - item->getAmount()); - GameState::remove(item); - // log transaction - std::stringstream str; - str << "User picked up item " << ic->getDatabaseID() - << " at " << opos.x << "x" << opos.y; - accountHandler->sendTransaction(client.character->getDatabaseID(), - TRANS_ITEM_PICKUP, str.str()); + if (!Inventory(client.character).insert(ic->getDatabaseID(), + item->getAmount())) + { + + GameState::remove(item); + // log transaction + std::stringstream str; + str << "User picked up item " << ic->getDatabaseID() + << " at " << opos.x << "x" << opos.y; + accountHandler->sendTransaction( + client.character->getDatabaseID(), + TRANS_ITEM_PICKUP, str.str() + ); + } break; } } -- cgit From 4a9de81c1911c747f9ecff695de58b12d0dc4a71 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sat, 3 Sep 2011 04:03:29 +0800 Subject: Added possibility for using monster name in SPAWN map objects. Reviewed-by: Bertram. --- src/game-server/mapreader.cpp | 55 ++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/game-server/mapreader.cpp b/src/game-server/mapreader.cpp index 462105f..8438c82 100644 --- a/src/game-server/mapreader.cpp +++ b/src/game-server/mapreader.cpp @@ -198,7 +198,7 @@ Map* MapReader::readMap(xmlNodePtr node, const std::string &path, } else if (utils::compareStrI(objType, "SPAWN") == 0) { - int monsterId = -1; + MonsterClass *monster = 0; int maxBeings = 10; // Default value int spawnRate = 10; // Default value @@ -213,33 +213,60 @@ Map* MapReader::readMap(xmlNodePtr node, const std::string &path, { if (xmlStrEqual(propertyNode->name, BAD_CAST "property")) { - std::string value = XML::getProperty(propertyNode, "name", std::string()); + std::string value = XML::getProperty( + propertyNode, + "name", + std::string()); value = utils::toUpper(value); if (utils::compareStrI(value, "MONSTER_ID") == 0) { - monsterId = getObjectProperty(propertyNode, monsterId); + std::string monsterName = + getObjectProperty(propertyNode, + std::string()); + int monsterId = utils::stringToInt(monsterName); + if (monsterId) + { + monster = monsterManager->getMonster( + monsterId); + if (!monster) + { + LOG_WARN("Couldn't find monster ID " + << monsterId << + " for spawn area"); + } + } + else + { + monster = monsterManager-> + getMonsterByName(monsterName); + if (!monster) + { + LOG_WARN("Couldn't find monster " + << monsterName << + " for spawn area"); + } + } } - else if (utils::compareStrI(value, "MAX_BEINGS") == 0) + else if (utils::compareStrI(value, + "MAX_BEINGS") == 0) { - maxBeings = getObjectProperty(propertyNode, maxBeings); + maxBeings = getObjectProperty(propertyNode, + maxBeings); } - else if (utils::compareStrI(value, "SPAWN_RATE") == 0) + else if (utils::compareStrI(value, + "SPAWN_RATE") == 0) { - spawnRate = getObjectProperty(propertyNode, spawnRate); + spawnRate = getObjectProperty(propertyNode, + spawnRate); } } } } - MonsterClass *monster = monsterManager->getMonster(monsterId); if (monster) { - things.push_back(new SpawnArea(composite, monster, rect, maxBeings, spawnRate)); - } - else - { - LOG_WARN("Couldn't find monster ID " << monsterId << - " for spawn area"); + things.push_back(new SpawnArea(composite, monster, rect, + maxBeings, spawnRate)); } } else if (utils::compareStrI(objType, "NPC") == 0) -- cgit From 082a88a7ac74e52fd5d239e1e974731a9a7b3fdc Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Fri, 2 Sep 2011 18:49:14 +0800 Subject: Fixed size of mapid field in mysql database. Resolves: Mana-Mantis: #388. Reviewed-by: Bertram. --- src/account-server/storage.cpp | 2 +- src/sql/mysql/createTables.sql | 2 +- src/sql/mysql/updates/update_15_to_16.sql | 7 +++++++ src/sql/sqlite/updates/update_15_to_16.sql | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/sql/mysql/updates/update_15_to_16.sql create mode 100644 src/sql/sqlite/updates/update_15_to_16.sql (limited to 'src') diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp index 9660120..3d6d4f5 100644 --- a/src/account-server/storage.cpp +++ b/src/account-server/storage.cpp @@ -41,7 +41,7 @@ static const char *DEFAULT_ITEM_FILE = "items.xml"; // Defines the supported db version static const char *DB_VERSION_PARAMETER = "database_version"; -static const char *SUPPORTED_DB_VERSION = "14"; +static const char *SUPPORTED_DB_VERSION = "16"; /* * MySQL specificities: diff --git a/src/sql/mysql/createTables.sql b/src/sql/mysql/createTables.sql index 9e1e31a..3a5f518 100644 --- a/src/sql/mysql/createTables.sql +++ b/src/sql/mysql/createTables.sql @@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS `mana_characters` ( -- location on the map `x` smallint(5) unsigned NOT NULL, `y` smallint(5) unsigned NOT NULL, - `map_id` tinyint(3) unsigned NOT NULL, + `map_id` smallint(5) unsigned NOT NULL, `slot` smallint(5) unsigned NOT NULL, -- PRIMARY KEY (`id`), diff --git a/src/sql/mysql/updates/update_15_to_16.sql b/src/sql/mysql/updates/update_15_to_16.sql new file mode 100644 index 0000000..df94f99 --- /dev/null +++ b/src/sql/mysql/updates/update_15_to_16.sql @@ -0,0 +1,7 @@ +ALTER TABLE mana_characters CHANGE map_id map_id smallint(5); + +-- Update database version. +UPDATE mana_world_states +SET value = '16', +moddate = UNIX_TIMESTAMP() +WHERE state_name = 'database_version'; diff --git a/src/sql/sqlite/updates/update_15_to_16.sql b/src/sql/sqlite/updates/update_15_to_16.sql new file mode 100644 index 0000000..aa5d464 --- /dev/null +++ b/src/sql/sqlite/updates/update_15_to_16.sql @@ -0,0 +1,7 @@ +-- No changes required. It was only an issue with mysql. + +-- Update the database version, and set date of update +UPDATE mana_world_states + SET value = '16', + moddate = strftime('%s','now') + WHERE state_name = 'database_version'; -- cgit