16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 00:29:19 +02:00

compilation warnings fixes

This commit is contained in:
tmj-fstate
2017-08-06 17:14:20 +02:00
parent 7e5b2d09cb
commit bc22d582de
12 changed files with 82 additions and 83 deletions

View File

@@ -1431,7 +1431,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
TableClear(); TableClear();
if( WriteLogFlag ) { if( WriteLogFlag ) {
mkdir( "physicslog\\" ); _mkdir( "physicslog\\" );
LogFile.open( std::string( "physicslog\\" + VehicleName + ".dat" ).c_str(), LogFile.open( std::string( "physicslog\\" + VehicleName + ".dat" ).c_str(),
std::ios::in | std::ios::out | std::ios::trunc ); std::ios::in | std::ios::out | std::ios::trunc );
#if LOGPRESS == 0 #if LOGPRESS == 0
@@ -1579,12 +1579,14 @@ void TController::Activation()
ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) - ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) -
// silnikowy dla EZT // silnikowy dla EZT
} }
if (mvControlling->EngineType == if( mvControlling->EngineType == DieselEngine ) {
DieselEngine) // dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy // dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy
if (mvControlling->ShuntModeAllow) if( mvControlling->ShuntModeAllow ) {
mvControlling->CurrentSwitch( mvControlling->CurrentSwitch(
(OrderList[OrderPos] & Shunt) || ( ( OrderList[ OrderPos ] & Shunt ) == Shunt )
(fMass > 224000.0)); // do tego na wzniesieniu może nie dać rady na liniowym || ( fMass > 224000.0 ) ); // do tego na wzniesieniu może nie dać rady na liniowym
}
}
// Ra: to przełączanie poniżej jest tu bez sensu // Ra: to przełączanie poniżej jest tu bez sensu
mvOccupied->ActiveCab = mvOccupied->ActiveCab =
iDirection; // aktywacja kabiny w prowadzonym pojeżdzie (silnikowy może być odwrotnie?) iDirection; // aktywacja kabiny w prowadzonym pojeżdzie (silnikowy może być odwrotnie?)

View File

@@ -187,16 +187,16 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
World.OnKeyDown( key ); World.OnKeyDown( key );
#ifdef CAN_I_HAS_LIBPNG
switch( key ) switch( key )
{ {
#ifdef CAN_I_HAS_LIBPNG
case GLFW_KEY_F11: { case GLFW_KEY_F11: {
make_screenshot(); make_screenshot();
break; break;
} }
#endif
default: { break; } default: { break; }
} }
#endif
} }
} }
@@ -423,7 +423,7 @@ int main(int argc, char *argv[])
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
try { try {
if( false == World.Init( window ) ) { if( false == World.Init( window ) ) {
ErrorLog( "Failed to init TWorld" ); ErrorLog( "Simulation setup failed" );
return -1; return -1;
} }
} }

View File

