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

@@ -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);