diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index e0a76f67..6248bfe9 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -402,10 +402,10 @@ void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) { void PhantomPhysicsComponent::SpawnVertices() { if (!m_dpEntity) return; - std::cout << m_Parent->GetObjectID() << std::endl; + LOG("%llu", m_Parent->GetObjectID()); auto box = static_cast(m_dpEntity->GetShape()); for (auto vert : box->GetVertices()) { - std::cout << vert.x << ", " << vert.y << ", " << vert.z << std::endl; + LOG("%f, %f, %f", vert.x, vert.y, vert.z); EntityInfo info; info.lot = 33; diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 9a50a746..40293fbe 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -244,13 +244,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System case eGameMessageType::REQUEST_RESURRECT: { GameMessages::SendResurrect(entity); - /*auto* dest = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); - if (dest) { - dest->SetHealth(4); - dest->SetArmor(0); - dest->SetImagination(6); - Game::entityManager->SerializeEntity(entity); - }*/ break; } case eGameMessageType::GET_HOT_PROPERTY_DATA: { @@ -339,11 +332,8 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System RakNet::BitStream bitStreamLocal; BitStreamUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); bitStreamLocal.Write(entity->GetObjectID()); - //bitStreamLocal.Write((unsigned short)eGameMessageType::ECHO_SYNC_SKILL); - //bitStreamLocal.Write(inStream); SyncSkill sync = SyncSkill(inStream); // inStream replaced &bitStream - //sync.Serialize(&bitStreamLocal); ostringstream buffer; @@ -353,8 +343,6 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System buffer << setw(2) << hex << setfill('0') << (int)s << " "; } - //cout << buffer.str() << endl; - if (usr != nullptr) { RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)sync.sBitStream.c_str(), sync.sBitStream.size(), false); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 71f0e38b..f4a21cab 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1372,7 +1372,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit ChatPackets::SendSystemMessage(sysAddr, u"<" + (GeneralUtils::to_u16string(position.x)) + u", " + (GeneralUtils::to_u16string(position.y)) + u", " + (GeneralUtils::to_u16string(position.z)) + u">"); - std::cout << position.x << ", " << position.y << ", " << position.z << std::endl; + LOG("Position: %f, %f, %f", position.x, position.y, position.z); } if (chatCommand == "rot" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { @@ -1380,14 +1380,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit ChatPackets::SendSystemMessage(sysAddr, u"<" + (GeneralUtils::to_u16string(rotation.w)) + u", " + (GeneralUtils::to_u16string(rotation.x)) + u", " + (GeneralUtils::to_u16string(rotation.y)) + u", " + (GeneralUtils::to_u16string(rotation.z)) + u">"); - std::cout << rotation.w << ", " << rotation.x << ", " << rotation.y << ", " << rotation.z << std::endl; + LOG("Rotation: %f, %f, %f, %f", rotation.w, rotation.x, rotation.y, rotation.z); } if (chatCommand == "locrow" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { const auto position = entity->GetPosition(); const auto rotation = entity->GetRotation(); - std::cout << "" << std::endl; + LOG("", position.x, position.y, position.z, rotation.w, rotation.x, rotation.y, rotation.z); } if (chatCommand == "playlvlfx" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) { @@ -1652,7 +1652,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit auto sphere = static_cast(prox.second->GetShape()); auto pos = prox.second->GetPosition(); - std::cout << prox.first << ", r: " << sphere->GetRadius() << ", pos: " << pos.x << "," << pos.y << "," << pos.z << std::endl; + LOG("Proximity: %s, r: %f, pos: %f, %f, %f", prox.first.c_str(), sphere->GetRadius(), pos.x, pos.y, pos.z); } } } diff --git a/dPhysics/dpEntity.cpp b/dPhysics/dpEntity.cpp index c7ed56f8..70bddb40 100644 --- a/dPhysics/dpEntity.cpp +++ b/dPhysics/dpEntity.cpp @@ -22,7 +22,7 @@ dpEntity::dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStati break; default: - std::cout << "No shape for shapeType: " << (int)shapeType << std::endl; + LOG("No shape for shapeType: %d", static_cast(shapeType)); } } @@ -83,15 +83,9 @@ void dpEntity::CheckCollision(dpEntity* other) { if (isColliding && !wasFound) { m_CurrentlyCollidingObjects.emplace(other->GetObjectID(), other); m_NewObjects.push_back(other); - - //if (m_CollisionShape->GetShapeType() == dpShapeType::Sphere && other->GetShape()->GetShapeType() == dpShapeType::Sphere) - //std::cout << "started sphere col at: " << other->GetPosition().x << ", " << other->GetPosition().y << ", " << other->GetPosition().z << std::endl; } else if (!isColliding && wasFound) { m_CurrentlyCollidingObjects.erase(other->GetObjectID()); m_RemovedObjects.push_back(other); - - //if (m_CollisionShape->GetShapeType() == dpShapeType::Sphere && other->GetShape()->GetShapeType() == dpShapeType::Sphere) - // std::cout << "stopped sphere col at: " << other->GetPosition().x << ", " << other->GetPosition().y << ", " << other->GetPosition().z << std::endl; } } diff --git a/dPhysics/dpGrid.cpp b/dPhysics/dpGrid.cpp index c3259b51..1704e068 100644 --- a/dPhysics/dpGrid.cpp +++ b/dPhysics/dpGrid.cpp @@ -8,8 +8,6 @@ dpGrid::dpGrid(int numCells, int cellSize) { CELL_SIZE = cellSize; m_DeleteGrid = true; - //dumb method but i can't be bothered - //fill x for (int i = 0; i < NUM_CELLS; i++) { m_Cells.push_back(std::vector>()); diff --git a/dPhysics/dpShapeBase.cpp b/dPhysics/dpShapeBase.cpp index 54575159..29f5d789 100644 --- a/dPhysics/dpShapeBase.cpp +++ b/dPhysics/dpShapeBase.cpp @@ -10,7 +10,7 @@ dpShapeBase::~dpShapeBase() { } bool dpShapeBase::IsColliding(dpShapeBase* other) { - std::cout << "Base shapes do not have any *shape* to them, and thus cannot be overlapping." << std::endl; - std::cout << "You should be using a shape class inherited from this base class." << std::endl; + LOG("Base shapes do not have any *shape* to them, and thus cannot be overlapping."); + LOG("You should be using a shape class inherited from this base class."); return false; } diff --git a/dPhysics/dpShapeBox.cpp b/dPhysics/dpShapeBox.cpp index b40be6af..bfd72dea 100644 --- a/dPhysics/dpShapeBox.cpp +++ b/dPhysics/dpShapeBox.cpp @@ -34,7 +34,7 @@ bool dpShapeBox::IsColliding(dpShapeBase* other) { return dpCollisionChecks::CheckBoxes(m_ParentEntity, other->GetParentEntity()); default: - std::cout << "No collision detection for: " << (int)m_ShapeType << "-to-" << (int)other->GetShapeType() << " collision!" << std::endl; + LOG("No collision detection for: %i-to-%i collision!", static_cast(m_ShapeType), static_cast(other->GetShapeType())); } return false; @@ -72,10 +72,7 @@ void dpShapeBox::SetScale(float scale) { m_Height *= scale; m_Depth *= scale; - //fuuuckkk yoouu InitVertices(); - - //SetRotation(m_ParentEntity->GetRotation()); } void dpShapeBox::SetRotation(const NiQuaternion& rotation) { diff --git a/dPhysics/dpShapeSphere.cpp b/dPhysics/dpShapeSphere.cpp index 168a3b21..545d58ed 100644 --- a/dPhysics/dpShapeSphere.cpp +++ b/dPhysics/dpShapeSphere.cpp @@ -1,5 +1,7 @@ #include "dpShapeSphere.h" #include "dpCollisionChecks.h" +#include "Game.h" +#include "Logger.h" #include dpShapeSphere::dpShapeSphere(dpEntity* parentEntity, float radius) : @@ -22,7 +24,7 @@ bool dpShapeSphere::IsColliding(dpShapeBase* other) { return dpCollisionChecks::CheckSphereBox(m_ParentEntity, other->GetParentEntity()); default: - std::cout << "No collision detection for: " << (int)m_ShapeType << "-to-" << (int)other->GetShapeType() << " collision!" << std::endl; + LOG("No collision detection for: %i-to-%i collision!", static_cast(m_ShapeType), static_cast(other->GetShapeType())); } return false; diff --git a/dPhysics/main.cpp b/dPhysics/main.cpp deleted file mode 100644 index 7de1555a..00000000 --- a/dPhysics/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//This file included for reference only - -/*#include -#include -#include -#include "dpWorld.h" - -#include "NiQuaternion.hpp" -#include "NiPoint3.hpp" - -int main() { - std::cout << "dPhysics test engine" << std::endl; - - //Test rotation code: - NiPoint3 p(1.0f, 0.0f, 0.0f); - - float angle = 45.0f; - NiQuaternion q = NiQuaternion::CreateFromAxisAngle(NiPoint3(0.0f, 0.0f, 1.0f), angle); - - NiPoint3 rotated = p.RotateByQuaternion(q); - - std::cout << "OG: " << p.x << ", " << p.y << ", " << p.z << std::endl; - std::cout << "Quater: " << q.x << ", " << q.y << ", " << q.z << ", " << q.w << " angle: " << angle << std::endl; - std::cout << "Rotated: " << rotated.x << ", " << rotated.y << ", " << rotated.z << std::endl; - - //Test some collisions: - dpWorld::GetInstance().Initialize(1000); - - while (true) { - dpWorld::GetInstance().StepWorld(1.0f/60.0f); - std::this_thread::sleep_for(std::chrono::milliseconds(16)); - } - - return 0; -}*/ diff --git a/dZoneManager/Level.cpp b/dZoneManager/Level.cpp index 8202b760..4c6ff93c 100644 --- a/dZoneManager/Level.cpp +++ b/dZoneManager/Level.cpp @@ -16,6 +16,12 @@ #include "AssetManager.h" #include "dConfig.h" +void Level::SceneObjectDataChunk::PrintAllObjects() const { + for (const auto& [id, sceneObj] : objects) { + LOG("ID: %d LOT: %d", id, sceneObj.lot); + } +} + Level::Level(Zone* parentZone, const std::string& filepath) { m_ParentZone = parentZone; @@ -33,9 +39,9 @@ Level::Level(Zone* parentZone, const std::string& filepath) { } Level::~Level() { - for (std::map::iterator it = m_ChunkHeaders.begin(); it != m_ChunkHeaders.end(); ++it) { - if (it->second.id == Level::ChunkTypeID::FileInfo) delete it->second.fileInfo; - if (it->second.id == Level::ChunkTypeID::SceneObjectData) delete it->second.sceneObjects; + for (auto& [id, header] : m_ChunkHeaders) { + if (header.id == Level::ChunkTypeID::FileInfo) delete header.fileInfo; + if (header.id == Level::ChunkTypeID::SceneObjectData) delete header.sceneObjects; } } @@ -248,8 +254,8 @@ void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) { BinaryIO::BinaryRead(file, obj.id); BinaryIO::BinaryRead(file, obj.lot); - /*if (header.fileInfo->version >= 0x26)*/ BinaryIO::BinaryRead(file, obj.value1); - /*if (header.fileInfo->version >= 0x20)*/ BinaryIO::BinaryRead(file, obj.value2); + /*if (header.fileInfo->version >= 0x26)*/ BinaryIO::BinaryRead(file, obj.nodeType); + /*if (header.fileInfo->version >= 0x20)*/ BinaryIO::BinaryRead(file, obj.glomId); BinaryIO::BinaryRead(file, obj.position); BinaryIO::BinaryRead(file, obj.rotation); diff --git a/dZoneManager/Level.h b/dZoneManager/Level.h index a27326a2..6f56e073 100644 --- a/dZoneManager/Level.h +++ b/dZoneManager/Level.h @@ -30,11 +30,7 @@ public: struct SceneObjectDataChunk { std::map objects; - const void PrintAllObjects() { - for (std::map::iterator it = objects.begin(); it != objects.end(); ++it) { - std::cout << "\t ID: " << it->first << " LOT: " << it->second.lot << std::endl; - } - } + void PrintAllObjects() const; uint32_t GetObjectCount() { return objects.size(); } }; diff --git a/dZoneManager/Zone.h b/dZoneManager/Zone.h index af9f6b55..ff931154 100644 --- a/dZoneManager/Zone.h +++ b/dZoneManager/Zone.h @@ -148,6 +148,8 @@ struct PropertyPath { float repMultiplier; PropertyRentalPeriod rentalPeriod; PropertyAchievmentRequired achievementRequired; + + // Player respawn coordinates in the main zone (not the property zone) NiPoint3 playerZoneCoords; float maxBuildHeight; }; diff --git a/dZoneManager/dZMCommon.h b/dZoneManager/dZMCommon.h index 635faaae..738fc283 100644 --- a/dZoneManager/dZMCommon.h +++ b/dZoneManager/dZMCommon.h @@ -12,8 +12,8 @@ struct mapCompareLwoSceneIDs { struct SceneObject { LWOOBJID id; LOT lot; - uint32_t value1; - uint32_t value2; + uint32_t nodeType; + uint32_t glomId; NiPoint3 position; NiQuaternion rotation; float scale = 1.0f; diff --git a/tests/dCommonTests/Amf3Tests.cpp b/tests/dCommonTests/Amf3Tests.cpp index a51fe4ba..5b52cf27 100644 --- a/tests/dCommonTests/Amf3Tests.cpp +++ b/tests/dCommonTests/Amf3Tests.cpp @@ -71,25 +71,15 @@ TEST(dCommonTests, AMF3InsertionAssociativeTest) { array.Insert>("Undefined", {}); array.Insert("Null", nullptr); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get("CString")->GetValueType(), eAmf::String); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get("String")->GetValueType(), eAmf::String); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get("False")->GetValueType(), eAmf::False); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get("True")->GetValueType(), eAmf::True); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get("Integer")->GetValueType(), eAmf::Integer); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get("Double")->GetValueType(), eAmf::Double); - std::cout << "test" << std::endl; ASSERT_EQ(array.GetArray("Array")->GetValueType(), eAmf::Array); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get("Null")->GetValueType(), eAmf::Null); - std::cout << "test" << std::endl; ASSERT_EQ(array.Get>("Undefined")->GetValueType(), eAmf::Undefined); - std::cout << "test" << std::endl; } TEST(dCommonTests, AMF3InsertionDenseTest) {