Cleanup colormaps upon exiting the game; bug #1149
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3765 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -64,6 +64,10 @@ static int mapcount;
|
|||||||
static Mutex maplock;
|
static Mutex maplock;
|
||||||
|
|
||||||
|
|
||||||
|
static void release_colormap (TFB_ColorMap *map);
|
||||||
|
static void delete_colormap (TFB_ColorMap *map);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InitColorMaps (void)
|
InitColorMaps (void)
|
||||||
{
|
{
|
||||||
@@ -84,13 +88,23 @@ InitColorMaps (void)
|
|||||||
void
|
void
|
||||||
UninitColorMaps (void)
|
UninitColorMaps (void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
TFB_ColorMap *next;
|
TFB_ColorMap *next;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_COLORMAPS; ++i)
|
||||||
|
{
|
||||||
|
TFB_ColorMap *map = colormaps[i];
|
||||||
|
if (!map)
|
||||||
|
continue;
|
||||||
|
release_colormap (map);
|
||||||
|
colormaps[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// free spares
|
// free spares
|
||||||
for ( ; poolhead; poolhead = next)
|
for ( ; poolhead; poolhead = next, --poolcount)
|
||||||
{
|
{
|
||||||
next = poolhead->next;
|
next = poolhead->next;
|
||||||
HFree (poolhead);
|
delete_colormap (poolhead);
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyMutex (fadeLock);
|
DestroyMutex (fadeLock);
|
||||||
@@ -155,6 +169,13 @@ clone_colormap (TFB_ColorMap *from, int index)
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_colormap (TFB_ColorMap *map)
|
||||||
|
{
|
||||||
|
FreeNativePalette (map->palette);
|
||||||
|
HFree (map);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
free_colormap (TFB_ColorMap *map)
|
free_colormap (TFB_ColorMap *map)
|
||||||
{
|
{
|
||||||
@@ -172,8 +193,7 @@ free_colormap (TFB_ColorMap *map)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // don't need any more spares
|
{ // don't need any more spares
|
||||||
FreeNativePalette (map->palette);
|
delete_colormap (map);
|
||||||
HFree (map);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +213,7 @@ get_colormap (int index)
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static void
|
||||||
release_colormap (TFB_ColorMap *map)
|
release_colormap (TFB_ColorMap *map)
|
||||||
{
|
{
|
||||||
if (!map)
|
if (!map)
|
||||||
|
|||||||
@@ -635,6 +635,13 @@ TFB_PurgeDanglingGraphics (void)
|
|||||||
HFree (data);
|
HFree (data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case TFB_DRAWCOMMANDTYPE_IMAGE:
|
||||||
|
{
|
||||||
|
TFB_ColorMap *cmap = DC.data.image.colormap;
|
||||||
|
if (cmap)
|
||||||
|
TFB_ReturnColorMap (cmap);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TFB_DRAWCOMMANDTYPE_SENDSIGNAL:
|
case TFB_DRAWCOMMANDTYPE_SENDSIGNAL:
|
||||||
{
|
{
|
||||||
ClearSemaphore (DC.data.sendsignal.sem);
|
ClearSemaphore (DC.data.sendsignal.sem);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ UnbatchGraphics (void)
|
|||||||
been processed. */
|
been processed. */
|
||||||
|
|
||||||
void
|
void
|
||||||
FlushGraphics ()
|
FlushGraphics (void)
|
||||||
{
|
{
|
||||||
TFB_DrawScreen_WaitForSignal ();
|
TFB_DrawScreen_WaitForSignal ();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -467,9 +467,10 @@ main (int argc, char *argv[])
|
|||||||
// Not yet: TFB_UninitInput ();
|
// Not yet: TFB_UninitInput ();
|
||||||
unInitAudio ();
|
unInitAudio ();
|
||||||
uninit_communication ();
|
uninit_communication ();
|
||||||
UninitColorMaps ();
|
|
||||||
// TODO: Merge into TFB_UninitGraphics when it goes live
|
// TODO: Merge into TFB_UninitGraphics when it goes live
|
||||||
TFB_PurgeDanglingGraphics ();
|
TFB_PurgeDanglingGraphics ();
|
||||||
|
// Purge above refers to colormaps which have to be still up
|
||||||
|
UninitColorMaps ();
|
||||||
// Not yet: TFB_UninitGraphics ();
|
// Not yet: TFB_UninitGraphics ();
|
||||||
|
|
||||||
#ifdef NETPLAY
|
#ifdef NETPLAY
|
||||||
|
|||||||
Reference in New Issue
Block a user