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

maintenance: minor code touch ups

This commit is contained in:
tmj-fstate
2017-11-01 02:54:31 +01:00
parent ffbaacdb0e
commit a700d36ea7
20 changed files with 53 additions and 46 deletions

View File

@@ -125,7 +125,7 @@ class TAnimModel : public editor::basic_node {
public: public:
// constructors // constructors
TAnimModel( scene::node_data const &Nodedata ); explicit TAnimModel( scene::node_data const &Nodedata );
// destructor // destructor
~TAnimModel(); ~TAnimModel();
// methods // methods

View File

@@ -32,6 +32,7 @@ class TButton
void void
play(); play();
// plays specified sound // plays specified sound
static
void void
play( PSound Sound ); play( PSound Sound );

View File

@@ -134,8 +134,8 @@ bool TEventLauncher::check_conditions()
// key and modifier // key and modifier
auto const modifier = ( iKey & 0xff00 ) >> 8; auto const modifier = ( iKey & 0xff00 ) >> 8;
bCond = ( Console::Pressed( iKey & 0xff ) ) bCond = ( Console::Pressed( iKey & 0xff ) )
&& ( modifier & 1 ? Global::shiftState : true ) && ( ( modifier & 1 ) ? Global::shiftState : true )
&& ( modifier & 2 ? Global::ctrlState : true ); && ( ( modifier & 2 ) ? Global::ctrlState : true );
} }
else { else {
// just key // just key

View File

@@ -18,7 +18,7 @@ class TEventLauncher : public editor::basic_node {
public: public:
// constructor // constructor
TEventLauncher( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {} explicit TEventLauncher( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}
// legacy constructor // legacy constructor
TEventLauncher() = default; TEventLauncher() = default;

View File

@@ -294,7 +294,7 @@ FileExists( std::string const &Filename ) {
} }
// returns time of last modification for specified file // returns time of last modification for specified file
__time64_t std::time_t
last_modified( std::string const &Filename ) { last_modified( std::string const &Filename ) {
struct stat filestat; struct stat filestat;

View File

@@ -160,4 +160,4 @@ extract_value( bool &Variable, std::string const &Key, std::string const &Input,
bool FileExists( std::string const &Filename ); bool FileExists( std::string const &Filename );
// returns time of last modification for specified file // returns time of last modification for specified file
__time64_t last_modified( std::string const &Filename ); std::time_t last_modified( std::string const &Filename );

View File

@@ -139,7 +139,7 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1,
&& ( !TestFlag( CheckMask, conditional_memval2 ) || ( fValue2 == fTestValue2 ) ) ); && ( !TestFlag( CheckMask, conditional_memval2 ) || ( fValue2 == fTestValue2 ) ) );
}; };
bool TMemCell::IsVelocity() bool TMemCell::IsVelocity() const
{ // sprawdzenie, czy event odczytu tej komórki ma być do skanowania, czy do kolejkowania { // sprawdzenie, czy event odczytu tej komórki ma być do skanowania, czy do kolejkowania
if (eCommand == cm_SetVelocity) if (eCommand == cm_SetVelocity)
return true; return true;

View File

@@ -19,7 +19,7 @@ class TMemCell : public editor::basic_node {
public: public:
std::string asTrackName; // McZapkie-100302 - zeby nazwe toru na ktory jest Putcommand wysylane pamietac std::string asTrackName; // McZapkie-100302 - zeby nazwe toru na ktory jest Putcommand wysylane pamietac
TMemCell( scene::node_data const &Nodedata ); explicit TMemCell( scene::node_data const &Nodedata );
void void
UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask ); UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask );
@@ -46,7 +46,7 @@ public:
return bCommand; }; return bCommand; };
void StopCommandSent(); void StopCommandSent();
TCommandType CommandCheck(); TCommandType CommandCheck();
bool IsVelocity(); bool IsVelocity() const;
void AssignEvents(TEvent *e); void AssignEvents(TEvent *e);
private: private:

View File

