Skip to content

Commit 5c61fd3

Browse files
committed
Not needed anymore
2 parents ce87999 + f6f072d commit 5c61fd3

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

GekkoLib/src/gekko.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void Gekko::Session::SetNetAdapter(GekkoNetAdapter* adapter)
5959

6060
i32 Gekko::Session::AddActor(GekkoPlayerType type, GekkoNetAddress* addr)
6161
{
62-
const int ERR = -1;
62+
const i32 ERR = -1;
6363
std::unique_ptr<NetAddress> address;
6464

6565
if (addr) {
@@ -519,7 +519,7 @@ void Gekko::Session::HandleReceivedInputs()
519519
const Frame start = current->input.start_frame;
520520

521521
for (u32 i = 0; i < handles; i++) {
522-
Handle handle = spectating ? i + 1 : current->handles[i];
522+
Handle handle = spectating ? i : current->handles[i];
523523
for (u32 j = 1; j <= count; j++) {
524524
Frame frame = start + j;
525525
u8* input = &current->input.inputs[(player_offset * i) + ((j - 1) * _config.input_size)];

GekkoLib/src/sync.cpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,22 @@ void Gekko::SyncSystem::Init(u8 num_players, u32 input_size)
2828

2929
void Gekko::SyncSystem::AddLocalInput(Handle player, u8* input)
3030
{
31-
// valid handles start from 1 while the input buffers index starts at 0.
32-
i32 plyr = player - 1;
33-
3431
// drop inputs from incorrect handles
35-
if (plyr >= _num_players || plyr < 0) {
32+
if (player >= _num_players || player < 0) {
3633
return;
3734
}
3835

39-
_input_buffers[plyr].AddLocalInput(_current_frame, input);
36+
_input_buffers[player].AddLocalInput(_current_frame, input);
4037
}
4138

4239
void Gekko::SyncSystem::AddRemoteInput(Handle player, u8* input, Frame frame)
4340
{
44-
// valid handles start from 1 while the input buffers index starts at 0.
45-
i32 plyr = player - 1;
46-
4741
// drop inputs from incorrect handles
48-
if (plyr >= _num_players || plyr < 0) {
42+
if (player >= _num_players || player < 0) {
4943
return;
5044
}
5145

52-
_input_buffers[plyr].AddInput(frame, input);
46+
_input_buffers[player].AddInput(frame, input);
5347
}
5448

5549
void Gekko::SyncSystem::IncrementFrame()
@@ -95,7 +89,7 @@ bool Gekko::SyncSystem::GetLocalInputs(std::vector<Handle>& handles, std::unique
9589
inputs.reset();
9690
std::unique_ptr<u8[]> all_input(new u8[_input_size * handles.size()]);
9791
for (u8 i = 0; i < handles.size(); i++) {
98-
auto inp = _input_buffers[handles[i] - 1].GetInput(frame, true);
92+
auto inp = _input_buffers[handles[i]].GetInput(frame, true);
9993

10094
if (inp->frame == GameInput::NULL_FRAME) {
10195
return false;
@@ -109,17 +103,17 @@ bool Gekko::SyncSystem::GetLocalInputs(std::vector<Handle>& handles, std::unique
109103

110104
void Gekko::SyncSystem::SetLocalDelay(Handle player, u8 delay)
111105
{
112-
_input_buffers[player - 1].SetDelay(delay);
106+
_input_buffers[player].SetDelay(delay);
113107
}
114108

115109
u8 Gekko::SyncSystem::GetLocalDelay(Handle player)
116110
{
117-
return _input_buffers[player - 1].GetDelay();
111+
return _input_buffers[player].GetDelay();
118112
}
119113

120114
void Gekko::SyncSystem::SetInputPredictionWindow(Handle player, u8 input_window)
121115
{
122-
_input_buffers[player - 1].SetInputPredictionWindow(input_window);
116+
_input_buffers[player].SetInputPredictionWindow(input_window);
123117
}
124118

125119
Frame Gekko::SyncSystem::GetCurrentFrame()
@@ -157,10 +151,8 @@ Frame Gekko::SyncSystem::GetMinReceivedFrame()
157151

158152
Frame Gekko::SyncSystem::GetLastReceivedFrom(Handle player)
159153
{
160-
u32 plyr = player - 1;
161-
162-
if (plyr >= 0 && plyr < _num_players) {
163-
return _input_buffers[plyr].GetLastReceivedFrame();
154+
if (player >= 0 && player < _num_players) {
155+
return _input_buffers[player].GetLastReceivedFrame();
164156
}
165157

166158
return GameInput::NULL_FRAME;

0 commit comments

Comments
 (0)