Merge pull request #1608 from GriffinRichards/fix-fieldmap
Fix some incorrect fieldmap names
This commit is contained in:
@@ -1185,10 +1185,10 @@ static u16 GetDecorationElevation(u8 decoration, u8 tileIndex)
|
||||
switch (decoration)
|
||||
{
|
||||
case DECOR_STAND:
|
||||
elevation = sDecorationStandElevations[tileIndex] << METATILE_ELEVATION_SHIFT;
|
||||
elevation = sDecorationStandElevations[tileIndex] << MAPGRID_ELEVATION_SHIFT;
|
||||
return elevation;
|
||||
case DECOR_SLIDE:
|
||||
elevation = sDecorationSlideElevation[tileIndex] << METATILE_ELEVATION_SHIFT;
|
||||
elevation = sDecorationSlideElevation[tileIndex] << MAPGRID_ELEVATION_SHIFT;
|
||||
return elevation;
|
||||
default:
|
||||
return elevation;
|
||||
@@ -1199,7 +1199,7 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
|
||||
{
|
||||
u16 i, j;
|
||||
s16 x, y;
|
||||
u16 behavior;
|
||||
u16 attributes;
|
||||
u16 impassableFlag;
|
||||
u16 overlapsWall;
|
||||
u16 elevation;
|
||||
@@ -1210,9 +1210,10 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
|
||||
for (i = 0; i < decWidth; i++)
|
||||
{
|
||||
x = mapX + i;
|
||||
behavior = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]);
|
||||
if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (behavior >> METATILE_ELEVATION_SHIFT)))
|
||||
impassableFlag = METATILE_COLLISION_MASK;
|
||||
attributes = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]);
|
||||
if (MetatileBehavior_IsSecretBaseImpassable(attributes & METATILE_ATTR_BEHAVIOR_MASK) == TRUE
|
||||
|| (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT) != METATILE_LAYER_TYPE_NORMAL))
|
||||
impassableFlag = MAPGRID_COLLISION_MASK;
|
||||
else
|
||||
impassableFlag = 0;
|
||||
|
||||
@@ -1471,24 +1472,26 @@ static void AttemptCancelPlaceDecoration(u8 taskId)
|
||||
DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt);
|
||||
}
|
||||
|
||||
// Note: behaviorBy is pre-anded with METATILE_ELEVATION_MASK.
|
||||
static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 behaviorBy)
|
||||
static bool8 IsSecretBaseTrainerSpot(u8 behaviorAt, u16 layerType)
|
||||
{
|
||||
if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || behaviorBy != 0)
|
||||
if (!(MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) == TRUE && layerType == METATILE_LAYER_TYPE_NORMAL))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 behaviorBy)
|
||||
// Can't place decoration where the player was standing when they interacted with the PC
|
||||
static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 layerType)
|
||||
{
|
||||
if (x == gTasks[taskId].tInitialX + MAP_OFFSET && y == gTasks[taskId].tInitialY + MAP_OFFSET && behaviorBy != 0)
|
||||
if (x == gTasks[taskId].tInitialX + MAP_OFFSET
|
||||
&& y == gTasks[taskId].tInitialY + MAP_OFFSET
|
||||
&& layerType != METATILE_LAYER_TYPE_NORMAL)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool8 IsFloorOrBoardAndHole(u16 behaviorAt, const struct Decoration *decoration)
|
||||
{
|
||||
if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE)
|
||||
if (MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) != TRUE)
|
||||
{
|
||||
if (decoration->id == DECOR_SOLID_BOARD && MetatileBehavior_IsSecretBaseHole(behaviorAt) == TRUE)
|
||||
return TRUE;
|
||||
@@ -1505,7 +1508,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
|
||||
u8 i;
|
||||
u8 j;
|
||||
u8 behaviorAt;
|
||||
u16 behaviorBy;
|
||||
u16 layerType;
|
||||
u8 mapY;
|
||||
u8 mapX;
|
||||
s16 curY;
|
||||
@@ -1524,14 +1527,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
|
||||
{
|
||||
curX = gTasks[taskId].tCursorX + j;
|
||||
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
||||
behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
|
||||
layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
|
||||
if (!IsFloorOrBoardAndHole(behaviorAt, decoration))
|
||||
return FALSE;
|
||||
|
||||
if (!IsntInitialPosition(taskId, curX, curY, behaviorBy))
|
||||
if (!IsntInitialPosition(taskId, curX, curY, layerType))
|
||||
return FALSE;
|
||||
|
||||
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
|
||||
behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
|
||||
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1545,14 +1548,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
|
||||
{
|
||||
curX = gTasks[taskId].tCursorX + j;
|
||||
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
||||
behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
|
||||
if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, behaviorBy))
|
||||
layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
|
||||
if (!MetatileBehavior_IsNormal(behaviorAt) && !IsSecretBaseTrainerSpot(behaviorAt, layerType))
|
||||
return FALSE;
|
||||
|
||||
if (!IsntInitialPosition(taskId, curX, curY, behaviorBy))
|
||||
if (!IsntInitialPosition(taskId, curX, curY, layerType))
|
||||
return FALSE;
|
||||
|
||||
if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
|
||||
if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1562,14 +1565,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
|
||||
{
|
||||
curX = gTasks[taskId].tCursorX + j;
|
||||
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
|
||||
behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ELEVATION_MASK;
|
||||
layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ATTR_LAYER_MASK;
|
||||
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
|
||||
return FALSE;
|
||||
|
||||
if (!IsntInitialPosition(taskId, curX, curY, behaviorBy))
|
||||
if (!IsntInitialPosition(taskId, curX, curY, layerType))
|
||||
return FALSE;
|
||||
|
||||
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
|
||||
behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
|
||||
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1606,7 +1609,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
|
||||
if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user