GekkoNet
1.0
C/C++ Peer to Peer Game Networking SDK
Loading...
Searching...
No Matches
storage.cpp
Go to the documentation of this file.
1
#include "
storage.h
"
2
3
Gekko::StateStorage::StateStorage
()
4
{
5
_max_num_states
= 0;
6
}
7
8
9
void
Gekko::StateStorage::Init
(
u32
num_states,
u32
state_size,
bool
limited)
10
{
11
const
u32
num = limited ? 2 : num_states + 2;
12
_max_num_states
= num;
13
14
for
(
u32
i = 0; i <
_max_num_states
; i++) {
15
_states
.push_back(std::make_unique<StateEntry>());
16
_states
.back().get()->state = std::make_unique<u8[]>(state_size);
17
_states
.back().get()->state_len = state_size;
18
}
19
20
_runahead_state
.state = std::make_unique<u8[]>(state_size);
21
_runahead_state
.state_len = state_size;
22
_runahead_state
.frame =
GameInput::NULL_FRAME
;
23
}
24
25
Gekko::StateEntry
*
Gekko::StateStorage::GetRunaheadState
()
26
{
27
return
&
_runahead_state
;
28
}
29
30
Gekko::StateEntry
*
Gekko::StateStorage::GetState
(
Frame
frame)
31
{
32
frame = frame < 0 ? frame +
_max_num_states
: frame;
33
return
_states
[frame %
_max_num_states
].get();
34
}
Gekko::StateStorage::_max_num_states
u32 _max_num_states
Definition
storage.h:28
Gekko::StateStorage::GetRunaheadState
StateEntry * GetRunaheadState()
Definition
storage.cpp:25
Gekko::StateStorage::GetState
StateEntry * GetState(Frame frame)
Definition
storage.cpp:30
Gekko::StateStorage::_states
std::vector< std::unique_ptr< StateEntry > > _states
Definition
storage.h:30
Gekko::StateStorage::StateStorage
StateStorage()
Definition
storage.cpp:3
Gekko::StateStorage::Init
void Init(u32 num_states, u32 state_size, bool limited)
Definition
storage.cpp:9
Gekko::StateStorage::_runahead_state
StateEntry _runahead_state
Definition
storage.h:32
Frame
int32_t Frame
Definition
gekko_types.h:18
u32
uint32_t u32
Definition
gekko_types.h:7
storage.h
Gekko::GameInput::NULL_FRAME
static const i32 NULL_FRAME
Definition
input.h:21
Gekko::StateEntry
Definition
storage.h:10
src
storage.cpp
Generated by
1.15.0