From 8ad8f9566cec55b36a35cb07add01fdfcaeb43aa Mon Sep 17 00:00:00 2001 From: olel Date: Sun, 24 Sep 2023 10:31:03 +0200 Subject: [PATCH] Fixed game rejoin --- src/inc/game.cpp | 1 + src/inc/ui.cpp | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/inc/game.cpp b/src/inc/game.cpp index 6769727..e15dcbe 100644 --- a/src/inc/game.cpp +++ b/src/inc/game.cpp @@ -135,6 +135,7 @@ bool Player::isInviolable() { Game::Game() { // Allocating 33 bytes of memory for gameID strings gid = (char *)malloc(33 * sizeof(char)); + strcpy(gid, ""); team = Team(); player = Player(); startTime = 0; diff --git a/src/inc/ui.cpp b/src/inc/ui.cpp index 91b4fca..56cf695 100644 --- a/src/inc/ui.cpp +++ b/src/inc/ui.cpp @@ -108,19 +108,15 @@ void SkirmishUI::update() { uint32_t currentTS = getCurrentTS(); if (game->gid[0] == 0) { // No game setScene(SCENE_NO_GAME); - - } else if (game->gid[0] != 0 && // joined - game->startTime == 0) { // but not started game + } else if (strcmp(game->gid, "") != 0 && // joined + game->startTime == 0) { // but not started game setScene(SCENE_JOINED_GAME); - } else if (game->startTime > 0 && // started game game->startTime >= currentTS) { // but counting down setScene(SCENE_COUNTDOWN); - } else if (game->startTime > 0 && // started game game->startTime < currentTS) { // but running setScene(SCENE_GAME); - } else { /* Should never happen */ setScene(SCENE_NO_SCENE); }