Fix some bugs
This commit is contained in:
parent
1e2d20d289
commit
05436e135a
|
@ -395,7 +395,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
|
||||||
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
|
if multiUseThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
|
||||||
local player = g_game.getLocalPlayer()
|
local player = g_game.getLocalPlayer()
|
||||||
if multiUseThing:isCreature() and multiUseThing:isCreature() ~= player then
|
if multiUseThing:isCreature() and multiUseThing:isCreature() ~= player then
|
||||||
g_game.attack(multiUseThing:isCreature())
|
g_game.attack(multiUseThing)
|
||||||
return true
|
return true
|
||||||
elseif multiUseThing:isContainer() then
|
elseif multiUseThing:isContainer() then
|
||||||
if multiUseThing:getParentContainer() then
|
if multiUseThing:getParentContainer() then
|
||||||
|
|
|
@ -24,12 +24,15 @@ function UIItem:onDrop(widget, mousePos)
|
||||||
if not widget or not widget.currentDragThing then return false end
|
if not widget or not widget.currentDragThing then return false end
|
||||||
|
|
||||||
local item = widget.currentDragThing
|
local item = widget.currentDragThing
|
||||||
|
if not item:isItem() then return false end
|
||||||
|
|
||||||
local toPos = self.position
|
local toPos = self.position
|
||||||
|
|
||||||
local itemPos = item:getPosition()
|
local itemPos = item:getPosition()
|
||||||
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
||||||
|
|
||||||
if item:getCount() > 1 then
|
if item:getCount() > 1 then
|
||||||
|
g_game.look(item)
|
||||||
modules.game_interface.moveStackableItem(item, toPos)
|
modules.game_interface.moveStackableItem(item, toPos)
|
||||||
else
|
else
|
||||||
g_game.move(item, toPos, 1)
|
g_game.move(item, toPos, 1)
|
||||||
|
|
|
@ -79,7 +79,6 @@ Texture::Texture(const ImagePtr& image, bool buildMipmaps)
|
||||||
|
|
||||||
Texture::~Texture()
|
Texture::~Texture()
|
||||||
{
|
{
|
||||||
assert(!g_app.isTerminated());
|
|
||||||
// free texture from gl memory
|
// free texture from gl memory
|
||||||
if(g_graphics.ok() && m_id != 0)
|
if(g_graphics.ok() && m_id != 0)
|
||||||
glDeleteTextures(1, &m_id);
|
glDeleteTextures(1, &m_id);
|
||||||
|
|
|
@ -40,9 +40,12 @@ void TextureManager::terminate()
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// check for leaks
|
// check for leaks
|
||||||
int refs = 0;
|
int refs = 0;
|
||||||
for(const auto& it : m_textures)
|
for(const auto& it : m_textures) {
|
||||||
if(it.second->ref_count() > 1)
|
if(it.second->ref_count() > 1) {
|
||||||
refs++;
|
refs++;
|
||||||
|
g_logger.debug(stdext::format("texture reference released: %s", it.first));
|
||||||
|
}
|
||||||
|
}
|
||||||
if(refs > 0)
|
if(refs > 0)
|
||||||
g_logger.debug(stdext::format("%d textures references left", refs));
|
g_logger.debug(stdext::format("%d textures references left", refs));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,12 @@ Game::Game()
|
||||||
m_protocolVersion = 0;
|
m_protocolVersion = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::terminate()
|
||||||
|
{
|
||||||
|
resetGameStates();
|
||||||
|
m_protocolGame = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Game::resetGameStates()
|
void Game::resetGameStates()
|
||||||
{
|
{
|
||||||
m_online = false;
|
m_online = false;
|
||||||
|
|
|
@ -42,6 +42,8 @@ class Game
|
||||||
public:
|
public:
|
||||||
Game();
|
Game();
|
||||||
|
|
||||||
|
void terminate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetGameStates();
|
void resetGameStates();
|
||||||
|
|
||||||
|
@ -241,9 +243,6 @@ public:
|
||||||
void setClientVersion(int version);
|
void setClientVersion(int version);
|
||||||
int getClientVersion() { return m_protocolVersion; }
|
int getClientVersion() { return m_protocolVersion; }
|
||||||
|
|
||||||
void setRSA(const std::string& rsa);
|
|
||||||
std::string getRSA() { return m_rsa; }
|
|
||||||
|
|
||||||
bool canPerformGameAction();
|
bool canPerformGameAction();
|
||||||
bool checkBotProtection();
|
bool checkBotProtection();
|
||||||
|
|
||||||
|
@ -298,7 +297,6 @@ private:
|
||||||
std::string m_worldName;
|
std::string m_worldName;
|
||||||
std::bitset<Otc::LastGameFeature> m_features;
|
std::bitset<Otc::LastGameFeature> m_features;
|
||||||
int m_protocolVersion;
|
int m_protocolVersion;
|
||||||
std::string m_rsa;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Game g_game;
|
extern Game g_game;
|
||||||
|
|
|
@ -298,6 +298,20 @@ void Item::serializeItem(const BinaryTreePtr& out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Item::getSubType()
|
||||||
|
{
|
||||||
|
if(isSplash() || isFluidContainer())
|
||||||
|
return m_countOrSubType;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Item::getCount()
|
||||||
|
{
|
||||||
|
if(isStackable())
|
||||||
|
return m_countOrSubType;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool Item::isMoveable()
|
bool Item::isMoveable()
|
||||||
{
|
{
|
||||||
return !rawGetThingType()->isNotMoveable();
|
return !rawGetThingType()->isNotMoveable();
|
||||||
|
|
|
@ -90,8 +90,8 @@ public:
|
||||||
void setSubType(int subType) { m_countOrSubType = subType; }
|
void setSubType(int subType) { m_countOrSubType = subType; }
|
||||||
|
|
||||||
int getCountOrSubType() { return m_countOrSubType; }
|
int getCountOrSubType() { return m_countOrSubType; }
|
||||||
int getSubType() { return m_countOrSubType; }
|
int getSubType();
|
||||||
int getCount() { return m_countOrSubType; }
|
int getCount();
|
||||||
uint32 getId() { return m_id; }
|
uint32 getId() { return m_id; }
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void UIItem::drawSelf(Fw::DrawPane drawPane)
|
||||||
g_painter->setColor(Color::white);
|
g_painter->setColor(Color::white);
|
||||||
m_item->draw(dest, scaleFactor, true);
|
m_item->draw(dest, scaleFactor, true);
|
||||||
|
|
||||||
if(m_font && (m_item->isStackable() || m_item->isChargeable()) && m_item->getCount() > 1) {
|
if(m_font && (m_item->isStackable() || m_item->isChargeable()) && m_item->getCountOrSubType() > 1) {
|
||||||
std::string count = stdext::to_string(m_item->getCount());
|
std::string count = stdext::to_string(m_item->getCount());
|
||||||
g_painter->setColor(Color(231, 231, 231));
|
g_painter->setColor(Color(231, 231, 231));
|
||||||
m_font->drawText(count, Rect(m_rect.topLeft(), m_rect.bottomRight() - Point(3, 0)), Fw::AlignBottomRight);
|
m_font->drawText(count, Rect(m_rect.topLeft(), m_rect.bottomRight() - Point(3, 0)), Fw::AlignBottomRight);
|
||||||
|
|
Loading…
Reference in New Issue