forked from DizzyEggg/pokeemerald
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting Battle configs during tests (#5803)
Co-authored-by: sbird <[email protected]>
- Loading branch information
1 parent
e64da06
commit 009de5c
Showing
8 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef GUARD_CONSTANTS_GENERATIONAL_CHANGES_H | ||
#define GUARD_CONSTANTS_GENERATIONAL_CHANGES_H | ||
|
||
enum GenConfigTag | ||
{ | ||
GEN_CONFIG_GALE_WINGS, | ||
GEN_CONFIG_COUNT | ||
}; | ||
|
||
#endif // GUARD_CONSTANTS_GENERATIONAL_CHANGES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef GUARD_GENERATIONAL_CHANGES_H | ||
#define GUARD_GENERATIONAL_CHANGES_H | ||
|
||
#include "constants/generational_changes.h" | ||
#include "config/battle.h" | ||
|
||
static const u8 sGenerationalChanges[GEN_CONFIG_COUNT] = | ||
{ | ||
[GEN_CONFIG_GALE_WINGS] = B_GALE_WINGS, | ||
}; | ||
|
||
#if TESTING | ||
extern u8 *gGenerationalChangesTestOverride; | ||
#endif | ||
|
||
static inline u32 GetGenConfig(enum GenConfigTag configTag) | ||
{ | ||
if (configTag >= GEN_CONFIG_COUNT) return GEN_LATEST; | ||
#if TESTING | ||
if (gGenerationalChangesTestOverride == NULL) return sGenerationalChanges[configTag]; | ||
return gGenerationalChangesTestOverride[configTag]; | ||
#else | ||
return sGenerationalChanges[configTag]; | ||
#endif | ||
} | ||
|
||
static inline void SetGenConfig(enum GenConfigTag configTag, u32 value) | ||
{ | ||
#if TESTING | ||
if (configTag >= GEN_CONFIG_COUNT) return; | ||
if (gGenerationalChangesTestOverride == NULL) return; | ||
gGenerationalChangesTestOverride[configTag] = value; | ||
#endif | ||
} | ||
|
||
#if TESTING | ||
void TestInitConfigData(void); | ||
void TestFreeConfigData(void); | ||
#endif | ||
|
||
#endif // GUARD_GENERATIONAL_CHANGES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "global.h" | ||
#include "generational_changes.h" | ||
#include "malloc.h" | ||
#include "constants/generational_changes.h" | ||
|
||
#if TESTING | ||
EWRAM_DATA u8 *gGenerationalChangesTestOverride = NULL; | ||
|
||
void TestInitConfigData(void) | ||
{ | ||
gGenerationalChangesTestOverride = Alloc(sizeof(sGenerationalChanges)); | ||
memcpy(gGenerationalChangesTestOverride, sGenerationalChanges, sizeof(sGenerationalChanges)); | ||
} | ||
|
||
void TestFreeConfigData(void) | ||
{ | ||
TRY_FREE_AND_SET_NULL(gGenerationalChangesTestOverride) | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters