16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 17:09:19 +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

@@ -795,11 +795,11 @@ std::unordered_map<std::string, user_command> commandMap = {
void command_queue::update()
{
double delta = Timer::GetDeltaTime();
const double delta = Timer::GetDeltaTime();
for (auto c : m_active_continuous)
{
command_data data({c.first, GLFW_REPEAT, 0.0, 0.0, delta, false, glm::vec3()}); // todo: improve
auto lookup = m_commands.emplace( c.second, commanddata_sequence() );
const auto lookup = m_commands.emplace( c.second, commanddata_sequence() );
// recipient stack was either located or created, so we can add to it quite safely
lookup.first->second.emplace_back( data );
}
@@ -809,7 +809,7 @@ void command_queue::update()
void
command_queue::push( command_data const &Command, uint32_t const Recipient ) {
if (is_network_target(Recipient)) {
auto lookup = m_intercept_queue.emplace(Recipient, commanddata_sequence());
const auto lookup = m_intercept_queue.emplace(Recipient, commanddata_sequence());
lookup.first->second.emplace_back(Command);
} else {
push_direct(Command, Recipient);
@@ -828,7 +828,7 @@ void command_queue::push_direct(const command_data &Command, const uint32_t Reci
return;
}
auto lookup = m_commands.emplace( Recipient, commanddata_sequence() );
const auto lookup = m_commands.emplace( Recipient, commanddata_sequence() );
// recipient stack was either located or created, so we can add to it quite safely
lookup.first->second.emplace_back( Command );
}
@@ -837,7 +837,7 @@ void command_queue::push_direct(const command_data &Command, const uint32_t Reci
bool
command_queue::pop( command_data &Command, uint32_t const Recipient ) {
auto lookup = m_commands.find( Recipient );
const auto lookup = m_commands.find( Recipient );
if( lookup == m_commands.end() ) {
// no command stack for this recipient, so no commands
return false;

View File

@@ -139,7 +139,7 @@ mouse_slider::on_move( double const Mousex, double const Mousey ) {
auto const controledge { Global.window_size.y * 0.5 + controlsize * 0.5 };
auto const stepsize { controlsize / m_valuerange };
auto mousey = std::clamp( Mousey, controledge - controlsize, controledge );
const auto mousey = std::clamp( Mousey, controledge - controlsize, controledge );
m_value = m_analogue ? (controledge - mousey) / controlsize : std::floor((controledge - mousey) / stepsize);
if( m_invertrange ) {
m_value = ( m_analogue ? 1.0 : m_valuerange ) - m_value; }
@@ -285,7 +285,7 @@ drivermouse_input::scroll( double const Xoffset, double const Yoffset ) {
else {
// scroll adjusts master controller
// TODO: allow configurable scroll commands
auto command {
const auto command {
adjust_command(
Yoffset > 0.0 ?
m_wheelbindings.up :

View File

@@ -238,7 +238,7 @@ void keyboard_input::dump_bindings()
for (const std::pair<user_command, std::tuple<int, std::string>> &binding : m_bindingsetups) {
stream << simulation::Commands_descriptions[static_cast<std::size_t>(binding.first)].name << ' ';
int keycode = std::get<int>(binding.second);
const int keycode = std::get<int>(binding.second);
auto it = keytonamemap.find(keycode & 0xFFFF);
if (it != keytonamemap.end()) {
if (keycode & keymodifier::control)

View File

@@ -68,7 +68,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
|| typeid(*event) == typeid(lights_event)
|| event->m_sibling != 0 ) {
// tylko jawne albo niejawne Multiple
command_relay relay;
const command_relay relay;
relay.post(user_command::queueevent, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &event->name());
}
}
@@ -78,13 +78,13 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
case 3: // rozkaz dla AI
if (Global.iMultiplayer)
{
int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
const int i = int(pRozkaz->cString[8]); // długość pierwszego łańcucha (z przodu dwa floaty)
CommLog(
Now() + " " + std::to_string(pRozkaz->iComm) + " " +
std::string(pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[10 + i]) +
" rcvd");
// nazwa pojazdu jest druga
auto *vehicle = simulation::Vehicles.find( { pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[ 10 + i ] } );
const auto *vehicle = simulation::Vehicles.find( { pRozkaz->cString + 11 + i, (unsigned)pRozkaz->cString[ 10 + i ] } );
if( vehicle != nullptr
&& vehicle->Mechanik != nullptr ) {
vehicle->Mechanik->PutCommand(
@@ -114,7 +114,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
if (*pRozkaz->iPar == 0) // sprawdzenie czasu
if (*pRozkaz->iPar & 1) // ustawienie czasu
{
auto t = pRozkaz->fPar[1];
const auto t = pRozkaz->fPar[1];
simulation::Time.data().wDay = std::floor(t); // niby nie powinno być dnia, ale...
if (Global.fMoveLight >= 0)
Global.fMoveLight = t; // trzeba by deklinację Słońca przeliczyć
@@ -138,7 +138,7 @@ OnCommandGet(multiplayer::DaneRozkaz *pRozkaz)
+ " rcvd" );
if (pRozkaz->cString[0]) {
// jeśli długość nazwy jest niezerowa szukamy pierwszego pojazdu o takiej nazwie i odsyłamy parametry ramką #7
auto *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
const auto *vehicle = pRozkaz->cString[1] == '*' ? simulation::Train->Dynamic() : simulation::Vehicles.find(std::string{pRozkaz->cString + 1, (unsigned)pRozkaz->cString[0]});
if( vehicle != nullptr ) {
WyslijNamiary( vehicle ); // wysłanie informacji o pojeździe
}
@@ -225,7 +225,7 @@ WyslijUszkodzenia(const std::string &t, char fl)
DaneRozkaz r;
r.iSygn = EU07_MESSAGEHEADER;
r.iComm = 13; // numer komunikatu
size_t i = t.length();
const size_t i = t.length();
r.cString[0] = char(fl);
r.cString[1] = char(i);
strcpy(r.cString + 2, t.c_str()); // z zerem kończącym
@@ -245,7 +245,7 @@ WyslijString(const std::string &t, int n)
DaneRozkaz r;
r.iSygn = EU07_MESSAGEHEADER;
r.iComm = n; // numer komunikatu
size_t i = t.length();
const size_t i = t.length();
r.cString[0] = char(i);
strcpy(r.cString + 1, t.c_str()); // z zerem kończącym
COPYDATASTRUCT cData;
@@ -271,7 +271,7 @@ WyslijNamiary(TDynamicObject const *Vehicle)
r.iSygn = EU07_MESSAGEHEADER;
r.iComm = 7; // 7 - dane pojazdu
int i = 32;
size_t j = Vehicle->asName.length();
const size_t j = Vehicle->asName.length();
r.iPar[0] = i; // ilość danych liczbowych
r.fPar[1] = Global.fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba)
r.fPar[2] = Vehicle->MoverParameters->Loc.X; // pozycja X
@@ -356,7 +356,7 @@ WyslijObsadzone()
for (int i=0; i<1984; ++i) r.cString[i] = 0;
// TODO: clean this up, we shouldn't be relying on direct list access
auto &vehiclelist = simulation::Vehicles.sequence();
const auto &vehiclelist = simulation::Vehicles.sequence();
int i = 0;
for( auto *vehicle : vehiclelist ) {

View File

@@ -31,7 +31,7 @@ float zmq_input::unpack_float(const zmq::message_t &msg) {
}
zmq::message_t zmq_input::pack_float(float f) {
uint32_t v = reinterpret_cast<uint32_t&>(f);
const uint32_t v = reinterpret_cast<uint32_t&>(f);
uint8_t buf[4];
buf[3] = v;
buf[2] = v >> 8;
@@ -240,7 +240,7 @@ zmq::message_t zmq_input::pack_field(zmq_input::output_fields f) {
if (f == output_fields::time_millisecond_of_day)
return pack_float(time.wSecond * 1000 + time.wMilliseconds);
TTrain *train = simulation::Train;
const TTrain *train = simulation::Train;
if (!train)
return pack_float(0.0f);
const TTrain::state_t state = train->get_state();