forked from 0ad/0ad
acpi and mahaf: now set ModuleInitState to error if something fails (prevents a subsequent init from returning true and allowing its dependent to continue and crash into a wall)
wtime: "implement" CLOCK_MONOTONIC (that's what the timer already did, anyhow) main: move early init to GameSetup!EarlyInit (fixes atlas problem with timer) This was SVN commit r5101.
This commit is contained in:
parent
2348f71aea
commit
c9f10be090
@ -245,7 +245,10 @@ bool acpi_Init()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(!mahaf_Init())
|
if(!mahaf_Init())
|
||||||
|
{
|
||||||
|
ModuleSetError(&initState);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LatchAllTables();
|
LatchAllTables();
|
||||||
return true;
|
return true;
|
||||||
|
@ -261,7 +261,10 @@ bool mahaf_Init()
|
|||||||
DWORD shareMode = 0;
|
DWORD shareMode = 0;
|
||||||
hAken = CreateFile("\\\\.\\Aken", GENERIC_READ, shareMode, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
hAken = CreateFile("\\\\.\\Aken", GENERIC_READ, shareMode, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if(hAken == INVALID_HANDLE_VALUE)
|
if(hAken == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
ModuleSetError(&initState);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ static uint MsFromTimespec(const timespec& ts)
|
|||||||
|
|
||||||
int clock_gettime(clockid_t clock, struct timespec* ts)
|
int clock_gettime(clockid_t clock, struct timespec* ts)
|
||||||
{
|
{
|
||||||
debug_assert(clock == CLOCK_REALTIME);
|
debug_assert(clock == CLOCK_REALTIME || clock == CLOCK_MONOTONIC);
|
||||||
|
|
||||||
const i64 ns = CurrentSystemTime_ns();
|
const i64 ns = CurrentSystemTime_ns();
|
||||||
*ts = TimespecFromNs(ns);
|
*ts = TimespecFromNs(ns);
|
||||||
@ -120,7 +120,7 @@ int clock_gettime(clockid_t clock, struct timespec* ts)
|
|||||||
|
|
||||||
int clock_getres(clockid_t clock, struct timespec* ts)
|
int clock_getres(clockid_t clock, struct timespec* ts)
|
||||||
{
|
{
|
||||||
debug_assert(clock == CLOCK_REALTIME);
|
debug_assert(clock == CLOCK_REALTIME || clock == CLOCK_MONOTONIC);
|
||||||
|
|
||||||
const i64 ns = cpu_i64FromDouble(whrt_Resolution() * 1e9);
|
const i64 ns = cpu_i64FromDouble(whrt_Resolution() * 1e9);
|
||||||
*ts = TimespecFromNs(ns);
|
*ts = TimespecFromNs(ns);
|
||||||
|
@ -41,7 +41,11 @@ extern int usleep(useconds_t us);
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CLOCK_REALTIME
|
// in our implementation, these actually do the same thing
|
||||||
|
// (a timer that latches the system time at startup and uses the
|
||||||
|
// monotonic HRT to add elapsed time since then)
|
||||||
|
CLOCK_REALTIME,
|
||||||
|
CLOCK_MONOTONIC
|
||||||
}
|
}
|
||||||
clockid_t;
|
clockid_t;
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ that of Atlas depending on commandline parameters.
|
|||||||
#include "lib/precompiled.h"
|
#include "lib/precompiled.h"
|
||||||
|
|
||||||
#include "lib/input.h"
|
#include "lib/input.h"
|
||||||
#include "lib/external_libraries/sdl.h"
|
|
||||||
#include "lib/timer.h"
|
#include "lib/timer.h"
|
||||||
|
#include "lib/external_libraries/sdl.h"
|
||||||
#include "lib/res/file/vfs.h"
|
#include "lib/res/file/vfs.h"
|
||||||
#include "lib/res/sound/snd_mgr.h"
|
#include "lib/res/sound/snd_mgr.h"
|
||||||
#include "lib/res/file/vfs_optimizer.h"
|
#include "lib/res/file/vfs_optimizer.h"
|
||||||
@ -39,10 +39,6 @@ that of Atlas depending on commandline parameters.
|
|||||||
#include "sound/CMusicPlayer.h"
|
#include "sound/CMusicPlayer.h"
|
||||||
#include "gui/GUI.h"
|
#include "gui/GUI.h"
|
||||||
|
|
||||||
#if OS_WIN
|
|
||||||
# include "lib/sysdep/win/wstartup.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOG_CATEGORY "main"
|
#define LOG_CATEGORY "main"
|
||||||
|
|
||||||
extern bool g_TerrainModified;
|
extern bool g_TerrainModified;
|
||||||
@ -381,13 +377,7 @@ static void RunGameOrAtlas(int argc, char* argv[])
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// If you ever want to catch a particular allocation:
|
EarlyInit(); // must come at beginning of main
|
||||||
//_CrtSetBreakAlloc(321);
|
|
||||||
|
|
||||||
// see discussion at declaration of wstartup_PreMainInit.
|
|
||||||
#if OS_WIN
|
|
||||||
wstartup_PreMainInit();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RunGameOrAtlas(argc, argv);
|
RunGameOrAtlas(argc, argv);
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
#include "lib/res/sound/snd_mgr.h"
|
#include "lib/res/sound/snd_mgr.h"
|
||||||
#include "lib/res/graphics/tex.h"
|
#include "lib/res/graphics/tex.h"
|
||||||
#include "lib/res/graphics/cursor.h"
|
#include "lib/res/graphics/cursor.h"
|
||||||
|
#if OS_WIN
|
||||||
|
# include "lib/sysdep/win/wstartup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ps/CConsole.h"
|
#include "ps/CConsole.h"
|
||||||
#include "ps/CLogger.h"
|
#include "ps/CLogger.h"
|
||||||
@ -95,9 +98,6 @@ ERROR_TYPE(System, RequiredExtensionsMissing);
|
|||||||
#define LOG_CATEGORY "gamesetup"
|
#define LOG_CATEGORY "gamesetup"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
static int SetVideoMode(int w, int h, int bpp, bool fullscreen)
|
||||||
{
|
{
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
@ -876,22 +876,34 @@ void Shutdown(uint flags)
|
|||||||
TIMER_END("shutdown misc");
|
TIMER_END("shutdown misc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EarlyInit()
|
||||||
void Init(const CmdLineArgs& args, uint flags)
|
|
||||||
{
|
{
|
||||||
const bool setup_vmode = (flags & INIT_HAVE_VMODE) == 0;
|
#if OS_WIN
|
||||||
|
// see discussion at declaration of wstartup_PreMainInit.
|
||||||
|
wstartup_PreMainInit(); // must come before any use of lib/sysdep/win
|
||||||
|
#endif
|
||||||
|
|
||||||
MICROLOG(L"Init");
|
MICROLOG(L"EarlyInit");
|
||||||
|
|
||||||
|
// If you ever want to catch a particular allocation:
|
||||||
|
//_CrtSetBreakAlloc(321);
|
||||||
|
|
||||||
debug_set_thread_name("main");
|
debug_set_thread_name("main");
|
||||||
// add all debug_printf "tags" that we are interested in:
|
// add all debug_printf "tags" that we are interested in:
|
||||||
debug_filter_add("TIMER");
|
debug_filter_add("TIMER");
|
||||||
|
|
||||||
lockfree_Init();
|
lockfree_Init();
|
||||||
|
|
||||||
timer_Init();
|
timer_Init();
|
||||||
|
|
||||||
// Query CPU capabilities, possibly set some CPU-dependent flags
|
cpu_Init(); // must come after timer_Init
|
||||||
cpu_Init();
|
}
|
||||||
|
|
||||||
|
void Init(const CmdLineArgs& args, uint flags)
|
||||||
|
{
|
||||||
|
const bool setup_vmode = (flags & INIT_HAVE_VMODE) == 0;
|
||||||
|
|
||||||
|
MICROLOG(L"Init");
|
||||||
|
|
||||||
h_mgr_init();
|
h_mgr_init();
|
||||||
|
|
||||||
|
@ -18,6 +18,12 @@ extern void Render();
|
|||||||
extern void RenderActor();
|
extern void RenderActor();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize global modules that are be needed before Init.
|
||||||
|
* must be called from the very beginning of main.
|
||||||
|
**/
|
||||||
|
extern void EarlyInit();
|
||||||
|
|
||||||
enum InitFlags
|
enum InitFlags
|
||||||
{
|
{
|
||||||
// avoid setting a video mode / initializing OpenGL; assume that has
|
// avoid setting a video mode / initializing OpenGL; assume that has
|
||||||
|
Loading…
Reference in New Issue
Block a user