@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
std::ofstream output; // standardowy "log.txt", można go wyłączyć std::ofstream output; // standardowy "log.txt", można go wyłączyć
std::ofstream errors; // lista błędów "errors.txt", zawsze działa std::ofstream errors; // lista błędów "errors.txt", zawsze działa
std::ofstream comms; // lista komunikatow "comms.txt", można go wyłączyć std::ofstream comms; // lista komunikatow "comms.txt", można go wyłączyć
char logbuffer[ 256 ];
char endstring[10] = "\n"; char endstring[10] = "\n";
@@ -22,8 +23,9 @@ std::string filename_date() {
::SYSTEMTIME st; ::SYSTEMTIME st;
::GetLocalTime( &st ); ::GetLocalTime( &st );
char buffer[ 256 ]; std::snprintf(
sprintf( buffer, logbuffer,
sizeof(logbuffer),
"%d%02d%02d_%02d%02d", "%d%02d%02d_%02d%02d",
st.wYear, st.wYear,
st.wMonth, st.wMonth,
@@ -31,7 +33,7 @@ std::string filename_date() {
st.wHour, st.wHour,
st.wMinute ); st.wMinute );
return std::string( buffer ); return std::string( logbuffer );
} }
std::string filename_scenery() { std::string filename_scenery() {
@@ -45,13 +47,12 @@ std::string filename_scenery() {
} }
} }
void WriteConsoleOnly(const char *str, double value) void WriteConsoleOnly(const char *str, double value) {
{
char buf[255]; std::snprintf(logbuffer , sizeof(logbuffer), "%s %f \n", str, value);
sprintf(buf, "%s %f \n", str, value);
// stdout= GetStdHandle(STD_OUTPUT_HANDLE); // stdout= GetStdHandle(STD_OUTPUT_HANDLE);
DWORD wr = 0; DWORD wr = 0;
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), buf, (DWORD)strlen(buf), &wr, NULL); WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), logbuffer, (DWORD)strlen(logbuffer), &wr, NULL);
// WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),endstring,strlen(endstring),&wr,NULL); // WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),endstring,strlen(endstring),&wr,NULL);
} }
@@ -66,18 +67,16 @@ void WriteConsoleOnly(const char *str, bool newline)
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), endstring, (DWORD)strlen(endstring), &wr, NULL); WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), endstring, (DWORD)strlen(endstring), &wr, NULL);
} }
void WriteLog(const char *str, double value) void WriteLog(const char *str, double value) {
{
if (Global::iWriteLogEnabled) if (Global::iWriteLogEnabled) {
{ if (str) {
if (str) std::snprintf(logbuffer, sizeof(logbuffer), "%s %f", str, value);
{ WriteLog(logbuffer);
char buf[255];
sprintf(buf, "%s %f", str, value);
WriteLog(buf);
} }
} }
}; };
void WriteLog(const char *str, bool newline) void WriteLog(const char *str, bool newline)
{ {
if (str) if (str)

View File

@@ -1024,7 +1024,7 @@ public:
bool IncBrakeLevel(); // wersja na użytek AI bool IncBrakeLevel(); // wersja na użytek AI
bool DecBrakeLevel(); bool DecBrakeLevel();
bool ChangeCab(int direction); bool ChangeCab(int direction);
bool CurrentSwitch(int direction); bool CurrentSwitch(bool const State);
void UpdateBatteryVoltage(double dt); void UpdateBatteryVoltage(double dt);
double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, const TLocation &NewLoc, TRotation &NewRot); //oblicza przesuniecie pojazdu double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, const TLocation &NewLoc, TRotation &NewRot); //oblicza przesuniecie pojazdu
double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, const TLocation &NewLoc, TRotation &NewRot); //oblicza przesuniecie pojazdu - wersja zoptymalizowana double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, const TLocation &NewLoc, TRotation &NewRot); //oblicza przesuniecie pojazdu - wersja zoptymalizowana

View File

@@ -692,13 +692,13 @@ bool TMoverParameters::ChangeCab(int direction)
return false; return false;
}; };
bool TMoverParameters::CurrentSwitch(int direction) // rozruch wysoki (true) albo niski (false)
{ // rozruch wysoki (true) albo niski (false) bool
TMoverParameters::CurrentSwitch(bool const State) {
// Ra: przeniosłem z Train.cpp, nie wiem czy ma to sens // Ra: przeniosłem z Train.cpp, nie wiem czy ma to sens
if (MaxCurrentSwitch(direction != 0)) if (MaxCurrentSwitch(State)) {
{
if (TrainType != dt_EZT) if (TrainType != dt_EZT)
return (MinCurrentSwitch(direction != 0)); return (MinCurrentSwitch(State));
} }
// TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that // TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that
// dla 2Ls150 // dla 2Ls150
@@ -706,14 +706,14 @@ bool TMoverParameters::CurrentSwitch(int direction)
&& ( true == ShuntModeAllow ) && ( true == ShuntModeAllow )
&& ( ActiveDir == 0 ) ) { && ( ActiveDir == 0 ) ) {
// przed ustawieniem kierunku // przed ustawieniem kierunku
ShuntMode = ( direction != 0 ); ShuntMode = State;
return true; return true;
} }
// for SM42/SP42 // for SM42/SP42
if( ( EngineType == DieselElectric ) if( ( EngineType == DieselElectric )
&& ( true == ShuntModeAllow ) && ( true == ShuntModeAllow )
&& ( MainCtrlPos == 0 ) ) { && ( MainCtrlPos == 0 ) ) {
ShuntMode = ( direction != 0 ); ShuntMode = State;
return true; return true;
} }

