mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 06:24:32 +00:00
Core: tgaSave() should free memory passed in. SceneEditor: Add support for grid map dumping (in TGA format).
This allows reconstructing the map templates, which were never shipped with the game. This patch also fixes insane memory leaking when taking screenshots, or dumping screen frames.
This commit is contained in:
parent
a97629b52b
commit
d903e74bf6
4 changed files with 37 additions and 1 deletions
|
@ -4777,6 +4777,7 @@ int Core::tgaSave( const char *filename,
|
|||
// open file and check for errors
|
||||
file = fopen(adjustFilenameCase(filename).c_str(), "wb");
|
||||
if (file == NULL) {
|
||||
delete [] imageData;
|
||||
return (int)false;
|
||||
}
|
||||
|
||||
|
@ -4802,6 +4803,7 @@ int Core::tgaSave( const char *filename,
|
|||
|| fwrite(&cGarbage, sizeof(unsigned char), 1, file) != 1)
|
||||
{
|
||||
fclose(file);
|
||||
delete [] imageData;
|
||||
return (int)false;
|
||||
}
|
||||
|
||||
|
@ -4818,10 +4820,12 @@ int Core::tgaSave( const char *filename,
|
|||
width * height * mode, file) != width * height * mode)
|
||||
{
|
||||
fclose(file);
|
||||
delete [] imageData;
|
||||
return (int)false;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
delete [] imageData;
|
||||
|
||||
return (int)true;
|
||||
}
|
||||
|
|
|
@ -1310,6 +1310,9 @@ public:
|
|||
void pollEvents();
|
||||
|
||||
CoreSettings settings;
|
||||
|
||||
int tgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
||||
|
||||
protected:
|
||||
|
||||
std::string fpsDebugString;
|
||||
|
@ -1397,7 +1400,6 @@ protected:
|
|||
|
||||
|
||||
int tgaSaveSeries(char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
||||
int tgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
||||
virtual void onUpdate(float dt);
|
||||
virtual void onRender(){}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue