refactor: allow usage of NiPoint3 and NiQuaternion in constexpr context (#1414)

* allow usage of NiPoint3 and NiQuaternion in constexpr context

* removed .cpp files entirely

* moving circular dependency circumvention stuff to an .inl file

* real world usage!!!!!

* reverting weird branch cross-pollination

* removing more weird branch cross-pollination

* remove comment

* added inverse header guard to inl file

* Update NiPoint3.inl

* trying different constructor syntax

* reorganize into .inl files for readability

* uncomment include

* moved non-constexpr definitions to cpp file

* moved static definitions back to inl files

* testing fix

* moved constants into seperate namespace

* Undo change in build-and-test.yml

* nodiscard
This commit is contained in:
jadebenn
2024-01-29 01:53:12 -06:00
committed by GitHub
parent 2f247b1fc9
commit a0d51e21ca
41 changed files with 509 additions and 533 deletions

View File

@@ -13,13 +13,13 @@ public:
bUsedMouse = false;
fCasterLatency = 0.0f;
iCastType = 0;
lastClickedPosit = NiPoint3::ZERO;
lastClickedPosit = NiPoint3Constant::ZERO;
optionalTargetID = LWOOBJID_EMPTY;
originatorRot = NiQuaternion::IDENTITY;
originatorRot = NiQuaternionConstant::IDENTITY;
uiSkillHandle = 0;
}
EchoStartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternion::IDENTITY, uint32_t _uiSkillHandle = 0) {
EchoStartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternionConstant::IDENTITY, uint32_t _uiSkillHandle = 0) {
bUsedMouse = _bUsedMouse;
fCasterLatency = _fCasterLatency;
iCastType = _iCastType;
@@ -50,16 +50,16 @@ public:
stream->Write(iCastType != 0);
if (iCastType != 0) stream->Write(iCastType);
stream->Write(lastClickedPosit != NiPoint3::ZERO);
if (lastClickedPosit != NiPoint3::ZERO) stream->Write(lastClickedPosit);
stream->Write(lastClickedPosit != NiPoint3Constant::ZERO);
if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit);
stream->Write(optionalOriginatorID);
stream->Write(optionalTargetID != LWOOBJID_EMPTY);
if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID);
stream->Write(originatorRot != NiQuaternion::IDENTITY);
if (originatorRot != NiQuaternion::IDENTITY) stream->Write(originatorRot);
stream->Write(originatorRot != NiQuaternionConstant::IDENTITY);
if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot);
uint32_t sBitStreamLength = sBitStream.length();
stream->Write(sBitStreamLength);

View File

