fix: init lists, scope reduit i rename vorbis_error
This commit is contained in:
@@ -265,13 +265,13 @@ inline JA_Music_t* JA_LoadMusic(const Uint8* buffer, Uint32 length) {
|
||||
auto* music = new JA_Music_t();
|
||||
music->ogg_data.assign(buffer, buffer + length);
|
||||
|
||||
int error = 0;
|
||||
int vorbis_error = 0;
|
||||
music->vorbis = stb_vorbis_open_memory(music->ogg_data.data(),
|
||||
static_cast<int>(length),
|
||||
&error,
|
||||
&vorbis_error,
|
||||
nullptr);
|
||||
if (!music->vorbis) {
|
||||
std::cout << "JA_LoadMusic: stb_vorbis_open_memory failed (error " << error << ")" << '\n';
|
||||
std::cout << "JA_LoadMusic: stb_vorbis_open_memory failed (error " << vorbis_error << ")" << '\n';
|
||||
delete music;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -75,11 +75,11 @@ namespace Resource {
|
||||
}
|
||||
|
||||
// Buscar la última entrada con el mismo prefijo de ruta e insertar después
|
||||
std::string entry = " - " + var_path + "\n";
|
||||
auto last_pos = content.rfind(var_path.substr(0, var_path.rfind('/')));
|
||||
if (last_pos != std::string::npos) {
|
||||
auto end_of_line = content.find('\n', last_pos);
|
||||
if (end_of_line != std::string::npos) {
|
||||
std::string entry = " - " + var_path + "\n";
|
||||
content.insert(end_of_line + 1, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,21 +45,24 @@
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Director::Director() {
|
||||
std::cout << "Game start" << '\n';
|
||||
|
||||
namespace {
|
||||
auto getExecutablePath() -> std::string {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// En Emscripten els assets estan al root del filesystem virtual (/data, /config)
|
||||
executable_path_ = "";
|
||||
return "";
|
||||
#else
|
||||
// Obtiene la ruta del ejecutable
|
||||
std::string base = SDL_GetBasePath();
|
||||
if (!base.empty() && base.back() == '/') {
|
||||
base.pop_back();
|
||||
}
|
||||
executable_path_ = base;
|
||||
return base;
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Constructor
|
||||
Director::Director() : executable_path_(getExecutablePath()) {
|
||||
std::cout << "Game start" << '\n';
|
||||
|
||||
// Crea la carpeta del sistema donde guardar datos
|
||||
createSystemFolder("jailgames");
|
||||
|
||||
@@ -15,13 +15,10 @@
|
||||
|
||||
// Constructor
|
||||
EditorStatusBar::EditorStatusBar(std::string room_number, std::string room_name)
|
||||
: room_number_(std::move(room_number)),
|
||||
: surface_(std::make_shared<Surface>(Options::game.width, 6.0F * Tile::SIZE)),
|
||||
surface_dest_{.x = 0, .y = Options::game.height - (6.0F * Tile::SIZE), .w = Options::game.width, .h = 6.0F * Tile::SIZE},
|
||||
room_number_(std::move(room_number)),
|
||||
room_name_(std::move(room_name)) {
|
||||
const float SURFACE_WIDTH = Options::game.width;
|
||||
constexpr float SURFACE_HEIGHT = 6.0F * Tile::SIZE; // 48 pixels, igual que el scoreboard
|
||||
|
||||
surface_ = std::make_shared<Surface>(SURFACE_WIDTH, SURFACE_HEIGHT);
|
||||
surface_dest_ = {.x = 0, .y = Options::game.height - SURFACE_HEIGHT, .w = SURFACE_WIDTH, .h = SURFACE_HEIGHT};
|
||||
}
|
||||
|
||||
// Pinta la barra de estado en pantalla
|
||||
|
||||
@@ -15,9 +15,8 @@ TilemapRenderer::TilemapRenderer(std::vector<int> tile_map, int tile_set_width,
|
||||
tile_set_width_(tile_set_width),
|
||||
tileset_surface_(std::move(tileset_surface)),
|
||||
bg_color_(std::move(bg_color)),
|
||||
conveyor_belt_direction_(conveyor_belt_direction) {
|
||||
// Crear la surface del mapa
|
||||
map_surface_ = std::make_shared<Surface>(PlayArea::WIDTH, PlayArea::HEIGHT);
|
||||
conveyor_belt_direction_(conveyor_belt_direction),
|
||||
map_surface_(std::make_shared<Surface>(PlayArea::WIDTH, PlayArea::HEIGHT)) {
|
||||
}
|
||||
|
||||
// Inicializa el renderizador
|
||||
|
||||
Reference in New Issue
Block a user