fix walk up/down with parcels
This commit is contained in:
parent
7fef0809cb
commit
a5b4ee2c19
|
@ -10,7 +10,7 @@ function UIProgressBar.create()
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIProgressBar:setPercent(percent)
|
function UIProgressBar:setPercent(percent)
|
||||||
self.m_percent = percent
|
self.m_percent = math.max(math.min(percent, 100), 0)
|
||||||
self:updateBackground()
|
self:updateBackground()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ Module
|
||||||
dependencies:
|
dependencies:
|
||||||
- game_healthbar
|
- game_healthbar
|
||||||
- game_inventory
|
- game_inventory
|
||||||
- game_skills
|
//- game_skills
|
||||||
- game_textmessage
|
- game_textmessage
|
||||||
- game_viplist
|
//- game_viplist
|
||||||
- game_console
|
- game_console
|
||||||
- game_outfit
|
- game_outfit
|
||||||
- game_containers
|
- game_containers
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <framework/core/resourcemanager.h>
|
#include <framework/core/resourcemanager.h>
|
||||||
#include <framework/util/utf8.h>
|
#include <framework/util/utf8.h>
|
||||||
|
|
||||||
|
#define HSB_BIT_SET(p, n) (p[(n)/8] |= (128 >>((n)%8)))
|
||||||
|
|
||||||
WIN32Window::WIN32Window()
|
WIN32Window::WIN32Window()
|
||||||
{
|
{
|
||||||
m_window = 0;
|
m_window = 0;
|
||||||
|
@ -536,7 +538,6 @@ void WIN32Window::swapBuffers()
|
||||||
|
|
||||||
void WIN32Window::restoreMouseCursor()
|
void WIN32Window::restoreMouseCursor()
|
||||||
{
|
{
|
||||||
logTraceDebug();
|
|
||||||
if(m_cursor) {
|
if(m_cursor) {
|
||||||
DestroyCursor(m_cursor);
|
DestroyCursor(m_cursor);
|
||||||
m_cursor = NULL;
|
m_cursor = NULL;
|
||||||
|
@ -547,13 +548,11 @@ void WIN32Window::restoreMouseCursor()
|
||||||
|
|
||||||
void WIN32Window::showMouse()
|
void WIN32Window::showMouse()
|
||||||
{
|
{
|
||||||
logTraceDebug();
|
|
||||||
ShowCursor(true);
|
ShowCursor(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WIN32Window::hideMouse()
|
void WIN32Window::hideMouse()
|
||||||
{
|
{
|
||||||
logTraceDebug();
|
|
||||||
ShowCursor(false);
|
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);
|
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)
|
void WIN32Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||||
{
|
{
|
||||||
logTraceDebug();
|
|
||||||
std::stringstream fin;
|
std::stringstream fin;
|
||||||
g_resources.loadFile(file, 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)
|
void Game::processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos)
|
||||||
{
|
{
|
||||||
// walk
|
if(!oldPos.isInRange(newPos, 1, 1, 0))
|
||||||
if(oldPos.isInRange(newPos, 1, 1, 0)) {
|
logError("unexpected creature move");
|
||||||
creature->walk(oldPos, newPos);
|
|
||||||
// teleport
|
// animate walk
|
||||||
} else {
|
creature->walk(oldPos, newPos);
|
||||||
// stop walking on teleport
|
}
|
||||||
creature->stopWalk();
|
|
||||||
}
|
void Game::processCreatureTeleport(const CreaturePtr& creature)
|
||||||
|
{
|
||||||
|
// stop walking on creature teleports
|
||||||
|
creature->stopWalk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::processAttackCancel()
|
void Game::processAttackCancel()
|
||||||
|
@ -170,7 +173,21 @@ void Game::walk(Otc::Direction direction)
|
||||||
if(!m_localPlayer->canWalk(direction))
|
if(!m_localPlayer->canWalk(direction))
|
||||||
return;
|
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);
|
forceWalk(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,6 +385,7 @@ int Game::getThingStackpos(const ThingPtr& thing)
|
||||||
{
|
{
|
||||||
// thing is at map
|
// thing is at map
|
||||||
if(thing->getPos().x != 65535) {
|
if(thing->getPos().x != 65535) {
|
||||||
|
dump << thing->getPos();
|
||||||
TilePtr tile = g_map.getTile(thing->getPos());
|
TilePtr tile = g_map.getTile(thing->getPos());
|
||||||
if(tile)
|
if(tile)
|
||||||
return tile->getThingStackpos(thing);
|
return tile->getThingStackpos(thing);
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
void processContainerAddItem(int containerId, const ItemPtr& item);
|
void processContainerAddItem(int containerId, const ItemPtr& item);
|
||||||
void processInventoryChange(int slot, const ItemPtr& item);
|
void processInventoryChange(int slot, const ItemPtr& item);
|
||||||
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
|
void processCreatureMove(const CreaturePtr& creature, const Position& oldPos, const Position& newPos);
|
||||||
|
void processCreatureTeleport(const CreaturePtr& creature);
|
||||||
void processAttackCancel();
|
void processAttackCancel();
|
||||||
void processWalkCancel(Otc::Direction direction);
|
void processWalkCancel(Otc::Direction direction);
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// avoid doing more walks than wanted when receiving a lot of walks from server
|
// 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;
|
return false;
|
||||||
|
|
||||||
// cannot walk while locked
|
// cannot walk while locked
|
||||||
|
@ -96,13 +96,6 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||||
else
|
else
|
||||||
m_walkLocked = false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +115,7 @@ void LocalPlayer::cancelWalk(Otc::Direction direction)
|
||||||
void LocalPlayer::stopWalk()
|
void LocalPlayer::stopWalk()
|
||||||
{
|
{
|
||||||
Creature::stopWalk();
|
Creature::stopWalk();
|
||||||
|
m_lastPrewalkDone = true;
|
||||||
m_lastPrewalkDestionation = Position();
|
m_lastPrewalkDestionation = Position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,11 +244,19 @@ void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
|
||||||
if(!thing)
|
if(!thing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Position oldPos = thing->getPos();
|
||||||
|
bool teleport = false;
|
||||||
|
if(oldPos.isValid() && !oldPos.isInRange(pos,1,1,0))
|
||||||
|
teleport = true;
|
||||||
|
|
||||||
TilePtr tile = getTile(pos);
|
TilePtr tile = getTile(pos);
|
||||||
|
|
||||||
if(CreaturePtr creature = thing->asCreature()) {
|
if(CreaturePtr creature = thing->asCreature()) {
|
||||||
tile->addThing(thing, stackPos);
|
tile->addThing(thing, stackPos);
|
||||||
m_creatures[creature->getId()] = creature;
|
m_creatures[creature->getId()] = creature;
|
||||||
|
|
||||||
|
if(teleport)
|
||||||
|
g_game.processCreatureTeleport(creature);
|
||||||
}
|
}
|
||||||
else if(MissilePtr shot = thing->asMissile()) {
|
else if(MissilePtr shot = thing->asMissile()) {
|
||||||
m_missilesAtFloor[shot->getPos().z].push_back(shot);
|
m_missilesAtFloor[shot->getPos().z].push_back(shot);
|
||||||
|
|
|
@ -152,12 +152,12 @@ ThingPtr Tile::getTopThing()
|
||||||
|
|
||||||
ThingPtr Tile::removeThingByStackpos(int stackPos)
|
ThingPtr Tile::removeThingByStackpos(int stackPos)
|
||||||
{
|
{
|
||||||
ThingPtr oldObject;
|
ThingPtr oldThing;
|
||||||
if(stackPos >= 0 && stackPos < (int)m_things.size()) {
|
if(stackPos >= 0 && stackPos < (int)m_things.size()) {
|
||||||
oldObject = m_things[stackPos];
|
oldThing = m_things[stackPos];
|
||||||
m_things.erase(m_things.begin() + stackPos);
|
m_things.erase(m_things.begin() + stackPos);
|
||||||
}
|
}
|
||||||
return oldObject;
|
return oldThing;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThingPtr Tile::removeThing(const ThingPtr& thing)
|
ThingPtr Tile::removeThing(const ThingPtr& thing)
|
||||||
|
@ -168,13 +168,13 @@ ThingPtr Tile::removeThing(const ThingPtr& thing)
|
||||||
m_effects.erase(it);
|
m_effects.erase(it);
|
||||||
return thing;
|
return thing;
|
||||||
}
|
}
|
||||||
ThingPtr oldObject;
|
ThingPtr oldThing;
|
||||||
auto it = std::find(m_things.begin(), m_things.end(), thing);
|
auto it = std::find(m_things.begin(), m_things.end(), thing);
|
||||||
if(it != m_things.end()) {
|
if(it != m_things.end()) {
|
||||||
oldObject = *it;
|
oldThing = *it;
|
||||||
m_things.erase(it);
|
m_things.erase(it);
|
||||||
}
|
}
|
||||||
return oldObject;
|
return oldThing;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CreaturePtr> Tile::getCreatures()
|
std::vector<CreaturePtr> Tile::getCreatures()
|
||||||
|
|
Loading…
Reference in New Issue