diff options
Diffstat (limited to 'src/field')
| -rw-r--r-- | src/field/field_map_obj.c | 38 | ||||
| -rw-r--r-- | src/field/overworld.c | 26 | ||||
| -rw-r--r-- | src/field/trainer_see.c | 22 | 
3 files changed, 43 insertions, 43 deletions
| diff --git a/src/field/field_map_obj.c b/src/field/field_map_obj.c index 81c0c5854..ba7c3d68e 100644 --- a/src/field/field_map_obj.c +++ b/src/field/field_map_obj.c @@ -2020,7 +2020,7 @@ u8 GetFieldObjectIdByLocalId(u8 localId)  #ifdef NONMATCHING  u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 b, u8 c)  { -    struct MapObject2 *mapObj;  //TODO: resolve the mapobj_unk_19b weirdness +    struct MapObject *mapObj;  //TODO: resolve the mapobj_unk_19b weirdness      u8 var;      u16 r3;      u16 r2; @@ -2029,8 +2029,8 @@ u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 b, u8      if (GetAvailableFieldObjectSlot(template->localId, b, c, &var) != 0)          return 16;      //_0805ACCE -    mapObj = (struct MapObject2 *)&gMapObjects[var]; -    npc_clear_ids_and_state((struct MapObject *)mapObj); +    mapObj = &gMapObjects[var]; +    npc_clear_ids_and_state(mapObj);      r3 = template->x + 7;      r2 = template->y + 7;      mapObj->active = TRUE; @@ -2048,8 +2048,8 @@ u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 b, u8      mapObj->coords3.y = r2;      mapObj->mapobj_unk_0B_0 = template->elevation;      mapObj->elevation = template->elevation; -    mapObj->mapobj_unk_19 = template->unkA_0; -    mapObj->mapobj_unk_19b = template->unkA_4; +    mapObj->range.as_nybbles.x = template->unkA_0; +    mapObj->range.as_nybbles.y = template->unkA_4;      mapObj->trainerType = template->unkC;      mapObj->trainerRange_berryTreeId = template->unkE;      mapObj->mapobj_unk_20 = gUnknown_0836DC09[template->movementType]; @@ -2058,10 +2058,10 @@ u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 b, u8      //asm("":::"r5","r6");      if (gUnknown_0836DBBC[mapObj->animPattern] != 0)      { -        if (mapObj->mapobj_unk_19 == 0) -            mapObj->mapobj_unk_19++; -        if (mapObj->mapobj_unk_19b == 0) -            mapObj->mapobj_unk_19b++; +        if (mapObj->range.as_nybbles.x == 0) +            mapObj->range.as_nybbles.x++; +        if (mapObj->range.as_nybbles.y == 0) +            mapObj->range.as_nybbles.y++;      }      return var;  } @@ -5464,7 +5464,7 @@ u8 sub_805FF20(struct MapObject *mapObject, u8 direction)      return npc_block_way(mapObject, x, y, direction);  } -bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y); +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *mapObject, s16 x, s16 y);  static bool8 DoesObjectCollideWithObjectAt(struct MapObject *mapObject, s16 x, s16 y);  bool8 IsMetatileDirectionallyImpassable(struct MapObject *mapObject, s16 x, s16 y, u8 direction); @@ -5472,7 +5472,7 @@ u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn)  {      u8 direction;      direction = dirn; -    if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) +    if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y))          return 1;      else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction))          return 2; @@ -5489,7 +5489,7 @@ u8 sub_8060024(struct MapObject *mapObject, s16 x, s16 y, u8 direction)  {      u8 flags = 0; -    if (IsCoordOutsideFieldObjectMovementRect((struct MapObject2 *)mapObject, x, y)) +    if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y))          flags |= 1;      if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction) || (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)))          flags |= 2; @@ -5500,22 +5500,22 @@ u8 sub_8060024(struct MapObject *mapObject, s16 x, s16 y, u8 direction)      return flags;  } -bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *mapObject, s16 x, s16 y) +bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject *mapObject, s16 x, s16 y)  {      s16 minv;      s16 maxv; -    if (mapObject->mapobj_unk_19 != 0) +    if (mapObject->range.as_nybbles.x != 0)      { -        minv = mapObject->coords1.x - (mapObject->mapobj_unk_19); -        maxv = mapObject->coords1.x + (mapObject->mapobj_unk_19); +        minv = mapObject->coords1.x - (mapObject->range.as_nybbles.x); +        maxv = mapObject->coords1.x + (mapObject->range.as_nybbles.x);          if (minv > x || maxv < x)              return TRUE;      } -    if (mapObject->mapobj_unk_19b != 0) +    if (mapObject->range.as_nybbles.y != 0)      { -        minv = mapObject->coords1.y - (mapObject->mapobj_unk_19b); -        maxv = mapObject->coords1.y + (mapObject->mapobj_unk_19b); +        minv = mapObject->coords1.y - (mapObject->range.as_nybbles.y); +        maxv = mapObject->coords1.y + (mapObject->range.as_nybbles.y);          if (minv > y || maxv < y)              return TRUE;      } diff --git a/src/field/overworld.c b/src/field/overworld.c index 21f3f98ef..b9a40488e 100644 --- a/src/field/overworld.c +++ b/src/field/overworld.c @@ -287,7 +287,7 @@ void LoadMapObjTemplatesFromHeader(void)  {      // Clear map object templates      CpuFill32(0, gSaveBlock1.mapObjectTemplates, sizeof(gSaveBlock1.mapObjectTemplates)); -     +      // Copy map header events to save block      CpuCopy32(gMapHeader.events->mapObjects,                gSaveBlock1.mapObjectTemplates, @@ -981,7 +981,7 @@ static void PlayAmbientCry(void)      s16 x, y;      s8 pan;      s8 volume; -     +      PlayerGetDestCoords(&x, &y);      if (sIsAmbientCryWaterMon == TRUE       && !MetatileBehavior_IsSurfableWaterOrUnderwater(MapGridGetMetatileBehaviorAt(x, y))) @@ -1158,7 +1158,7 @@ void OverworldBasic(void)      sub_8072EDC();  } -// This CB2 is used when starting  +// This CB2 is used when starting  void CB2_OverworldBasic(void)  {      OverworldBasic(); @@ -2430,7 +2430,7 @@ void SpawnLinkPlayerMapObject(u8 linkPlayerId, s16 x, s16 y, u8 a4)      mapObj->active = 1;      mapObj->mapobj_bit_1 = a4; -    mapObj->mapobj_unk_19 = 2; +    mapObj->range.as_byte = 2;      mapObj->spriteId = 64;      InitLinkPlayerMapObjectPos(mapObj, x, y); @@ -2453,7 +2453,7 @@ void unref_sub_8055A6C(u8 linkPlayerId, u8 a2)      {          u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId;          struct MapObject *mapObj = &gMapObjects[mapObjId]; -        mapObj->mapobj_unk_19 = a2; +        mapObj->range.as_byte = a2;      }  } @@ -2487,7 +2487,7 @@ u8 sub_8055B30(u8 linkPlayerId)  {      u8 mapObjId = gLinkPlayerMapObjects[linkPlayerId].mapObjId;      struct MapObject *mapObj = &gMapObjects[mapObjId]; -    return mapObj->mapobj_unk_19; +    return mapObj->range.as_byte;  }  u8 sub_8055B50(u8 linkPlayerId) @@ -2559,10 +2559,10 @@ static u8 sub_8055CB0(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapOb  {      s16 x, y; -    mapObj->mapobj_unk_19 = npc_something3(a3, mapObj->mapobj_unk_19); -    FieldObjectMoveDestCoords(mapObj, mapObj->mapobj_unk_19, &x, &y); +    mapObj->range.as_byte = npc_something3(a3, mapObj->range.as_byte); +    FieldObjectMoveDestCoords(mapObj, mapObj->range.as_byte, &x, &y); -    if (LinkPlayerDetectCollision(linkPlayerMapObj->mapObjId, mapObj->mapobj_unk_19, x, y)) +    if (LinkPlayerDetectCollision(linkPlayerMapObj->mapObjId, mapObj->range.as_byte, x, y))      {          return 0;      } @@ -2577,7 +2577,7 @@ static u8 sub_8055CB0(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapOb  static u8 sub_8055D18(struct LinkPlayerMapObject *linkPlayerMapObj, struct MapObject *mapObj, u8 a3)  { -    mapObj->mapobj_unk_19 = npc_something3(a3, mapObj->mapobj_unk_19); +    mapObj->range.as_byte = npc_something3(a3, mapObj->range.as_byte);      return 0;  } @@ -2590,7 +2590,7 @@ static void sub_8055D38(struct LinkPlayerMapObject *linkPlayerMapObj, struct Map  {      mapObj->mapobj_unk_21--;      linkPlayerMapObj->mode = 1; -    MoveCoords(mapObj->mapobj_unk_19, &mapObj->coords1.x, &mapObj->coords1.y); +    MoveCoords(mapObj->range.as_byte, &mapObj->coords1.x, &mapObj->coords1.y);      if (!mapObj->mapobj_unk_21)      {          npc_coords_shift_still(mapObj); @@ -2662,9 +2662,9 @@ void SpriteCB_LinkPlayer(struct Sprite *sprite)      SetObjectSubpriorityByZCoord(mapObj->elevation, sprite, 1);      sprite->oam.priority = ZCoordToPriority(mapObj->elevation);      if (!linkPlayerMapObj->mode) -        StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObj->mapobj_unk_19)); +        StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(mapObj->range.as_byte));      else -        StartSpriteAnimIfDifferent(sprite, get_go_image_anim_num(mapObj->mapobj_unk_19)); +        StartSpriteAnimIfDifferent(sprite, get_go_image_anim_num(mapObj->range.as_byte));      sub_806487C(sprite, 0);      if (mapObj->mapobj_bit_2)      { diff --git a/src/field/trainer_see.c b/src/field/trainer_see.c index 4e92d95ca..3034b2b65 100644 --- a/src/field/trainer_see.c +++ b/src/field/trainer_see.c @@ -14,7 +14,7 @@ static void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3);  static void objc_exclamation_mark_probably(struct Sprite *sprite);  static bool8 TrainerCanApproachPlayer(struct MapObject *);  static void sub_80842C8(struct MapObject *, u8); -static bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject2 *trainerObj, u8 approachDistance, u8 direction); +static bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject *trainerObj, u8 approachDistance, u8 direction);  static void RunTrainerSeeFuncList(u8 taskId);  const u8 gSpriteImage_839B308[] = INCBIN_U8("graphics/unknown_sprites/839B4E0/0.4bpp"); @@ -84,14 +84,14 @@ static bool8 TrainerCanApproachPlayer(struct MapObject *trainerObj)      if (trainerObj->trainerType == 1)  // can only see in one direction      {          approachDistance = sDirectionalApproachDistanceFuncs[trainerObj->mapobj_unk_18 - 1](trainerObj, trainerObj->trainerRange_berryTreeId, x, y); -        return CheckPathBetweenTrainerAndPlayer((struct MapObject2 *)trainerObj, approachDistance, trainerObj->mapobj_unk_18); +        return CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, trainerObj->mapobj_unk_18);      }      else  // can see in all directions      {          for (i = 0; i < 4; i++)          {              approachDistance = sDirectionalApproachDistanceFuncs[i](trainerObj, trainerObj->trainerRange_berryTreeId, x, y); -            if (CheckPathBetweenTrainerAndPlayer((struct MapObject2 *)trainerObj, approachDistance, i + 1)) // directions are 1-4 instead of 0-3. south north west east +            if (CheckPathBetweenTrainerAndPlayer(trainerObj, approachDistance, i + 1)) // directions are 1-4 instead of 0-3. south north west east                  return approachDistance;          }      } @@ -148,7 +148,7 @@ static u8 GetTrainerApproachDistanceEast(struct MapObject *trainerObj, s16 range  #define COLLISION_MASK 1  #endif -static bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject2 *trainerObj, u8 approachDistance, u8 direction) +static bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject *trainerObj, u8 approachDistance, u8 direction)  {      s16 x, y;      u8 unk19_temp; @@ -164,21 +164,21 @@ static bool8 CheckPathBetweenTrainerAndPlayer(struct MapObject2 *trainerObj, u8      for (i = 0; i <= approachDistance - 1; i++, MoveCoords(direction, &x, &y))      { -        collision = sub_8060024((struct MapObject *)trainerObj, x, y, direction); +        collision = sub_8060024(trainerObj, x, y, direction);          if (collision != 0 && (collision & COLLISION_MASK))              return FALSE;      }      // preserve mapobj_unk_19 before clearing. -    unk19_temp = trainerObj->mapobj_unk_19; -    unk19b_temp = trainerObj->mapobj_unk_19b; -    trainerObj->mapobj_unk_19 = 0; -    trainerObj->mapobj_unk_19b = 0; +    unk19_temp = trainerObj->range.as_nybbles.x; +    unk19b_temp = trainerObj->range.as_nybbles.y; +    trainerObj->range.as_nybbles.x = 0; +    trainerObj->range.as_nybbles.y = 0;      collision = npc_block_way((struct MapObject *)trainerObj, x, y, direction); -    trainerObj->mapobj_unk_19 = unk19_temp; -    trainerObj->mapobj_unk_19b = unk19b_temp; +    trainerObj->range.as_nybbles.x = unk19_temp; +    trainerObj->range.as_nybbles.y = unk19b_temp;      if (collision == 4)          return approachDistance; | 