View File

@@ -1433,16 +1433,16 @@ void TModel3d::SaveToBinFile(std::string const &FileName)
std::ofstream s(FileName, std::ios::binary); std::ofstream s(FileName, std::ios::binary);
sn_utils::ls_uint32(s, MAKE_ID4('E', '3', 'D', '0')); sn_utils::ls_uint32(s, MAKE_ID4('E', '3', 'D', '0'));
size_t e3d_spos = s.tellp(); auto const e3d_spos = s.tellp();
sn_utils::ls_uint32(s, 0); sn_utils::ls_uint32(s, 0);
{ {
sn_utils::ls_uint32(s, MAKE_ID4('S', 'U', 'B', '0')); sn_utils::ls_uint32(s, MAKE_ID4('S', 'U', 'B', '0'));
size_t sub_spos = s.tellp(); auto const sub_spos = s.tellp();
sn_utils::ls_uint32(s, 0); sn_utils::ls_uint32(s, 0);
for (size_t i = 0; i < models.size(); i++) for (size_t i = 0; i < models.size(); i++)
models[i]->serialize(s, models, names, textures, transforms); models[i]->serialize(s, models, names, textures, transforms);
size_t pos = s.tellp(); auto const pos = s.tellp();
s.seekp(sub_spos); s.seekp(sub_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + pos - sub_spos)); sn_utils::ls_uint32(s, (uint32_t)(4 + pos - sub_spos));
s.seekp(pos); s.seekp(pos);
@@ -1460,11 +1460,11 @@ void TModel3d::SaveToBinFile(std::string const &FileName)
if (textures.size()) if (textures.size())
{ {
sn_utils::ls_uint32(s, MAKE_ID4('T', 'E', 'X', '0')); sn_utils::ls_uint32(s, MAKE_ID4('T', 'E', 'X', '0'));
size_t tex_spos = s.tellp(); auto const tex_spos = s.tellp();
sn_utils::ls_uint32(s, 0); sn_utils::ls_uint32(s, 0);
for (size_t i = 0; i < textures.size(); i++) for (size_t i = 0; i < textures.size(); i++)
sn_utils::s_str(s, textures[i]); sn_utils::s_str(s, textures[i]);
size_t pos = s.tellp(); auto const pos = s.tellp();
s.seekp(tex_spos); s.seekp(tex_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + pos - tex_spos)); sn_utils::ls_uint32(s, (uint32_t)(4 + pos - tex_spos));
s.seekp(pos); s.seekp(pos);
@@ -1473,17 +1473,17 @@ void TModel3d::SaveToBinFile(std::string const &FileName)
if (names.size()) if (names.size())
{ {
sn_utils::ls_uint32(s, MAKE_ID4('N', 'A', 'M', '0')); sn_utils::ls_uint32(s, MAKE_ID4('N', 'A', 'M', '0'));
size_t nam_spos = s.tellp(); auto const nam_spos = s.tellp();
sn_utils::ls_uint32(s, 0); sn_utils::ls_uint32(s, 0);
for (size_t i = 0; i < names.size(); i++) for (size_t i = 0; i < names.size(); i++)
sn_utils::s_str(s, names[i]); sn_utils::s_str(s, names[i]);
size_t pos = s.tellp(); auto const pos = s.tellp();
s.seekp(nam_spos); s.seekp(nam_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + pos - nam_spos)); sn_utils::ls_uint32(s, (uint32_t)(4 + pos - nam_spos));
s.seekp(pos); s.seekp(pos);
} }
size_t end = s.tellp(); auto const end = s.tellp();
s.seekp(e3d_spos); s.seekp(e3d_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + end - e3d_spos)); sn_utils::ls_uint32(s, (uint32_t)(4 + end - e3d_spos));
s.close(); s.close();
@@ -1727,8 +1727,9 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
pName = ""; pName = "";
if (iTexture > 0) if (iTexture > 0)
{ // obsługa stałej tekstury { // obsługa stałej tekstury
if( iTexture < t->size() ) { auto const textureindex = static_cast<std::size_t>( iTexture );
pTexture = t->at( iTexture ); if( textureindex < t->size() ) {
pTexture = t->at( textureindex );
if( pTexture.find_last_of( "/\\" ) == std::string::npos ) if( pTexture.find_last_of( "/\\" ) == std::string::npos )
pTexture.insert( 0, Global::asCurrentTexturePath ); pTexture.insert( 0, Global::asCurrentTexturePath );
TextureID = GfxRenderer.Fetch_Texture( pTexture ); TextureID = GfxRenderer.Fetch_Texture( pTexture );

View File

@@ -237,38 +237,22 @@ void TSoundsManager::RestoreAll()
}; };
}; };
void TSoundsManager::Init(HWND hWnd) bool TSoundsManager::Init(HWND hWnd) {
{
First = NULL; First = nullptr;
Count = 0; Count = 0;
pDS = NULL; pDS = nullptr;
pDSNotify = NULL; pDSNotify = nullptr;
HRESULT hr; //=222; HRESULT hr; //=222;
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL; LPDIRECTSOUNDBUFFER pDSBPrimary = nullptr;
// strcpy(Directory, NDirectory);
// Create IDirectSound using the primary sound device // Create IDirectSound using the primary sound device
hr = DirectSoundCreate(NULL, &pDS, NULL); hr = DirectSoundCreate(NULL, &pDS, NULL);
if (hr != DS_OK) if (hr != DS_OK) {
{
if (hr == DSERR_ALLOCATED) return false;
return;
if (hr == DSERR_INVALIDPARAM)
return;
if (hr == DSERR_NOAGGREGATION)
return;
if (hr == DSERR_NODRIVER)
return;
if (hr == DSERR_OUTOFMEMORY)
return;
// hr=0;
}; };
// return ;
// Set coop level to DSSCL_PRIORITY // Set coop level to DSSCL_PRIORITY
// if( FAILED( hr = pDS->SetCooperativeLevel( hWnd, DSSCL_PRIORITY ) ) ); // if( FAILED( hr = pDS->SetCooperativeLevel( hWnd, DSSCL_PRIORITY ) ) );
@@ -285,8 +269,9 @@ void TSoundsManager::Init(HWND hWnd)
dsbd.dwBufferBytes = 0; dsbd.dwBufferBytes = 0;
dsbd.lpwfxFormat = NULL; dsbd.lpwfxFormat = NULL;
if (FAILED(hr = pDS->CreateSoundBuffer(&dsbd, &pDSBPrimary, NULL))) if( FAILED( hr = pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL ) ) ) {
return; return false;
}
// Set primary buffer format to 22kHz and 16-bit output. // Set primary buffer format to 22kHz and 16-bit output.
WAVEFORMATEX wfx; WAVEFORMATEX wfx;
@@ -298,8 +283,11 @@ void TSoundsManager::Init(HWND hWnd)
wfx.nBlockAlign = wfx.wBitsPerSample / 8 * wfx.nChannels; wfx.nBlockAlign = wfx.wBitsPerSample / 8 * wfx.nChannels;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
if (FAILED(hr = pDSBPrimary->SetFormat(&wfx))) if( FAILED( hr = pDSBPrimary->SetFormat( &wfx ) ) ) {
return; return false;
}
SAFE_RELEASE(pDSBPrimary); SAFE_RELEASE(pDSBPrimary);
return true;
}; };

