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