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

basic executable versioning

This commit is contained in:
tmj-fstate
2017-05-16 14:13:28 +02:00
parent 52a76f0ba1
commit 23f4892bcc
10 changed files with 74 additions and 30 deletions

View File

@@ -52,6 +52,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
#pragma comment( lib, "setupapi.lib" )
#pragma comment( lib, "python27.lib" )
#pragma comment (lib, "dbghelp.lib")
#pragma comment (lib, "version.lib")
#ifdef CAN_I_HAS_LIBPNG
#pragma comment (lib, "libpng16.lib")
#endif
@@ -224,12 +225,49 @@ int main(int argc, char *argv[])
AllocConsole();
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN );
}
/*
std::string executable( argv[ 0 ] ); auto const pathend = executable.rfind( '\\' );
Global::ExecutableName =
( pathend != std::string::npos ?
executable.substr( executable.rfind( '\\' ) + 1 ) :
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)
{

View File

@@ -32,8 +32,7 @@ std::string Global::AppName{ "EU07" };
std::string Global::asCurrentSceneryPath = "scenery/";
std::string Global::asCurrentTexturePath = std::string(szTexturePath);
std::string Global::asCurrentDynamicPath = "";
int Global::iSlowMotion =
0; // info o malym FPS: 0-OK, 1-wyłączyć multisampling, 3-promień 1.5km, 7-1km
int Global::iSlowMotion = 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
double Global::ABuDebug = 0;
std::string Global::asSky = "1";
@@ -48,9 +47,7 @@ GLFWwindow *Global::window;
bool Global::shiftState;
bool Global::ctrlState;
int Global::iCameraLast = -1;
std::string Global::asRelease = "16.0.1172.482";
std::string Global::asVersion = "Compilation 2017-03-19, release " + Global::asRelease; // tutaj, bo wysyłany
std::string Global::ExecutableName;
std::string Global::asVersion = "couldn't retrieve version string";
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
double Global::fSunDeclination = 0.0; // deklinacja Słońca

View File

@@ -266,9 +266,7 @@ class Global
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 int iCameraLast;
static std::string asRelease; // numer
static std::string asVersion; // z opisem
static std::string ExecutableName;
static GLint iMaxTextureSize; // maksymalny rozmiar tekstury
static int iTextMode; // tryb pracy wyświetlacza tekstowego
static int iScreenMode[12]; // numer ekranu wyświetlacza tekstowego

View File

@@ -112,7 +112,7 @@ void ErrorLog(const char *str)
"logs/errors (" + filename_scenery() + ") " + filename_date() + ".txt" :
"errors.txt" );
errors.open( filename, std::ios::trunc );
errors << "EU07.EXE " + Global::asRelease << "\n";
errors << "EU07.EXE " + Global::asVersion << "\n";
}
if (str)
errors << str;

View File

@@ -599,10 +599,10 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
if (DebugModeFlag) // tylko podczas testów
Material = 4; // pokazanie, że to przęsło ma podłączone zasilanie
#else
// TBD, TODO: we don't need to maintain 4-7 value range as it's part of legacy system
PowerState = 4;
#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
#ifdef EU07_USE_OLD_TRACTIONPOWER_CODE
if (DebugModeFlag) // tylko podczas testów
@@ -615,11 +615,14 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
#else
if( t->PowerState != 4 ) {
// przęsła zasilającego nie modyfikować
if( t->PowerState < 4 ) {
// tymczasowo, aby zmieniła kolor
if( t->psPowered != nullptr ) {
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
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
switch( PowerState ) {
case 4: {
// niebieskie z podłączonym zasilaniem
Red = 0.5f;
Green = 0.5f;
Blue = 1.0f;
break;
}
case 5: {
case 1: {
// czerwone z podłączonym zasilaniem 1
Red = 1.0f;
Green = 0.0f;
Blue = 0.0f;
break;
}
case 6: {
case 2: {
// zielone z podłączonym zasilaniem 2
Red = 0.0f;
Green = 1.0f;
Blue = 0.0f;
break;
}
case 7: {
case 3: {
//żółte z podłączonym zasilaniem z obu stron
Red = 1.0f;
Green = 1.0f;
Blue = 0.0f;
break;
}
case 4: {
// niebieskie z podłączonym zasilaniem
Red = 0.5f;
Green = 0.5f;
Blue = 1.0f;
break;
}
default: { break; }
}
if( hvParallel ) { // jeśli z bieżnią wspólną, to dodatkowo przyciemniamy

View File

@@ -281,11 +281,10 @@ bool TWorld::Init( GLFWwindow *Window ) {
Global::window = Window; // do WM_COPYDATA
Global::pCamera = &Camera; // Ra: wskaźnik potrzebny do likwidacji drgań
WriteLog("\nStarting MaSzyna rail vehicle simulator.");
WriteLog( "Release " + Global::asRelease + " (executable: " + Global::ExecutableName + ")" );
WriteLog("Online documentation and additional files on http://eu07.pl");
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");
WriteLog( "\nStarting MaSzyna rail vehicle simulator (release: " + Global::asVersion + ")" );
WriteLog( "For online documentation and additional files refer to: http://eu07.pl");
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" );
UILayer.set_background( "logo" );
@@ -1982,7 +1981,7 @@ TWorld::Update_UI() {
case( GLFW_KEY_F9 ) : {
// 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 ) {
uitextline1 += " (multiplayer mode is active)";
}

Binary file not shown.

View File

@@ -431,6 +431,9 @@
<ClInclude Include="gamepadinput.h">
<Filter>Header Files\input</Filter>
</ClInclude>
<ClInclude Include="version.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="maszyna.rc">

View File

@@ -26,6 +26,7 @@
#undef NOMINMAX
#include <dbghelp.h>
#include <direct.h>
#include <strsafe.h>
#endif
// stl
#include <cstdlib>

5
version.h Normal file
View File

@@ -0,0 +1,5 @@
#pragma once
#define VERSION_MAJOR 17
#define VERSION_MINOR 516
#define VERSION_REVISION 0