FIX: Ya inicia la sesión online correctamente tras cambiar el JailerID
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -256,30 +257,59 @@ void EnterID::fillTexture()
|
||||
void EnterID::initOnline()
|
||||
{
|
||||
if (options->online.sessionEnabled)
|
||||
{ // Si ya ha iniciado la sesión, que no continue
|
||||
return;
|
||||
}
|
||||
|
||||
if (options->online.jailerID == "")
|
||||
{ // Jailer ID no definido
|
||||
options->online.enabled = false;
|
||||
}
|
||||
else
|
||||
{ // Jailer ID iniciado
|
||||
options->online.enabled = options->online.sessionEnabled = true;
|
||||
jscore::init(options->online.server, options->online.port);
|
||||
{ // Si ya ha iniciado la sesión, que no continue
|
||||
return;
|
||||
}
|
||||
|
||||
if (options->online.jailerID == "")
|
||||
{ // Jailer ID no definido
|
||||
options->online.enabled = false;
|
||||
}
|
||||
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);
|
||||
if (options->console)
|
||||
{
|
||||
std::cout << caption << std::endl;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Termina la sección
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user