diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_dome.c | 8 | ||||
-rw-r--r-- | src/battle_main.c | 6 | ||||
-rw-r--r-- | src/battle_pyramid_bag.c | 4 | ||||
-rw-r--r-- | src/battle_script_commands.c | 4 | ||||
-rw-r--r-- | src/daycare.c | 4 | ||||
-rw-r--r-- | src/decoration.c | 6 | ||||
-rw-r--r-- | src/event_object_lock.c | 8 | ||||
-rwxr-xr-x | src/item_menu.c | 4 | ||||
-rw-r--r-- | src/menu_specialized.c | 2 | ||||
-rw-r--r-- | src/player_pc.c | 8 | ||||
-rw-r--r-- | src/scrcmd.c | 10 | ||||
-rwxr-xr-x | src/shop.c | 10 | ||||
-rw-r--r-- | src/union_room.c | 19 | ||||
-rw-r--r-- | src/wild_encounter.c | 4 |
14 files changed, 52 insertions, 45 deletions
diff --git a/src/battle_dome.c b/src/battle_dome.c index 59e418a06..ea1e5abba 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -1211,8 +1211,8 @@ static const u8 gUnknown_0860D1A0[DOME_TOURNAMENT_TRAINERS_COUNT / 2][DOME_ROUND static const u8 gUnknown_0860D1C0[DOME_TOURNAMENT_TRAINERS_COUNT] = {0, 15, 8, 7, 3, 12, 11, 4, 1, 14, 9, 6, 2, 13, 10, 5}; -// Each tourney trainer has a text describing their potential to win, depending on their seed ranking for the current tourney -// Dome Ace Tucker has their own separate potential text +// The first line of text on a trainers info card. It describes their potential to win, based on their seed in the tournament tree. +// Dome Ace Tucker has their own separate potential text. static const u8 *const sBattleDomePotentialTexts[DOME_TOURNAMENT_TRAINERS_COUNT + 1] = { BattleDome_Text_Potential1, // Highest potential @@ -1234,7 +1234,7 @@ static const u8 *const sBattleDomePotentialTexts[DOME_TOURNAMENT_TRAINERS_COUNT BattleDome_Text_PotentialDomeAceTucker, }; -// The first line of text on a trainers info card that gives information about their battle style (dependent on their party's moves) +// The second line of text on a trainers info card. It gives information about their battle style (dependent on their party's moves). static const u8 *const sBattleDomeOpponentStyleTexts[NUM_BATTLE_STYLES] = { [DOME_BATTLE_STYLE_RISKY] = BattleDome_Text_StyleRiskDisaster, @@ -1271,7 +1271,7 @@ static const u8 *const sBattleDomeOpponentStyleTexts[NUM_BATTLE_STYLES] = [DOME_BATTLE_STYLE_UNUSED4] = BattleDome_Text_StyleSampleMessage4, }; -// The second line of text on a trainers info card that gives information about their party's stat spread +// The third line of text on a trainers info card. It that gives information about their party's stat spread (based on their Pokémon's effort values and Nature). static const u8 *const sBattleDomeOpponentStatsTexts[] = { BattleDome_Text_EmphasizesHPAndAtk, // DOME_TEXT_TWO_GOOD_STATS and DOME_TEXT_HP start here diff --git a/src/battle_main.c b/src/battle_main.c index 001e2ec17..977bcbd9c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -1961,10 +1961,10 @@ static u8 CreateNPCTrainerParty(struct Pokemon *party, u16 trainerNum, bool8 fir if (gTrainers[trainerNum].doubleBattle == TRUE) personalityValue = 0x80; - else if (gTrainers[trainerNum].encounterMusic_gender & 0x80) - personalityValue = 0x78; + else if (gTrainers[trainerNum].encounterMusic_gender & F_TRAINER_FEMALE) + personalityValue = 0x78; // Use personality more likely to result in a female Pokémon else - personalityValue = 0x88; + personalityValue = 0x88; // Use personality more likely to result in a male Pokémon for (j = 0; gTrainers[trainerNum].trainerName[j] != EOS; j++) nameHash += gTrainers[trainerNum].trainerName[j]; diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 0b13512ec..095cd2bdf 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -106,7 +106,7 @@ static void BagAction_Give(u8); static void BagAction_Cancel(u8); static void BagAction_UseInBattle(u8); static void BagCursorMoved(s32, bool8, struct ListMenu *); -static void PrintItemQuantity(u8, s32, u8); +static void PrintItemQuantity(u8 windowId, u32 itemId, u8 y); static void TossItem(u8); static void DontTossItem(u8); @@ -651,7 +651,7 @@ static void BagCursorMoved(s32 itemIndex, bool8 onInit, struct ListMenu *list) } } -static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y) +static void PrintItemQuantity(u8 windowId, u32 itemIndex, u8 y) { s32 xAlign; if (itemIndex == LIST_CANCEL) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 15e44dd75..d927ffb76 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3269,7 +3269,7 @@ static void Cmd_getexp(void) if (viaExpShare) // at least one mon is getting exp via exp share { - *exp = calculatedExp / 2 / viaSentIn; + *exp = SAFE_DIV(calculatedExp / 2, viaSentIn); if (*exp == 0) *exp = 1; @@ -3279,7 +3279,7 @@ static void Cmd_getexp(void) } else { - *exp = calculatedExp / viaSentIn; + *exp = SAFE_DIV(calculatedExp, viaSentIn); if (*exp == 0) *exp = 1; gExpShareExp = 0; diff --git a/src/daycare.c b/src/daycare.c index 4199bfda6..6a1715049 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -29,7 +29,7 @@ extern const struct Evolution gEvolutionTable[][EVOS_PER_MON]; static void ClearDaycareMonMail(struct DaycareMail *mail); static void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare); static u8 GetDaycareCompatibilityScore(struct DayCare *daycare); -static void DaycarePrintMonInfo(u8 windowId, s32 daycareSlotId, u8 y); +static void DaycarePrintMonInfo(u8 windowId, u32 daycareSlotId, u8 y); // RAM buffers used to assist with BuildEggMoveset() EWRAM_DATA static u16 sHatchedEggLevelUpMoves[EGG_LVL_UP_MOVES_ARRAY_COUNT] = {0}; @@ -1226,7 +1226,7 @@ static void DaycarePrintMonLvl(struct DayCare *daycare, u8 windowId, u32 daycare DaycareAddTextPrinter(windowId, lvlText, x, y); } -static void DaycarePrintMonInfo(u8 windowId, s32 daycareSlotId, u8 y) +static void DaycarePrintMonInfo(u8 windowId, u32 daycareSlotId, u8 y) { if (daycareSlotId < (unsigned) DAYCARE_MON_COUNT) { diff --git a/src/decoration.c b/src/decoration.c index 6b6cf21e8..ebd7eb26c 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -147,7 +147,7 @@ static void ReturnToActionsMenuFromCategories(u8 taskId); static void ExitTraderDecorationMenu(u8 taskId); static void CopyDecorationMenuItemName(u8 *dest, u16 decoration); static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct ListMenu *menu); -static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, s32 itemIndex, u8 y); +static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, u32 itemIndex, u8 y); static void ShowDecorationItemsWindow(u8 taskId); static void HandleDecorationItemsMenuInput(u8 taskId); static void PrintDecorationItemDescription(s32 itemIndex); @@ -912,9 +912,9 @@ static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct L PrintDecorationItemDescription(itemIndex); } -static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, s32 itemIndex, u8 y) +static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, u32 itemIndex, u8 y) { - if (itemIndex != -2) + if (itemIndex != LIST_CANCEL) { if (IsDecorationIndexInSecretBase(itemIndex + 1) == TRUE) BlitMenuInfoIcon(windowId, MENU_INFO_ICON_BALL_RED, 92, y + 2); diff --git a/src/event_object_lock.c b/src/event_object_lock.c index dec2d7906..179c72813 100644 --- a/src/event_object_lock.c +++ b/src/event_object_lock.c @@ -40,7 +40,7 @@ bool8 IsFreezePlayerFinished(void) } -void ScriptFreezeObjectEvents(void) +void FreezeObjects_WaitForPlayer(void) { FreezeObjectEvents(); CreateTask(Task_FreezePlayer, 80); @@ -82,7 +82,9 @@ bool8 IsFreezeSelectedObjectAndPlayerFinished(void) } } -void LockSelectedObjectEvent(void) +// Freeze all objects immediately except the selected object and the player. +// The selected object and player are frozen once their movement is finished. +void FreezeObjects_WaitForPlayerAndSelected(void) { u8 taskId; FreezeObjectEventsExceptOne(gSelectedObjectEvent); @@ -144,6 +146,8 @@ static void Task_FreezeObjectAndPlayer(u8 taskId) DestroyTask(taskId); } +// Freeze all objects immediately except the player and the approaching trainers. +// The approaching trainers and player are frozen once their movement is finished void FreezeForApproachingTrainers(void) { u8 trainerObjectId1, trainerObjectId2, taskId; diff --git a/src/item_menu.c b/src/item_menu.c index de4d82e9b..39abf883a 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -133,7 +133,7 @@ void UpdatePocketScrollPositions(void); u8 CreateBagInputHandlerTask(u8); void sub_81AC23C(u8); void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu*); -void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 a); +void BagMenu_ItemPrintCallback(u8 windowId, u32 itemIndex, u8 a); void ItemMenu_UseOutOfBattle(u8 taskId); void ItemMenu_Toss(u8 taskId); void ItemMenu_Register(u8 taskId); @@ -893,7 +893,7 @@ void BagMenu_MoveCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *li } } -void BagMenu_ItemPrintCallback(u8 windowId, s32 itemIndex, u8 y) +void BagMenu_ItemPrintCallback(u8 windowId, u32 itemIndex, u8 y) { u16 itemId; u16 itemQuantity; diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 4c4be57f0..2afcf51ca 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -253,7 +253,7 @@ static u8 sub_81D1D34(u8 a0) return sUnknown_0203CF48[a0]; } -static void sub_81D1D44(u8 windowId, s32 itemId, u8 y) +static void sub_81D1D44(u8 windowId, u32 itemId, u8 y) { u8 buffer[30]; u16 length; diff --git a/src/player_pc.c b/src/player_pc.c index a040ba5b6..946f0645c 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -119,7 +119,7 @@ static void sub_816C060(u16 itemId); static void sub_816BEF0(s32 id); static void sub_816B4DC(u8 taskId); static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu * thisMenu); -static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset); +static void fish4_goto_x5_or_x6(u8 windowId, u32 id, u8 yOffset); // EWRAM static EWRAM_DATA const u8 *gPcItemMenuOptionOrder = NULL; @@ -943,7 +943,7 @@ static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu *thisMenu) if (gUnknown_0203BCC4->unk666 == 0xFF) { sub_816C0C8(); - if (id != -2) + if (id != LIST_CANCEL) sub_816C060(gSaveBlock1Ptr->pcItems[id].itemId); else sub_816C060(ITEMPC_GO_BACK_TO_PREV); @@ -951,9 +951,9 @@ static void ItemStorage_MoveCursor(s32 id, bool8 b, struct ListMenu *thisMenu) } } -static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset) +static void fish4_goto_x5_or_x6(u8 windowId, u32 id, u8 yOffset) { - if (id != -2) + if (id != LIST_CANCEL) { if (gUnknown_0203BCC4->unk666 != 0xFF) { diff --git a/src/scrcmd.c b/src/scrcmd.c index 0ee20d1c6..f53483978 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1203,6 +1203,8 @@ bool8 ScrCmd_turnvobject(struct ScriptContext *ctx) return FALSE; } +// lockall freezes all object events except the player immediately. +// The player is frozen after waiting for their current movement to finish. bool8 ScrCmd_lockall(struct ScriptContext *ctx) { if (IsUpdateLinkStateCBActive()) @@ -1211,12 +1213,14 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx) } else { - ScriptFreezeObjectEvents(); + FreezeObjects_WaitForPlayer(); SetupNativeScript(ctx, IsFreezePlayerFinished); return TRUE; } } +// lock freezes all object events except the player and the selected object immediately. +// The player and selected object are frozen after waiting for their current movement to finish. bool8 ScrCmd_lock(struct ScriptContext *ctx) { if (IsUpdateLinkStateCBActive()) @@ -1227,12 +1231,12 @@ bool8 ScrCmd_lock(struct ScriptContext *ctx) { if (gObjectEvents[gSelectedObjectEvent].active) { - LockSelectedObjectEvent(); + FreezeObjects_WaitForPlayerAndSelected(); SetupNativeScript(ctx, IsFreezeSelectedObjectAndPlayerFinished); } else { - ScriptFreezeObjectEvents(); + FreezeObjects_WaitForPlayer(); SetupNativeScript(ctx, IsFreezePlayerFinished); } return TRUE; diff --git a/src/shop.c b/src/shop.c index 55b421928..2a30bea22 100755 --- a/src/shop.c +++ b/src/shop.c @@ -91,7 +91,7 @@ static void Task_ReturnToItemListAfterDecorationPurchase(u8 taskId); static void Task_HandleShopMenuBuy(u8 taskId); static void Task_HandleShopMenuSell(u8 taskId); static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list); -static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y); +static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y); static const struct YesNoFuncTable sShopPurchaseYesNoFuncs = { @@ -552,17 +552,17 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, s BuyMenuPrint(2, description, 3, 1, 0, 0); } -static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) +static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y) { u8 x; - if (item != LIST_CANCEL) + if (itemId != LIST_CANCEL) { if (sMartInfo.martType == MART_TYPE_NORMAL) { ConvertIntToDecimalStringN( gStringVar1, - ItemId_GetPrice(item) >> GetPriceReduction(POKENEWS_SLATEPORT), + ItemId_GetPrice(itemId) >> GetPriceReduction(POKENEWS_SLATEPORT), STR_CONV_MODE_LEFT_ALIGN, 5); } @@ -570,7 +570,7 @@ static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y) { ConvertIntToDecimalStringN( gStringVar1, - gDecorations[item].price, + gDecorations[itemId].price, STR_CONV_MODE_LEFT_ALIGN, 5); } diff --git a/src/union_room.c b/src/union_room.c index bd6b303b9..8d02a260d 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -253,10 +253,10 @@ static bool32 UR_PrintFieldMessage(const u8 *); static s32 GetChatLeaderActionRequestMessage(u8 *, u32, u16 *, struct WirelessLink_URoom *); static void Task_InitUnionRoom(u8 taskId); static bool8 AreGnameUnameDifferent(struct WirelessGnameUnamePair*, const struct WirelessGnameUnamePair*); -static void ItemPrintFunc_PossibleGroupMembers(u8, s32, u8); -static void ListMenuItemPrintFunc_UnionRoomGroups(u8, s32, u8); -static void TradeBoardListMenuItemPrintFunc(u8, s32, u8); -static void nullsub_14(u8, s32, u8); +static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, u32 id, u8 y); +static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, u32 id, u8 y); +static void TradeBoardListMenuItemPrintFunc(u8 windowId, u32 id, u8 y); +static void nullsub_14(u8 windowId, u32 id, u8 y); #include "data/union_room.h" @@ -835,7 +835,7 @@ static bool8 Leader_SetStateIfMemberListChanged(struct WirelessLink_Leader *data return FALSE; } -static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, s32 id, u8 y) +static void ItemPrintFunc_PossibleGroupMembers(u8 windowId, u32 id, u8 y) { struct WirelessLink_Leader *data = sWirelessLinkMain.leader; u8 colorIdx = UR_COLOR_DKE_WHT_LTE; @@ -1363,7 +1363,7 @@ static u8 URoomGroupListGetTextColor(struct WirelessLink_Group *data, u32 id) return UR_COLOR_DKE_WHT_LTE; } -static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, s32 id, u8 y) +static void ListMenuItemPrintFunc_UnionRoomGroups(u8 windowId, u32 id, u8 y) { struct WirelessLink_Group *data = sWirelessLinkMain.group; u8 colorId = URoomGroupListGetTextColor(data, id); @@ -4074,9 +4074,8 @@ static s32 UnionRoomGetPlayerInteractionResponse(struct UnkStruct_Main0 *main0, } } -void nullsub_14(u8 windowId, s32 itemId, u8 y) +void nullsub_14(u8 windowId, u32 itemId, u8 y) { - } static void TradeBoardPrintItemInfo(u8 windowId, u8 y, struct GFtgtGname * gname, const u8 * uname, u8 colorIdx) @@ -4100,7 +4099,7 @@ static void TradeBoardPrintItemInfo(u8 windowId, u8 y, struct GFtgtGname * gname } } -static void TradeBoardListMenuItemPrintFunc(u8 windowId, s32 itemId, u8 y) +static void TradeBoardListMenuItemPrintFunc(u8 windowId, u32 itemId, u8 y) { struct WirelessLink_Leader *data = sWirelessLinkMain.leader; struct GFtgtGname *rfu; @@ -4420,7 +4419,7 @@ static void HandleCancelActivity(bool32 setData) static void UR_EnableScriptContext2AndFreezeObjectEvents(void) { ScriptContext2_Enable(); - ScriptFreezeObjectEvents(); + FreezeObjects_WaitForPlayer(); } static u8 GetActivePartnerSpriteGenderParam(struct WirelessLink_URoom *data) diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 767fbe4e7..8bcb17605 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -162,7 +162,7 @@ static u8 ChooseWildMonIndex_Land(void) return 8; else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_8 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) return 9; - else if (rand == ENCOUNTER_CHANCE_LAND_MONS_SLOT_9) + else if (rand >= ENCOUNTER_CHANCE_LAND_MONS_SLOT_9 && rand < ENCOUNTER_CHANCE_LAND_MONS_SLOT_10) return 10; else return 11; @@ -215,7 +215,7 @@ static u8 ChooseWildMonIndex_Fishing(u8 rod) wildMonIndex = 7; if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_7 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8) wildMonIndex = 8; - if (rand == ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8) + if (rand >= ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_8 && rand < ENCOUNTER_CHANCE_FISHING_MONS_SUPER_ROD_SLOT_9) wildMonIndex = 9; break; } |