FIX: Ya inicia la sesión online correctamente tras cambiar el JailerID

This commit is contained in:
2023-09-24 10:02:03 +02:00
parent 26f7cf2a37
commit 3e7aeeedbf
3 changed files with 54 additions and 23 deletions

View File

@@ -5,12 +5,13 @@
#include <iostream>
// Constructor
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section)
EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, options_t *options, section_t *section)
{
// Copia la dirección de los objetos
this->renderer = renderer;
this->screen = screen;
this->asset = asset;
this->lang = lang;
this->options = options;
this->section = section;
@@ -267,18 +268,47 @@ void EnterID::initOnline()
else
{ // Jailer ID iniciado
options->online.enabled = options->online.sessionEnabled = true;
// Establece el servidor y el puerto
jscore::init(options->online.server, options->online.port);
#ifdef DEBUG
const std::string caption = "IS LOGGED IN (DEBUG)";
const std::string caption = options->online.jailerID + " (DEBUG)";
#else
const std::string caption = "IS LOGGED IN";
const std::string caption = options->online.jailerID;
#endif
screen->showNotification(options->online.jailerID, caption, 12);
screen->showNotification(caption, lang->getText(85), 12);
if (options->console)
{
std::cout << caption << std::endl;
}
// Obtiene la información de puntuaciones online
if (!jscore::initOnlineScore(options->online.gameID))
{
screen->showNotification(lang->getText(80), options->online.server);
if (options->console)
{
std::cout << "Can't connect to " << options->online.server << std::endl;
}
options->online.enabled = false;
return;
}
// Obten la puntuación online para el jailerID
const int points = jscore::getUserPoints(options->online.gameID, options->online.jailerID);
if (points == 0)
{ // Fallo de conexión o no hay registros
screen->showNotification(lang->getText(81), lang->getText(82));
if (options->console)
{
std::cout << "Can't get online scores" << std::endl;
}
}
else
{
options->online.score = points;
}
}
}

View File

@@ -25,6 +25,7 @@ private:
Asset *asset; // Objeto con los ficheros de recursos
options_t *options; // Puntero a las opciones del juego
Screen *screen; // Objeto encargado de dibujar en pantalla
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
SDL_Event *eventHandler; // Manejador de eventos
SDL_Renderer *renderer; // El renderizador de la ventana
SDL_Texture *textTexture; // Textura para dibujar el texto
@@ -70,7 +71,7 @@ private:
public:
// Constructor
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, options_t *options, section_t *section);
// Destructor
~EnterID();

View File

@@ -1025,7 +1025,7 @@ void Title::runDemoGame()
// Introduce el JailerID
void Title::runEnterID()
{
enterID = new EnterID(renderer, screen, asset, options, section);
enterID = new EnterID(renderer, screen, asset, lang, options, section);
enterID->run();
delete enterID;
}