LOL: - reverted last commit which would break map shape drawing (I have now changed the map shape coordinates to decimal numbers though since some compiler seems to complain about signed hex numbers)

- added support for placing items in wall niches (like that one in the thugs' cave)

svn-id: r39823
This commit is contained in:
Florian Kagerer 2009-04-04 00:19:34 +00:00
parent 121f174d61
commit 3d608dda3e
4 changed files with 36 additions and 20 deletions

View File

@ -1916,8 +1916,8 @@ uint16 LoLEngine::getClosestPartyMember(int x, int y) {
if (!(_characters[i].flags & 1) || _characters[i].hitPointsCur <= 0) if (!(_characters[i].flags & 1) || _characters[i].hitPointsCur <= 0)
continue; continue;
int16 charX = 0; uint16 charX = 0;
int16 charY = 0; uint16 charY = 0;
calcCoordinatesForSingleCharacter(i, charX, charY); calcCoordinatesForSingleCharacter(i, charX, charY);
int d = ABS(x - charX) + ABS(y - charY); int d = ABS(x - charX) + ABS(y - charY);

View File

@ -851,8 +851,8 @@ private:
uint16 calcNewBlockPosition(uint16 curBlock, uint16 direction); uint16 calcNewBlockPosition(uint16 curBlock, uint16 direction);
uint16 calcBlockIndex(uint16 x, uint16 y); uint16 calcBlockIndex(uint16 x, uint16 y);
void calcCoordinates(uint16 &x, uint16 &y, int block, uint16 xOffs, uint16 yOffs); void calcCoordinates(uint16 &x, uint16 &y, int block, uint16 xOffs, uint16 yOffs);
void calcCoordinatesForSingleCharacter(int charNum, int16 &x, int16 &y); void calcCoordinatesForSingleCharacter(int charNum, uint16 &x, uint16 &y);
void calcCoordinatesAddDirectionOffset(int16 &x, int16 &y, int direction); void calcCoordinatesAddDirectionOffset(uint16 &x, uint16 &y, int direction);
int clickedWallShape(uint16 block, uint16 direction); int clickedWallShape(uint16 block, uint16 direction);
int clickedLeverOn(uint16 block, uint16 direction); int clickedLeverOn(uint16 block, uint16 direction);
@ -1205,7 +1205,7 @@ private:
uint8 *_mapCursorOverlay; uint8 *_mapCursorOverlay;
uint8 _automapTopLeftX; uint8 _automapTopLeftX;
uint8 _automapTopLeftY; uint8 _automapTopLeftY;
static const uint8 _mapCoords[12][4]; static const int8 _mapCoords[12][4];
bool _mapUpdateNeeded; bool _mapUpdateNeeded;
}; };

View File

