Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
81e6cf210e
|
@ -82,6 +82,8 @@ public:
|
||||||
|
|
||||||
LuaObjectPtr asLuaObject() { return shared_from_this(); }
|
LuaObjectPtr asLuaObject() { return shared_from_this(); }
|
||||||
|
|
||||||
|
void operator=(const LuaObject& other) { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_fieldsTableRef;
|
int m_fieldsTableRef;
|
||||||
int m_metatableRef;
|
int m_metatableRef;
|
||||||
|
|
|
@ -815,10 +815,12 @@ void UIWidget::setLayout(const UILayoutPtr& layout)
|
||||||
|
|
||||||
bool UIWidget::setRect(const Rect& rect)
|
bool UIWidget::setRect(const Rect& rect)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if(rect.width() > 8192 || rect.height() > 8192) {
|
if(rect.width() > 8192 || rect.height() > 8192) {
|
||||||
g_logger.error(stdext::format("attempt to set huge rect size (%s) for %s", stdext::to_string(rect), m_id));
|
g_logger.error(stdext::format("attempt to set huge rect size (%s) for %s", stdext::to_string(rect), m_id));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// only update if the rect really changed
|
// only update if the rect really changed
|
||||||
Rect oldRect = m_rect;
|
Rect oldRect = m_rect;
|
||||||
if(rect == oldRect)
|
if(rect == oldRect)
|
||||||
|
|
|
@ -293,3 +293,10 @@ bool Item::isMoveable()
|
||||||
"Invalid dat type for item %d", m_id));
|
"Invalid dat type for item %d", m_id));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemPtr Item::clone()
|
||||||
|
{
|
||||||
|
ItemPtr item = ItemPtr(new Item);
|
||||||
|
*(item.get()) = *this;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ public:
|
||||||
uint8 getDoorId() { return m_doorId; }
|
uint8 getDoorId() { return m_doorId; }
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
|
ItemPtr clone();
|
||||||
ItemPtr asItem() { return std::static_pointer_cast<Item>(shared_from_this()); }
|
ItemPtr asItem() { return std::static_pointer_cast<Item>(shared_from_this()); }
|
||||||
bool isItem() { return true; }
|
bool isItem() { return true; }
|
||||||
|
|
||||||
|
|
|
@ -315,6 +315,7 @@ void OTClient::registerLuaFunctions()
|
||||||
|
|
||||||
g_lua.registerClass<Item, Thing>();
|
g_lua.registerClass<Item, Thing>();
|
||||||
g_lua.bindClassStaticFunction<Item>("create", &Item::create);
|
g_lua.bindClassStaticFunction<Item>("create", &Item::create);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("clone", &Item::clone);
|
||||||
g_lua.bindClassMemberFunction<Item>("setCount", &Item::setCount);
|
g_lua.bindClassMemberFunction<Item>("setCount", &Item::setCount);
|
||||||
g_lua.bindClassMemberFunction<Item>("getCount", &Item::getCount);
|
g_lua.bindClassMemberFunction<Item>("getCount", &Item::getCount);
|
||||||
g_lua.bindClassMemberFunction<Item>("getId", &Item::getId);
|
g_lua.bindClassMemberFunction<Item>("getId", &Item::getId);
|
||||||
|
|
|
@ -218,7 +218,7 @@ void Map::loadOtbm(const std::string& fileName)
|
||||||
} else if(item->isDoor())
|
} else if(item->isDoor())
|
||||||
house->addDoor(item->getDoorId(), pos);
|
house->addDoor(item->getDoorId(), pos);
|
||||||
} else if(tile)
|
} else if(tile)
|
||||||
addThing(item, pos, 255);
|
addThing(item, pos);
|
||||||
else if(item->isGround())
|
else if(item->isGround())
|
||||||
ground = item;
|
ground = item;
|
||||||
else
|
else
|
||||||
|
@ -438,7 +438,7 @@ bool Map::loadOtcm(const std::string& fileName)
|
||||||
item->setCountOrSubType(countOrSubType);
|
item->setCountOrSubType(countOrSubType);
|
||||||
|
|
||||||
if(item->isValid())
|
if(item->isValid())
|
||||||
addThing(item, pos, 255);
|
addThing(item, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ bool Map::removeThing(const ThingPtr& thing)
|
||||||
m_staticTexts.erase(it);
|
m_staticTexts.erase(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if(TilePtr tile = thing->getTile())
|
} else if(const TilePtr& tile = thing->getTile())
|
||||||
return tile->removeThing(thing);
|
return tile->removeThing(thing);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -651,7 +651,7 @@ TilePtr Map::createTileEx(const Position& pos, const Items&... items)
|
||||||
TilePtr tile = getOrCreateTile(pos);
|
TilePtr tile = getOrCreateTile(pos);
|
||||||
auto vec = {items...};
|
auto vec = {items...};
|
||||||
for (auto it : vec)
|
for (auto it : vec)
|
||||||
addThing(it, pos, 255);
|
addThing(it, pos);
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,7 +512,7 @@ void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
|
||||||
if(!g_map.removeThing(thing))
|
if(!g_map.removeThing(thing))
|
||||||
g_logger.traceError("could not remove thing");
|
g_logger.traceError("could not remove thing");
|
||||||
|
|
||||||
g_map.addThing(thing, newPos);
|
g_map.addThing(thing, newPos, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
|
void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
|
||||||
|
@ -1307,7 +1307,7 @@ void ProtocolGame::setTileDescription(const InputMessagePtr& msg, Position posit
|
||||||
g_logger.traceError(stdext::format("too many things, stackpos=%d, pos=%s", stackPos, stdext::to_string(position)));
|
g_logger.traceError(stdext::format("too many things, stackpos=%d, pos=%s", stackPos, stdext::to_string(position)));
|
||||||
|
|
||||||
ThingPtr thing = getThing(msg);
|
ThingPtr thing = getThing(msg);
|
||||||
g_map.addThing(thing, position, -1);
|
g_map.addThing(thing, position, -2);
|
||||||
}
|
}
|
||||||
stackPos++;
|
stackPos++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,6 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stackPos < 0) {
|
|
||||||
// the items stackpos follows this order:
|
// the items stackpos follows this order:
|
||||||
// 0 - ground
|
// 0 - ground
|
||||||
// 1 - ground borders
|
// 1 - ground borders
|
||||||
|
@ -171,8 +170,10 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||||
// 3 - on top (doors)
|
// 3 - on top (doors)
|
||||||
// 4 - creatures, from top to bottom
|
// 4 - creatures, from top to bottom
|
||||||
// 5 - items, from top to bottom
|
// 5 - items, from top to bottom
|
||||||
|
if(stackPos < 0) {
|
||||||
stackPos = 0;
|
stackPos = 0;
|
||||||
int priority = thing->getStackPriority();
|
int priority = thing->getStackPriority();
|
||||||
|
bool prepend = (stackPos == -2 || priority <= 3);
|
||||||
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
||||||
int otherPriority = m_things[stackPos]->getStackPriority();
|
int otherPriority = m_things[stackPos]->getStackPriority();
|
||||||
if(!g_game.getFeature(Otc::GameReverseCreatureStack)) {
|
if(!g_game.getFeature(Otc::GameReverseCreatureStack)) {
|
||||||
|
@ -180,7 +181,7 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||||
if(priority == 4 && otherPriority == 4)
|
if(priority == 4 && otherPriority == 4)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(otherPriority > priority)
|
if((prepend && otherPriority > priority) || (!prepend && otherPriority >= priority))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(stackPos > (int)m_things.size())
|
} else if(stackPos > (int)m_things.size())
|
||||||
|
@ -233,6 +234,14 @@ ThingPtr Tile::getThing(int stackPos)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EffectPtr Tile::getEffect(uint16 id)
|
||||||
|
{
|
||||||
|
for(const EffectPtr& effect : m_effects)
|
||||||
|
if(effect->getId() == id)
|
||||||
|
return effect;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool Tile::hasThing(const ThingPtr& thing)
|
bool Tile::hasThing(const ThingPtr& thing)
|
||||||
{
|
{
|
||||||
return std::find(m_things.begin(), m_things.end(), thing) != m_things.end();
|
return std::find(m_things.begin(), m_things.end(), thing) != m_things.end();
|
||||||
|
@ -246,11 +255,14 @@ int Tile::getThingStackpos(const ThingPtr& thing)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThingPtr Tile::getTopThing()
|
ThingPtr Tile:: getTopThing()
|
||||||
{
|
{
|
||||||
if(isEmpty())
|
if(isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
for(const ThingPtr& thing : m_things) {
|
||||||
|
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->isCreature())
|
||||||
|
return thing;
|
||||||
|
}
|
||||||
return m_things[m_things.size() - 1];
|
return m_things[m_things.size() - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ public:
|
||||||
ThingPtr addThing(const ThingPtr& thing, int stackPos = -1);
|
ThingPtr addThing(const ThingPtr& thing, int stackPos = -1);
|
||||||
bool removeThing(ThingPtr thing);
|
bool removeThing(ThingPtr thing);
|
||||||
ThingPtr getThing(int stackPos);
|
ThingPtr getThing(int stackPos);
|
||||||
|
EffectPtr getEffect(uint16 id);
|
||||||
bool hasThing(const ThingPtr& thing);
|
bool hasThing(const ThingPtr& thing);
|
||||||
int getThingStackpos(const ThingPtr& thing);
|
int getThingStackpos(const ThingPtr& thing);
|
||||||
ThingPtr getTopThing();
|
ThingPtr getTopThing();
|
||||||
|
|
Loading…
Reference in New Issue