Disambiguate fieldmap names

This commit is contained in:
GriffinR
2022-01-19 10:15:32 -05:00
parent f127e64a3c
commit a8b466dc80
14 changed files with 120 additions and 110 deletions
+18 -19
View File
@@ -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,9 @@ 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) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT)))
impassableFlag = MAPGRID_COLLISION_MASK;
else
impassableFlag = 0;
@@ -1471,17 +1471,16 @@ 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 IsNonBlockNonElevated(u8 behaviorAt, u16 layerType)
{
if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || behaviorBy != 0)
if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || layerType != 0)
return FALSE;
return TRUE;
}
static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 behaviorBy)
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 != 0)
return FALSE;
return TRUE;
}
@@ -1505,7 +1504,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,11 +1523,11 @@ 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);
@@ -1545,11 +1544,11 @@ 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) && !IsNonBlockNonElevated(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)
@@ -1562,11 +1561,11 @@ 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);