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

reformat: remove redundant parentheses

This commit is contained in:
jerrrrycho
2026-06-30 21:19:46 +02:00
parent 7c88907f6b
commit d85096f64d
108 changed files with 4098 additions and 4662 deletions

View File

@@ -121,7 +121,7 @@ state_manager::update_clocks() {
// Ra 2014-07: przeliczenie kąta czasu (do animacji zależnych od czasu)
auto const &time = simulation::Time.data();
Global.fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + ( ( time.wSecond + 0.001 * time.wMilliseconds ) / 240.0 );
Global.fTimeAngleDeg = time.wHour * 15.0 + time.wMinute * 0.25 + (time.wSecond + 0.001 * time.wMilliseconds) / 240.0;
Global.fClockAngleDeg[ 0 ] = 36.0 * ( time.wSecond % 10 ); // jednostki sekund
Global.fClockAngleDeg[ 1 ] = 36.0 * ( time.wSecond / 10 ); // dziesiątki sekund
Global.fClockAngleDeg[ 2 ] = 36.0 * ( time.wMinute % 10 ); // jednostki minut
@@ -233,7 +233,7 @@ void state_manager::process_commands() {
// NOTE: because malformed scenario can have vehicle name duplicates we first try to locate vehicle in world, with name search as fallback
TDynamicObject *targetvehicle = std::get<TDynamicObject *>( simulation::Region->find_vehicle( commanddata.location, 50, false, false ) );
if( ( targetvehicle == nullptr ) || ( targetvehicle->name() != commanddata.payload ) ) {
if( targetvehicle == nullptr || targetvehicle->name() != commanddata.payload ) {
targetvehicle = simulation::Vehicles.find( commanddata.payload );
}
@@ -251,8 +251,8 @@ void state_manager::process_commands() {
}
auto const sameconsist{
( targetvehicle->ctOwner == currentvehicle->Mechanik )
|| ( targetvehicle->ctOwner == currentvehicle->ctOwner ) };
targetvehicle->ctOwner == currentvehicle->Mechanik
|| targetvehicle->ctOwner == currentvehicle->ctOwner };
auto const isincharge{ currentvehicle->Mechanik->primary() };
auto const aidriveractive{ currentvehicle->Mechanik->AIControllFlag };
// TODO: support for primary mode request passed as commanddata.param1
@@ -387,7 +387,7 @@ void state_manager::process_commands() {
// pantographs
for( auto idx = 0; idx < vehicle->iAnimType[ ANIM_PANTS ]; ++idx ) {
auto &pantograph { *( vehicle->pants[ idx ].fParamPants ) };
auto &pantograph { *vehicle->pants[idx].fParamPants };
if( pantograph.PantWys >= 0.0 ) // negative value means pantograph is broken
continue;
pantograph.fAngleL = pantograph.fAngleL0;

View File

@@ -61,28 +61,25 @@ world_environment::compute_season( int const Yearday ) {
void
world_environment::compute_weather() {
Global.Weather = (
Global.Overcast <= 0.10 ? "clear:" :
Global.Overcast <= 0.50 ? "scattered:" :
Global.Overcast <= 0.90 ? "broken:" :
Global.Overcast <= 1.00 ? "overcast:" :
(Global.AirTemperature > 1 ? "rain:" :
"snow:" ) );
Global.Weather = Global.Overcast <= 0.10 ? "clear:" :
Global.Overcast <= 0.50 ? "scattered:" :
Global.Overcast <= 0.90 ? "broken:" :
Global.Overcast <= 1.00 ? "overcast:" :
Global.fTurbidity = (
Global.Overcast <= 0.10 ? 3 :
Global.Overcast <= 0.20 ? 4 :
Global.Overcast <= 0.30 ? 5 :
Global.Overcast <= 0.40 ? 5 :
Global.Overcast <= 0.50 ? 5 :
Global.Overcast <= 0.60 ? 5 :
Global.Overcast <= 0.70 ? 6 :
Global.Overcast <= 0.80 ? 7 :
Global.Overcast <= 0.90 ? 8 :
Global.Overcast > 0.90 ? 9 :
9
);
Global.AirTemperature > 1 ? "rain:" :
"snow:";
Global.fTurbidity = Global.Overcast <= 0.10 ? 3 :
Global.Overcast <= 0.20 ? 4 :
Global.Overcast <= 0.30 ? 5 :
Global.Overcast <= 0.40 ? 5 :
Global.Overcast <= 0.50 ? 5 :
Global.Overcast <= 0.60 ? 5 :
Global.Overcast <= 0.70 ? 6 :
Global.Overcast <= 0.80 ? 7 :
Global.Overcast <= 0.90 ? 8 :
Global.Overcast > 0.90 ? 9 :
9;
}
void
@@ -96,9 +93,7 @@ world_environment::init() {
{
auto const rainsoundoverride { simulation::Sound_overrides.find( "weather.rainsound:" ) };
m_rainsound.deserialize(
( rainsoundoverride != simulation::Sound_overrides.end() ?
rainsoundoverride->second :
"rain-sound-loop" ),
rainsoundoverride != simulation::Sound_overrides.end() ? rainsoundoverride->second : "rain-sound-loop",
sound_type::single );
}
m_wind = basic_wind{
@@ -135,7 +130,7 @@ world_environment::update() {
float keylightintensity;
glm::vec3 keylightcolor;
Global.SunAngle = m_sun.getAngle();
if ((moonlightlevel > sunlightlevel) && (Global.SunAngle <(-20)))
if (moonlightlevel > sunlightlevel && Global.SunAngle < -20)
{
// rare situations when the moon is brighter than the sun, typically at night
Global.SunAngle = m_moon.getAngle();
@@ -165,7 +160,7 @@ world_environment::update() {
auto const skydomecolour = m_skydome.GetAverageColor();
auto const skydomehsv = colors::RGBtoHSV( skydomecolour );
// sun strength is reduced by overcast level
keylightintensity *= ( 1.0f - std::min( 1.f, Global.Overcast ) * 0.65f );
keylightintensity *= 1.0f - std::min(1.f, Global.Overcast) * 0.65f;
// intensity combines intensity of the sun and the light reflected by the sky dome
// it'd be more technically correct to have just the intensity of the sun here,
@@ -180,7 +175,7 @@ world_environment::update() {
// tonal impact of skydome color is inversely proportional to how high the sun is above the horizon
// (this is pure conjecture, aimed more to 'look right' than be accurate)
float const ambienttone = std::clamp( 1.0f - ( Global.SunAngle / 90.0f ), 0.0f, 1.0f );
float const ambienttone = std::clamp( 1.0f - Global.SunAngle / 90.0f, 0.0f, 1.0f );
float const ambientintensitynightfactor = 1.f - 0.75f * std::clamp( -m_sun.getAngle(), 0.0f, 18.0f ) / 18.0f;
Global.DayLight.ambient[ 0 ] = std::lerp( skydomehsv.z, skydomecolour.r, ambienttone ) * ambientintensitynightfactor;
Global.DayLight.ambient[ 1 ] = std::lerp( skydomehsv.z, skydomecolour.g, ambienttone ) * ambientintensitynightfactor;
@@ -190,23 +185,17 @@ world_environment::update() {
// update the fog. setting it to match the average colour of the sky dome is cheap
// but quite effective way to make the distant items blend with background better
Global.FogColor = ((m_skydome.GetAverageHorizonColor()) * keylightcolor) *
Global.FogColor = m_skydome.GetAverageHorizonColor() * keylightcolor *
std::clamp((float)Global.fLuminance, 0.f, 1.f);
// weather-related simulation factors
Global.FrictionWeatherFactor = (
Global.Weather == "rain:" ? 0.85f :
Global.Weather == "snow:" ? 0.75f :
1.0f );
Global.FrictionWeatherFactor = Global.Weather == "rain:" ? 0.85f : Global.Weather == "snow:" ? 0.75f : 1.0f;
Global.Period = (
m_sun.getAngle() > -12.0f ?
"day:" :
"night:" );
Global.Period = m_sun.getAngle() > -12.0f ? "day:" : "night:";
if( ( true == ( FreeFlyModeFlag || Global.CabWindowOpen ) )
&& ( Global.Weather == "rain:" ) ) {
if( true == (FreeFlyModeFlag || Global.CabWindowOpen)
&& Global.Weather == "rain:" ) {
if( m_rainsound.is_combined() ) {
m_rainsound.pitch( Global.Overcast - 1.0 );
}

View File

@@ -53,8 +53,8 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) {
// TODO: check first for presence of serialized binary files
// if this fails, fall back on the legacy text format
state->scratchpad.name = Scenariofile;
if( ( true == Global.file_binary_terrain )
&& ( Scenariofile != "$.scn" ) ) {
if( true == Global.file_binary_terrain
&& Scenariofile != "$.scn" ) {
// compilation to binary file isn't supported for rainsted-created overrides
// NOTE: we postpone actual loading of the scene until we process time, season and weather data
state->scratchpad.binary.terrain = Region->is_scene( Scenariofile ) ;
@@ -158,9 +158,9 @@ state_serializer::deserialize_continue(std::shared_ptr<deserializer_state> state
scene::Groups.update_map();
Region->create_map_geometry();
if( ( true == Global.file_binary_terrain )
&& ( false == state->scratchpad.binary.terrain )
&& ( state->scenariofile != "$.scn" ) ) {
if( true == Global.file_binary_terrain
&& false == state->scratchpad.binary.terrain
&& state->scenariofile != "$.scn" ) {
// if we didn't find usable binary version of the scenario files, create them now for future use
// as long as the scenario file wasn't rainsted-created base file override
Region->serialize( state->scenariofile );
@@ -175,8 +175,8 @@ state_serializer::deserialize_isolated( cParser &Input, scene::scratch_data &Scr
auto token { Input.getToken<std::string>() };
auto *groupowner { TIsolated::Find( token ) };
// ...followed by list of its tracks
while( ( false == ( token = Input.getToken<std::string>() ).empty() )
&& ( token != "endisolated" ) ) {
while( false == (token = Input.getToken<std::string>()).empty()
&& token != "endisolated" ) {
auto *track { simulation::Paths.find( token ) };
if( track != nullptr )
track->AddIsolated( groupowner );
@@ -191,8 +191,8 @@ state_serializer::deserialize_area( cParser &Input, scene::scratch_data &Scratch
auto token { Input.getToken<std::string>() };
auto *groupowner { TIsolated::Find( token ) };
// ...followed by list of its children
while( ( false == ( token = Input.getToken<std::string>() ).empty() )
&& ( token != "endarea" ) ) {
while( false == (token = Input.getToken<std::string>()).empty()
&& token != "endarea" ) {
// bind the children with their parent
auto *isolated { TIsolated::Find( token ) };
isolated->parent( groupowner );
@@ -203,8 +203,8 @@ void
state_serializer::deserialize_assignment( cParser &Input, scene::scratch_data &Scratchpad ) {
std::string token { Input.getToken<std::string>() };
while( ( false == token.empty() )
&& ( token != "endassignment" ) ) {
while( false == token.empty()
&& token != "endassignment" ) {
// assignment is expected to come as string pairs: language id and the actual assignment enclosed in quotes to form a single token
auto assignment{ Input.getToken<std::string>() };
win1250_to_ascii( assignment );
@@ -254,8 +254,8 @@ state_serializer::deserialize_atmo( cParser &Input, scene::scratch_data &Scratch
// NOTE: ugly, clean it up when we're done with world refactoring
simulation::Environment.compute_weather();
}
while( ( false == token.empty() )
&& ( token != "endatmo" ) ) {
while( false == token.empty()
&& token != "endatmo" ) {
// anything else left in the section has no defined meaning
token = Input.getToken<std::string>();
}
@@ -394,11 +394,11 @@ void state_serializer::init_time() {
if( true == Global.ScenarioTimeCurrent ) {
// calculate time shift required to match scenario time with local clock
auto const *localtime = std::gmtime( &Global.starting_timestamp );
Global.ScenarioTimeOffset = ( ( localtime->tm_hour * 60 + localtime->tm_min ) - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
Global.ScenarioTimeOffset = ( localtime->tm_hour * 60 + localtime->tm_min - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
}
else if( false == std::isnan( Global.ScenarioTimeOverride ) ) {
// scenario time override takes precedence over scenario time offset
Global.ScenarioTimeOffset = ( ( Global.ScenarioTimeOverride * 60 ) - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
Global.ScenarioTimeOffset = (Global.ScenarioTimeOverride * 60 - ( time.wHour * 60 + time.wMinute ) ) / 60.f;
}
}
@@ -457,9 +457,9 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
ErrorLog( "Bad scenario: duplicate vehicle name \"" + vehicle->name() + "\" defined in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" );
}
if( ( vehicle->MoverParameters->CategoryFlag == 1 ) // trains only
&& ( ( ( vehicle->LightList( end::front ) & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 )
|| ( ( vehicle->LightList( end::rear ) & ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) != 0 ) ) ) {
if( vehicle->MoverParameters->CategoryFlag == 1 // trains only
&& ( (vehicle->LightList(end::front) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0
|| (vehicle->LightList(end::rear) & (light::headlight_left | light::headlight_right | light::headlight_upper)) != 0 ) ) {
simulation::Lights.insert( vehicle );
}
}
@@ -564,16 +564,16 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
}
}
}
else if( ( nodedata.type == "triangles" )
|| ( nodedata.type == "triangle_strip" )
|| ( nodedata.type == "triangle_fan" ) ) {
else if( nodedata.type == "triangles"
|| nodedata.type == "triangle_strip"
|| nodedata.type == "triangle_fan" ) {
auto const skip {
// all shapes will be loaded from the binary version of the file
( true == Scratchpad.binary.terrain )
true == Scratchpad.binary.terrain
// crude way to detect fixed switch trackbed geometry
|| ( ( true == Global.CreateSwitchTrackbeds )
&& ( Input.Name().size() >= 15 )
|| ( true == Global.CreateSwitchTrackbeds
&& Input.Name().size() >= 15
&& Input.Name().starts_with("scenery/zwr")
&& Input.Name().ends_with(".inc") ) };
@@ -589,9 +589,9 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch
skip_until( Input, "endtri" );
}
}
else if( ( nodedata.type == "lines" )
|| ( nodedata.type == "line_strip" )
|| ( nodedata.type == "line_loop" ) ) {
else if( nodedata.type == "lines"
|| nodedata.type == "line_strip"
|| nodedata.type == "line_loop" ) {
if( false == Scratchpad.binary.terrain ) {
@@ -691,10 +691,7 @@ state_serializer::deserialize_scale( cParser &Input, scene::scratch_data &Scratc
factor = glm::vec3( 1.0f );
}
// scales compose component-wise, mirroring how origin offsets compose additively.
glm::vec3 const parent = (
Scratchpad.location.scale.empty() ?
glm::vec3( 1.0f ) :
Scratchpad.location.scale.top() );
glm::vec3 const parent = Scratchpad.location.scale.empty() ? glm::vec3(1.0f) : Scratchpad.location.scale.top();
Scratchpad.location.scale.emplace( factor * parent );
}
@@ -826,7 +823,7 @@ state_serializer::deserialize_editorterrain(cParser &Input, scene::scratch_data
if (!folder.empty() && cells > 0 && cellsize > 0.0f)
{
EditorTerrain.directory(folder);
EditorTerrain.configure(cells, cellsize, (radius < 0 ? 0 : radius), 0.0f, std::string());
EditorTerrain.configure(cells, cellsize, radius < 0 ? 0 : radius, 0.0f, std::string());
EditorTerrain.active(true);
WriteLog("Editor terrain stream enabled: " + folder + " (cells " + std::to_string(cells)
+ ", cellsize " + std::to_string(cellsize) + ", radius " + std::to_string(radius) + ")",
@@ -837,8 +834,8 @@ state_serializer::deserialize_editorterrain(cParser &Input, scene::scratch_data
void
state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &Scratchpad ) {
if( ( false == Scratchpad.trainset.is_open )
|| ( true == Scratchpad.trainset.vehicles.empty() ) ) {
if( false == Scratchpad.trainset.is_open
|| true == Scratchpad.trainset.vehicles.empty() ) {
// not bloody likely but we better check for it just the same
ErrorLog( "Bad trainset: empty trainset defined in file \"" + Input.Name() + "\" (line " + std::to_string( Input.Line() - 1 ) + ")" );
Scratchpad.trainset.is_open = false;
@@ -848,8 +845,8 @@ state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &
std::size_t vehicleindex { 0 };
for( auto *vehicle : Scratchpad.trainset.vehicles ) {
// go through list of vehicles in the trainset, coupling them together and checking for potential driver
if( ( vehicle->Mechanik != nullptr )
&& ( vehicle->Mechanik->primary() ) ) {
if( vehicle->Mechanik != nullptr
&& vehicle->Mechanik->primary() ) {
// primary driver will receive the timetable for this trainset
Scratchpad.trainset.driver = vehicle;
// they'll also receive assignment data if there's any
@@ -883,9 +880,7 @@ state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &
// place end signals only on trains without a driver, activate markers otherwise
Scratchpad.trainset.vehicles.back()->RaLightsSet(
-1,
( Scratchpad.trainset.driver != nullptr ?
light::redmarker_left | light::redmarker_right | light::rearendsignals :
light::rearendsignals ) );
Scratchpad.trainset.driver != nullptr ? light::redmarker_left | light::redmarker_right | light::rearendsignals : light::rearendsignals );
}
// all done
Scratchpad.trainset.is_open = false;
@@ -918,10 +913,7 @@ state_serializer::deserialize_traction( cParser &Input, scene::scratch_data &Scr
}
// TODO: refactor track and wrapper classes and their de/serialization. do offset and rotation after deserialization is done
auto *traction = new TTraction( Nodedata );
auto offset = (
Scratchpad.location.offset.empty() ?
glm::dvec3() :
Scratchpad.location.offset.top() );
auto offset = Scratchpad.location.offset.empty() ? glm::dvec3() : Scratchpad.location.offset.top();
traction->Load( &Input, offset );
return traction;
@@ -1020,45 +1012,27 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra
replace_slashes(skinfile);
replace_slashes(mmdfile);
auto const pathname = (
Scratchpad.trainset.is_open ?
Scratchpad.trainset.track :
Input.getToken<std::string>() );
auto const pathname = Scratchpad.trainset.is_open ? Scratchpad.trainset.track : Input.getToken<std::string>();
auto const offset { Input.getToken<double>( false ) };
auto const drivertype { Input.getToken<std::string>() };
auto const couplingdata = (
Scratchpad.trainset.is_open ?
Input.getToken<std::string>() :
"3" );
auto const velocity = (
Scratchpad.trainset.is_open ?
Scratchpad.trainset.velocity :
Input.getToken<float>( false ) );
auto const couplingdata = Scratchpad.trainset.is_open ? Input.getToken<std::string>() : "3";
auto const velocity = Scratchpad.trainset.is_open ? Scratchpad.trainset.velocity : Input.getToken<float>(false);
// extract coupling type and optional parameters
auto const couplingdatawithparams = couplingdata.find( '.' );
auto coupling = (
couplingdatawithparams != std::string::npos ?
std::atoi( couplingdata.substr( 0, couplingdatawithparams ).c_str() ) :
std::atoi( couplingdata.c_str() ) );
auto coupling = couplingdatawithparams != std::string::npos ? std::atoi(couplingdata.substr(0, couplingdatawithparams).c_str()) : std::atoi(couplingdata.c_str());
if( coupling < 0 ) {
// sprzęg zablokowany (pojazdy nierozłączalne przy manewrach)
coupling = ( -coupling ) | coupling::permanent;
coupling = -coupling | coupling::permanent;
}
if( ( offset != -1.0 )
&& ( std::abs( offset ) > 0.5 ) ) { // maksymalna odległość między sprzęgami - do przemyślenia
if( offset != -1.0
&& std::abs(offset) > 0.5 ) { // maksymalna odległość między sprzęgami - do przemyślenia
// likwidacja sprzęgu, jeśli odległość zbyt duża - to powinno być uwzględniane w fizyce sprzęgów...
coupling = coupling::faux;
}
auto const params = (
couplingdatawithparams != std::string::npos ?
couplingdata.substr( couplingdatawithparams + 1 ) :
"" );
auto const params = couplingdatawithparams != std::string::npos ? couplingdata.substr(couplingdatawithparams + 1) : "";
// load amount and type
auto loadcount { Input.getToken<int>( false ) };
auto loadtype = (
loadcount ?
Input.getToken<std::string>() :
"" );
auto loadtype = loadcount ? Input.getToken<std::string>() : "";
if( loadtype == "enddynamic" ) {
// idiotoodporność: ładunek bez podanego typu nie liczy się jako ładunek
loadcount = 0;
@@ -1073,11 +1047,11 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra
return nullptr;
}
if( ( true == Scratchpad.trainset.vehicles.empty() ) // jeśli pierwszy pojazd,
&& ( false == path->m_events0.empty() ) // tor ma Event0
&& ( std::abs( velocity ) <= 1.f ) // a skład stoi
&& ( Scratchpad.trainset.offset >= 0.0 ) // ale może nie sięgać na owy tor
&& ( Scratchpad.trainset.offset < 8.0 ) ) { // i raczej nie sięga
if( true == Scratchpad.trainset.vehicles.empty() // jeśli pierwszy pojazd,
&& false == path->m_events0.empty() // tor ma Event0
&& std::abs(velocity) <= 1.f // a skład stoi
&& Scratchpad.trainset.offset >= 0.0 // ale może nie sięgać na owy tor
&& Scratchpad.trainset.offset < 8.0 ) { // i raczej nie sięga
// przesuwamy około pół EU07 dla wstecznej zgodności
Scratchpad.trainset.offset = 8.0;
}
@@ -1089,22 +1063,20 @@ state_serializer::deserialize_dynamic( cParser &Input, scene::scratch_data &Scra
Nodedata.name,
datafolder, skinfile, mmdfile,
path,
( offset == -1.0 ?
Scratchpad.trainset.offset :
Scratchpad.trainset.offset - offset ),
offset == -1.0 ? Scratchpad.trainset.offset : Scratchpad.trainset.offset - offset,
drivertype,
velocity,
Scratchpad.trainset.name,
loadcount, loadtype,
( offset == -1.0 ),
offset == -1.0,
params );
if( length != 0.0 ) { // zero oznacza błąd
// przesunięcie dla kolejnego, minus bo idziemy w stronę punktu 1
Scratchpad.trainset.offset -= length;
// automatically establish permanent connections for couplers which specify them in their definitions
if( ( coupling != 0 )
&& ( vehicle->MoverParameters->Couplers[ ( offset == -1.0 ? end::front : end::rear ) ].AllowedFlag & coupling::permanent ) ) {
if( coupling != 0
&& vehicle->MoverParameters->Couplers[(offset == -1.0 ? end::front : end::rear)].AllowedFlag & coupling::permanent ) {
coupling |= coupling::permanent;
}
if( true == Scratchpad.trainset.is_open ) {
@@ -1160,8 +1132,8 @@ void
state_serializer::skip_until( cParser &Input, std::string const &Token ) {
std::string token { Input.getToken<std::string>() };
while( ( false == token.empty() )
&& ( token != Token ) ) {
while( false == token.empty()
&& token != Token ) {
token = Input.getToken<std::string>();
}
@@ -1296,8 +1268,8 @@ state_serializer::export_as_text(std::string const &Scenariofile) const {
// mem cells
ctrfile << "// memory cells\n";
for( auto const *memorycell : Memory.sequence() ) {
if( ( true == memorycell->is_exportable )
&& ( memorycell->group() == null_handle ) ) {
if( true == memorycell->is_exportable
&& memorycell->group() == null_handle) {
memorycell->export_as_text( ctrfile );
}
}

View File

@@ -28,7 +28,7 @@ scenario_time::init(std::time_t timestamp) {
// potentially adjust scenario clock
auto const requestedtime { clamp_circular<int>( m_time.wHour * 60 + m_time.wMinute + Global.ScenarioTimeOffset * 60, 24 * 60 ) };
auto const requestedhour { ( requestedtime / 60 ) % 24 };
auto const requestedhour { requestedtime / 60 % 24 };
auto const requestedminute { requestedtime % 60 };
// cache requested elements, if any
@@ -50,8 +50,8 @@ scenario_time::init(std::time_t timestamp) {
if( requestedhour != -1 ) { m_time.wHour = static_cast<WORD>( std::clamp( requestedhour, 0, 23 ) ); }
if( requestedminute != -1 ) { m_time.wMinute = static_cast<WORD>( std::clamp( requestedminute, 0, 59 ) ); }
// if the time is taken from the local clock leave the seconds intact, otherwise set them to zero
if( ( requestedhour != -1 )
|| ( requestedminute != 1 ) ) {
if( requestedhour != -1
|| requestedminute != 1 ) {
m_time.wSecond = 0;
}
@@ -82,13 +82,13 @@ scenario_time::init(std::time_t timestamp) {
zonebias += timezoneinfo.StandardBias;
}
m_timezonebias = ( zonebias / 60.0 );
m_timezonebias = zonebias / 60.0;
}
void
scenario_time::update( double const Deltatime ) {
m_milliseconds += ( 1000.0 * Deltatime );
m_milliseconds += 1000.0 * Deltatime;
while( m_milliseconds >= 1000.0 ) {
++m_time.wSecond;
@@ -154,7 +154,7 @@ scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yea
int const leap { is_leap( Year ) };
WORD idx = 1;
while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) {
while( idx < 13 && Yearday >= daytab[leap][idx] ) {
++idx;
}
@@ -178,7 +178,7 @@ scenario_time::julian_day() const {
const int gregorianswitchday = 2299160;
if( JD > gregorianswitchday ) {
int K3 = std::floor( std::floor( ( yy * 0.01 ) + 49 ) * 0.75 ) - 38;
int K3 = std::floor( std::floor( yy * 0.01 + 49 ) * 0.75 ) - 38;
JD -= K3;
}
@@ -201,10 +201,10 @@ scenario_time::day_of_week( int const Day, int const Month, int const Year ) con
int const m = Month > 2 ? Month : Month + 12;
int const y = Month > 2 ? Year : Year - 1;
int const h = ( q + ( 26 * ( m + 1 ) / 10 ) + y + ( y / 4 ) + 6 * ( y / 100 ) + ( y / 400 ) ) % 7;
int const h = ( q + 26 * (m + 1) / 10 + y + y / 4 + 6 * ( y / 100 ) + y / 400 ) % 7;
/* return ( (h + 5) % 7 ) + 1; // iso week standard, with monday = 1
*/ return ( (h + 6) % 7 ) + 1; // sunday = 1 numbering method, used in north america, japan
*/ return (h + 6) % 7 + 1; // sunday = 1 numbering method, used in north america, japan
}
// calculates day of month for specified weekday of specified month of the year
@@ -251,7 +251,7 @@ scenario_time::convert_transition_time( SYSTEMTIME &Time ) const {
bool
scenario_time::is_leap( int const Year ) const {
return ( ( Year % 4 == 0 ) && ( ( Year % 100 != 0 ) || ( Year % 400 == 0 ) ) );
return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
}
//---------------------------------------------------------------------------

View File

@@ -34,7 +34,7 @@ public:
inline
double
second() const {
return ( m_time.wMilliseconds * 0.001 + m_time.wSecond ); }
return m_time.wMilliseconds * 0.001 + m_time.wSecond; }
inline
int
year_day() const {