mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Add fix for described UB
This commit is contained in:
parent
603d870ea0
commit
020266463c
@ -126,7 +126,6 @@ static const u8 *const sHeaderTexts[NUM_GROUPTYPES + 1] = {
|
|||||||
// Activity, group type, number of players
|
// Activity, group type, number of players
|
||||||
// 0 players means the number of players can change and should be counted dynamically
|
// 0 players means the number of players can change and should be counted dynamically
|
||||||
// GROUPTYPE_TOTAL have no unique group and are simply counted in the total of "people communicating"
|
// GROUPTYPE_TOTAL have no unique group and are simply counted in the total of "people communicating"
|
||||||
// UB: GROUPTYPE_NONE (-1) can potentially be used as an index into a u8[4] in CountPlayersInGroupAndGetActivity
|
|
||||||
static const u8 sActivityGroupInfo[][3] = {
|
static const u8 sActivityGroupInfo[][3] = {
|
||||||
{ACTIVITY_BATTLE_SINGLE, GROUPTYPE_BATTLE, 2},
|
{ACTIVITY_BATTLE_SINGLE, GROUPTYPE_BATTLE, 2},
|
||||||
{ACTIVITY_BATTLE_DOUBLE, GROUPTYPE_BATTLE, 2},
|
{ACTIVITY_BATTLE_DOUBLE, GROUPTYPE_BATTLE, 2},
|
||||||
@ -382,6 +381,13 @@ static u32 CountPlayersInGroupAndGetActivity(struct RfuPlayer * player, u32 * gr
|
|||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(sActivityGroupInfo); i++)
|
for (i = 0; i < ARRAY_COUNT(sActivityGroupInfo); i++)
|
||||||
{
|
{
|
||||||
|
#ifdef UBFIX
|
||||||
|
// GROUPTYPE_NONE is -1, and shouldn't be used as an index into groupCounts.
|
||||||
|
// In theory the only activity with this group type (ACTIVITY_SEARCH) wouldn't
|
||||||
|
// satisfy the condition below, but not necessarily.
|
||||||
|
if (group_type(i) == GROUPTYPE_NONE)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
if (activity == group_activity(i) && player->groupScheduledAnim == UNION_ROOM_SPAWN_IN)
|
if (activity == group_activity(i) && player->groupScheduledAnim == UNION_ROOM_SPAWN_IN)
|
||||||
{
|
{
|
||||||
if (group_players(i) == 0)
|
if (group_players(i) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user