Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper authored and ZivDero committed Jan 22, 2025
1 parent 3196c26 commit 2b2de03
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
49 changes: 42 additions & 7 deletions src/extensions/drivelocomotor/drivelocomotionext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "drivelocomotionext_hooks.h"
#include "drivelocomotion.h"
#include "foot.h"
#include "footext.h"
#include "technotype.h"
#include "technotypeext.h"
#include "cell.h"
Expand All @@ -51,20 +52,52 @@
static void DriveLocomotionClass_Process_Create_WakeAnim(DriveLocomotionClass *this_ptr)
{
FootClass *linked_foot = this_ptr->Linked_To();
FootClassExtension *linked_footext = Extension::Fetch<FootClassExtension>(linked_foot);
TechnoTypeClassExtension *technotype_ext = Extension::Fetch<TechnoTypeClassExtension>(linked_foot->Techno_Type_Class());

/**
* #issue-944
*
* Only spawn the wake animation every 'X' frames, as set by the objects properties.
* x
*/
if (!(Frame % technotype_ext->WakeAnimRate)) {
if (linked_foot->IsOnBridge || linked_foot->Get_Cell_Ptr()->Land_Type() != LAND_WATER) {
return;
}

/**
* x
*/
if (linked_footext->IdleWakeAnim) {

if (!this_ptr->Is_Moving()) {
linked_footext->IdleWakeAnim->Make_Invisible();
} else {
linked_footext->IdleWakeAnim->Make_Visible();
}

} else {

/**
* x
*/
linked_footext->IdleWakeAnim = new AnimClass(technotype_ext->IdleWakeAnim, linked_foot->Get_Coord());
ASSERT(linked_footext->IdleWakeAnim != nullptr);

if (!linked_foot->IsOnBridge && linked_foot->Get_Cell_Ptr()->Land_Type() == LAND_WATER) {
}

/**
* x
*/
if (this_ptr->Is_Moving()) {

/**
* #issue-944
*
* Only spawn the wake animation every 'X' frames, as set by the objects properties.
*/
if (!(Frame % technotype_ext->WakeAnimRate)) {

/**
* #issue-944
*
*
* Fetch the wake animation from the object attached to this
* locomotor, and fall-back to the Rules wake animation if
* one is not defined.
Expand All @@ -78,7 +111,9 @@ static void DriveLocomotionClass_Process_Create_WakeAnim(DriveLocomotionClass *t
AnimClass *animptr = new AnimClass(wake_anim, linked_foot->Get_Coord());
ASSERT(animptr != nullptr);
}

}

}
}

Expand All @@ -105,5 +140,5 @@ DECLARE_PATCH(_DriveLocomotionClass_Process_WakeAnim_Patch)
*/
void DriveLocomotionClassExtension_Hooks()
{
Patch_Jump(0x0047DFE8, &_DriveLocomotionClass_Process_WakeAnim_Patch);
Patch_Jump(0x0047DFDB, &_DriveLocomotionClass_Process_WakeAnim_Patch);
}
8 changes: 7 additions & 1 deletion src/extensions/techno/technoext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ TechnoClassExtension::TechnoClassExtension(const TechnoClass *this_ptr) :
ElectricBolt(nullptr),
Storage(Tiberiums.Count()),
SpawnManager(nullptr),
SpawnOwner(nullptr)
SpawnOwner(nullptr),
IdleWakeAnim(nullptr)
{
//if (this_ptr) EXT_DEBUG_TRACE("TechnoClassExtension::TechnoClassExtension - Name: %s (0x%08X)\n", Name(), (uintptr_t)(This()));

Expand Down Expand Up @@ -108,6 +109,9 @@ TechnoClassExtension::~TechnoClassExtension()
delete SpawnManager;
SpawnManager = nullptr;
}

delete IdleWakeAnim;
IdleWakeAnim = nullptr;
}


Expand All @@ -131,6 +135,8 @@ HRESULT TechnoClassExtension::Load(IStream *pStm)

VINIFERA_SWIZZLE_REQUEST_POINTER_REMAP(SpawnManager, "SpawnManager");
VINIFERA_SWIZZLE_REQUEST_POINTER_REMAP(SpawnOwner, "SpawnOwner");

VINIFERA_SWIZZLE_REQUEST_POINTER_REMAP(IdleWakeAnim, "IdleWakeAnim");

return hr;
}
Expand Down
6 changes: 6 additions & 0 deletions src/extensions/techno/technoext.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SpawnManagerClass;
class EBoltClass;
class TechnoTypeClass;
class TechnoTypeClassExtension;
class AnimClass;


class TechnoClassExtension : public RadioClassExtension
Expand Down Expand Up @@ -92,4 +93,9 @@ class TechnoClassExtension : public RadioClassExtension
* The object that spawned this object.
*/
TechnoClass* SpawnOwner;

/**
* The idle wake animation attached to this object.
*/
AnimClass *IdleWakeAnim;
};
5 changes: 4 additions & 1 deletion src/extensions/technotype/technotypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ TechnoTypeClassExtension::TechnoTypeClassExtension(const TechnoTypeClass *this_p
ForbiddenHouses(-1),
TargetZoneScan(TZST_SAME),
WakeAnim(nullptr),
WakeAnimRate(10) // Default DriveLocomotion value.
WakeAnimRate(10), // Default DriveLocomotion value.
IdleWakeAnim(nullptr)
{
//if (this_ptr) EXT_DEBUG_TRACE("TechnoTypeClassExtension::TechnoTypeClassExtension - Name: %s (0x%08X)\n", Name(), (uintptr_t)(This()));
}
Expand Down Expand Up @@ -140,6 +141,7 @@ HRESULT TechnoTypeClassExtension::Load(IStream *pStm)
VINIFERA_SWIZZLE_REQUEST_POINTER_REMAP(UnloadingClass, "UnloadingClass");
VINIFERA_SWIZZLE_REQUEST_POINTER_REMAP(Spawns, "Spawns");
VINIFERA_SWIZZLE_REQUEST_POINTER_REMAP(WakeAnim, "WakeAnim");
VINIFERA_SWIZZLE_REQUEST_POINTER_REMAP(IdleWakeAnim, "IdleWakeAnim");

/**
* We need to reload the "Cameo" key because TechnoTypeClass does
Expand Down Expand Up @@ -329,6 +331,7 @@ bool TechnoTypeClassExtension::Read_INI(CCINIClass &ini)

WakeAnim = ArtINI.Get_Anim(graphic_name, "WakeAnim", WakeAnim);
WakeAnimRate = ArtINI.Get_Int(graphic_name, "WakeAnimRate", WakeAnimRate);
IdleWakeAnim = ArtINI.Get_Anim(graphic_name, "IdleWakeAnim", IdleWakeAnim);

if (ini.Is_Present(ini_name, "Description"))
ini.Get_String(ini_name, "Description", Description, std::size(Description));
Expand Down
5 changes: 5 additions & 0 deletions src/extensions/technotype/technotypeext.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,9 @@ class TechnoTypeClassExtension : public ObjectTypeClassExtension
* The rate at which this object creates the wake animation while moving.
*/
unsigned WakeAnimRate;

/**
* The wake graphic to show as the object moves across water.
*/
const AnimTypeClass *IdleWakeAnim;
};

0 comments on commit 2b2de03

Please sign in to comment.