summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Adding-Support-for-Connectivity-with-Other-Hacks-Whilst-Maintaining-Connectivity-with-Vanilla.md74
1 files changed, 73 insertions, 1 deletions
diff --git a/Adding-Support-for-Connectivity-with-Other-Hacks-Whilst-Maintaining-Connectivity-with-Vanilla.md b/Adding-Support-for-Connectivity-with-Other-Hacks-Whilst-Maintaining-Connectivity-with-Vanilla.md
index 3c165b9..aeecfd5 100644
--- a/Adding-Support-for-Connectivity-with-Other-Hacks-Whilst-Maintaining-Connectivity-with-Vanilla.md
+++ b/Adding-Support-for-Connectivity-with-Other-Hacks-Whilst-Maintaining-Connectivity-with-Vanilla.md
@@ -168,7 +168,7 @@ struct TrainerCard
This is so the game can use the `versionModifier` value when loading the trainer card.
Next, find the definition of `CopyTrainerCardData` and change it to the following:
```c
-void CopyTrainerCardData(struct TrainerCard *dst, u16 *src, u8 gameVersion, u8 versionModifier);
+void CopyTrainerCardData(struct TrainerCard *dst, struct TrainerCard *src, u8 gameVersion, u8 versionModifier);
```
Okay, now we actually need to use that new byte! Open [src/trainer_card.c](https://github.com/pret/pokeemerald/blob/master/src/trainer_card.c) and find the functions `CopyTrainerCardData`, `TrainerCard_GenerateCardForLinkPlayer` and `TrainerCard_GenerateCardForPlayer`.
In `CopyTrainerCardData`, make the following changes:
@@ -297,4 +297,76 @@ Same reasoning behind the `GetSetCardType` changes.
There are some static declarations in `src/trainer_card.c`. We need to change `VersionToCardType`'s declaration which is `static u8 VersionToCardType(u8);`, we need to change it to `static u8 VersionToCardType(u8, u8);`
+Next, we need to edit a couple of functions that call `CopyTrainerCardData`. These changes are required to get version modifier value of the game you're linking to for their trainer card.
+
+In `src/cable_club.c`, go to `Task_LinkupAwaitTrainerCardData` and make the following change:
+```diff
+static void Task_LinkupAwaitTrainerCardData(u8 taskId)
+{
+ u8 index;
+
+ if (CheckLinkErrored(taskId) == TRUE)
+ return;
+
+ if (GetBlockReceivedStatus() != GetSavedLinkPlayerCountAsBitFlags())
+ return;
+
+ for (index = 0; index < GetLinkPlayerCount(); index++)
+ {
+- CopyTrainerCardData(&gTrainerCards[index], (struct TrainerCard *)gBlockRecvBuffer[index], gLinkPlayers[index].version);
++ CopyTrainerCardData(&gTrainerCards[index], (struct TrainerCard *)gBlockRecvBuffer[index], gLinkPlayers[index].version, gLinkPlayers[index].versionModifier);
+ }
+
+ SetSuppressLinkErrorMessage(FALSE);
+ ResetBlockReceivedFlags();
+ FinishLinkup(&gSpecialVar_Result, taskId);
+}
+```
+And lastly, we need to go to `Task_ExchangeCards` and make a similar change:
+```diff
+static void Task_ExchangeCards(u8 taskId)
+{
+ switch (gTasks[taskId].data[0])
+ {
+ case 0:
+ if (GetMultiplayerId() == 0)
+ SendBlockRequest(BLOCK_REQ_SIZE_100);
+ gTasks[taskId].data[0]++;
+ break;
+ case 1:
+ if (GetBlockReceivedStatus() == GetLinkPlayerCountAsBitFlags())
+ {
+ s32 i;
+ u16 *recvBuff;
+
+ for (i = 0; i < GetLinkPlayerCount(); i++)
+ {
+ recvBuff = gBlockRecvBuffer[i];
+- CopyTrainerCardData(&gTrainerCards[i], (struct TrainerCard *)recvBuff, gLinkPlayers[i].version);
++ CopyTrainerCardData(&gTrainerCards[i], (struct TrainerCard *)recvBuff, gLinkPlayers[i].version, gLinkPlayers[i].versionModifier);
+ }
+
+ if (GetLinkPlayerCount() == 2)
+ {
+ // Note: hasAllFrontierSymbols is a re-used field.
+ // Here it is set by CreateTrainerCardInBuffer.
+ // If the player has a saved Wonder Card and it is the same Wonder Card
+ // as their partner then mystery gift stats are enabled.
+ recvBuff = gBlockRecvBuffer[GetMultiplayerId() ^ 1];
+ MysteryGift_TryEnableStatsByFlagId(((struct TrainerCard *)recvBuff)->hasAllFrontierSymbols);
+ }
+ else
+ {
+ MysteryGift_DisableStats();
+ }
+
+ ResetBlockReceivedFlags();
+ DestroyTask(taskId);
+ }
+ break;
+ }
+}
+```
+With that, the version modifier stuff should be getting checked and being used when it should be.
+
Once I can get around to it, I'll be updating this tutorial so it will show how to add new card types and show how to update the player graphics for the games you're linking in both the overworld and in battle. But for now, this is all I have. If I didn't mess anything up, your game should now use its own unique identifier when linking! \ No newline at end of file