Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"The Big Thing of the Brotherhood" creates log entries for Old and New Camp #223

Merged
merged 6 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Fix [#193](https://g1cp.org/issues/193): Objects activated by switches/levers/winches are no longer stuck after loading a game.
* Fix [#212](https://g1cp.org/issues/212): The cauldron near the ore heap in the New Camp now correctly requires a scoop to use.
* Fix [#213](https://g1cp.org/issues/213): The cauldron near the entrance of the hollow of the New Camp now correctly requires a scoop to use.
* Fix [#223](https://g1cp.org/issues/223): The quest log no longer shows entries for both Old Camp and New Camp for the quest "The Big Thing of the Brotherhood".

### Story
* Fix [#23](https://g1cp.org/issues/23): The armor "Novice's Armor" is now available in chapter 2 to make it accessible before receiving the first templar armor.
Expand Down
1 change: 1 addition & 0 deletions docs/changelog_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Fix [#201](https://g1cp.org/issues/201): Die Beschreibung der Rüstung "Antike Erzrüstung" passt nun in die Textbox des Inventars und enthält keinen Rechtschreibfehler mehr.
* Fix [#212](https://g1cp.org/issues/212): Der Kessel nahe dem Erzhaufen im Neuen Lager setzt zur Benutzung nun korrekt einen Kochlöffel voraus.
* Fix [#213](https://g1cp.org/issues/213): Der Kessel nahe dem Höhleneingang im Neuen Lager setzt zur Benutzung nun korrekt einen Kochlöffel voraus.
* Fix [#223](https://g1cp.org/issues/223): Das Tagebuch zeigt nicht mehr die Einträge für sowohl das Alte als auch für das Neue Lager für die Quest "Die Große Sache der Bruderschaft" an.

### Story
* Fix [#23](https://g1cp.org/issues/23): Die Rüstung "Novizenrüstung" ist nun im zweiten Kapitel erhältlich, damit sie vor der ersten Templerrüstung erlangt werden kann.
Expand Down
99 changes: 99 additions & 0 deletions src/Ninja/G1CP/Content/Fixes/Session/fix223_CorKalomSpyQuest.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* #223 "The Big Thing of the Brotherhood" creates log entries for Old and New Camp
*/
func int G1CP_223_CarKalomSpyQuest() {
var int applied; applied = FALSE;

// Get all necessary symbols
var int funcId; funcId = G1CP_GetFuncId("Info_CorKalom_BringMCQBalls_Success_Info", "void|none");
var int bLogEntryId; bLogEntryId = G1CP_GetFuncId("B_LogEntry", "void|string|string");
var int topic1Id; topic1Id = G1CP_GetStringConstId("CH1_GotoPsiCamp", 0);
var int topic2Id; topic2Id = G1CP_GetStringConstId("CH1_GotoPsi", 0);
if (funcId == -1) || (bLogEntryId == -1) || (topic1Id == -1) || (topic2Id == -1)
|| (!G1CP_IsIntVar("Mordrag_GotoKalom", 0)) || (!G1CP_IsIntVar("Raven_SpySect", 0))
|| (!G1CP_IsNpcInst("ORG_826_Mordrag")) {
return FALSE;
};

// Get the topic names
const string CH1_GotoPsiCamp = ""; CH1_GotoPsiCamp = G1CP_GetStringConstI(topic1Id, 0, CH1_GotoPsiCamp);
const string CH1_GotoPsi = ""; CH1_GotoPsi = G1CP_GetStringConstI(topic2Id, 0, CH1_GotoPsi);

// Check if the fix is even necessary
if (!Hlp_StrCmp(CH1_GotoPsiCamp, CH1_GotoPsi)) {
return FALSE;
};

// Find all calls to "B_LogEntry" in "Info_CorKalom_BringMCQBalls_Success_Info"
var int matches; matches = G1CP_FindCall(funcId, 0, bLogEntryId);

// Iterate over all occurrences to find the specific match
repeat(i, MEM_ArraySize(matches)-1); var int i;
var int addr; addr = MEM_ArrayRead(matches, i);
var int addrNext; addrNext = MEM_ArrayRead(matches, i+1);

/* We are looking for

-10 zPAR_TOK_PUSHVAR CH1_GotoPsiCamp
-5 zPAR_TOK_PUSHVAR xxxx
0 zPAR_TOK_CALL B_LogEntry <-- addr
+5 zPAR_TOK_PUSHVAR CH1_GotoPsi
+10 zPAR_TOK_PUSHVAR xxxx
+15 zPAR_TOK_CALL B_LogEntry <-- addrNexx
*/

// First check position of the next found call
if (addrNext != addr+15) {
continue;
};

// Next check the first arguments of both
if (!Hlp_StrCmp(G1CP_GetStringI(MEM_ReadInt(addr-9), 0, "G1CP invalid string 1"), CH1_GotoPsiCamp))
|| (!Hlp_StrCmp(G1CP_GetStringI(MEM_ReadInt(addr+6), 0, "G1CP invalid string 2"), CH1_GotoPsi)) {
continue;
};

// Found what we are looking for
MEMINT_OverrideFunc_Ptr = addr;
MEMINT_OFTokPar(zPAR_TOK_CALL, MEM_GetFuncOffset(G1CP_223_CarKalomSpyQuest_Topic1));
MEMINT_OverrideFunc_Ptr = addrNext;
MEMINT_OFTokPar(zPAR_TOK_CALL, MEM_GetFuncOffset(G1CP_223_CarKalomSpyQuest_Topic2));

applied = TRUE;
break;
end;

// Free the array
MEM_ArrayFree(matches);

return applied;
};

/*
* Intercept the first call to "B_LogEntry"
*/
func void G1CP_223_CarKalomSpyQuest_Topic1(var string topic, var string entry) {
G1CP_ReportFuncToSpy();

// Define possibly missing symbol locally
const int LOG_RUNNING = 1;

var C_Npc npc; npc = Hlp_GetNpc(G1CP_GetNpcInstId("Org_826_Mordrag"));
if (G1CP_GetIntVar("Mordrag_GotoKalom", 0, 0) == LOG_RUNNING) && (!Npc_IsDead(npc)) {
B_LogEntry(topic, entry);
};
};

/*
* Intercept the second call to "B_LogEntry"
*/
func void G1CP_223_CarKalomSpyQuest_Topic2(var string topic, var string entry) {
G1CP_ReportFuncToSpy();

// Define possibly missing symbol locally
const int LOG_RUNNING = 1;

if (G1CP_GetIntVar("Raven_SpySect", 0, 0) == LOG_RUNNING) {
B_LogEntry(topic, entry);
};
};
89 changes: 89 additions & 0 deletions src/Ninja/G1CP/Content/Tests/test223.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* #223 "The Big Thing of the Brotherhood" creates log entries for Old and New Camp
*
* The dialog function will be executed twice for each condition.
*
* Expected behavior: There will be exactly one entry in the log topic in both cases.
*/

/*
* Convenience function
*/
func int G1CP_Test_223_CallFunc(var int funcId, var string topic, var string iter) {
// Define possibly missing symbols locally
const int LOG_MISSION = 0;
const int LOG_RUNNING = 1;

// Create the log topic
Log_CreateTopic(topic, LOG_MISSION);
Log_SetTopicStatus(topic, LOG_RUNNING);

// Call the function to create the entry/entries
G1CP_Testsuite_Call(funcId, 0, 0, TRUE);

// Count the number of entries
var int count; count = -1;
var int ltPtr; ltPtr = G1CP_LogGetTopic(topic);
if (ltPtr) {
var oCLogTopic lt; lt = _^(ltPtr);
count = List_Length(lt.m_lstEntries_next);
};

G1CP_LogRemoveTopic(topic);

// Check the number of entries
if (count > 1) {
G1CP_TestsuiteErrorDetailSSS("Too many log entries were created for the ", iter, " condition");
return FALSE;
} else if (count == 0) {
G1CP_TestsuiteErrorDetailSSS("No log entry was created for the ", iter, " condition");
return FALSE;
} else if (count < 0) {
G1CP_TestsuiteErrorDetailSSS("The log entry was not found for the ", iter, " condition");
return FALSE;
} else {
return TRUE;
};
};

/*
* Test function
*/
func int G1CP_Test_223() {
const string TMP_TOPIC_NAME = "G1CP Log topic 223"; // Must be unique with all certainty
var int funcId; funcId = G1CP_Testsuite_CheckDialogFunc("Info_CorKalom_BringMCQBalls_Success_Info");
G1CP_Testsuite_CheckStringConst("CH1_GoToPsi", 0);
const string CH1_GotoPsiCamp = ""; CH1_GotoPsiCamp = G1CP_Testsuite_GetStringConst("CH1_GotoPsiCamp", 0);
var int ncQuestId; ncQuestId = G1CP_Testsuite_CheckIntVar("Mordrag_GotoKalom", 0);
var int ocQuestId; ocQuestId = G1CP_Testsuite_CheckIntVar("Raven_SpySect", 0);
G1CP_Testsuite_FindNpc("Org_826_Mordrag");
G1CP_Testsuite_CheckPassed();

// Define possibly missing symbols locally
const int ATR_HITPOINTS = 0;
const int LOG_RUNNING = 1;

var int passed; passed = 0;

// Backup values
G1CP_LogRenameTopic(CH1_GotoPsiCamp, TMP_TOPIC_NAME);
var int ncQuestBak; ncQuestBak = G1CP_GetIntVarI(ncQuestId, 0, 0);
var int ocQuestBak; ocQuestBak = G1CP_GetIntVarI(ocQuestId, 0, 0);

// First pass
G1CP_SetIntVarI(ncQuestId, 0, LOG_RUNNING);
G1CP_SetIntVarI(ocQuestId, 0, 0);
passed += G1CP_Test_223_CallFunc(funcId, CH1_GotoPsiCamp, "first");

// Second pass
G1CP_SetIntVarI(ncQuestId, 0, 0);
G1CP_SetIntVarI(ocQuestId, 0, LOG_RUNNING);
passed += G1CP_Test_223_CallFunc(funcId, CH1_GotoPsiCamp, "second");

// Restore values
G1CP_LogRenameTopic(CH1_GotoPsiCamp, TMP_TOPIC_NAME);
G1CP_SetIntVarI(ncQuestId, 0, ncQuestBak);
G1CP_SetIntVarI(ocQuestId, 0, ocQuestBak);

return (passed == 2);
};
1 change: 1 addition & 0 deletions src/Ninja/G1CP/Content/patchInit.d
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func void Ninja_G1CP_Menu(var int menuPtr) {
G1CP_215_GuyDailyRoutine(); // #215
G1CP_216_DiggerDailyRoutine(); // #216
G1CP_217_MercenaryDailyRoutine(); // #217
G1CP_223_CarKalomSpyQuest(); // #223
};
};

Expand Down
1 change: 1 addition & 0 deletions src/Ninja/G1CP/Content_G1.src
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Content\Fixes\Session\fix214_GrahamDailyRoutine.d
Content\Fixes\Session\fix215_GuyDailyRoutine.d
Content\Fixes\Session\fix216_DiggerDailyRoutine.d
Content\Fixes\Session\fix217_MercenaryDailyRoutine.d
Content\Fixes\Session\fix223_CorKalomSpyQuest.d

// Game save fixes
Content\Fixes\Gamesave\fix037_LogEntryGravoMerchant.d
Expand Down
1 change: 1 addition & 0 deletions src/Ninja/G1CP/Testsuite.src
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ Content\Tests\test214.d
Content\Tests\test215.d
Content\Tests\test216.d
Content\Tests\test217.d
Content\Tests\test223.d