mirror of
https://github.com/pret/pokeheartgold.git
synced 2024-11-30 08:30:54 +00:00
address review comments
This commit is contained in:
parent
5932c80a62
commit
bac3c65023
@ -37,7 +37,7 @@ struct BattleSetup { // declared in trainer_data.h
|
||||
PCStorage *storagePC; // 114
|
||||
SOUND_CHATOT *chatot[BATTLER_MAX]; // 118
|
||||
void *unk_128;
|
||||
void *unk_12C;
|
||||
void *wifiHistory;
|
||||
Options *options; // 130
|
||||
struct UnkStruct_02067A60 *unk_134;
|
||||
struct BattleSetupSub_138 unk138;
|
||||
|
@ -144,7 +144,7 @@ struct FieldSystem {
|
||||
u8 filler_98[0x4];
|
||||
void *unk9C;
|
||||
UnkStruct_Fsys_A0 *unkA0;
|
||||
Save_LinkBattleRuleset *unkA4;
|
||||
Save_LinkBattleRuleset *linkBattleRuleset;
|
||||
u32 *unkA8;
|
||||
u32 unkAC;
|
||||
void *unkB0;
|
||||
|
@ -74,7 +74,7 @@ typedef struct WirelessTradeSelectMonArgs {
|
||||
Party *party;
|
||||
SavePalPad *palPad;
|
||||
SaveData *saveData;
|
||||
SaveWiFiHistory *unk14;
|
||||
SaveWiFiHistory *wifiHistory;
|
||||
Options *options;
|
||||
GameStats *gameStats;
|
||||
Pokedex *pokedex;
|
||||
@ -131,7 +131,7 @@ typedef struct UnkStruct_0203F844 {
|
||||
PCStorage *pcStorage;
|
||||
Pokedex *pokedex;
|
||||
UnkStruct_021D2230 *unk14;
|
||||
void *unk18;
|
||||
void *wifiHistory;
|
||||
PlayerProfile *profile;
|
||||
SaveData *saveData;
|
||||
Options *options;
|
||||
|
@ -5,6 +5,15 @@
|
||||
|
||||
typedef struct SaveWiFiHistory SaveWiFiHistory;
|
||||
|
||||
#define SAVE_WIFI_HISTORY_COUNTRY_MAX 255
|
||||
#define SAVE_WIFI_HISTORY_REGION_MAX 64
|
||||
#define SAVE_WIFI_HISTORY_STATE_UNSEEEN 0
|
||||
#define SAVE_WIFI_HISTORY_STATE_NEW 1
|
||||
#define SAVE_WIFI_HISTORY_STATE_OLD 2
|
||||
#define SAVE_WIFI_HISTORY_STATE_MINE 3
|
||||
#define SAVE_WIFI_HISTORY_STATE_MAX 4
|
||||
#define SAVE_WIFI_HISTORY_STATE_MASK 3
|
||||
|
||||
u32 Save_WiFiHistory_sizeof(void);
|
||||
void Save_WiFiHistory_Init(SaveWiFiHistory *wifiHistory);
|
||||
SaveWiFiHistory *Save_WiFiHistory_Get(SaveData *saveData);
|
||||
|
@ -56,7 +56,7 @@ BOOL Battle_Run(OVY_MANAGER *man, int *state) {
|
||||
break;
|
||||
case BSTATE_LINK_INIT:
|
||||
ov12_022399D4(man, setup);
|
||||
sub_02039F68(setup->unk_12C);
|
||||
sub_02039F68(setup->wifiHistory);
|
||||
if (!sub_02039998()) {
|
||||
GameStats_Inc(setup->gameStats, GAME_STAT_UNK21);
|
||||
if (setup->battleType != 0x8F) {
|
||||
|
@ -66,7 +66,7 @@ BattleSetup *BattleSetup_New(HeapID heapId, u32 battleTypeFlags) {
|
||||
setup->bagCursor = NULL;
|
||||
setup->unk1B8 = NULL;
|
||||
setup->safariBalls = 0;
|
||||
setup->unk_12C = NULL;
|
||||
setup->wifiHistory = NULL;
|
||||
setup->gameStats = NULL;
|
||||
setup->fixedDamaageMovesBanned = FALSE;
|
||||
setup->bugContestMon = AllocMonZeroed(heapId);
|
||||
@ -247,7 +247,7 @@ void sub_02051D18(BattleSetup *setup, FieldSystem *fieldSystem, SaveData *saveDa
|
||||
setup->weatherType = LocalFieldData_GetWeatherType(local);
|
||||
setup->bagCursor = bagCursor;
|
||||
setup->unk1B8 = arg5;
|
||||
setup->unk_12C = Save_WiFiHistory_Get(saveData);
|
||||
setup->wifiHistory = Save_WiFiHistory_Get(saveData);
|
||||
setup->gameStats = Save_GameStats_Get(saveData);
|
||||
setup->palPad = Save_PalPad_Get(saveData);
|
||||
setup->mapNumber = mapno;
|
||||
@ -295,15 +295,15 @@ void BattleSetup_InitForFixedLevelFacility(BattleSetup *setup, FieldSystem *fiel
|
||||
Pokedex_Copy(pokedex, setup->pokedex);
|
||||
Options_Copy(options, setup->options);
|
||||
BattleSetup_SetChatotVoiceClip(setup, chatot, BATTLER_PLAYER);
|
||||
setup->storagePC = SaveArray_PCStorage_Get(fieldSystem->saveData);
|
||||
setup->timeOfDay = Field_GetTimeOfDay(fieldSystem);
|
||||
setup->bagCursor = fieldSystem->bagCursor;
|
||||
setup->unk1B8 = fieldSystem->unkB0;
|
||||
setup->unk_12C = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
setup->gameStats = Save_GameStats_Get(fieldSystem->saveData);
|
||||
setup->palPad = Save_PalPad_Get(fieldSystem->saveData);
|
||||
setup->mapNumber = fieldSystem->location->mapId;
|
||||
setup->saveData = fieldSystem->saveData;
|
||||
setup->storagePC = SaveArray_PCStorage_Get(fieldSystem->saveData);
|
||||
setup->timeOfDay = Field_GetTimeOfDay(fieldSystem);
|
||||
setup->bagCursor = fieldSystem->bagCursor;
|
||||
setup->unk1B8 = fieldSystem->unkB0;
|
||||
setup->wifiHistory = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
setup->gameStats = Save_GameStats_Get(fieldSystem->saveData);
|
||||
setup->palPad = Save_PalPad_Get(fieldSystem->saveData);
|
||||
setup->mapNumber = fieldSystem->location->mapId;
|
||||
setup->saveData = fieldSystem->saveData;
|
||||
BattleSetup_SetAllySideBattlersToPlayer(setup);
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ void sub_020520B0(BattleSetup *setup, FieldSystem *fieldSystem, Party *party, u8
|
||||
pokedex = Save_Pokedex_Get(fieldSystem->saveData);
|
||||
chatot = Save_Chatot_Get(fieldSystem->saveData);
|
||||
options = Save_PlayerData_GetOptionsAddr(fieldSystem->saveData);
|
||||
ruleset = fieldSystem->unkA4;
|
||||
ruleset = fieldSystem->linkBattleRuleset;
|
||||
|
||||
setup->battleBg = BATTLE_BG_BUILDING_1;
|
||||
setup->terrain = TERRAIN_BUILDING;
|
||||
@ -366,15 +366,15 @@ void sub_020520B0(BattleSetup *setup, FieldSystem *fieldSystem, Party *party, u8
|
||||
Pokedex_Copy(pokedex, setup->pokedex);
|
||||
Options_Copy(options, setup->options);
|
||||
BattleSetup_SetChatotVoiceClip(setup, chatot, BATTLER_PLAYER);
|
||||
setup->storagePC = SaveArray_PCStorage_Get(fieldSystem->saveData);
|
||||
setup->timeOfDay = Field_GetTimeOfDay(fieldSystem);
|
||||
setup->bagCursor = fieldSystem->bagCursor;
|
||||
setup->unk1B8 = fieldSystem->unkB0;
|
||||
setup->unk_12C = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
setup->gameStats = Save_GameStats_Get(fieldSystem->saveData);
|
||||
setup->mapNumber = fieldSystem->location->mapId;
|
||||
setup->palPad = Save_PalPad_Get(fieldSystem->saveData);
|
||||
setup->saveData = fieldSystem->saveData;
|
||||
setup->storagePC = SaveArray_PCStorage_Get(fieldSystem->saveData);
|
||||
setup->timeOfDay = Field_GetTimeOfDay(fieldSystem);
|
||||
setup->bagCursor = fieldSystem->bagCursor;
|
||||
setup->unk1B8 = fieldSystem->unkB0;
|
||||
setup->wifiHistory = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
setup->gameStats = Save_GameStats_Get(fieldSystem->saveData);
|
||||
setup->mapNumber = fieldSystem->location->mapId;
|
||||
setup->palPad = Save_PalPad_Get(fieldSystem->saveData);
|
||||
setup->saveData = fieldSystem->saveData;
|
||||
|
||||
if (sub_0203401C(sub_0203993C())) {
|
||||
int avatar = PlayerProfile_GetAvatar(profile);
|
||||
|
@ -828,7 +828,7 @@ void sub_02051598(FieldSystem *fieldSystem, void *param1, s32 battleType) {
|
||||
sub_020522F0(setup, fieldSystem, param1);
|
||||
sub_0202FBF0(fieldSystem->saveData, HEAP_ID_FIELD, &var);
|
||||
|
||||
setup->unk1B2 = sub_02051474(fieldSystem->unkA4, battleType);
|
||||
setup->unk1B2 = sub_02051474(fieldSystem->linkBattleRuleset, battleType);
|
||||
|
||||
encounter = Encounter_New(setup, BattleSetup_GetWildTransitionEffect(setup), BattleSetup_GetWildBattleMusic(setup), NULL);
|
||||
|
||||
@ -843,7 +843,7 @@ void sub_020515FC(FieldSystem *fieldSystem, Party *party, s32 battleType) {
|
||||
sub_020520B0(setup, fieldSystem, party, NULL);
|
||||
sub_0202FBF0(fieldSystem->saveData, HEAP_ID_FIELD, &var);
|
||||
|
||||
setup->unk1B2 = sub_02051474(fieldSystem->unkA4, battleType);
|
||||
setup->unk1B2 = sub_02051474(fieldSystem->linkBattleRuleset, battleType);
|
||||
|
||||
encounter = Encounter_New(setup, BattleSetup_GetWildTransitionEffect(setup), BattleSetup_GetWildBattleMusic(setup), NULL);
|
||||
|
||||
|
@ -869,7 +869,7 @@ static void InitWirelessTradeSelectMonArgs(WirelessTradeSelectMonArgs *args, Fie
|
||||
args->profile = Save_PlayerData_GetProfileAddr(fieldSystem->saveData);
|
||||
args->party = SaveArray_Party_Get(fieldSystem->saveData);
|
||||
args->palPad = SaveArray_Get(fieldSystem->saveData, SAVE_PALPAD);
|
||||
args->unk14 = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
args->wifiHistory = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
args->options = Save_PlayerData_GetOptionsAddr(fieldSystem->saveData);
|
||||
args->pokedex = Save_Pokedex_Get(fieldSystem->saveData);
|
||||
args->natDexEnabled = SaveArray_IsNatDexEnabled(fieldSystem->saveData);
|
||||
@ -1179,7 +1179,7 @@ void sub_0203F844(FieldSystem *fieldSystem, u16 a1) {
|
||||
args->pcStorage = SaveArray_PCStorage_Get(fieldSystem->saveData);
|
||||
args->pokedex = Save_Pokedex_Get(fieldSystem->saveData);
|
||||
args->unk14 = sub_0202C6F4(fieldSystem->saveData);
|
||||
args->unk18 = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
args->wifiHistory = Save_WiFiHistory_Get(fieldSystem->saveData);
|
||||
args->profile = Save_PlayerData_GetProfileAddr(fieldSystem->saveData);
|
||||
args->options = Save_PlayerData_GetOptionsAddr(fieldSystem->saveData);
|
||||
args->gameStats = Save_GameStats_Get(fieldSystem->saveData);
|
||||
|
@ -4,12 +4,14 @@
|
||||
|
||||
#include "constants/geonet_globe.h"
|
||||
|
||||
#define SAVE_WIFI_HISTORY_REGION_WIDTH ((SAVE_WIFI_HISTORY_REGION_MAX + 3) / 4)
|
||||
|
||||
struct SaveWiFiHistory {
|
||||
u32 unk_000; // unused but type needed for alignment
|
||||
u8 seenNotJapanese;
|
||||
u8 country;
|
||||
u8 region;
|
||||
u8 seenLocations[255 * 16]; // does not match as a 2d array
|
||||
u8 seenLocations[SAVE_WIFI_HISTORY_COUNTRY_MAX * SAVE_WIFI_HISTORY_REGION_WIDTH]; // does not match as a 2d array
|
||||
}; // size: 0xFF8
|
||||
|
||||
u32 Save_WiFiHistory_sizeof(void) {
|
||||
@ -27,11 +29,11 @@ SaveWiFiHistory *Save_WiFiHistory_Get(SaveData *saveData) {
|
||||
}
|
||||
|
||||
void WiFiHistory_SetPlayerGlobeInfo(SaveWiFiHistory *wifiHistory, int country, int region) {
|
||||
GF_ASSERT(country < 256);
|
||||
GF_ASSERT(region < 64);
|
||||
GF_ASSERT(country < SAVE_WIFI_HISTORY_COUNTRY_MAX + 1);
|
||||
GF_ASSERT(region < SAVE_WIFI_HISTORY_REGION_MAX);
|
||||
wifiHistory->country = country;
|
||||
wifiHistory->region = region;
|
||||
WiFiHistory_SetLocationSeenState(wifiHistory, country, region, 3);
|
||||
WiFiHistory_SetLocationSeenState(wifiHistory, country, region, SAVE_WIFI_HISTORY_STATE_MINE);
|
||||
SaveSubstruct_UpdateCRC(SAVE_WIFI_HISTORY);
|
||||
}
|
||||
|
||||
@ -44,22 +46,22 @@ u8 WiFiHistory_GetPlayerRegion(SaveWiFiHistory *wifiHistory) {
|
||||
}
|
||||
|
||||
int WiFiHistory_GetLocationSeenState(SaveWiFiHistory *wifiHistory, int country, int region) {
|
||||
GF_ASSERT(country < 256);
|
||||
GF_ASSERT(region < 64);
|
||||
GF_ASSERT(country < SAVE_WIFI_HISTORY_COUNTRY_MAX + 1);
|
||||
GF_ASSERT(region < SAVE_WIFI_HISTORY_REGION_MAX);
|
||||
if (country == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (wifiHistory->seenLocations[(country - 1) * 16 + region / 4] >> ((region % 4) * 2)) & 3;
|
||||
return (wifiHistory->seenLocations[(country - 1) * 16 + region / 4] >> ((region % 4) * 2)) & SAVE_WIFI_HISTORY_STATE_MASK;
|
||||
}
|
||||
|
||||
void WiFiHistory_SetLocationSeenState(SaveWiFiHistory *wifiHistory, int country, int region, int state) {
|
||||
GF_ASSERT(state < 4);
|
||||
GF_ASSERT(country < 256);
|
||||
GF_ASSERT(region < 64);
|
||||
GF_ASSERT(state < SAVE_WIFI_HISTORY_STATE_MAX);
|
||||
GF_ASSERT(country < SAVE_WIFI_HISTORY_COUNTRY_MAX + 1);
|
||||
GF_ASSERT(region < SAVE_WIFI_HISTORY_REGION_MAX);
|
||||
if (country != 0) {
|
||||
u8 *pVal = &wifiHistory->seenLocations[(country - 1) * 16 + region / 4];
|
||||
*pVal &= (3 << ((region % 4) * 2)) ^ 0xFF;
|
||||
*pVal &= (SAVE_WIFI_HISTORY_STATE_MASK << ((region % 4) * 2)) ^ 0xFF;
|
||||
*pVal |= state << ((region % 4) * 2);
|
||||
if (country != COUNTRY_JAPAN) {
|
||||
WiFiHistory_SetNonJapaneseFlag(wifiHistory, TRUE);
|
||||
@ -81,12 +83,12 @@ void WiFiHistory_UpgradeAllLocationsState(SaveWiFiHistory *wifiHistory) {
|
||||
int i;
|
||||
int j;
|
||||
u8 byte;
|
||||
for (i = 0; i < 255 * 16; ++i) {
|
||||
for (i = 0; i < SAVE_WIFI_HISTORY_COUNTRY_MAX * SAVE_WIFI_HISTORY_REGION_WIDTH; ++i) {
|
||||
byte = wifiHistory->seenLocations[i];
|
||||
for (j = 0; j < 8; j += 2) {
|
||||
if (((byte >> j) & 3) == 1) {
|
||||
byte &= (3 << j) ^ 0xFF;
|
||||
byte |= (2 << j);
|
||||
if (((byte >> j) & SAVE_WIFI_HISTORY_STATE_MASK) == SAVE_WIFI_HISTORY_STATE_NEW) {
|
||||
byte &= (SAVE_WIFI_HISTORY_STATE_MASK << j) ^ 0xFF;
|
||||
byte |= (SAVE_WIFI_HISTORY_STATE_OLD << j);
|
||||
}
|
||||
}
|
||||
wifiHistory->seenLocations[i] = byte;
|
||||
|
Loading…
Reference in New Issue
Block a user