FIX: Ya inicia la sesión online correctamente tras cambiar el JailerID
This commit is contained in:
@@ -5,12 +5,13 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// 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
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
|
this->lang = lang;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
|
||||||
@@ -256,30 +257,59 @@ void EnterID::fillTexture()
|
|||||||
void EnterID::initOnline()
|
void EnterID::initOnline()
|
||||||
{
|
{
|
||||||
if (options->online.sessionEnabled)
|
if (options->online.sessionEnabled)
|
||||||
{ // Si ya ha iniciado la sesión, que no continue
|
{ // Si ya ha iniciado la sesión, que no continue
|
||||||
return;
|
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);
|
|
||||||
|
|
||||||
|
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
|
#ifdef DEBUG
|
||||||
const std::string caption = "IS LOGGED IN (DEBUG)";
|
const std::string caption = options->online.jailerID + " (DEBUG)";
|
||||||
#else
|
#else
|
||||||
const std::string caption = "IS LOGGED IN";
|
const std::string caption = options->online.jailerID;
|
||||||
#endif
|
#endif
|
||||||
screen->showNotification(options->online.jailerID, caption, 12);
|
screen->showNotification(caption, lang->getText(85), 12);
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
std::cout << caption << std::endl;
|
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
|
// Termina la sección
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ private:
|
|||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
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_Event *eventHandler; // Manejador de eventos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||||
@@ -70,7 +71,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// 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
|
// Destructor
|
||||||
~EnterID();
|
~EnterID();
|
||||||
|
|||||||
@@ -1025,7 +1025,7 @@ void Title::runDemoGame()
|
|||||||
// Introduce el JailerID
|
// Introduce el JailerID
|
||||||
void Title::runEnterID()
|
void Title::runEnterID()
|
||||||
{
|
{
|
||||||
enterID = new EnterID(renderer, screen, asset, options, section);
|
enterID = new EnterID(renderer, screen, asset, lang, options, section);
|
||||||
enterID->run();
|
enterID->run();
|
||||||
delete enterID;
|
delete enterID;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user