just fixes
* clean map when relogging * fix otclientrc.lua reloading * fix game disconnection messagebox * fix animated texture
This commit is contained in:
parent
4bac617fd9
commit
f62f507813
|
@ -1,7 +1,7 @@
|
||||||
Client = {}
|
Client = {}
|
||||||
|
|
||||||
function Client.reloadScripts()
|
function Client.reloadScripts()
|
||||||
dofile 'otclientrc.lua'
|
dofile '/otclientrc'
|
||||||
reloadModules()
|
reloadModules()
|
||||||
TextMessage.displayEventAdvance('All modules and scripts were reloaded.')
|
TextMessage.displayEventAdvance('All modules and scripts were reloaded.')
|
||||||
print('All modules and scripts were reloaded.')
|
print('All modules and scripts were reloaded.')
|
||||||
|
|
|
@ -4,6 +4,7 @@ CharacterList = { }
|
||||||
local charactersWindow
|
local charactersWindow
|
||||||
local loadBox
|
local loadBox
|
||||||
local characterList
|
local characterList
|
||||||
|
local errorBox
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
local function onCharactersWindowKeyPress(self, keyCode, keyboardModifiers)
|
local function onCharactersWindowKeyPress(self, keyCode, keyboardModifiers)
|
||||||
|
@ -54,14 +55,20 @@ end
|
||||||
|
|
||||||
function onGameLoginError(message)
|
function onGameLoginError(message)
|
||||||
CharacterList.destroyLoadBox()
|
CharacterList.destroyLoadBox()
|
||||||
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
|
errorBox = displayErrorBox("Login Error", "Login error: " .. message)
|
||||||
errorBox.onOk = CharacterList.showAgain
|
errorBox.onOk = function()
|
||||||
|
errorBox = nil
|
||||||
|
CharacterList.showAgain()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function onGameConnectionError(message)
|
function onGameConnectionError(message)
|
||||||
CharacterList.destroyLoadBox()
|
CharacterList.destroyLoadBox()
|
||||||
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
|
errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
|
||||||
errorBox.onOk = CharacterList.showAgain
|
errorBox.onOk = function()
|
||||||
|
errorBox = nil
|
||||||
|
CharacterList.showAgain()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
|
@ -137,7 +144,7 @@ function CharacterList.destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
function CharacterList.show()
|
function CharacterList.show()
|
||||||
if not loadBox then
|
if not loadBox and not errorBox then
|
||||||
charactersWindow:show()
|
charactersWindow:show()
|
||||||
charactersWindow:raise()
|
charactersWindow:raise()
|
||||||
charactersWindow:focus()
|
charactersWindow:focus()
|
||||||
|
|
|
@ -70,6 +70,6 @@ void AnimatedTexture::processAnimation()
|
||||||
AnimatedTexturePtr self = asAnimatedTexture();
|
AnimatedTexturePtr self = asAnimatedTexture();
|
||||||
|
|
||||||
// continue to animate only if something still referencing this texture
|
// continue to animate only if something still referencing this texture
|
||||||
if(self.use_count() > 2)
|
if(self.use_count() > 1)
|
||||||
g_eventDispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]);
|
g_eventDispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ Creature::Creature() : Thing()
|
||||||
m_emblem = Otc::EmblemNone;
|
m_emblem = Otc::EmblemNone;
|
||||||
m_shieldBlink = false;
|
m_shieldBlink = false;
|
||||||
m_showShieldTexture = true;
|
m_showShieldTexture = true;
|
||||||
|
m_removed = false;
|
||||||
m_informationFont = g_fonts.getFont("verdana-11px-rounded");
|
m_informationFont = g_fonts.getFont("verdana-11px-rounded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
void setShieldTexture(const std::string& filename, bool blink);
|
void setShieldTexture(const std::string& filename, bool blink);
|
||||||
void setEmblemTexture(const std::string& filename);
|
void setEmblemTexture(const std::string& filename);
|
||||||
void setPassable(bool passable) { m_passable = passable; }
|
void setPassable(bool passable) { m_passable = passable; }
|
||||||
|
void setRemoved(bool removed) { m_removed = removed; }
|
||||||
|
|
||||||
void addTimedSquare(uint8 color);
|
void addTimedSquare(uint8 color);
|
||||||
void removeTimedSquare() { m_showTimedSquare = false; }
|
void removeTimedSquare() { m_showTimedSquare = false; }
|
||||||
|
@ -88,6 +89,7 @@ public:
|
||||||
virtual void stopWalk();
|
virtual void stopWalk();
|
||||||
|
|
||||||
bool isWalking() { return m_walking; }
|
bool isWalking() { return m_walking; }
|
||||||
|
bool isRemoved() { return m_removed; }
|
||||||
|
|
||||||
CreaturePtr asCreature() { return std::static_pointer_cast<Creature>(shared_from_this()); }
|
CreaturePtr asCreature() { return std::static_pointer_cast<Creature>(shared_from_this()); }
|
||||||
|
|
||||||
|
@ -120,6 +122,7 @@ protected:
|
||||||
Color m_staticSquareColor;
|
Color m_staticSquareColor;
|
||||||
bool m_showTimedSquare;
|
bool m_showTimedSquare;
|
||||||
bool m_showStaticSquare;
|
bool m_showStaticSquare;
|
||||||
|
bool m_removed;
|
||||||
|
|
||||||
FontPtr m_informationFont;
|
FontPtr m_informationFont;
|
||||||
Color m_informationColor;
|
Color m_informationColor;
|
||||||
|
|
|
@ -115,6 +115,9 @@ void Game::processGameEnd()
|
||||||
|
|
||||||
// reset game state
|
// reset game state
|
||||||
resetGameStates();
|
resetGameStates();
|
||||||
|
|
||||||
|
// clean map creatures
|
||||||
|
g_map.cleanDynamicThings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::processLogin()
|
void Game::processLogin()
|
||||||
|
@ -336,7 +339,7 @@ void Game::forceLogout()
|
||||||
if(!isOnline())
|
if(!isOnline())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//m_protocolGame->sendLogout();
|
m_protocolGame->sendLogout();
|
||||||
processDisconnect();
|
processDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,18 @@ void Map::save()
|
||||||
|
|
||||||
void Map::clean()
|
void Map::clean()
|
||||||
{
|
{
|
||||||
|
cleanDynamicThings();
|
||||||
m_tiles.clear();
|
m_tiles.clear();
|
||||||
m_knownCreatures.clear();
|
}
|
||||||
|
|
||||||
|
void Map::cleanDynamicThings()
|
||||||
|
{
|
||||||
|
for(const auto& pair : m_knownCreatures) {
|
||||||
|
const CreaturePtr& creature = pair.second;
|
||||||
|
removeThing(creature);
|
||||||
|
creature->setRemoved(true);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0;i<=Otc::MAX_Z;++i)
|
for(int i=0;i<=Otc::MAX_Z;++i)
|
||||||
m_floorMissiles[i].clear();
|
m_floorMissiles[i].clear();
|
||||||
m_animatedTexts.clear();
|
m_animatedTexts.clear();
|
||||||
|
@ -261,12 +271,14 @@ void Map::removeCreatureById(uint32 id)
|
||||||
{
|
{
|
||||||
if(id == 0)
|
if(id == 0)
|
||||||
return;
|
return;
|
||||||
|
if(CreaturePtr creature = m_knownCreatures[id])
|
||||||
|
creature->setRemoved(true);
|
||||||
m_knownCreatures.erase(id);
|
m_knownCreatures.erase(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::setCentralPosition(const Position& centralPosition)
|
void Map::setCentralPosition(const Position& centralPosition)
|
||||||
{
|
{
|
||||||
bool teleported = !m_centralPosition.isInRange(centralPosition, 1,1);
|
bool teleported = !m_centralPosition.isInRange(centralPosition, 1, 1);
|
||||||
m_centralPosition = centralPosition;
|
m_centralPosition = centralPosition;
|
||||||
|
|
||||||
// remove all creatures when teleporting, the server will resend them again
|
// remove all creatures when teleporting, the server will resend them again
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
void load();
|
void load();
|
||||||
void save();
|
void save();
|
||||||
void clean();
|
void clean();
|
||||||
|
void cleanDynamicThings();
|
||||||
|
|
||||||
// thing related
|
// thing related
|
||||||
void addThing(const ThingPtr& thing, const Position& pos, int stackPos = -1);
|
void addThing(const ThingPtr& thing, const Position& pos, int stackPos = -1);
|
||||||
|
|
|
@ -100,6 +100,8 @@ void Tile::draw(const Point& dest, float scaleFactor, int drawFlags)
|
||||||
if(drawFlags & Otc::DrawCreatures) {
|
if(drawFlags & Otc::DrawCreatures) {
|
||||||
if(animate) {
|
if(animate) {
|
||||||
for(const CreaturePtr& creature : m_walkingCreatures) {
|
for(const CreaturePtr& creature : m_walkingCreatures) {
|
||||||
|
if(creature->isRemoved())
|
||||||
|
continue;
|
||||||
creature->draw(Point(dest.x + ((creature->getPosition().x - m_position.x)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor,
|
creature->draw(Point(dest.x + ((creature->getPosition().x - m_position.x)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor,
|
||||||
dest.y + ((creature->getPosition().y - m_position.y)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor), scaleFactor, animate);
|
dest.y + ((creature->getPosition().y - m_position.y)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor), scaleFactor, animate);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue