From a65c941ad8fdfc0f8ff927bdcdc9aa5d8cb30b9d Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sat, 8 Nov 2025 17:01:21 -0500 Subject: [PATCH] feat: add sendEntityQuery method to request all entities from the server --- src/OverteClient.cpp | 24 ++++++++++++++++++++++++ src/OverteClient.hpp | 1 + 2 files changed, 25 insertions(+) diff --git a/src/OverteClient.cpp b/src/OverteClient.cpp index 3681fb5..f096be3 100644 --- a/src/OverteClient.cpp +++ b/src/OverteClient.cpp @@ -382,6 +382,30 @@ void OverteClient::sendDomainListRequest() { } } +void OverteClient::sendEntityQuery() { + if (m_entityFd < 0) return; + + const unsigned char PACKET_TYPE_ENTITY_QUERY = 0x15; + + // EntityQuery packet structure: + // [PacketType:u8][ConicalViews:bool][CameraPosition:vec3][CameraOrientation:quat][CameraFov:float][CameraAspectRatio:float][CameraNearClip:float][CameraFarClip:float][CameraEyeOffsetPosition:vec3] + // Simplified version: just send packet type + false for conical views (requests all entities) + + unsigned char packet[1 + 1]; // PacketType + ConicalViews flag + packet[0] = PACKET_TYPE_ENTITY_QUERY; + packet[1] = 0; // false - no conical frustum, send all entities + + ssize_t sent = sendto(m_entityFd, packet, sizeof(packet), 0, + reinterpret_cast(&m_entityAddr), m_entityAddrLen); + + if (sent > 0) { + std::cout << "[OverteClient] Sent EntityQuery (all entities)" << std::endl; + m_entityServerReady = true; + } else { + std::cerr << "[OverteClient] Failed to send EntityQuery: " << strerror(errno) << std::endl; + } +} + void OverteClient::sendMovementInput(const glm::vec3& linearVelocity) { (void)linearVelocity; // TODO: send to avatar mixer } diff --git a/src/OverteClient.hpp b/src/OverteClient.hpp index 2e5e207..2383fec 100644 --- a/src/OverteClient.hpp +++ b/src/OverteClient.hpp @@ -51,6 +51,7 @@ private: void parseEntityPacket(const char* data, size_t len); void handleDomainListReply(const char* data, size_t len); void sendDomainListRequest(); + void sendEntityQuery(); std::string m_domainUrl; std::string m_host{"127.0.0.1"};