@@ -1752,7 +1752,7 @@ void TModel3d::Init()
// 2012-02 funkcje do tworzenia terenu z E3D // 2012-02 funkcje do tworzenia terenu z E3D
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int TModel3d::TerrainCount() int TModel3d::TerrainCount() const
{ // zliczanie kwadratów kilometrowych (główna { // zliczanie kwadratów kilometrowych (główna
// linia po Next) do tworznia tablicy // linia po Next) do tworznia tablicy
int i = 0; int i = 0;

View File

@@ -183,15 +183,13 @@ public:
}; };
void InitialRotate(bool doit); void InitialRotate(bool doit);
void BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t, std::vector<std::string> *n, bool dynamic); void BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t, std::vector<std::string> *n, bool dynamic);
void ReplacableSet(material_handle const *r, int a) static void ReplacableSet(material_handle const *r, int a) {
{
ReplacableSkinId = r; ReplacableSkinId = r;
iAlpha = a; iAlpha = a; };
};
void Name_Material( std::string const &Name ); void Name_Material( std::string const &Name );
void Name( std::string const &Name ); void Name( std::string const &Name );
// Ra: funkcje do budowania terenu z E3D // Ra: funkcje do budowania terenu z E3D
int Flags() { return iFlags; }; int Flags() const { return iFlags; };
void UnFlagNext() { iFlags &= 0x00FFFFFF; }; void UnFlagNext() { iFlags &= 0x00FFFFFF; };
void ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular ); void ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular );
// sets light level (alpha component of illumination color) to specified value // sets light level (alpha component of illumination color) to specified value
@@ -200,7 +198,7 @@ public:
return fMatrix ? *(fMatrix->TranslationGet()) + v_TransVector : v_TransVector; } return fMatrix ? *(fMatrix->TranslationGet()) + v_TransVector : v_TransVector; }
inline float3 Translation2Get() { inline float3 Translation2Get() {
return *(fMatrix->TranslationGet()) + Child->Translation1Get(); } return *(fMatrix->TranslationGet()) + Child->Translation1Get(); }
material_handle GetMaterial() { material_handle GetMaterial() const {
return m_material; } return m_material; }
void ParentMatrix(float4x4 *m); void ParentMatrix(float4x4 *m);
float MaxY( float4x4 const &m ); float MaxY( float4x4 const &m );
@@ -249,8 +247,8 @@ public:
void SaveToBinFile(std::string const &FileName); void SaveToBinFile(std::string const &FileName);
int Flags() const { return iFlags; }; int Flags() const { return iFlags; };
void Init(); void Init();
std::string NameGet() { return m_filename; }; std::string NameGet() const { return m_filename; };
int TerrainCount(); int TerrainCount() const;
TSubModel * TerrainSquare(int n); TSubModel * TerrainSquare(int n);
void deserialize(std::istream &s, size_t size, bool dynamic); void deserialize(std::istream &s, size_t size, bool dynamic);
}; };

View File

