Compare commits
No commits in common. "9d2785541d46617e43c170c59baca18a1f2d3a52" and "59918b86b12d5650861029d0078a80e04c0d8ec0" have entirely different histories.
9d2785541d
...
59918b86b1
12
deerith_engine_core/include/deerith/SyncBuffer.h
Normal file
12
deerith_engine_core/include/deerith/SyncBuffer.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <deerith/engine.h>
|
||||||
|
|
||||||
|
namespace deerith
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
class SyncBuffer
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
// At
|
// At
|
||||||
#define UNIVERSE_SIMULATION_TICK_FREQ 50
|
#define UNIVERSE_SIMULATION_TICK_FREQ 50
|
||||||
#define NETWORK_RELATIVE_TICK 2
|
#define NETWORK_RELATIVE_UNIVERSE_TICK 2
|
||||||
#define NETWORK_DELAY 10
|
#define NETWORK_DELAY 6
|
||||||
|
|
||||||
namespace deerith
|
namespace deerith
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <deerith/engine.h>
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
#define BUFFER_SIZE (NETWORK_DELAY + 20)
|
|
||||||
|
|
||||||
namespace deerith
|
|
||||||
{
|
|
||||||
struct sync_variable_base_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~sync_variable_base_t() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct sync_variable_entry_t
|
|
||||||
{
|
|
||||||
T value;
|
|
||||||
uint32_t tick_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class sync_variable_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~sync_buffer_t() = default;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::array<sync_variable_entry_t<T>, BUFFER_SIZE> buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class sync_variable_t
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <deerith/universe/user.h>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace deerith
|
|
||||||
{
|
|
||||||
|
|
||||||
void define_client_callback(std::function<void(user &)>);
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <deerith/network/sync_variable.h>
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace deerith
|
|
||||||
{
|
|
||||||
class user_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void *user_data = nullptr;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void register_sync_variable(sync_variable_t<T> *var);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<sync_variable_base_t *> buffers;
|
|
||||||
};
|
|
||||||
|
|
||||||
void register_user_sync_variables_init_callback(std::function<void(user_t &)>);
|
|
||||||
void register_user_sync_variables_shutdown_callback(std::function<void(user_t &)>);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void deerith::user_t::register_sync_variable(sync_variable_t<T> *var)
|
|
||||||
{
|
|
||||||
buffers.push_back(var);
|
|
||||||
}
|
|
||||||
11
deerith_engine_core/include/deerith/universe_definition.h
Normal file
11
deerith_engine_core/include/deerith/universe_definition.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
namespace deerith
|
||||||
|
{
|
||||||
|
class Client
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
void define_client_callback(std::function<void(Client)>);
|
||||||
|
}
|
||||||
@ -1,6 +0,0 @@
|
|||||||
#include <deerith/universe/user.h>
|
|
||||||
|
|
||||||
namespace deerit
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
#include <deerith/universe.h>
|
#include <deerith/universe.h>
|
||||||
|
#include <deerith/universe_definition.h>
|
||||||
|
|
||||||
#include <deerith/core/tick.h>
|
#include <deerith/core/tick.h>
|
||||||
#include <deerith/core/log.h>
|
#include <deerith/core/log.h>
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <deerith/universe/user.h>
|
|
||||||
#include <deerith/network/sync_variable.h>
|
|
||||||
#include <deerith/universe/universe_definition.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
struct sandbox_user_data_t
|
|
||||||
{
|
|
||||||
deerith::sync_variable_t<glm::vec2> position_sync;
|
|
||||||
};
|
|
||||||
|
|
||||||
void define_user();
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
#include "common/common.h"
|
|
||||||
#include <deerith/universe/user.h>
|
|
||||||
#include <deerith/core/log.h>
|
|
||||||
|
|
||||||
void user_sync_variables_init(deerith::user_t &user)
|
|
||||||
{
|
|
||||||
deerith_trace("removing user data to new user");
|
|
||||||
sandbox_user_data_t *sandbox_user_data = new sandbox_user_data_t();
|
|
||||||
|
|
||||||
user.user_data = sandbox_user_data;
|
|
||||||
user.register_sync_variable(&sandbox_user_data->position_sync);
|
|
||||||
}
|
|
||||||
|
|
||||||
void user_sync_variables_shutdown(deerith::user_t &user)
|
|
||||||
{
|
|
||||||
deerith_trace("removing user");
|
|
||||||
delete ((sandbox_user_data_t *)user.user_data);
|
|
||||||
user.user_data = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void client_definition()
|
|
||||||
{
|
|
||||||
deerith::register_user_sync_variables_init_callback(user_sync_variables_init);
|
|
||||||
deerith::register_user_sync_variables_shutdown_callback(user_sync_variables_shutdown);
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user