View File

@@ -43,7 +43,7 @@ private:
public: public:
~TSoundsManager(); ~TSoundsManager();
static void Init( HWND hWnd ); static bool Init( HWND hWnd );
static void Free(); static void Free();
static LPDIRECTSOUNDBUFFER GetFromName( std::string const &Name, bool Dynamic, float *fSamplingRate = NULL ); static LPDIRECTSOUNDBUFFER GetFromName( std::string const &Name, bool Dynamic, float *fSamplingRate = NULL );
static void RestoreAll(); static void RestoreAll();

View File

@@ -2319,7 +2319,7 @@ int TTrack::TestPoint(vector3 *Point)
return -1; return -1;
}; };
void TTrack::MovedUp1(double dh) void TTrack::MovedUp1(float const dh)
{ // poprawienie przechyłki wymaga wydłużenia podsypki { // poprawienie przechyłki wymaga wydłużenia podsypki
fTexHeight1 += dh; fTexHeight1 += dh;
}; };

View File

@@ -261,7 +261,7 @@ public:
TextureID2 ); }; TextureID2 ); };
bool IsGroupable(); bool IsGroupable();
int TestPoint(vector3 *Point); int TestPoint(vector3 *Point);
void MovedUp1(double dh); void MovedUp1(float const dh);
std::string NameGet(); std::string NameGet();
void VelocitySet(float v); void VelocitySet(float v);
float VelocityGet(); float VelocityGet();

