fix walk up/down with parcels

master
Eduardo Bart 12 years ago
parent 7fef0809cb
commit a5b4ee2c19

@ -10,7 +10,7 @@ function UIProgressBar.create()
end
function UIProgressBar:setPercent(percent)
self.m_percent = percent
self.m_percent = math.max(math.min(percent, 100), 0)
self:updateBackground()
end

@ -7,9 +7,9 @@ Module
dependencies:
- game_healthbar
- game_inventory
- game_skills
//- game_skills
- game_textmessage
- game_viplist
//- game_viplist
- game_console
- game_outfit
- game_containers

@ -27,6 +27,8 @@
#include <framework/core/resourcemanager.h>
#include <framework/util/utf8.h>
#define HSB_BIT_SET(p, n) (p[(n)/8] |= (128 >>((n)%8)))
WIN32Window::WIN32Window()
{
m_window = 0;
@ -536,7 +538,6 @@ void WIN32Window::swapBuffers()
void WIN32Window::restoreMouseCursor()
{
logTraceDebug();
if(m_cursor) {
DestroyCursor(m_cursor);
m_cursor = NULL;
@ -547,13 +548,11 @@ void WIN32Window::restoreMouseCursor()
void WIN32Window::showMouse()
{
logTraceDebug();
ShowCursor(true);
}
void WIN32Window::hideMouse()
{
logTraceDebug();
ShowCursor(false);
}
@ -562,12 +561,8 @@ void WIN32Window::displayFatalError(const std::string& message)
MessageBoxA(m_window, message.c_str(), "FATAL ERROR", MB_OK | MB_ICONERROR);
}
#define LSB_BIT_SET(p, n) (p[(n)/8] |= (1 <<((n)%8)))
#define HSB_BIT_SET(p, n) (p[(n)/8] |= (128 >>((n)%8)))
void WIN32Window::setMouseCursor(const std::string& file, const Point& hotSpot)
{
logTraceDebug();
std::stringstream fin;
g_resources.loadFile(file, fin);

@ -138,14 +138,17 @@ void Game::processInventoryChange(int slot, const ItemPtr& item)
void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos)
{
// walk
if(oldPos.isInRange(newPos, 1, 1, 0)) {
creature->walk(oldPos, newPos);
// teleport
} else {
// stop walking on teleport
creature->stopWalk();
}
if(!oldPos.isInRange(newPos, 1, 1, 0))
logError("unexpected creature move");
// animate walk
creature->walk(oldPos, newPos);
}
void Game::processCreatureTeleport(const CreaturePtr& creature)
{
// stop walking on creature teleports
creature->stopWalk();
}
void Game::processAttackCancel()
@ -170,7 +173,21 @@ void Game::walk(Otc::Direction direction)
if(!m_localPlayer->canWalk(direction))
return;
m_localPlayer->preWalk(direction);
// TODO: restore check for blockable tiles
/*
if(toTile && !toTile->isWalkable() && !fromTile->getElevation() >= 3) {
g_game.processTextMessage("statusSmall", "Sorry, not possible.");
return false;
}*/
// only do prewalk to walkable tiles
TilePtr toTile = g_map.getTile(m_localPlayer->getPos() + Position::getPosFromDirection(direction));
if(toTile && toTile->isWalkable())
m_localPlayer->preWalk(direction);
else
m_localPlayer->lockWalk();
forceWalk(direction);
}
@ -368,6 +385,7 @@ int Game::getThingStackpos(const ThingPtr& thing)
{
// thing is at map
if(thing->getPos().x != 65535) {
dump << thing->getPos();
TilePtr tile = g_map.getTile(thing->getPos());
if(tile)
return tile->getThingStackpos(thing);

@ -51,6 +51,7 @@ public:
void processContainerAddItem(int containerId, const ItemPtr& item);
void processInventoryChange(int slot, const ItemPtr& item);
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
void processCreatureTeleport(const CreaturePtr& creature);
void processAttackCancel();
void processWalkCancel(Otc::Direction direction);

@ -87,7 +87,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
return false;
// avoid doing more walks than wanted when receiving a lot of walks from server
if(!m_lastPrewalkDone && !prewalkTimeouted)
if(!m_lastPrewalkDone && m_preWalking && !prewalkTimeouted)
return false;
// cannot walk while locked
@ -96,13 +96,6 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
else
m_walkLocked = false;
// check for blockable tiles in the walk direction
TilePtr tile = g_map.getTile(m_pos + Position::getPosFromDirection(direction));
if(!tile || !tile->isWalkable()) {
g_game.processTextMessage("statusSmall", "Sorry, not possible.");
return false;
}
return true;
}
@ -122,6 +115,7 @@ void LocalPlayer::cancelWalk(Otc::Direction direction)
void LocalPlayer::stopWalk()
{
Creature::stopWalk();
m_lastPrewalkDone = true;
m_lastPrewalkDestionation = Position();
}

@ -244,11 +244,19 @@ void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
if(!thing)
return;
Position oldPos = thing->getPos();
bool teleport = false;
if(oldPos.isValid() && !oldPos.isInRange(pos,1,1,0))
teleport = true;
TilePtr tile = getTile(pos);
if(CreaturePtr creature = thing->asCreature()) {
tile->addThing(thing, stackPos);
m_creatures[creature->getId()] = creature;
if(teleport)
g_game.processCreatureTeleport(creature);
}
else if(MissilePtr shot = thing->asMissile()) {
m_missilesAtFloor[shot->getPos().z].push_back(shot);

@ -152,12 +152,12 @@ ThingPtr Tile::getTopThing()
ThingPtr Tile::removeThingByStackpos(int stackPos)
{
ThingPtr oldObject;
ThingPtr oldThing;
if(stackPos >= 0 && stackPos < (int)m_things.size()) {
oldObject = m_things[stackPos];
oldThing = m_things[stackPos];
m_things.erase(m_things.begin() + stackPos);
}
return oldObject;
return oldThing;
}
ThingPtr Tile::removeThing(const ThingPtr& thing)
@ -168,13 +168,13 @@ ThingPtr Tile::removeThing(const ThingPtr& thing)
m_effects.erase(it);
return thing;
}
ThingPtr oldObject;
ThingPtr oldThing;
auto it = std::find(m_things.begin(), m_things.end(), thing);
if(it != m_things.end()) {
oldObject = *it;
oldThing = *it;
m_things.erase(it);
}
return oldObject;
return oldThing;
}
std::vector<CreaturePtr> Tile::getCreatures()

Loading…
Cancel
Save