16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 23:19: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();
if( WriteLogFlag ) {
mkdir( "physicslog\\" );
_mkdir( "physicslog\\" );
LogFile.open( std::string( "physicslog\\" + VehicleName + ".dat" ).c_str(),
std::ios::in | std::ios::out | std::ios::trunc );
#if LOGPRESS == 0
@@ -1579,12 +1579,14 @@ void TController::Activation()
ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) -
// silnikowy dla EZT
}
if (mvControlling->EngineType ==
DieselEngine) // dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy
if (mvControlling->ShuntModeAllow)
if( mvControlling->EngineType == DieselEngine ) {
// dla 2Ls150 - przed ustawieniem kierunku - można zmienić tryb pracy
if( mvControlling->ShuntModeAllow ) {
mvControlling->CurrentSwitch(
(OrderList[OrderPos] & Shunt) ||
(fMass > 224000.0)); // do tego na wzniesieniu może nie dać rady na liniowym
( ( OrderList[ OrderPos ] & Shunt ) == Shunt )
|| ( fMass > 224000.0 ) ); // do tego na wzniesieniu może nie dać rady na liniowym
}
}
// Ra: to przełączanie poniżej jest tu bez sensu
mvOccupied->ActiveCab =
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 );
#ifdef CAN_I_HAS_LIBPNG
switch( key )
{
#ifdef CAN_I_HAS_LIBPNG
case GLFW_KEY_F11: {
make_screenshot();
break;
}
#endif
default: { break; }
}
#endif
}
}
@@ -423,7 +423,7 @@ int main(int argc, char *argv[])
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
try {
if( false == World.Init( window ) ) {
ErrorLog( "Failed to init TWorld" );
ErrorLog( "Simulation setup failed" );
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 errors; // lista błędów "errors.txt", zawsze działa
std::ofstream comms; // lista komunikatow "comms.txt", można go wyłączyć
char logbuffer[ 256 ];
char endstring[10] = "\n";
@@ -22,8 +23,9 @@ std::string filename_date() {
::SYSTEMTIME st;
::GetLocalTime( &st );
char buffer[ 256 ];
sprintf( buffer,
std::snprintf(
logbuffer,
sizeof(logbuffer),
"%d%02d%02d_%02d%02d",
st.wYear,
st.wMonth,
@@ -31,7 +33,7 @@ std::string filename_date() {
st.wHour,
st.wMinute );
return std::string( buffer );
return std::string( logbuffer );
}
std::string filename_scenery() {
@@ -45,13 +47,12 @@ std::string filename_scenery() {
}
}
void WriteConsoleOnly(const char *str, double value)
{
char buf[255];
sprintf(buf, "%s %f \n", str, value);
void WriteConsoleOnly(const char *str, double value) {
std::snprintf(logbuffer , sizeof(logbuffer), "%s %f \n", str, value);
// stdout= GetStdHandle(STD_OUTPUT_HANDLE);
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);
}
@@ -66,18 +67,16 @@ void WriteConsoleOnly(const char *str, bool newline)
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), endstring, (DWORD)strlen(endstring), &wr, NULL);
}
void WriteLog(const char *str, double value)
{
if (Global::iWriteLogEnabled)
{
if (str)
{
char buf[255];
sprintf(buf, "%s %f", str, value);
WriteLog(buf);
void WriteLog(const char *str, double value) {
if (Global::iWriteLogEnabled) {
if (str) {
std::snprintf(logbuffer, sizeof(logbuffer), "%s %f", str, value);
WriteLog(logbuffer);
}
}
};
void WriteLog(const char *str, bool newline)
{
if (str)

View File

@@ -1024,7 +1024,7 @@ public:
bool IncBrakeLevel(); // wersja na użytek AI
bool DecBrakeLevel();
bool ChangeCab(int direction);
bool CurrentSwitch(int direction);
bool CurrentSwitch(bool const State);
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 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;
};
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
if (MaxCurrentSwitch(direction != 0))
{
if (MaxCurrentSwitch(State)) {
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
// dla 2Ls150
@@ -706,14 +706,14 @@ bool TMoverParameters::CurrentSwitch(int direction)
&& ( true == ShuntModeAllow )
&& ( ActiveDir == 0 ) ) {
// przed ustawieniem kierunku
ShuntMode = ( direction != 0 );
ShuntMode = State;
return true;
}
// for SM42/SP42
if( ( EngineType == DieselElectric )
&& ( true == ShuntModeAllow )
&& ( MainCtrlPos == 0 ) ) {
ShuntMode = ( direction != 0 );
ShuntMode = State;
return true;
}

View File

@@ -1433,16 +1433,16 @@ void TModel3d::SaveToBinFile(std::string const &FileName)
std::ofstream s(FileName, std::ios::binary);
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, MAKE_ID4('S', 'U', 'B', '0'));
size_t sub_spos = s.tellp();
auto const sub_spos = s.tellp();
sn_utils::ls_uint32(s, 0);
for (size_t i = 0; i < models.size(); i++)
models[i]->serialize(s, models, names, textures, transforms);
size_t pos = s.tellp();
auto const pos = s.tellp();
s.seekp(sub_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + pos - sub_spos));
s.seekp(pos);
@@ -1460,11 +1460,11 @@ void TModel3d::SaveToBinFile(std::string const &FileName)
if (textures.size())
{
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);
for (size_t i = 0; i < textures.size(); i++)
sn_utils::s_str(s, textures[i]);
size_t pos = s.tellp();
auto const pos = s.tellp();
s.seekp(tex_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + pos - tex_spos));
s.seekp(pos);
@@ -1473,17 +1473,17 @@ void TModel3d::SaveToBinFile(std::string const &FileName)
if (names.size())
{
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);
for (size_t i = 0; i < names.size(); i++)
sn_utils::s_str(s, names[i]);
size_t pos = s.tellp();
auto const pos = s.tellp();
s.seekp(nam_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + pos - nam_spos));
s.seekp(pos);
}
size_t end = s.tellp();
auto const end = s.tellp();
s.seekp(e3d_spos);
sn_utils::ls_uint32(s, (uint32_t)(4 + end - e3d_spos));
s.close();
@@ -1727,8 +1727,9 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
pName = "";
if (iTexture > 0)
{ // obsługa stałej tekstury
if( iTexture < t->size() ) {
pTexture = t->at( iTexture );
auto const textureindex = static_cast<std::size_t>( iTexture );
if( textureindex < t->size() ) {
pTexture = t->at( textureindex );
if( pTexture.find_last_of( "/\\" ) == std::string::npos )
pTexture.insert( 0, Global::asCurrentTexturePath );
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;
pDS = NULL;
pDSNotify = NULL;
pDS = nullptr;
pDSNotify = nullptr;
HRESULT hr; //=222;
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;
// strcpy(Directory, NDirectory);
LPDIRECTSOUNDBUFFER pDSBPrimary = nullptr;
// Create IDirectSound using the primary sound device
hr = DirectSoundCreate(NULL, &pDS, NULL);
if (hr != DS_OK)
{
if (hr != DS_OK) {
if (hr == DSERR_ALLOCATED)
return;
if (hr == DSERR_INVALIDPARAM)
return;
if (hr == DSERR_NOAGGREGATION)
return;
if (hr == DSERR_NODRIVER)
return;
if (hr == DSERR_OUTOFMEMORY)
return;
// hr=0;
return false;
};
// return ;
// Set coop level to DSSCL_PRIORITY
// if( FAILED( hr = pDS->SetCooperativeLevel( hWnd, DSSCL_PRIORITY ) ) );
@@ -285,8 +269,9 @@ void TSoundsManager::Init(HWND hWnd)
dsbd.dwBufferBytes = 0;
dsbd.lpwfxFormat = NULL;
if (FAILED(hr = pDS->CreateSoundBuffer(&dsbd, &pDSBPrimary, NULL)))
return;
if( FAILED( hr = pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL ) ) ) {
return false;
}
// Set primary buffer format to 22kHz and 16-bit output.
WAVEFORMATEX wfx;
@@ -298,8 +283,11 @@ void TSoundsManager::Init(HWND hWnd)
wfx.nBlockAlign = wfx.wBitsPerSample / 8 * wfx.nChannels;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
if (FAILED(hr = pDSBPrimary->SetFormat(&wfx)))
return;
if( FAILED( hr = pDSBPrimary->SetFormat( &wfx ) ) ) {
return false;
}
SAFE_RELEASE(pDSBPrimary);
return true;
};

View File

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

View File

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

View File

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

View File

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

View File

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