Skip to content

Commit

Permalink
make behavior slot use a real type
Browse files Browse the repository at this point in the history
  • Loading branch information
aronwk-aaron committed Oct 9, 2023
1 parent 678eece commit 8273ac5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dGame/dBehaviors/BehaviorSlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#ifndef BEHAVIORSLOT_H
#define BEHAVIORSLOT_H
#include <cstdint>

enum class BehaviorSlot
{
enum class BehaviorSlot : int32_t {
Invalid = -1,
Primary,
Offhand,
Expand Down
6 changes: 3 additions & 3 deletions dGame/dComponents/InventoryComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) {
if (slot == BehaviorSlot::Primary) {
m_Skills.insert_or_assign(BehaviorSlot::Primary, 1);

GameMessages::SendAddSkill(m_Parent, 1, static_cast<int>(BehaviorSlot::Primary));
GameMessages::SendAddSkill(m_Parent, 1, BehaviorSlot::Primary);
}
}

Expand Down Expand Up @@ -1617,7 +1617,7 @@ void InventoryComponent::UpdatePetXml(tinyxml2::XMLDocument* document) {
}


bool InventoryComponent::SetSkill(int slot, uint32_t skillId){
bool InventoryComponent::SetSkill(int32_t slot, uint32_t skillId){
BehaviorSlot behaviorSlot = BehaviorSlot::Invalid;
if (slot == 1 ) behaviorSlot = BehaviorSlot::Primary;
else if (slot == 2 ) behaviorSlot = BehaviorSlot::Offhand;
Expand All @@ -1636,7 +1636,7 @@ bool InventoryComponent::SetSkill(BehaviorSlot slot, uint32_t skillId){
GameMessages::SendRemoveSkill(m_Parent, old);
}

GameMessages::SendAddSkill(m_Parent, skillId, static_cast<int>(slot));
GameMessages::SendAddSkill(m_Parent, skillId, slot);
m_Skills.insert_or_assign(slot, skillId);
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo
SEND_PACKET;
}

void GameMessages::SendAddSkill(Entity* entity, TSkillID skillID, int slotID) {
void GameMessages::SendAddSkill(Entity* entity, TSkillID skillID, BehaviorSlot slotID) {
int AICombatWeight = 0;
bool bFromSkillSet = false;
int castType = 0;
Expand Down Expand Up @@ -1195,8 +1195,8 @@ void GameMessages::SendAddSkill(Entity* entity, TSkillID skillID, int slotID) {

bitStream.Write(skillID);

bitStream.Write(slotID != -1);
if (slotID != -1) bitStream.Write(slotID);
bitStream.Write(slotID != BehaviorSlot::Invalid);
if (slotID != BehaviorSlot::Invalid) bitStream.Write(slotID);

bitStream.Write(temporary);

Expand Down
3 changes: 2 additions & 1 deletion dGame/dGameMessages/GameMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum class ePetTamingNotifyType : uint32_t;
enum class eUseItemResponse : uint32_t;
enum class eQuickBuildFailReason : uint32_t;
enum class eRebuildState : uint32_t;
enum class BehaviorSlot : int32_t;

namespace GameMessages {
class PropertyDataMessage;
Expand Down Expand Up @@ -119,7 +120,7 @@ namespace GameMessages {
void SendSetPlayerControlScheme(Entity* entity, eControlScheme controlScheme);
void SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPoint3& position, const NiQuaternion& rotation);

void SendAddSkill(Entity* entity, TSkillID skillID, int slotID);
void SendAddSkill(Entity* entity, TSkillID skillID, BehaviorSlot slotID);
void SendRemoveSkill(Entity* entity, TSkillID skillID);

void SendFinishArrangingWithItem(Entity* entity, const LWOOBJID& buildAreaID);
Expand Down

0 comments on commit 8273ac5

Please sign in to comment.