mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-22 00:48:09 +01:00
Re-enabled the network synchronizer module, and started cleaning it / porting it.
This commit is contained in:
parent
4871c46ec0
commit
e16d80eecb
@ -5,4 +5,8 @@ Import("env_modules")
|
||||
|
||||
env_network_synchronizer = env_modules.Clone()
|
||||
|
||||
env_network_synchronizer.add_source_files(env.modules_sources, "*.cpp")
|
||||
#env_network_synchronizer.add_source_files(env.modules_sources, "*.cpp")
|
||||
|
||||
env_network_synchronizer.add_source_files(env.modules_sources, "bit_array.cpp")
|
||||
|
||||
env_network_synchronizer.add_source_files(env.modules_sources, "register_types.cpp")
|
@ -35,13 +35,13 @@
|
||||
#include "bit_array.h"
|
||||
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
BitArray::BitArray(uint32_t p_initial_size_in_bit) {
|
||||
resize_in_bits(p_initial_size_in_bit);
|
||||
}
|
||||
|
||||
BitArray::BitArray(const Vector<uint8_t> &p_bytes) :
|
||||
BitArray::BitArray(const PoolByteArray &p_bytes) :
|
||||
bytes(p_bytes) {
|
||||
}
|
||||
|
||||
@ -73,6 +73,8 @@ void BitArray::store_bits(int p_bit_offset, uint64_t p_value, int p_bits) {
|
||||
int bit_offset = p_bit_offset;
|
||||
uint64_t val = p_value;
|
||||
|
||||
PoolByteArray::Write w = bytes.write();
|
||||
|
||||
while (bits > 0) {
|
||||
const int bits_to_write = MIN(bits, 8 - bit_offset % 8);
|
||||
const int bits_to_jump = bit_offset % 8;
|
||||
@ -84,16 +86,18 @@ void BitArray::store_bits(int p_bit_offset, uint64_t p_value, int p_bits) {
|
||||
uint8_t byte_clear = 0xFF >> bits_to_jump;
|
||||
byte_clear = byte_clear << (bits_to_jump + bits_to_skip);
|
||||
byte_clear = ~(byte_clear >> bits_to_skip);
|
||||
bytes.write[byte_offset] &= byte_clear;
|
||||
w[byte_offset] &= byte_clear;
|
||||
|
||||
// Now we can continue to write bits
|
||||
bytes.write[byte_offset] |= (val & 0xFF) << bits_to_jump;
|
||||
w[byte_offset] |= (val & 0xFF) << bits_to_jump;
|
||||
|
||||
bits -= bits_to_write;
|
||||
bit_offset += bits_to_write;
|
||||
|
||||
val >>= bits_to_write;
|
||||
}
|
||||
|
||||
w.release();
|
||||
}
|
||||
|
||||
uint64_t BitArray::read_bits(int p_bit_offset, int p_bits) const {
|
||||
@ -104,7 +108,8 @@ uint64_t BitArray::read_bits(int p_bit_offset, int p_bits) const {
|
||||
int bit_offset = p_bit_offset;
|
||||
uint64_t val = 0;
|
||||
|
||||
const uint8_t *bytes_ptr = bytes.ptr();
|
||||
PoolByteArray::Read r = bytes.read();
|
||||
const uint8_t *bytes_ptr = r.ptr();
|
||||
|
||||
int val_bits_to_jump = 0;
|
||||
while (bits > 0) {
|
||||
@ -124,11 +129,15 @@ uint64_t BitArray::read_bits(int p_bit_offset, int p_bits) const {
|
||||
val_bits_to_jump += bits_to_read;
|
||||
}
|
||||
|
||||
r.release();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void BitArray::zero() {
|
||||
if (bytes.size() > 0) {
|
||||
memset(bytes.ptrw(), 0, sizeof(uint8_t) * bytes.size());
|
||||
PoolByteArray::Write w = bytes.write();
|
||||
memset(w.ptr(), 0, sizeof(uint8_t) * bytes.size());
|
||||
w.release();
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef BITARRAY_H
|
||||
#define BITARRAY_H
|
||||
|
||||
/*************************************************************************/
|
||||
/* bit_array.h */
|
||||
/*************************************************************************/
|
||||
@ -32,24 +35,21 @@
|
||||
@author AndreaCatania
|
||||
*/
|
||||
|
||||
#include "core/vector.h"
|
||||
|
||||
#ifndef BITARRAY_H
|
||||
#define BITARRAY_H
|
||||
#include "core/variant.h"
|
||||
|
||||
class BitArray {
|
||||
Vector<uint8_t> bytes;
|
||||
PoolByteArray bytes;
|
||||
|
||||
public:
|
||||
BitArray() = default;
|
||||
BitArray(uint32_t p_initial_size_in_bit);
|
||||
BitArray(const Vector<uint8_t> &p_bytes);
|
||||
BitArray(const PoolByteArray &p_bytes);
|
||||
|
||||
const Vector<uint8_t> &get_bytes() const {
|
||||
const PoolByteArray &get_bytes() const {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Vector<uint8_t> &get_bytes_mut() {
|
||||
PoolByteArray &get_bytes_mut() {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
def can_build(env, platform):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def configure(env):
|
||||
@ -7,12 +7,14 @@ def configure(env):
|
||||
|
||||
|
||||
def get_doc_classes():
|
||||
return []
|
||||
return [
|
||||
#"BitArray",
|
||||
]
|
||||
|
||||
|
||||
def get_doc_path():
|
||||
return ""
|
||||
return "doc_classes"
|
||||
|
||||
|
||||
def is_enabled():
|
||||
return False
|
||||
return True
|
||||
|
@ -34,21 +34,24 @@
|
||||
|
||||
#include "register_types.h"
|
||||
|
||||
/*
|
||||
#include "data_buffer.h"
|
||||
#include "interpolator.h"
|
||||
#include "networked_controller.h"
|
||||
#include "scene_diff.h"
|
||||
#include "scene_synchronizer.h"
|
||||
*/
|
||||
|
||||
void register_network_synchronizer_types() {
|
||||
/*
|
||||
GDREGISTER_CLASS(DataBuffer);
|
||||
GDREGISTER_CLASS(SceneDiff);
|
||||
GDREGISTER_CLASS(Interpolator);
|
||||
GDREGISTER_CLASS(NetworkedController);
|
||||
GDREGISTER_CLASS(SceneSynchronizer);
|
||||
|
||||
GLOBAL_DEF("NetworkSynchronizer/debug_server_speedup", false);
|
||||
GLOBAL_DEF("NetworkSynchronizer/debug_doll_speedup", false);
|
||||
*/
|
||||
// GLOBAL_DEF("NetworkSynchronizer/debug_server_speedup", false);
|
||||
// GLOBAL_DEF("NetworkSynchronizer/debug_doll_speedup", false);
|
||||
}
|
||||
|
||||
void unregister_network_synchronizer_types() {
|
||||
|
Loading…
Reference in New Issue
Block a user