From e8bb25454e9650f16e1ab60754063b72b758605a Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Sat, 3 Feb 2018 17:37:46 +0100 Subject: [PATCH] pre-merge syncs --- Classes.h | 2 +- Console.cpp | 2 +- DynObj.cpp | 20 +------------------- EU07.cpp | 18 ++++++++---------- EvLaunch.cpp | 2 +- Event.cpp | 4 ++-- Event.h | 4 ---- Globals.cpp | 2 +- Model3d.cpp | 17 +++++++++-------- World.cpp | 5 ++--- dumb3d.h | 2 +- messaging.cpp | 24 +++++++++++++++++++----- mouseinput.cpp | 3 +-- openglgeometrybank.h | 2 +- openglmatrixstack.h | 2 +- scene.h | 4 ---- simulation.cpp | 10 ---------- simulation.h | 4 ---- stdafx.h | 6 +++--- utilities.cpp | 2 +- 20 files changed, 53 insertions(+), 82 deletions(-) diff --git a/Classes.h b/Classes.h index 51ceaa35..202ac2aa 100644 --- a/Classes.h +++ b/Classes.h @@ -27,8 +27,8 @@ class sound_source; class TEventLauncher; class TTraction; // drut class TTractionPowerSource; // zasilanie drutów -class TCamera; class TWorld; +class TCamera; class simulation_time; class TMoverParameters; diff --git a/Console.cpp b/Console.cpp index db6f2d1a..94712fa6 100644 --- a/Console.cpp +++ b/Console.cpp @@ -84,7 +84,7 @@ TKeyTrans Console::ktTable[4 * 256]; // Ra: bajer do migania LED-ami w klawiaturze void SetLedState( unsigned char Code, bool bOn ) { -#ifdef _WINDOWS +#ifdef _WIN32 if( bOn != ( ::GetKeyState( Code ) != 0 ) ) { keybd_event( Code, MapVirtualKey( Code, 0 ), KEYEVENTF_EXTENDEDKEY | 0, 0 ); keybd_event( Code, MapVirtualKey( Code, 0 ), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 ); diff --git a/DynObj.cpp b/DynObj.cpp index 4eda69ee..439a6bfc 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -3833,24 +3833,6 @@ void TDynamicObject::RenderSounds() { // special events if( MoverParameters->EventFlag ) { - // TODO: dedicated sound, played alongside regular noise - if( true == TestFlag( MoverParameters->DamageFlag, dtrain_wheelwear ) ) { -#ifdef EU07_USE_OLD_SOUNDCODE - if( rsOuterNoise.AM != 0 ) { - rsOuterNoise.Stop(); - float am = rsOuterNoise.AM; - float fa = rsOuterNoise.FA; - float fm = rsOuterNoise.FM; - rsOuterNoise.Init( "lomotpodkucia.wav", -1, 0, 0, 0, true ); // MC: zmiana szumu na lomot - if( rsOuterNoise.AM == 1 ) - rsOuterNoise.AM = am; - rsOuterNoise.AA = 0.7; - rsOuterNoise.FA = fa; - rsOuterNoise.FM = fm; - } -#else -#endif - } // McZapkie: w razie wykolejenia if( true == TestFlag( MoverParameters->DamageFlag, dtrain_out ) ) { if( GetVelocity() > 0 ) { @@ -5441,7 +5423,7 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer) for( auto const &destination : destinations ) { - auto material = TextureTest( destination ); + auto material = TextureTest( ToLower( destination ) ); if( false == material.empty() ) { m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Material( material ); break; diff --git a/EU07.cpp b/EU07.cpp index 50962461..966256bc 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -38,7 +38,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others #pragma comment( lib, "glfw3.lib" ) #pragma comment( lib, "glew32s.lib" ) #else -#ifdef _WINDOWS +#ifdef _WIN32 #pragma comment( lib, "glfw3dll.lib" ) #else #pragma comment( lib, "glfw3.lib" ) @@ -47,9 +47,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others #endif // build_static #pragma comment( lib, "opengl32.lib" ) #pragma comment( lib, "glu32.lib" ) -#pragma comment( lib, "dsound.lib" ) #pragma comment( lib, "openal32.lib") -#pragma comment( lib, "winmm.lib" ) #pragma comment( lib, "setupapi.lib" ) #pragma comment( lib, "python27.lib" ) #pragma comment (lib, "dbghelp.lib") @@ -218,7 +216,7 @@ void scroll_callback( GLFWwindow* window, double xoffset, double yoffset ) { } } -#ifdef _WINDOWS +#ifdef _WIN32 extern "C" { GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); @@ -241,14 +239,14 @@ int main(int argc, char *argv[]) // this will turn on FPE for #IND and zerodiv state = _control87( state & ~( _EM_ZERODIVIDE | _EM_INVALID ), _MCW_EM ); #endif -#ifdef _WINDOWS +#ifdef _WIN32 ::SetUnhandledExceptionFilter( unhandled_handler ); #endif if (!glfwInit()) return -1; -#ifdef _WINDOWS +#ifdef _WIN32 DeleteFile( "log.txt" ); DeleteFile( "errors.txt" ); _mkdir("logs"); @@ -394,7 +392,7 @@ int main(int argc, char *argv[]) return -1; } -#ifdef _WINDOWS +#ifdef _WIN32 // setup wrapper for base glfw window proc, to handle copydata messages Hwnd = glfwGetWin32Window( window ); BaseWindowProc = (WNDPROC)::SetWindowLongPtr( Hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc ); @@ -426,7 +424,7 @@ int main(int argc, char *argv[]) ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) ); return -1; } -#ifdef _WINDOWS +#ifdef _WIN32 Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoś zainicjowac trzeba #endif if( Global.iConvertModels < 0 ) { @@ -434,7 +432,7 @@ int main(int argc, char *argv[]) World.CreateE3D( "models\\" ); // rekurencyjne przeglądanie katalogów World.CreateE3D( "dynamic\\", true ); } // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć -#ifdef _WINDOWS +#ifdef _WIN32 Console::On(); // włączenie konsoli #endif try { @@ -454,7 +452,7 @@ int main(int argc, char *argv[]) } TPythonInterpreter::killInstance(); -#ifdef _WINDOWS +#ifdef _WIN32 Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej) SafeDelete( pConsole ); #endif diff --git a/EvLaunch.cpp b/EvLaunch.cpp index fbc02caa..bbc7dcfc 100644 --- a/EvLaunch.cpp +++ b/EvLaunch.cpp @@ -32,7 +32,7 @@ http://mozilla.org/MPL/2.0/. // and the high byte holds modifiers: 0x1 = shift, 0x2 = ctrl, 0x4 = alt int vk_to_glfw_key( int const Keycode ) { -#ifdef _WINDOWS +#ifdef _WIN32 auto const code = VkKeyScan( Keycode ); char key = code & 0xff; char shiftstate = ( code & 0xff00 ) >> 8; diff --git a/Event.cpp b/Event.cpp index cc0d1dcd..4fcc7a1a 100644 --- a/Event.cpp +++ b/Event.cpp @@ -50,10 +50,10 @@ TEvent::~TEvent() { SafeDeleteArray(Params[10].asText); break; case tp_Animation: // nic - // SafeDeleteArray(Params[9].asText); //nie usuwać - nazwa jest zamieniana na wskaźnik do - // submodelu + // SafeDeleteArray(Params[9].asText); //nie usuwać - nazwa jest zamieniana na wskaźnik do submodelu if (Params[0].asInt == 4) // jeśli z pliku VMD SafeDeleteArray( Params[8].asPointer ); // zwolnić obszar + break; case tp_GetValues: // nic break; case tp_PutValues: // params[0].astext stores the token diff --git a/Event.h b/Event.h index d6492795..6ae2fa92 100644 --- a/Event.h +++ b/Event.h @@ -72,11 +72,7 @@ union TParam bool asBool; double asdouble; int asInt; -#ifdef EU07_USE_OLD_SOUNDCODE - TTextSound *tsTextSound; -#else sound_source *tsTextSound; -#endif char *asText; TCommandType asCommand; TTractionPowerSource *psPower; diff --git a/Globals.cpp b/Globals.cpp index c5717682..e40eb860 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -704,7 +704,7 @@ global_settings::ConfigParse(cParser &Parser) { // TBD: remove, or launch depending on passed flag? if (qp) { // to poniżej wykonywane tylko raz, jedynie po wczytaniu eu07.ini*/ -#ifdef _WINDOWS +#ifdef _WIN32 Console::ModeSet(iFeedbackMode, iFeedbackPort); // tryb pracy konsoli sterowniczej #endif /*iFpsRadiusMax = 0.000025 * fFpsRadiusMax * diff --git a/Model3d.cpp b/Model3d.cpp index 7c9873b6..047cd899 100644 --- a/Model3d.cpp +++ b/Model3d.cpp @@ -1111,7 +1111,6 @@ TModel3d::~TModel3d() { if (iFlags & 0x0200) { // wczytany z pliku tekstowego, submodele sprzątają same SafeDelete( Root ); -// Root = nullptr; } else { // wczytano z pliku binarnego (jest właścicielem tablic) @@ -1121,17 +1120,19 @@ TModel3d::~TModel3d() { TSubModel *TModel3d::AddToNamed(const char *Name, TSubModel *SubModel) { - TSubModel *sm = Name ? GetFromName(Name) : NULL; + TSubModel *sm = Name ? GetFromName(Name) : nullptr; + if( ( sm == nullptr ) + && ( Name != nullptr ) && ( std::strcmp( Name, "none" ) != 0 ) ) { + ErrorLog( "Bad model: parent for sub-model \"" + SubModel->pName +"\" doesn't exist or is located after in the model data", logtype::model ); + } AddTo(sm, SubModel); // szukanie nadrzędnego return sm; // zwracamy wskaźnik do nadrzędnego submodelu }; -void TModel3d::AddTo(TSubModel *tmp, TSubModel *SubModel) -{ // jedyny poprawny sposób dodawania - // submodeli, inaczej mogą zginąć - // przy zapisie E3D - if (tmp) - { // jeśli znaleziony, podłączamy mu jako potomny +// jedyny poprawny sposób dodawania submodeli, inaczej mogą zginąć przy zapisie E3D +void TModel3d::AddTo(TSubModel *tmp, TSubModel *SubModel) { + if (tmp) { + // jeśli znaleziony, podłączamy mu jako potomny tmp->ChildAdd(SubModel); } else diff --git a/World.cpp b/World.cpp index dcdd40db..0f869be7 100644 --- a/World.cpp +++ b/World.cpp @@ -596,8 +596,7 @@ void TWorld::OnKeyDown(int cKey) { { // i potwierdzenie if( cKey == GLFW_KEY_Y ) { // flaga wyjścia z programu - ::PostQuitMessage( 0 ); -// Global.iTextMode = -1; + glfwSetWindowShouldClose( window, 1 ); } return; // nie przekazujemy do pociągu } @@ -1921,7 +1920,7 @@ void TWorld::CreateE3D(std::string const &Path, bool Dynamic) double at{ 0.0 }; double shift{ 0.0 }; -#ifdef _WINDOWS +#ifdef _WIN32 std::string searchpattern( "*.*" ); diff --git a/dumb3d.h b/dumb3d.h index 2c59083b..ceec7c21 100644 --- a/dumb3d.h +++ b/dumb3d.h @@ -127,7 +127,7 @@ class matrix4x4 public: matrix4x4(void) { - ::SecureZeroMemory( e, sizeof( e ) ); + memset( e, 0, sizeof( e ) ); } // When defining matrices in C arrays, it is easiest to define them with diff --git a/messaging.cpp b/messaging.cpp index c9e59ded..41308f4d 100644 --- a/messaging.cpp +++ b/messaging.cpp @@ -15,26 +15,30 @@ http://mozilla.org/MPL/2.0/. #include "mtable.h" #include "logs.h" +#ifdef _WIN32 extern "C" { GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound } +#endif namespace multiplayer { -#ifdef _WINDOWS void Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) { +#ifdef _WIN32 // wysłanie komunikatu do sterującego HWND h = FindWindow(ClassName.c_str(), 0); // można by to zapamiętać if (h == 0) h = FindWindow(0, ClassName.c_str()); // można by to zapamiętać SendMessage(h, Msg, wParam, lParam); +#endif } void WyslijEvent(const std::string &e, const std::string &d) { // Ra: jeszcze do wyczyszczenia +#ifdef _WIN32 DaneRozkaz r; r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' ); r.iComm = 2; // 2 - event @@ -49,12 +53,14 @@ WyslijEvent(const std::string &e, const std::string &d) cData.lpData = &r; Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global.window ), (LPARAM)&cData ); CommLog( Now() + " " + std::to_string(r.iComm) + " " + e + " sent" ); +#endif } void WyslijUszkodzenia(const std::string &t, char fl) { // wysłanie informacji w postaci pojedynczego tekstu - DaneRozkaz r; +#ifdef _WIN32 + DaneRozkaz r; r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' ); r.iComm = 13; // numer komunikatu size_t i = t.length(); @@ -67,11 +73,13 @@ WyslijUszkodzenia(const std::string &t, char fl) cData.lpData = &r; Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global.window ), (LPARAM)&cData ); CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); +#endif } void WyslijString(const std::string &t, int n) { // wysłanie informacji w postaci pojedynczego tekstu +#ifdef _WIN32 DaneRozkaz r; r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' ); r.iComm = n; // numer komunikatu @@ -84,6 +92,7 @@ WyslijString(const std::string &t, int n) cData.lpData = &r; Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global.window ), (LPARAM)&cData ); CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent"); +#endif } void @@ -95,7 +104,8 @@ WyslijWolny(const std::string &t) void WyslijNamiary(TDynamicObject const *Vehicle) { // wysłanie informacji o pojeździe - (float), długość ramki będzie zwiększana w miarę potrzeby - // WriteLog("Wysylam pojazd"); +#ifdef _WIN32 + // WriteLog("Wysylam pojazd"); DaneRozkaz r; r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' ); r.iComm = 7; // 7 - dane pojazdu @@ -167,12 +177,14 @@ WyslijNamiary(TDynamicObject const *Vehicle) Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global.window ), (LPARAM)&cData ); // WriteLog("Ramka poszla!"); CommLog( Now() + " " + std::to_string(r.iComm) + " " + Vehicle->asName + " sent"); +#endif } void WyslijObsadzone() { // wysłanie informacji o pojeździe - DaneRozkaz2 r; +#ifdef _WIN32 + DaneRozkaz2 r; r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' ); r.iComm = 12; // kod 12 for (int i=0; i<1984; ++i) r.cString[i] = 0; @@ -213,11 +225,13 @@ WyslijObsadzone() // WriteLog("Ramka gotowa"); Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global.window ), (LPARAM)&cData ); CommLog( Now() + " " + std::to_string(r.iComm) + " obsadzone" + " sent"); +#endif } void WyslijParam(int nr, int fl) { // wysłanie parametrów symulacji w ramce (nr) z flagami (fl) +#ifdef _WIN32 DaneRozkaz r; r.iSygn = MAKE_ID4( 'E', 'U', '0', '7' ); r.iComm = nr; // zwykle 5 @@ -236,8 +250,8 @@ WyslijParam(int nr, int fl) cData.cbData = 12 + i; // 12+rozmiar danych cData.lpData = &r; Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global.window ), (LPARAM)&cData ); -} #endif +} } // multiplayer diff --git a/mouseinput.cpp b/mouseinput.cpp index 873d8b90..da2c7ee5 100644 --- a/mouseinput.cpp +++ b/mouseinput.cpp @@ -21,14 +21,13 @@ extern TWorld World; bool mouse_input::init() { -#ifdef _WINDOWS +#ifdef _WIN32 DWORD systemkeyboardspeed; ::SystemParametersInfo( SPI_GETKEYBOARDSPEED, 0, &systemkeyboardspeed, 0 ); m_updaterate = interpolate( 0.5, 0.04, systemkeyboardspeed / 31.0 ); DWORD systemkeyboarddelay; ::SystemParametersInfo( SPI_GETKEYBOARDDELAY, 0, &systemkeyboarddelay, 0 ); m_updatedelay = interpolate( 0.25, 1.0, systemkeyboarddelay / 3.0 ); - #endif return true; } diff --git a/openglgeometrybank.h b/openglgeometrybank.h index c2bf6ac2..dd937204 100644 --- a/openglgeometrybank.h +++ b/openglgeometrybank.h @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. #include #include #include "GL/glew.h" -#ifdef _WINDOWS +#ifdef _WIN32 #include "GL/wglew.h" #endif #include "ResourceManager.h" diff --git a/openglmatrixstack.h b/openglmatrixstack.h index 4d988b8a..3859d21e 100644 --- a/openglmatrixstack.h +++ b/openglmatrixstack.h @@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/. #include #include #include "GL/glew.h" -#ifdef _WINDOWS +#ifdef _WIN32 #include "GL/wglew.h" #endif diff --git a/scene.h b/scene.h index c5e7e620..c7f2dd6e 100644 --- a/scene.h +++ b/scene.h @@ -105,11 +105,7 @@ public: insert( TAnimModel *Instance ); // adds provided sound instance to the cell void -#ifdef EU07_USE_OLD_SOUNDCODE - insert( TTextSound *Sound ); -#else insert( sound_source *Sound ); -#endif // adds provided event launcher to the cell void insert( TEventLauncher *Launcher ); diff --git a/simulation.cpp b/simulation.cpp index 4140e443..d9c2b8b3 100644 --- a/simulation.cpp +++ b/simulation.cpp @@ -832,11 +832,7 @@ state_manager::deserialize_dynamic( cParser &Input, scene::scratch_data &Scratch return vehicle; } -#ifdef EU07_USE_OLD_SOUNDCODE -TTextSound * -#else sound_source * -#endif state_manager::deserialize_sound( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ) { glm::dvec3 location; @@ -848,16 +844,10 @@ state_manager::deserialize_sound( cParser &Input, scene::scratch_data &Scratchpa // adjust location location = transform( location, Scratchpad ); -#ifdef EU07_USE_OLD_SOUNDCODE - auto const soundname { Input.getToken() }; - auto *sound = new TTextSound( soundname, Nodedata.range_max, location.x, location.y, location.z, false, false, Nodedata.range_min ); - sound->name( Nodedata.name ); -#else auto *sound = new sound_source( sound_placement::external, Nodedata.range_max ); sound->offset( location ); sound->name( Nodedata.name ); sound->deserialize( Input, sound_type::single ); -#endif skip_until( Input, "endsound" ); diff --git a/simulation.h b/simulation.h index ceceb2ac..0a344aa8 100644 --- a/simulation.h +++ b/simulation.h @@ -64,11 +64,7 @@ private: TEventLauncher * deserialize_eventlauncher( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); TAnimModel * deserialize_model( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); TDynamicObject * deserialize_dynamic( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); -#ifdef EU07_USE_OLD_SOUNDCODE - TTextSound * deserialize_sound( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); -#else sound_source * deserialize_sound( cParser &Input, scene::scratch_data &Scratchpad, scene::node_data const &Nodedata ); -#endif // skips content of stream until specified token void skip_until( cParser &Input, std::string const &Token ); // transforms provided location by specifed rotation and offset diff --git a/stdafx.h b/stdafx.h index 9a043076..c2bcfa2b 100644 --- a/stdafx.h +++ b/stdafx.h @@ -18,7 +18,7 @@ #endif // _DEBUG #endif // operating system -#ifdef _WINDOWS +#ifdef _WIN32 #include "targetver.h" #define NOMINMAX #include @@ -73,12 +73,12 @@ #ifdef EU07_BUILD_STATIC #define GLEW_STATIC #else -#ifdef _WINDOWS +#ifdef _WIN32 #define GLFW_DLL #endif // _windows #endif // build_static #include "GL/glew.h" -#ifdef _WINDOWS +#ifdef _WIN32 #include "GL/wglew.h" #endif #define GLFW_INCLUDE_GLU diff --git a/utilities.cpp b/utilities.cpp index d515fb43..ac060970 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -84,7 +84,7 @@ bool ClearFlag( int &Flag, int const Value ) { } } -inline double Random(double a, double b) +double Random(double a, double b) { std::uniform_real_distribution<> dis(a, b); return dis(Global.random_engine);