제출 버전
This commit is contained in:
@@ -149,9 +149,12 @@ void ClientRefresher(utils::ThreadPool* tp, Network::IOCP* iocp) {
|
||||
header_serialized.end());
|
||||
send_data.insert(send_data.end(), model_serialized.begin(),
|
||||
model_serialized.end());
|
||||
if (!model.second->needsUpdate && !needs_all_update &&
|
||||
/*if (!model.second->needsUpdate && !needs_all_update &&
|
||||
!model.second->shouldBeDestroyed) {
|
||||
continue;
|
||||
}*/
|
||||
if (!needs_all_update) {
|
||||
continue;
|
||||
}
|
||||
model.second->needsUpdate = false;
|
||||
if (iocp->send(client, send_data) == -1) {
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "socket/packet.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#define TICKRATE 10
|
||||
constexpr double TICKDELAY = (1 / TICKRATE);
|
||||
|
||||
namespace veng {
|
||||
|
||||
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) {
|
||||
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;
|
||||
for (auto& it : models_) {
|
||||
std::lock_guard lock(it.second->modding);
|
||||
if (!it.second->networkReplicated) continue;
|
||||
if (!it.second->needsUpdate) continue;
|
||||
if (!it.second->networkReplicated && !needs_all_update) continue;
|
||||
if (!it.second->needsUpdate && !needs_all_update) continue;
|
||||
|
||||
Packet::Header header;
|
||||
header.opcode = Packet::Opcode::UPDATEMODEL;
|
||||
|
||||
Reference in New Issue
Block a user