Cleanup: ScanContext dispensed by scan.c
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3340 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -134,29 +134,14 @@ GenerateChmmr_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
|
|||||||
else if (matchWorld (solarSys, world, 1, 0))
|
else if (matchWorld (solarSys, world, 1, 0))
|
||||||
{
|
{
|
||||||
/* Starbase */
|
/* Starbase */
|
||||||
RECT r;
|
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
|
|
||||||
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
|
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
|
||||||
solarSys->SysInfo.PlanetInfo.DiscoveryString =
|
solarSys->SysInfo.PlanetInfo.DiscoveryString =
|
||||||
CaptureStringTable (LoadStringTable (CHMMR_BASE_STRTAB));
|
CaptureStringTable (LoadStringTable (CHMMR_BASE_STRTAB));
|
||||||
|
|
||||||
ScanContext = CreateContext ("genchmmr.ScanContext");
|
|
||||||
SetContext (ScanContext);
|
|
||||||
SetContextFGFrame (Screen);
|
|
||||||
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
|
|
||||||
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
|
|
||||||
r.extent.width = MAP_WIDTH;
|
|
||||||
r.extent.height = MAP_HEIGHT;
|
|
||||||
SetContextClipRect (&r);
|
|
||||||
|
|
||||||
DoDiscoveryReport (MenuSounds);
|
DoDiscoveryReport (MenuSounds);
|
||||||
|
|
||||||
SetContext (SpaceContext);
|
|
||||||
DestroyContext (ScanContext);
|
|
||||||
ScanContext = 0;
|
|
||||||
|
|
||||||
DestroyStringTable (ReleaseStringTable (
|
DestroyStringTable (ReleaseStringTable (
|
||||||
solarSys->SysInfo.PlanetInfo.DiscoveryString));
|
solarSys->SysInfo.PlanetInfo.DiscoveryString));
|
||||||
solarSys->SysInfo.PlanetInfo.DiscoveryString = 0;
|
solarSys->SysInfo.PlanetInfo.DiscoveryString = 0;
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ extern LanderInputState *pLanderInputState;
|
|||||||
// a function call instead.
|
// a function call instead.
|
||||||
|
|
||||||
|
|
||||||
extern CONTEXT ScanContext;
|
|
||||||
extern MUSIC_REF LanderMusic;
|
extern MUSIC_REF LanderMusic;
|
||||||
|
|
||||||
extern void PlanetSide (POINT planetLoc);
|
extern void PlanetSide (POINT planetLoc);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lander.h"
|
#include "lander.h"
|
||||||
|
#include "scan.h"
|
||||||
#include "planets.h"
|
#include "planets.h"
|
||||||
#include "../colors.h"
|
#include "../colors.h"
|
||||||
#include "../controls.h"
|
#include "../controls.h"
|
||||||
@@ -245,13 +246,16 @@ void
|
|||||||
DoDiscoveryReport (SOUND ReadOutSounds)
|
DoDiscoveryReport (SOUND ReadOutSounds)
|
||||||
{
|
{
|
||||||
CONTEXT OldContext;
|
CONTEXT OldContext;
|
||||||
|
CONTEXT context;
|
||||||
|
BOOLEAN ownContext;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (disableInteractivity)
|
if (disableInteractivity)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OldContext = SetContext (ScanContext);
|
context = GetScanContext (&ownContext);
|
||||||
|
OldContext = SetContext (context);
|
||||||
{
|
{
|
||||||
FONT OldFont;
|
FONT OldFont;
|
||||||
FRAME OldFontEffect;
|
FRAME OldFontEffect;
|
||||||
@@ -280,6 +284,9 @@ DoDiscoveryReport (SOUND ReadOutSounds)
|
|||||||
ClearDrawable ();
|
ClearDrawable ();
|
||||||
#endif /* OLD */
|
#endif /* OLD */
|
||||||
SetContext (OldContext);
|
SetContext (OldContext);
|
||||||
|
// TODO: Make CONTEXT ref-counted
|
||||||
|
if (ownContext)
|
||||||
|
DestroyContext (context);
|
||||||
|
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
FlushInput ();
|
FlushInput ();
|
||||||
|
|||||||
+41
-13
@@ -50,8 +50,7 @@ extern FRAME SpaceJunkFrame;
|
|||||||
|
|
||||||
#define FLASH_INDEX 105
|
#define FLASH_INDEX 105
|
||||||
|
|
||||||
// TODO: this will become static once genchmmr.c declares its own CONTEXT
|
static CONTEXT ScanContext;
|
||||||
CONTEXT ScanContext;
|
|
||||||
|
|
||||||
static POINT planetLoc;
|
static POINT planetLoc;
|
||||||
static RECT cursorRect;
|
static RECT cursorRect;
|
||||||
@@ -1168,10 +1167,47 @@ DoScan (MENU_STATE *pMS)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CONTEXT
|
||||||
|
CreateScanContext (void)
|
||||||
|
{
|
||||||
|
CONTEXT oldContext;
|
||||||
|
CONTEXT context;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
|
context = CreateContext ("ScanContext");
|
||||||
|
oldContext = SetContext (context);
|
||||||
|
|
||||||
|
SetContextFGFrame (Screen);
|
||||||
|
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
|
||||||
|
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
|
||||||
|
r.extent.width = MAP_WIDTH;
|
||||||
|
r.extent.height = MAP_HEIGHT;
|
||||||
|
SetContextClipRect (&r);
|
||||||
|
|
||||||
|
SetContext (oldContext);
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
CONTEXT
|
||||||
|
GetScanContext (BOOLEAN *owner)
|
||||||
|
{
|
||||||
|
// TODO: Make CONTEXT ref-counted
|
||||||
|
if (ScanContext)
|
||||||
|
{
|
||||||
|
*owner = FALSE;
|
||||||
|
return ScanContext;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*owner = TRUE;
|
||||||
|
return CreateScanContext ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ScanSystem (void)
|
ScanSystem (void)
|
||||||
{
|
{
|
||||||
RECT r;
|
|
||||||
MENU_STATE MenuState;
|
MENU_STATE MenuState;
|
||||||
|
|
||||||
MenuState.InputFunc = DoScan;
|
MenuState.InputFunc = DoScan;
|
||||||
@@ -1210,17 +1246,9 @@ ScanSystem (void)
|
|||||||
planetLoc.y = (MAP_HEIGHT >> 1) << MAG_SHIFT;
|
planetLoc.y = (MAP_HEIGHT >> 1) << MAG_SHIFT;
|
||||||
|
|
||||||
LockMutex (GraphicsLock);
|
LockMutex (GraphicsLock);
|
||||||
ScanContext = CreateContext ("ScanContext");
|
|
||||||
SetContext (ScanContext);
|
|
||||||
|
|
||||||
initPlanetLocationImage ();
|
initPlanetLocationImage ();
|
||||||
|
ScanContext = CreateScanContext ();
|
||||||
SetContextFGFrame (Screen);
|
SetContext (ScanContext);
|
||||||
r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH;
|
|
||||||
r.corner.y = (SIS_ORG_Y + SIS_SCREEN_HEIGHT) - MAP_HEIGHT;
|
|
||||||
r.extent.width = MAP_WIDTH;
|
|
||||||
r.extent.height = MAP_HEIGHT;
|
|
||||||
SetContextClipRect (&r);
|
|
||||||
DrawScannedObjects (FALSE);
|
DrawScannedObjects (FALSE);
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ extern bool callGenerateForScanType (SOLARSYS_STATE *solarSys,
|
|||||||
PLANET_DESC *world, COUNT *node, BYTE scanType);
|
PLANET_DESC *world, COUNT *node, BYTE scanType);
|
||||||
|
|
||||||
extern void RedrawSurfaceScan (const POINT *newLoc);
|
extern void RedrawSurfaceScan (const POINT *newLoc);
|
||||||
|
extern CONTEXT GetScanContext (BOOLEAN *owner);
|
||||||
|
|
||||||
bool isNodeRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr);
|
bool isNodeRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr);
|
||||||
void setNodeRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr);
|
void setNodeRetrieved (PLANET_INFO *planetInfo, BYTE scanType, BYTE nodeNr);
|
||||||
|
|||||||
Reference in New Issue
Block a user