FIX: La máxima puntuación no se actualizaba correctamente en el marcador cuando se jugaba con puntuaciones online activadas
This commit is contained in:
@@ -82,7 +82,7 @@ void EnterID::checkEvents()
|
||||
{
|
||||
if (eventHandler->key.keysym.scancode == SDL_SCANCODE_RETURN)
|
||||
{
|
||||
options->online.jailerID = (std::string)name;
|
||||
options->online.jailerID = toLower((std::string)name);
|
||||
endSection();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
|
||||
// Carga los recursos
|
||||
loadMedia();
|
||||
|
||||
// Carga ficheros
|
||||
loadDemoFile();
|
||||
|
||||
// Establece la máxima puntuación desde fichero o desde las puntuaciones online
|
||||
setHiScore();
|
||||
|
||||
clouds1A = new MovingSprite(0, 0, 256, 52, -0.4f, 0.0f, 0.0f, 0.0f, gameCloudsTexture, renderer);
|
||||
clouds1B = new MovingSprite(256, 0, 256, 52, -0.4f, 0.0f, 0.0f, 0.0f, gameCloudsTexture, renderer);
|
||||
clouds2A = new MovingSprite(0, 52, 256, 32, -0.2f, 0.0f, 0.0f, 0.0f, gameCloudsTexture, renderer);
|
||||
@@ -392,10 +398,6 @@ void Game::loadMedia()
|
||||
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
|
||||
}
|
||||
|
||||
// Carga ficheros
|
||||
loadScoreFile();
|
||||
loadDemoFile();
|
||||
|
||||
// Texturas
|
||||
bulletTexture = new Texture(renderer, asset->get("bullet.png"));
|
||||
gameBuildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
|
||||
@@ -1612,6 +1614,12 @@ void Game::updateHiScore()
|
||||
// Actualiza la máxima puntuación
|
||||
hiScore = player->getScore();
|
||||
|
||||
// Cambia el nombre del jugador con la máxima puntuación
|
||||
if (options->online.enabled)
|
||||
{
|
||||
hiScoreName = options->online.jailerID.substr(0, 12) + " - ";
|
||||
}
|
||||
|
||||
// Almacena la máxima puntuación en el fichero junto con un checksum
|
||||
scoreDataFile[0] = hiScore;
|
||||
scoreDataFile[1] = hiScore % 43;
|
||||
@@ -1736,22 +1744,7 @@ void Game::renderScoreBoard()
|
||||
|
||||
// HI-SCORE
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3, lang->getText(56));
|
||||
if (options->online.enabled)
|
||||
{
|
||||
if (jscore::getNumUsers() > 0)
|
||||
{
|
||||
const std::string txt = jscore::getUserName(0).substr(0, 12) + " - " + updateScoreText((Uint32)jscore::getPoints(0));
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, txt);
|
||||
}
|
||||
else
|
||||
{
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, "Bacteriol - 0000010");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, updateScoreText(hiScore));
|
||||
}
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, hiScoreName + updateScoreText(hiScore));
|
||||
}
|
||||
|
||||
// Actualiza las variables del jugador
|
||||
@@ -3088,15 +3081,12 @@ void Game::checkGameInput()
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el input de pausa
|
||||
//if (input->checkInput(input_pause, REPEAT_FALSE))
|
||||
// Si se pulsa cualquier tecla, se sale del modo demo
|
||||
if (input->checkAnyInput())
|
||||
{
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Incrementa el contador de la demo
|
||||
if (demo.counter < TOTAL_DEMO_DATA)
|
||||
{
|
||||
@@ -3966,4 +3956,30 @@ void Game::reloadTextures()
|
||||
gamePowerMeterTexture->reLoad();
|
||||
gameSkyColorsTexture->reLoad();
|
||||
gameTextTexture->reLoad();
|
||||
}
|
||||
|
||||
// Establece la máxima puntuación desde fichero o desde las puntuaciones online
|
||||
void Game::setHiScore()
|
||||
{
|
||||
// Carga el fichero de puntos
|
||||
loadScoreFile();
|
||||
|
||||
// Establece el resto de variables
|
||||
if (options->online.enabled)
|
||||
{
|
||||
if (jscore::getNumUsers() > 0)
|
||||
{
|
||||
hiScoreName = jscore::getUserName(0).substr(0, 12) + " - ";
|
||||
hiScore = (Uint32)jscore::getPoints(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
hiScoreName = "Bacteriol - ";
|
||||
hiScore = 10;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hiScoreName = "";
|
||||
}
|
||||
}
|
||||
@@ -199,6 +199,7 @@ private:
|
||||
Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
Uint32 hiScore; // Puntuación máxima
|
||||
bool hiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
||||
std::string hiScoreName; // Nombre del jugador que ostenta la máxima puntuación
|
||||
stage_t stage[10]; // Variable con los datos de cada pantalla
|
||||
Uint8 currentStage; // Indica la fase actual
|
||||
Uint8 stageBitmapCounter; // Contador para el tiempo visible del texto de Stage
|
||||
@@ -511,6 +512,9 @@ private:
|
||||
// Recarga las texturas
|
||||
void reloadTextures();
|
||||
|
||||
// Establece la máxima puntuación desde fichero o desde las puntuaciones online
|
||||
void setHiScore();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, options_t *options, section_t *section);
|
||||
|
||||
Reference in New Issue
Block a user