/* How to use: 1) #include "debug_imgtrack.vc" at the very top of your system.vc. 2) If at any point during the program you want to dump the current state of images, run the function dbg_ImageReport(). 3) The report will automatically be run when exit() is called to give a final tally. */ #define DEBUG_MAXIMAGETRACK 20000 //if you get an error about this number being too small, increase it. The bigger it gets, the slower the game will run. int nVerbose = 0; //controls if the log will show all images, or just unfreeded images struct debug_imagetrack { string sFilename; int nHandle; int bFreed; int bUsed; } debug_imagetrack dbg_images[DEBUG_MAXIMAGETRACK]; /* Functions to macro over NewImage(int, int) LoadImage(string) LoadImage0(string) DuplicateImage(int) FreeImage(int) */ int dbg_NewImage(int width, int height) { return dbg_ImageAdd(NewImage(width, height), "NewImage(" + str(width) + ", " + str(height) + ")"); } int dbg_LoadImage(string filename) { return dbg_ImageAdd(LoadImage(filename), filename); } int dbg_LoadImage0(string filename) { return dbg_ImageAdd(LoadImage0(filename), filename); } int dbg_DuplicateImage(int hndl) { return dbg_ImageAdd(DuplicateImage(hndl), "DuplicateImage(" + str(hndl) + ")"); } void dbg_FreeImage(int hndl) { dbg_images[dbg_FindImage(hndl)].bFreed = 1; FreeImage(hndl); } int dbg_ImageAdd(int hndl, string filename) { //adds a new item at the end of the array, keeping track of the hndl and filename int i; for(i=0;i=0;i--) { if(dbg_images[i].bUsed == 1 && dbg_images[i].nHandle == hndl) return i; } Messagebox("debug_imgtrack.vc::FindImage() couldn't find " + str(hndl)); return 0; } void dbg_ImageReport() { int i; Log(""); Log("Image Report Start"); for(i=0;i