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

reformat: use auto on certain types

This commit is contained in:
jerrrrycho
2026-07-04 05:22:52 +02:00
parent f61068ff89
commit 20e7a99516
118 changed files with 2118 additions and 2063 deletions

View File

@@ -450,7 +450,7 @@ basic_cell::erase( TAnimModel *Instance ) {
if( mat != nullptr ) {
for( int i = 0; i < 5; ++i ) { key.skins[i] = mat->replacable_skins[i]; }
}
auto bucket = m_instancebuckets_opaque.find( key );
const auto bucket = m_instancebuckets_opaque.find( key );
if( bucket != m_instancebuckets_opaque.end() ) {
bucket->second.erase(
std::remove( std::begin( bucket->second ), std::end( bucket->second ), Instance ),
@@ -511,7 +511,7 @@ basic_cell::find( glm::dvec3 const &Point, float const Radius, bool const Onlyco
float distance;
float const distancecutoff { Radius * Radius }; // we'll ignore vehicles farther than this
for( auto *path : m_paths ) {
for (const auto *path : m_paths ) {
for( auto *vehicle : path->Dynamics ) {
if( true == Onlycontrolled
&& vehicle->Mechanik == nullptr ) {
@@ -682,7 +682,7 @@ basic_cell::launch_event( TEventLauncher *Launcher, bool local_only ) {
simulation::Events.AddToQuery( Launcher->Event1, nullptr );
}
} else {
command_relay commandrelay;
const command_relay commandrelay;
if (Global.shiftState && Launcher->Event2 != nullptr)
commandrelay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &Launcher->Event2->name());
else if (Launcher->Event1)
@@ -1031,7 +1031,7 @@ basic_region::basic_region() {
basic_region::~basic_region() {
for( auto *section : m_sections ) { if( section != nullptr ) { delete section; } }
for (const auto *section : m_sections ) { if( section != nullptr ) { delete section; } }
}
// potentially activates event handler with the same name as provided node, and within handler activation range
@@ -1110,8 +1110,8 @@ basic_region::is_scene( std::string const &Scenariofile ) const {
// file type and version check
std::ifstream input( filename, std::ios::binary );
uint32_t headermain{ sn_utils::ld_uint32( input ) };
uint32_t headertype{ sn_utils::ld_uint32( input ) };
const uint32_t headermain{ sn_utils::ld_uint32( input ) };
const uint32_t headertype{ sn_utils::ld_uint32( input ) };
if( headermain != EU07_FILEHEADER || headertype != EU07_FILEVERSION_REGION ) {
// wrong file type
@@ -1143,7 +1143,7 @@ basic_region::serialize( std::string const &Scenariofile ) const {
// sections
// TBD, TODO: build table of sections and file offsets, if we postpone section loading until they're within range
std::uint32_t sectioncount { 0 };
for( auto *section : m_sections ) {
for (const auto *section : m_sections ) {
if( section != nullptr ) {
++sectioncount;
}
@@ -1151,7 +1151,7 @@ basic_region::serialize( std::string const &Scenariofile ) const {
// section count, followed by section data
sn_utils::ls_uint32( output, sectioncount );
std::uint32_t sectionindex { 0 };
for( auto *section : m_sections ) {
for (const auto *section : m_sections ) {
// section data: section index, followed by length of section data, followed by section data
if( section != nullptr ) {
sn_utils::ls_uint32( output, sectionindex );
@@ -1181,8 +1181,8 @@ basic_region::deserialize( std::string const &Scenariofile ) {
// file type and version check
std::ifstream input( filename, std::ios::binary );
uint32_t headermain { sn_utils::ld_uint32( input ) };
uint32_t headertype { sn_utils::ld_uint32( input ) };
const uint32_t headermain { sn_utils::ld_uint32( input ) };
const uint32_t headertype { sn_utils::ld_uint32( input ) };
if( headermain != EU07_FILEHEADER || headertype != EU07_FILEVERSION_REGION ) {
// wrong file type
@@ -1210,7 +1210,7 @@ basic_region::deserialize( std::string const &Scenariofile ) {
void
basic_region::export_as_text( std::ostream &Output ) const {
for( auto *section : m_sections ) {
for (const auto *section : m_sections ) {
// text format export dumps only relevant basic objects from non-empty sections
if( section != nullptr ) {
section->export_as_text( Output );
@@ -1734,7 +1734,7 @@ void basic_region::update_poi_geometry()
vertices.push_back(std::move(sem->vertex()));
if (!m_map_poipoints) {
gfx::geometrybank_handle poibank = GfxRenderer->Create_Bank();
const gfx::geometrybank_handle poibank = GfxRenderer->Create_Bank();
m_map_poipoints = GfxRenderer->Insert(vertices, userdata, poibank, GL_POINTS);
}
else {

View File

@@ -60,7 +60,7 @@ void
shape_node::shapenode_data::serialize( std::ostream &Output ) const {
// bounding area
area.serialize( Output );
bool has_userdata = !userdata.empty();
const bool has_userdata = !userdata.empty();
// visibility
sn_utils::ls_float64( Output, rangesquared_min );
sn_utils::ls_float64( Output, rangesquared_max );
@@ -98,7 +98,7 @@ shape_node::shapenode_data::deserialize( std::istream &Input ) {
visible = sn_utils::d_bool( Input );
// material
translucent = sn_utils::d_bool( Input );
bool has_userdata = sn_utils::d_bool( Input );
const bool has_userdata = sn_utils::d_bool( Input );
auto const materialname { sn_utils::d_str( Input ) };
if( false == materialname.empty() ) {
material = GfxRenderer->Fetch_Material( materialname );

View File

@@ -41,7 +41,7 @@ node_groups::close()
if( true == m_activegroup.empty()
|| m_activegroup.top() != closinggroup ) {
auto lookup { m_groupmap.find( closinggroup ) };
const auto lookup { m_groupmap.find( closinggroup ) };
if( lookup != m_groupmap.end()
&& lookup->second.nodes.size() + lookup->second.events.size() <= 1 ) {
@@ -62,7 +62,7 @@ bool node_groups::assign_cross_switch(map::track_switch& sw, std::string &sw_nam
if (!sw.action[idx])
return false;
auto multi = dynamic_cast<multi_event*>(sw.action[idx]);
const auto multi = dynamic_cast<multi_event*>(sw.action[idx]);
if (!multi)
return false;
@@ -73,13 +73,13 @@ bool node_groups::assign_cross_switch(map::track_switch& sw, std::string &sw_nam
if (it->size() > 4)
continue;
int pos_a = it->find_last_of('a');
int pos_b = it->find_last_of('b');
int pos_c = it->find_last_of('c');
int pos_d = it->find_last_of('d');
const int pos_a = it->find_last_of('a');
const int pos_b = it->find_last_of('b');
const int pos_c = it->find_last_of('c');
const int pos_d = it->find_last_of('d');
int pos_0 = it->find_last_of('0');
int pos_1 = it->find_last_of('1');
const int pos_0 = it->find_last_of('0');
const int pos_1 = it->find_last_of('1');
int pos;
@@ -135,7 +135,7 @@ node_groups::update_map()
}
if (Global.map_manualswitchcontrol) {
if (auto track = dynamic_cast<TTrack*>(node)) {
if (const auto track = dynamic_cast<TTrack*>(node)) {
if (track->eType != tt_Switch)
continue;
@@ -161,7 +161,7 @@ node_groups::update_map()
if (sw_name.size() <= 2)
continue;
char lastc = sw_name.back();
const char lastc = sw_name.back();
sw_name.pop_back();
if (sw_name.back() == '_')
sw_name.pop_back();
@@ -184,7 +184,7 @@ node_groups::update_map()
continue;
last_switch->track[lastc - 'a'] = track;
for (auto trk : last_switch->track)
for (const auto trk : last_switch->track)
if (!trk)
goto skip_e;
@@ -203,7 +203,7 @@ node_groups::update_map()
last_switch_map.erase(sw_name);
}
} else {
if (auto launcher = dynamic_cast<TEventLauncher*>(node)) {
if (const auto launcher = dynamic_cast<TEventLauncher*>(node)) {
if (!launcher || !launcher->Event1 || !launcher->Event2)
continue;
@@ -287,7 +287,7 @@ node_groups::export_as_text( std::ostream &Output, bool Dirty ) const {
node->export_as_text( Output );
}
for( auto *event : group.second.events ) {
for (const auto *event : group.second.events ) {
if (Dirty)
continue;

View File

@@ -195,7 +195,7 @@ void sn_utils::ls_int64(std::ostream &s, int64_t v)
void sn_utils::ls_float32(std::ostream &s, float t)
{
uint32_t v = reinterpret_cast<uint32_t&>(t);
const uint32_t v = reinterpret_cast<uint32_t&>(t);
uint8_t buf[4];
buf[0] = v;
buf[1] = v >> 8;
@@ -206,7 +206,7 @@ void sn_utils::ls_float32(std::ostream &s, float t)
void sn_utils::ls_float64(std::ostream &s, double t)
{
uint64_t v = reinterpret_cast<uint64_t&>(t);
const uint64_t v = reinterpret_cast<uint64_t&>(t);
uint8_t buf[8];
buf[0] = v;
buf[1] = v >> 8;