VERSIÓ 1.0 RC3

- [FIX] Funció "view.local()" canviada a "view.tolocal()", per a evitar problemes.
- [FIX] Si una surface no s'ha creat, no hi ha res que alliberar.
- [NEW] Afegit log de creació i destrucció de surfaces.
This commit is contained in:
2025-06-03 13:26:11 +02:00
parent adcc44ddab
commit 4bda9cbd39
3 changed files with 15 additions and 6 deletions

View File

@@ -210,12 +210,17 @@ uint8_t newsurf(int w, int h) {
surfaces[i].h = h;
surfaces[i].size = w*h;
surfaces[i].p = (uint8_t*)calloc(surfaces[i].size,1);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Surface %i creada.\n", i);
return i;
}
uint8_t loadsurf(const char* filename) {
// Si el gif ja s'ha carregat en una textura, tornem eixa textura
for (int i=0; i<MAX_TEXTURES; ++i) if (strcmp(surfaces[i].name, filename)==0) return i;
for (int i=0; i<MAX_TEXTURES; ++i)
if (surfaces[i].name && strcmp(surfaces[i].name, filename)==0) {
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Carrega de '%s' abortada: Reusant: %i.\n", filename, i);
return i;
}
int i = 0;
while (i<MAX_TEXTURES && surfaces[i].p != NULL) ++i;
@@ -229,6 +234,7 @@ uint8_t loadsurf(const char* filename) {
strcpy(surfaces[i].name, filename);
free(buffer);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Carregat '%s': Surface: %i.\n", filename, i);
return i;
}
@@ -243,10 +249,13 @@ void savesurf(uint8_t surface, const char* filename, uint8_t *pal, uint8_t color
}
void freesurf(uint8_t surface) {
if (surfaces[surface].p != NULL) free(surfaces[surface].p);
surfaces[surface].p = NULL;
if (surfaces[surface].name != NULL) free(surfaces[surface].name);
surfaces[surface].name = NULL;
if (surfaces[surface].p != NULL) {
free(surfaces[surface].p);
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Surface %i alliberada.\n", surface);
}
surfaces[surface].p = NULL;
}
int surfw(uint8_t surface) {