Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from AmProsius/bug223
"The Big Thing of the Brotherhood" creates log entries for Old and New Camp
- Loading branch information
Showing
7 changed files
with
193 additions
and
0 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
99 changes: 99 additions & 0 deletions
99
src/Ninja/G1CP/Content/Fixes/Session/fix223_CorKalomSpyQuest.d
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,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); | ||
}; | ||
}; |
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,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); | ||
}; |
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