제출 버전
This commit is contained in:
@@ -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