Apply style suggestions from code review

This commit is contained in:
Eduardo Quezada D'Ottone 2022-09-03 21:22:15 -04:00 committed by GitHub
parent 13cc640b78
commit 4017fc3e20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 372 additions and 452 deletions

View File

@ -52,7 +52,7 @@ Debug_FlagsNotSetMessage::
Debug_FlagsNotSetMessage_Text:
.string "Feature unavailable!\n"
.string "Please define a usable flag in:\l"
.string "'include/constants/debug{UNDERSCORE}config.h'!$"
.string "'include/constants/overworld{UNDERSCORE}config.h'!$"
Debug_Script_1::
end

View File

@ -138,8 +138,8 @@
#define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water.
#define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles.
#define B_SMART_WILD_AI_FLAG 0 // If not 0, you can set this flag in a script to enable smart wild pokemon
#define B_FLAG_NO_BAG_USE 0 // If this flag is set, the debug function in the Utility submenu to disable the bag in battle can be used.
#define B_FLAG_NO_CATCHING 0 // If this flag is set, the debug function in the Utility submenu to disable catching of wild Pokémon can be used.
#define B_FLAG_NO_BAG_USE 0 // If this flag is set, the ability to use the bag in battle is disabled.
#define B_FLAG_NO_CATCHING 0 // If this flag is set, the ability to catch wild Pokémon is disabled.
// Var Settings
// To use the following features in scripting, replace the 0s with the var ID you're assigning it to.

View File

@ -16,7 +16,6 @@
#include "berry.h"
#include "bg.h"
#include "data.h"
#include "debug.h"
#include "decompress.h"
#include "dma3.h"
#include "event_data.h"

View File

