조작이 둔할 때가 생기는데 뭘까?
This commit is contained in:
@@ -57,6 +57,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
|||||||
|
|
||||||
if (!w_laststate) {
|
if (!w_laststate) {
|
||||||
player->needsUpdate = true;
|
player->needsUpdate = true;
|
||||||
|
player->updateRedundantCount = 0;
|
||||||
w_laststate = true;
|
w_laststate = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -64,6 +65,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
|||||||
player_flame->visible = false;
|
player_flame->visible = false;
|
||||||
if (w_laststate) {
|
if (w_laststate) {
|
||||||
player->needsUpdate = true;
|
player->needsUpdate = true;
|
||||||
|
player->updateRedundantCount = 0;
|
||||||
w_laststate = false;
|
w_laststate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,6 +118,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
|||||||
player->angular_velocity = right * 6.f;
|
player->angular_velocity = right * 6.f;
|
||||||
if (!ad_laststate) {
|
if (!ad_laststate) {
|
||||||
player->needsUpdate = true;
|
player->needsUpdate = true;
|
||||||
|
player->updateRedundantCount = 0;
|
||||||
ad_laststate = true;
|
ad_laststate = true;
|
||||||
}
|
}
|
||||||
} else if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(),
|
} else if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(),
|
||||||
@@ -124,6 +127,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
|||||||
player->angular_velocity = right * -6.f;
|
player->angular_velocity = right * -6.f;
|
||||||
if (!ad_laststate) {
|
if (!ad_laststate) {
|
||||||
player->needsUpdate = true;
|
player->needsUpdate = true;
|
||||||
|
player->updateRedundantCount = 0;
|
||||||
ad_laststate = true;
|
ad_laststate = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -131,6 +135,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
|||||||
player->angular_velocity = right * 0.f;
|
player->angular_velocity = right * 0.f;
|
||||||
if (ad_laststate) {
|
if (ad_laststate) {
|
||||||
player->needsUpdate = true;
|
player->needsUpdate = true;
|
||||||
|
player->updateRedundantCount = 0;
|
||||||
ad_laststate = false;
|
ad_laststate = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
|
|
||||||
#define LISTENIP "::"
|
#define LISTENIP "::"
|
||||||
#define LISTENPORT 9010
|
#define LISTENPORT 9010
|
||||||
|
#define TICKRATE 60
|
||||||
|
constexpr double TICKDELAY = (1 / TICKRATE);
|
||||||
|
|
||||||
std::uint8_t CLIENTID = 0;
|
std::uint8_t CLIENTID = 0;
|
||||||
|
|
||||||
std::unordered_map<utils::Snowflake, veng::Model> MODELS;
|
std::unordered_map<utils::Snowflake, veng::Model> MODELS;
|
||||||
@@ -59,7 +62,7 @@ void ClientRefresher(utils::ThreadPool* tp, Network::IOCP* iocp) {
|
|||||||
static double last_frame_time_;
|
static double last_frame_time_;
|
||||||
auto current_time = glfwGetTime();
|
auto current_time = glfwGetTime();
|
||||||
bool needs_all_update = false;
|
bool needs_all_update = false;
|
||||||
if (current_time - last_all_updated >= .01f) {
|
if (current_time - last_all_updated >= TICKDELAY) {
|
||||||
needs_all_update = true;
|
needs_all_update = true;
|
||||||
last_all_updated = glfwGetTime();
|
last_all_updated = glfwGetTime();
|
||||||
}
|
}
|
||||||
@@ -100,12 +103,12 @@ void ClientRefresher(utils::ThreadPool* tp, Network::IOCP* iocp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CLIENTS_MUTEX.lock();
|
CLIENTS_MUTEX.lock();
|
||||||
for (auto& client : CLIENTS) {
|
for (auto& model : MODELS) {
|
||||||
if (client->sock == 0) continue;
|
if (model.second.name == "camera_lag") continue;
|
||||||
for (auto& model : MODELS) {
|
model.second.Update(delta_time);
|
||||||
if (model.second.name == "camera_lag") continue;
|
for (auto& client : CLIENTS) {
|
||||||
|
if (client->sock == 0) continue;
|
||||||
std::vector<char> send_data;
|
std::vector<char> send_data;
|
||||||
model.second.Update(delta_time);
|
|
||||||
auto model_serialized = model.second.Serialize();
|
auto model_serialized = model.second.Serialize();
|
||||||
Packet::Header header;
|
Packet::Header header;
|
||||||
header.opcode = Packet::Opcode::UPDATEMODEL;
|
header.opcode = Packet::Opcode::UPDATEMODEL;
|
||||||
|
|||||||
@@ -176,7 +176,12 @@ void Engine::NetworkUpload(std::shared_ptr<Network::Socket> sock) {
|
|||||||
|
|
||||||
data.insert(data.end(), header_serialized.begin(), header_serialized.end());
|
data.insert(data.end(), header_serialized.begin(), header_serialized.end());
|
||||||
data.insert(data.end(), model.begin(), model.end());
|
data.insert(data.end(), model.begin(), model.end());
|
||||||
it.second->needsUpdate = false;
|
if (it.second->updateRedundantCount >= 2) {
|
||||||
|
it.second->needsUpdate = false;
|
||||||
|
it.second->updateRedundantCount = 0;
|
||||||
|
} else {
|
||||||
|
it.second->updateRedundantCount++;
|
||||||
|
}
|
||||||
spdlog::debug("{} uploaded", it.second->name);
|
spdlog::debug("{} uploaded", it.second->name);
|
||||||
}
|
}
|
||||||
iocp_->send(sock, data);
|
iocp_->send(sock, data);
|
||||||
|
|||||||
@@ -164,6 +164,8 @@ struct Model {
|
|||||||
|
|
||||||
double lastUpdatedTime = 0.f; // 서버 기준 업데이트된 시간임
|
double lastUpdatedTime = 0.f; // 서버 기준 업데이트된 시간임
|
||||||
|
|
||||||
|
std::uint8_t updateRedundantCount;
|
||||||
|
|
||||||
std::mutex modding;
|
std::mutex modding;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user