-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes bug with the current difficulty not being checked when enabling…
… triggers.
- Loading branch information
Showing
4 changed files
with
172 additions
and
2 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
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,87 @@ | ||
/******************************************************************************* | ||
/* O P E N S O U R C E -- V I N I F E R A ** | ||
/******************************************************************************* | ||
* | ||
* @project Vinifera | ||
* | ||
* @file TRIGGEREXT_HOOKS.CPP | ||
* | ||
* @author CCHyper | ||
* | ||
* @brief Contains the hooks for the extended TriggerClass. | ||
* | ||
* @license Vinifera is free software: you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, either version | ||
* 3 of the License, or (at your option) any later version. | ||
* | ||
* Vinifera is distributed in the hope that it will be | ||
* useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
******************************************************************************/ | ||
#include "sideext_hooks.h" | ||
#include "tibsun_globals.h" | ||
#include "trigger.h" | ||
#include "triggertype.h" | ||
#include "scenario.h" | ||
#include "fatal.h" | ||
#include "debughandler.h" | ||
#include "asserthandler.h" | ||
|
||
#include "hooker.h" | ||
#include "hooker_macros.h" | ||
|
||
|
||
/** | ||
* #issue-299 | ||
* | ||
* Fixes the issue with the current difficulty not being checked | ||
* when enabling triggers. | ||
* | ||
* @see: TriggerTypeClass and TActionClass for the other parts of this fix. | ||
* | ||
* @author: CCHyper | ||
*/ | ||
DECLARE_PATCH(_TriggerClass_Constructor_Enabled_For_Difficulty_Patch) | ||
{ | ||
GET_REGISTER_STATIC(TriggerClass *, this_ptr, esi); | ||
|
||
/** | ||
* This is direct port of the code from Red Alert 2, which looks to fix this issue. | ||
*/ | ||
|
||
if (this_ptr->Class) { | ||
|
||
this_ptr->Reset(); | ||
|
||
/** | ||
* Set this trigger to be disabled if; | ||
* - The class instance is marked as inactive. | ||
* - It is marked as disabled for this current mission difficulty. | ||
*/ | ||
if (!this_ptr->Class->Enabled | ||
|| (Scen->Difficulty == DIFF_EASY && !this_ptr->Class->Easy) | ||
|| (Scen->Difficulty == DIFF_NORMAL && !this_ptr->Class->Normal) | ||
|| (Scen->Difficulty == DIFF_HARD && !this_ptr->Class->Hard)) { | ||
|
||
this_ptr->IsEnabled = false; | ||
} | ||
} | ||
|
||
JMP(0x00649188); | ||
} | ||
|
||
|
||
/** | ||
* Main function for patching the hooks. | ||
*/ | ||
void TriggerClassExtension_Hooks() | ||
{ | ||
Patch_Jump(0x00649171, &_TriggerClass_Constructor_Enabled_For_Difficulty_Patch); | ||
} |
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,31 @@ | ||
/******************************************************************************* | ||
/* O P E N S O U R C E -- V I N I F E R A ** | ||
/******************************************************************************* | ||
* | ||
* @project Vinifera | ||
* | ||
* @file TRIGGEREXT_HOOKS.H | ||
* | ||
* @author CCHyper | ||
* | ||
* @brief Contains the hooks for the extended TriggerClass. | ||
* | ||
* @license Vinifera is free software: you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation, either version | ||
* 3 of the License, or (at your option) any later version. | ||
* | ||
* Vinifera is distributed in the hope that it will be | ||
* useful, but WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
* PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program. | ||
* If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
******************************************************************************/ | ||
#pragma once | ||
|
||
|
||
void TriggerClassExtension_Hooks(); |