From 91f677f0490c8a44b529322f03c2966903e3517a Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Fri, 5 Aug 2016 20:30:33 +0200 Subject: [PATCH] CLIENT: add orientation to npc spawn --- .gitignore | 2 ++ src/client/Client.cpp | 5 ++--- src/client/Client.h | 2 +- src/client/network/EntityUpdateHandler.h | 4 ++-- src/client/network/NpcSpawnHandler.h | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index df2664bc8..b2612eb9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.pyc /build /.project +/.cproject +/.settings /Makefile.local diff --git a/src/client/Client.cpp b/src/client/Client.cpp index bcb60c145..01e8576cd 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -69,7 +69,6 @@ void Client::onMouseMotion(int32_t x, int32_t y, int32_t relX, int32_t relY) { void Client::onEvent(const network::DisconnectEvent& event) { removeState(CLIENT_CONNECTING); - core_assert(!hasState(CLIENT_CONNECTING)); ui::Window* main = new frontend::LoginWindow(this); new frontend::DisconnectWindow(main); } @@ -295,10 +294,10 @@ void Client::entityUpdate(frontend::ClientEntityId id, const glm::vec3& pos, flo entity->lerpPosition(pos, orientation); } -void Client::npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, const glm::vec3& pos) { +void Client::npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, float orientation, const glm::vec3& pos) { Log::info("NPC %li spawned at pos %f:%f:%f (type %i)", id, pos.x, pos.y, pos.z, type); const std::string& meshName = "mesh/chr_skelett2_bake.FBX"; // core::string::toLower(network::messages::EnumNameNpcType(type)); - _worldRenderer.addEntity(std::make_shared(id, type, pos, 0.0f, _meshPool->getMesh(meshName))); + _worldRenderer.addEntity(std::make_shared(id, type, pos, orientation, _meshPool->getMesh(meshName))); } void Client::entityRemove(frontend::ClientEntityId id) { diff --git a/src/client/Client.h b/src/client/Client.h index ed1760250..dab68b199 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -103,7 +103,7 @@ public: void authFailed(); void signup(const std::string& email, const std::string& password); void lostPassword(const std::string& email); - void npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, const glm::vec3& pos); + void npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, float orientation, const glm::vec3& pos); void entityUpdate(frontend::ClientEntityId id, const glm::vec3& pos, float orientation); void entityRemove(frontend::ClientEntityId id); void disconnect(); diff --git a/src/client/network/EntityUpdateHandler.h b/src/client/network/EntityUpdateHandler.h index cc28b06a7..7d78b77ff 100644 --- a/src/client/network/EntityUpdateHandler.h +++ b/src/client/network/EntityUpdateHandler.h @@ -14,6 +14,6 @@ CLIENTPROTOHANDLERIMPL(EntityUpdate) { if (pos == nullptr) { return; } - const glm::vec3 userPos(pos->x(), pos->y(), pos->z()); - client->entityUpdate(message->id(), userPos, message->rotation()); + const glm::vec3 entityPos(pos->x(), pos->y(), pos->z()); + client->entityUpdate(message->id(), entityPos, message->rotation()); } diff --git a/src/client/network/NpcSpawnHandler.h b/src/client/network/NpcSpawnHandler.h index 6accd891c..2ece2e893 100644 --- a/src/client/network/NpcSpawnHandler.h +++ b/src/client/network/NpcSpawnHandler.h @@ -11,5 +11,5 @@ */ CLIENTPROTOHANDLERIMPL(NpcSpawn) { const network::messages::Vec3 *pos = message->pos(); - client->npcSpawn(message->id(), message->type(), glm::vec3(pos->x(), pos->y(), pos->z())); + client->npcSpawn(message->id(), message->type(), message->rotation(), glm::vec3(pos->x(), pos->y(), pos->z())); }