@ -662,7 +662,7 @@ void LoLEngine::calcCoordinates(uint16 &x, uint16 &y, int block, uint16 xOffs, u
y = ((block & 0xffe0) << 3) | yOffs; y = ((block & 0xffe0) << 3) | yOffs;
} }
void LoLEngine::calcCoordinatesForSingleCharacter(int charNum, int16 &x, int16 &y) { void LoLEngine::calcCoordinatesForSingleCharacter(int charNum, uint16 &x, uint16 &y) {
static const uint8 xOffsets[] = { 0x80, 0x00, 0x00, 0x40, 0xC0, 0x00, 0x40, 0x80, 0xC0 }; static const uint8 xOffsets[] = { 0x80, 0x00, 0x00, 0x40, 0xC0, 0x00, 0x40, 0x80, 0xC0 };
int c = countActiveCharacters(); int c = countActiveCharacters();
if (!c) if (!c)
@ -679,19 +679,25 @@ void LoLEngine::calcCoordinatesForSingleCharacter(int charNum, int16 &x, int16 &
y |= (_partyPosY & 0xff00); y |= (_partyPosY & 0xff00);
} }
void LoLEngine::calcCoordinatesAddDirectionOffset(int16 &x, int16 &y, int direction) { void LoLEngine::calcCoordinatesAddDirectionOffset(uint16 &x, uint16 &y, int direction) {
if (!direction) if (!direction)
return; return;
int tx = x;
int ty = y;
if (direction & 1) if (direction & 1)
SWAP(x, y); SWAP(tx, ty);
if (direction == 1) if (direction != 1)
y = (y - 256) * -1; ty = (ty - 256) * -1;
if (direction == 3) { if (direction != 3) {
x = (x - 256) * -1; tx = (tx - 256) * -1;
} }
x = tx;
y = ty;
} }
bool LoLEngine::checkBlockPassability(uint16 block, uint16 direction) { bool LoLEngine::checkBlockPassability(uint16 block, uint16 direction) {
@ -781,6 +787,16 @@ int LoLEngine::clickedDoorSwitch(uint16 block, uint16 direction) {
} }
int LoLEngine::clickedNiche(uint16 block, uint16 direction) { int LoLEngine::clickedNiche(uint16 block, uint16 direction) {
uint8 v = _wllShapeMap[_levelBlockProperties[block].walls[direction]];
if (!clickedShape(v) || !_itemInHand)
return 0;
uint16 x = 0x80;
uint16 y = 0xff;
calcCoordinatesAddDirectionOffset(x, y, _currentDirection);
calcCoordinates(x, y, block, x, y);
setItemPosition(_itemInHand, x, y, 8, 1);
setHandItem(0);
return 1; return 1;
} }
@ -1878,7 +1894,7 @@ void LoLEngine::drawDecorations(int index) {
} }
void LoLEngine::drawBlockEffects(int index, int type) { void LoLEngine::drawBlockEffects(int index, int type) {
static const int16 yOffs[] = { 0xff, 0xff, 0x80, 0x80 }; static const uint16 yOffs[] = { 0xff, 0xff, 0x80, 0x80 };
uint8 flg = _visibleBlocks[index]->flags; uint8 flg = _visibleBlocks[index]->flags;
// flags: 0x10 = ice wall, 0x20 = teleporter, 0x40 = blue slime spot, 0x80 = blood spot // flags: 0x10 = ice wall, 0x20 = teleporter, 0x40 = blue slime spot, 0x80 = blood spot
if (!(flg & 0xf0)) if (!(flg & 0xf0))
@ -1890,8 +1906,8 @@ void LoLEngine::drawBlockEffects(int index, int type) {
if (!((0x10 << type) & flg)) if (!((0x10 << type) & flg))
continue; continue;
int16 x = 0x80; uint16 x = 0x80;
int16 y = yOffs[type]; uint16 y = yOffs[type];
uint16 drawFlag = (type == 3) ? 0x80 : 0x20; uint16 drawFlag = (type == 3) ? 0x80 : 0x20;
uint8 *ovl = (type == 3) ? _screen->_grayOverlay : 0; uint8 *ovl = (type == 3) ? _screen->_grayOverlay : 0;

View File

@ -3063,11 +3063,11 @@ const uint8 LoLEngine::_clock2Timers[] = {
0x51, 0x52, 0x08, 0x09, 0x0A 0x51, 0x52, 0x08, 0x09, 0x0A
}; };
const uint8 LoLEngine::_mapCoords[12][4] = { const int8 LoLEngine::_mapCoords[12][4] = {
{ 0x00, 0x07, 0x00, 0xFB }, { 0xFB, 0x00, 0x06, 0x00 }, { 0x07, 0x05, 0x07, 0x01 }, { 0, 7, 0, -5 }, { -5, 0, 6, 0 }, { 7, 5, 7, 1 },
{ 0x05, 0x06, 0x04, 0x06 }, { 0x00, 0x07, 0x00, 0xFF }, { 0xFD, 0x00, 0x06, 0x00 }, { 5, 6, 4, 6 }, { 0, 7, 0, -1 }, { -3, 0, 6, 0 },
{ 0x06, 0x07, 0x06, 0xFD }, { 0xFD, 0x05, 0x06, 0x05 }, { 0x01, 0x05, 0x01, 0x01 }, { 6, 7, 6, -3 }, { -3, 5, 6, 5 }, { 1, 5, 1, 1 },
{ 0x03, 0x01, 0x03, 0x01 }, { 0xFF, 0x06, 0xFF, 0xF8 }, { 0xF9, 0xFF, 0x05, 0xFF } { 3, 1, 3, 1 }, { -1, 6, -1, -8 }, { -7, -1, 5, -1 }
}; };
const uint8 LoLEngine::_numClock2Timers = ARRAYSIZE(LoLEngine::_clock2Timers); const uint8 LoLEngine::_numClock2Timers = ARRAYSIZE(LoLEngine::_clock2Timers);