Skip to content

Commit

Permalink
Merge reverted changes of #128 into #244
Browse files Browse the repository at this point in the history
  • Loading branch information
AmProsius committed Jul 27, 2021
2 parents 5694a14 + dc06b49 commit be95e16
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion docs/changelog_de.md
Expand Up @@ -12,7 +12,7 @@

### Story
* Fix [#55](https://g1cp.org/issues/55) (aktualisiert): Grim erwähnt In Extremo im zweiten Kapitel nun auch wenn das Konzert noch nicht begonnen hat. Für weitere Informationen zum Fix, siehe [v1.1.0](https://g1cp.org/blob/master/docs/changelog_de.md#v110-01052021).
* Fix [#128](https://g1cp.org/issues/128): Ein Gardist der Alten Mine hat nun nicht mehr zwei ENDE Dialogoptionen.
* Fix [#128](https://g1cp.org/issues/128): Einer der Gardisten der Alten Mine hat nun nicht mehr zwei ENDE Dialogoptionen.
* Fix [#129](https://g1cp.org/issues/129): Drakes Hautfarbe des Körpers entspricht jetzt der seines Kopfes.
* Fix [#220](https://g1cp.org/issues/220): Gor Na Ran greift den Spielercharakter nicht länger im 6. Kapitel an.
* Fix [#224](https://g1cp.org/issues/224): Grash-Varrag-Arushat (der letzte untote Ork-Priester) kann nicht mehr durch Fallschaden getötet werden.
Expand Down
23 changes: 0 additions & 23 deletions src/Ninja/G1CP/Content/Bytecode/return.d

This file was deleted.

56 changes: 50 additions & 6 deletions src/Ninja/G1CP/Content/Fixes/Session/fix042_GuardExitDialog.d
Expand Up @@ -2,6 +2,30 @@
* #42 Guard has duplicated END dialog
*/

/*
* Check the content of a given function against: { return 1; }
*/
func int G1CP_042_ConfirmByteCode(var int funcId) {
if (!G1CP_IsFuncI(funcId, "int|none")) {
return FALSE;
};
var zCPar_Symbol symb; symb = _^(MEM_GetSymbolByIndex(funcId));
var int pos; pos = symb.content + MEM_Parser.stack_stack;

// Ends with return
if (MEM_ReadByte(pos+5) == zPAR_TOK_RET) {
// And pushes a non-zero value onto the stack
if (MEM_ReadByte(pos) == zPAR_TOK_PUSHINT) && (MEM_ReadInt(pos+1) != 0) {
return TRUE;
} else if (MEM_ReadByte(pos) == zPAR_TOK_PUSHVAR) && (G1CP_GetIntI(MEM_ReadInt(pos+1), 0, 0) != 0) {
return TRUE;
};
};

// Not found as expected
return FALSE;
};

/*
* The fix function called from initialization
*
Expand All @@ -11,26 +35,46 @@
* present) is replaced to check if there is another exit dialog.
*/
func int G1CP_042_GuardExitDialog() {
var int applied; applied = FALSE;

// Find all necessary symbols
if (!G1CP_IsStringConst("DIALOG_ENDE", 0)) {
return FALSE;
};
var int funcId; funcId = MEM_GetSymbolIndex("DIA_Grd_218_Exit_Condition");

if (G1CP_ConfirmByteCode(funcId)) {
if (G1CP_042_ConfirmByteCode(funcId)) {
HookDaedalusFuncI(funcId, MEM_GetFuncId(G1CP_042_EndCond));
applied = TRUE;
return TRUE;
};

return applied;
return FALSE;
};

/*
* The replacement functions with additional conditions
*/
func int G1CP_042_NewCondition(var C_Npc slf) {
// Define possibly missing symbols locally
const string DIALOG_ENDE = "END";
DIALOG_ENDE = G1CP_GetStringConst("DIALOG_ENDE", 0, DIALOG_ENDE);

// Avoid recursion, because G1C_HasInfoWithDesc may call this very condition function
const int recursion = FALSE;
if (recursion) {
return FALSE;
};

recursion = TRUE;
var int hasEnd; hasEnd = G1CP_HasInfoWithDesc(slf, DIALOG_ENDE);
recursion = FALSE;

// Keep this one, if there is no other exit dialog
return !hasEnd;
};

/*
* The additional condition
*/
func int G1CP_042_EndCond() {
G1CP_ReportFuncToSpy();
return G1CP_NpcCheckEndDialog(self);
return G1CP_042_NewCondition(self);
};
8 changes: 4 additions & 4 deletions src/Ninja/G1CP/Content/Fixes/Session/fix128_GuardExitDialog.d
Expand Up @@ -19,18 +19,18 @@ func int G1CP_128_GuardExitDialog() {
};
var int funcId; funcId = MEM_GetSymbolIndex("DIA_Grd_264_Exit_Condition");

if (G1CP_ConfirmByteCode(funcId)) {
if (G1CP_042_ConfirmByteCode(funcId)) {
HookDaedalusFuncI(funcId, MEM_GetFuncId(G1CP_128_EndCond));
applied = TRUE;
return TRUE;
};

return applied;
return FALSE;
};

/*
* The additional condition
*/
func int G1CP_128_EndCond() {
G1CP_ReportFuncToSpy();
return G1CP_NpcCheckEndDialog(self);
return G1CP_042_NewCondition(self);
};
8 changes: 4 additions & 4 deletions src/Ninja/G1CP/Content/Fixes/Session/fix244_GuardExitDialog.d
Expand Up @@ -19,18 +19,18 @@ func int G1CP_244_GuardExitDialog() {
};
var int funcId; funcId = MEM_GetSymbolIndex("DIA_Grd_245_Exit_Condition");

if (G1CP_ConfirmByteCode(funcId)) {
if (G1CP_042_ConfirmByteCode(funcId)) {
HookDaedalusFuncI(funcId, MEM_GetFuncId(G1CP_244_EndCond));
applied = TRUE;
return TRUE;
};

return applied;
return FALSE;
};

/*
* The additional condition
*/
func int G1CP_244_EndCond() {
G1CP_ReportFuncToSpy();
return G1CP_NpcCheckEndDialog(self);
return G1CP_042_NewCondition(self);
};
22 changes: 0 additions & 22 deletions src/Ninja/G1CP/Content/Misc/npc.d
Expand Up @@ -173,25 +173,3 @@ func void G1CP_NpcIdSetAiVar(var int npcInstance, var string aiVarName, var int
var C_Npc slf; slf = Hlp_GetNpc(npcInstance);
G1CP_NpcSetAiVar(slf, aiVarName, value);
};

/*
* Check an NPC's end dialogs and keep only one
*/
func int G1CP_NpcCheckEndDialog(var C_Npc slf) {
// Define possibly missing symbols locally
const string DIALOG_ENDE = "END";
DIALOG_ENDE = G1CP_GetStringConst("DIALOG_ENDE", 0, DIALOG_ENDE);

// Avoid recursion, because G1C_HasInfoWithDesc may call this very condition function
const int recursion = FALSE;
if (recursion) {
return FALSE;
};

recursion = TRUE;
var int hasEnd; hasEnd = G1CP_HasInfoWithDesc(slf, DIALOG_ENDE);
recursion = FALSE;

// Keep this one, if there is no other exit dialog
return !hasEnd;
};
1 change: 0 additions & 1 deletion src/Ninja/G1CP/Content_G1.src
Expand Up @@ -29,7 +29,6 @@ Content\Bytecode\string.d
Content\Bytecode\if.d
Content\Bytecode\ou.d
Content\Bytecode\sendToSpy.d
Content\Bytecode\return.d

Content\Misc\info.d
Content\Misc\topic.d
Expand Down

0 comments on commit be95e16

Please sign in to comment.