제출 버전
This commit is contained in:
@@ -149,9 +149,12 @@ void ClientRefresher(utils::ThreadPool* tp, Network::IOCP* iocp) {
|
|||||||
header_serialized.end());
|
header_serialized.end());
|
||||||
send_data.insert(send_data.end(), model_serialized.begin(),
|
send_data.insert(send_data.end(), model_serialized.begin(),
|
||||||
model_serialized.end());
|
model_serialized.end());
|
||||||
if (!model.second->needsUpdate && !needs_all_update &&
|
/*if (!model.second->needsUpdate && !needs_all_update &&
|
||||||
!model.second->shouldBeDestroyed) {
|
!model.second->shouldBeDestroyed) {
|
||||||
continue;
|
continue;
|
||||||
|
}*/
|
||||||
|
if (!needs_all_update) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
model.second->needsUpdate = false;
|
model.second->needsUpdate = false;
|
||||||
if (iocp->send(client, send_data) == -1) {
|
if (iocp->send(client, send_data) == -1) {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
#include "socket/packet.h"
|
#include "socket/packet.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
|
#define TICKRATE 10
|
||||||
|
constexpr double TICKDELAY = (1 / TICKRATE);
|
||||||
|
|
||||||
namespace veng {
|
namespace veng {
|
||||||
|
|
||||||
void Engine::init() {
|
void Engine::init() {
|
||||||
@@ -156,11 +159,19 @@ void Engine::NetUpdate(std::shared_ptr<Network::Socket> sock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Engine::NetworkUpload(std::shared_ptr<Network::Socket> sock) {
|
void Engine::NetworkUpload(std::shared_ptr<Network::Socket> sock) {
|
||||||
|
static double last_all_updated;
|
||||||
|
auto current_time = glfwGetTime();
|
||||||
|
bool needs_all_update = false;
|
||||||
|
if (current_time - last_all_updated >= TICKDELAY) {
|
||||||
|
needs_all_update = true;
|
||||||
|
last_all_updated = glfwGetTime();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<char> data;
|
std::vector<char> data;
|
||||||
for (auto& it : models_) {
|
for (auto& it : models_) {
|
||||||
std::lock_guard lock(it.second->modding);
|
std::lock_guard lock(it.second->modding);
|
||||||
if (!it.second->networkReplicated) continue;
|
if (!it.second->networkReplicated && !needs_all_update) continue;
|
||||||
if (!it.second->needsUpdate) continue;
|
if (!it.second->needsUpdate && !needs_all_update) continue;
|
||||||
|
|
||||||
Packet::Header header;
|
Packet::Header header;
|
||||||
header.opcode = Packet::Opcode::UPDATEMODEL;
|
header.opcode = Packet::Opcode::UPDATEMODEL;
|
||||||
|
|||||||
Reference in New Issue
Block a user