View File

@@ -288,17 +288,26 @@ bool TWorld::Init( GLFWwindow *Window ) {
UILayer.set_background( "logo" ); UILayer.set_background( "logo" );
TSoundsManager::Init( glfwGetWin32Window( window ) ); if( true == TSoundsManager::Init( glfwGetWin32Window( window ) ) ) {
WriteLog("Sound Init OK"); WriteLog( "Sound subsystem setup complete" );
}
else {
ErrorLog( "Sound subsystem setup failed" );
return false;
}
glfwSetWindowTitle( window, ( Global::AppName + " (" + Global::SceneryFile + ")" ).c_str() ); // nazwa scenerii glfwSetWindowTitle( window, ( Global::AppName + " (" + Global::SceneryFile + ")" ).c_str() ); // nazwa scenerii
UILayer.set_progress(0.01); UILayer.set_progress(0.01);
UILayer.set_progress( "Loading scenery / Wczytywanie scenerii" ); UILayer.set_progress( "Loading scenery / Wczytywanie scenerii" );
GfxRenderer.Render(); GfxRenderer.Render();
WriteLog( "Ground init" ); WriteLog( "World setup..." );
if( true == Ground.Init( Global::SceneryFile ) ) { if( true == Ground.Init( Global::SceneryFile ) ) {
WriteLog( "Ground init OK" ); WriteLog( "...world setup done" );
}
else {
ErrorLog( "...world setup failed" );
return false;
} }
simulation::Time.init(); simulation::Time.init();

View File

@@ -1431,7 +1431,7 @@ opengl_renderer::Render( TGroundNode *Node ) {
::glLineWidth( static_cast<float>( linewidth ) ); ::glLineWidth( static_cast<float>( linewidth ) );
} }
GfxRenderer.Bind( 0 ); GfxRenderer.Bind( NULL );
::glPushMatrix(); ::glPushMatrix();
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position(); auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();
@@ -1902,7 +1902,7 @@ opengl_renderer::Render( TSubModel *Submodel ) {
// material configuration: // material configuration:
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_POINT_BIT ); ::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_POINT_BIT );
Bind( 0 ); Bind( NULL );
::glPointSize( std::max( 3.f, 5.f * distancefactor * anglefactor ) ); ::glPointSize( std::max( 3.f, 5.f * distancefactor * anglefactor ) );
::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], lightlevel * anglefactor ); ::glColor4f( Submodel->f4Diffuse[ 0 ], Submodel->f4Diffuse[ 1 ], Submodel->f4Diffuse[ 2 ], lightlevel * anglefactor );
::glDisable( GL_LIGHTING ); ::glDisable( GL_LIGHTING );
@@ -1941,7 +1941,7 @@ opengl_renderer::Render( TSubModel *Submodel ) {
// material configuration: // material configuration:
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT ); ::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT );
Bind( 0 ); Bind( NULL );
::glDisable( GL_LIGHTING ); ::glDisable( GL_LIGHTING );
// main draw call // main draw call
@@ -2217,7 +2217,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
::glLineWidth( static_cast<float>(linewidth) ); ::glLineWidth( static_cast<float>(linewidth) );
} }
GfxRenderer.Bind( 0 ); GfxRenderer.Bind( NULL );
::glPushMatrix(); ::glPushMatrix();
auto const originoffset = Node->m_rootposition - m_renderpass.camera.position(); auto const originoffset = Node->m_rootposition - m_renderpass.camera.position();