just fixes

* clean map when relogging
* fix otclientrc.lua reloading
* fix game disconnection messagebox
* fix animated texture
This commit is contained in:
Eduardo Bart 2012-03-19 14:54:47 -03:00
parent 4bac617fd9
commit f62f507813
9 changed files with 39 additions and 10 deletions

View File

@ -1,7 +1,7 @@
Client = {}
function Client.reloadScripts()
dofile 'otclientrc.lua'
dofile '/otclientrc'
reloadModules()
TextMessage.displayEventAdvance('All modules and scripts were reloaded.')
print('All modules and scripts were reloaded.')

View File

@ -4,6 +4,7 @@ CharacterList = { }
local charactersWindow
local loadBox
local characterList
local errorBox
-- private functions
local function onCharactersWindowKeyPress(self, keyCode, keyboardModifiers)
@ -54,14 +55,20 @@ end
function onGameLoginError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Login error: " .. message)
errorBox.onOk = CharacterList.showAgain
errorBox = displayErrorBox("Login Error", "Login error: " .. message)
errorBox.onOk = function()
errorBox = nil
CharacterList.showAgain()
end
end
function onGameConnectionError(message)
CharacterList.destroyLoadBox()
local errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
errorBox.onOk = CharacterList.showAgain
errorBox = displayErrorBox("Login Error", "Connection error: " .. message)
errorBox.onOk = function()
errorBox = nil
CharacterList.showAgain()
end
end
-- public functions
@ -137,7 +144,7 @@ function CharacterList.destroy()
end
function CharacterList.show()
if not loadBox then
if not loadBox and not errorBox then
charactersWindow:show()
charactersWindow:raise()
charactersWindow:focus()

View File

@ -70,6 +70,6 @@ void AnimatedTexture::processAnimation()
AnimatedTexturePtr self = asAnimatedTexture();
// 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]);
}

View File

@ -55,6 +55,7 @@ Creature::Creature() : Thing()
m_emblem = Otc::EmblemNone;
m_shieldBlink = false;
m_showShieldTexture = true;
m_removed = false;
m_informationFont = g_fonts.getFont("verdana-11px-rounded");
}

View File

@ -59,6 +59,7 @@ public:
void setShieldTexture(const std::string& filename, bool blink);
void setEmblemTexture(const std::string& filename);
void setPassable(bool passable) { m_passable = passable; }
void setRemoved(bool removed) { m_removed = removed; }
void addTimedSquare(uint8 color);
void removeTimedSquare() { m_showTimedSquare = false; }
@ -88,6 +89,7 @@ public:
virtual void stopWalk();
bool isWalking() { return m_walking; }
bool isRemoved() { return m_removed; }
CreaturePtr asCreature() { return std::static_pointer_cast<Creature>(shared_from_this()); }
@ -120,6 +122,7 @@ protected:
Color m_staticSquareColor;
bool m_showTimedSquare;
bool m_showStaticSquare;
bool m_removed;
FontPtr m_informationFont;
Color m_informationColor;

View File

@ -115,6 +115,9 @@ void Game::processGameEnd()
// reset game state
resetGameStates();
// clean map creatures
g_map.cleanDynamicThings();
}
void Game::processLogin()
@ -336,7 +339,7 @@ void Game::forceLogout()
if(!isOnline())
return;
//m_protocolGame->sendLogout();
m_protocolGame->sendLogout();
processDisconnect();
}

View File

@ -109,8 +109,18 @@ void Map::save()
void Map::clean()
{
cleanDynamicThings();
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)
m_floorMissiles[i].clear();
m_animatedTexts.clear();
@ -261,6 +271,8 @@ void Map::removeCreatureById(uint32 id)
{
if(id == 0)
return;
if(CreaturePtr creature = m_knownCreatures[id])
creature->setRemoved(true);
m_knownCreatures.erase(id);
}

View File

@ -37,6 +37,7 @@ public:
void load();
void save();
void clean();
void cleanDynamicThings();
// thing related
void addThing(const ThingPtr& thing, const Position& pos, int stackPos = -1);

View File

@ -100,6 +100,8 @@ void Tile::draw(const Point& dest, float scaleFactor, int drawFlags)
if(drawFlags & Otc::DrawCreatures) {
if(animate) {
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,
dest.y + ((creature->getPosition().y - m_position.y)*Otc::TILE_PIXELS - m_drawElevation)*scaleFactor), scaleFactor, animate);