Skip to content

Commit 5f10aa3

Browse files
committed
fix conflicts
2 parents f1e8be9 + 384b8f1 commit 5f10aa3

22 files changed

+634
-424
lines changed

include/battle_controllers.h

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,65 @@ enum {
6464
REQUEST_TOUGH_RIBBON_BATTLE,
6565
};
6666

67+
// Accessors for gBattleControllerExecFlags.
68+
//
69+
// These are provided for documentation purposes, to make the battle
70+
// controller internals and the link communication internals more
71+
// legible. Several of these have functions that you should call
72+
// (e.g. MarkBattlerForControllerExec) instead of using these macros
73+
// directly.
74+
75+
#define MARK_BATTLE_CONTROLLER_ACTIVE_ON_LOCAL(battler) \
76+
gBattleControllerExecFlags |= gBitTable[battler]
77+
78+
#define MARK_BATTLE_CONTROLLER_IDLE_ON_LOCAL(battler) \
79+
gBattleControllerExecFlags &= ~gBitTable(battler)
80+
81+
#define IS_BATTLE_CONTROLLER_ACTIVE_ON_LOCAL(battler) \
82+
(gBattleControllerExecFlags & gBitTable[battler])
83+
84+
#define MARK_BATTLE_CONTROLLER_MESSAGE_OUTBOUND_OVER_LINK(battler) \
85+
gBattleControllerExecFlags |= gBitTable[battler] << (32 - MAX_BATTLERS_COUNT)
86+
87+
#define MARK_BATTLE_CONTROLLER_MESSAGE_SYNCHRONIZED_OVER_LINK(battler) \
88+
gBattleControllerExecFlags &= ~((1 << 28) << (battler))
89+
90+
#define MARK_BATTLE_CONTROLLER_ACTIVE_FOR_PLAYER(battler, playerId) \
91+
gBattleControllerExecFlags |= gBitTable[battler] << ((playerId) << 2)
92+
93+
#define MARK_BATTLE_CONTROLLER_IDLE_FOR_PLAYER(battler, playerId) \
94+
gBattleControllerExecFlags &= ~(gBitTable[battler] << ((playerId) * 4))
95+
96+
#define IS_BATTLE_CONTROLLER_ACTIVE_FOR_PLAYER(battler, playerId) \
97+
(gBattleControllerExecFlags & (gBitTable[battler] << ((playerId) * 4)))
98+
99+
// This actually checks if a specific controller is active on any player or if
100+
// *any* controller is pending sync over link communications, but the macro name
101+
// can only be so specific before it just gets ridiculous.
102+
#define IS_BATTLE_CONTROLLER_ACTIVE_OR_PENDING_SYNC_ANYWHERE(battler) \
103+
(gBattleControllerExecFlags & ( \
104+
(gBitTable[battler]) \
105+
| (0xF << 28) \
106+
| (gBitTable[battler] << 4) \
107+
| (gBitTable[battler] << 8) \
108+
| (gBitTable[battler] << 12) \
109+
))
110+
67111
// Special arguments for Battle Controller functions.
68112

69-
enum { // Values given to the emit functions to choose gBattleBufferA or gBattleBufferB
70-
BUFFER_A,
71-
BUFFER_B
113+
enum {
114+
// For commands sent from the core battle engine to a controller.
115+
B_COMM_TO_CONTROLLER, // gBattleBufferA
116+
117+
// For replies sent from a controller to the core battle engine.
118+
B_COMM_TO_ENGINE, // gBattleBufferB
119+
120+
// During local play, a controller must directly mark itself as
121+
// inactive when it's done processing, whether or not it sends
122+
// a reply. During multiplayer, it must NOT directly mark itself
123+
// as inactive, but instead send one of these, with the player's
124+
// multiplayer ID as data.
125+
B_COMM_CONTROLLER_IS_DONE
72126
};
73127

74128
enum {

src/battle_ai_switch_items.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static bool8 ShouldSwitchIfPerishSong(void)
2323
&& gDisableStructs[gActiveBattler].perishSongTimer == 0)
2424
{
2525
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
26-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
26+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_SWITCH, 0);
2727
return TRUE;
2828
}
2929
else
@@ -107,7 +107,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
107107
{
108108
// We found a mon.
109109
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
110-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
110+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_SWITCH, 0);
111111
return TRUE;
112112
}
113113
}
@@ -207,7 +207,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
207207
{
208208
// we found a mon.
209209
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
210-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
210+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_SWITCH, 0);
211211
return TRUE;
212212
}
213213
}
@@ -229,14 +229,14 @@ static bool8 ShouldSwitchIfNaturalCure(void)
229229
&& Random() & 1)
230230
{
231231
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
232-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
232+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_SWITCH, 0);
233233
return TRUE;
234234
}
235235
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0
236236
&& Random() & 1)
237237
{
238238
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
239-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
239+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_SWITCH, 0);
240240
return TRUE;
241241
}
242242

@@ -248,7 +248,7 @@ static bool8 ShouldSwitchIfNaturalCure(void)
248248
if (Random() & 1)
249249
{
250250
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
251-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
251+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_SWITCH, 0);
252252
return TRUE;
253253
}
254254

@@ -416,7 +416,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
416416
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0)
417417
{
418418
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
419-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_SWITCH, 0);
419+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_SWITCH, 0);
420420
return TRUE;
421421
}
422422
}
@@ -599,7 +599,7 @@ void AI_TrySwitchOrUseItem(void)
599599
}
600600
}
601601

602-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_MOVE, BATTLE_OPPOSITE(gActiveBattler) << 8);
602+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_USE_MOVE, BATTLE_OPPOSITE(gActiveBattler) << 8);
603603
}
604604

605605
static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var)
@@ -933,7 +933,7 @@ static bool8 ShouldUseItem(void)
933933

934934
if (shouldUse)
935935
{
936-
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0);
936+
BtlController_EmitTwoReturnValues(B_COMM_TO_ENGINE, B_ACTION_USE_ITEM, 0);
937937
*(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item;
938938
gBattleResources->battleHistory->trainerItems[i] = ITEM_NONE;
939939
return shouldUse;

0 commit comments

Comments
 (0)