@@ -61,11 +61,11 @@ class garbage_collector {
public: public:
// constructor: // constructor:
garbage_collector( Container_ &Container, int const Secondstolive, int const Sweepsize, std::string const Resourcename = "resource" ) : garbage_collector( Container_ &Container, unsigned int const Secondstolive, std::size_t const Sweepsize, std::string const Resourcename = "resource" ) :
m_container( Container ), m_unusedresourcetimetolive{ std::chrono::seconds{ Secondstolive } },
m_unusedresourcetimetolive { std::chrono::seconds( Secondstolive ) }, m_unusedresourcesweepsize{ Sweepsize },
m_unusedresourcesweepsize( Sweepsize ), m_resourcename{ Resourcename },
m_resourcename( Resourcename ) m_container{ Container }
{} {}
// methods: // methods:

View File

@@ -625,7 +625,7 @@ opengl_texture::release( bool const Backup ) {
} }
void void
opengl_texture::set_filtering() { opengl_texture::set_filtering() const {
// default texture mode // default texture mode
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); ::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

View File

@@ -60,7 +60,7 @@ private:
void load_DDS(); void load_DDS();
void load_TEX(); void load_TEX();
void load_TGA(); void load_TGA();
void set_filtering(); void set_filtering() const;
void downsize( GLuint const Format ); void downsize( GLuint const Format );
// members // members

23
Track.h
View File

@@ -96,16 +96,11 @@ class TSwitchExtension
class TIsolated class TIsolated
{ // obiekt zbierający zajętości z kilku odcinków { // obiekt zbierający zajętości z kilku odcinków
int iAxles = 0; // ilość osi na odcinkach obsługiwanych przez obiekt public:
TIsolated *pNext = nullptr; // odcinki izolowane są trzymane w postaci listy jednikierunkowej // constructors
static TIsolated *pRoot; // początek listy
public:
std::string asName; // nazwa obiektu, baza do nazw eventów
TEvent *evBusy = nullptr; // zdarzenie wyzwalane po zajęciu grupy
TEvent *evFree = nullptr; // zdarzenie wyzwalane po całkowitym zwolnieniu zajętości grupy
TMemCell *pMemCell = nullptr; // automatyczna komórka pamięci, która współpracuje z odcinkiem izolowanym
TIsolated(); TIsolated();
TIsolated(const std::string &n, TIsolated *i); TIsolated(const std::string &n, TIsolated *i);
// methods
static void DeleteAll(); static void DeleteAll();
static TIsolated * Find(const std::string &n); // znalezienie obiektu albo utworzenie nowego static TIsolated * Find(const std::string &n); // znalezienie obiektu albo utworzenie nowego
void Modify(int i, TDynamicObject *o); // dodanie lub odjęcie osi void Modify(int i, TDynamicObject *o); // dodanie lub odjęcie osi
@@ -115,6 +110,16 @@ class TIsolated
return (pRoot); }; return (pRoot); };
TIsolated * Next() { TIsolated * Next() {
return (pNext); }; return (pNext); };
// members
std::string asName; // nazwa obiektu, baza do nazw eventów
TEvent *evBusy { nullptr }; // zdarzenie wyzwalane po zajęciu grupy
TEvent *evFree { nullptr }; // zdarzenie wyzwalane po całkowitym zwolnieniu zajętości grupy
TMemCell *pMemCell { nullptr }; // automatyczna komórka pamięci, która współpracuje z odcinkiem izolowanym
private:
// members
int iAxles { 0 }; // ilość osi na odcinkach obsługiwanych przez obiekt
TIsolated *pNext { nullptr }; // odcinki izolowane są trzymane w postaci listy jednikierunkowej
static TIsolated *pRoot; // początek listy
}; };
// trajektoria ruchu - opakowanie // trajektoria ruchu - opakowanie
@@ -184,7 +189,7 @@ public:
bool ScannedFlag = false; // McZapkie: do zaznaczania kolorem torów skanowanych przez AI bool ScannedFlag = false; // McZapkie: do zaznaczania kolorem torów skanowanych przez AI
TGroundNode *nFouling[ 2 ] = { nullptr, nullptr }; // współrzędne ukresu albo oporu kozła TGroundNode *nFouling[ 2 ] = { nullptr, nullptr }; // współrzędne ukresu albo oporu kozła
TTrack( scene::node_data const &Nodedata ); explicit TTrack( scene::node_data const &Nodedata );
virtual ~TTrack(); virtual ~TTrack();
void Init(); void Init();

View File

