#Some magic

4 messages · Page 1 of 1 (latest)

real forge
#

The bug is kind of fixed, but I wanted to share it with you in case anyone have some random thoughts that may help me figuring out what is going on here.

I'm using Photon Server Plugin. The game is PvP between two real players. Server executes game loop itself to check if everything is valid.

The communication between client-server is simple:

  1. Initialization and loading game
  2. Starting game
  3. Sending player inputs between players
  4. Game End.

The problem occurs on the last step, when game is ending.
Server logic is very simple as well:

  1. Check if anyone's HP is <= 0. If so - send game result to backend using PhotonHost.HttpRequest() and wait for callback.
  2. Run game loop

Important: after server decides that game has ended and sends http request to backend game loop will stop working as well, but only after executing one last time.

Now the magic part:
-If server doesn't run any checks nor game logic (just calling game end method when requested to do so) - callback executes
-If server decides that game has ended and sends request, after which immediately terminates logic execution, not allowing for game loop to happen - callback executes
-If server decides that game has ended and sends request, after which keeps magic variable GameState = Battle and allows game loop to happen one or more times - callback executes
-If server decides that game has ended and sends request, after which changes magic variable GameState = !battle (anything but battle) and allows game loop to happen at least one more time - callback does not execute

Notes:

  1. GameState variable is used in game logic only, it does not affect any server code and no networking method depend on this variable
  2. There is no event happening on changing GameState, nothing is subscribed, it is just a variable
  3. No exceptions are ever thrown in any case
  4. Callback is called from PhotonServer and does not require any UpdateCallbacks() method to be called whatsoever
#
  1. HttpRequest() to backend on game end is called only once
#
  1. Game loop has nothing to do with networking and does not send any packets. Just executing game's logic locally
#
  1. Backend always receives request to end the game and always sends callback back to server
  2. There is no multithreading