------------------------------------------------------------------------------- deinitApp frees all memory consumed by the application and terminates the engine -------------------------------------------------------------------------------*/
| 1202 | |
| 1203 | -------------------------------------------------------------------------------*/ |
| 1204 | int deinitApp() |
| 1205 | { |
| 1206 | #ifdef USE_OPENAL |
| 1207 | closeOPENAL(); |
| 1208 | #endif |
| 1209 | // close engine |
| 1210 | printlog("closing engine...\n"); |
| 1211 | |
| 1212 | finishStackTraceUnique(); |
| 1213 | |
| 1214 | printlog("freeing engine resources...\n"); |
| 1215 | list_FreeAll(&button_l); |
| 1216 | list_FreeAll(&entitiesdeleted); |
| 1217 | if (font8x8_bmp) { |
| 1218 | SDL_FreeSurface(font8x8_bmp); |
| 1219 | } |
| 1220 | if (font12x12_bmp) { |
| 1221 | SDL_FreeSurface(font12x12_bmp); |
| 1222 | } |
| 1223 | if (font16x16_bmp) { |
| 1224 | SDL_FreeSurface(font16x16_bmp); |
| 1225 | } |
| 1226 | if (ttf8) { |
| 1227 | TTF_CloseFont(ttf8); |
| 1228 | } |
| 1229 | if (ttf12) { |
| 1230 | TTF_CloseFont(ttf12); |
| 1231 | } |
| 1232 | if (ttf16) { |
| 1233 | TTF_CloseFont(ttf16); |
| 1234 | } |
| 1235 | |
| 1236 | printlog("freeing ui resources...\n"); |
| 1237 | Text::dumpCache(); |
| 1238 | Image::dumpCache(); |
| 1239 | Font::dumpCache(); |
| 1240 | Frame::guiDestroy(); |
| 1241 | destroyTileTextures(); |
| 1242 | |
| 1243 | printlog("freeing map data...\n"); |
| 1244 | if (map.entities != nullptr) { |
| 1245 | list_FreeAll(map.entities); |
| 1246 | free(map.entities); |
| 1247 | } |
| 1248 | if (map.creatures != nullptr) { |
| 1249 | list_FreeAll(map.creatures); //TODO: Need to call this? Entities are only pointed to by the thing, not owned. |
| 1250 | delete map.creatures; |
| 1251 | } |
| 1252 | if (map.worldUI != nullptr) { |
| 1253 | list_FreeAll(map.worldUI); |
| 1254 | delete map.worldUI; |
| 1255 | } |
| 1256 | list_FreeAll(&light_l); |
| 1257 | if (map.tiles != nullptr) { |
| 1258 | free(map.tiles); |
| 1259 | } |
| 1260 | #ifdef EDITOR |
| 1261 | if (camera.vismap != nullptr) { |
no test coverage detected