Skip to content

Commit

Permalink
Revert "Sync AttachArrow events"
Browse files Browse the repository at this point in the history
This reverts commit d665a43.
  • Loading branch information
RobbeBryssinck committed Oct 30, 2021
1 parent e503975 commit ea83570
Show file tree
Hide file tree
Showing 15 changed files with 4 additions and 209 deletions.
10 changes: 0 additions & 10 deletions Code/client/Events/ArrowAttachedEvent.h

This file was deleted.

26 changes: 0 additions & 26 deletions Code/client/Games/Skyrim/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include <Events/HealthChangeEvent.h>
#include <Events/InventoryChangeEvent.h>
#include <Events/ArrowAttachedEvent.h>

#include <World.h>
#include <Services/PapyrusService.h>
Expand Down Expand Up @@ -79,7 +78,6 @@ TP_THIS_FUNCTION(TCharacterConstructor2, Actor*, Actor, uint8_t aUnk);
TP_THIS_FUNCTION(TCharacterDestructor, Actor*, Actor);
TP_THIS_FUNCTION(TAddInventoryItem, void, Actor, TESBoundObject* apItem, BSExtraDataList* apExtraData, uint32_t aCount, TESObjectREFR* apOldOwner);
TP_THIS_FUNCTION(TPickUpItem, void*, Actor, TESObjectREFR* apObject, int32_t aCount, bool aUnk1, float aUnk2);
TP_THIS_FUNCTION(TAttachArrow, void, Actor, void*);

using TGetLocation = TESForm *(TESForm *);
static TGetLocation *FUNC_GetActorLocation;
Expand All @@ -90,7 +88,6 @@ TCharacterDestructor* RealCharacterDestructor;

static TAddInventoryItem* RealAddInventoryItem = nullptr;
static TPickUpItem* RealPickUpItem = nullptr;
static TAttachArrow* RealAttachArrow = nullptr;

Actor* TP_MAKE_THISCALL(HookCharacterConstructor, Actor)
{
Expand Down Expand Up @@ -472,17 +469,6 @@ void Actor::Respawn() noexcept
Reset();
}

/*
void* Actor::GetBiped() const noexcept
{
TP_THIS_FUNCTION(TGetBiped, void*, Actor);
POINTER_SKYRIMSE(TGetBiped, s_getBiped, 0x140693DF0 - 0x140000000);
ThisCall(s_getBiped, this);
}
*/

TP_THIS_FUNCTION(TForceState, void, Actor, const NiPoint3&, float, float, TESObjectCELL*, TESWorldSpace*, bool);
static TForceState* RealForceState = nullptr;

Expand Down Expand Up @@ -608,15 +594,6 @@ void* TP_MAKE_THISCALL(HookPickUpItem, Actor, TESObjectREFR* apObject, int32_t a
return ThisCall(RealPickUpItem, apThis, apObject, aCount, aUnk1, aUnk2);
}

void TP_MAKE_THISCALL(HookAttachArrow, Actor, void* apBiped)
{
const auto pExActor = apThis->GetExtension();
if (pExActor->IsLocal())
World::Get().GetRunner().Trigger(ArrowAttachedEvent(apThis->formID));

ThisCall(RealAttachArrow, apThis, apBiped);
}

