mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 18:39:18 +02:00
basic executable versioning
This commit is contained in:
40
EU07.cpp
40
EU07.cpp
@@ -52,6 +52,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
|||||||
#pragma comment( lib, "setupapi.lib" )
|
#pragma comment( lib, "setupapi.lib" )
|
||||||
#pragma comment( lib, "python27.lib" )
|
#pragma comment( lib, "python27.lib" )
|
||||||
#pragma comment (lib, "dbghelp.lib")
|
#pragma comment (lib, "dbghelp.lib")
|
||||||
|
#pragma comment (lib, "version.lib")
|
||||||
#ifdef CAN_I_HAS_LIBPNG
|
#ifdef CAN_I_HAS_LIBPNG
|
||||||
#pragma comment (lib, "libpng16.lib")
|
#pragma comment (lib, "libpng16.lib")
|
||||||
#endif
|
#endif
|
||||||
@@ -224,12 +225,49 @@ int main(int argc, char *argv[])
|
|||||||
AllocConsole();
|
AllocConsole();
|
||||||
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN );
|
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN );
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
std::string executable( argv[ 0 ] ); auto const pathend = executable.rfind( '\\' );
|
std::string executable( argv[ 0 ] ); auto const pathend = executable.rfind( '\\' );
|
||||||
Global::ExecutableName =
|
Global::ExecutableName =
|
||||||
( pathend != std::string::npos ?
|
( pathend != std::string::npos ?
|
||||||
executable.substr( executable.rfind( '\\' ) + 1 ) :
|
executable.substr( executable.rfind( '\\' ) + 1 ) :
|
||||||
executable );
|
executable );
|
||||||
|
*/
|
||||||
|
// retrieve product version from the file's version data table
|
||||||
|
{
|
||||||
|
auto const fileversionsize = ::GetFileVersionInfoSize( argv[ 0 ], NULL );
|
||||||
|
std::vector<BYTE>fileversiondata; fileversiondata.resize( fileversionsize );
|
||||||
|
if( ::GetFileVersionInfo( argv[ 0 ], NULL, fileversionsize, fileversiondata.data() ) ) {
|
||||||
|
|
||||||
|
struct lang_codepage {
|
||||||
|
WORD language;
|
||||||
|
WORD codepage;
|
||||||
|
} *langcodepage;
|
||||||
|
UINT datasize;
|
||||||
|
|
||||||
|
::VerQueryValue(
|
||||||
|
fileversiondata.data(),
|
||||||
|
TEXT( "\\VarFileInfo\\Translation" ),
|
||||||
|
(LPVOID*)&langcodepage,
|
||||||
|
&datasize );
|
||||||
|
|
||||||
|
std::string subblock; subblock.resize( 50 );
|
||||||
|
::StringCchPrintf(
|
||||||
|
&subblock[0], subblock.size(),
|
||||||
|
TEXT( "\\StringFileInfo\\%04x%04x\\ProductVersion" ),
|
||||||
|
langcodepage->language,
|
||||||
|
langcodepage->codepage );
|
||||||
|
|
||||||
|
VOID *stringdata;
|
||||||
|
if( ::VerQueryValue(
|
||||||
|
fileversiondata.data(),
|
||||||
|
subblock.data(),
|
||||||
|
&stringdata,
|
||||||
|
&datasize ) ) {
|
||||||
|
|
||||||
|
Global::asVersion = std::string( reinterpret_cast<char*>(stringdata) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i)
|
for (int i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ std::string Global::AppName{ "EU07" };
|
|||||||
std::string Global::asCurrentSceneryPath = "scenery/";
|
std::string Global::asCurrentSceneryPath = "scenery/";
|
||||||
std::string Global::asCurrentTexturePath = std::string(szTexturePath);
|
std::string Global::asCurrentTexturePath = std::string(szTexturePath);
|
||||||
std::string Global::asCurrentDynamicPath = "";
|
std::string Global::asCurrentDynamicPath = "";
|
||||||
int Global::iSlowMotion =
|
int Global::iSlowMotion = 0; // info o malym FPS: 0-OK, 1-wyłączyć multisampling, 3-promień 1.5km, 7-1km
|
||||||
0; // info o malym FPS: 0-OK, 1-wyłączyć multisampling, 3-promień 1.5km, 7-1km
|
|
||||||
TDynamicObject *Global::changeDynObj = NULL; // info o zmianie pojazdu
|
TDynamicObject *Global::changeDynObj = NULL; // info o zmianie pojazdu
|
||||||
double Global::ABuDebug = 0;
|
double Global::ABuDebug = 0;
|
||||||
std::string Global::asSky = "1";
|
std::string Global::asSky = "1";
|
||||||
@@ -48,9 +47,7 @@ GLFWwindow *Global::window;
|
|||||||
bool Global::shiftState;
|
bool Global::shiftState;
|
||||||
bool Global::ctrlState;
|
bool Global::ctrlState;
|
||||||
int Global::iCameraLast = -1;
|
int Global::iCameraLast = -1;
|
||||||
std::string Global::asRelease = "16.0.1172.482";
|
std::string Global::asVersion = "couldn't retrieve version string";
|
||||||
std::string Global::asVersion = "Compilation 2017-03-19, release " + Global::asRelease; // tutaj, bo wysyłany
|
|
||||||
std::string Global::ExecutableName;
|
|
||||||
int Global::iTextMode = 0; // tryb pracy wyświetlacza tekstowego
|
int Global::iTextMode = 0; // tryb pracy wyświetlacza tekstowego
|
||||||
int Global::iScreenMode[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // numer ekranu wyświetlacza tekstowego
|
int Global::iScreenMode[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // numer ekranu wyświetlacza tekstowego
|
||||||
double Global::fSunDeclination = 0.0; // deklinacja Słońca
|
double Global::fSunDeclination = 0.0; // deklinacja Słońca
|
||||||
|
|||||||
@@ -266,9 +266,7 @@ class Global
|
|||||||
static float ZoomFactor; // determines current camera zoom level. TODO: move it to the renderer
|
static float ZoomFactor; // determines current camera zoom level. TODO: move it to the renderer
|
||||||
static float FieldOfView; // vertical field of view for the camera. TODO: move it to the renderer
|
static float FieldOfView; // vertical field of view for the camera. TODO: move it to the renderer
|
||||||
static int iCameraLast;
|
static int iCameraLast;
|
||||||
static std::string asRelease; // numer
|
|
||||||
static std::string asVersion; // z opisem
|
static std::string asVersion; // z opisem
|
||||||
static std::string ExecutableName;
|
|
||||||
static GLint iMaxTextureSize; // maksymalny rozmiar tekstury
|
static GLint iMaxTextureSize; // maksymalny rozmiar tekstury
|
||||||
static int iTextMode; // tryb pracy wyświetlacza tekstowego
|
static int iTextMode; // tryb pracy wyświetlacza tekstowego
|
||||||
static int iScreenMode[12]; // numer ekranu wyświetlacza tekstowego
|
static int iScreenMode[12]; // numer ekranu wyświetlacza tekstowego
|
||||||
|
|||||||
2
Logs.cpp
2
Logs.cpp
@@ -112,7 +112,7 @@ void ErrorLog(const char *str)
|
|||||||
"logs/errors (" + filename_scenery() + ") " + filename_date() + ".txt" :
|
"logs/errors (" + filename_scenery() + ") " + filename_date() + ".txt" :
|
||||||
"errors.txt" );
|
"errors.txt" );
|
||||||
errors.open( filename, std::ios::trunc );
|
errors.open( filename, std::ios::trunc );
|
||||||
errors << "EU07.EXE " + Global::asRelease << "\n";
|
errors << "EU07.EXE " + Global::asVersion << "\n";
|
||||||
}
|
}
|
||||||
if (str)
|
if (str)
|
||||||
errors << str;
|
errors << str;
|
||||||
|
|||||||
33
Traction.cpp
33
Traction.cpp
@@ -599,10 +599,10 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
|
|||||||
if (DebugModeFlag) // tylko podczas testów
|
if (DebugModeFlag) // tylko podczas testów
|
||||||
Material = 4; // pokazanie, że to przęsło ma podłączone zasilanie
|
Material = 4; // pokazanie, że to przęsło ma podłączone zasilanie
|
||||||
#else
|
#else
|
||||||
// TBD, TODO: we don't need to maintain 4-7 value range as it's part of legacy system
|
|
||||||
PowerState = 4;
|
PowerState = 4;
|
||||||
#endif
|
#endif
|
||||||
while (t ? !t->psPower[d] : false) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza
|
while( ( t != nullptr )
|
||||||
|
&& ( t->psPower[d] == nullptr ) ) // jeśli jest jakiś kolejny i nie ma ustalonego zasilacza
|
||||||
{ // ustawienie zasilacza i policzenie rezystancji zastępczej
|
{ // ustawienie zasilacza i policzenie rezystancji zastępczej
|
||||||
#ifdef EU07_USE_OLD_TRACTIONPOWER_CODE
|
#ifdef EU07_USE_OLD_TRACTIONPOWER_CODE
|
||||||
if (DebugModeFlag) // tylko podczas testów
|
if (DebugModeFlag) // tylko podczas testów
|
||||||
@@ -615,11 +615,14 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
|
|||||||
#else
|
#else
|
||||||
if( t->PowerState != 4 ) {
|
if( t->PowerState != 4 ) {
|
||||||
// przęsła zasilającego nie modyfikować
|
// przęsła zasilającego nie modyfikować
|
||||||
if( t->PowerState < 4 ) {
|
if( t->psPowered != nullptr ) {
|
||||||
// tymczasowo, aby zmieniła kolor
|
|
||||||
t->PowerState = 4;
|
t->PowerState = 4;
|
||||||
}
|
}
|
||||||
t->PowerState |= d ? 2 : 1; // kolor zależny od strony, z której jest zasilanie
|
else {
|
||||||
|
// kolor zależny od strony, z której jest zasilanie
|
||||||
|
t->PowerState |= d ? 2 : 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony
|
t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony
|
||||||
@@ -751,34 +754,34 @@ TTraction::wire_color( float &Red, float &Green, float &Blue ) const {
|
|||||||
// tymczasowo pokazanie zasilanych odcinków
|
// tymczasowo pokazanie zasilanych odcinków
|
||||||
switch( PowerState ) {
|
switch( PowerState ) {
|
||||||
|
|
||||||
case 4: {
|
case 1: {
|
||||||
// niebieskie z podłączonym zasilaniem
|
|
||||||
Red = 0.5f;
|
|
||||||
Green = 0.5f;
|
|
||||||
Blue = 1.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 5: {
|
|
||||||
// czerwone z podłączonym zasilaniem 1
|
// czerwone z podłączonym zasilaniem 1
|
||||||
Red = 1.0f;
|
Red = 1.0f;
|
||||||
Green = 0.0f;
|
Green = 0.0f;
|
||||||
Blue = 0.0f;
|
Blue = 0.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6: {
|
case 2: {
|
||||||
// zielone z podłączonym zasilaniem 2
|
// zielone z podłączonym zasilaniem 2
|
||||||
Red = 0.0f;
|
Red = 0.0f;
|
||||||
Green = 1.0f;
|
Green = 1.0f;
|
||||||
Blue = 0.0f;
|
Blue = 0.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 7: {
|
case 3: {
|
||||||
//żółte z podłączonym zasilaniem z obu stron
|
//żółte z podłączonym zasilaniem z obu stron
|
||||||
Red = 1.0f;
|
Red = 1.0f;
|
||||||
Green = 1.0f;
|
Green = 1.0f;
|
||||||
Blue = 0.0f;
|
Blue = 0.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 4: {
|
||||||
|
// niebieskie z podłączonym zasilaniem
|
||||||
|
Red = 0.5f;
|
||||||
|
Green = 0.5f;
|
||||||
|
Blue = 1.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: { break; }
|
default: { break; }
|
||||||
}
|
}
|
||||||
if( hvParallel ) { // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy
|
if( hvParallel ) { // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy
|
||||||
|
|||||||
11
World.cpp
11
World.cpp
@@ -281,11 +281,10 @@ bool TWorld::Init( GLFWwindow *Window ) {
|
|||||||
Global::window = Window; // do WM_COPYDATA
|
Global::window = Window; // do WM_COPYDATA
|
||||||
Global::pCamera = &Camera; // Ra: wskaźnik potrzebny do likwidacji drgań
|
Global::pCamera = &Camera; // Ra: wskaźnik potrzebny do likwidacji drgań
|
||||||
|
|
||||||
WriteLog("\nStarting MaSzyna rail vehicle simulator.");
|
WriteLog( "\nStarting MaSzyna rail vehicle simulator (release: " + Global::asVersion + ")" );
|
||||||
WriteLog( "Release " + Global::asRelease + " (executable: " + Global::ExecutableName + ")" );
|
WriteLog( "For online documentation and additional files refer to: http://eu07.pl");
|
||||||
WriteLog("Online documentation and additional files on http://eu07.pl");
|
WriteLog( "Authors: Marcin_EU, McZapkie, ABu, Winger, Tolaris, nbmx, OLO_EU, Bart, Quark-t, "
|
||||||
WriteLog("Authors: Marcin_EU, McZapkie, ABu, Winger, Tolaris, nbmx, OLO_EU, Bart, Quark-t, "
|
"ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter, szociu, Stele, Q, firleju and others\n" );
|
||||||
"ShaXbee, Oli_EU, youBy, KURS90, Ra, hunter, szociu, Stele, Q, firleju and others\n");
|
|
||||||
|
|
||||||
UILayer.set_background( "logo" );
|
UILayer.set_background( "logo" );
|
||||||
|
|
||||||
@@ -1982,7 +1981,7 @@ TWorld::Update_UI() {
|
|||||||
|
|
||||||
case( GLFW_KEY_F9 ) : {
|
case( GLFW_KEY_F9 ) : {
|
||||||
// informacja o wersji, sposobie wyświetlania i błędach OpenGL
|
// informacja o wersji, sposobie wyświetlania i błędach OpenGL
|
||||||
uitextline1 = Global::asVersion; // informacja o wersji
|
uitextline1 = "MaSzyna " + Global::asVersion; // informacja o wersji
|
||||||
if( Global::iMultiplayer ) {
|
if( Global::iMultiplayer ) {
|
||||||
uitextline1 += " (multiplayer mode is active)";
|
uitextline1 += " (multiplayer mode is active)";
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
maszyna.rc
BIN
maszyna.rc
Binary file not shown.
@@ -431,6 +431,9 @@
|
|||||||
<ClInclude Include="gamepadinput.h">
|
<ClInclude Include="gamepadinput.h">
|
||||||
<Filter>Header Files\input</Filter>
|
<Filter>Header Files\input</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="version.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="maszyna.rc">
|
<ResourceCompile Include="maszyna.rc">
|
||||||
|
|||||||
1
stdafx.h
1
stdafx.h
@@ -26,6 +26,7 @@
|
|||||||
#undef NOMINMAX
|
#undef NOMINMAX
|
||||||
#include <dbghelp.h>
|
#include <dbghelp.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
|
#include <strsafe.h>
|
||||||
#endif
|
#endif
|
||||||
// stl
|
// stl
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|||||||
Reference in New Issue
Block a user