summaryrefslogtreecommitdiff
path: root/src/game-server/gamehandler.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-09 02:35:25 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-09-09 02:36:30 +0200
commit6ae2001e91eaaeb8b72031e96f88820711bb1ca0 (patch)
tree8ab01e1d9e59860837560e6cd8bbd7eabaa428de /src/game-server/gamehandler.cpp
parent40a31c52aebc19221cc9da8a0f764d21e672937b (diff)
downloadmanaserv-6ae2001e91eaaeb8b72031e96f88820711bb1ca0.tar.gz
manaserv-6ae2001e91eaaeb8b72031e96f88820711bb1ca0.tar.bz2
manaserv-6ae2001e91eaaeb8b72031e96f88820711bb1ca0.tar.xz
manaserv-6ae2001e91eaaeb8b72031e96f88820711bb1ca0.zip
Add persistent items support based on seeseekey's work.
Also made some random changes where useful, including: - Code formatting fixes, - Design fix about the fact that only the game config option should be checked. - Fixed the size of the values sent and receive to follow the rest of the development. - Fixed variables names to make them show what they are, and not why they are used. Resolves: Mana-Mantis #142.
Diffstat (limited to 'src/game-server/gamehandler.cpp')
-rw-r--r--src/game-server/gamehandler.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 92971903..e6c4737f 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -472,11 +472,22 @@ void GameHandler::handlePickup(GameClient &client, MessageIn &message)
{
Item *item = static_cast< Item * >(o);
ItemClass *ic = item->getItemClass();
+ int amount = item->getAmount();
if (!Inventory(client.character).insert(ic->getDatabaseID(),
- item->getAmount()))
+ amount))
{
-
GameState::remove(item);
+
+ // We only do this when items are to be kept in memory
+ // between two server restart.
+ if (!Configuration::getValue("game_floorItemDecayTime", 0))
+ {
+ // Remove the floor item from map
+ accountHandler->removeFloorItems(map->getID(),
+ ic->getDatabaseID(),
+ amount, x, y);
+ }
+
// log transaction
std::stringstream str;
str << "User picked up item " << ic->getDatabaseID()
@@ -531,8 +542,20 @@ void GameHandler::handleDrop(GameClient &client, MessageIn &message)
delete item;
return;
}
- // log transaction
+
Point pt = client.character->getPosition();
+
+ // We store the item in database only when the floor items are meant
+ // to be persistent between two server restarts.
+ if (!Configuration::getValue("game_floorItemDecayTime", 0))
+ {
+ // Create the floor item on map
+ accountHandler->createFloorItems(client.character->getMap()->getID(),
+ ic->getDatabaseID(),
+ amount, pt.x, pt.y);
+ }
+
+ // log transaction
std::stringstream str;
str << "User dropped item " << ic->getDatabaseID()
<< " at " << pt.x << "x" << pt.y;