@@ -385,8 +385,8 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd
float fIdleTimeElapsed = 0.0f;
float fMoveTimeElapsed = 0.0f;
float fPercentBetweenPoints = 0.0f;
NiPoint3 ptUnexpectedLocation = NiPoint3::ZERO;
NiQuaternion qUnexpectedRotation = NiQuaternion::IDENTITY;
NiPoint3 ptUnexpectedLocation = NiPoint3Constant::ZERO;
NiQuaternion qUnexpectedRotation = NiQuaternionConstant::IDENTITY;
bitStream.Write(bReverse);
bitStream.Write(bStopAtDesiredWaypoint);
@@ -403,8 +403,8 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd
bitStream.Write(ptUnexpectedLocation.y);
bitStream.Write(ptUnexpectedLocation.z);
bitStream.Write(qUnexpectedRotation != NiQuaternion::IDENTITY);
if (qUnexpectedRotation != NiQuaternion::IDENTITY) {
bitStream.Write(qUnexpectedRotation != NiQuaternionConstant::IDENTITY);
if (qUnexpectedRotation != NiQuaternionConstant::IDENTITY) {
bitStream.Write(qUnexpectedRotation.x);
bitStream.Write(qUnexpectedRotation.y);
bitStream.Write(qUnexpectedRotation.z);
@@ -770,7 +770,7 @@ void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootTyp
bitStream.Write(lootType != LOOTTYPE_NONE);
if (lootType != LOOTTYPE_NONE) bitStream.Write(lootType);
bitStream.Write(NiPoint3::ZERO);
bitStream.Write(NiPoint3Constant::ZERO);
bitStream.Write(sourceLOT != LOT_NULL);
if (sourceLOT != LOT_NULL) bitStream.Write(sourceLOT);
@@ -1079,7 +1079,7 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
entity->RegisterCoinDrop(currency);
}
if (spawnPos != NiPoint3::ZERO) {
if (spawnPos != NiPoint3Constant::ZERO) {
bUsePosition = true;
//Calculate where the loot will go:
@@ -1101,8 +1101,8 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
bitStream.Write(bUsePosition);
bitStream.Write(finalPosition != NiPoint3::ZERO);
if (finalPosition != NiPoint3::ZERO) bitStream.Write(finalPosition);
bitStream.Write(finalPosition != NiPoint3Constant::ZERO);
if (finalPosition != NiPoint3Constant::ZERO) bitStream.Write(finalPosition);
bitStream.Write(currency);
bitStream.Write(item);
@@ -1110,8 +1110,8 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
bitStream.Write(owner);
bitStream.Write(sourceID);
bitStream.Write(spawnPos != NiPoint3::ZERO);
if (spawnPos != NiPoint3::ZERO) bitStream.Write(spawnPos);
bitStream.Write(spawnPos != NiPoint3Constant::ZERO);
if (spawnPos != NiPoint3Constant::ZERO) bitStream.Write(spawnPos);
auto* team = TeamManager::Instance()->GetTeam(owner);
@@ -1170,7 +1170,7 @@ void GameMessages::SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPo
bitStream.Write(position.y);
bitStream.Write(position.z);
const bool bIsNotIdentity = rotation != NiQuaternion::IDENTITY;
const bool bIsNotIdentity = rotation != NiQuaternionConstant::IDENTITY;
bitStream.Write(bIsNotIdentity);
if (bIsNotIdentity) {
@@ -1646,8 +1646,8 @@ void GameMessages::SendNotifyClientShootingGalleryScore(LWOOBJID objectId, const
void GameMessages::HandleUpdateShootingGalleryRotation(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
float angle = 0.0f;
NiPoint3 facing = NiPoint3::ZERO;
NiPoint3 muzzlePos = NiPoint3::ZERO;
NiPoint3 facing = NiPoint3Constant::ZERO;
NiPoint3 muzzlePos = NiPoint3Constant::ZERO;
inStream->Read(angle);
inStream->Read(facing);
inStream->Read(muzzlePos);
@@ -2103,8 +2103,8 @@ void GameMessages::SendPlaceModelResponse(LWOOBJID objectId, const SystemAddress
bitStream.Write(objectId);
bitStream.Write(eGameMessageType::PLACE_MODEL_RESPONSE);
bitStream.Write(position != NiPoint3::ZERO);
if (position != NiPoint3::ZERO) {
bitStream.Write(position != NiPoint3Constant::ZERO);
if (position != NiPoint3Constant::ZERO) {
bitStream.Write(position);
}
@@ -2118,8 +2118,8 @@ void GameMessages::SendPlaceModelResponse(LWOOBJID objectId, const SystemAddress
bitStream.Write(response);
}
bitStream.Write(rotation != NiQuaternion::IDENTITY);
if (rotation != NiQuaternion::IDENTITY) {
bitStream.Write(rotation != NiQuaternionConstant::IDENTITY);
if (rotation != NiQuaternionConstant::IDENTITY) {
bitStream.Write(response);
}
@@ -2271,7 +2271,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit
bool modePaused{};
int modeValue = 1;
LWOOBJID playerId{};
NiPoint3 startPosition = NiPoint3::ZERO;
NiPoint3 startPosition = NiPoint3Constant::ZERO;
inStream->Read(start);
@@ -2290,7 +2290,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit
auto* player = Game::entityManager->GetEntity(playerId);
if (startPosition == NiPoint3::ZERO) {
if (startPosition == NiPoint3Constant::ZERO) {
startPosition = player->GetPosition();
}
@@ -2384,13 +2384,13 @@ void GameMessages::HandlePlacePropertyModel(RakNet::BitStream* inStream, Entity*
inStream->Read(model);
PropertyManagementComponent::Instance()->UpdateModelPosition(model, NiPoint3::ZERO, NiQuaternion::IDENTITY);
PropertyManagementComponent::Instance()->UpdateModelPosition(model, NiPoint3Constant::ZERO, NiQuaternionConstant::IDENTITY);
}
void GameMessages::HandleUpdatePropertyModel(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
LWOOBJID model;
NiPoint3 position;
NiQuaternion rotation = NiQuaternion::IDENTITY;
NiQuaternion rotation = NiQuaternionConstant::IDENTITY;
inStream->Read(model);
inStream->Read(position);
@@ -2612,7 +2612,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
IPropertyContents::Model model;
model.id = newIDL;
model.ugcId = blueprintIDSmall;
model.position = NiPoint3::ZERO;
model.position = NiPoint3Constant::ZERO;
model.rotation = NiQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
model.lot = 14;
Database::Get()->InsertNewPropertyModel(propertyId, model, "Objects_14_name");
@@ -3393,7 +3393,7 @@ void GameMessages::SendNotifyPetTamingMinigame(LWOOBJID objectId, LWOOBJID petId
bitStream.Write(petsDestPos);
bitStream.Write(telePos);
const bool hasDefault = teleRot != NiQuaternion::IDENTITY;
const bool hasDefault = teleRot != NiQuaternionConstant::IDENTITY;
bitStream.Write(hasDefault);
if (hasDefault) bitStream.Write(teleRot);
@@ -4218,7 +4218,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
LWOOBJID pickupObjID = LWOOBJID_EMPTY;
LWOOBJID pickupSpawnerID = LWOOBJID_EMPTY;
int32_t pickupSpawnerIndex = -1;
NiPoint3 vehiclePosition = NiPoint3::ZERO;
NiPoint3 vehiclePosition = NiPoint3Constant::ZERO;
if (inStream->ReadBit()) inStream->Read(pickupObjID);
if (inStream->ReadBit()) inStream->Read(pickupSpawnerID);

View File

@@ -55,14 +55,14 @@ namespace GameMessages {
const SystemAddress& sysAddr,
bool bFirstTime = true,
const LWOOBJID& buildAreaID = LWOOBJID_EMPTY,
NiPoint3 buildStartPOS = NiPoint3::ZERO,
NiPoint3 buildStartPOS = NiPoint3Constant::ZERO,
int sourceBAG = 0,
const LWOOBJID& sourceID = LWOOBJID_EMPTY,
LOT sourceLOT = 0,
int sourceTYPE = 8,
const LWOOBJID& targetID = 0,
LOT targetLOT = 0,
NiPoint3 targetPOS = NiPoint3::ZERO,
NiPoint3 targetPOS = NiPoint3Constant::ZERO,
int targetTYPE = 0
);
@@ -122,7 +122,7 @@ namespace GameMessages {
void SendStop2DAmbientSound(Entity* entity, bool force, std::string audioGUID, bool result = false);
void SendPlay2DAmbientSound(Entity* entity, std::string audioGUID, bool result = false);
void SendSetNetworkScriptVar(Entity* entity, const SystemAddress& sysAddr, std::string data);
void SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, LOT item, int currency, NiPoint3 spawnPos = NiPoint3::ZERO, int count = 1);
void SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID, LOT item, int currency, NiPoint3 spawnPos = NiPoint3Constant::ZERO, int count = 1);
void SendSetPlayerControlScheme(Entity* entity, eControlScheme controlScheme);
void SendPlayerReachedRespawnCheckpoint(Entity* entity, const NiPoint3& position, const NiQuaternion& rotation);
@@ -239,7 +239,7 @@ namespace GameMessages {
void SendLockNodeRotation(Entity* entity, std::string nodeName);
void SendSetBuildModeConfirmed(LWOOBJID objectId, const SystemAddress& sysAddr, bool start, bool warnVisitors, bool modePaused, int32_t modeValue, LWOOBJID playerId, NiPoint3 startPos = NiPoint3::ZERO);
void SendSetBuildModeConfirmed(LWOOBJID objectId, const SystemAddress& sysAddr, bool start, bool warnVisitors, bool modePaused, int32_t modeValue, LWOOBJID playerId, NiPoint3 startPos = NiPoint3Constant::ZERO);
void SendGetModelsOnProperty(LWOOBJID objectId, std::map<LWOOBJID, LWOOBJID> models, const SystemAddress& sysAddr);

View File

@@ -16,13 +16,13 @@ public:
consumableItemID = LWOOBJID_EMPTY;
fCasterLatency = 0.0f;
iCastType = 0;
lastClickedPosit = NiPoint3::ZERO;
lastClickedPosit = NiPoint3Constant::ZERO;
optionalTargetID = LWOOBJID_EMPTY;
originatorRot = NiQuaternion::IDENTITY;
originatorRot = NiQuaternionConstant::IDENTITY;
uiSkillHandle = 0;
}
StartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, LWOOBJID _consumableItemID = LWOOBJID_EMPTY, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternion::IDENTITY, uint32_t _uiSkillHandle = 0) {
StartSkill(LWOOBJID _optionalOriginatorID, std::string _sBitStream, TSkillID _skillID, bool _bUsedMouse = false, LWOOBJID _consumableItemID = LWOOBJID_EMPTY, float _fCasterLatency = 0.0f, int32_t _iCastType = 0, NiPoint3 _lastClickedPosit = NiPoint3Constant::ZERO, LWOOBJID _optionalTargetID = LWOOBJID_EMPTY, NiQuaternion _originatorRot = NiQuaternionConstant::IDENTITY, uint32_t _uiSkillHandle = 0) {
bUsedMouse = _bUsedMouse;
consumableItemID = _consumableItemID;
fCasterLatency = _fCasterLatency;
@@ -57,16 +57,16 @@ public:
stream->Write(iCastType != 0);
if (iCastType != 0) stream->Write(iCastType);
stream->Write(lastClickedPosit != NiPoint3::ZERO);
if (lastClickedPosit != NiPoint3::ZERO) stream->Write(lastClickedPosit);
stream->Write(lastClickedPosit != NiPoint3Constant::ZERO);
if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit);
stream->Write(optionalOriginatorID);
stream->Write(optionalTargetID != LWOOBJID_EMPTY);
if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID);
stream->Write(originatorRot != NiQuaternion::IDENTITY);
if (originatorRot != NiQuaternion::IDENTITY) stream->Write(originatorRot);
stream->Write(originatorRot != NiQuaternionConstant::IDENTITY);
if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot);
uint32_t sBitStreamLength = sBitStream.length();
stream->Write(sBitStreamLength);