commit
3340e06da6
|
@ -23,7 +23,7 @@
|
|||
#include "container.h"
|
||||
#include "item.h"
|
||||
|
||||
Container::Container(int id, int capacity, const std::string& name, const ItemPtr& containerItem, bool hasParent)
|
||||
Container::Container(int id, int capacity, const std::string& name, const ItemPtr& containerItem, bool hasParent, bool isUnlocked, bool hasPages, int containerSize, int firstIndex)
|
||||
{
|
||||
m_id = id;
|
||||
m_capacity = capacity;
|
||||
|
@ -31,6 +31,10 @@ Container::Container(int id, int capacity, const std::string& name, const ItemPt
|
|||
m_containerItem = containerItem;
|
||||
m_hasParent = hasParent;
|
||||
m_closed = false;
|
||||
m_unlocked = isUnlocked;
|
||||
m_hasPages = hasPages;
|
||||
m_size = containerSize;
|
||||
m_firstIndex = firstIndex;
|
||||
}
|
||||
|
||||
ItemPtr Container::getItem(int slot)
|
||||
|
@ -51,12 +55,12 @@ void Container::onClose()
|
|||
callLuaField("onClose");
|
||||
}
|
||||
|
||||
void Container::onAddItem(const ItemPtr& item)
|
||||
void Container::onAddItem(const ItemPtr& item, int slot)
|
||||
{
|
||||
m_items.push_front(item);
|
||||
updateItemsPositions();
|
||||
|
||||
callLuaField("onAddItem", 0, item);
|
||||
callLuaField("onAddItem", slot, item);
|
||||
}
|
||||
|
||||
ItemPtr Container::findItemById(uint itemId, int subType)
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
class Container : public LuaObject
|
||||
{
|
||||
protected:
|
||||
Container(int id, int capacity, const std::string& name, const ItemPtr& containerItem, bool hasParent);
|
||||
Container(int id, int capacity, const std::string& name, const ItemPtr& containerItem, bool hasParent, bool isUnlocked, bool hasPages, int containerSize, int firstIndex);
|
||||
|
||||
public:
|
||||
ItemPtr getItem(int slot);
|
||||
|
@ -45,12 +45,16 @@ public:
|
|||
std::string getName() { return m_name; }
|
||||
bool hasParent() { return m_hasParent; }
|
||||
bool isClosed() { return m_closed; }
|
||||
bool isUnlocked() { return m_unlocked; }
|
||||
bool hasPages() { return m_hasPages; }
|
||||
int getSize() { return m_size; }
|
||||
int getFirstIndex() { return m_firstIndex; }
|
||||
ItemPtr findItemById(uint itemId, int subType);
|
||||
|
||||
protected:
|
||||
void onOpen(const ContainerPtr& previousContainer);
|
||||
void onClose();
|
||||
void onAddItem(const ItemPtr& item);
|
||||
void onAddItem(const ItemPtr& item, int slot);
|
||||
void onAddItems(const std::vector<ItemPtr>& items);
|
||||
void onUpdateItem(int slot, const ItemPtr& item);
|
||||
void onRemoveItem(int slot);
|
||||
|
@ -66,6 +70,10 @@ private:
|
|||
std::string m_name;
|
||||
bool m_hasParent;
|
||||
bool m_closed;
|
||||
bool m_unlocked;
|
||||
bool m_hasPages;
|
||||
int m_size;
|
||||
int m_firstIndex;
|
||||
std::deque<ItemPtr> m_items;
|
||||
};
|
||||
|
||||
|
|
|
@ -234,6 +234,11 @@ void Game::processGMActions(const std::vector<uint8>& actions)
|
|||
g_lua.callGlobalField("g_game", "onGMActions", actions);
|
||||
}
|
||||
|
||||
void Game::processPlayerHelpers(int helpers)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onPlayerHelpersUpdate", helpers);
|
||||
}
|
||||
|
||||
void Game::processPing()
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onPing");
|
||||
|
@ -268,10 +273,10 @@ void Game::processTalk(const std::string& name, int level, Otc::MessageMode mode
|
|||
g_lua.callGlobalField("g_game", "onTalk", name, level, mode, text, channelId, pos);
|
||||
}
|
||||
|
||||
void Game::processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items)
|
||||
void Game::processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items, bool isUnlocked, bool hasPages, int containerSize, int firstIndex)
|
||||
{
|
||||
ContainerPtr previousContainer = getContainer(containerId);
|
||||
ContainerPtr container = ContainerPtr(new Container(containerId, capacity, name, containerItem, hasParent));
|
||||
ContainerPtr container = ContainerPtr(new Container(containerId, capacity, name, containerItem, hasParent, isUnlocked, hasPages, containerSize, firstIndex));
|
||||
m_containers[containerId] = container;
|
||||
container->onAddItems(items);
|
||||
|
||||
|
@ -296,7 +301,7 @@ void Game::processCloseContainer(int containerId)
|
|||
container->onClose();
|
||||
}
|
||||
|
||||
void Game::processContainerAddItem(int containerId, const ItemPtr& item)
|
||||
void Game::processContainerAddItem(int containerId, const ItemPtr& item, int slot)
|
||||
{
|
||||
ContainerPtr container = getContainer(containerId);
|
||||
if(!container) {
|
||||
|
@ -304,7 +309,7 @@ void Game::processContainerAddItem(int containerId, const ItemPtr& item)
|
|||
return;
|
||||
}
|
||||
|
||||
container->onAddItem(item);
|
||||
container->onAddItem(item, slot);
|
||||
}
|
||||
|
||||
void Game::processContainerUpdateItem(int containerId, int slot, const ItemPtr& item)
|
||||
|
|
|
@ -73,14 +73,16 @@ protected:
|
|||
void processAttackCancel(uint seq);
|
||||
void processWalkCancel(Otc::Direction direction);
|
||||
|
||||
void processPlayerHelpers(int helpers);
|
||||
|
||||
// message related
|
||||
void processTextMessage(Otc::MessageMode mode, const std::string& text);
|
||||
void processTalk(const std::string& name, int level, Otc::MessageMode mode, const std::string& text, int channelId, const Position& pos);
|
||||
|
||||
// container related
|
||||
void processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items);
|
||||
void processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items, bool isUnlocked, bool hasPages, int containerSize, int firstIndex);
|
||||
void processCloseContainer(int containerId);
|
||||
void processContainerAddItem(int containerId, const ItemPtr& item);
|
||||
void processContainerAddItem(int containerId, const ItemPtr& item, int slot);
|
||||
void processContainerUpdateItem(int containerId, int slot, const ItemPtr& item);
|
||||
void processContainerRemoveItem(int containerId, int slot);
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void Client::registerLuaFunctions()
|
|||
g_lua.bindSingletonFunction("g_things", "findItemTypeByClientId", &ThingTypeManager::findItemTypeByClientId, &g_things);
|
||||
g_lua.bindSingletonFunction("g_things", "findItemTypeByName", &ThingTypeManager::findItemTypeByName, &g_things);
|
||||
g_lua.bindSingletonFunction("g_things", "findItemTypesByName", &ThingTypeManager::findItemTypesByName, &g_things);
|
||||
g_lua.bindSingletonFunction("g_things", "findItemTypesByString", &ThingTypeManager::findItemTypesByString, &g_things);
|
||||
g_lua.bindSingletonFunction("g_things", "findItemTypesByString", &ThingTypeManager::findItemTypesByString, &g_things);
|
||||
g_lua.bindSingletonFunction("g_things", "findItemTypeByCategory", &ThingTypeManager::findItemTypeByCategory, &g_things);
|
||||
g_lua.bindSingletonFunction("g_things", "findThingTypeByAttr", &ThingTypeManager::findThingTypeByAttr, &g_things);
|
||||
|
||||
|
@ -317,6 +317,10 @@ void Client::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<Container>("getContainerItem", &Container::getContainerItem);
|
||||
g_lua.bindClassMemberFunction<Container>("hasParent", &Container::hasParent);
|
||||
g_lua.bindClassMemberFunction<Container>("isClosed", &Container::isClosed);
|
||||
g_lua.bindClassMemberFunction<Container>("isUnlocked", &Container::isUnlocked);
|
||||
g_lua.bindClassMemberFunction<Container>("hasPages", &Container::hasPages);
|
||||
g_lua.bindClassMemberFunction<Container>("getSize", &Container::getSize);
|
||||
g_lua.bindClassMemberFunction<Container>("getFirstIndex", &Container::getFirstIndex);
|
||||
|
||||
g_lua.registerClass<Thing>();
|
||||
g_lua.bindClassMemberFunction<Thing>("setId", &Thing::setId);
|
||||
|
@ -646,7 +650,7 @@ void Client::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UIMinimap>("getMinZoom", &UIMinimap::getMinZoom);
|
||||
g_lua.bindClassMemberFunction<UIMinimap>("getMaxZoom", &UIMinimap::getMaxZoom);
|
||||
g_lua.bindClassMemberFunction<UIMinimap>("getZoom", &UIMinimap::getZoom);
|
||||
g_lua.bindClassMemberFunction<UIMinimap>("getScale", &UIMinimap::getScale);
|
||||
g_lua.bindClassMemberFunction<UIMinimap>("getScale", &UIMinimap::getScale);
|
||||
g_lua.bindClassMemberFunction<UIMinimap>("anchorPosition", &UIMinimap::anchorPosition);
|
||||
g_lua.bindClassMemberFunction<UIMinimap>("fillPosition", &UIMinimap::fillPosition);
|
||||
g_lua.bindClassMemberFunction<UIMinimap>("centerInPosition", &UIMinimap::centerInPosition);
|
||||
|
|
|
@ -102,6 +102,7 @@ namespace Proto {
|
|||
GameServerCreatureSkull = 144,
|
||||
GameServerCreatureParty = 145,
|
||||
GameServerCreatureUnpass = 146,
|
||||
GameServerPlayerHelpers = 148,
|
||||
GameServerEditText = 150,
|
||||
GameServerEditList = 151,
|
||||
GameServerPlayerDataBasic = 159, // 950
|
||||
|
|
|
@ -125,6 +125,7 @@ public:
|
|||
void addPosition(const OutputMessagePtr& msg, const Position& position);
|
||||
|
||||
private:
|
||||
void parsePlayerHelpers(const InputMessagePtr& msg);
|
||||
void parseMessage(const InputMessagePtr& msg);
|
||||
void parsePendingGame(const InputMessagePtr& msg);
|
||||
void parseEnterGame(const InputMessagePtr& msg);
|
||||
|
|
|
@ -323,6 +323,10 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
|
|||
case Proto::GameServerEnterGame:
|
||||
parseEnterGame(msg);
|
||||
break;
|
||||
// PROTOCOL>=1010
|
||||
case Proto::GameServerPlayerHelpers:
|
||||
parsePlayerHelpers(msg);
|
||||
break;
|
||||
// otclient ONLY
|
||||
case Proto::GameServerExtendedOpcode:
|
||||
parseExtendedOpcode(msg);
|
||||
|
@ -379,6 +383,18 @@ void ProtocolGame::parseEnterGame(const InputMessagePtr& msg)
|
|||
}
|
||||
}
|
||||
|
||||
void ProtocolGame::parsePlayerHelpers(const InputMessagePtr& msg)
|
||||
{
|
||||
uint id = msg->getU32();
|
||||
int helpers = msg->getU16();
|
||||
|
||||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
g_game.processPlayerHelpers(helpers);
|
||||
else
|
||||
g_logger.traceError("could not get creature");
|
||||
}
|
||||
|
||||
void ProtocolGame::parseGMActions(const InputMessagePtr& msg)
|
||||
{
|
||||
std::vector<uint8> actions;
|
||||
|
@ -604,11 +620,16 @@ void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
|
|||
int capacity = msg->getU8();
|
||||
bool hasParent = (msg->getU8() != 0);
|
||||
|
||||
bool isUnlocked = false;
|
||||
bool hasPages = false;
|
||||
int containerSize = 0;
|
||||
int firstIndex = 0;
|
||||
|
||||
if(g_game.getFeature(Otc::GameContainerPagination)) {
|
||||
msg->getU8(); // drag and drop
|
||||
msg->getU8(); // pagination
|
||||
msg->getU16(); // container size
|
||||
msg->getU16(); // first index
|
||||
isUnlocked = (msg->getU8() != 0); // drag and drop
|
||||
hasPages = (msg->getU8() != 0); // pagination
|
||||
containerSize = msg->getU16(); // container size
|
||||
firstIndex = msg->getU16(); // first index
|
||||
}
|
||||
|
||||
int itemCount = msg->getU8();
|
||||
|
@ -617,7 +638,7 @@ void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
|
|||
for(int i = 0; i < itemCount; i++)
|
||||
items[i] = getItem(msg);
|
||||
|
||||
g_game.processOpenContainer(containerId, containerItem, name, capacity, hasParent, items);
|
||||
g_game.processOpenContainer(containerId, containerItem, name, capacity, hasParent, items, isUnlocked, hasPages, containerSize, firstIndex);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseCloseContainer(const InputMessagePtr& msg)
|
||||
|
@ -629,11 +650,12 @@ void ProtocolGame::parseCloseContainer(const InputMessagePtr& msg)
|
|||
void ProtocolGame::parseContainerAddItem(const InputMessagePtr& msg)
|
||||
{
|
||||
int containerId = msg->getU8();
|
||||
int slot = 0;
|
||||
if(g_game.getFeature(Otc::GameContainerPagination)) {
|
||||
msg->getU16(); // slot
|
||||
slot = msg->getU16(); // slot
|
||||
}
|
||||
ItemPtr item = getItem(msg);
|
||||
g_game.processContainerAddItem(containerId, item);
|
||||
g_game.processContainerAddItem(containerId, item, slot);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseContainerUpdateItem(const InputMessagePtr& msg)
|
||||
|
|
Loading…
Reference in New Issue