fix: cppcheck (21 troballes)
This commit is contained in:
@@ -145,11 +145,11 @@ void JD8_FillRect(int x, int y, int w, int h, Uint8 color) {
|
||||
}
|
||||
}
|
||||
|
||||
void JD8_Blit(JD8_Surface surface) {
|
||||
void JD8_Blit(const Uint8* surface) {
|
||||
memcpy(screen, surface, 64000);
|
||||
}
|
||||
|
||||
void JD8_Blit(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh) {
|
||||
void JD8_Blit(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh) {
|
||||
int src_pointer = sx + (sy * 320);
|
||||
int dst_pointer = x + (y * 320);
|
||||
for (int i = 0; i < sh; i++) {
|
||||
@@ -159,7 +159,7 @@ void JD8_Blit(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh)
|
||||
}
|
||||
}
|
||||
|
||||
void JD8_BlitToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest) {
|
||||
void JD8_BlitToSurface(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, JD8_Surface dest) {
|
||||
int src_pointer = sx + (sy * 320);
|
||||
int dst_pointer = x + (y * 320);
|
||||
for (int i = 0; i < sh; i++) {
|
||||
@@ -305,7 +305,7 @@ void JD8_FadeStartOut() {
|
||||
fade_step = 0;
|
||||
}
|
||||
|
||||
void JD8_FadeStartToPal(JD8_Palette pal) {
|
||||
void JD8_FadeStartToPal(const Color* pal) {
|
||||
fade_type = FadeType::ToPal;
|
||||
memcpy(fade_target, pal, sizeof(Color) * 256);
|
||||
fade_step = 0;
|
||||
|
||||
@@ -30,11 +30,11 @@ void JD8_FillSquare(int ini, int height, Uint8 color);
|
||||
// Pensat per a UI senzilla (barra de progrés del BootLoader, etc.).
|
||||
void JD8_FillRect(int x, int y, int w, int h, Uint8 color);
|
||||
|
||||
void JD8_Blit(JD8_Surface surface);
|
||||
void JD8_Blit(const Uint8* surface);
|
||||
|
||||
void JD8_Blit(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh);
|
||||
void JD8_Blit(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh);
|
||||
|
||||
void JD8_BlitToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest);
|
||||
void JD8_BlitToSurface(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, JD8_Surface dest);
|
||||
|
||||
void JD8_BlitCK(int x, int y, const Uint8* surface, int sx, int sy, int sw, int sh, Uint8 colorkey);
|
||||
|
||||
@@ -69,7 +69,7 @@ void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b);
|
||||
// un fade en curs per a enllaçar-lo amb un altre subsistema.
|
||||
// L'embolcall `scenes::PaletteFade` ho fa més idiomàtic per a escenes.
|
||||
void JD8_FadeStartOut();
|
||||
void JD8_FadeStartToPal(JD8_Palette pal);
|
||||
void JD8_FadeStartToPal(const Color* pal);
|
||||
auto JD8_FadeTickStep() -> bool;
|
||||
auto JD8_FadeIsActive() -> bool;
|
||||
|
||||
|
||||
+13
-15
@@ -3,6 +3,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
@@ -90,11 +91,10 @@ void file_setconfigfolder(const char* foldername) {
|
||||
homedir = "/tmp";
|
||||
}
|
||||
config_folder = std::string(homedir) + "/.config/" + foldername;
|
||||
#else
|
||||
config_folder = std::string("/tmp/jailgames_config/") + foldername;
|
||||
#endif
|
||||
|
||||
if (config_folder.empty()) {
|
||||
config_folder = "/tmp/jailgames_config";
|
||||
}
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(config_folder, ec);
|
||||
// A emscripten/MEMFS create_directories pot fallar (p.ex. parent
|
||||
@@ -112,12 +112,11 @@ auto file_getconfigvalue(const char* key) -> const char* {
|
||||
if (config.empty()) {
|
||||
load_config_values();
|
||||
}
|
||||
for (const auto& pair : config) {
|
||||
if (pair.key == key) {
|
||||
thread_local std::string value_cache;
|
||||
value_cache = pair.value;
|
||||
return value_cache.c_str();
|
||||
}
|
||||
const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
|
||||
if (it != config.end()) {
|
||||
thread_local std::string value_cache;
|
||||
value_cache = it->value;
|
||||
return value_cache.c_str();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -126,12 +125,11 @@ void file_setconfigvalue(const char* key, const char* value) {
|
||||
if (config.empty()) {
|
||||
load_config_values();
|
||||
}
|
||||
for (auto& pair : config) {
|
||||
if (pair.key == key) {
|
||||
pair.value = value;
|
||||
save_config_values();
|
||||
return;
|
||||
}
|
||||
const auto it = std::find_if(config.begin(), config.end(), [key](const keyvalue& pair) { return pair.key == key; });
|
||||
if (it != config.end()) {
|
||||
it->value = value;
|
||||
save_config_values();
|
||||
return;
|
||||
}
|
||||
config.push_back({std::string(key), std::string(value)});
|
||||
save_config_values();
|
||||
|
||||
Reference in New Issue
Block a user