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:
4
lua.cpp
4
lua.cpp
@@ -323,7 +323,7 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_viewport_local(lua_State *L) {
|
||||
static int cpp_viewport_tolocal(lua_State *L) {
|
||||
int x = luaL_checknumber(L, 1);
|
||||
int y = luaL_checknumber(L, 2);
|
||||
lua_pushinteger(L, x+camx());
|
||||
@@ -834,7 +834,7 @@ void push_lua_funcs() {
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_viewport_clip); lua_setfield(L, -2, "clip");
|
||||
lua_pushcfunction(L,cpp_viewport_origin); lua_setfield(L, -2, "origin");
|
||||
lua_pushcfunction(L,cpp_viewport_local); lua_setfield(L, -2, "local");
|
||||
lua_pushcfunction(L,cpp_viewport_tolocal); lua_setfield(L, -2, "tolocal");
|
||||
lua_setglobal(L, "view");
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
15
mini.cpp
15
mini.cpp
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user