unify coordinate structs (#1010)
Some checks are pending
build / build (push) Waiting to run

This commit is contained in:
scbroede 2026-03-18 10:05:03 -04:00 committed by GitHub
parent 92fffdc5d9
commit 8fbf711e09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 123 additions and 124 deletions

View File

@ -3,12 +3,31 @@
typedef struct CoordinatesS16 {
s16 x;
s16 y;
union {
s16 y;
s16 z;
};
} CoordinatesS16;
typedef struct CoordinatesU16 {
u16 x;
u16 y;
union {
u16 y;
u16 z;
};
} CoordinatesU16;
typedef struct CoordinatesInt {
int x;
union {
int y;
int z;
};
} CoordinatesInt;
typedef struct CoordinatesFX32 {
fx32 x;
fx32 y;
} CoordinatesFX32;
#endif // POKEPLATINUM_COORDINATES_H

View File

@ -34,16 +34,6 @@
#define MAX_GOOD_WIDTH 3
#define MAX_GOOD_DEPTH 3
typedef struct Coordinates {
u16 x;
u16 z;
} Coordinates;
typedef struct Coordinates2D {
u16 x;
u16 y;
} Coordinates2D;
typedef struct SpherePrice {
u8 sphereType;
u8 minSize;

View File

@ -5,6 +5,7 @@
#include "underground/defs.h"
#include "underground/text_printer.h"
#include "coordinates.h"
#include "savedata.h"
#include "string_gf.h"
#include "sys_task_manager.h"
@ -68,7 +69,7 @@ enum MapMarkerAnim {
#define MAX_RADAR_BLIPS 16
typedef Coordinates *(*CoordinatesGetter)(Coordinates *, int);
typedef CoordinatesU16 *(*GetCoordinatesFunc)(CoordinatesU16 *coordinates, int index);
UndergroundTextPrinter *UndergroundMan_GetCommonTextPrinter(void);
UndergroundTextPrinter *UndergroundMan_GetCaptureFlagTextPrinter(void);
@ -83,9 +84,9 @@ BOOL UndergroundMan_CheckForTouchInput(void);
void UndergroundMan_ProcessTouchInput(int netID, int unused1, void *data, void *unused3);
void UndergroundMan_ProcessTouchRadarTrapResults(int unused0, int size, void *data, void *unused3);
void UndergroundMan_ProcessTouchRadarMiningSpotResults(int unused0, int size, void *data, void *unused3);
int UndergroundMan_CalcCoordsIndexGet(Coordinates *coordinates);
int UndergroundMan_CalcCoordsIndexInsert(Coordinates *coordinates);
void UndergroundMan_InitCoordsOrderingState(int orderedArrayLength, CoordinatesGetter coordinatesGetter);
int UndergroundMan_CalcCoordsIndexGet(CoordinatesU16 *coordinates);
int UndergroundMan_CalcCoordsIndexInsert(CoordinatesU16 *coordinates);
void UndergroundMan_InitCoordsOrderingState(int orderedArrayLength, GetCoordinatesFunc getCoordsFunc);
void UndergroundMan_OpenMenu(void);
void UndergroundMan_ProgressInteractCooldown(void);
void UndergroundMan_ProcessInteract(u8 flags);

View File

@ -6,6 +6,7 @@
#include "field/field_system_decl.h"
#include "underground/defs.h"
#include "coordinates.h"
#include "string_gf.h"
void MiningEnv_Init(void *dest, FieldSystem *fieldSystem);
@ -13,7 +14,7 @@ int MiningEnv_Size(void);
void Mining_Dummy(void);
void Mining_Dummy2(void);
void MiningEnv_Free(void);
BOOL Mining_CheckForMiningSpotInteract(int netID, Coordinates *coordinates);
BOOL Mining_CheckForMiningSpotInteract(int netID, CoordinatesU16 *coordinates);
void Mining_SpawnMiningSpotNearBuriedSphere(int buriedSphereX, int buriedSphereZ, MATHRandContext16 *rand);
void Mining_SendRadarResults(void);
void Mining_ProcessMiningSpotInteract(int unused0, int unused1, void *data, void *unused3);

View File

@ -4,8 +4,10 @@
#include "underground/defs.h"
#include "underground/menus.h"
int UndergroundPC_GetPCOwnerNetIDAtCoordinates(Coordinates *coordinates, int dir);
BOOL UndergroundPC_TryUsePC(int netID, Coordinates *coordinates);
#include "coordinates.h"
int UndergroundPC_GetPCOwnerNetIDAtCoordinates(CoordinatesU16 *coordinates, int dir);
BOOL UndergroundPC_TryUsePC(int netID, CoordinatesU16 *coordinates);
void UndergroundPC_ProcessPCInteraction(int unused0, int unused1, void *data, void *data2);
int CommPacketSizeOf_PCInteraction(void);
void UndergroundPC_ProcessTakeFlagAttempt(int unused0, int unused1, void *data, void *unused3);

View File

@ -6,6 +6,7 @@
#include "field/field_system_decl.h"
#include "underground/defs.h"
#include "coordinates.h"
#include "savedata.h"
#include "string_gf.h"
#include "underground.h"
@ -64,7 +65,7 @@ int SecretBases_PrintBaseDecorationMessage(int bankEntry);
void SecretBases_EraseBaseDecorationMessageBox(void);
void SecretBases_SetGoodNameForPrinter(enum Good goodID);
void SecretBases_SetTwoDigitNumberWithIndexForPrinter(int num, int index);
BOOL SecretBases_CheckForInteractableGood(int netID, Coordinates *coordinates);
BOOL SecretBases_CheckForInteractableGood(int netID, CoordinatesU16 *coordinates);
void SecretBases_ProcessGoodInteractionEvent(int unused0, int unused1, void *data, void *unused3);
int CommPacketSizeOf_GoodInteractionEvent(void);
void SecretBases_QueueObtainedFlagMessage(int netID, int flagOwnerNetID);

View File

@ -7,6 +7,7 @@
#include "field/field_system_decl.h"
#include "coordinates.h"
#include "string_gf.h"
typedef struct TouchRadarSearchContext {
@ -14,11 +15,6 @@ typedef struct TouchRadarSearchContext {
u16 radius;
} TouchRadarSearchContext;
typedef struct TouchRadarCoordinates {
s16 x;
s16 z;
} TouchRadarCoordinates;
void SpheresEnv_Init(void *dest, FieldSystem *fieldSystem);
int SpheresEnv_Size(void);
void Spheres_DisableBuriedSphereSparkles(void);
@ -27,7 +23,7 @@ void SpheresEnv_Free(void);
void Spheres_AdvanceBuriedSphereSparkleTimer(void);
void Spheres_ProcessRetrieveBuriedSphereRequest(int unused, int unused2, void *src, void *unused3);
void TouchRadarSearch_Init(TouchRadarSearchContext *ctx, int radius);
BOOL TouchRadarSearch_GetNextCoords(TouchRadarSearchContext *ctx, TouchRadarCoordinates *out);
BOOL TouchRadarSearch_GetNextCoords(TouchRadarSearchContext *ctx, CoordinatesS16 *out);
void Spheres_TryBurySphere(enum SphereType sphereType, int sphereSize, int x, int z);
BOOL Spheres_IsMiningItemSphere(int miningItemID);
BOOL Spheres_IsBuriedSphereAtCoordinates(int x, int z);

View File

@ -9,6 +9,7 @@
#include "underground/defs.h"
#include "bg_window.h"
#include "coordinates.h"
#include "string_gf.h"
void TrapsEnv_Init(void *dest, FieldSystem *fieldSystem);
@ -34,8 +35,8 @@ void Traps_ReceiveLoadTrapsResult(int unused0, int unused1, void *data, void *un
int CommPacketSizeOf_LoadTrapsResult(void);
BOOL Traps_HaveLinksReceivedPlacedTraps(void);
void Traps_ClearLinksReceivedPlacedTraps(void);
int CommPacketSizeOf_Coordinates(void);
BOOL Traps_TryDisengageTrap(int netID, Coordinates *unused, u8 flags);
int CommPacketSizeOf_CoordinatesU16(void);
BOOL Traps_TryDisengageTrap(int netID, CoordinatesU16 *unused, u8 flags);
int CommPacketSizeOf_TriggeredTrap(void);
void Traps_ProcessDisengagedTrap(int unused0, int unused1, void *data, void *unused3);
BOOL Traps_IsTrapAtCoordinates(int x, int z);

View File

@ -24,6 +24,7 @@
#include "berry_patch_graphics.h"
#include "bg_window.h"
#include "billboard.h"
#include "coordinates.h"
#include "field_script_context.h"
#include "font.h"
#include "game_records.h"
@ -62,11 +63,6 @@
#define MAX_LIST_ENTRIES 120
typedef struct RegiDotCoordinates {
s16 x;
s16 z;
} RegiDotCoordinates;
typedef struct BattleHallRecordSelector {
FieldSystem *fieldSystem;
SysTask *task;
@ -846,34 +842,34 @@ BOOL ScrCmd_Dummy316(ScriptContext *ctx)
return TRUE;
}
static const RegiDotCoordinates sDotCoordinatesIronRuins[] = {
{ 4, 7 },
{ 5, 5 },
{ 5, 9 },
{ 7, 7 },
{ 9, 5 },
{ 9, 9 },
{ 10, 7 }
static const CoordinatesS16 sDotCoordinatesIronRuins[] = {
{ .x = 4, .z = 7 },
{ .x = 5, .z = 5 },
{ .x = 5, .z = 9 },
{ .x = 7, .z = 7 },
{ .x = 9, .z = 5 },
{ .x = 9, .z = 9 },
{ .x = 10, .z = 7 }
};
static const RegiDotCoordinates sDotCoordinatesIcebergRuins[] = {
{ 3, 7 },
{ 5, 7 },
{ 7, 5 },
{ 7, 7 },
{ 7, 9 },
{ 9, 7 },
{ 11, 7 }
static const CoordinatesS16 sDotCoordinatesIcebergRuins[] = {
{ .x = 3, .z = 7 },
{ .x = 5, .z = 7 },
{ .x = 7, .z = 5 },
{ .x = 7, .z = 7 },
{ .x = 7, .z = 9 },
{ .x = 9, .z = 7 },
{ .x = 11, .z = 7 }
};
static const RegiDotCoordinates sDotCoordinatesRockPeakRuins[] = {
{ 5, 5 },
{ 5, 7 },
{ 5, 9 },
{ 7, 7 },
{ 9, 5 },
{ 9, 7 },
{ 9, 9 }
static const CoordinatesS16 sDotCoordinatesRockPeakRuins[] = {
{ .x = 5, .z = 5 },
{ .x = 5, .z = 7 },
{ .x = 5, .z = 9 },
{ .x = 7, .z = 7 },
{ .x = 9, .z = 5 },
{ .x = 9, .z = 7 },
{ .x = 9, .z = 9 }
};
BOOL ScrCmd_ActivateRegiRuinsDot(ScriptContext *ctx)

View File

@ -7,6 +7,7 @@
#include "badges.h"
#include "char_transfer.h"
#include "coordinates.h"
#include "gx_layers.h"
#include "heap.h"
#include "narc.h"
@ -17,11 +18,6 @@
#include "sprite_transfer.h"
#include "sprite_util.h"
typedef struct Coordinates {
int x;
int y;
} Coordinates;
static const u8 sSpriteResourceCapacities[4] = {
[SPRITE_RESOURCE_CHAR] = 1,
[SPRITE_RESOURCE_PLTT] = 2,
@ -29,7 +25,7 @@ static const u8 sSpriteResourceCapacities[4] = {
[SPRITE_RESOURCE_ANIM] = 1
};
static const Coordinates sBadgeCoordinates[] = {
static const CoordinatesInt sBadgeCoordinates[] = {
[BADGE_ID_COAL] = { .x = 24, .y = 40 },
[BADGE_ID_FOREST] = { .x = 80, .y = 40 },
[BADGE_ID_COBBLE] = { .x = 136, .y = 40 },
@ -40,7 +36,7 @@ static const Coordinates sBadgeCoordinates[] = {
[BADGE_ID_BEACON] = { .x = 192, .y = 72 }
};
static const Coordinates sSparkleCoordinates[] = {
static const CoordinatesInt sSparkleCoordinates[] = {
[BADGE_ID_COAL] = { .x = 24, .y = 40 },
[BADGE_ID_FOREST] = { .x = 80, .y = 40 },
[BADGE_ID_COBBLE] = { .x = 136, .y = 40 },

View File

@ -27,6 +27,7 @@
#include "comm_player_manager.h"
#include "communication_information.h"
#include "communication_system.h"
#include "coordinates.h"
#include "field_system.h"
#include "game_options.h"
#include "graphics.h"
@ -71,8 +72,8 @@ typedef struct UndergroundManager {
FieldSystem *fieldSystem;
u8 padding[4];
SysTask *sysTask;
Coordinates2D touchCoordinates;
Coordinates touchedTileCoords;
CoordinatesU16 touchCoordinates;
CoordinatesU16 touchedTileCoords;
StoredListMenuPos storedPositions[MAX_STORED_MENU_POSITIONS];
u16 storedPositionKey;
u8 linksTalkedTo[MAX_CONNECTED_PLAYERS];
@ -82,7 +83,7 @@ typedef struct UndergroundManager {
u8 touchRadarTrapResults[MAX_TOUCH_RADAR_RESULTS_OF_TYPE];
u8 touchRadarMiningSpotResults[MAX_TOUCH_RADAR_RESULTS_OF_TYPE];
u8 touchRadarBuriedSphereResults[MAX_TOUCH_RADAR_RESULTS_OF_TYPE];
CoordinatesGetter coordinatesGetter;
GetCoordinatesFunc getCoordsFunc;
UndergroundTextPrinter *commonTextPrinter;
UndergroundTextPrinter *captureFlagTextPrinter;
UndergroundTextPrinter *miscTextPrinter;
@ -311,7 +312,7 @@ static BOOL UndergroundMan_GetQueuedPlayerMessage(String *dest)
// doesn't check for everything that could be at the coordinates
BOOL UndergroundMan_AreCoordinatesOccupied(int x, int z)
{
Coordinates coordinates = {
CoordinatesU16 coordinates = {
.x = x,
.z = z
};
@ -358,7 +359,7 @@ BOOL UndergroundMan_CheckForTouchInput(void)
pos = ov5_GetPositionFromTouchCoordinates(gSystem.touchX, gSystem.touchY, sUndergroundMan->fieldSystem->unk_8C);
int x, z;
LandData_ObjectPosToTilePos(pos.x, pos.z, &x, &z);
Coordinates touchedTileCoords = {
CoordinatesU16 touchedTileCoords = {
.x = x,
.z = z
};
@ -368,7 +369,7 @@ BOOL UndergroundMan_CheckForTouchInput(void)
sUndergroundMan->touchedTileCoords.x = x;
sUndergroundMan->touchedTileCoords.z = z;
CommSys_SendData(48, &touchedTileCoords, sizeof(Coordinates));
CommSys_SendData(48, &touchedTileCoords, sizeof(CoordinatesU16));
return TRUE;
}
@ -378,7 +379,7 @@ BOOL UndergroundMan_CheckForTouchInput(void)
return FALSE;
}
static int UndergroundMan_TouchRadarSearch(u8 *out, TouchRadarItemCheckFunc isItemAtCoords, Coordinates *touchedTileCoords)
static int UndergroundMan_TouchRadarSearch(u8 *out, TouchRadarItemCheckFunc isItemAtCoords, CoordinatesU16 *touchedTileCoords)
{
int index = 1;
@ -388,7 +389,7 @@ static int UndergroundMan_TouchRadarSearch(u8 *out, TouchRadarItemCheckFunc isIt
TouchRadarSearchContext ctx;
TouchRadarSearch_Init(&ctx, TOUCH_RADAR_RADIUS);
TouchRadarCoordinates radarCoords;
CoordinatesS16 radarCoords;
while (TouchRadarSearch_GetNextCoords(&ctx, &radarCoords)) {
int x = touchedTileCoords->x + radarCoords.x;
int z = touchedTileCoords->z + radarCoords.z;
@ -408,7 +409,7 @@ static int UndergroundMan_TouchRadarSearch(u8 *out, TouchRadarItemCheckFunc isIt
return index;
}
static void UndergroundMan_StartTouchRadar(int netID, Coordinates *touchedTileCoords)
static void UndergroundMan_StartTouchRadar(int netID, CoordinatesU16 *touchedTileCoords)
{
u8 buffer[MAX_TOUCH_RADAR_RESULTS_OF_TYPE + 1];
int size = 1;
@ -424,7 +425,7 @@ static void UndergroundMan_StartTouchRadar(int netID, Coordinates *touchedTileCo
void UndergroundMan_ProcessTouchInput(int netID, int unused1, void *data, void *unused3)
{
Coordinates *touchedTileCoords = data;
CoordinatesU16 *touchedTileCoords = data;
if (!CommPlayerMan_IsMovementEnabled(netID)) {
return;
@ -469,7 +470,7 @@ void UndergroundMan_ProcessTouchRadarMiningSpotResults(int unused0, int size, vo
TouchRadar_StartTask(sUndergroundMan->fieldSystem, sUndergroundMan->touchedTileCoords.x, sUndergroundMan->touchedTileCoords.z, sUndergroundMan->touchCoordinates.x, sUndergroundMan->touchCoordinates.y, sUndergroundMan->touchRadarTrapResults, sUndergroundMan->touchRadarTrapResultCount, sUndergroundMan->touchRadarMiningSpotResults, sUndergroundMan->touchRadarMiningSpotResultCount, sUndergroundMan->touchRadarBuriedSphereResults, sUndergroundMan->touchRadarBuriedSphereResultCount);
}
static int UndergroundMan_GetOrderedCoordinatesValue(Coordinates *coordinates)
static int UndergroundMan_GetOrderedCoordinatesValue(CoordinatesU16 *coordinates)
{
int x = 0, z = 0;
@ -483,45 +484,45 @@ static int UndergroundMan_GetOrderedCoordinatesValue(Coordinates *coordinates)
return (z * MAP_MATRIX_MAX_WIDTH * MAP_TILES_COUNT_X) + x;
}
int UndergroundMan_CalcCoordsIndexGet(Coordinates *coordinates)
int UndergroundMan_CalcCoordsIndexGet(CoordinatesU16 *coordinates)
{
int index = 0;
int max = sUndergroundMan->orderedArrayLength - 1;
int orderedValue = UndergroundMan_GetOrderedCoordinatesValue(coordinates);
Coordinates _;
CoordinatesGetter getCoordinates = sUndergroundMan->coordinatesGetter;
CoordinatesU16 _;
GetCoordinatesFunc getCoordsFunc = sUndergroundMan->getCoordsFunc;
while (index < max) {
int midpoint = (index + max) / 2;
if (UndergroundMan_GetOrderedCoordinatesValue(getCoordinates(&_, midpoint)) < orderedValue) {
if (UndergroundMan_GetOrderedCoordinatesValue(getCoordsFunc(&_, midpoint)) < orderedValue) {
index = midpoint + 1;
} else {
max = midpoint;
}
}
if (UndergroundMan_GetOrderedCoordinatesValue(getCoordinates(&_, index)) == orderedValue) {
if (UndergroundMan_GetOrderedCoordinatesValue(getCoordsFunc(&_, index)) == orderedValue) {
return index;
}
return -1;
}
int UndergroundMan_CalcCoordsIndexInsert(Coordinates *coordinates)
int UndergroundMan_CalcCoordsIndexInsert(CoordinatesU16 *coordinates)
{
int index = 0;
int max = sUndergroundMan->orderedArrayLength - 2;
int orderedValue = UndergroundMan_GetOrderedCoordinatesValue(coordinates);
Coordinates _;
CoordinatesGetter getCoordinates = sUndergroundMan->coordinatesGetter;
CoordinatesU16 _;
GetCoordinatesFunc getCoordsFunc = sUndergroundMan->getCoordsFunc;
max++; // why?
while (index < max) {
int midpoint = (index + max) / 2;
if (UndergroundMan_GetOrderedCoordinatesValue(getCoordinates(&_, midpoint)) < orderedValue) {
if (UndergroundMan_GetOrderedCoordinatesValue(getCoordsFunc(&_, midpoint)) < orderedValue) {
index = midpoint + 1;
} else {
max = midpoint;
@ -531,9 +532,9 @@ int UndergroundMan_CalcCoordsIndexInsert(Coordinates *coordinates)
return index;
}
void UndergroundMan_InitCoordsOrderingState(int orderedArrayLength, CoordinatesGetter coordinatesGetter)
void UndergroundMan_InitCoordsOrderingState(int orderedArrayLength, GetCoordinatesFunc getCoordsFunc)
{
sUndergroundMan->coordinatesGetter = coordinatesGetter;
sUndergroundMan->getCoordsFunc = getCoordsFunc;
sUndergroundMan->orderedArrayLength = orderedArrayLength;
}
@ -595,7 +596,7 @@ void UndergroundMan_ProcessInteractEvent(int netID, int unused1, void *data, voi
{
TalkEvent talkEvent;
InteractEvent *event = data;
Coordinates coordinates;
CoordinatesU16 coordinates;
u8 netIDBuffer = netID;
coordinates.x = CommPlayer_GetXInFrontOfPlayerServer(netID);
coordinates.z = CommPlayer_GetZInFrontOfPlayerServer(netID);

View File

@ -27,6 +27,7 @@
#include "comm_player_manager.h"
#include "communication_information.h"
#include "communication_system.h"
#include "coordinates.h"
#include "field_system.h"
#include "field_task.h"
#include "game_records.h"
@ -803,7 +804,7 @@ void MiningEnv_Free(void)
}
}
BOOL Mining_CheckForMiningSpotInteract(int netID, Coordinates *coordinates)
BOOL Mining_CheckForMiningSpotInteract(int netID, CoordinatesU16 *coordinates)
{
MiningSpot *miningSpot = Mining_GetMiningSpotAtCoordinates(coordinates->x, coordinates->z);
u8 buffer = netID;

View File

@ -26,6 +26,7 @@
#include "comm_player_manager.h"
#include "communication_information.h"
#include "communication_system.h"
#include "coordinates.h"
#include "field_system.h"
#include "field_task.h"
#include "heap.h"
@ -142,7 +143,7 @@ static const WindowTemplate sYesNoWindowTemplate = {
.baseTile = BASE_TILE_YES_NO_MENU
};
int UndergroundPC_GetPCOwnerNetIDAtCoordinates(Coordinates *coordinates, int dir)
int UndergroundPC_GetPCOwnerNetIDAtCoordinates(CoordinatesU16 *coordinates, int dir)
{
int netID;
int x = coordinates->x;
@ -176,7 +177,7 @@ int UndergroundPC_GetPCOwnerNetIDAtCoordinates(Coordinates *coordinates, int dir
return NETID_NONE;
}
BOOL UndergroundPC_TryUsePC(int netID, Coordinates *coordinates)
BOOL UndergroundPC_TryUsePC(int netID, CoordinatesU16 *coordinates)
{
int pcNetID = UndergroundPC_GetPCOwnerNetIDAtCoordinates(coordinates, CommPlayer_DirServer(netID));

View File

@ -30,6 +30,7 @@
#include "comm_player_manager.h"
#include "communication_information.h"
#include "communication_system.h"
#include "coordinates.h"
#include "field_map_change.h"
#include "field_system.h"
#include "field_task.h"
@ -2303,7 +2304,7 @@ static enum Good SecretBases_GetGoodWithCollisionAtCoordinates(SecretBase *secre
return UG_GOOD_NONE;
}
BOOL SecretBases_CheckForInteractableGood(int netID, Coordinates *coordinates)
BOOL SecretBases_CheckForInteractableGood(int netID, CoordinatesU16 *coordinates)
{
int x = coordinates->x;
int z = coordinates->z;

View File

@ -15,6 +15,7 @@
#include "comm_player_manager.h"
#include "communication_system.h"
#include "coordinates.h"
#include "field_system.h"
#include "game_records.h"
#include "heap.h"
@ -158,7 +159,7 @@ void Spheres_AdvanceBuriedSphereSparkleTimer(void)
}
}
static Coordinates *Spheres_GetCoordinatesOfBuriedSphereAtOrderedIndex(Coordinates *coordinates, int index)
static CoordinatesU16 *Spheres_GetCoordinatesOfBuriedSphereAtOrderedIndex(CoordinatesU16 *coordinates, int index)
{
if (spheresEnv->buriedSpheresByCoordinates[index] == NULL) {
return NULL;
@ -172,7 +173,7 @@ static Coordinates *Spheres_GetCoordinatesOfBuriedSphereAtOrderedIndex(Coordinat
static void Spheres_AddBuriedSphereToCoordinatesOrdering(BuriedSphere *sphere)
{
Coordinates coordinates = {
CoordinatesU16 coordinates = {
.x = sphere->x,
.z = sphere->z
};
@ -221,7 +222,7 @@ static BuriedSphere *Spheres_Dummy(BuriedSphere *sphere)
static BuriedSphere *Spheres_GetBuriedSphereAtCoordinates(int x, int z)
{
Coordinates coordinates = {
CoordinatesU16 coordinates = {
.x = x,
.z = z
};
@ -286,7 +287,7 @@ void TouchRadarSearch_Init(TouchRadarSearchContext *ctx, int radius)
ctx->iterator = 0;
}
BOOL TouchRadarSearch_GetNextCoords(TouchRadarSearchContext *ctx, TouchRadarCoordinates *out)
BOOL TouchRadarSearch_GetNextCoords(TouchRadarSearchContext *ctx, CoordinatesS16 *out)
{
int i;
int iterator = ctx->iterator;

View File

@ -71,11 +71,6 @@ typedef struct MessageQueue {
charcode_t tempStringChars[TEMP_STRING_SIZE];
} MessageQueue;
typedef struct PlayerCoordinates {
int x;
int z;
} PlayerCoordinates;
typedef struct PlayerMarkerData {
int x;
int z;
@ -91,7 +86,7 @@ typedef struct OtherMarkerData {
struct UndergroundTopScreenContext_t {
int state;
PlayerCoordinates playerCoords[MAX_CONNECTED_PLAYERS];
CoordinatesInt playerCoords[MAX_CONNECTED_PLAYERS];
PlayerMarkerData playerMarkers[MAX_CONNECTED_PLAYERS];
OtherMarkerData otherMarkers[MAX_RADAR_BLIPS + 1];
FieldSystem *parent;
@ -114,8 +109,8 @@ static int positionsDummy[MAX_CONNECTED_PLAYERS][2];
static void UndergroundTopScreen_InitBackgrounds(BgConfig *bgConfig, Window *window);
static void UndergroundMap_InitSpriteResources(UndergroundTopScreenContext *ctx);
static void UndergroundMap_FetchPlayerPositions(PlayerAvatar *const playerAvatar, PlayerCoordinates playerCoords[], PlayerMarkerData markerData[]);
static void UndergroundMap_InitPlayerPositions(PlayerCoordinates playerCoords[], PlayerMarkerData markerData[]);
static void UndergroundMap_FetchPlayerPositions(PlayerAvatar *const playerAvatar, CoordinatesInt playerCoords[], PlayerMarkerData markerData[]);
static void UndergroundMap_InitPlayerPositions(CoordinatesInt playerCoords[], PlayerMarkerData markerData[]);
static void UndergroundMap_DrawPlayerMarkers(PlayerMarkerData markerData[], Sprite *sprites[]);
static void UndergroundTopScreen_FreeBackgrounds(BgConfig *bgConfig);
static void UndergroundTopScreen_HandleMessageQueue(BgConfig *unused, Window *window, int *printerID, int *state, int *timer, MessageQueue *queue);
@ -251,7 +246,7 @@ static void UndergroundTopScreen_Task(SysTask *sysTask, void *data)
}
}
static void UndergroundMap_InitPlayerPositions(PlayerCoordinates playerCoords[], PlayerMarkerData markerData[])
static void UndergroundMap_InitPlayerPositions(CoordinatesInt playerCoords[], PlayerMarkerData markerData[])
{
for (int netID = 0; netID < MAX_CONNECTED_PLAYERS; netID++) {
playerCoords[netID].x = 0;
@ -265,7 +260,7 @@ static void UndergroundMap_InitPlayerPositions(PlayerCoordinates playerCoords[],
}
}
static void UndergroundMap_FetchPlayerPositions(PlayerAvatar *const playerAvatar, PlayerCoordinates playerCoords[], PlayerMarkerData markerData[])
static void UndergroundMap_FetchPlayerPositions(PlayerAvatar *const playerAvatar, CoordinatesInt playerCoords[], PlayerMarkerData markerData[])
{
for (int netID = 0; netID < MAX_CONNECTED_PLAYERS; netID++) {
playerCoords[netID].x = CommPlayer_GetXIfActive(netID);

View File

@ -27,6 +27,7 @@
#include "comm_player_manager.h"
#include "communication_information.h"
#include "communication_system.h"
#include "coordinates.h"
#include "field_system.h"
#include "field_task.h"
#include "game_records.h"
@ -121,11 +122,6 @@ typedef struct TrapRadarResult {
u8 netID;
} TrapRadarResult;
typedef struct fx32Coordinates {
fx32 x;
fx32 y;
} fx32Coordinates;
typedef struct TrapRadarContext {
TrapRadarResult results[MAX_PLACED_TRAPS + MAX_SPAWNED_TRAPS];
u8 index;
@ -182,7 +178,7 @@ typedef struct LeafTrapContext {
int state;
int printerID;
u16 leafAngleIdx[MAX_TRAP_EFFECT_SPRITES];
Coordinates2D leafCoords[MAX_TRAP_EFFECT_SPRITES];
CoordinatesU16 leafCoords[MAX_TRAP_EFFECT_SPRITES];
u8 micBlowIntensities[40];
u8 micBlowDelay[MAX_TRAP_EFFECT_SPRITES];
u8 blowIntensityIndex;
@ -242,7 +238,7 @@ typedef struct BubbleTrapContext {
int printerID;
u8 bubbleSizes[MAX_BUBBLES];
u16 bubbleAngleIdx[MAX_BUBBLES];
fx32Coordinates bubbleCoords[MAX_BUBBLES];
CoordinatesFX32 bubbleCoords[MAX_BUBBLES];
BOOL isBubblePopped[MAX_BUBBLES];
u16 bubbleScaleTimer[MAX_BUBBLES];
u8 timer;
@ -1016,7 +1012,7 @@ int CommPacketSizeOf_AllTrapsPlacedPlayer(void)
return sizeof(BuriedTrap) * MAX_PLACED_TRAPS;
}
static Coordinates *Traps_GetCoordinatesOfBuriedTrapAtOrderedIndex(Coordinates *coordinates, int index)
static CoordinatesU16 *Traps_GetCoordinatesOfBuriedTrapAtOrderedIndex(CoordinatesU16 *coordinates, int index)
{
if (trapsEnv->buriedTrapsByCoordinates[index] == NULL) {
return NULL;
@ -1030,7 +1026,7 @@ static Coordinates *Traps_GetCoordinatesOfBuriedTrapAtOrderedIndex(Coordinates *
static void Traps_AddBuriedTrapToCoordinatesOrdering(BuriedTrap *trap)
{
Coordinates coordinates = {
CoordinatesU16 coordinates = {
.x = trap->x,
.z = trap->z
};
@ -1480,12 +1476,12 @@ void Traps_ClearLinksReceivedPlacedTraps(void)
trapsEnv->linksReceivedPlacedTraps = FALSE;
}
int CommPacketSizeOf_Coordinates(void)
int CommPacketSizeOf_CoordinatesU16(void)
{
return sizeof(Coordinates);
return sizeof(CoordinatesU16);
}
BOOL Traps_TryDisengageTrap(int netID, Coordinates *unused, u8 flags)
BOOL Traps_TryDisengageTrap(int netID, CoordinatesU16 *unused, u8 flags)
{
Underground *underground = SaveData_GetUnderground(FieldSystem_GetSaveData(trapsEnv->fieldSystem));
@ -1594,7 +1590,7 @@ static int Traps_GetBuriedTrapSetterNetID(BuriedTrap *trap)
static BuriedTrap *Traps_GetTrapAtCoordinates(int x, int z)
{
Coordinates coordinates = {
CoordinatesU16 coordinates = {
.x = x,
.z = z
};
@ -2372,7 +2368,7 @@ static void Traps_EndSmokeTrapEffectClient(int netID, BOOL allowToolStepBack)
}
// returns true when less than 13 tiles of smoke remain
static BOOL Traps_ProcessSmoke(Coordinates2D *touchCoordinates, BgConfig *bgConfig, SmokeTrapContext *ctx)
static BOOL Traps_ProcessSmoke(CoordinatesU16 *touchCoordinates, BgConfig *bgConfig, SmokeTrapContext *ctx)
{
int smokeTilesLeft = 0;
u8 *tilemap = Bg_GetTilemapBuffer(bgConfig, BG_LAYER_MAIN_2);
@ -2514,10 +2510,10 @@ static void Traps_SmokeTrapClientTask(SysTask *sysTask, void *data)
break;
case SMOKE_TRAP_STATE_MAIN:
if (gSystem.touchHeld) {
Coordinates2D touchCoordinates;
touchCoordinates.x = gSystem.touchX;
touchCoordinates.y = gSystem.touchY;
CoordinatesU16 touchCoordinates = {
.x = gSystem.touchX,
.y = gSystem.touchY
};
if (Traps_ProcessSmoke(&touchCoordinates, ctx->bgConfig, ctx)) {
if (ctx->isTool) {

View File

@ -72,7 +72,7 @@ static const CommCmdTable Unk_020F68A4[] = {
{ Traps_ProcessTriggeredTrapBits, CommPacketSizeOf_NetId, NULL },
{ Traps_QueueSendTrapRadarResults, CommPacketSizeOf_Nothing, NULL },
{ Traps_ReceiveTrapRadarResults, CommPacketSizeOf_TrapRadarResult, NULL },
{ UndergroundMan_ProcessTouchInput, CommPacketSizeOf_Coordinates, NULL },
{ UndergroundMan_ProcessTouchInput, CommPacketSizeOf_CoordinatesU16, NULL },
{ UndergroundMan_ProcessTouchRadarTrapResults, CommPacketSizeOf_Variable, NULL },
{ UndergroundMan_ProcessTouchRadarMiningSpotResults, CommPacketSizeOf_Variable, NULL }, // 50
{ Traps_ProcessDisengagedTrap, CommPacketSizeOf_TriggeredTrap, NULL },