Subversion Repositories eoserv

Compare Revisions

Ignore whitespace Rev 385 → Rev 386

/trunk/src/map.cpp
253,6 → 253,45
return 0;
}
 
int Map_Chest::DelSomeItem(short item_id, int amount)
{
UTIL_IFOREACH(this->items, it)
{
if (it->id == item_id)
{
if (amount < it->amount)
{
it->amount -= amount;
 
if (it->slot)
{
double current_time = Timer::GetTime();
 
UTIL_FOREACH(this->spawns, spawn)
{
if (spawn.slot == it->slot)
{
spawn.last_taken = current_time;
}
}
 
it->slot = 0;
}
 
return it->amount;
}
else
{
return DelItem(item_id);
}
 
break;
}
}
 
return 0;
}
 
void Map_Chest::Update(Map *map, Character *exclude) const
{
PacketBuilder builder(PACKET_CHEST, PACKET_AGREE, this->items.size() * 5);
/trunk/src/map.hpp
197,6 → 197,7
int HasItem(short item) const;
int AddItem(short item, int amount, int slot = 0);
int DelItem(short item);
int DelSomeItem(short item, int amount);
 
void Update(Map *map, Character *exclude = 0) const;
};
/trunk/src/handlers/Item.cpp
462,17 → 462,20
 
int taken = character->CanHoldItem(item->id, item->amount);
 
character->AddItem(item->id, taken);
if (taken > 0)
{
character->AddItem(item->id, taken);
 
PacketBuilder reply(PACKET_ITEM, PACKET_GET, 9);
reply.AddShort(uid);
reply.AddShort(item->id);
reply.AddThree(taken);
reply.AddChar(character->weight);
reply.AddChar(character->maxweight);
character->Send(reply);
PacketBuilder reply(PACKET_ITEM, PACKET_GET, 9);
reply.AddShort(uid);
reply.AddShort(item->id);
reply.AddThree(taken);
reply.AddChar(character->weight);
reply.AddChar(character->maxweight);
character->Send(reply);
 
character->map->DelSomeItem(item->uid, taken, character);
character->map->DelSomeItem(item->uid, taken, character);
}
}
}
 
/trunk/src/handlers/Chest.cpp
84,11 → 84,12
{
if (chest->x == x && chest->y == y)
{
int amount = chest->DelItem(id);
int amount = chest->HasItem(id);
int taken = character->CanHoldItem(id, amount);
 
if (taken)
if (taken > 0)
{
chest->DelSomeItem(id, taken);
character->AddItem(id, taken);
 
PacketBuilder reply(PACKET_CHEST, PACKET_GET, 7 + (chest->items.size() + 1) * 5);
97,11 → 98,6
reply.AddChar(character->weight);
reply.AddChar(character->maxweight);
 
if (amount - taken > 0)
{
chest->AddItem(id, amount - taken);
}
 
UTIL_CIFOREACH(chest->items, item)
{
if (item->id != 0)