@@ -52,7 +52,7 @@ class TTraction : public editor::basic_node {
glm::dvec3 m_origin; glm::dvec3 m_origin;
geometry_handle m_geometry; geometry_handle m_geometry;
TTraction( scene::node_data const &Nodedata ); explicit TTraction( scene::node_data const &Nodedata );
void Load( cParser *parser, glm::dvec3 const &pOrigin ); void Load( cParser *parser, glm::dvec3 const &pOrigin );
// set origin point // set origin point

View File

@@ -199,8 +199,10 @@ private:
bind_buffer(); bind_buffer();
void void
delete_buffer(); delete_buffer();
static
void void
bind_streams( stream_units const &Units, unsigned int const Streams ); bind_streams( stream_units const &Units, unsigned int const Streams );
static
void void
release_streams(); release_streams();
@@ -310,7 +312,7 @@ private:
// methods // methods
inline inline
bool bool
valid( geometry_handle const &Geometry ) { valid( geometry_handle const &Geometry ) const {
return ( ( Geometry.bank != 0 ) return ( ( Geometry.bank != 0 )
&& ( Geometry.bank <= m_geometrybanks.size() ) ); } && ( Geometry.bank <= m_geometrybanks.size() ) ); }
inline inline

View File

@@ -394,7 +394,7 @@ basic_cell::register_end( TTraction *Traction ) {
// find a vehicle located nearest to specified point, within specified radius, optionally ignoring vehicles without drivers. reurns: located vehicle and distance // find a vehicle located nearest to specified point, within specified radius, optionally ignoring vehicles without drivers. reurns: located vehicle and distance
std::tuple<TDynamicObject *, float> std::tuple<TDynamicObject *, float>
basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ) { basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ) const {
TDynamicObject *vehiclenearest { nullptr }; TDynamicObject *vehiclenearest { nullptr };
float leastdistance { std::numeric_limits<float>::max() }; float leastdistance { std::numeric_limits<float>::max() };
@@ -429,7 +429,7 @@ basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlyco
// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint // finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint
std::tuple<TTrack *, int> std::tuple<TTrack *, int>
basic_cell::find( glm::dvec3 const &Point, TTrack const *Exclude ) { basic_cell::find( glm::dvec3 const &Point, TTrack const *Exclude ) const {
Math3D::vector3 point { Point.x, Point.y, Point.z }; // sad workaround until math classes unification Math3D::vector3 point { Point.x, Point.y, Point.z }; // sad workaround until math classes unification
int endpointid; int endpointid;
@@ -449,7 +449,7 @@ basic_cell::find( glm::dvec3 const &Point, TTrack const *Exclude ) {
// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint // finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint
std::tuple<TTraction *, int> std::tuple<TTraction *, int>
basic_cell::find( glm::dvec3 const &Point, TTraction const *Exclude ) { basic_cell::find( glm::dvec3 const &Point, TTraction const *Exclude ) const {
int endpointid; int endpointid;
@@ -468,7 +468,7 @@ basic_cell::find( glm::dvec3 const &Point, TTraction const *Exclude ) {
// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece // finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece
std::tuple<TTraction *, int, float> std::tuple<TTraction *, int, float>
basic_cell::find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ) { basic_cell::find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ) const {
TTraction TTraction
*tractionnearest { nullptr }; *tractionnearest { nullptr };

View File

@@ -116,16 +116,16 @@ public:
register_end( TTraction *Traction ); register_end( TTraction *Traction );
// find a vehicle located nearest to specified point, within specified radius. reurns: located vehicle and distance // find a vehicle located nearest to specified point, within specified radius. reurns: located vehicle and distance
std::tuple<TDynamicObject *, float> std::tuple<TDynamicObject *, float>
find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ); find( glm::dvec3 const &Point, float const Radius, bool const Onlycontrolled, bool const Findbycoupler ) const;
// finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint // finds a path with one of its ends located in specified point. returns: located path and id of the matching endpoint
std::tuple<TTrack *, int> std::tuple<TTrack *, int>
find( glm::dvec3 const &Point, TTrack const *Exclude ); find( glm::dvec3 const &Point, TTrack const *Exclude ) const;
// finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint // finds a traction piece with one of its ends located in specified point. returns: located traction piece and id of the matching endpoint
std::tuple<TTraction *, int> std::tuple<TTraction *, int>
find( glm::dvec3 const &Point, TTraction const *Exclude ); find( glm::dvec3 const &Point, TTraction const *Exclude ) const;
// finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece // finds a traction piece located nearest to specified point, sharing section with specified other piece and powered in specified direction. returns: located traction piece
std::tuple<TTraction *, int, float> std::tuple<TTraction *, int, float>
find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ); find( glm::dvec3 const &Point, TTraction const *Other, int const Currentdirection ) const;
// sets center point of the cell // sets center point of the cell
void void
center( glm::dvec3 Center ); center( glm::dvec3 Center );
@@ -351,6 +351,7 @@ private:
bool bool
point_inside( glm::dvec3 const &Location ); point_inside( glm::dvec3 const &Location );
// legacy method, trims provided shape to fit into a section. adds trimmed part at the end of provided list, returns true if changes were made // legacy method, trims provided shape to fit into a section. adds trimmed part at the end of provided list, returns true if changes were made
static
bool bool
RaTriangleDivider( shape_node &Shape, std::deque<shape_node> &Shapes ); RaTriangleDivider( shape_node &Shape, std::deque<shape_node> &Shapes );
// provides access to section enclosing specified point // provides access to section enclosing specified point

View File

@@ -307,7 +307,7 @@ struct basic_node {
public: public:
// constructor // constructor
basic_node( scene::node_data const &Nodedata ); explicit basic_node( scene::node_data const &Nodedata );
// destructor // destructor
virtual ~basic_node() = default; virtual ~basic_node() = default;
// methods // methods

View File

@@ -33,7 +33,7 @@ public:
// methods // methods
// legacy method, calculates changes in simulation state over specified time // legacy method, calculates changes in simulation state over specified time
void void
update( double dt, int iter ); update( double Deltatime, int Iterationcount );
bool bool
deserialize( std::string const &Scenariofile ); deserialize( std::string const &Scenariofile );