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>
102 Report(
"Shutting down...");
166 for (
size_t i = 0; i <
engines.size(); i++)
206 Report(
"Deleting all engines...");
207 for (
size_t i = 0; i <
engines.size(); i++)
221 for (
size_t i = 0; i <
engines.size(); i++)
225 if (
engines[i]->IsCameraActive() ==
true)
249 if (engine->
IsLoading() ==
true && force ==
false)
253 bool state_set =
false;
258 if (switch_engines ==
true)
275 if (switch_engines ==
true && state_set ==
true)
295 for (
size_t i = 0; i <
engines.size(); i++)
310 if (
engines[i - 1]->IsLoading() ==
true &&
engines[i - 1]->IsLoadingFinished() ==
false)
315 if (
engines[i]->IsLoadingFinished() ==
false && run ==
true)
328 if (
engines[i]->IsLoadingFinished() ==
true)
341 newengines.emplace_back(
engines[i]);
347 if (
engines[i]->NewEngine ==
true)
349 newengines.emplace_back(
engines[i]);
362 for (
size_t i = 0; i <
engines.size(); i++)
366 if (
engines[i]->IsLoading() ==
true &&
engines[i]->IsLoadingFinished() ==
false)
377 bool deleted =
false;
379 for (
size_t i = 0; i <
engines.size(); i++)
384 if (
engines[i]->GetShutdownState() ==
true)
399 if (deleted ==
true &&
engines.size() > 0)
415 for (
size_t i = 0; i <
engines.size(); i++)
419 if (
engines[i]->Reload ==
true)
442 if (number < 0 || number >= (
int)
engines.size())
454 for (
size_t i = 0; i <
engines.size(); i++)
458 if (loading_only ==
true)
460 if (
engines[i]->IsLoading() ==
true)
486 if (
parent->IsInside() ==
true &&
parent->IsCameraActive() ==
false &&
parent->Paused ==
false)
494 Report(
"Searching for engine to attach to...");
495 for (
size_t i = 0; i <
engines.size(); i++)
499 if (
engines[i]->IsInside() ==
true &&
engines[i]->IsCameraActive() ==
false &&
engines[i]->Paused ==
false)
519 for (
size_t i = 0; i <
engines.size(); i++)
534 for (
size_t i = 0; i <
engines.size(); i++)
538 if (
engines[i]->GetSystem() == sbs)
549 for (
size_t i = 0; i <
engines.size(); i++)
563 if (number < (
int)
engines.size())
578 for (
size_t i = 0; i <
engines.size(); i++)
600 Report(
"Initiating engine start");
601 return engine->
Start(cameras);
622int VM::Run(std::vector<EngineContext*> &newengines)
642 if (newengines.size() > 0)
652 Report(
"Unloading due to shutdown request");
674 Report(
"Unloading to menu...");
710 Report(
"Loading engine for building file '" + filename +
"'...");
720 bool result = engine->
Load(filename);
791#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
800 size_t osversion_len =
sizeof(osversion) - 1;
801 int osversion_name[] = { CTL_KERN, KERN_OSRELEASE };
803 if (sysctl(osversion_name, 2, osversion, &osversion_len, NULL, 0) == -1) {
804 printf(
"get_macos_version: sysctl() failed\n");
808 if (sscanf(osversion,
"%u.%u", &major, &minor) != 2) {
809 printf(
"get_macos_version: sscanf() failed\n");
830#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_32
833#if OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64
837#if OGRE_CPU == OGRE_CPU_X86
839#elif OGRE_CPU == OGRE_CPU_PPC
841#elif OGRE_CPU == OGRE_CPU_ARM
843#elif OGRE_CPU == OGRE_CPU_MIPS
845#elif OGRE_CPU == OGRE_CPU_UNKNOWN
849#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
851#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
857#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
861#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
863 uint32_t major = 0, minor = 0;
881#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
884 NTSTATUS(WINAPI* RtlGetVersion)(LPOSVERSIONINFOEXW);
885 OSVERSIONINFOEXW osInfo;
887 *(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA(
"ntdll"),
"RtlGetVersion");
889 if (NULL != RtlGetVersion)
891 osInfo.dwOSVersionInfoSize =
sizeof(osInfo);
892 RtlGetVersion(&osInfo);
893 GetHAL()->
Report(
"Running on Microsoft Windows " +
ToString((
int)osInfo.dwMajorVersion) +
"." +
ToString((
int)osInfo.dwMinorVersion),
"");
897#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
898 struct utsname osInfo{};
901 GetHAL()->
Report(
"Running on FreeBSD " + std::string(osInfo.release),
"");
903 GetHAL()->
Report(
"Running on Linux " + std::string(osInfo.release),
"");
920 int current_percent = 0;
928 int final = ((
Real)current_percent / (
Real)total_percent) * 100;
971 for (
int i = 0; i <
engines.size(); i++)
974 engines[i]->GetSystem()->RenderOnStartup = value;
994 if (instance >=
engines.size())
996 return engines[instance]->time_stat;
1003 Report(
"Listing playing sounds in all engines");
1004 for (
size_t i = 0; i <
engines.size(); i++)
1024int VM::GetGlobalStats(
int &meshes,
int &textures,
int &actions,
int &sounds,
int &objects,
int &walls,
int &polygons)
1035 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)
std::string version_state
int Run(std::vector< EngineContext * > &newengine)
SkySystem * GetSkySystem()
unsigned long current_time
void Report(const std::string &message)
void SetParent(wxWindow *parent)
int GetGlobalStats(int &meshes, int &textures, int &actions, int &sounds, int &objects, int &walls, int &polygons)
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)