Move some initialization code from src/ into lib/framework
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3353 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
2e76e8d1f9
commit
eddebc7f81
|
@ -186,6 +186,20 @@ void debug_init(void)
|
|||
{
|
||||
int count = 0;
|
||||
|
||||
/*** Initialize the debug subsystem ***/
|
||||
#if defined(WZ_CC_MSVC) && defined(DEBUG)
|
||||
int tmpDbgFlag;
|
||||
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG ); // Output CRT info to debugger
|
||||
|
||||
tmpDbgFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // Grab current flags
|
||||
# if defined(DEBUG_MEMORY)
|
||||
tmpDbgFlag |= _CRTDBG_CHECK_ALWAYS_DF; // Check every (de)allocation
|
||||
# endif // DEBUG_MEMORY
|
||||
tmpDbgFlag |= _CRTDBG_ALLOC_MEM_DF; // Check allocations
|
||||
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF; // Check for memleaks
|
||||
_CrtSetDbgFlag( tmpDbgFlag );
|
||||
#endif // WZ_CC_MSVC && DEBUG
|
||||
|
||||
while (strcmp(code_part_names[count], "last") != 0) {
|
||||
count++;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "frameint.h"
|
||||
#include "frameresource.h"
|
||||
#include "input.h"
|
||||
#include "SDL_framerate.h"
|
||||
|
||||
#include "fractions.h"
|
||||
#include <assert.h>
|
||||
|
@ -84,6 +85,18 @@ static Uint64 curFrames = 0; // Number of frames elapsed since start
|
|||
static Uint64 lastFrames = 0;
|
||||
static Uint32 curTicks = 0; // Number of ticks since execution started
|
||||
static Uint32 lastTicks = 0;
|
||||
static FPSmanager wzFPSmanager;
|
||||
|
||||
void setFramerateLimit(int fpsLimit)
|
||||
{
|
||||
SDL_setFramerate(&wzFPSmanager, fpsLimit);
|
||||
}
|
||||
|
||||
|
||||
int getFramerateLimit(void)
|
||||
{
|
||||
return SDL_getFramerate(&wzFPSmanager);
|
||||
}
|
||||
|
||||
/* InitFrameStuff - needs to be called once before frame loop commences */
|
||||
static void InitFrameStuff( void )
|
||||
|
@ -223,14 +236,17 @@ BOOL frameInitialise(
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* initialise all cursors */
|
||||
initCursors();
|
||||
/* initialise all cursors */
|
||||
initCursors();
|
||||
|
||||
/* Initialise the Direct Draw Buffers */
|
||||
if (!screenInitialise(width, height, bitDepth, fullScreen))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
/* Initialise the Direct Draw Buffers */
|
||||
if (!screenInitialise(width, height, bitDepth, fullScreen))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Initialize framerate handler */
|
||||
SDL_initFramerate( &wzFPSmanager );
|
||||
|
||||
/* Initialise the input system */
|
||||
inputInitialise();
|
||||
|
@ -257,6 +273,8 @@ void frameUpdate(void)
|
|||
|
||||
/* Update the frame rate stuff */
|
||||
MaintainFrameStuff();
|
||||
|
||||
SDL_framerateDelay(&wzFPSmanager);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -79,13 +79,25 @@ extern BOOL frameInitialise(
|
|||
*/
|
||||
extern void frameShutDown(void);
|
||||
|
||||
|
||||
typedef enum _focus_state
|
||||
{
|
||||
FOCUS_OUT, // Window does not have the focus
|
||||
FOCUS_IN, // Window has got the focus
|
||||
} FOCUS_STATE;
|
||||
|
||||
/*!
|
||||
* Set the framerate limit
|
||||
*
|
||||
* \param fpsLimit Desired framerate
|
||||
*/
|
||||
extern void setFramerateLimit(int fpsLimit);
|
||||
|
||||
/*!
|
||||
* Get the framerate limit
|
||||
*
|
||||
* \return Desired framerate
|
||||
*/
|
||||
extern int getFramerateLimit(void);
|
||||
|
||||
/** Call this each cycle to allow the framework to deal with
|
||||
* windows messages, and do general house keeping.
|
||||
|
|
|
@ -37,22 +37,6 @@ extern bool ParseCommandLineEarly(int argc, const char** argv);
|
|||
|
||||
extern BOOL bAllowDebugMode;
|
||||
|
||||
// FIXME The following does not belong here:
|
||||
|
||||
/*!
|
||||
* Set the framerate limit
|
||||
*
|
||||
* \param fpsLimit Desired framerate
|
||||
*/
|
||||
extern void setFramerateLimit(int fpsLimit);
|
||||
|
||||
/*!
|
||||
* Get the framerate limit
|
||||
*
|
||||
* \return Desired framerate
|
||||
*/
|
||||
extern int getFramerateLimit(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
35
src/main.c
35
src/main.c
|
@ -38,7 +38,6 @@
|
|||
|
||||
#include "lib/framework/configfile.h"
|
||||
#include "lib/framework/input.h"
|
||||
#include "lib/framework/SDL_framerate.h"
|
||||
#include "lib/framework/tagfile.h"
|
||||
|
||||
#include "lib/gamelib/gtime.h"
|
||||
|
@ -105,8 +104,6 @@ char MultiPlayersPath[PATH_MAX];
|
|||
char KeyMapPath[PATH_MAX];
|
||||
char UserMusicPath[PATH_MAX];
|
||||
|
||||
static FPSmanager wzFPSmanager;
|
||||
|
||||
// Start game in title mode:
|
||||
static GS_GAMEMODE gameStatus = GS_TITLE_SCREEN;
|
||||
// Status of the gameloop
|
||||
|
@ -116,19 +113,6 @@ extern FOCUS_STATE focusState;
|
|||
extern void debug_callback_stderr( void**, const char * );
|
||||
extern void debug_callback_win32debug( void**, const char * );
|
||||
|
||||
|
||||
void setFramerateLimit(int fpsLimit)
|
||||
{
|
||||
SDL_setFramerate( &wzFPSmanager, fpsLimit );
|
||||
}
|
||||
|
||||
|
||||
int getFramerateLimit(void)
|
||||
{
|
||||
return SDL_getFramerate( &wzFPSmanager );
|
||||
}
|
||||
|
||||
|
||||
static BOOL inList( char * list[], const char * item )
|
||||
{
|
||||
int i = 0;
|
||||
|
@ -752,8 +736,6 @@ static void mainLoop(void)
|
|||
|
||||
gameTimeUpdate(); // Update gametime. FIXME There is probably code duplicated with MaintainFrameStuff
|
||||
}
|
||||
|
||||
SDL_framerateDelay(&wzFPSmanager);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -763,20 +745,6 @@ int main(int argc, char *argv[])
|
|||
PIELIGHT *psPaletteBuffer = NULL;
|
||||
UDWORD pSize = 0;
|
||||
|
||||
/*** Initialize the debug subsystem ***/
|
||||
#if defined(WZ_CC_MSVC) && defined(DEBUG)
|
||||
int tmpDbgFlag;
|
||||
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG ); // Output CRT info to debugger
|
||||
|
||||
tmpDbgFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); // Grab current flags
|
||||
# if defined(DEBUG_MEMORY)
|
||||
tmpDbgFlag |= _CRTDBG_CHECK_ALWAYS_DF; // Check every (de)allocation
|
||||
# endif // DEBUG_MEMORY
|
||||
tmpDbgFlag |= _CRTDBG_ALLOC_MEM_DF; // Check allocations
|
||||
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF; // Check for memleaks
|
||||
_CrtSetDbgFlag( tmpDbgFlag );
|
||||
#endif // WZ_CC_MSVC && DEBUG
|
||||
|
||||
setupExceptionHandler(argv[0]);
|
||||
|
||||
debug_init();
|
||||
|
@ -835,9 +803,6 @@ int main(int argc, char *argv[])
|
|||
strlcpy(KeyMapPath, "keymap.map", sizeof(KeyMapPath));
|
||||
strlcpy(UserMusicPath, "music", sizeof(UserMusicPath));
|
||||
|
||||
/* Initialize framerate handler */
|
||||
SDL_initFramerate( &wzFPSmanager );
|
||||
|
||||
// initialise all the command line states
|
||||
war_SetDefaultStates();
|
||||
|
||||
|
|
Loading…
Reference in New Issue