Clean up TCOD_sys_save_screenshot function.
@@ -836,19 +836,18 @@ void TCOD_sys_save_bitmap(void *bitmap, const char *filename) {
void TCOD_sys_save_screenshot(const char *filename) {
char buf[128];
- if ( filename == NULL ) {
- /* generate filename */
int idx = 0;
- do {
- FILE *f=NULL;
+ while (!filename) {
+ /* generate filename */
+ FILE *access_file = NULL;
sprintf(buf, "./screenshot%03d.png", idx);
- f=fopen(buf,"rb");
- if ( ! f ) filename=buf;
- else {
+ access_file = fopen(buf, "rb");
+ if (!access_file) {
+ filename = buf;
+ } else {
idx++;
- fclose(f);
+ fclose(access_file);
}
- } while(!filename);
}
sdl->save_screenshot(filename);
}