@ -151,7 +151,6 @@ enum { //Sound
// EWRAM
static EWRAM_DATA struct DebugMonData *sDebugMonData = NULL;
// *******************************
struct DebugMonData
{
@ -172,7 +171,6 @@ struct DebugMonData
u16 mon_move_3;
};
// *******************************
// Define functions
static void Debug_ShowMenu(void (*HandleInput)(u8), struct ListMenuTemplate LMtemplate);
@ -285,12 +283,6 @@ extern u8 Debug_ShowFieldMessageStringVar4[];
extern u8 Debug_CheatStart[];
extern u8 PlayersHouse_2F_EventScript_SetWallClock[];
extern u8 PlayersHouse_2F_EventScript_CheckWallClock[];
#ifdef BATTLE_ENGINE
#define ABILITY_NAME_LENGTH 16
#else
#define ABILITY_NAME_LENGTH 12
#endif
extern const u8 gAbilityNames[][ABILITY_NAME_LENGTH + 1];
// *******************************
@ -449,7 +441,6 @@ static const struct ListMenuItem sDebugMenu_Items_Utilities[] =
[DEBUG_UTIL_MENU_ITEM_SAVEBLOCK] = {gDebugText_Util_SaveBlockSpace, DEBUG_UTIL_MENU_ITEM_SAVEBLOCK},
[DEBUG_UTIL_MENU_ITEM_CHECKWALLCLOCK] = {gDebugText_Util_CheckWallClock, DEBUG_UTIL_MENU_ITEM_CHECKWALLCLOCK},
[DEBUG_UTIL_MENU_ITEM_SETWALLCLOCK] = {gDebugText_Util_SetWallClock, DEBUG_UTIL_MENU_ITEM_SETWALLCLOCK},
[DEBUG_UTIL_MENU_ITEM_CHECKWEEKDAY] = {gDebugText_Util_CheckWeekDay, DEBUG_UTIL_MENU_ITEM_CHECKWEEKDAY},
[DEBUG_UTIL_MENU_ITEM_WATCHCREDITS] = {gDebugText_Util_WatchCredits, DEBUG_UTIL_MENU_ITEM_WATCHCREDITS},
[DEBUG_UTIL_MENU_ITEM_TRAINER_NAME] = {gDebugText_Util_Trainer_Name, DEBUG_UTIL_MENU_ITEM_TRAINER_NAME},
[DEBUG_UTIL_MENU_ITEM_TRAINER_GENDER] = {gDebugText_Util_Trainer_Gender, DEBUG_UTIL_MENU_ITEM_TRAINER_GENDER},
@ -528,7 +519,6 @@ static void (*const sDebugMenu_Actions_Utilities[])(u8) =
[DEBUG_UTIL_MENU_ITEM_SAVEBLOCK] = DebugAction_Util_CheckSaveBlock,
[DEBUG_UTIL_MENU_ITEM_CHECKWALLCLOCK] = DebugAction_Util_CheckWallClock,
[DEBUG_UTIL_MENU_ITEM_SETWALLCLOCK] = DebugAction_Util_SetWallClock,
[DEBUG_UTIL_MENU_ITEM_CHECKWEEKDAY] = DebugAction_Util_CheckWeekDay,
[DEBUG_UTIL_MENU_ITEM_WATCHCREDITS] = DebugAction_Util_WatchCredits,
[DEBUG_UTIL_MENU_ITEM_TRAINER_NAME] = DebugAction_Util_Trainer_Name,
[DEBUG_UTIL_MENU_ITEM_TRAINER_GENDER] = DebugAction_Util_Trainer_Gender,
@ -944,7 +934,6 @@ static void DebugAction_Util_Warp_Warp(u8 taskId)
CopyWindowToVram(windowId, 3);
ConvertIntToDecimalStringN(gStringVar1, gTasks[taskId].data[3], STR_CONV_MODE_LEADING_ZEROS, 2);
ConvertIntToDecimalStringN(gStringVar2, MAP_GROUPS_COUNT-1, STR_CONV_MODE_LEADING_ZEROS, 2);
StringExpandPlaceholders(gStringVar1, gDebugText_Util_WarpToMap_SelMax);
@ -1103,7 +1092,8 @@ static void DebugAction_Util_Warp_SelectWarp(u8 taskId)
{
gTasks[taskId].data[7] = gTasks[taskId].data[3];
//WARP
SetWarpDestinationToMapWarp(gTasks[taskId].data[5], gTasks[taskId].data[6], gTasks[taskId].data[7]); //If not warp with the number available -> center of map
//If there's no warp with the number available, warp to the center of the map.
SetWarpDestinationToMapWarp(gTasks[taskId].data[5], gTasks[taskId].data[6], gTasks[taskId].data[7]);
DoWarp();
ResetInitialPlayerAvatarState();
DebugAction_DestroyExtraWindow(taskId);
@ -1365,13 +1355,10 @@ static void DebugAction_Flags_SetPokedexFlags(u8 taskId)
static void DebugAction_Flags_SwitchDex(u8 taskId)
{
if (FlagGet(FLAG_SYS_POKEDEX_GET))
{
FlagClear(FLAG_SYS_POKEDEX_GET);
PlaySE(SE_PC_OFF);
}else{
FlagSet(FLAG_SYS_POKEDEX_GET);
else
PlaySE(SE_PC_LOGIN);
}
FlagToggle(FLAG_SYS_POKEDEX_GET);
}
static void DebugAction_Flags_SwitchNatDex(u8 taskId)
{
@ -1379,7 +1366,9 @@ static void DebugAction_Flags_SwitchNatDex(u8 taskId)
{
DisableNationalPokedex();
PlaySE(SE_PC_OFF);
}else{
}
else
{
EnableNationalPokedex();
PlaySE(SE_PC_LOGIN);
}
@ -1387,13 +1376,10 @@ static void DebugAction_Flags_SwitchNatDex(u8 taskId)
static void DebugAction_Flags_SwitchPokeNav(u8 taskId)
{
if (FlagGet(FLAG_SYS_POKENAV_GET))
{
FlagClear(FLAG_SYS_POKENAV_GET);
PlaySE(SE_PC_OFF);
}else{
FlagSet(FLAG_SYS_POKENAV_GET);
else
PlaySE(SE_PC_LOGIN);
}
FlagToggle(FLAG_SYS_POKENAV_GET);
}
static void DebugAction_Flags_ToggleFlyFlags(u8 taskId)
{
@ -1402,6 +1388,7 @@ static void DebugAction_Flags_ToggleFlyFlags(u8 taskId)
PlaySE(SE_PC_OFF);
else
PlaySE(SE_PC_LOGIN);
FlagToggle(FLAG_VISITED_LITTLEROOT_TOWN);
FlagToggle(FLAG_VISITED_OLDALE_TOWN);
FlagToggle(FLAG_VISITED_DEWFORD_TOWN);
@ -1428,6 +1415,7 @@ static void DebugAction_Flags_ToggleBadgeFlags(u8 taskId)
PlaySE(SE_PC_OFF);
else
PlaySE(SE_PC_LOGIN);
FlagToggle(FLAG_BADGE01_GET);
FlagToggle(FLAG_BADGE02_GET);
FlagToggle(FLAG_BADGE03_GET);
@ -1454,47 +1442,38 @@ static void DebugAction_Flags_CollisionOnOff(u8 taskId)
ScriptContext_SetupScript(Debug_FlagsNotSetMessage);
#else
if (FlagGet(DEBUG_FLAG_NO_COLLISION))
{
FlagClear(DEBUG_FLAG_NO_COLLISION);
PlaySE(SE_PC_OFF);
}else{
FlagSet(DEBUG_FLAG_NO_COLLISION);
else
PlaySE(SE_PC_LOGIN);
}
FlagToggle(DEBUG_FLAG_NO_COLLISION);
#endif
}
static void DebugAction_Flags_EncounterOnOff(u8 taskId)
{
#if DEBUG_FLAG_NO_ENCOUNTER == 0
#if OW_FLAG_NO_ENCOUNTER == 0
Debug_DestroyMenu(taskId);
LockPlayerFieldControls();
ScriptContext_SetupScript(Debug_FlagsNotSetMessage);
#else
if(FlagGet(DEBUG_FLAG_NO_ENCOUNTER))
{
FlagClear(DEBUG_FLAG_NO_ENCOUNTER);
if (FlagGet(OW_FLAG_NO_ENCOUNTER))
PlaySE(SE_PC_OFF);
}else{
FlagSet(DEBUG_FLAG_NO_ENCOUNTER);
else
PlaySE(SE_PC_LOGIN);
}
FlagToggle(OW_FLAG_NO_ENCOUNTER);
#endif
}
static void DebugAction_Flags_TrainerSeeOnOff(u8 taskId)
{
#if DEBUG_FLAG_NO_TRAINER_SEE == 0
#if OW_FLAG_NO_TRAINER_SEE == 0
Debug_DestroyMenu(taskId);
LockPlayerFieldControls();
ScriptContext_SetupScript(Debug_FlagsNotSetMessage);
#else
if(FlagGet(DEBUG_FLAG_NO_TRAINER_SEE))
{
FlagClear(DEBUG_FLAG_NO_TRAINER_SEE);
if (FlagGet(OW_FLAG_NO_TRAINER_SEE))
PlaySE(SE_PC_OFF);
}else{
FlagSet(DEBUG_FLAG_NO_TRAINER_SEE);
else
PlaySE(SE_PC_LOGIN);
}
FlagToggle(OW_FLAG_NO_TRAINER_SEE);
#endif
}
static void DebugAction_Flags_BagUseOnOff(u8 taskId)
@ -1505,13 +1484,10 @@ static void DebugAction_Flags_BagUseOnOff(u8 taskId)
ScriptContext_SetupScript(Debug_FlagsNotSetMessage);
#else
if (FlagGet(B_FLAG_NO_BAG_USE))
{
FlagClear(B_FLAG_NO_BAG_USE);
PlaySE(SE_PC_OFF);
}else{
FlagSet(B_FLAG_NO_BAG_USE);
else
PlaySE(SE_PC_LOGIN);
}
FlagToggle(B_FLAG_NO_BAG_USE);
#endif
}
static void DebugAction_Flags_CatchingOnOff(u8 taskId)
@ -1522,13 +1498,10 @@ static void DebugAction_Flags_CatchingOnOff(u8 taskId)
ScriptContext_SetupScript(Debug_FlagsNotSetMessage);
#else
if (FlagGet(B_FLAG_NO_CATCHING))
{
FlagClear(B_FLAG_NO_CATCHING);
PlaySE(SE_PC_OFF);
}else{
FlagSet(B_FLAG_NO_CATCHING);
else
PlaySE(SE_PC_LOGIN);
}
FlagToggle(B_FLAG_NO_CATCHING);
#endif
}
@ -1570,33 +1543,27 @@ static void DebugAction_Vars_Select(u8 taskId)
if (gMain.newKeys & DPAD_UP)
{
gTasks[taskId].data[3] += sPowersOfTen[gTasks[taskId].data[4]];
if(gTasks[taskId].data[3] > VARS_END){
if(gTasks[taskId].data[3] > VARS_END)
gTasks[taskId].data[3] = VARS_END;
}
}
if (gMain.newKeys & DPAD_DOWN)
{
gTasks[taskId].data[3] -= sPowersOfTen[gTasks[taskId].data[4]];
if(gTasks[taskId].data[3] < VARS_START){
if (gTasks[taskId].data[3] < VARS_START)
gTasks[taskId].data[3] = VARS_START;
}
}
if (gMain.newKeys & DPAD_LEFT)
{
gTasks[taskId].data[4] -= 1;
if(gTasks[taskId].data[4] < 0)
{
gTasks[taskId].data[4] = 0;
}
}
if (gMain.newKeys & DPAD_RIGHT)
{
gTasks[taskId].data[4] += 1;
if (gTasks[taskId].data[4] > DEBUG_NUMBER_DIGITS_VARIABLES - 1)
{
gTasks[taskId].data[4] = DEBUG_NUMBER_DIGITS_VARIABLES - 1;
}
}
if (gMain.newKeys & DPAD_ANY)
{
@ -1654,10 +1621,10 @@ static void DebugAction_Vars_SetValue(u8 taskId)
gTasks[taskId].data[6] += sPowersOfTen[gTasks[taskId].data[4]];
else
gTasks[taskId].data[6] = 32000 - 1;
if(gTasks[taskId].data[6] >= 32000){
if (gTasks[taskId].data[6] >= 32000)
gTasks[taskId].data[6] = 32000 - 1;
}
}
if(gMain.newKeys & DPAD_DOWN)
{
gTasks[taskId].data[6] -= sPowersOfTen[gTasks[taskId].data[4]];
@ -1880,9 +1847,11 @@ static void DebugAction_Give_AllTMs(u8 taskId)
{
u16 i;
PlayFanfare(MUS_OBTAIN_TMHM);
for (i = ITEM_TM01; i <= ITEM_TM50; i++)
if(!CheckBagHasItem(i, 1))
for (i = ITEM_TM01; i <= ITEM_HM08; i++)
{
if (ItemIdToBattleMoveId(i) != MOVE_NONE && !CheckBagHasItem(i, 1))
AddBagItem(i, 1);
}
Debug_DestroyMenu(taskId);
ScriptContext_Enable();
}
@ -1937,12 +1906,7 @@ static void DebugAction_Give_PokemonSimple(u8 taskId)
gTasks[taskId].data[5] = 0; //Complex?
FreeMonIconPalettes(); //Free space for new pallete
LoadMonIconPalette(gTasks[taskId].data[3]); //Loads pallete for current mon
#ifndef POKEMON_EXPANSION
gTasks[taskId].data[6] = CreateMonIcon(gTasks[taskId].data[3], SpriteCB_MonIcon, DEBUG_NUMBER_ICON_X, DEBUG_NUMBER_ICON_Y, 4, 0, TRUE); //Create pokemon sprite
#endif
#ifdef POKEMON_EXPANSION
gTasks[taskId].data[6] = CreateMonIcon(gTasks[taskId].data[3], SpriteCB_MonIcon, DEBUG_NUMBER_ICON_X, DEBUG_NUMBER_ICON_Y, 4, 0); //Create pokemon sprite
#endif
gSprites[gTasks[taskId].data[6]].oam.priority = 0; //Mon Icon ID
}
static void DebugAction_Give_PokemonComplex(u8 taskId)
@ -1972,7 +1936,6 @@ static void DebugAction_Give_PokemonComplex(u8 taskId)
StringExpandPlaceholders(gStringVar4, gDebugText_PokemonID);
AddTextPrinterParameterized(windowId, 1, gStringVar4, 1, 1, 0, NULL);
gTasks[taskId].func = DebugAction_Give_Pokemon_SelectId;
gTasks[taskId].data[2] = windowId;
gTasks[taskId].data[3] = 1; //Current ID
@ -1980,12 +1943,7 @@ static void DebugAction_Give_PokemonComplex(u8 taskId)
gTasks[taskId].data[5] = 1; //Complex?
FreeMonIconPalettes(); //Free space for new palletes
LoadMonIconPalette(gTasks[taskId].data[3]); //Loads pallete for current mon
#ifndef POKEMON_EXPANSION
gTasks[taskId].data[6] = CreateMonIcon(gTasks[taskId].data[3], SpriteCB_MonIcon, DEBUG_NUMBER_ICON_X, DEBUG_NUMBER_ICON_Y, 4, 0, TRUE); //Create pokemon sprite
#endif
#ifdef POKEMON_EXPANSION
gTasks[taskId].data[6] = CreateMonIcon(gTasks[taskId].data[3], SpriteCB_MonIcon, DEBUG_NUMBER_ICON_X, DEBUG_NUMBER_ICON_Y, 4, 0); //Create pokemon sprite
#endif
gSprites[gTasks[taskId].data[6]].oam.priority = 0; //Mon Icon ID
gTasks[taskId].data[7] = 0; //iterator
}
@ -1999,16 +1957,12 @@ static void DebugAction_Give_Pokemon_SelectId(u8 taskId)
if (gMain.newKeys & DPAD_UP)
{
gTasks[taskId].data[3] += sPowersOfTen[gTasks[taskId].data[4]];
if(gTasks[taskId].data[3] > SPECIES_CELEBI && gTasks[taskId].data[3] < SPECIES_TREECKO)
gTasks[taskId].data[3] = SPECIES_TREECKO;
if (gTasks[taskId].data[3] >= NUM_SPECIES)
gTasks[taskId].data[3] = NUM_SPECIES - 1;
}
if (gMain.newKeys & DPAD_DOWN)
{
gTasks[taskId].data[3] -= sPowersOfTen[gTasks[taskId].data[4]];
if(gTasks[taskId].data[3] < SPECIES_TREECKO && gTasks[taskId].data[3] > SPECIES_CELEBI)
gTasks[taskId].data[3] = SPECIES_CELEBI;
if (gTasks[taskId].data[3] < 1)
gTasks[taskId].data[3] = 1;
}
@ -2033,12 +1987,7 @@ static void DebugAction_Give_Pokemon_SelectId(u8 taskId)
FreeAndDestroyMonIconSprite(&gSprites[gTasks[taskId].data[6]]);
FreeMonIconPalettes(); //Free space for new pallete
LoadMonIconPalette(gTasks[taskId].data[3]); //Loads pallete for current mon
#ifndef POKEMON_EXPANSION
gTasks[taskId].data[6] = CreateMonIcon(gTasks[taskId].data[3], SpriteCB_MonIcon, DEBUG_NUMBER_ICON_X, DEBUG_NUMBER_ICON_Y, 4, 0, TRUE); //Create pokemon sprite
#endif
#ifdef POKEMON_EXPANSION
gTasks[taskId].data[6] = CreateMonIcon(gTasks[taskId].data[3], SpriteCB_MonIcon, DEBUG_NUMBER_ICON_X, DEBUG_NUMBER_ICON_Y, 4, 0); //Create pokemon sprite
#endif
gSprites[gTasks[taskId].data[6]].oam.priority = 0;
}
@ -2242,11 +2191,8 @@ static void DebugAction_Give_Pokemon_SelectNature(u8 taskId)
static void DebugAction_Give_Pokemon_SelectAbility(u8 taskId)
{
u8 abilityId;
u8 abilityCount = 2 - 1; //-1 for proper iteration
u8 abilityCount = NUM_ABILITY_SLOTS - 1; //-1 for proper iteration
u8 i = 0;
#ifdef POKEMON_EXPANSION
abilityCount = NUM_ABILITY_SLOTS - 1;
#endif
if (gMain.newKeys & DPAD_ANY)
{
@ -2583,12 +2529,11 @@ static void DebugAction_Give_Pokemon_ComplexCreateMon(u8 taskId) //https://githu
IVs[4] = sDebugMonData->mon_iv_satk;
IVs[5] = sDebugMonData->mon_iv_sdef;
//Nature
if (nature == NUM_NATURES || nature == 0xFF)
nature = Random() % NUM_NATURES;
//Shinyness
//Shininess
if (isShiny == 1)
{
u32 personality;
@ -2608,21 +2553,9 @@ static void DebugAction_Give_Pokemon_ComplexCreateMon(u8 taskId) //https://githu
else
CreateMonWithNature(&mon, species, level, 32, nature);
//EVs/IVs
//IVs
for (i = 0; i < NUM_STATS; i++)
{
// ev
// if (evs[i] != 0xFF && evTotal < 510)
// {
// // only up to 510 evs
// if ((evTotal + evs[i]) > 510)
// evs[i] = (510 - evTotal);
// evTotal += evs[i];
// SetMonData(&mon, MON_DATA_HP_EV + i, &evs[i]);
// }
// iv
iv_val = IVs[i];
if (iv_val != 32 && iv_val != 0xFF)
SetMonData(&mon, MON_DATA_HP_IV + i, &iv_val);
@ -2648,17 +2581,7 @@ static void DebugAction_Give_Pokemon_ComplexCreateMon(u8 taskId) //https://githu
SetMonData(&mon, MON_DATA_ABILITY_NUM, &abilityNum);
//ball
// if (ball <= POKEBALL_COUNT)
// SetMonData(&mon, MON_DATA_POKEBALL, &ball);
//item
// heldItem[0] = item;
// heldItem[1] = item >> 8;
// SetMonData(&mon, MON_DATA_HELD_ITEM, heldItem);
// give player the mon
//sentToPc = GiveMonToPlayer(&mon);
SetMonData(&mon, MON_DATA_OT_NAME, gSaveBlock2Ptr->playerName);
SetMonData(&mon, MON_DATA_OT_GENDER, &gSaveBlock2Ptr->playerGender);
for (i = 0; i < PARTY_SIZE; i++)

View File

@ -9,7 +9,6 @@
#include "bike.h"
#include "coins.h"
#include "data.h"
#include "debug.h"
#include "event_data.h"
#include "event_object_lock.h"
#include "event_object_movement.h"

View File

@ -1,6 +1,5 @@
#include "global.h"
#include "battle_setup.h"
#include "debug.h"
#include "event_data.h"
#include "event_object_movement.h"
#include "field_effect.h"