Skip to content

Commit

Permalink
Fix vanilla bug where it was impossible to tell infantry to enter clo…
Browse files Browse the repository at this point in the history
…aked allied transports
  • Loading branch information
Rampastring committed Feb 19, 2025
1 parent 9b775fe commit 803a0bb
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 1 deletion.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ This page lists all the individual contributions to the project by their author.
- Add `Inaccuracy` to RocketTypes.
- Add `TargetZoneScan` to TechnoTypes.
- Fix a bug where a visceroid was spawned when poison gas destroyed a non-crewed vehicle, building, or terrain object.
- Fix a bug where it was impossible to tell infantry to enter cloaked allied transports.
- **secsome**:
- Add support for up to 32767 waypoints to be used in scenarios.
- **Starkku**:
Expand Down
1 change: 1 addition & 0 deletions docs/Bugfixes.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ This page lists all vanilla bugs fixed by Vinifera.
- VehicleTypes with Jumpjet locomotion now take damage in flight.
- Fix the map glitching around when scrolling if the map is not large enough to fill the entire screen.
- Fix a bug where a visceroid was spawned when poison gas destroyed a non-crewed vehicle, building, or terrain object.
- Fix a bug where it was impossible to tell infantry to enter cloaked allied transports.
5 changes: 4 additions & 1 deletion src/extensions/extension_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "overlayext_hooks.h"
#include "overlaytypeext_hooks.h"
//#include "particleext_hooks.h"
#include "particleext_hooks.h"
#include "particletypeext_hooks.h"
#include "particlesysext_hooks.h"
#include "particlesystypeext_hooks.h"
Expand Down Expand Up @@ -108,6 +109,7 @@
#include "themeext_hooks.h"

#include "displayext_hooks.h"
#include "scrollext_hooks.h"
#include "sidebarext_hooks.h"
#include "mouseext_hooks.h"

Expand Down Expand Up @@ -199,7 +201,7 @@ void Extension_Hooks()
//BuildingLightExtension_Hooks(); // Not yet implemented
OverlayClassExtension_Hooks();
OverlayTypeClassExtension_Hooks();
//ParticleClassExtension_Hooks(); // Not yet implemented
ParticleClassExtension_Hooks();
ParticleTypeClassExtension_Hooks();
ParticleSystemClassExtension_Hooks();
ParticleSystemTypeClassExtension_Hooks();
Expand Down Expand Up @@ -253,6 +255,7 @@ void Extension_Hooks()
ThemeClassExtension_Hooks();

DisplayClassExtension_Hooks();
ScrollClassExtension_Hooks();
SidebarClassExtension_Hooks();
MouseClassExtension_Hooks();

Expand Down
139 changes: 139 additions & 0 deletions src/extensions/scroll/scrollext_hooks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*******************************************************************************
/* O P E N S O U R C E -- V I N I F E R A **
/*******************************************************************************
*
* @project Vinifera (Dawn of the Tiberium Age Build)
*
* @file SCROLLEXT_HOOKS.CPP
*
* @author Rampastring
*
* @brief Contains the hooks for the extended ScrollClass.
*
* @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 "building.h"
#include "house.h"
#include "housetype.h"
#include "mouse.h"
#include "particlesysext_hooks.h"
#include "particlesys.h"
#include "rules.h"
#include "scenario.h"
#include "techno.h"
#include "unit.h"
#include "tibsun_globals.h"
#include "tibsun_defines.h"
#include "fatal.h"
#include "debughandler.h"
#include "asserthandler.h"

#include "hooker.h"
#include "hooker_macros.h"


bool Passes_Cloak_Check(TechnoClass* techno)
{
if (PlayerPtr->Is_Ally(techno))
{
return true;
}

Coordinate coord = techno->Center_Coord();
const CellClass* cellptr = &Map[coord];
if (cellptr->Sensed_By((HousesType)PlayerPtr->ID))
{
return true;
}

return false;
}


/**
* Fixes a bug where mouse input is not handled on cloaked objects of allied players.
* Sadly, the bug appears to be caused by a function that is inlined or copy-pasted
* in multiple places, so we need multiple patches.
*
* Author: Rampastring
*/
DECLARE_PATCH(_ScrollClass_Input_Allied_Cloaked_Object_Patch1)
{
GET_REGISTER_STATIC(TechnoClass*, techno, esi);

if (Passes_Cloak_Check(techno))
{
// Target object is cloaked but visible to us (allied or sensed),
// handle mouse input on it normally.
JMP(0x005E886B);
}

// Target object is cloaked and not visible to us.
JMP(0x005E887F);
}


/**
* Fixes a bug where mouse input is not handled on cloaked buildings of allied players.
*
* Author: Rampastring
*/
DECLARE_PATCH(_ScrollClass_Input_Allied_Cloaked_Object_Patch2)
{
GET_REGISTER_STATIC(BuildingClass*, building, edi);

if (Passes_Cloak_Check(building))
{
// Target object is visible to us (allied or sensed), handle mouse input on it normally.
JMP(0x005E88D6);
}

// Target object is cloaked and not visible to us.
JMP(0x005E88E6);
}


/**
* Fixes a bug where mouse input is not handled on cloaked objects of allied players.
* While this is in TacticalClass, the bug is identical to the bugs in ScrollClass
* and has an identical fix, which is why we include this hack here.
*
* Author: Rampastring
*/
DECLARE_PATCH(_Tactical_Get_Object_At_Cell_Allied_Cloaked_Object_Patch)
{
GET_REGISTER_STATIC(TechnoClass*, techno, eax);

if (Passes_Cloak_Check(techno))
{
// Target object is visible to us (allied or sensed), handle mouse input on it normally.
JMP(0x0061680F);
}

// Target object is cloaked and not visible to us.
JMP(0x00616811);
}


/**
* Main function for patching the hooks.
*/
void ScrollClassExtension_Hooks()
{
Patch_Jump(0x005E8840, &_ScrollClass_Input_Allied_Cloaked_Object_Patch1);
Patch_Jump(0x005E88AA, &_ScrollClass_Input_Allied_Cloaked_Object_Patch2);
Patch_Jump(0x006167E3, &_Tactical_Get_Object_At_Cell_Allied_Cloaked_Object_Patch);
}
31 changes: 31 additions & 0 deletions src/extensions/scroll/scrollext_hooks.h
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 (Dawn of the Tiberium Age Build)
*
* @file SCROLLEXT_HOOKS.H
*
* @author Rampastring
*
* @brief Contains the hooks for the extended ScrollClass.
*
* @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 ScrollClassExtension_Hooks();

0 comments on commit 803a0bb

Please sign in to comment.