Pret merge (14th of August) (#5165)
This commit is contained in:
commit
a00a584284
3 changed files with 23 additions and 26 deletions
|
@ -130,7 +130,7 @@ struct MapEvents
|
||||||
struct MapConnection
|
struct MapConnection
|
||||||
{
|
{
|
||||||
u8 direction;
|
u8 direction;
|
||||||
u32 offset;
|
s32 offset;
|
||||||
u8 mapGroup;
|
u8 mapGroup;
|
||||||
u8 mapNum;
|
u8 mapNum;
|
||||||
};
|
};
|
||||||
|
|
|
@ -141,7 +141,7 @@ static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader)
|
||||||
for (i = 0; i < count; i++, connection++)
|
for (i = 0; i < count; i++, connection++)
|
||||||
{
|
{
|
||||||
struct MapHeader const *cMap = GetMapHeaderFromConnection(connection);
|
struct MapHeader const *cMap = GetMapHeaderFromConnection(connection);
|
||||||
u32 offset = connection->offset;
|
s32 offset = connection->offset;
|
||||||
switch (connection->direction)
|
switch (connection->direction)
|
||||||
{
|
{
|
||||||
case CONNECTION_SOUTH:
|
case CONNECTION_SOUTH:
|
||||||
|
|
|
@ -430,46 +430,43 @@ static bool8 IsHiddenItemPresentAtCoords(const struct MapEvents *events, s16 x,
|
||||||
|
|
||||||
static bool8 IsHiddenItemPresentInConnection(const struct MapConnection *connection, int x, int y)
|
static bool8 IsHiddenItemPresentInConnection(const struct MapConnection *connection, int x, int y)
|
||||||
{
|
{
|
||||||
|
s16 connectionX, connectionY;
|
||||||
|
struct MapHeader const *const connectionHeader = GetMapHeaderFromConnection(connection);
|
||||||
|
|
||||||
u16 localX, localY;
|
// To convert our x/y into coordinates that are relative to the connected map, we must:
|
||||||
u32 localOffset;
|
// - Subtract the virtual offset used for the border buffer (MAP_OFFSET).
|
||||||
s32 localLength;
|
// - Subtract the horizontal offset between North/South connections, or the vertical offset for East/West
|
||||||
|
// - Account for map size. (0,0) is in the NW corner of our map, so when looking North/West we have to add the height/width of the connected map,
|
||||||
struct MapHeader const *const mapHeader = GetMapHeaderFromConnection(connection);
|
// and when looking South/East we have to subtract the height/width of our current map.
|
||||||
|
#define localX (x - MAP_OFFSET)
|
||||||
|
#define localY (y - MAP_OFFSET)
|
||||||
switch (connection->direction)
|
switch (connection->direction)
|
||||||
{
|
{
|
||||||
// same weird temp variable behavior seen in IsHiddenItemPresentAtCoords
|
|
||||||
case CONNECTION_NORTH:
|
case CONNECTION_NORTH:
|
||||||
localOffset = connection->offset + MAP_OFFSET;
|
connectionX = localX - connection->offset;
|
||||||
localX = x - localOffset;
|
connectionY = connectionHeader->mapLayout->height + localY;
|
||||||
localLength = mapHeader->mapLayout->height - MAP_OFFSET;
|
|
||||||
localY = localLength + y; // additions are reversed for some reason
|
|
||||||
break;
|
break;
|
||||||
case CONNECTION_SOUTH:
|
case CONNECTION_SOUTH:
|
||||||
localOffset = connection->offset + MAP_OFFSET;
|
connectionX = localX - connection->offset;
|
||||||
localX = x - localOffset;
|
connectionY = localY - gMapHeader.mapLayout->height;
|
||||||
localLength = gMapHeader.mapLayout->height + MAP_OFFSET;
|
|
||||||
localY = y - localLength;
|
|
||||||
break;
|
break;
|
||||||
case CONNECTION_WEST:
|
case CONNECTION_WEST:
|
||||||
localLength = mapHeader->mapLayout->width - MAP_OFFSET;
|
connectionX = connectionHeader->mapLayout->width + localX;
|
||||||
localX = localLength + x; // additions are reversed for some reason
|
connectionY = localY - connection->offset;
|
||||||
localOffset = connection->offset + MAP_OFFSET;
|
|
||||||
localY = y - localOffset;
|
|
||||||
break;
|
break;
|
||||||
case CONNECTION_EAST:
|
case CONNECTION_EAST:
|
||||||
localLength = gMapHeader.mapLayout->width + MAP_OFFSET;
|
connectionX = localX - gMapHeader.mapLayout->width;
|
||||||
localX = x - localLength;
|
connectionY = localY - connection->offset;
|
||||||
localOffset = connection->offset + MAP_OFFSET;
|
|
||||||
localY = y - localOffset;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return IsHiddenItemPresentAtCoords(mapHeader->events, localX, localY);
|
return IsHiddenItemPresentAtCoords(connectionHeader->events, connectionX, connectionY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef localX
|
||||||
|
#undef localY
|
||||||
|
|
||||||
static void CheckForHiddenItemsInMapConnection(u8 taskId)
|
static void CheckForHiddenItemsInMapConnection(u8 taskId)
|
||||||
{
|
{
|
||||||
s16 playerX, playerY;
|
s16 playerX, playerY;
|
||||||
|
|
Loading…
Reference in a new issue