Skip to content

Commit 2107bc9

Browse files
committed
Internet cycle fix
Fixed not checking packet size in internet cycle
1 parent 5b82b43 commit 2107bc9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/cycles/serverGame.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ void ServerGameCycle::update(App& _app) {
8080
// Getting internet messages
8181
switch (connection.updateMessages()) {
8282
case ConnectionCode::GameTurn:
83-
#if CHECK_CORRECTION
84-
SDL_Log("Turn of opponent player: from %u to %u", connection.lastPacket->getData<Uint8>(2), connection.lastPacket->getData<Uint8>(3));
85-
#endif
86-
field.clickMultiplayerOpponent(connection.lastPacket->getData<Uint8>(2), connection.lastPacket->getData<Uint8>(3));
87-
// Making sound
88-
//_app.sounds.play(SND_RESET);
83+
if (connection.lastPacket->isBytesAvaliable(4)) {
84+
#if CHECK_CORRECTION
85+
SDL_Log("Turn of opponent player: from %u to %u", connection.lastPacket->getData<Uint8>(2), connection.lastPacket->getData<Uint8>(3));
86+
#endif
87+
field.clickMultiplayerOpponent(connection.lastPacket->getData<Uint8>(2), connection.lastPacket->getData<Uint8>(3));
88+
// Making sound
89+
//_app.sounds.play(SND_RESET);
90+
}
8991
return;
9092
}
9193
}

0 commit comments

Comments
 (0)