static TiltedPhoques::Initializer s_actorHooks([]()
{
POINTER_SKYRIMSE(TCharacterConstructor, s_characterCtor, 0x1406928C0 - 0x140000000);
Expand All @@ -630,7 +607,6 @@ static TiltedPhoques::Initializer s_actorHooks([]()
POINTER_SKYRIMSE(TRegenAttributes, s_regenAttributes, 0x140620900 - 0x140000000);
POINTER_SKYRIMSE(TAddInventoryItem, s_addInventoryItem, 0x1405E6F20 - 0x140000000);
POINTER_SKYRIMSE(TPickUpItem, s_pickUpItem, 0x1405E6580 - 0x140000000);
POINTER_SKYRIMSE(TAttachArrow, s_attachArrow, 0x140624090 - 0x140000000);

FUNC_GetActorLocation = s_GetActorLocation.Get();
RealCharacterConstructor = s_characterCtor.Get();
Expand All @@ -642,7 +618,6 @@ static TiltedPhoques::Initializer s_actorHooks([]()
RealRegenAttributes = s_regenAttributes.Get();
RealAddInventoryItem = s_addInventoryItem.Get();
RealPickUpItem = s_pickUpItem.Get();
RealAttachArrow = s_attachArrow.Get();

TP_HOOK(&RealCharacterConstructor, HookCharacterConstructor);
TP_HOOK(&RealCharacterConstructor2, HookCharacterConstructor2);
Expand All @@ -653,6 +628,5 @@ static TiltedPhoques::Initializer s_actorHooks([]()
TP_HOOK(&RealRegenAttributes, HookRegenAttributes);
TP_HOOK(&RealAddInventoryItem, HookAddInventoryItem);
TP_HOOK(&RealPickUpItem, HookPickUpItem);
TP_HOOK(&RealAttachArrow, HookAttachArrow);

});
5 changes: 1 addition & 4 deletions Code/client/Games/Skyrim/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct Actor : TESObjectREFR
virtual void sub_CA();
virtual void sub_CB();
virtual void sub_CC();
virtual void AttachArrow(void* apBiped);
virtual void AttachArrow();
virtual void sub_CE();
virtual void sub_CF();
virtual void sub_D0();
Expand Down Expand Up @@ -171,9 +171,6 @@ struct Actor : TESObjectREFR
virtual void sub_125();
virtual void sub_126();
virtual void sub_127();

// Should be virtual
//void* GetBiped() const noexcept;

// Real functions
void DualCastSpell(TESObjectREFR* apDesiredTarget);
Expand Down
2 changes: 1 addition & 1 deletion Code/client/Games/Skyrim/TESObjectREFR.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct TESObjectREFR : TESForm
virtual void sub_7C();
virtual void sub_7D();
virtual void* sub_7E(bool aUnk);
virtual void* GetBiped();
virtual void sub_7F();
virtual void sub_80();
virtual void sub_81();
virtual void sub_82();
Expand Down
6 changes: 0 additions & 6 deletions Code/client/Services/CharacterService.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ struct NotifySpawnData;
struct NotifyOwnershipTransfer;
struct SpellCastEvent;
struct NotifySpellCast;
struct ArrowAttachedEvent;
struct NotifyAttachArrow;
struct ProjectileLaunchedEvent;
struct NotifyProjectileLaunch;

Expand Down Expand Up @@ -48,8 +46,6 @@ struct CharacterService
void OnRemoteSpawnDataReceived(const NotifySpawnData& acEvent) const noexcept;
void OnSpellCastEvent(const SpellCastEvent& acSpellCastEvent) const noexcept;
void OnNotifySpellCast(const NotifySpellCast& acMessage) const noexcept;
void OnArrowAttachedEvent(const ArrowAttachedEvent& acEvent) const noexcept;
void OnNotifyAttachArrow(const NotifyAttachArrow& acMessage) const noexcept;
void OnProjectileLaunchedEvent(const ProjectileLaunchedEvent& acEvent) const noexcept;
void OnNotifyProjectileLaunch(const NotifyProjectileLaunch& acMessage) const noexcept;

Expand Down Expand Up @@ -84,8 +80,6 @@ struct CharacterService
entt::scoped_connection m_remoteSpawnDataReceivedConnection;
entt::scoped_connection m_spellCastEventConnection;
entt::scoped_connection m_notifySpellCastConnection;
entt::scoped_connection m_arrowAttachedEvent;
entt::scoped_connection m_notifyAttachArrowConnection;
entt::scoped_connection m_projectileLaunchedConnection;
entt::scoped_connection m_projectileLaunchConnection;
};
64 changes: 0 additions & 64 deletions Code/client/Services/Generic/CharacterService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <Events/EquipmentChangeEvent.h>
#include <Events/UpdateEvent.h>
#include <Events/SpellCastEvent.h>
#include <Events/ArrowAttachedEvent.h>
#include <Events/ProjectileLaunchedEvent.h>

#include <Structs/ActionEvent.h>
Expand All @@ -52,8 +51,6 @@
#include <Messages/RequestOwnershipClaim.h>
#include <Messages/SpellCastRequest.h>
#include <Messages/NotifySpellCast.h>
#include <Messages/AttachArrowRequest.h>
#include <Messages/NotifyAttachArrow.h>
#include <Messages/ProjectileLaunchRequest.h>
#include <Messages/NotifyProjectileLaunch.h>

Expand Down Expand Up @@ -88,8 +85,6 @@ CharacterService::CharacterService(World& aWorld, entt::dispatcher& aDispatcher,
m_remoteSpawnDataReceivedConnection = m_dispatcher.sink<NotifySpawnData>().connect<&CharacterService::OnRemoteSpawnDataReceived>(this);
m_spellCastEventConnection = m_dispatcher.sink<SpellCastEvent>().connect<&CharacterService::OnSpellCastEvent>(this);
m_notifySpellCastConnection = m_dispatcher.sink<NotifySpellCast>().connect<&CharacterService::OnNotifySpellCast>(this);
m_arrowAttachedEvent = m_dispatcher.sink<ArrowAttachedEvent>().connect<&CharacterService::OnArrowAttachedEvent>(this);
m_notifyAttachArrowConnection = m_dispatcher.sink<NotifyAttachArrow>().connect<&CharacterService::OnNotifyAttachArrow>(this);
m_projectileLaunchedConnection = m_dispatcher.sink<ProjectileLaunchedEvent>().connect<&CharacterService::OnProjectileLaunchedEvent>(this);
m_projectileLaunchConnection = m_dispatcher.sink<NotifyProjectileLaunch>().connect<&CharacterService::OnNotifyProjectileLaunch>(this);
}
Expand Down Expand Up @@ -1077,65 +1072,6 @@ void CharacterService::OnNotifySpellCast(const NotifySpellCast& acMessage) const
#endif
}

void CharacterService::OnArrowAttachedEvent(const ArrowAttachedEvent& acEvent) const noexcept
{
#if TP_SKYRIM64
return;

/*
uint32_t formId = acEvent.FormID;
auto view = m_world.view<FormIdComponent, LocalComponent>();
const auto shooterEntityIt = std::find_if(std::begin(view), std::end(view), [formId, view](entt::entity entity)
{
return view.get<FormIdComponent>(entity).Id == formId;
});
if (shooterEntityIt == std::end(view))
return;
auto& localComponent = view.get<LocalComponent>(*shooterEntityIt);
AttachArrowRequest request;
request.ShooterId = localComponent.Id;
spdlog::info("Sending attach arrow request for {:X}", localComponent.Id);
m_transport.Send(request);
*/
#endif
}

void CharacterService::OnNotifyAttachArrow(const NotifyAttachArrow& acMessage) const noexcept
{
#if TP_SKYRIM64
auto remoteView = m_world.view<RemoteComponent, FormIdComponent>();
const auto remoteIt = std::find_if(std::begin(remoteView), std::end(remoteView), [remoteView, Id = acMessage.ShooterId](auto entity)
{
return remoteView.get<RemoteComponent>(entity).Id == Id;
});

if (remoteIt == std::end(remoteView))
{
spdlog::warn("Shooter with remote id {:X} not found.", acMessage.ShooterId);
return;
}

auto formIdComponent = remoteView.get<FormIdComponent>(*remoteIt);

auto* pForm = TESForm::GetById(formIdComponent.Id);
auto* pActor = RTTI_CAST(pForm, TESForm, Actor);

void* pBiped = pActor->GetBiped();
pActor->AttachArrow(pBiped);

// TODO: set attack state flags when attaching arrow? look at ArrowAttachHandler
pActor->actorState.flags1 &= 0xFFFFFFFu;
pActor->actorState.flags1 |= 0x90000000;

spdlog::info("Attached arrow");
#endif
}

void CharacterService::OnProjectileLaunchedEvent(const ProjectileLaunchedEvent& acEvent) const noexcept
{
Expand Down
13 changes: 0 additions & 13 deletions Code/encoding/Messages/AttachArrowRequest.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions Code/encoding/Messages/AttachArrowRequest.h

This file was deleted.

3 changes: 1 addition & 2 deletions Code/encoding/Messages/ClientMessageFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <Messages/RequestOwnershipClaim.h>
#include <Messages/RequestObjectInventoryChanges.h>
#include <Messages/SpellCastRequest.h>
#include <Messages/AttachArrowRequest.h>
#include <Messages/ProjectileLaunchRequest.h>

using TiltedPhoques::UniquePtr;
Expand All @@ -48,7 +47,7 @@ struct ClientMessageFactory
RequestActorValueChanges, RequestActorMaxValueChanges, EnterExteriorCellRequest,
RequestHealthChangeBroadcast, RequestSpawnData, ActivateRequest, LockChangeRequest,
AssignObjectsRequest, RequestDeathStateChange, ShiftGridCellRequest, RequestOwnershipTransfer,
RequestOwnershipClaim, RequestObjectInventoryChanges, SpellCastRequest, AttachArrowRequest, ProjectileLaunchRequest>;
RequestOwnershipClaim, RequestObjectInventoryChanges, SpellCastRequest, ProjectileLaunchRequest>;

return s_visitor(std::forward<T>(func));
}
Expand Down
13 changes: 0 additions & 13 deletions Code/encoding/Messages/NotifyAttachArrow.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions Code/encoding/Messages/NotifyAttachArrow.h

This file was deleted.

3 changes: 1 addition & 2 deletions Code/encoding/Messages/ServerMessageFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <Messages/NotifyOwnershipTransfer.h>
#include <Messages/NotifyObjectInventoryChanges.h>
#include <Messages/NotifySpellCast.h>
#include <Messages/NotifyAttachArrow.h>
#include <Messages/NotifyProjectileLaunch.h>

using TiltedPhoques::UniquePtr;
Expand All @@ -46,7 +45,7 @@ struct ServerMessageFactory
NotifyPartyInfo, NotifyPartyInvite, NotifyActorValueChanges,
NotifyActorMaxValueChanges, NotifyHealthChangeBroadcast, NotifySpawnData, NotifyActivate,
NotifyLockChange, AssignObjectsResponse, NotifyDeathStateChange, NotifyOwnershipTransfer,
NotifyObjectInventoryChanges, NotifySpellCast, NotifyAttachArrow, NotifyProjectileLaunch>;
NotifyObjectInventoryChanges, NotifySpellCast, NotifyProjectileLaunch>;

return s_visitor(std::forward<T>(func));
}
Expand Down
2 changes: 0 additions & 2 deletions Code/encoding/Opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ enum ClientOpcode : unsigned char
kRequestObjectInventoryChanges,
kRequestCharacterInventoryChanges,
kSpellCastRequest,
kAttachArrowRequest,
kProjectileLaunchRequest,
kClientOpcodeMax
};
Expand Down Expand Up @@ -61,7 +60,6 @@ enum ServerOpcode : unsigned char
kNotifyObjectInventoryChanges,
kNotifyCharacterInventoryChanges,
kNotifySpellCast,
kNotifyAttachArrow,
kNotifyProjectileLaunch,
kServerOpcodeMax
};
Loading

0 comments on commit ea83570

Please sign in to comment.