From e31e6707207754ea342dd161aa730fef87da079f Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Wed, 13 Dec 2023 14:06:22 -0500 Subject: [PATCH] Yaya --- SQCSim-common/player.cpp | 4 ++++ SQCSim-common/player.h | 1 + SQCSim-srv/connection.cpp | 10 +++++----- SQCSim2021/engine.cpp | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SQCSim-common/player.cpp b/SQCSim-common/player.cpp index 85df138..845b96f 100644 --- a/SQCSim-common/player.cpp +++ b/SQCSim-common/player.cpp @@ -272,6 +272,10 @@ std::string Player::GetUsername() const { return m_username; } float Player::GetHP() const { return m_hp; } +void Player::SetHP(float hp) { + m_hp = hp; +} + void Player::Teleport(int& x, int& z) { m_position.x -= x * CHUNK_SIZE_X; m_position.z -= z * CHUNK_SIZE_Z; diff --git a/SQCSim-common/player.h b/SQCSim-common/player.h index 6117605..ac2dce6 100644 --- a/SQCSim-common/player.h +++ b/SQCSim-common/player.h @@ -33,6 +33,7 @@ public: Vector3f GetPOV() const; std::string GetUsername() const; float GetHP() const; + void SetHP(float hp); void Teleport(int& x, int& z); bool GetIsAirborne() const; diff --git a/SQCSim-srv/connection.cpp b/SQCSim-srv/connection.cpp index c125974..ce6b02f 100644 --- a/SQCSim-srv/connection.cpp +++ b/SQCSim-srv/connection.cpp @@ -117,10 +117,10 @@ Timestamp Connection::Run(World* world) { if (m_input_manifest.size() < 2) return tstamp; - if (player->AmIDead()) { - m_input_manifest.clear(); - return tstamp; - } + //if (player->AmIDead()) { + // m_input_manifest.clear(); + // return tstamp; + //} while (m_last_in < m_input_vector.size() - 1) { in = m_input_vector.at(m_last_in + 1); @@ -131,7 +131,7 @@ Timestamp Connection::Run(World* world) { if (m_shoot_acc > 0.) { m_shoot_acc -= el; if (m_shoot_acc < 0.) - m_shoot_acc = 0; + m_shoot_acc = 0.; } player->SetDirection(in.direction); diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index db23ef3..44f5fd9 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -618,6 +618,7 @@ bool Engine::StartMultiplayerGame() { //m_world.SetSeed(m_conn.getSeed()); m_world.SetSeed(9370707); m_networkgame = true; + m_player.m_username = m_username; } else { std::cout << "Erreur de connexion." << std::endl; @@ -1513,7 +1514,7 @@ void Engine::Render(float elapsedTime) { std::cout << sync.hp << std::endl; m_otherplayerpos = sync.position; - m_player.InflictDamage(sync.hp - m_player.GetHP()); + m_player.SetHP(sync.hp); Vector3f diff = sync.position - comp.position;