23#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
24#include <sys/sysctl.h>
26#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
29#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
30#include <sys/utsname.h>
96 Report(
"Shutting down...");
160 for (
size_t i = 0; i <
engines.size(); i++)
200 Report(
"Deleting all engines...");
201 for (
size_t i = 0; i <
engines.size(); i++)
215 for (
size_t i = 0; i <
engines.size(); i++)
219 if (
engines[i]->IsCameraActive() ==
true)
243 if (engine->
IsLoading() ==
true && force ==
false)
247 bool state_set =
false;
252 if (switch_engines ==
true)
269 if (switch_engines ==
true && state_set ==
true)
289 for (
size_t i = 0; i <
engines.size(); i++)
304 if (
engines[i - 1]->IsLoading() ==
true &&
engines[i - 1]->IsLoadingFinished() ==
false)
309 if (
engines[i]->IsLoadingFinished() ==
false && run ==
true)
322 if (
engines[i]->IsLoadingFinished() ==
true)
335 newengines.emplace_back(
engines[i]);
341 if (
engines[i]->NewEngine ==
true)
343 newengines.emplace_back(
engines[i]);
356 for (
size_t i = 0; i <
engines.size(); i++)
360 if (
engines[i]->IsLoading() ==
true &&
engines[i]->IsLoadingFinished() ==
false)
371 bool deleted =
false;
373 for (
size_t i = 0; i <
engines.size(); i++)
378 if (
engines[i]->GetShutdownState() ==
true)
409 for (
size_t i = 0; i <
engines.size(); i++)
413 if (
engines[i]->Reload ==
true)
436 if (number < 0 || number >= (
int)
engines.size())
448 for (
size_t i = 0; i <
engines.size(); i++)
452 if (loading_only ==
true)
454 if (
engines[i]->IsLoading() ==
true)
480 if (
parent->IsInside() ==
true &&
parent->IsCameraActive() ==
false)
488 Report(
"Searching for engine to attach to...");
489 for (
size_t i = 0; i <
engines.size(); i++)
493 if (
engines[i]->IsInside() ==
true &&
engines[i]->IsCameraActive() ==
false)
513 for (
size_t i = 0; i <
engines.size(); i++)
528 for (
size_t i = 0; i <
engines.size(); i++)
532 if (
engines[i]->GetSystem() == sbs)
543 for (
size_t i = 0; i <
engines.size(); i++)
557 if (number < (
int)
engines.size())
572 for (
size_t i = 0; i <
engines.size(); i++)
594 Report(
"Initiating engine start");
595 return engine->
Start(cameras);
616int VM::Run(std::vector<EngineContext*> &newengines)
636 if (newengines.size() > 0)
646 Report(
"Unloading due to shutdown request");
668 Report(
"Unloading to menu...");
704 Report(
"Loading engine for building file '" + filename +
"'...");
714 bool result = engine->
Load(filename);
785#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
794 size_t osversion_len =
sizeof(osversion) - 1;
795 int osversion_name[] = { CTL_KERN, KERN_OSRELEASE };
797 if (sysctl(osversion_name, 2, osversion, &osversion_len, NULL, 0) == -1) {
798 printf(
"get_macos_version: sysctl() failed\n");
802 if (sscanf(osversion,
"%u.%u", &major, &minor) != 2) {
803 printf(
"get_macos_version: sscanf() failed\n");
824#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32
827#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64
831#if OGRE_CPU == OGRE_CPU_X86
833#elif OGRE_CPU == OGRE_CPU_PPC
835#elif OGRE_CPU == OGRE_CPU_ARM
837#elif OGRE_CPU == OGRE_CPU_MIPS
839#elif OGRE_CPU == OGRE_CPU_UNKNOWN
843#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
845#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
851#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
855#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
857 uint32_t major = 0, minor = 0;
875#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
878 NTSTATUS(WINAPI* RtlGetVersion)(LPOSVERSIONINFOEXW);
879 OSVERSIONINFOEXW osInfo;
881 *(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA(
"ntdll"),
"RtlGetVersion");
883 if (NULL != RtlGetVersion)
885 osInfo.dwOSVersionInfoSize =
sizeof(osInfo);
886 RtlGetVersion(&osInfo);
887 GetHAL()->
Report(
"Running on Microsoft Windows " +
ToString((
int)osInfo.dwMajorVersion) +
"." +
ToString((
int)osInfo.dwMinorVersion),
"");
891#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
892 struct utsname osInfo{};
895 GetHAL()->
Report(
"Running on FreeBSD " + std::string(osInfo.release),
"");
897 GetHAL()->
Report(
"Running on Linux " + std::string(osInfo.release),
"");
914 int current_percent = 0;
922 int final = ((
Real)current_percent / (
Real)total_percent) * 100;
965 for (
int i = 0; i <
engines.size(); i++)
968 engines[i]->GetSystem()->RenderOnStartup = value;
988 if (instance >=
engines.size())
990 return engines[instance]->time_stat;
997 for (
size_t i = 0; i <
engines.size(); i++)
SoundSystem * GetSoundSystem()
void ShowPlayingSounds(bool verbose=true)
void DetachCamera(bool reset_building=false)
void SetCameraState(const ::SBS::CameraState &state, bool set_floor=true)
ScriptProcessor * GetScriptProcessor()
void AttachCamera(std::vector< Ogre::Camera * > &cameras, bool init_state=true)
bool Start(std::vector< Ogre::Camera * > &cameras)
EngineContext * GetParent()
::SBS::CameraState GetCameraState()
bool Load(std::string filename)
bool UpdateProgress(int percent)
bool ReportMissingFiles(std::vector< std::string > &missing_files)
bool ReportFatalError(const std::string &message, const std::string &prompt)
std::string GetConfigString(Ogre::ConfigFile *file, const std::string &key, const std::string &default_value)
Ogre::RenderWindow * GetRenderWindow()
unsigned long GetCurrentTime()
Ogre::SceneManager * GetSceneManager()
std::vector< Ogre::Camera * > mCameras
void Report(const std::string &message, const std::string &prompt)
bool ReportError(const std::string &message, const std::string &prompt)
FMOD::System * GetSoundSystem()
Ogre::ConfigFile * configfile
void CreateSky(EngineContext *engine)
void Process(const std::string &text="", bool echo=true)
EngineContext * FindActiveEngine()
bool IsValidEngine(EngineContext *engine)
int GetFreeInstanceNumber()
EngineContext * GetFirstValidEngine()
bool StartEngine(EngineContext *engine, std::vector< Ogre::Camera * > &cameras)
::SBS::SBS * GetActiveSystem()
void SetActiveEngine(int number, bool switch_engines=false, bool force=false)
void HandleEngineShutdown()
int RegisterEngine(EngineContext *engine)
int GetEngineCount(bool loading_only=false)
bool GetRenderOnStartup()
EngineContext * Initialize(bool clear, EngineContext *parent=0, const Vector3 &position=Vector3::ZERO, Real rotation=0.0, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
bool IsValidSystem(::SBS::SBS *sbs)
bool DeleteEngine(EngineContext *engine)
unsigned long GetElapsedTime(int instance)
EngineContext * active_engine
bool Load(bool clear, const std::string &filename, EngineContext *parent=0, const Vector3 &position=Vector3::ZERO, Real rotation=0.0, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
bool RunEngines(std::vector< EngineContext * > &newengines)
bool ReportMissingFiles(std::vector< std::string > &missing_files)
int Run(std::vector< EngineContext * > &newengine)
SkySystem * GetSkySystem()
unsigned long current_time
void Report(const std::string &message)
void SetParent(wxWindow *parent)
ScriptProcessor * GetActiveScriptProcessor()
EngineContext * GetActiveEngine()
bool ReportError(const std::string &message)
bool ReportFatalError(const std::string &message)
EngineContext * GetEngine(int number)
EngineContext * CreateEngine(EngineContext *parent=0, const Vector3 &position=Vector3::ZERO, Real rotation=0.0, const Vector3 &area_min=Vector3::ZERO, const Vector3 &area_max=Vector3::ZERO)
void SetRenderOnStartup(bool value)
std::vector< EngineContext * > engines
std::string ToString(int number)
int get_macos_version(uint32_t &major, uint32_t &minor, bool &osx)
#define SBS_PROFILE_MAIN(name)