From 220689a5e30474d284a30fff37a0ff1d28fdd270 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 4 Jul 2026 07:08:14 +0200 Subject: [PATCH] reformat: parameters can be made const --- Console.cpp | 24 +- Console.h | 2 +- Console/LPT.cpp | 4 +- Console/PoKeys55.cpp | 6 +- EU07.cpp | 2 +- McZapkie/Mover.cpp | 182 +++++------ McZapkie/Oerlikon_ESt.cpp | 24 +- McZapkie/Oerlikon_ESt.h | 2 +- McZapkie/friction.cpp | 14 +- McZapkie/hamulce.cpp | 132 ++++---- McZapkie/hamulce.h | 24 +- application/application.cpp | 30 +- application/driveruipanels.cpp | 2 +- application/editormode.cpp | 12 +- application/editormode.h | 4 +- application/editoruilayer.cpp | 4 +- application/editoruipanels.cpp | 2 +- application/scenarioloaderuilayer.cpp | 4 +- application/uilayer.cpp | 12 +- application/uitranscripts.cpp | 2 +- audio/audiorenderer_extra.h | 2 +- editor/editorSettings.cpp | 2 +- editor/editorSettings.hpp | 2 +- editor/editorTerrain.cpp | 22 +- editor/editorTerrain.hpp | 2 +- editor/editorTerrainStreamer.cpp | 16 +- editor/editorTerrainStreamer.hpp | 10 +- export_e3d_standalone.cpp | 2 +- extras/piped_proc.cpp | 6 +- gl/buffer.cpp | 14 +- gl/cubemap.cpp | 4 +- gl/framebuffer.cpp | 22 +- gl/pbo.cpp | 8 +- gl/query.cpp | 4 +- gl/renderbuffer.cpp | 4 +- gl/shader.cpp | 2 +- gl/ubo.cpp | 4 +- gl/ubo.h | 2 +- gl/vao.cpp | 2 +- imgui/ImGuizmo.cpp | 88 +++--- imgui/ImGuizmo.h | 2 +- imgui/imgui.cpp | 373 ++++++++++++----------- imgui/imgui.h | 74 ++--- imgui/imgui_demo.cpp | 12 +- imgui/imgui_draw.cpp | 128 ++++---- imgui/imgui_impl_glfw.cpp | 14 +- imgui/imgui_impl_opengl2.cpp | 2 +- imgui/imgui_impl_opengl3.cpp | 6 +- imgui/imgui_internal.h | 96 +++--- imgui/imgui_widgets.cpp | 329 ++++++++++---------- imgui/imstb_rectpack.h | 14 +- imgui/imstb_truetype.h | 214 ++++++------- input/messaging.cpp | 8 +- input/zmq_input.cpp | 2 +- launcher/scenery_list.cpp | 4 +- launcher/scenery_list.h | 2 +- model/AnimModel.cpp | 4 +- model/MdlMngr.cpp | 4 +- model/Model3d.cpp | 30 +- model/Model3d.h | 2 +- model/Texture.cpp | 14 +- model/material.h | 2 +- model/vertex.h | 2 +- network/backend/asio.cpp | 10 +- network/manager.cpp | 2 +- network/message.h | 4 +- network/network.cpp | 4 +- rendering/geometrybank.cpp | 2 +- rendering/geometrybank.h | 6 +- rendering/opengl33geometrybank.cpp | 4 +- rendering/opengl33renderer.cpp | 22 +- rendering/openglgeometrybank.cpp | 2 +- rendering/openglrenderer.cpp | 2 +- rendering/renderer.cpp | 2 +- rendering/screenshot.cpp | 2 +- scene/scene.cpp | 2 +- scene/scene.h | 2 +- scene/scenenode.h | 6 +- scene/scenenodegroups.cpp | 6 +- scene/sn_utils.cpp | 12 +- scripting/ladderlogic.cpp | 2 +- scripting/ladderlogic.h | 2 +- scripting/pythonscreenviewer.cpp | 14 +- simulation/simulation.cpp | 2 +- simulation/simulationstateserializer.cpp | 2 +- simulation/simulationtime.cpp | 4 +- stb/stb_image.h | 230 +++++++------- stb/stb_image_write.h | 61 ++-- utilities/Float3d.h | 15 +- utilities/Globals.cpp | 4 +- utilities/Logs.cpp | 10 +- utilities/Timer.cpp | 4 +- utilities/headtrack.cpp | 2 +- utilities/parser.cpp | 16 +- utilities/translation.cpp | 4 +- utilities/utilities.cpp | 18 +- utilities/utilities.h | 6 +- utilities/uuid.hpp | 2 +- vehicle/Button.cpp | 6 +- vehicle/Camera.cpp | 6 +- vehicle/Driver.cpp | 42 +-- vehicle/Driver.h | 4 +- vehicle/DynObj.cpp | 42 +-- vehicle/DynObj.h | 2 +- vehicle/Gauge.cpp | 6 +- vehicle/Train.cpp | 14 +- vr/openvr_imp.cpp | 8 +- vr/vr_interface.cpp | 2 +- widgets/cameraview_extcam.cpp | 2 +- windows.cpp | 4 +- world/Event.cpp | 4 +- world/Event.h | 2 +- world/Segment.cpp | 2 +- world/Spring.cpp | 2 +- world/Track.cpp | 24 +- world/Track.h | 2 +- world/Traction.cpp | 4 +- world/TractionPower.cpp | 4 +- world/TrkFoll.cpp | 6 +- world/mtable.cpp | 10 +- world/mtable.h | 2 +- 121 files changed, 1380 insertions(+), 1352 deletions(-) diff --git a/Console.cpp b/Console.cpp index b4b49b81..0fe6ff0d 100644 --- a/Console.cpp +++ b/Console.cpp @@ -58,7 +58,7 @@ Działanie jest następujące: TKeyTrans Console::ktTable[4 * 256]; // Ra: bajer do migania LED-ami w klawiaturze -void SetLedState( unsigned char Code, bool bOn ) { +void SetLedState(const unsigned char Code, const bool bOn ) { #ifdef _WIN32 if( bOn != ( GetKeyState( Code ) != 0 ) ) { keybd_event( Code, MapVirtualKey( Code, 0 ), KEYEVENTF_EXTENDEDKEY | 0, 0 ); @@ -92,7 +92,7 @@ Console::~Console() Off(); }; -void Console::ModeSet(int m, int h) +void Console::ModeSet(const int m, const int h) { // ustawienie trybu pracy iMode = m; iConfig = h; @@ -154,7 +154,7 @@ void Console::Off() SafeDelete( LPT ); }; -void Console::BitsSet(int mask, int entry) +void Console::BitsSet(const int mask, int entry) { // ustawienie bitów o podanej masce (mask) na wejściu (entry) if ((iBits & mask) != mask) // jeżeli zmiana { @@ -167,7 +167,7 @@ void Console::BitsSet(int mask, int entry) } }; -void Console::BitsClear(int mask, int entry) +void Console::BitsClear(const int mask, int entry) { // zerowanie bitów o podanej masce (mask) na wejściu (entry) if (iBits & mask) // jeżeli zmiana { @@ -177,7 +177,7 @@ void Console::BitsClear(int mask, int entry) } }; -void Console::BitsUpdate(int mask) +void Console::BitsUpdate(const int mask) { // aktualizacja stanu interfejsu informacji zwrotnej; (mask) - zakres zmienianych bitów switch (iMode) { @@ -298,7 +298,7 @@ void Console::Update() } }; -float Console::AnalogGet(int x) +float Console::AnalogGet(const int x) { // pobranie wartości analogowej if (iMode == 4) if (PoKeys55[0]) @@ -306,7 +306,7 @@ float Console::AnalogGet(int x) return -1.0; }; -float Console::AnalogCalibrateGet(int x) +float Console::AnalogCalibrateGet(const int x) { // pobranie i kalibracja wartości analogowej, jeśli nie ma PoKeys zwraca NULL if (iMode == 4 && PoKeys55[0]) { @@ -325,7 +325,7 @@ float Console::AnalogCalibrateGet(int x) return -1.0; // odcięcie }; -unsigned char Console::DigitalGet(int x) +unsigned char Console::DigitalGet(const int x) { // pobranie wartości cyfrowej if (iMode == 4) if (PoKeys55[0]) @@ -333,7 +333,7 @@ unsigned char Console::DigitalGet(int x) return 0; }; -void Console::OnKeyDown(int k) +void Console::OnKeyDown(const int k) { // naciśnięcie klawisza z powoduje wyłączenie, a if (k & 0x10000) // jeśli [Shift] { // ustawienie bitu w tabeli przełączników bistabilnych @@ -357,7 +357,7 @@ void Console::OnKeyDown(int k) } }; -void Console::OnKeyUp(int k) +void Console::OnKeyUp(const int k) { // puszczenie klawisza w zasadzie nie ma znaczenia dla iSwitch, ale zeruje iButton if ((k & 0x20000) == 0) // monostabilne tylko bez [Ctrl] if (k & 0x10000) // jeśli [Shift] @@ -366,12 +366,12 @@ void Console::OnKeyUp(int k) iButton[char(k) >> 5] &= ~(1 << (k & 31)); // wyłącz monostabilny podstawowy }; -int Console::KeyDownConvert(int k) +int Console::KeyDownConvert(const int k) { return int(ktTable[k & 0x3FF].iDown); }; -int Console::KeyUpConvert(int k) +int Console::KeyUpConvert(const int k) { return int(ktTable[k & 0x3FF].iUp); }; diff --git a/Console.h b/Console.h index c6e09534..8c01481b 100644 --- a/Console.h +++ b/Console.h @@ -50,7 +50,7 @@ class Console static int On(); static void Off(); - static bool Pressed(int x) + static bool Pressed(const int x) { // na razie tak - czyta się tylko klawiatura if (glfwGetKey(Application.window(), x) == GLFW_TRUE) return true; diff --git a/Console/LPT.cpp b/Console/LPT.cpp index c7be8275..f37c7d1b 100644 --- a/Console/LPT.cpp +++ b/Console/LPT.cpp @@ -23,7 +23,7 @@ typedef void(__stdcall *OutPortType)(USHORT BasePort, USHORT value); InPortType InPort; OutPortType OutPort; -bool TLPT::Connect(int port) +bool TLPT::Connect(const int port) { WriteLog("lpt: trying to connect lpt, port " + std::to_string(port)); @@ -57,7 +57,7 @@ bool TLPT::Connect(int port) return OutPort != 0; }; -void TLPT::Out(int x) +void TLPT::Out(const int x) { // wysłanie bajtu do portu OutPort(address, x); }; diff --git a/Console/PoKeys55.cpp b/Console/PoKeys55.cpp index 747f3adc..411a6e78 100644 --- a/Console/PoKeys55.cpp +++ b/Console/PoKeys55.cpp @@ -201,7 +201,7 @@ bool TPoKeys55::Connect() return false; } //--------------------------------------------------------------------------- -bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4, unsigned char b5) +bool TPoKeys55::Write(const unsigned char c, const unsigned char b3, const unsigned char b4, const unsigned char b5) { DWORD BytesWritten = 0; OutputBuffer[0] = 0; // The first byte is the "Report ID" and does not get transmitted over the @@ -287,14 +287,14 @@ std::string TPoKeys55::Version() return ""; }; -bool TPoKeys55::PWM(int x, float y) +bool TPoKeys55::PWM(const int x, const float y) { // ustawienie wskazanego PWM (@12Mhz: 12000=1ms=1000Hz) // iPWM[7]=1024; //1024==85333.3333333333ns=11718.75Hz iPWM[x] = int(0.5f + 0x0FFF * y) & 0x0FFF; // 0x0FFF=4095 return true; } -bool TPoKeys55::Update(bool pause) +bool TPoKeys55::Update(const bool pause) { // funkcja powinna być wywoływana regularnie, np. raz w każdej ramce ekranowej if (pause) { // specjalna procedura, jeśli utracone połączenie spowodowało pauzę diff --git a/EU07.cpp b/EU07.cpp index bf545595..a66a4c1e 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -79,7 +79,7 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo) #endif -int main(int argc, char *argv[]) +int main(const int argc, char *argv[]) { #ifdef WITHDUMPGEN #ifdef _WIN32 diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index e413869c..71b6d79f 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -33,12 +33,12 @@ std::vector const TMoverParameters::eimc_labels = {"dfic: ", "dfmax std::vector const TMoverParameters::eimv_labels = { "Fkrt:", "Fmax:", "ks: ", "df: ", "fp: ", "Us: ", "pole:", "Ic: ", "If: ", "M: ", "Fr: ", "Ipoj:", "Pm: ", "Pe: ", "eta: ", "fkr: ", "Uzsm:", "Pmax:", "Fzad:", "Imax:", "Fful:"}; -inline double square(double val) // SQR() zle liczylo w current() ... +inline double square(const double val) // SQR() zle liczylo w current() ... { return val * val; } -double ComputeCollision(double &v1, double &v2, double m1, double m2, double beta, bool vc) +double ComputeCollision(double &v1, double &v2, const double m1, const double m2, const double beta, const bool vc) { // oblicza zmiane predkosci i przyrost pedu wskutek kolizji assert(beta < 1.0); @@ -55,12 +55,12 @@ double ComputeCollision(double &v1, double &v2, double m1, double m2, double bet } } -int DirPatch(int Coupler1, int Coupler2) +int DirPatch(const int Coupler1, const int Coupler2) { // poprawka dla liczenia sil przy ustawieniu przeciwnym obiektow return Coupler1 != Coupler2 ? 1 : -1; } -int DirF(int CouplerN) +int DirF(const int CouplerN) { switch (CouplerN) { @@ -73,7 +73,7 @@ int DirF(int CouplerN) } } -void TSecuritySystem::set_enabled(bool e) +void TSecuritySystem::set_enabled(const bool e) { if (vigilance_enabled || cabsignal_enabled || radiostop_enabled) enabled = e; @@ -118,7 +118,7 @@ void TSecuritySystem::cabsignal_reset() } } -void TSecuritySystem::update(double dt, double vel, bool pwr, int cab) +void TSecuritySystem::update(const double dt, const double vel, const bool pwr, const int cab) { if (!enabled || !pwr || DebugModeFlag) { @@ -218,7 +218,7 @@ bool TSecuritySystem::radiostop_available() const return radiostop_enabled; } -void TSecuritySystem::set_cabsignal_lock(bool v) +void TSecuritySystem::set_cabsignal_lock(const bool v) { cabsignal_lock = v; } @@ -231,7 +231,7 @@ bool TSecuritySystem::is_engine_blocked() const return velocity < AwareMinSpeed && pressed; } -void TSecuritySystem::load(std::string const &line, double Vmax) +void TSecuritySystem::load(std::string const &line, const double Vmax) { const std::string awaresystem = extract_value("AwareSystem", line); if (awaresystem.find("Active") != std::string::npos) @@ -254,7 +254,7 @@ void TSecuritySystem::load(std::string const &line, double Vmax) extract_value(CabDependent, "CabDependent", line, ""); } -double TableInterpolation(std::map &Map, double Parameter) +double TableInterpolation(std::map &Map, const double Parameter) { if (Map.size() == 0) return 0.0; @@ -282,7 +282,7 @@ double TableInterpolation(std::map &Map, double Parameter) // Q: 20160716 // Obliczanie natężenie prądu w silnikach // ************************************************************************************************* -double TMoverParameters::Current(double n, double U) +double TMoverParameters::Current(const double n, const double U) { // wazna funkcja - liczy prad plynacy przez silniki polaczone szeregowo lub rownolegle // w zaleznosci od polozenia nastawnikow MainCtrl i ScndCtrl oraz predkosci obrotowej n @@ -463,7 +463,7 @@ double TMoverParameters::Current(double n, double U) // ************************************************************************************************* // główny konstruktor // ************************************************************************************************* -TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit, std::string NameInit, int Cab) : TypeName(TypeNameInit), Name(NameInit), CabOccupied(Cab) +TMoverParameters::TMoverParameters(const double VelInitial, std::string TypeNameInit, std::string NameInit, const int Cab) : TypeName(TypeNameInit), Name(NameInit), CabOccupied(Cab) { WriteLog("------------------------------------------------------"); WriteLog("init default physic values for " + NameInit + ", [" + TypeNameInit + "]"); @@ -582,7 +582,7 @@ double TMoverParameters::CouplerDist(TMoverParameters const *Left, TMoverParamet return Distance(Left->Loc, Right->Loc, Left->Dim, Right->Dim); // odległość pomiędzy sprzęgami (kula!) }; -bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *ConnectTo, int CouplingType, bool Enforce, bool Audible) +bool TMoverParameters::Attach(const int ConnectNo, const int ConnectToNr, TMoverParameters *ConnectTo, const int CouplingType, const bool Enforce, const bool Audible) { // łączenie do swojego sprzęgu (ConnectNo) pojazdu (ConnectTo) stroną (ConnectToNr) // Ra: zwykle wykonywane dwukrotnie, dla każdego pojazdu oddzielnie // Ra: trzeba by odróżnić wymóg dociśnięcia od uszkodzenia sprzęgu przy podczepianiu AI do składu @@ -641,7 +641,7 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters * return true; } -int TMoverParameters::DettachStatus(int ConnectNo) +int TMoverParameters::DettachStatus(const int ConnectNo) { // Ra: sprawdzenie, czy odległość jest dobra do rozłączania // powinny być 3 informacje: =0 sprzęg już rozłączony, <0 da się rozłączyć. >0 nie da się rozłączyć if (!Couplers[ConnectNo].Connected) @@ -656,7 +656,7 @@ int TMoverParameters::DettachStatus(int ConnectNo) return Neighbours[ConnectNo].distance > 0.2 ? -Couplers[ConnectNo].CouplingFlag : Couplers[ConnectNo].CouplingFlag; }; -bool TMoverParameters::Dettach(int ConnectNo) +bool TMoverParameters::Dettach(const int ConnectNo) { // rozlaczanie auto &coupler{Couplers[ConnectNo]}; @@ -723,7 +723,7 @@ bool TMoverParameters::DirectionForward() // Nastawianie hamulców -void TMoverParameters::BrakeLevelSet(double b) +void TMoverParameters::BrakeLevelSet(const double b) { // ustawienie pozycji hamulca na wartość (b) w zakresie od -2 do BrakeCtrlPosNo // jedyny dopuszczalny sposób przestawienia hamulca zasadniczego if (fBrakeCtrlPos == b) @@ -764,7 +764,7 @@ void TMoverParameters::BrakeLevelSet(double b) */ }; -bool TMoverParameters::BrakeLevelAdd(double b) +bool TMoverParameters::BrakeLevelAdd(const double b) { // dodanie wartości (b) do pozycji hamulca (w tym ujemnej) // zwraca false, gdy po dodaniu było by poza zakresem BrakeLevelSet(fBrakeCtrlPos + b); @@ -781,7 +781,7 @@ bool TMoverParameters::DecBrakeLevel() return BrakeLevelAdd(-1.0); }; // nowa wersja na użytek AI, false gdy osiągnięto pozycję -1 -bool TMoverParameters::ChangeCab(int direction) +bool TMoverParameters::ChangeCab(const int direction) { // zmiana kabiny i resetowanie ustawien if (std::abs(CabOccupied + direction) < 2) { @@ -838,7 +838,7 @@ bool TMoverParameters::IsMotorOverloadRelayHighThresholdOn() const } // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze nie tak -void TMoverParameters::UpdatePantVolume(double dt) +void TMoverParameters::UpdatePantVolume(const double dt) { // check the pantograph compressor while at it // TODO: move the check to a separate method @@ -934,7 +934,7 @@ void TMoverParameters::UpdatePantVolume(double dt) } }; -void TMoverParameters::UpdateBatteryVoltage(double dt) +void TMoverParameters::UpdateBatteryVoltage(const double dt) { // przeliczenie obciążenia baterii double sn1 = 0.0, sn2 = 0.0, sn3 = 0.0, sn4 = 0.0, sn5 = 0.0; // Ra: zrobić z tego amperomierz NN @@ -1354,7 +1354,7 @@ void TMoverParameters::Derail(DerailReason const Reason) // ************************************************************************************************* // Oblicza przemieszczenie taboru // ************************************************************************************************* -double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot) +double TMoverParameters::ComputeMovement(const double dt, const double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot) { constexpr double Vepsilon = 1e-5; constexpr double Aepsilon = 1e-3; // ASBSpeed=0.8; @@ -1478,7 +1478,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap // Oblicza przemieszczenie taboru - uproszczona wersja // ************************************************************************************************* -double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, TLocation const &NewLoc, TRotation const &NewRot) +double TMoverParameters::FastComputeMovement(const double dt, const TTrackShape &Shape, TTrackParam &Track, TLocation const &NewLoc, TRotation const &NewRot) { int b; // T_MoverParameters::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot); @@ -1990,7 +1990,7 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const } } -double TMoverParameters::ShowEngineRotation(int VehN) +double TMoverParameters::ShowEngineRotation(const int VehN) { // Zwraca wartość prędkości obrotowej silnika wybranego pojazdu. Do 3 pojazdów (3×SN61). int b; switch (VehN) @@ -2340,7 +2340,7 @@ void TMoverParameters::LightsCheck(double const Timestep) light.dimming; } -double TMoverParameters::ShowCurrent(int AmpN) const +double TMoverParameters::ShowCurrent(const int AmpN) const { // Odczyt poboru prądu na podanym amperomierzu switch (EngineType) { @@ -2372,7 +2372,7 @@ double TMoverParameters::ShowCurrent(int AmpN) const // zwiększenie nastawinika // ************************************************************************************************* -bool TMoverParameters::IncMainCtrl(int CtrlSpeed) +bool TMoverParameters::IncMainCtrl(const int CtrlSpeed) { // basic fail conditions: if (MainCtrlPosNo <= 0 || CabActive == 0) @@ -2555,7 +2555,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed) // Q: 20160710 // zmniejszenie nastawnika // ***************************************************************************** -bool TMoverParameters::DecMainCtrl(int CtrlSpeed) +bool TMoverParameters::DecMainCtrl(const int CtrlSpeed) { bool OK = false; // basic fail conditions: @@ -2729,7 +2729,7 @@ int TMoverParameters::MainCtrlPowerPos() const // Q: 20160710 // zwiększenie bocznika // ************************************************************************************************* -bool TMoverParameters::IncScndCtrl(int CtrlSpeed) +bool TMoverParameters::IncScndCtrl(const int CtrlSpeed) { bool OK = false; @@ -2802,7 +2802,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed) // Q: 20160710 // zmniejszenie bocznika // ************************************************************************************************* -bool TMoverParameters::DecScndCtrl(int CtrlSpeed) +bool TMoverParameters::DecScndCtrl(const int CtrlSpeed) { bool OK = false; @@ -2968,7 +2968,7 @@ bool TMoverParameters::CabDeactivisationAuto(bool const Enforce) // Q: 20160710 // Siła napędzająca drezynę po naciśnięciu wajhy // ************************************************************************************************* -bool TMoverParameters::AddPulseForce(int Multipler) +bool TMoverParameters::AddPulseForce(const int Multipler) { bool APF; if (EngineType == TEngineType::WheelsDriven && EnginePowerSource.SourceType == TPowerSource::InternalSource && EnginePowerSource.PowerType == TPowerType::BioPower) @@ -3106,7 +3106,7 @@ bool TMoverParameters::Sandbox(bool const State, range_t const Notify) // yB: 20190909 // włączenie / wyłączenie automatycznej piasecznicy // ************************************************************************************************* -bool TMoverParameters::SandboxAutoAllow(bool State) +bool TMoverParameters::SandboxAutoAllow(const bool State) { // SendCtrlToNext("SandboxAutoAllow", int(State), CabActive, ctrain_controll); @@ -3136,7 +3136,7 @@ void TMoverParameters::SecuritySystemReset(void) // zbijanie czuwaka/SHP // Q: 20160711 // sprawdzanie stanu CA/SHP // ************************************************************************************************* -void TMoverParameters::SecuritySystemCheck(double dt) +void TMoverParameters::SecuritySystemCheck(const double dt) { const bool isPower = Power24vIsAvailable || Power110vIsAvailable; SecuritySystem.update(dt, Vel, isPower, CabActive); @@ -3151,7 +3151,7 @@ void TMoverParameters::SecuritySystemCheck(double dt) // Q: 20160710 // włączenie / wyłączenie baterii // ************************************************************************************************* -bool TMoverParameters::BatterySwitch(bool State, range_t const Notify) +bool TMoverParameters::BatterySwitch(const bool State, range_t const Notify) { auto const initialstate{Battery}; @@ -3175,7 +3175,7 @@ bool TMoverParameters::BatterySwitch(bool State, range_t const Notify) // Q: 20160710 // włączenie / wyłączenie hamulca elektro-pneumatycznego // ************************************************************************************************* -bool TMoverParameters::EpFuseSwitch(bool State) +bool TMoverParameters::EpFuseSwitch(const bool State) { if (EpFuse != State) { @@ -3192,7 +3192,7 @@ bool TMoverParameters::EpFuseSwitch(bool State) // yB: 20190906 // włączenie / wyłączenie hamulca sprezynowego // ************************************************************************************************* -bool TMoverParameters::SpringBrakeActivate(bool State) +bool TMoverParameters::SpringBrakeActivate(const bool State) { if (Power24vIsAvailable || Power110vIsAvailable) { @@ -3211,7 +3211,7 @@ bool TMoverParameters::SpringBrakeActivate(bool State) // yB: 20190906 // włączenie / wyłączenie odciecia hamulca sprezynowego // ************************************************************************************************* -bool TMoverParameters::SpringBrakeShutOff(bool State) +bool TMoverParameters::SpringBrakeShutOff(const bool State) { if (SpringBrake.ShuttOff != State) { @@ -3289,7 +3289,7 @@ bool TMoverParameters::AntiSlippingButton(void) } // water pump breaker state toggle -bool TMoverParameters::WaterPumpBreakerSwitch(bool State, range_t const Notify) +bool TMoverParameters::WaterPumpBreakerSwitch(const bool State, range_t const Notify) { /* if( FuelPump.start_type == start::automatic ) { @@ -3310,7 +3310,7 @@ bool TMoverParameters::WaterPumpBreakerSwitch(bool State, range_t const Notify) } // water pump state toggle -bool TMoverParameters::WaterPumpSwitch(bool State, range_t const Notify) +bool TMoverParameters::WaterPumpSwitch(const bool State, range_t const Notify) { if (WaterPump.start_type == start_t::battery) @@ -3332,7 +3332,7 @@ bool TMoverParameters::WaterPumpSwitch(bool State, range_t const Notify) } // water pump state toggle -bool TMoverParameters::WaterPumpSwitchOff(bool State, range_t const Notify) +bool TMoverParameters::WaterPumpSwitchOff(const bool State, range_t const Notify) { if (WaterPump.start_type == start_t::battery) @@ -3354,7 +3354,7 @@ bool TMoverParameters::WaterPumpSwitchOff(bool State, range_t const Notify) } // water heater breaker state toggle -bool TMoverParameters::WaterHeaterBreakerSwitch(bool State, range_t const Notify) +bool TMoverParameters::WaterHeaterBreakerSwitch(const bool State, range_t const Notify) { /* if( FuelPump.start_type == start::automatic ) { @@ -3375,7 +3375,7 @@ bool TMoverParameters::WaterHeaterBreakerSwitch(bool State, range_t const Notify } // water heater state toggle -bool TMoverParameters::WaterHeaterSwitch(bool State, range_t const Notify) +bool TMoverParameters::WaterHeaterSwitch(const bool State, range_t const Notify) { /* if( FuelPump.start_type == start::automatic ) { @@ -3396,7 +3396,7 @@ bool TMoverParameters::WaterHeaterSwitch(bool State, range_t const Notify) } // water circuits link state toggle -bool TMoverParameters::WaterCircuitsLinkSwitch(bool State, range_t const Notify) +bool TMoverParameters::WaterCircuitsLinkSwitch(const bool State, range_t const Notify) { if (false == dizel_heat.auxiliary_water_circuit) @@ -3418,7 +3418,7 @@ bool TMoverParameters::WaterCircuitsLinkSwitch(bool State, range_t const Notify) } // fuel pump state toggle -bool TMoverParameters::FuelPumpSwitch(bool State, range_t const Notify) +bool TMoverParameters::FuelPumpSwitch(const bool State, range_t const Notify) { if (FuelPump.start_type == start_t::automatic) @@ -3439,7 +3439,7 @@ bool TMoverParameters::FuelPumpSwitch(bool State, range_t const Notify) return FuelPump.is_enabled != initialstate; } -bool TMoverParameters::FuelPumpSwitchOff(bool State, range_t const Notify) +bool TMoverParameters::FuelPumpSwitchOff(const bool State, range_t const Notify) { if (FuelPump.start_type == start_t::automatic) @@ -3461,7 +3461,7 @@ bool TMoverParameters::FuelPumpSwitchOff(bool State, range_t const Notify) } // oil pump state toggle -bool TMoverParameters::OilPumpSwitch(bool State, range_t const Notify) +bool TMoverParameters::OilPumpSwitch(const bool State, range_t const Notify) { if (OilPump.start_type == start_t::automatic) @@ -3482,7 +3482,7 @@ bool TMoverParameters::OilPumpSwitch(bool State, range_t const Notify) return OilPump.is_enabled != initialstate; } -bool TMoverParameters::OilPumpSwitchOff(bool State, range_t const Notify) +bool TMoverParameters::OilPumpSwitchOff(const bool State, range_t const Notify) { if (OilPump.start_type == start_t::automatic) @@ -3503,7 +3503,7 @@ bool TMoverParameters::OilPumpSwitchOff(bool State, range_t const Notify) return OilPump.is_disabled != initialstate; } -bool TMoverParameters::MotorBlowersSwitch(bool State, end const Side, range_t const Notify) +bool TMoverParameters::MotorBlowersSwitch(const bool State, end const Side, range_t const Notify) { auto &fan{MotorBlowers[Side]}; @@ -3527,7 +3527,7 @@ bool TMoverParameters::MotorBlowersSwitch(bool State, end const Side, range_t co return fan.is_enabled != initialstate; } -bool TMoverParameters::MotorBlowersSwitchOff(bool State, end const Side, range_t const Notify) +bool TMoverParameters::MotorBlowersSwitchOff(const bool State, end const Side, range_t const Notify) { auto &fan{MotorBlowers[Side]}; @@ -3551,7 +3551,7 @@ bool TMoverParameters::MotorBlowersSwitchOff(bool State, end const Side, range_t return fan.is_disabled != initialstate; } -bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify) +bool TMoverParameters::CompartmentLightsSwitch(const bool State, range_t const Notify) { if (CompartmentLights.start_type == start_t::automatic) @@ -3573,7 +3573,7 @@ bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify) } // water pump state toggle -bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Notify) +bool TMoverParameters::CompartmentLightsSwitchOff(const bool State, range_t const Notify) { if (CompartmentLights.start_type == start_t::automatic) @@ -3699,7 +3699,7 @@ bool TMoverParameters::MainSwitchCheck() const // Q: 20160713 // włączenie / wyłączenie przetwornicy // ************************************************************************************************* -bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify) +bool TMoverParameters::ConverterSwitch(const bool State, range_t const Notify) { auto const initialstate{ConverterAllow}; @@ -3721,7 +3721,7 @@ bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify) // Q: 20160713 // włączenie / wyłączenie sprężarki // ************************************************************************************************* -bool TMoverParameters::CompressorSwitch(bool State, range_t const Notify) +bool TMoverParameters::CompressorSwitch(const bool State, range_t const Notify) { if (CompressorStart != start_t::manual) @@ -3920,7 +3920,7 @@ bool TMoverParameters::DecDynamicBrakeLevel(float const CtrlSpeed) // ************************************************************************************************* // bezposrednie ustawienie nastawnika hamulca elektrodynamicznego (DynamicBrakeCtrl) // ************************************************************************************************* -bool TMoverParameters::DynamicBrakeLevelSet(double Position) +bool TMoverParameters::DynamicBrakeLevelSet(const double Position) { if (false == SplitEDPneumaticBrake) return false; @@ -4002,7 +4002,7 @@ bool TMoverParameters::DecManualBrakeLevel(int CtrlSpeed) // Q: 20160713 // reczne przelaczanie hamulca elektrodynamicznego // ************************************************************************************************* -bool TMoverParameters::DynamicBrakeSwitch(bool Switch) +bool TMoverParameters::DynamicBrakeSwitch(const bool Switch) { bool DBS; @@ -4030,7 +4030,7 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch) // Q: 20160711 // włączenie / wyłączenie hamowania awaryjnego // ************************************************************************************************* -bool TMoverParameters::RadiostopSwitch(bool Switch) +bool TMoverParameters::RadiostopSwitch(const bool Switch) { bool EBS; if (BrakeSystem != TBrakeSystem::Individual && BrakeCtrlPosNo > 0) @@ -4096,7 +4096,7 @@ bool TMoverParameters::AntiSlippingBrake(void) // Q: 20160711 // włączenie / wyłączenie odluźniacza // ************************************************************************************************* -bool TMoverParameters::BrakeReleaser(int state) +bool TMoverParameters::BrakeReleaser(const int state) { bool OK = true; // false tylko jeśli nie uda się wysłać, GF 20161124 if (state != 0) @@ -4120,7 +4120,7 @@ bool TMoverParameters::BrakeReleaser(int state) // yB: 20160711 // włączenie / wyłączenie uniwersalnego przycisku hamulcowego // ************************************************************************************************* -bool TMoverParameters::UniversalBrakeButton(int button, int state) +bool TMoverParameters::UniversalBrakeButton(const int button, const int state) { constexpr bool OK = true; // false tylko jeśli nie uda się wysłać, GF 20161124 UniversalBrakeButtonActive[button] = state > 0; @@ -4150,7 +4150,7 @@ bool TMoverParameters::UniversalBrakeButton(int button, int state) // Q: 20160711 // włączenie / wyłączenie hamulca elektro-pneumatycznego // ************************************************************************************************* -bool TMoverParameters::SwitchEPBrake(int state) +bool TMoverParameters::SwitchEPBrake(const int state) { bool OK; @@ -4173,7 +4173,7 @@ bool TMoverParameters::SwitchEPBrake(int state) // Q: 20160711 // zwiększenie ciśnienia hamowania // ************************************************************************************************* -bool TMoverParameters::IncBrakePress(double &brake, double PressLimit, double dp) +bool TMoverParameters::IncBrakePress(double &brake, const double PressLimit, double dp) { bool IBP; // if (DynamicBrakeType<>dbrake_switch) and (DynamicBrakeType<>dbrake_none) and @@ -4202,7 +4202,7 @@ bool TMoverParameters::IncBrakePress(double &brake, double PressLimit, double dp // Q: 20160711 // zmniejszenie ciśnienia hamowania // ************************************************************************************************* -bool TMoverParameters::DecBrakePress(double &brake, double PressLimit, double dp) +bool TMoverParameters::DecBrakePress(double &brake, const double PressLimit, const double dp) { bool DBP; @@ -4228,7 +4228,7 @@ bool TMoverParameters::DecBrakePress(double &brake, double PressLimit, double dp // Q: 20160711 // przełączenie nastawy hamulca O/P/T // ************************************************************************************************* -bool TMoverParameters::BrakeDelaySwitch(int BDS) +bool TMoverParameters::BrakeDelaySwitch(const int BDS) { bool rBDS; if (Hamulec->SetBDF(BDS)) @@ -4297,7 +4297,7 @@ bool TMoverParameters::DecBrakeMult(void) // Q: 20160712 // zaktualizowanie ciśnienia w hamulcach // ************************************************************************************************* -void TMoverParameters::UpdateBrakePressure(double dt) +void TMoverParameters::UpdateBrakePressure(const double dt) { // const double LBDelay = 5.0; // stala czasowa hamulca // double Rate, Speed, dp, sm; @@ -4316,7 +4316,7 @@ void TMoverParameters::UpdateBrakePressure(double dt) // Q: 20160712 // Obliczanie pracy sprężarki // ************************************************************************************************* -void TMoverParameters::CompressorCheck(double dt) +void TMoverParameters::CompressorCheck(const double dt) { if (CompressorSpeed == 0.0) @@ -4473,7 +4473,7 @@ void TMoverParameters::CompressorCheck(double dt) // Q: 20160712 // aktualizacja ciśnienia w przewodzie głównym // ************************************************************************************************* -void TMoverParameters::UpdatePipePressure(double dt) +void TMoverParameters::UpdatePipePressure(const double dt) { if (PipePress > 1.0) { @@ -4760,7 +4760,7 @@ void TMoverParameters::UpdatePipePressure(double dt) // Q: 20160713 // Aktualizacja ciśnienia w przewodzie zasilającym // ************************************************************************************************* -void TMoverParameters::UpdateScndPipePressure(double dt) +void TMoverParameters::UpdateScndPipePressure(const double dt) { if (ScndPipePress > 1.0) { @@ -4859,7 +4859,7 @@ void TMoverParameters::UpdateSpringBrake(double dt) // Q: 20160715 // oblicza i zwraca przepływ powietrza pomiędzy pojazdami // ************************************************************************************************* -double TMoverParameters::GetDVc(double dt) +double TMoverParameters::GetDVc(const double dt) { // T_MoverParameters *c; TMoverParameters *c; @@ -4996,7 +4996,7 @@ void TMoverParameters::ComputeMass() // Obliczanie wypadkowej siły z wszystkich działających sił // ************************************************************************************************* // TBD, TODO: move some of the calculations out of the method, they're relevant to more than just force calculations -void TMoverParameters::ComputeTotalForce(double dt) +void TMoverParameters::ComputeTotalForce(const double dt) { Vel = std::abs(V) * 3.6; // prędkość w km/h @@ -5136,7 +5136,7 @@ void TMoverParameters::ComputeTotalForce(double dt) FTotal = FTrain - Sign(V) * FStand; } -double TMoverParameters::BrakeForceR(double ratio, double velocity) +double TMoverParameters::BrakeForceR(double ratio, const double velocity) { double press = 0; if (MBPM > 2) @@ -5165,7 +5165,7 @@ double TMoverParameters::BrakeForceR(double ratio, double velocity) return BrakeForceP(press * ratio, velocity); } -double TMoverParameters::BrakeForceP(double press, double velocity) +double TMoverParameters::BrakeForceP(const double press, const double velocity) { double BFP = 0; double K = ((press * P2FTrans - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj) * BrakeRigEff; @@ -5264,7 +5264,7 @@ double TMoverParameters::FrictionForce() const // Q: 20160713 // Oblicza przyczepność // ************************************************************************************************* -double TMoverParameters::Adhesive(double staticfriction) const +double TMoverParameters::Adhesive(const double staticfriction) const { double adhesion = 0.0; constexpr double adh_factor = 0.25; // współczynnik określający, jak bardzo spada tarcie przy poślizgu @@ -5319,7 +5319,7 @@ double TMoverParameters::Adhesive(double staticfriction) const // Q: 20160713 // Obliczanie sił dzialających na sprzęgach // ************************************************************************************************* -double TMoverParameters::CouplerForce(int const End, double dt) +double TMoverParameters::CouplerForce(int const End, const double dt) { auto &coupler{Couplers[End]}; @@ -5477,7 +5477,7 @@ double TMoverParameters::CouplerForce(int const End, double dt) // Q: 20160714 // oblicza sile trakcyjna lokomotywy (dla elektrowozu tez calkowity prad) // ************************************************************************************************* -double TMoverParameters::TractionForce(double dt) +double TMoverParameters::TractionForce(const double dt) { double PosRatio, dmoment, dtrans, tmp; @@ -6568,7 +6568,7 @@ double TMoverParameters::TractionForce(double dt) // Q: 20160713 // Obliczenie predkości obrotowej kół??? // ************************************************************************************************* -double TMoverParameters::ComputeRotatingWheel(double WForce, double dt, double n) const +double TMoverParameters::ComputeRotatingWheel(const double WForce, const double dt, const double n) const { double newn = 0, eps = 0; if (n == 0 && WForce * Sign(V) < 0) @@ -6742,7 +6742,7 @@ double TMoverParameters::v2n(void) // Q: 20160714 // Oblicza moment siły wytwarzany przez silnik // ************************************************************************************************* -double TMoverParameters::Momentum(double I) +double TMoverParameters::Momentum(const double I) { // liczy moment sily wytwarzany przez silnik elektryczny} int SP; @@ -6760,7 +6760,7 @@ double TMoverParameters::Momentum(double I) // Q: 20160714 // Oblicza moment siły do sterowania wzbudzeniem // ************************************************************************************************* -double TMoverParameters::MomentumF(double I, double Iw, int SCP) +double TMoverParameters::MomentumF(const double I, const double Iw, const int SCP) { // umozliwia dokladne sterowanie wzbudzeniem @@ -6789,7 +6789,7 @@ bool TMoverParameters::CutOffEngine(void) // Q: 20160713 // Przełączenie wysoki / niski prąd rozruchu // ************************************************************************************************* -bool TMoverParameters::MaxCurrentSwitch(bool State, range_t const Notify) +bool TMoverParameters::MaxCurrentSwitch(const bool State, range_t const Notify) { auto const initialstate{MotorOverloadRelayHighThreshold}; @@ -6807,7 +6807,7 @@ bool TMoverParameters::MaxCurrentSwitch(bool State, range_t const Notify) // Q: 20160713 // Przełączenie wysoki / niski prąd rozruchu automatycznego // ************************************************************************************************* -bool TMoverParameters::MinCurrentSwitch(bool State) +bool TMoverParameters::MinCurrentSwitch(const bool State) { bool MCS = false; if ((EngineType == TEngineType::ElectricSeriesMotor && IminHi > IminLo) || (TrainType == dt_EZT && EngineType != TEngineType::ElectricInductionMotor)) @@ -6855,7 +6855,7 @@ bool TMoverParameters::ResistorsFlagCheck(void) const // Q: 20160713 // Włączenie / wyłączenie automatycznego rozruchu // ************************************************************************************************* -bool TMoverParameters::AutoRelaySwitch(bool State) +bool TMoverParameters::AutoRelaySwitch(const bool State) { bool ARS; if (AutoRelayType == 2 && AutoRelayFlag != State) @@ -7323,7 +7323,7 @@ bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify return State != initialstate; } -void TMoverParameters::CheckEIMIC(double dt) +void TMoverParameters::CheckEIMIC(const double dt) { const double offset = EIMCtrlAdditionalZeros ? 1.0 : 0.0; const double multiplier = (EIMCtrlEmergency ? 1.0 : 0.0) + offset; @@ -7511,7 +7511,7 @@ void TMoverParameters::CheckEIMIC(double dt) eimic = std::clamp(eimic, -1.0, eimicpowerenabled ? eimic_max : 0.0); } -void TMoverParameters::CheckSpeedCtrl(double dt) +void TMoverParameters::CheckSpeedCtrl(const double dt) { if (EIMCtrlType == 0) { @@ -7613,7 +7613,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt) } } -void TMoverParameters::SpeedCtrlButton(int button) +void TMoverParameters::SpeedCtrlButton(const int button) { if (SpeedCtrl && ScndCtrlPos > 0) { @@ -7667,7 +7667,7 @@ bool TMoverParameters::SpeedCtrlPowerDec() // Q: 20160715 // Zmienia parametr do którego dąży sprzęgło // ************************************************************************************************* -bool TMoverParameters::dizel_EngageSwitch(double state) +bool TMoverParameters::dizel_EngageSwitch(const double state) { if (EngineType == TEngineType::DieselEngine && state <= 1 && state >= 0 && state != dizel_engagestate) { @@ -7871,7 +7871,7 @@ bool TMoverParameters::dizel_StartupCheck() // Q: 20160715 // Aktualizacja stanu silnika // ************************************************************************************************* -bool TMoverParameters::dizel_Update(double dt) +bool TMoverParameters::dizel_Update(const double dt) { WaterPumpCheck(dt); @@ -7925,7 +7925,7 @@ bool TMoverParameters::dizel_Update(double dt) // Q: 20160715 // oblicza napelnienie, uzwglednia regulator obrotow // ************************************************************************************************* -double TMoverParameters::dizel_fillcheck(int mcp, double dt) +double TMoverParameters::dizel_fillcheck(const int mcp, const double dt) { auto realfill{0.0}; @@ -8027,7 +8027,7 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt) // Q: 20160715 // Oblicza moment siły wytwarzany przez silnik spalinowy // ************************************************************************************************* -double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt) +double TMoverParameters::dizel_Momentum(const double dizel_fill, double n, const double dt) { // liczy moment sily wytwarzany przez silnik spalinowy} double Moment = 0, enMoment = 0, gearMoment = 0, eps = 0, newn = 0, friction = 0, neps = 0; double TorqueH = 0, TorqueL = 0, TorqueC = 0; @@ -8200,7 +8200,7 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt) return gearMoment; } -double TMoverParameters::dizel_MomentumRetarder(double n, double dt) +double TMoverParameters::dizel_MomentumRetarder(double n, const double dt) { double RetarderRequest = Mains ? std::max(0.0, -eimic_real) : 0; if (hydro_R_WithIndividual) @@ -8876,7 +8876,7 @@ void TMoverParameters::update_doors(double const Deltatime) // Q: 20160713 // Przesuwa pojazd o podaną wartość w bok względem toru (dla samochodów) // ************************************************************************************************* -bool TMoverParameters::ChangeOffsetH(double DeltaOffset) +bool TMoverParameters::ChangeOffsetH(const double DeltaOffset) { bool COH = false; if (TestFlag(CategoryFlag, 2) && TestFlag(RunningTrack.CategoryFlag, 2)) @@ -8898,7 +8898,7 @@ bool TMoverParameters::ChangeOffsetH(double DeltaOffset) // Q: 20160713 // Testuje zmienną (narazie tylko 0) i na podstawie uszkodzenia zwraca informację tekstową // ************************************************************************************************* -std::string TMoverParameters::EngineDescription(int what) const +std::string TMoverParameters::EngineDescription(const int what) const { std::string outstr{"OK"}; switch (what) @@ -11709,7 +11709,7 @@ TEngineType TMoverParameters::LoadFIZ_EngineDecode(std::string const &Engine) // Q: 20160717 // ************************************************************************************************* -bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) +bool TMoverParameters::CheckLocomotiveParameters(const bool ReadyFlag, int Dir) { WriteLog("check locomotive parameters..."); int b; @@ -12097,7 +12097,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir) // Q: 20160714 // Wstawia komendę z parametrem, od sprzęgu i w lokalizacji do pojazdu // ************************************************************************************************* -void TMoverParameters::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation) +void TMoverParameters::PutCommand(std::string NewCommand, const double NewValue1, const double NewValue2, const TLocation &NewLocation) { CommandLast = NewCommand; // zapamiętanie komendy @@ -12122,7 +12122,7 @@ double TMoverParameters::GetExternalCommand(std::string &Command) // Q: 20160714 // Ustawienie komendy wraz z parametrami // ************************************************************************************************* -bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype) +bool TMoverParameters::SetInternalCommand(std::string NewCommand, const double NewValue1, const double NewValue2, int const Couplertype) { bool SIC; if (CommandIn.Command == NewCommand && CommandIn.Value1 == NewValue1 && CommandIn.Value2 == NewValue2 && CommandIn.Coupling == Couplertype) @@ -12187,7 +12187,7 @@ bool TMoverParameters::SendCtrlToNext(std::string const CtrlCommand, double cons // Komenda musi być zdefiniowana tutaj, a jeśli się wywołuje funkcję, to ona nie może // sama przesyłać do kolejnych pojazdów. Należy też się zastanowić, czy dla uzyskania // jakiejś zmiany (np. IncMainCtrl) lepiej wywołać funkcję, czy od razu wysłać komendę. -bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CValue2, int const Couplertype) +bool TMoverParameters::RunCommand(std::string Command, const double CValue1, const double CValue2, int const Couplertype) { bool OK{false}; @@ -12753,7 +12753,7 @@ bool TMoverParameters::RunInternalCommand() // Q: 20160714 // Zwraca wartość natężenia prądu na wybranym amperomierzu. Podfunkcja do ShowCurrent. // ************************************************************************************************* -double TMoverParameters::ShowCurrentP(int AmpN) const +double TMoverParameters::ShowCurrentP(const int AmpN) const { int b, Bn; bool Grupowy; diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp index 654c1894..ca5f2092 100644 --- a/McZapkie/Oerlikon_ESt.cpp +++ b/McZapkie/Oerlikon_ESt.cpp @@ -36,12 +36,12 @@ void TRura::Update(double dt) // ------ PRZECIWPOSLIG ------ -void TPrzeciwposlizg::SetPoslizg(bool flag) +void TPrzeciwposlizg::SetPoslizg(const bool flag) { Poslizg = flag; } -void TPrzeciwposlizg::Update(double dt) +void TPrzeciwposlizg::Update(const double dt) { if (true == Poslizg) { @@ -55,7 +55,7 @@ void TPrzeciwposlizg::Update(double dt) // ------ PRZEKLADNIK ------ -void TPrzekladnik::Update(double dt) +void TPrzekladnik::Update(const double dt) { double dV; @@ -78,7 +78,7 @@ void TPrzekladnik::Update(double dt) // ------ PRZEKLADNIK RAPID ------ -void TRapid::SetRapidParams(double mult, double size) +void TRapid::SetRapidParams(const double mult, const double size) { RapidMult = mult; RapidStatus = false; @@ -94,12 +94,12 @@ void TRapid::SetRapidParams(double mult, double size) } } -void TRapid::SetRapidStatus(bool rs) +void TRapid::SetRapidStatus(const bool rs) { RapidStatus = rs; } -void TRapid::Update(double dt) +void TRapid::Update(const double dt) { const double BVP{ BrakeRes->P() }; const double BCP{ Next->P() }; @@ -129,12 +129,12 @@ void TRapid::Update(double dt) // ------ PRZEKŁADNIK CIĄGŁY ------ -void TPrzekCiagly::SetMult(double m) +void TPrzekCiagly::SetMult(const double m) { Mult = m; } -void TPrzekCiagly::Update(double dt) +void TPrzekCiagly::Update(const double dt) { double const BVP{ BrakeRes->P() }; double const BCP{ Next->P() }; @@ -154,12 +154,12 @@ void TPrzekCiagly::Update(double dt) // ------ PRZEKŁADNIK CIĄGŁY ------ -void TPrzek_PZZ::SetLBP(double P) +void TPrzek_PZZ::SetLBP(const double P) { LBP = P; } -void TPrzek_PZZ::Update(double dt) +void TPrzek_PZZ::Update(const double dt) { double const BVP{ BrakeRes->P() }; @@ -181,12 +181,12 @@ void TPrzek_PZZ::Update(double dt) // ------ PRZECIWPOSLIG ------ -void TPrzekED::SetP(double P) +void TPrzekED::SetP(const double P) { MaxP = P; } -void TPrzekED::Update(double dt) +void TPrzekED::Update(const double dt) { if (Next->P() > MaxP) { diff --git a/McZapkie/Oerlikon_ESt.h b/McZapkie/Oerlikon_ESt.h index dc7df462..f0eb788c 100644 --- a/McZapkie/Oerlikon_ESt.h +++ b/McZapkie/Oerlikon_ESt.h @@ -205,7 +205,7 @@ class TNESt3 : public TBrake { double LBP = 0.0; // cisnienie hamulca pomocniczego public: - TNESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : + TNESt3(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} void Init( double PP, double HPP, double LPP, double BP, int BDF ) /*override*/; diff --git a/McZapkie/friction.cpp b/McZapkie/friction.cpp index 6ecf5a06..89f90bb7 100644 --- a/McZapkie/friction.cpp +++ b/McZapkie/friction.cpp @@ -20,7 +20,7 @@ double TFricMat::GetFC(double N, double Vel) return 1; } -double TP10Bg::GetFC(double N, double Vel) +double TP10Bg::GetFC(const double N, const double Vel) { // GetFC:=0.60*((1.6*N+100)/(8.0*N+100))*((Vel+100)/(5*Vel+100))*(1.0032-0.0007*N-0.0001*N*N); // GetFC:=47/(2*Vel+100)*(2.145-0.0538*N+0.00074*N*N-0.00000536*N*N*N)/2.145; @@ -34,7 +34,7 @@ double TP10Bg::GetFC(double N, double Vel) 0.384 * exp(-Vel * 1.0 / 25.7) - 0.028; } -double TP10Bgu::GetFC(double N, double Vel) +double TP10Bgu::GetFC(const double N, const double Vel) { // GetFC:=0.60*((1.6*N+100)/(8.0*N+100))*((Vel+100)/(5*Vel+100)); // GetFC:=47/(2*Vel+100)*(2.137-0.0514*N+0.000832*N*N-0.00000604*N*N*N)/2.137; @@ -49,7 +49,7 @@ double TP10Bgu::GetFC(double N, double Vel) 0.381 * exp(-Vel * 1.0 / 25.7) - 0.022; // 0.05*exp(-0.2*N); } -double TP10yBg::GetFC(double N, double Vel) +double TP10yBg::GetFC(const double N, const double Vel) { double A; double C; @@ -63,7 +63,7 @@ double TP10yBg::GetFC(double N, double Vel) return u0 + C * exp(-Vel * 1.0 / V0); } -double TP10yBgu::GetFC(double N, double Vel) +double TP10yBgu::GetFC(const double N, const double Vel) { double A; double C; @@ -77,14 +77,14 @@ double TP10yBgu::GetFC(double N, double Vel) return u0 + C * exp(-Vel * 1.0 / V0); } -double TP10::GetFC(double N, double Vel) +double TP10::GetFC(const double N, const double Vel) { return 0.60 * ((1.6 * N + 100) * 1.0 / (8.0 * N + 100)) * ((Vel + 100) * 1.0 / (5 * Vel + 100)); // GetFC:=43/(2*Vel+100)*(2.145-0.0538*N+0.00074*N*N-0.00000536*N*N*N)/2.145 } -double TFR513::GetFC(double N, double Vel) +double TFR513::GetFC(double N, const double Vel) { return 0.3 - Vel * 0.00081; // GetFC:=43/(2*Vel+100)*(2.145-0.0538*N+0.00074*N*N-0.00000536*N*N*N)/2.145 @@ -95,7 +95,7 @@ double TCosid::GetFC(double N, double Vel) return 0.27; } -double TDisk1::GetFC(double N, double Vel) +double TDisk1::GetFC(const double N, double Vel) { return 0.2375 + 0.000885 * N - 0.000345 * N * N; } diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp index 71de6b86..29d083a7 100644 --- a/McZapkie/hamulce.cpp +++ b/McZapkie/hamulce.cpp @@ -43,7 +43,7 @@ double const TFVE408::pos_table[11] = {0, 10, 0, 0, 10, 7, 8, 9, 0, 1, 5}; /// Source pressure [bar]. /// Destination pressure [bar]. /// Dimensionless flow driver (positive when P2 > P1). -double PR(double P1, double P2) +double PR(const double P1, const double P2) { const double PH = std::max(P1, P2) + 0.1; const double PL = P1 + P2 - PH + 0.2; @@ -57,7 +57,7 @@ double PR(double P1, double P2) /// Destination pressure [bar]. /// Effective orifice cross-section. /// Volumetric flow rate (signed). -double PF_old(double P1, double P2, double S) +double PF_old(const double P1, const double P2, const double S) { const double PH = std::max(P1, P2) + 1; const double PL = P1 + P2 - PH + 2; @@ -203,7 +203,7 @@ double PFVd(double PH, double PL, double const S, double LIM, double const DP) /// Continuous handle position. /// Detent centre to compare against. /// True if pos is within ±0.5 of i_pos. -bool is_EQ(double pos, double i_pos) +bool is_EQ(const double pos, const double i_pos) { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -233,7 +233,7 @@ double TReservoir::P() /// The change is applied to Vol on the next call to . /// /// Flow delta (positive = into reservoir, negative = out). -void TReservoir::Flow(double dv) +void TReservoir::Flow(const double dv) { dVol = dVol + dv; } @@ -252,7 +252,7 @@ void TReservoir::Act() /// Sets the reservoir capacity in liters. /// /// Capacity in liters. -void TReservoir::CreateCap(double Capacity) +void TReservoir::CreateCap(const double Capacity) { Cap = Capacity; } @@ -262,7 +262,7 @@ void TReservoir::CreateCap(double Capacity) /// and clears any pending flow. /// /// Initial pressure in bar. -void TReservoir::CreatePress(double Press) +void TReservoir::CreatePress(const double Press) { Vol = Cap * Press; dVol = 0; @@ -367,7 +367,7 @@ end ; */ /// Friction material id (bp_* constant, optionally OR'ed with bp_MHS). /// Number of braked axles. /// Number of blocks per axle. -TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) +TBrake::TBrake(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, int i_mat, const int i_ba, const int i_nbpa) { // inherited:: Create; MaxBP = i_mbp; @@ -1313,7 +1313,7 @@ void TEStEP2::SetLP(double const TM, double const LM, double const TBP) /// quadratic-in-EPS rate and a load-weighing-aware ceiling at MaxBP * LoadC. /// /// Time step [s]. -void TEStEP2::EPCalc(double dt) +void TEStEP2::EPCalc(const double dt) { const double temp = BrakeRes->P() * int(EPS > 0); const double dv = PF(temp, LBP, 0.00053 + 0.00060 * int(EPS < 0)) * dt * EPS * EPS * int(LBP * EPS < MaxBP * LoadC); @@ -1327,7 +1327,7 @@ void TEStEP2::EPCalc(double dt) /// opening with a clamped error term S. /// /// Time step [s]. -void TEStEP1::EPCalc(double dt) +void TEStEP1::EPCalc(const double dt) { const double temp = EPS - std::floor(EPS); // część ułamkowa jest hamulcem EP const double LBPLim = std::min(MaxBP * LoadC * temp, BrakeRes->P()); // do czego dążymy @@ -2940,14 +2940,14 @@ double TDriverHandle::GetEP(double pos) /// Latches the manual overcharge / assimilation button state. /// /// True while the button is pressed. -void TDriverHandle::OvrldButton(bool Active) +void TDriverHandle::OvrldButton(const bool Active) { ManualOvrldActive = Active; } /// Stores the universal-button flags (combined ub_* values). /// Universal-button bitfield. -void TDriverHandle::SetUniversalFlag(int flag) +void TDriverHandle::SetUniversalFlag(const int flag) { UniversalFlag = flag; } @@ -2966,7 +2966,7 @@ void TDriverHandle::SetUniversalFlag(int flag) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TFV4a::GetPF(const double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; @@ -3034,7 +3034,7 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises CP and RP to the supplied pressure. /// Initial pressure [bar]. -void TFV4a::Init(double Press) +void TFV4a::Init(const double Press) { CP = Press; RP = Press; @@ -3055,7 +3055,7 @@ void TFV4a::Init(double Press) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TFV4aM::GetPF(double i_bcp, const double PP, const double HP, const double dt, double ep) { constexpr int LBDelay{100}; constexpr double xpM{0.3}; // mnoznik membrany komory pod @@ -3213,7 +3213,7 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises CP and RP to the supplied pressure. /// Initial pressure [bar]. -void TFV4aM::Init(double Press) +void TFV4aM::Init(const double Press) { CP = Press; RP = Press; @@ -3221,14 +3221,14 @@ void TFV4aM::Init(double Press) /// Sets the reductor adjustment offset (turning the reductor cap). /// Pressure correction [bar]. -void TFV4aM::SetReductor(double nAdj) +void TFV4aM::SetReductor(const double nAdj) { RedAdj = nAdj; } /// Returns Sounds[i] for valid indices, 0 otherwise. /// Sound channel index (s_fv4a_*). -double TFV4aM::GetSound(int i) +double TFV4aM::GetSound(const int i) { if (i > 4) return 0; @@ -3238,7 +3238,7 @@ double TFV4aM::GetSound(int i) /// Returns pos_table[i] (handle position for the requested function code). /// Function code (bh_*). -double TFV4aM::GetPos(int i) +double TFV4aM::GetPos(const int i) { return pos_table[i]; } @@ -3262,7 +3262,7 @@ double TFV4aM::GetRP() /// /// Continuous handle position. /// Interpolated target pressure [bar]. -double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; +double TFV4aM::LPP_RP(const double pos) // cisnienie z zaokraglonej pozycji; { int const i_pos = 2 + std::floor(pos); // zaokraglone w dol @@ -3271,7 +3271,7 @@ double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; /// Returns true if pos is within ±0.5 of i_pos (detent test). /// Continuous handle position. /// Detent centre. -bool TFV4aM::EQ(double pos, double i_pos) +bool TFV4aM::EQ(const double pos, const double i_pos) { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -3291,7 +3291,7 @@ bool TFV4aM::EQ(double pos, double i_pos) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TMHZ_EN57::GetPF(double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; @@ -3387,21 +3387,21 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep /// Initialises CP to the supplied pressure. /// Initial pressure [bar]. -void TMHZ_EN57::Init(double Press) +void TMHZ_EN57::Init(const double Press) { CP = Press; } /// Sets the reductor adjustment offset. /// Pressure correction [bar]. -void TMHZ_EN57::SetReductor(double nAdj) +void TMHZ_EN57::SetReductor(const double nAdj) { RedAdj = nAdj; } /// Returns Sounds[i] for valid indices, 0 otherwise. /// Sound channel index. -double TMHZ_EN57::GetSound(int i) +double TMHZ_EN57::GetSound(const int i) { if (i > 4) return 0; @@ -3411,7 +3411,7 @@ double TMHZ_EN57::GetSound(int i) /// Returns pos_table[i]. /// Function code (bh_*). -double TMHZ_EN57::GetPos(int i) +double TMHZ_EN57::GetPos(const int i) { return pos_table[i]; } @@ -3433,7 +3433,7 @@ double TMHZ_EN57::GetRP() /// (linear ramp 0..1 between positions 0 and 8, zero above 9.5). /// /// Handle position. -double TMHZ_EN57::GetEP(double pos) +double TMHZ_EN57::GetEP(const double pos) { if (pos < 9.5) return std::clamp(0.125 * pos, 0., 1.); @@ -3448,7 +3448,7 @@ double TMHZ_EN57::GetEP(double pos) /// /// Continuous handle position. /// Target brake-pipe pressure [bar]. -double TMHZ_EN57::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; +double TMHZ_EN57::LPP_RP(const double pos) // cisnienie z zaokraglonej pozycji; { if (pos > 8.5) return 5.0 - 0.15 * pos - 0.35; @@ -3470,7 +3470,7 @@ double TMHZ_EN57::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; /// Unbrake over-pressure [bar]. /// Overload (assimilation) max pressure. /// Overload pressure decay rate. -void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double, double OMP, double OPD) +void TMHZ_EN57::SetParams(const bool AO, const bool MO, const double OverP, double, const double OMP, const double OPD) { AutoOvrld = AO; ManualOvrld = MO; @@ -3481,7 +3481,7 @@ void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double, double OMP, do } /// Returns true if pos is within ±0.5 of i_pos (detent test). -bool TMHZ_EN57::EQ(double pos, double i_pos) +bool TMHZ_EN57::EQ(const double pos, const double i_pos) { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -3500,7 +3500,7 @@ bool TMHZ_EN57::EQ(double pos, double i_pos) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TMHZ_K5P::GetPF(double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; @@ -3599,7 +3599,7 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises CP and enables the time / EP-time chambers. /// Initial pressure [bar]. -void TMHZ_K5P::Init(double Press) +void TMHZ_K5P::Init(const double Press) { CP = Press; Time = true; @@ -3608,14 +3608,14 @@ void TMHZ_K5P::Init(double Press) /// Sets the reductor adjustment offset. /// Pressure correction [bar]. -void TMHZ_K5P::SetReductor(double nAdj) +void TMHZ_K5P::SetReductor(const double nAdj) { RedAdj = nAdj; } /// Returns Sounds[i] for valid indices, 0 otherwise. /// Sound channel index. -double TMHZ_K5P::GetSound(int i) +double TMHZ_K5P::GetSound(const int i) { if (i > 4) return 0; @@ -3625,7 +3625,7 @@ double TMHZ_K5P::GetSound(int i) /// Returns pos_table[i]. /// Function code (bh_*). -double TMHZ_K5P::GetPos(int i) +double TMHZ_K5P::GetPos(const int i) { return pos_table[i]; } @@ -3653,7 +3653,7 @@ double TMHZ_K5P::GetRP() /// Filling-stroke factor offset (FillingStrokeFactor = 1 + FSF). /// Overload max pressure. /// Overload pressure decay rate. -void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, double OPD) +void TMHZ_K5P::SetParams(const bool AO, const bool MO, const double OverP, const double FSF, const double OMP, const double OPD) { AutoOvrld = AO; ManualOvrld = MO; @@ -3665,7 +3665,7 @@ void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, } /// Returns true if pos is within ±0.5 of i_pos (detent test). -bool TMHZ_K5P::EQ(double pos, double i_pos) +bool TMHZ_K5P::EQ(const double pos, const double i_pos) { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -3683,7 +3683,7 @@ bool TMHZ_K5P::EQ(double pos, double i_pos) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TMHZ_6P::GetPF(double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; @@ -3782,7 +3782,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises CP and enables the time / EP-time chambers. /// Initial pressure [bar]. -void TMHZ_6P::Init(double Press) +void TMHZ_6P::Init(const double Press) { CP = Press; Time = true; @@ -3791,14 +3791,14 @@ void TMHZ_6P::Init(double Press) /// Sets the reductor adjustment offset. /// Pressure correction [bar]. -void TMHZ_6P::SetReductor(double nAdj) +void TMHZ_6P::SetReductor(const double nAdj) { RedAdj = nAdj; } /// Returns Sounds[i] for valid indices, 0 otherwise. /// Sound channel index. -double TMHZ_6P::GetSound(int i) +double TMHZ_6P::GetSound(const int i) { if (i > 4) return 0; @@ -3808,7 +3808,7 @@ double TMHZ_6P::GetSound(int i) /// Returns pos_table[i]. /// Function code (bh_*). -double TMHZ_6P::GetPos(int i) +double TMHZ_6P::GetPos(const int i) { return pos_table[i]; } @@ -3836,7 +3836,7 @@ double TMHZ_6P::GetRP() /// Filling-stroke factor offset. /// Overload max pressure. /// Overload pressure decay rate. -void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, double OPD) +void TMHZ_6P::SetParams(const bool AO, const bool MO, const double OverP, const double FSF, const double OMP, const double OPD) { AutoOvrld = AO; ManualOvrld = MO; @@ -3848,7 +3848,7 @@ void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP, } /// Returns true if pos is within ±0.5 of i_pos (detent test). -bool TMHZ_6P::EQ(double pos, double i_pos) +bool TMHZ_6P::EQ(const double pos, const double i_pos) { return pos <= i_pos + 0.5 && pos > i_pos - 0.5; } @@ -3867,7 +3867,7 @@ bool TMHZ_6P::EQ(double pos, double i_pos) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TM394::GetPF(const double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 65; @@ -3916,7 +3916,7 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises CP and enables the time chamber. /// Initial pressure [bar]. -void TM394::Init(double Press) +void TM394::Init(const double Press) { CP = Press; Time = true; @@ -3924,7 +3924,7 @@ void TM394::Init(double Press) /// Sets the reductor adjustment offset. /// Pressure correction [bar]. -void TM394::SetReductor(double nAdj) +void TM394::SetReductor(const double nAdj) { RedAdj = nAdj; } @@ -3943,7 +3943,7 @@ double TM394::GetRP() /// Returns pos_table[i]. /// Function code (bh_*). -double TM394::GetPos(int i) +double TM394::GetPos(const int i) { return pos_table[i]; } @@ -3963,7 +3963,7 @@ double TM394::GetPos(int i) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TH14K1::GetPF(const double i_bcp, const double PP, const double HP, const double dt, double ep) { constexpr int LBDelay = 100; // szybkosc + zasilanie sterujacego // static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2] = @@ -4009,7 +4009,7 @@ double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises CP and enables the time / EP-time chambers. /// Initial pressure [bar]. -void TH14K1::Init(double Press) +void TH14K1::Init(const double Press) { CP = Press; Time = true; @@ -4018,7 +4018,7 @@ void TH14K1::Init(double Press) /// Sets the reductor adjustment offset. /// Pressure correction [bar]. -void TH14K1::SetReductor(double nAdj) +void TH14K1::SetReductor(const double nAdj) { RedAdj = nAdj; } @@ -4037,7 +4037,7 @@ double TH14K1::GetRP() /// Returns pos_table[i]. /// Function code (bh_*). -double TH14K1::GetPos(int i) +double TH14K1::GetPos(const int i) { return pos_table[i]; } @@ -4055,7 +4055,7 @@ double TH14K1::GetPos(int i) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TSt113::GetPF(const double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; // szybkosc + zasilanie sterujacego static constexpr double NomPress = 5.0; @@ -4121,7 +4121,7 @@ double TSt113::GetEP() /// Returns pos_table[i]. /// Function code (bh_*). -double TSt113::GetPos(int i) +double TSt113::GetPos(const int i) { return pos_table[i]; } @@ -4147,7 +4147,7 @@ void TSt113::Init(double Press) /// Time step [s]. /// EP / equalising input [bar]. /// Brake pipe volume change for this step. -double Ttest::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double Ttest::GetPF(const double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; @@ -4182,7 +4182,7 @@ double Ttest::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises CP to the supplied pressure. /// Initial pressure [bar]. -void Ttest::Init(double Press) +void Ttest::Init(const double Press) { CP = Press; } @@ -4200,7 +4200,7 @@ void Ttest::Init(double Press) /// Time step [s]. /// EP / equalising input (unused). /// Negated cylinder pressure delta for this step. -double TFD1::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TFD1::GetPF(const double i_bcp, double PP, const double HP, const double dt, double ep) { double DP; double temp; @@ -4215,7 +4215,7 @@ double TFD1::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises MaxBP and the action speed (defaults to 1.0). /// Maximum cylinder pressure [bar]. -void TFD1::Init(double Press) +void TFD1::Init(const double Press) { MaxBP = Press; Speed = 1.0; @@ -4229,7 +4229,7 @@ double TFD1::GetCP() /// Sets the action speed multiplier (scales the response time). /// Speed multiplier. -void TFD1::SetSpeed(double nSpeed) +void TFD1::SetSpeed(const double nSpeed) { Speed = nSpeed; } @@ -4248,7 +4248,7 @@ void TFD1::SetSpeed(double nSpeed) /// Time step [s]. /// EP / equalising input (unused). /// Negated cylinder pressure delta for this step. -double TH1405::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TH1405::GetPF(const double i_bcp, double PP, const double HP, const double dt, double ep) { double DP; double temp; @@ -4274,7 +4274,7 @@ double TH1405::GetPF(double i_bcp, double PP, double HP, double dt, double ep) /// Initialises MaxBP and enables the time chamber. /// Maximum cylinder pressure [bar]. -void TH1405::Init(double Press) +void TH1405::Init(const double Press) { MaxBP = Press; Time = true; @@ -4300,7 +4300,7 @@ double TH1405::GetCP() /// Time step [s]. /// EP / equalising input (unused). /// Brake pipe volume change for this step. -double TFVel6::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TFVel6::GetPF(const double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; @@ -4361,14 +4361,14 @@ double TFVel6::GetEP() /// Returns pos_table[i]. /// Function code (bh_*). -double TFVel6::GetPos(int i) +double TFVel6::GetPos(const int i) { return pos_table[i]; } /// Returns Sounds[i] for valid indices, 0 otherwise. /// Sound channel index (0..2). -double TFVel6::GetSound(int i) +double TFVel6::GetSound(const int i) { if (i > 2) return 0; @@ -4397,7 +4397,7 @@ void TFVel6::Init(double Press) /// Time step [s]. /// EP / equalising input (unused). /// Brake pipe volume change for this step. -double TFVE408::GetPF(double i_bcp, double PP, double HP, double dt, double ep) +double TFVE408::GetPF(const double i_bcp, const double PP, const double HP, const double dt, double ep) { static constexpr int LBDelay = 100; @@ -4464,14 +4464,14 @@ double TFVE408::GetRP() /// Returns pos_table[i]. /// Function code (bh_*). -double TFVE408::GetPos(int i) +double TFVE408::GetPos(const int i) { return pos_table[i]; } /// Returns Sounds[i] for valid indices, 0 otherwise. /// Sound channel index (0..2). -double TFVE408::GetSound(int i) +double TFVE408::GetSound(const int i) { if (i > 2) return 0; diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.h index 7c564e52..5cfbdd6b 100644 --- a/McZapkie/hamulce.h +++ b/McZapkie/hamulce.h @@ -500,7 +500,7 @@ class TBrake virtual void SetED(double const EDstate) {}; // stan hamulca ED do luzowania /// Sets the universal-button flags (see TUniversalBrake). /// Combined ub_* flags. - virtual void SetUniversalFlag(int flag) + virtual void SetUniversalFlag(const int flag) { UniversalFlag = flag; } // przycisk uniwersalny @@ -556,7 +556,7 @@ class TWest : public TBrake void SetLP(double TM, double LM, double TBP); // parametry przystawki wazacej /// Constructs the distributor by forwarding all parameters to TBrake. - TWest(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} + TWest(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} }; /// @@ -614,7 +614,7 @@ class TESt : public TBrake void ForceEmptiness() /*override*/; // wymuszenie bycia pustym /// Constructs the ESt distributor and creates the control reservoir. - TESt(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) + TESt(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { CntrlRes = std::make_shared(); } @@ -636,7 +636,7 @@ class TESt3 : public TESt double GetPF(double PP, double dt, double Vel) /*override*/; // przeplyw miedzy komora wstepna i PG /// Constructs the ESt3 distributor. - TESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} + TESt3(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} }; /// @@ -669,7 +669,7 @@ class TESt3AL2 : public TESt3 void SetLP(double TM, double LM, double TBP); // parametry przystawki wazacej /// Constructs the distributor and creates the impulse chamber. - TESt3AL2(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt3(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) + TESt3AL2(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TESt3(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { ImplsRes = std::make_shared(); } @@ -700,7 +700,7 @@ class TESt4R : public TESt double GetPF(double PP, double dt, double Vel) /*override*/; // przeplyw miedzy komora wstepna i PG /// Constructs the distributor and creates the impulse chamber. - TESt4R(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) + TESt4R(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { ImplsRes = std::make_shared(); } @@ -743,7 +743,7 @@ class TLSt : public TESt4R virtual void SetED(double EDstate); // stan hamulca ED do luzowania /// Constructs the LSt distributor. - TLSt(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt4R(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} + TLSt(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TESt4R(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} }; /// @@ -826,7 +826,7 @@ class TEStEP2 : public TLSt void virtual EPCalc(double dt); /// Constructs the EP2 distributor. - TEStEP2(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TLSt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} + TEStEP2(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TLSt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {} }; /// @@ -845,7 +845,7 @@ class TEStEP1 : public TEStEP2 void SetEPS(double nEPS) override; // stan hamulca EP /// Constructs the EP1 distributor. - TEStEP1(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TEStEP2(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) + TEStEP1(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TEStEP2(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { } }; @@ -884,7 +884,7 @@ class TCV1 : public TBrake void ForceEmptiness() /*override*/; // wymuszenie bycia pustym /// Constructs the CV1 distributor and creates the control reservoir. - TCV1(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) + TCV1(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { CntrlRes = std::make_shared(); } @@ -931,7 +931,7 @@ class TCV1L_TR : public TCV1 double GetHPFlow(double HP, double dt) /*override*/; // przeplyw - 8 bar /// Constructs the CV1-L-TR and creates the impulse chamber. - TCV1L_TR(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TCV1(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) + TCV1L_TR(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TCV1(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { ImplsRes = std::make_shared(); } @@ -998,7 +998,7 @@ class TKE : public TBrake void ForceEmptiness() /*override*/; // wymuszenie bycia pustym /// Constructs the KE distributor and creates the control / impulse / secondary reservoirs. - TKE(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) + TKE(const double i_mbp, const double i_bcr, const double i_bcd, const double i_brc, const int i_bcn, const int i_BD, const int i_mat, const int i_ba, const int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) { ImplsRes = std::make_shared(); CntrlRes = std::make_shared(); diff --git a/application/application.cpp b/application/application.cpp index 368fb463..215a76f7 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -71,45 +71,45 @@ extern WNDPROC BaseWindowProc; // user input callbacks -void focus_callback(GLFWwindow *window, int focus) +void focus_callback(GLFWwindow *window, const int focus) { Application.on_focus_change(focus != 0); } -void framebuffer_resize_callback(GLFWwindow *, int w, int h) +void framebuffer_resize_callback(GLFWwindow *, const int w, const int h) { Global.fb_size = glm::ivec2(w, h); } -void window_resize_callback(GLFWwindow *, int w, int h) +void window_resize_callback(GLFWwindow *, const int w, const int h) { Global.window_size = glm::ivec2(w, h); Application.on_window_resize(w, h); } -void cursor_pos_callback(GLFWwindow *window, double x, double y) +void cursor_pos_callback(GLFWwindow *window, const double x, const double y) { Global.cursor_pos = glm::ivec2(x, y); Application.on_cursor_pos(x, y); } -void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) +void mouse_button_callback(GLFWwindow *window, const int button, const int action, const int mods) { Application.on_mouse_button(button, action, mods); } -void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) +void scroll_callback(GLFWwindow *window, const double xoffset, const double yoffset) { Application.on_scroll(xoffset, yoffset); } -void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods) +void key_callback(GLFWwindow *window, const int key, const int scancode, const int action, const int mods) { Application.on_key(key, scancode, action, mods); } -void char_callback(GLFWwindow *window, unsigned int c) +void char_callback(GLFWwindow *window, const unsigned int c) { Application.on_char(c); } @@ -304,7 +304,7 @@ void eu07_application::DiscordRPCService() } #endif -int eu07_application::init(int Argc, char *Argv[]) +int eu07_application::init(const int Argc, char *Argv[]) { int result{0}; @@ -436,7 +436,7 @@ double eu07_application::generate_sync() return sync; } -void eu07_application::queue_quit(bool direct) +void eu07_application::queue_quit(const bool direct) { if (direct || !m_modes[m_modestack.top()]->is_command_processor()) { @@ -891,13 +891,13 @@ void eu07_application::on_scroll(double const Xoffset, double const Yoffset) m_modes[m_modestack.top()]->on_scroll(Xoffset, Yoffset); } -void eu07_application::on_char(unsigned int c) +void eu07_application::on_char(const unsigned int c) { if (ui_layer::char_callback(c)) return; } -void eu07_application::on_focus_change(bool focus) +void eu07_application::on_focus_change(const bool focus) { if (Global.bInactivePause && m_network.has_value() && !m_network->client) { // jeśli ma być pauzowanie okna w tle @@ -906,14 +906,14 @@ void eu07_application::on_focus_change(bool focus) } } -void eu07_application::on_window_resize(int w, int h) +void eu07_application::on_window_resize(const int w, const int h) { if (m_modestack.empty()) return; m_modes[m_modestack.top()]->on_window_resize(w, h); } -GLFWwindow *eu07_application::window(int const Windowindex, bool visible, int width, int height, GLFWmonitor *monitor, bool keep_ownership, bool share_ctx) +GLFWwindow *eu07_application::window(int const Windowindex, const bool visible, const int width, const int height, GLFWmonitor *monitor, const bool keep_ownership, const bool share_ctx) { if (Windowindex >= 0) @@ -1105,7 +1105,7 @@ void eu07_application::init_files() } namespace fs = std::filesystem; -int eu07_application::init_settings(int Argc, char *Argv[]) +int eu07_application::init_settings(const int Argc, char *Argv[]) { Global.asVersion = VERSION_INFO; diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 5261b278..648c29d3 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -989,7 +989,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) { last_time = Timer::GetTime(); } -void debug_panel::graph_data::update(float val) { +void debug_panel::graph_data::update(const float val) { data[pos] = val; pos++; diff --git a/application/editormode.cpp b/application/editormode.cpp index a8451616..8febf510 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -48,12 +48,12 @@ namespace using vec3 = glm::vec3; using dvec2 = glm::dvec2; - bool is_release(int state) + bool is_release(const int state) { return state == GLFW_RELEASE; } - bool is_press(int state) + bool is_press(const int state) { return state == GLFW_PRESS; } @@ -373,7 +373,7 @@ scene::basic_node* editor_mode::find_node_by_any(scene::basic_node *node_ptr, co return nullptr; } -void editor_mode::push_snapshot(scene::basic_node *node, EditorSnapshot::Action Action, std::string const &Serialized) +void editor_mode::push_snapshot(scene::basic_node *node, const EditorSnapshot::Action Action, std::string const &Serialized) { if (!node) return; @@ -908,7 +908,7 @@ void editor_mode::render_terrain_ui() } } -editor_terrain *editor_mode::terrain_at(double X, double Z) +editor_terrain *editor_mode::terrain_at(const double X, const double Z) { for (const auto &terrain : m_terrains) if (terrain && terrain->contains(X, Z)) @@ -1131,7 +1131,7 @@ void editor_mode::capture_terrain() float const cellsize = static_cast(std::max(0.1, extent / cells)); // sampler: highest captured triangle at (x,z) - auto const sampler = [&tris](double X, double Z, double &OutY) -> bool { + auto const sampler = [&tris](const double X, const double Z, double &OutY) -> bool { double best = -std::numeric_limits::max(); bool found = false; for (auto const &t : tris) @@ -1745,7 +1745,7 @@ bool editor_mode::focus_active() return m_focus_active; } -void editor_mode::set_focus_active(bool isActive) +void editor_mode::set_focus_active(const bool isActive) { m_focus_active = isActive; } diff --git a/application/editormode.h b/application/editormode.h index 626283c0..53c6ab51 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -54,9 +54,9 @@ class editor_mode : public application_mode static void set_focus_active(bool isActive); static TCamera& get_camera() { return Camera; } static bool change_history() { return m_change_history; } - static void set_change_history(bool enabled) { m_change_history = enabled; } + static void set_change_history(const bool enabled) { m_change_history = enabled; } static bool settings_open() { return m_settings_open; } - static void set_settings_open(bool enabled) { m_settings_open = enabled; } + static void set_settings_open(const bool enabled) { m_settings_open = enabled; } private: // types struct editormode_input diff --git a/application/editoruilayer.cpp b/application/editoruilayer.cpp index 81f8ba6e..186a5d9e 100644 --- a/application/editoruilayer.cpp +++ b/application/editoruilayer.cpp @@ -49,7 +49,7 @@ void editor_ui::update() m_brushobjects.update(*ptr); } -void editor_ui::toggleBrushSettings(bool isVisible) +void editor_ui::toggleBrushSettings(const bool isVisible) { if (m_brushobjects.is_open != isVisible) m_brushobjects.is_open = isVisible; @@ -65,7 +65,7 @@ void editor_ui::add_node_template(const std::string &desc) m_nodebankpanel.add_template(desc); } -std::string const *editor_ui::get_active_node_template(bool bypassRandom) +std::string const *editor_ui::get_active_node_template(const bool bypassRandom) { if (!bypassRandom && m_brushobjects.is_open && m_brushobjects.useRandom && m_brushobjects.Objects.size() > 0) { diff --git a/application/editoruipanels.cpp b/application/editoruipanels.cpp index 3a661a26..03ff5403 100644 --- a/application/editoruipanels.cpp +++ b/application/editoruipanels.cpp @@ -381,7 +381,7 @@ brush_object_list::brush_object_list(std::string const &Name, bool const Isopen) size_max = {1000, 500}; } -bool brush_object_list::VectorGetter(void *data, int idx, const char **out_text) +bool brush_object_list::VectorGetter(void *data, const int idx, const char **out_text) { const auto *vec = static_cast *>(data); diff --git a/application/scenarioloaderuilayer.cpp b/application/scenarioloaderuilayer.cpp index b0aa5690..44af844b 100644 --- a/application/scenarioloaderuilayer.cpp +++ b/application/scenarioloaderuilayer.cpp @@ -103,7 +103,7 @@ std::vector scenarioloader_ui::get_random_trivia() } // Find byte position corresponding to character count - auto get_byte_pos_for_char_count = [&](const std::string& str, size_t char_count) -> size_t { + auto get_byte_pos_for_char_count = [&](const std::string& str, const size_t char_count) -> size_t { size_t byte_pos = 0; size_t current_chars = 0; for (size_t i = 0; i < str.length() && current_chars < char_count; ) @@ -136,7 +136,7 @@ std::vector scenarioloader_ui::get_random_trivia() }; // UTF-8 safe find space within character limit - auto find_space_before_char_count = [&](const std::string& str, size_t max_chars) -> size_t { + auto find_space_before_char_count = [&](const std::string& str, const size_t max_chars) -> size_t { const size_t byte_limit = get_byte_pos_for_char_count(str, max_chars); const size_t search_limit = std::min(str.length(), byte_limit); diff --git a/application/uilayer.cpp b/application/uilayer.cpp index c0b0fdd6..c6d91256 100644 --- a/application/uilayer.cpp +++ b/application/uilayer.cpp @@ -106,31 +106,31 @@ ui_layer::ui_layer() ui_layer::~ui_layer() {} -bool ui_layer::key_callback(int key, int scancode, int action, int mods) +bool ui_layer::key_callback(const int key, const int scancode, const int action, const int mods) { ImGui_ImplGlfw_KeyCallback(m_window, key, scancode, action, mods); return m_imguiio->WantCaptureKeyboard; } -bool ui_layer::char_callback(unsigned int c) +bool ui_layer::char_callback(const unsigned int c) { ImGui_ImplGlfw_CharCallback(m_window, c); return m_imguiio->WantCaptureKeyboard; } -bool ui_layer::scroll_callback(double xoffset, double yoffset) +bool ui_layer::scroll_callback(const double xoffset, const double yoffset) { ImGui_ImplGlfw_ScrollCallback(m_window, xoffset, yoffset); return m_imguiio->WantCaptureMouse; } -bool ui_layer::mouse_button_callback(int button, int action, int mods) +bool ui_layer::mouse_button_callback(const int button, const int action, const int mods) { ImGui_ImplGlfw_MouseButtonCallback(m_window, button, action, mods); return m_imguiio->WantCaptureMouse; } -static ImVec4 imvec_lerp(const ImVec4 &a, const ImVec4 &b, float t) +static ImVec4 imvec_lerp(const ImVec4 &a, const ImVec4 &b, const float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } @@ -356,7 +356,7 @@ bool ui_layer::on_mouse_button(int const Button, int const Action) return false; } -void ui_layer::on_window_resize(int w, int h) +void ui_layer::on_window_resize(const int w, const int h) { for (auto *panel : m_panels) panel->on_window_resize(w, h); diff --git a/application/uitranscripts.cpp b/application/uitranscripts.cpp index 96c9f735..1dadfa7f 100644 --- a/application/uitranscripts.cpp +++ b/application/uitranscripts.cpp @@ -11,7 +11,7 @@ TTranscripts Transcripts; // dodanie linii do tabeli, (show) i (hide) w [s] od aktualnego czasu void -TTranscripts::AddLine( std::string const &txt, float show, float hide, bool it ) { +TTranscripts::AddLine( std::string const &txt, float show, float hide, const bool it ) { if( show == hide ) { return; } // komentarz jest ignorowany diff --git a/audio/audiorenderer_extra.h b/audio/audiorenderer_extra.h index b7bbfd5c..29db5550 100644 --- a/audio/audiorenderer_extra.h +++ b/audio/audiorenderer_extra.h @@ -3,7 +3,7 @@ namespace audio { template openal_source & -openal_source::bind( sound_source *Controller, uint32_sequence Sounds, Iterator_ First, Iterator_ Last ) { +openal_source::bind( sound_source *Controller, const uint32_sequence Sounds, Iterator_ First, Iterator_ Last ) { controller = Controller; sounds = Sounds; diff --git a/editor/editorSettings.cpp b/editor/editorSettings.cpp index 86214d6b..325a8ec8 100644 --- a/editor/editorSettings.cpp +++ b/editor/editorSettings.cpp @@ -28,7 +28,7 @@ fs::path settings_path() return p.empty() ? fs::path("eu07_editor.ini") : p; } -const char *scheme_to_string(editorSettings::movement_scheme scheme) +const char *scheme_to_string(const editorSettings::movement_scheme scheme) { return scheme == editorSettings::movement_scheme::legacy ? "legacy" : "wsad"; } diff --git a/editor/editorSettings.hpp b/editor/editorSettings.hpp index 4ed09444..6af1b0fd 100644 --- a/editor/editorSettings.hpp +++ b/editor/editorSettings.hpp @@ -16,7 +16,7 @@ public: bool save(); movement_scheme movement() const { return m_movement; } - void movement(movement_scheme scheme) { m_movement = scheme; } + void movement(const movement_scheme scheme) { m_movement = scheme; } private: movement_scheme m_movement{movement_scheme::wsad}; diff --git a/editor/editorTerrain.cpp b/editor/editorTerrain.cpp index 55e71b5c..98a7cb60 100644 --- a/editor/editorTerrain.cpp +++ b/editor/editorTerrain.cpp @@ -84,7 +84,7 @@ bool editor_terrain::create(glm::dvec3 const &Center, int Cells, float CellSize, return true; } -glm::dvec3 editor_terrain::vertex_position(int Ix, int Iz) const +glm::dvec3 editor_terrain::vertex_position(const int Ix, const int Iz) const { return glm::dvec3( m_x0 + static_cast(Ix) * m_cellsize, @@ -105,7 +105,7 @@ glm::vec3 editor_terrain::vertex_normal(int Ix, int Iz) const return glm::normalize(n); } -world_vertex editor_terrain::make_vertex(int Ix, int Iz) const +world_vertex editor_terrain::make_vertex(const int Ix, const int Iz) const { world_vertex v; v.position = vertex_position(Ix, Iz); @@ -115,7 +115,7 @@ world_vertex editor_terrain::make_vertex(int Ix, int Iz) const } // emits one quad (two upward-facing triangles) spanning grid corners (X0,Z0)..(X1,Z1) -void editor_terrain::emit_quad(int X0, int Z0, int X1, int Z1, std::vector &Out) const +void editor_terrain::emit_quad(const int X0, const int Z0, const int X1, const int Z1, std::vector &Out) const { world_vertex const v00 = make_vertex(X0, Z0); world_vertex const v10 = make_vertex(X1, Z0); @@ -132,7 +132,7 @@ void editor_terrain::emit_quad(int X0, int Z0, int X1, int Z1, std::vector &Out) const +void editor_terrain::emit_block(const int X0, const int Z0, const int X1, const int Z1, const float Error, std::vector &Out) const { bool const splitx = (X1 - X0) > 1; bool const splitz = (Z1 - Z0) > 1; @@ -178,7 +178,7 @@ void editor_terrain::emit_block(int X0, int Z0, int X1, int Z1, float Error, std emit_block(xm, zm, X1, Z1, Error, Out); } -void editor_terrain::build_vertices(std::vector &Out, bool Simplify) const +void editor_terrain::build_vertices(std::vector &Out, const bool Simplify) const { Out.clear(); Out.reserve(static_cast(m_cells) * m_cells * 6); @@ -194,7 +194,7 @@ void editor_terrain::build_vertices(std::vector &Out, bool Simplif emit_quad(ix, iz, ix + 1, iz + 1, Out); } -void editor_terrain::regenerate(bool Simplify) +void editor_terrain::regenerate(const bool Simplify) { if (!valid()) return; @@ -233,7 +233,7 @@ void editor_terrain::regenerate(bool Simplify) m_vertexcount = gpuverts.size(); } -void editor_terrain::optimize(float ErrorMetres) +void editor_terrain::optimize(const float ErrorMetres) { m_simplify = true; m_simplify_error = (ErrorMetres > 0.0f ? ErrorMetres : 0.01f); @@ -269,14 +269,14 @@ void editor_terrain::destroy() m_heights.clear(); } -bool editor_terrain::contains(double X, double Z) const +bool editor_terrain::contains(const double X, const double Z) const { double const x1 = m_x0 + static_cast(m_cells) * m_cellsize; double const z1 = m_z0 + static_cast(m_cells) * m_cellsize; return (X >= m_x0 && X <= x1 && Z >= m_z0 && Z <= z1); } -double editor_terrain::height_at(double X, double Z) const +double editor_terrain::height_at(const double X, const double Z) const { double const fx = (X - m_x0) / m_cellsize; double const fz = (Z - m_z0) / m_cellsize; @@ -298,7 +298,7 @@ double editor_terrain::height_at(double X, double Z) const return h11 + (1.0 - tx) * (h01 - h11) + (1.0 - tz) * (h10 - h11); } -bool editor_terrain::sculpt(double X, double Z, double Radius, double Strength) +bool editor_terrain::sculpt(const double X, const double Z, const double Radius, const double Strength) { if (!valid() || Radius <= 0.0) return false; diff --git a/editor/editorTerrain.hpp b/editor/editorTerrain.hpp index 04436685..f77a518c 100644 --- a/editor/editorTerrain.hpp +++ b/editor/editorTerrain.hpp @@ -80,7 +80,7 @@ class editor_terrain std::size_t full_triangles() const { return static_cast(m_cells) * m_cells * 2; } private: - int index(int Ix, int Iz) const { return Iz * (m_cells + 1) + Ix; } + int index(const int Ix, const int Iz) const { return Iz * (m_cells + 1) + Ix; } glm::dvec3 vertex_position(int Ix, int Iz) const; glm::vec3 vertex_normal(int Ix, int Iz) const; world_vertex make_vertex(int Ix, int Iz) const; diff --git a/editor/editorTerrainStreamer.cpp b/editor/editorTerrainStreamer.cpp index 57dcf17b..e3dc1759 100644 --- a/editor/editorTerrainStreamer.cpp +++ b/editor/editorTerrainStreamer.cpp @@ -20,7 +20,7 @@ http://mozilla.org/MPL/2.0/. // simulation-level streamer instance (see header) terrain_streamer EditorTerrain; -void terrain_streamer::configure(int Cells, float CellSize, int Radius, float BaseHeight, std::string const &Texture) +void terrain_streamer::configure(const int Cells, const float CellSize, const int Radius, const float BaseHeight, std::string const &Texture) { m_cells = std::max(1, Cells); m_cellsize = std::max(0.1f, CellSize); @@ -29,19 +29,19 @@ void terrain_streamer::configure(int Cells, float CellSize, int Radius, float Ba m_texture = Texture; } -terrain_streamer::chunk_key terrain_streamer::key_at(double X, double Z) const +terrain_streamer::chunk_key terrain_streamer::key_at(const double X, const double Z) const { double const size = chunk_world_size(); return {static_cast(std::floor(X / size)), static_cast(std::floor(Z / size))}; } -glm::dvec3 terrain_streamer::chunk_centre(int Cx, int Cz) const +glm::dvec3 terrain_streamer::chunk_centre(const int Cx, const int Cz) const { double const size = chunk_world_size(); return glm::dvec3((Cx + 0.5) * size, static_cast(m_baseheight), (Cz + 0.5) * size); } -std::string terrain_streamer::chunk_path(int Cx, int Cz) const +std::string terrain_streamer::chunk_path(const int Cx, const int Cz) const { return m_dir + "/chunk_" + std::to_string(Cx) + "_" + std::to_string(Cz) + ".etc"; } @@ -60,7 +60,7 @@ bool terrain_streamer::chunk_on_disk(chunk_key const &Key) // 16-bit chunk file: 'ETC1' | uint16 cells | float baseY | float step | (cells+1)^2 * uint16 // where worldY = baseY + raw * step (per-chunk auto-scaled to fit the height range losslessly-ish) -bool terrain_streamer::load_heights(int Cx, int Cz, std::vector &Out) const +bool terrain_streamer::load_heights(const int Cx, const int Cz, std::vector &Out) const { std::ifstream f(chunk_path(Cx, Cz), std::ios::binary); if (!f) @@ -92,7 +92,7 @@ bool terrain_streamer::load_heights(int Cx, int Cz, std::vector &Out) con return true; } -void terrain_streamer::save_heights(int Cx, int Cz, editor_terrain const &Terrain) +void terrain_streamer::save_heights(const int Cx, const int Cz, editor_terrain const &Terrain) { auto const &h = Terrain.heights(); if (h.empty()) @@ -154,7 +154,7 @@ void terrain_streamer::update(glm::dvec3 const &CameraPos) int const cells = m_cells; float const cs = m_cellsize; editor_terrain::height_sampler sampler = - [&loaded, x0, z0, cells, cs](double X, double Z, double &OutY) -> bool { + [&loaded, x0, z0, cells, cs](const double X, const double Z, double &OutY) -> bool { int ix = static_cast(std::lround((X - x0) / cs)); int iz = static_cast(std::lround((Z - z0) / cs)); ix = std::clamp(ix, 0, cells); @@ -219,7 +219,7 @@ void terrain_streamer::collect(std::vector &Out) const Out.push_back(entry.second.get()); } -editor_terrain *terrain_streamer::terrain_at(double X, double Z) const +editor_terrain *terrain_streamer::terrain_at(const double X, const double Z) const { auto const it = m_chunks.find(key_at(X, Z)); if (it != m_chunks.end() && it->second && it->second->contains(X, Z)) diff --git a/editor/editorTerrainStreamer.hpp b/editor/editorTerrainStreamer.hpp index ead4a3e1..65f6ebe5 100644 --- a/editor/editorTerrainStreamer.hpp +++ b/editor/editorTerrainStreamer.hpp @@ -30,16 +30,16 @@ class terrain_streamer terrain_streamer() = default; - void active(bool State) { m_active = State; } + void active(const bool State) { m_active = State; } bool active() const { return m_active; } // per-chunk configuration (applied to chunks built from now on) void configure(int Cells, float CellSize, int Radius, float BaseHeight, std::string const &Texture); - void simplify(bool Auto, float Error) { m_auto_optimize = Auto; m_simplify_error = Error; } + void simplify(const bool Auto, const float Error) { m_auto_optimize = Auto; m_simplify_error = Error; } // safe to change while resident (only affects how far chunks load/unload) - void radius(int Radius) { m_radius = Radius < 0 ? 0 : Radius; } + void radius(const int Radius) { m_radius = Radius < 0 ? 0 : Radius; } // persist edited chunks to disk on unload, and load them back instead of regenerating - void persist(bool Enable) { m_persist = Enable; } + void persist(const bool Enable) { m_persist = Enable; } void directory(std::string const &Dir) { if (!Dir.empty() && Dir != m_dir) @@ -70,7 +70,7 @@ class terrain_streamer // persist an externally-authored chunk (e.g. a manual grid chunk being handed over to streaming) void save_chunk(int Cx, int Cz, editor_terrain const &Terrain); // chunk coordinate covering (X,Z) - chunk_key key_for(double X, double Z) const { return key_at(X, Z); } + chunk_key key_for(const double X, const double Z) const { return key_at(X, Z); } std::size_t resident() const { return m_chunks.size(); } float chunk_world_size() const { return m_cells * m_cellsize; } diff --git a/export_e3d_standalone.cpp b/export_e3d_standalone.cpp index ecdd4ab9..e55866a5 100644 --- a/export_e3d_standalone.cpp +++ b/export_e3d_standalone.cpp @@ -4,7 +4,7 @@ #include "utilities/Globals.h" #include "rendering/renderer.h" -void export_e3d_standalone(std::string in, std::string out, int flags, bool dynamic) +void export_e3d_standalone(std::string in, std::string out, const int flags, const bool dynamic) { Global.iConvertModels = flags; Global.iWriteLogEnabled = 2; diff --git a/extras/piped_proc.cpp b/extras/piped_proc.cpp index f7e4e67c..8466c6f8 100644 --- a/extras/piped_proc.cpp +++ b/extras/piped_proc.cpp @@ -34,7 +34,7 @@ size_t piped_proc::write(unsigned char *buf, size_t len) return fwrite(buf, 1, len, file); } #elif _WIN32 -piped_proc::piped_proc(std::string cmd, bool write) +piped_proc::piped_proc(std::string cmd, const bool write) { PROCESS_INFORMATION process; STARTUPINFO siStartInfo; @@ -86,7 +86,7 @@ piped_proc::~piped_proc() CloseHandle(proc_h); } -size_t piped_proc::read(unsigned char *buf, size_t len) +size_t piped_proc::read(unsigned char *buf, const size_t len) { if (!pipe_rd) return 0; @@ -97,7 +97,7 @@ size_t piped_proc::read(unsigned char *buf, size_t len) return read; } -size_t piped_proc::write(unsigned char *buf, size_t len) +size_t piped_proc::write(unsigned char *buf, const size_t len) { if (!pipe_wr) return 0; diff --git a/gl/buffer.cpp b/gl/buffer.cpp index 36c251e9..61bc07a0 100644 --- a/gl/buffer.cpp +++ b/gl/buffer.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "buffer.h" -GLenum gl::buffer::glenum_target(targets target) +GLenum gl::buffer::glenum_target(const targets target) { static GLenum mapping[13] = { @@ -22,7 +22,7 @@ GLenum gl::buffer::glenum_target(targets target) return mapping[target]; } -void gl::buffer::bind(targets target) +void gl::buffer::bind(const targets target) { if (binding_points[target] == *this) return; @@ -31,13 +31,13 @@ void gl::buffer::bind(targets target) binding_points[target] = *this; } -void gl::buffer::bind_base(targets target, GLuint index) +void gl::buffer::bind_base(const targets target, const GLuint index) { glBindBufferBase(glenum_target(target), index, *this); binding_points[target] = *this; } -void gl::buffer::unbind(targets target) +void gl::buffer::unbind(const targets target) { if( binding_points[ target ] == 0 ) { return; } @@ -61,19 +61,19 @@ gl::buffer::~buffer() glDeleteBuffers(1, *this); } -void gl::buffer::allocate(targets target, GLsizeiptr size, GLenum hint) +void gl::buffer::allocate(const targets target, const GLsizeiptr size, const GLenum hint) { bind(target); glBufferData(glenum_target(target), size, nullptr, hint); } -void gl::buffer::upload(targets target, const void *data, int offset, GLsizeiptr size) +void gl::buffer::upload(const targets target, const void *data, const int offset, const GLsizeiptr size) { bind(target); glBufferSubData(glenum_target(target), offset, size, data); } -void gl::buffer::download(targets target, void *data, int offset, GLsizeiptr size) +void gl::buffer::download(const targets target, void *data, const int offset, const GLsizeiptr size) { bind(target); if (GLAD_GL_VERSION_3_3) diff --git a/gl/cubemap.cpp b/gl/cubemap.cpp index ca0e6c08..5e215e74 100644 --- a/gl/cubemap.cpp +++ b/gl/cubemap.cpp @@ -15,7 +15,7 @@ gl::cubemap::~cubemap() glDeleteTextures(1, *this); } -void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, GLenum type) +void gl::cubemap::alloc(const GLint format, const int width, const int height, const GLenum components, const GLenum type) { glBindTexture(GL_TEXTURE_CUBE_MAP, *this); for (GLuint tgt = GL_TEXTURE_CUBE_MAP_POSITIVE_X; tgt <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; tgt++) @@ -29,7 +29,7 @@ void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, glBindTexture(GL_TEXTURE_CUBE_MAP, 0); } -void gl::cubemap::bind(int unit) +void gl::cubemap::bind(const int unit) { glActiveTexture(unit); glBindTexture(GL_TEXTURE_CUBE_MAP, *this); diff --git a/gl/framebuffer.cpp b/gl/framebuffer.cpp index 098d99b3..15b58b8b 100644 --- a/gl/framebuffer.cpp +++ b/gl/framebuffer.cpp @@ -14,36 +14,36 @@ gl::framebuffer::~framebuffer() glDeleteFramebuffers(1, *this); } -void gl::framebuffer::bind(GLuint id) +void gl::framebuffer::bind(const GLuint id) { glBindFramebuffer(GL_FRAMEBUFFER, id); } -void gl::framebuffer::attach(const opengl_texture &tex, GLenum location) +void gl::framebuffer::attach(const opengl_texture &tex, const GLenum location) { bind(); glFramebufferTexture2D(GL_FRAMEBUFFER, location, tex.target, tex.id, 0); } -void gl::framebuffer::attach(const opengl_texture &tex, GLenum location, GLint layer) +void gl::framebuffer::attach(const opengl_texture &tex, const GLenum location, const GLint layer) { bind(); glFramebufferTextureLayer(GL_FRAMEBUFFER, location, tex.id, 0, layer); } -void gl::framebuffer::attach(const cubemap &tex, int face, GLenum location) +void gl::framebuffer::attach(const cubemap &tex, const int face, const GLenum location) { bind(); glFramebufferTexture2D(GL_FRAMEBUFFER, location, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, *tex, 0); } -void gl::framebuffer::attach(const renderbuffer &rb, GLenum location) +void gl::framebuffer::attach(const renderbuffer &rb, const GLenum location) { bind(); glFramebufferRenderbuffer(GL_FRAMEBUFFER, location, GL_RENDERBUFFER, *rb); } -void gl::framebuffer::detach(GLenum location) +void gl::framebuffer::detach(const GLenum location) { bind(); glFramebufferRenderbuffer(GL_FRAMEBUFFER, location, GL_RENDERBUFFER, 0); @@ -62,7 +62,7 @@ bool gl::framebuffer::is_complete() return iscomplete; } -void gl::framebuffer::clear(GLbitfield mask) +void gl::framebuffer::clear(const GLbitfield mask) { bind(); if (mask & GL_DEPTH_BUFFER_BIT) @@ -70,17 +70,17 @@ void gl::framebuffer::clear(GLbitfield mask) glClear(mask); } -void gl::framebuffer::blit_to(framebuffer *other, int w, int h, GLbitfield mask, GLenum attachment) +void gl::framebuffer::blit_to(framebuffer *other, const int w, const int h, const GLbitfield mask, const GLenum attachment) { blit(this, other, 0, 0, w, h, mask, attachment); } -void gl::framebuffer::blit_from(framebuffer *other, int w, int h, GLbitfield mask, GLenum attachment) +void gl::framebuffer::blit_from(framebuffer *other, const int w, const int h, const GLbitfield mask, const GLenum attachment) { blit(other, this, 0, 0, w, h, mask, attachment); } -void gl::framebuffer::blit(framebuffer *src, framebuffer *dst, int sx, int sy, int w, int h, GLbitfield mask, GLenum attachment) +void gl::framebuffer::blit(framebuffer *src, framebuffer *dst, const int sx, const int sy, const int w, const int h, const GLbitfield mask, const GLenum attachment) { glBindFramebuffer(GL_READ_FRAMEBUFFER, src ? *src : 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst ? *dst : 0); @@ -108,7 +108,7 @@ void gl::framebuffer::blit(framebuffer *src, framebuffer *dst, int sx, int sy, i unbind(); } -void gl::framebuffer::setup_drawing(int attachments) +void gl::framebuffer::setup_drawing(const int attachments) { bind(); const GLenum a[8] = diff --git a/gl/pbo.cpp b/gl/pbo.cpp index fb18ebe6..da3906ac 100644 --- a/gl/pbo.cpp +++ b/gl/pbo.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "pbo.h" -void gl::pbo::request_read(int x, int y, int lx, int ly, int pixsize, GLenum format, GLenum type) +void gl::pbo::request_read(const int x, const int y, const int lx, const int ly, const int pixsize, const GLenum format, const GLenum type) { const int s = lx * ly * pixsize; if (s != size) @@ -18,7 +18,7 @@ void gl::pbo::request_read(int x, int y, int lx, int ly, int pixsize, GLenum for sync.emplace(); } -bool gl::pbo::read_data(int lx, int ly, void *data, int pixsize) +bool gl::pbo::read_data(const int lx, const int ly, void *data, const int pixsize) { is_busy(); @@ -51,13 +51,13 @@ bool gl::pbo::is_busy() return true; } -void* gl::pbo::map(GLuint mode, targets target) +void* gl::pbo::map(const GLuint mode, const targets target) { bind(target); return glMapBuffer(glenum_target(target), mode); } -void gl::pbo::unmap(targets target) +void gl::pbo::unmap(const targets target) { bind(target); glUnmapBuffer(glenum_target(target)); diff --git a/gl/query.cpp b/gl/query.cpp index 3f3b56af..4648cadf 100644 --- a/gl/query.cpp +++ b/gl/query.cpp @@ -2,7 +2,7 @@ #include "query.h" #include "utilities/Globals.h" -gl::query::query(targets target) +gl::query::query(const targets target) : target(target) { glGenQueries(1, *this); @@ -49,7 +49,7 @@ std::optional gl::query::result() return std::nullopt; } -GLenum gl::query::glenum_target(targets target) +GLenum gl::query::glenum_target(const targets target) { static GLenum mapping[6] = { diff --git a/gl/renderbuffer.cpp b/gl/renderbuffer.cpp index 4d896dab..2f1bbb9b 100644 --- a/gl/renderbuffer.cpp +++ b/gl/renderbuffer.cpp @@ -12,12 +12,12 @@ gl::renderbuffer::~renderbuffer() glDeleteRenderbuffers(1, *this); } -void gl::renderbuffer::bind(GLuint id) +void gl::renderbuffer::bind(const GLuint id) { glBindRenderbuffer(GL_RENDERBUFFER, id); } -void gl::renderbuffer::alloc(GLuint format, int width, int height, int samples) +void gl::renderbuffer::alloc(const GLuint format, const int width, const int height, const int samples) { bind(); if (samples == 1) diff --git a/gl/shader.cpp b/gl/shader.cpp index bf89a7f4..8389912a 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -407,7 +407,7 @@ gl::program::~program() glDeleteProgram(*this); } -void gl::program::bind(GLuint i) +void gl::program::bind(const GLuint i) { glUseProgram(i); } diff --git a/gl/ubo.cpp b/gl/ubo.cpp index 10288b01..30752f16 100644 --- a/gl/ubo.cpp +++ b/gl/ubo.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "ubo.h" -gl::ubo::ubo(size_t size, int idx, GLenum hint) +gl::ubo::ubo(const size_t size, const int idx, const GLenum hint) { allocate(UNIFORM_BUFFER, size, hint); index = idx; @@ -13,7 +13,7 @@ void gl::ubo::bind_uniform() bind_base(UNIFORM_BUFFER, index); } -void gl::ubo::update(const uint8_t *data, int offset, GLsizeiptr size) +void gl::ubo::update(const uint8_t *data, const int offset, const GLsizeiptr size) { upload(UNIFORM_BUFFER, data, offset, size); } diff --git a/gl/ubo.h b/gl/ubo.h index bce98b33..d7a081b5 100644 --- a/gl/ubo.h +++ b/gl/ubo.h @@ -27,7 +27,7 @@ namespace gl void bind_uniform(); void update(const uint8_t *data, int offset, GLsizeiptr size); - template void update(const T &data, size_t offset = 0) + template void update(const T &data, const size_t offset = 0) { update(reinterpret_cast(&data), offset, sizeof(data)); } diff --git a/gl/vao.cpp b/gl/vao.cpp index 54bb5fde..976d4b8b 100644 --- a/gl/vao.cpp +++ b/gl/vao.cpp @@ -20,7 +20,7 @@ gl::vao::~vao() glDeleteVertexArrays(1, *this); } -void gl::vao::setup_attrib(buffer &buffer, int attrib, int size, int type, int stride, int offset) +void gl::vao::setup_attrib(buffer &buffer, const int attrib, const int size, const int type, const int stride, const int offset) { if (use_vao) { bind(); diff --git a/imgui/ImGuizmo.cpp b/imgui/ImGuizmo.cpp index f7fe553f..d1e34487 100644 --- a/imgui/ImGuizmo.cpp +++ b/imgui/ImGuizmo.cpp @@ -54,28 +54,28 @@ namespace ImGuizmo static const float DEG2RAD = (ZPI / 180.f); constexpr float screenRotateSize = 0.06f; - static OPERATION operator&(OPERATION lhs, OPERATION rhs) + static OPERATION operator&(const OPERATION lhs, const OPERATION rhs) { return static_cast(static_cast(lhs) & static_cast(rhs)); } - static bool operator!=(OPERATION lhs, int rhs) + static bool operator!=(const OPERATION lhs, const int rhs) { return static_cast(lhs) != rhs; } - static bool operator==(OPERATION lhs, int rhs) + static bool operator==(const OPERATION lhs, const int rhs) { return static_cast(lhs) == rhs; } - static bool Intersects(OPERATION lhs, OPERATION rhs) + static bool Intersects(const OPERATION lhs, const OPERATION rhs) { return (lhs & rhs) != 0; } // True if lhs contains rhs - static bool Contains(OPERATION lhs, OPERATION rhs) + static bool Contains(const OPERATION lhs, const OPERATION rhs) { return (lhs & rhs) == rhs; } @@ -106,7 +106,7 @@ constexpr float screenRotateSize = 0.06f; r[15] = a[12] * b[3] + a[13] * b[7] + a[14] * b[11] + a[15] * b[15]; } - void Frustum(float left, float right, float bottom, float top, float znear, float zfar, float* m16) + void Frustum(const float left, const float right, const float bottom, const float top, const float znear, const float zfar, float* m16) { float temp, temp2, temp3, temp4; temp = 2.0f * znear; @@ -131,7 +131,7 @@ constexpr float screenRotateSize = 0.06f; m16[15] = 0.0; } - void Perspective(float fovyInDegrees, float aspectRatio, float znear, float zfar, float* m16) + void Perspective(const float fovyInDegrees, const float aspectRatio, const float znear, const float zfar, float* m16) { float ymax, xmax; ymax = znear * tanf(fovyInDegrees * DEG2RAD); @@ -202,7 +202,7 @@ constexpr float screenRotateSize = 0.06f; public: float x, y, z, w; - void Lerp(const vec_t& v, float t) + void Lerp(const vec_t& v, const float t) { x += (v.x - x) * t; y += (v.y - y) * t; @@ -210,13 +210,13 @@ constexpr float screenRotateSize = 0.06f; w += (v.w - w) * t; } - void Set(float v) { x = y = z = w = v; } - void Set(float _x, float _y, float _z = 0.f, float _w = 0.f) { x = _x; y = _y; z = _z; w = _w; } + void Set(const float v) { x = y = z = w = v; } + void Set(const float _x, const float _y, const float _z = 0.f, const float _w = 0.f) { x = _x; y = _y; z = _z; w = _w; } vec_t& operator -= (const vec_t& v) { x -= v.x; y -= v.y; z -= v.z; w -= v.w; return *this; } vec_t& operator += (const vec_t& v) { x += v.x; y += v.y; z += v.z; w += v.w; return *this; } vec_t& operator *= (const vec_t& v) { x *= v.x; y *= v.y; z *= v.z; w *= v.w; return *this; } - vec_t& operator *= (float v) { x *= v; y *= v; z *= v; w *= v; return *this; } + vec_t& operator *= (const float v) { x *= v; y *= v; z *= v; w *= v; return *this; } vec_t operator * (float f) const; vec_t operator - () const; @@ -270,14 +270,14 @@ constexpr float screenRotateSize = 0.06f; void TransformVector(const vec_t& v, const matrix_t& matrix) { (*this) = v; this->TransformVector(matrix); } void TransformPoint(const vec_t& v, const matrix_t& matrix) { (*this) = v; this->TransformPoint(matrix); } - float& operator [] (size_t index) { return ((float*)&x)[index]; } - const float& operator [] (size_t index) const { return ((float*)&x)[index]; } + float& operator [] (const size_t index) { return ((float*)&x)[index]; } + const float& operator [] (const size_t index) const { return ((float*)&x)[index]; } bool operator!=(const vec_t& other) const { return memcmp(this, &other, sizeof(vec_t)); } }; - vec_t makeVect(float _x, float _y, float _z = 0.f, float _w = 0.f) { vec_t res; res.x = _x; res.y = _y; res.z = _z; res.w = _w; return res; } - vec_t makeVect(ImVec2 v) { vec_t res; res.x = v.x; res.y = v.y; res.z = 0.f; res.w = 0.f; return res; } - vec_t vec_t::operator * (float f) const { return makeVect(x * f, y * f, z * f, w * f); } + vec_t makeVect(const float _x, const float _y, const float _z = 0.f, const float _w = 0.f) { vec_t res; res.x = _x; res.y = _y; res.z = _z; res.w = _w; return res; } + vec_t makeVect(const ImVec2 v) { vec_t res; res.x = v.x; res.y = v.y; res.z = 0.f; res.w = 0.f; return res; } + vec_t vec_t::operator * (const float f) const { return makeVect(x * f, y * f, z * f, w * f); } vec_t vec_t::operator - () const { return makeVect(-x, -y, -z, -w); } vec_t vec_t::operator - (const vec_t& v) const { return makeVect(x - v.x, y - v.y, z - v.z, w - v.w); } vec_t vec_t::operator + (const vec_t& v) const { return makeVect(x + v.x, y + v.y, z + v.z, w + v.w); } @@ -331,7 +331,7 @@ constexpr float screenRotateSize = 0.06f; operator float* () { return m16; } operator const float* () const { return m16; } - void Translation(float _x, float _y, float _z) { this->Translation(makeVect(_x, _y, _z)); } + void Translation(const float _x, const float _y, const float _z) { this->Translation(makeVect(_x, _y, _z)); } void Translation(const vec_t& vt) { @@ -341,7 +341,7 @@ constexpr float screenRotateSize = 0.06f; v.position.Set(vt.x, vt.y, vt.z, 1.f); } - void Scale(float _x, float _y, float _z) + void Scale(const float _x, const float _y, const float _z) { v.right.Set(_x, 0.f, 0.f, 0.f); v.up.Set(0.f, _y, 0.f, 0.f); @@ -466,7 +466,7 @@ constexpr float screenRotateSize = 0.06f; w = out.w; } - float matrix_t::Inverse(const matrix_t& srcMatrix, bool affine) + float matrix_t::Inverse(const matrix_t& srcMatrix, const bool affine) { float det = 0; @@ -562,7 +562,7 @@ constexpr float screenRotateSize = 0.06f; return det; } - void matrix_t::RotationAxis(const vec_t& axis, float angle) + void matrix_t::RotationAxis(const vec_t& axis, const float angle) { const float length2 = axis.LengthSq(); if (length2 < FLT_EPSILON) @@ -627,17 +627,17 @@ constexpr float screenRotateSize = 0.06f; MT_SCALE_XYZ }; - static bool IsTranslateType(int type) + static bool IsTranslateType(const int type) { return type >= MT_MOVE_X && type <= MT_MOVE_SCREEN; } - static bool IsRotateType(int type) + static bool IsRotateType(const int type) { return type >= MT_ROTATE_X && type <= MT_ROTATE_SCREEN; } - static bool IsScaleType(int type) + static bool IsScaleType(const int type) { return type >= MT_SCALE_X && type <= MT_SCALE_XYZ; } @@ -766,7 +766,7 @@ constexpr float screenRotateSize = 0.06f; static int GetRotateType(OPERATION op); static int GetScaleType(OPERATION op); - static ImVec2 worldToPos(const vec_t& worldPos, const matrix_t& mat, ImVec2 position = ImVec2(gContext.mX, gContext.mY), ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight)) + static ImVec2 worldToPos(const vec_t& worldPos, const matrix_t& mat, const ImVec2 position = ImVec2(gContext.mX, gContext.mY), const ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight)) { vec_t trans; trans.TransformPoint(worldPos, mat); @@ -780,7 +780,7 @@ constexpr float screenRotateSize = 0.06f; return ImVec2(trans.x, trans.y); } - static void ComputeCameraRay(vec_t& rayOrigin, vec_t& rayDir, ImVec2 position = ImVec2(gContext.mX, gContext.mY), ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight)) + static void ComputeCameraRay(vec_t& rayOrigin, vec_t& rayDir, const ImVec2 position = ImVec2(gContext.mX, gContext.mY), const ImVec2 size = ImVec2(gContext.mWidth, gContext.mHeight)) { const ImGuiIO & io = ImGui::GetIO(); @@ -885,12 +885,12 @@ constexpr float screenRotateSize = 0.06f; return plan.Dot3(point) + plan.w; } - static bool IsInContextRect(ImVec2 p) + static bool IsInContextRect(const ImVec2 p) { return IsWithin(p.x, gContext.mX, gContext.mXMax) && IsWithin(p.y, gContext.mY, gContext.mYMax); } - void SetRect(float x, float y, float width, float height) + void SetRect(const float x, const float y, const float width, const float height) { gContext.mX = x; gContext.mY = y; @@ -901,7 +901,7 @@ constexpr float screenRotateSize = 0.06f; gContext.mDisplayRatio = width / height; } - void SetOrthographic(bool isOrthographic) + void SetOrthographic(const bool isOrthographic) { gContext.mIsOrthographic = isOrthographic; } @@ -952,7 +952,7 @@ constexpr float screenRotateSize = 0.06f; (Intersects(gContext.mOperation, SCALE) && GetScaleType(gContext.mOperation) != MT_NONE) || IsUsing(); } - bool IsOver(OPERATION op) + bool IsOver(const OPERATION op) { if(IsUsing()) { @@ -973,7 +973,7 @@ constexpr float screenRotateSize = 0.06f; return false; } - void Enable(bool enable) + void Enable(const bool enable) { gContext.mbEnable = enable; if (!enable) @@ -983,7 +983,7 @@ constexpr float screenRotateSize = 0.06f; } } - static void ComputeContext(const float* view, const float* projection, float* matrix, MODE mode) + static void ComputeContext(const float* view, const float* projection, float* matrix, const MODE mode) { gContext.mMode = mode; gContext.mViewMat = *(matrix_t*)view; @@ -1038,7 +1038,7 @@ constexpr float screenRotateSize = 0.06f; ComputeCameraRay(gContext.mRayOrigin, gContext.mRayVector); } - static void ComputeColors(ImU32* colors, int type, OPERATION operation) + static void ComputeColors(ImU32* colors, const int type, const OPERATION operation) { if (gContext.mbEnable) { @@ -1081,7 +1081,7 @@ constexpr float screenRotateSize = 0.06f; } } - static void ComputeTripodAxisAndVisibility(int axisIndex, vec_t& dirAxis, vec_t& dirPlaneX, vec_t& dirPlaneY, bool& belowAxisLimit, bool& belowPlaneLimit) + static void ComputeTripodAxisAndVisibility(const int axisIndex, vec_t& dirAxis, vec_t& dirPlaneX, vec_t& dirPlaneY, bool& belowAxisLimit, bool& belowPlaneLimit) { dirAxis = directionUnary[axisIndex]; dirPlaneX = directionUnary[(axisIndex + 1) % 3]; @@ -1134,7 +1134,7 @@ constexpr float screenRotateSize = 0.06f; } } - static void ComputeSnap(float* value, float snap) + static void ComputeSnap(float* value, const float snap) { if (snap <= FLT_EPSILON) { @@ -1174,7 +1174,7 @@ constexpr float screenRotateSize = 0.06f; return angle; } - static void DrawRotationGizmo(OPERATION op, int type) + static void DrawRotationGizmo(const OPERATION op, const int type) { if(!Intersects(op, ROTATE)) { @@ -1271,7 +1271,7 @@ constexpr float screenRotateSize = 0.06f; } } - static void DrawScaleGizmo(OPERATION op, int type) + static void DrawScaleGizmo(const OPERATION op, const int type) { ImDrawList* drawList = gContext.mDrawList; @@ -1354,7 +1354,7 @@ constexpr float screenRotateSize = 0.06f; } - static void DrawTranslationGizmo(OPERATION op, int type) + static void DrawTranslationGizmo(const OPERATION op, const int type) { ImDrawList* drawList = gContext.mDrawList; if (!drawList) @@ -1714,7 +1714,7 @@ constexpr float screenRotateSize = 0.06f; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // - static int GetScaleType(OPERATION op) + static int GetScaleType(const OPERATION op) { const ImGuiIO & io = ImGui::GetIO(); int type = MT_NONE; @@ -1760,7 +1760,7 @@ constexpr float screenRotateSize = 0.06f; return type; } - static int GetRotateType(OPERATION op) + static int GetRotateType(const OPERATION op) { const ImGuiIO & io = ImGui::GetIO(); int type = MT_NONE; @@ -1814,7 +1814,7 @@ constexpr float screenRotateSize = 0.06f; return type; } - static int GetMoveType(OPERATION op, vec_t* gizmoHitProportion) + static int GetMoveType(const OPERATION op, vec_t* gizmoHitProportion) { if(!Intersects(op, TRANSLATE)) { @@ -2246,17 +2246,17 @@ constexpr float screenRotateSize = 0.06f; mat.v.position.Set(translation[0], translation[1], translation[2], 1.f); } - void SetID(int id) + void SetID(const int id) { gContext.mActualID = id; } - void AllowAxisFlip(bool value) + void AllowAxisFlip(const bool value) { gContext.mAllowAxisFlip = value; } - bool Manipulate(const float* view, const float* projection, OPERATION operation, MODE mode, float* matrix, float* deltaMatrix, const float* snap, const float* localBounds, const float* boundsSnap) + bool Manipulate(const float* view, const float* projection, const OPERATION operation, const MODE mode, float* matrix, float* deltaMatrix, const float* snap, const float* localBounds, const float* boundsSnap) { ComputeContext(view, projection, matrix, mode); @@ -2302,7 +2302,7 @@ constexpr float screenRotateSize = 0.06f; return manipulated; } - void SetGizmoSizeClipSpace(float value) + void SetGizmoSizeClipSpace(const float value) { gContext.mGizmoSizeClipSpace = value; } diff --git a/imgui/ImGuizmo.h b/imgui/ImGuizmo.h index bcc39053..6c38af23 100644 --- a/imgui/ImGuizmo.h +++ b/imgui/ImGuizmo.h @@ -181,7 +181,7 @@ namespace ImGuizmo SCALE = SCALE_X | SCALE_Y | SCALE_Z }; - inline OPERATION operator|(OPERATION lhs, OPERATION rhs) + inline OPERATION operator|(const OPERATION lhs, const OPERATION rhs) { return static_cast(static_cast(lhs) | static_cast(rhs)); } diff --git a/imgui/imgui.cpp b/imgui/imgui.cpp index fe2c3af3..eb855c21 100644 --- a/imgui/imgui.cpp +++ b/imgui/imgui.cpp @@ -1110,7 +1110,7 @@ ImGuiContext* GImGui = NULL; // If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file. // Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction. #ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS -static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); } +static void* MallocWrapper(const size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); } static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); } #else static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; } @@ -1168,7 +1168,7 @@ ImGuiStyle::ImGuiStyle() // To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you. // Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times. -void ImGuiStyle::ScaleAllSizes(float scale_factor) +void ImGuiStyle::ScaleAllSizes(const float scale_factor) { WindowPadding = ImFloor(WindowPadding * scale_factor); WindowRounding = ImFloor(WindowRounding * scale_factor); @@ -1256,7 +1256,7 @@ ImGuiIO::ImGuiIO() // Pass in translated ASCII characters for text input. // - with glfw you can get those from the callback set in glfwSetCharCallback() // - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message -void ImGuiIO::AddInputCharacter(unsigned int c) +void ImGuiIO::AddInputCharacter(const unsigned int c) { if (c > 0 && c < 0x10000) InputQueueCharacters.push_back((ImWchar)c); @@ -1345,7 +1345,7 @@ int ImStrnicmp(const char* str1, const char* str2, size_t count) return d; } -void ImStrncpy(char* dst, const char* src, size_t count) +void ImStrncpy(char* dst, const char* src, const size_t count) { if (count < 1) return; @@ -1375,7 +1375,7 @@ char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src) return (char*)memcpy(dst, (const void*)src, src_size); } -const char* ImStrchrRange(const char* str, const char* str_end, char c) +const char* ImStrchrRange(const char* str, const char* str_end, const char c) { const auto p = (const char*)memchr(str, (int)c, str_end - str); return p; @@ -1456,7 +1456,7 @@ void ImStrTrimBlanks(char* buf) #define vsnprintf _vsnprintf #endif -int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) +int ImFormatString(char* buf, const size_t buf_size, const char* fmt, ...) { va_list args; va_start(args, fmt); @@ -1474,7 +1474,7 @@ int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) return w; } -int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) +int ImFormatStringV(char* buf, const size_t buf_size, const char* fmt, va_list args) { #ifdef IMGUI_USE_STB_SPRINTF int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); @@ -1516,7 +1516,7 @@ static constexpr ImU32 GCrc32LookupTable[256] = // Known size hash // It is ok to call ImHashData on a string with known length but the ### operator won't be supported. // FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. -ImU32 ImHashData(const void* data_p, size_t data_size, ImU32 seed) +ImU32 ImHashData(const void* data_p, size_t data_size, const ImU32 seed) { ImU32 crc = ~seed; auto data = (const unsigned char*)data_p; @@ -1578,7 +1578,7 @@ FILE* ImFileOpen(const char* filename, const char* mode) // Load file content into memory // Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree() -void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size, int padding_bytes) +void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size, const int padding_bytes) { IM_ASSERT(filename && file_open_mode); if (out_file_size) @@ -1683,7 +1683,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* return 0; } -int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) +int ImTextStrFromUtf8(ImWchar* buf, const int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) { ImWchar* buf_out = buf; const ImWchar * buf_end = buf + buf_size; @@ -1718,7 +1718,7 @@ int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) } // Based on stb_to_utf8() from github.com/nothings/stb/ -static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c) +static inline int ImTextCharToUtf8(char* buf, const int buf_size, const unsigned int c) { if (c < 0x80) { @@ -1762,7 +1762,7 @@ int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end) return ImTextCharFromUtf8(&dummy, in_text, in_text_end); } -static inline int ImTextCountUtf8BytesFromChar(unsigned int c) +static inline int ImTextCountUtf8BytesFromChar(const unsigned int c) { if (c < 0x80) return 1; if (c < 0x800) return 2; @@ -1771,7 +1771,7 @@ static inline int ImTextCountUtf8BytesFromChar(unsigned int c) return 3; } -int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end) +int ImTextStrToUtf8(char* buf, const int buf_size, const ImWchar* in_text, const ImWchar* in_text_end) { char* buf_out = buf; const char* buf_end = buf + buf_size; @@ -1806,7 +1806,7 @@ int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_e // Note: The Convert functions are early design which are not consistent with other API. //----------------------------------------------------------------------------- -ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in) +ImVec4 ImGui::ColorConvertU32ToFloat4(const ImU32 in) { constexpr float s = 1.0f/255.0f; return ImVec4( @@ -1850,7 +1850,7 @@ void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& // Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593 // also http://en.wikipedia.org/wiki/HSL_and_HSV -void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b) +void ImGui::ColorConvertHSVtoRGB(float h, const float s, const float v, float& out_r, float& out_g, float& out_b) { if (s == 0.0f) { @@ -1877,7 +1877,7 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& } } -ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul) +ImU32 ImGui::GetColorU32(const ImGuiCol idx, const float alpha_mul) { const ImGuiStyle & style = GImGui->Style; ImVec4 c = style.Colors[idx]; @@ -1893,13 +1893,13 @@ ImU32 ImGui::GetColorU32(const ImVec4& col) return ColorConvertFloat4ToU32(c); } -const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx) +const ImVec4& ImGui::GetStyleColorVec4(const ImGuiCol idx) { const ImGuiStyle & style = GImGui->Style; return style.Colors[idx]; } -ImU32 ImGui::GetColorU32(ImU32 col) +ImU32 ImGui::GetColorU32(const ImU32 col) { const float style_alpha = GImGui->Style.Alpha; if (style_alpha >= 1.0f) @@ -1915,7 +1915,7 @@ ImU32 ImGui::GetColorU32(ImU32 col) //----------------------------------------------------------------------------- // std::lower_bound but without the bullshit -static ImGuiStorage::ImGuiStoragePair* LowerBound(ImVector& data, ImGuiID key) +static ImGuiStorage::ImGuiStoragePair* LowerBound(ImVector& data, const ImGuiID key) { ImGuiStorage::ImGuiStoragePair* first = data.Data; const ImGuiStorage::ImGuiStoragePair* last = data.Data + data.Size; @@ -1954,7 +1954,7 @@ void ImGuiStorage::BuildSortByKey() ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID); } -int ImGuiStorage::GetInt(ImGuiID key, int default_val) const +int ImGuiStorage::GetInt(const ImGuiID key, const int default_val) const { const ImGuiStoragePair * it = LowerBound(const_cast&>(Data), key); if (it == Data.end() || it->key != key) @@ -1962,12 +1962,12 @@ int ImGuiStorage::GetInt(ImGuiID key, int default_val) const return it->val_i; } -bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const +bool ImGuiStorage::GetBool(const ImGuiID key, const bool default_val) const { return GetInt(key, default_val ? 1 : 0) != 0; } -float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const +float ImGuiStorage::GetFloat(const ImGuiID key, const float default_val) const { const ImGuiStoragePair * it = LowerBound(const_cast&>(Data), key); if (it == Data.end() || it->key != key) @@ -1975,7 +1975,7 @@ float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const return it->val_f; } -void* ImGuiStorage::GetVoidPtr(ImGuiID key) const +void* ImGuiStorage::GetVoidPtr(const ImGuiID key) const { const ImGuiStoragePair * it = LowerBound(const_cast&>(Data), key); if (it == Data.end() || it->key != key) @@ -1984,7 +1984,7 @@ void* ImGuiStorage::GetVoidPtr(ImGuiID key) const } // References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. -int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val) +int* ImGuiStorage::GetIntRef(const ImGuiID key, const int default_val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) @@ -1992,12 +1992,12 @@ int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val) return &it->val_i; } -bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val) +bool* ImGuiStorage::GetBoolRef(const ImGuiID key, const bool default_val) { return (bool*)GetIntRef(key, default_val ? 1 : 0); } -float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) +float* ImGuiStorage::GetFloatRef(const ImGuiID key, const float default_val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) @@ -2005,7 +2005,7 @@ float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) return &it->val_f; } -void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) +void** ImGuiStorage::GetVoidPtrRef(const ImGuiID key, void* default_val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) @@ -2014,7 +2014,7 @@ void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) } // FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame) -void ImGuiStorage::SetInt(ImGuiID key, int val) +void ImGuiStorage::SetInt(const ImGuiID key, const int val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) @@ -2025,12 +2025,12 @@ void ImGuiStorage::SetInt(ImGuiID key, int val) it->val_i = val; } -void ImGuiStorage::SetBool(ImGuiID key, bool val) +void ImGuiStorage::SetBool(const ImGuiID key, const bool val) { SetInt(key, val ? 1 : 0); } -void ImGuiStorage::SetFloat(ImGuiID key, float val) +void ImGuiStorage::SetFloat(const ImGuiID key, const float val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) @@ -2041,7 +2041,7 @@ void ImGuiStorage::SetFloat(ImGuiID key, float val) it->val_f = val; } -void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val) +void ImGuiStorage::SetVoidPtr(const ImGuiID key, void* val) { ImGuiStoragePair* it = LowerBound(Data, key); if (it == Data.end() || it->key != key) @@ -2052,7 +2052,7 @@ void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val) it->val_p = val; } -void ImGuiStorage::SetAllInt(int v) +void ImGuiStorage::SetAllInt(const int v) { for (int i = 0; i < Data.Size; i++) Data[i].val_i = v; @@ -2077,7 +2077,7 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) } } -bool ImGuiTextFilter::Draw(const char* label, float width) +bool ImGuiTextFilter::Draw(const char* label, const float width) { if (width != 0.0f) ImGui::SetNextItemWidth(width); @@ -2087,7 +2087,7 @@ bool ImGuiTextFilter::Draw(const char* label, float width) return value_changed; } -void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector* out) const +void ImGuiTextFilter::ImGuiTextRange::split(const char separator, ImVector* out) const { out->resize(0); const char* wb = b; @@ -2203,7 +2203,7 @@ void ImGuiTextBuffer::appendf(const char* fmt, ...) } // Helper: Text buffer for logging/accumulating text -void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) +void ImGuiTextBuffer::appendfv(const char* fmt, const va_list args) { va_list args_copy; va_copy(args_copy, args); @@ -2238,7 +2238,7 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) // Helper to calculate coarse clipping of large list of evenly sized items. // NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern. // NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX -void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end) +void ImGui::CalcListClipping(const int items_count, const float items_height, int* out_items_display_start, int* out_items_display_end) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -2276,7 +2276,7 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items *out_items_display_end = end; } -static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height) +static void SetCursorPosYAndSetupDummyPrevLine(const float pos_y, const float line_height) { // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor. // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. @@ -2294,7 +2294,7 @@ static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height) // Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1 // Use case B: Begin() called from constructor with items_height>0 // FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style. -void ImGuiListClipper::Begin(int count, float items_height) +void ImGuiListClipper::Begin(const int count, const float items_height) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -2383,7 +2383,7 @@ const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) // Internal ImGui functions to render text // RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText() -void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash) +void ImGui::RenderText(const ImVec2 pos, const char* text, const char* text_end, const bool hide_text_after_hash) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -2409,7 +2409,7 @@ void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool } } -void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width) +void ImGui::RenderTextWrapped(const ImVec2 pos, const char* text, const char* text_end, const float wrap_width) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -2474,7 +2474,7 @@ void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, cons // Another overly complex function until we reorganize everything into a nice all-in-one helper. // This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display. // This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move. -void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known) +void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const float clip_max_x, const float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known) { const ImGuiContext & g = *GImGui; if (text_end_full == NULL) @@ -2552,7 +2552,7 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con } // Render a rectangle shaped with optional rounding and borders -void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding) +void ImGui::RenderFrame(const ImVec2 p_min, const ImVec2 p_max, const ImU32 fill_col, const bool border, const float rounding) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -2565,7 +2565,7 @@ void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, } } -void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) +void ImGui::RenderFrameBorder(const ImVec2 p_min, const ImVec2 p_max, const float rounding) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -2578,7 +2578,7 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) } // Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state -void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale) +void ImGui::RenderArrow(ImDrawList* draw_list, const ImVec2 pos, const ImU32 col, const ImGuiDir dir, const float scale) { const float h = draw_list->_Data->FontSize * 1.00f; float r = h * 0.40f * scale; @@ -2609,12 +2609,12 @@ void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir d draw_list->AddTriangleFilled(center + a, center + b, center + c, col); } -void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col) +void ImGui::RenderBullet(ImDrawList* draw_list, const ImVec2 pos, const ImU32 col) { draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8); } -void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz) +void ImGui::RenderCheckMark(ImVec2 pos, const ImU32 col, float sz) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -2632,7 +2632,7 @@ void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz) window->DrawList->PathStroke(col, false, thickness); } -void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags) +void ImGui::RenderNavHighlight(const ImRect& bb, const ImGuiID id, const ImGuiNavHighlightFlags flags) { const ImGuiContext & g = *GImGui; if (id != g.NavId) @@ -2756,7 +2756,7 @@ ImGuiID ImGuiWindow::GetID(const void* ptr) return id; } -ImGuiID ImGuiWindow::GetID(int n) +ImGuiID ImGuiWindow::GetID(const int n) { const ImGuiID seed = IDStack.back(); const ImGuiID id = ImHashData(&n, sizeof(n), seed); @@ -2776,7 +2776,7 @@ ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr) return ImHashData(&ptr, sizeof(void*), seed); } -ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n) +ImGuiID ImGuiWindow::GetIDNoKeepAlive(const int n) { const ImGuiID seed = IDStack.back(); return ImHashData(&n, sizeof(n), seed); @@ -2830,7 +2830,7 @@ void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window) window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0; } -void ImGui::SetNavID(ImGuiID id, int nav_layer) +void ImGui::SetNavID(const ImGuiID id, const int nav_layer) { ImGuiContext& g = *GImGui; IM_ASSERT(g.NavWindow); @@ -2839,7 +2839,7 @@ void ImGui::SetNavID(ImGuiID id, int nav_layer) g.NavWindow->NavLastIds[nav_layer] = id; } -void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel) +void ImGui::SetNavIDWithRectRel(const ImGuiID id, const int nav_layer, const ImRect& rect_rel) { ImGuiContext& g = *GImGui; SetNavID(id, nav_layer); @@ -2849,7 +2849,7 @@ void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_re g.NavDisableMouseHover = true; } -void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) +void ImGui::SetActiveID(const ImGuiID id, ImGuiWindow* window) { ImGuiContext& g = *GImGui; g.ActiveIdIsJustActivated = (g.ActiveId != id); @@ -2878,7 +2878,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) } // FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring. -void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) +void ImGui::SetFocusID(const ImGuiID id, ImGuiWindow* window) { ImGuiContext& g = *GImGui; IM_ASSERT(id != 0); @@ -2905,7 +2905,7 @@ void ImGui::ClearActiveID() SetActiveID(0, NULL); } -void ImGui::SetHoveredID(ImGuiID id) +void ImGui::SetHoveredID(const ImGuiID id) { ImGuiContext& g = *GImGui; g.HoveredId = id; @@ -2920,7 +2920,7 @@ ImGuiID ImGui::GetHoveredID() return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame; } -void ImGui::KeepAliveID(ImGuiID id) +void ImGui::KeepAliveID(const ImGuiID id) { ImGuiContext& g = *GImGui; if (g.ActiveId == id) @@ -2929,7 +2929,7 @@ void ImGui::KeepAliveID(ImGuiID id) g.ActiveIdPreviousFrameIsAlive = true; } -void ImGui::MarkItemEdited(ImGuiID id) +void ImGui::MarkItemEdited(const ImGuiID id) { // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit(). // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data. @@ -2942,7 +2942,7 @@ void ImGui::MarkItemEdited(ImGuiID id) g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited; } -static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags) +static inline bool IsWindowContentHoverable(ImGuiWindow* window, const ImGuiHoveredFlags flags) { // An active popup disable hovering on other windows (apart from its own children) // FIXME-OPT: This could be cached/stored within the window. @@ -2963,7 +2963,7 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFla } // Advance cursor given item size for layout. -void ImGui::ItemSize(const ImVec2& size, float text_offset_y) +void ImGui::ItemSize(const ImVec2& size, const float text_offset_y) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -2991,7 +2991,7 @@ void ImGui::ItemSize(const ImVec2& size, float text_offset_y) SameLine(); } -void ImGui::ItemSize(const ImRect& bb, float text_offset_y) +void ImGui::ItemSize(const ImRect& bb, const float text_offset_y) { ItemSize(bb.GetSize(), text_offset_y); } @@ -3056,7 +3056,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg) // This is roughly matching the behavior of internal-facing ItemHoverable() // - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered() // - this should work even for non-interactive items that have no ID, so we cannot use LastItemId -bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) +bool ImGui::IsItemHovered(const ImGuiHoveredFlags flags) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -3098,7 +3098,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) } // Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). -bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) +bool ImGui::ItemHoverable(const ImRect& bb, const ImGuiID id) { const ImGuiContext & g = *GImGui; if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) @@ -3131,7 +3131,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) return true; } -bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged) +bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID id, const bool clip_even_when_logged) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -3143,7 +3143,7 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged } // Process TAB/Shift+TAB. Be mindful that this function may _clear_ the ActiveID when tabbing out. -bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id) +bool ImGui::FocusableItemRegister(ImGuiWindow* window, const ImGuiID id) { ImGuiContext& g = *GImGui; @@ -3201,7 +3201,7 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) } // IM_ALLOC() == ImGui::MemAlloc() -void* ImGui::MemAlloc(size_t size) +void* ImGui::MemAlloc(const size_t size) { if (ImGuiContext* ctx = GImGui) ctx->IO.MetricsActiveAllocations++; @@ -3256,7 +3256,7 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx) // If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code // may see different structures than what imgui.cpp sees, which is problematic. // We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui. -bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx) +bool ImGui::DebugCheckVersionAndDataLayout(const char* version, const size_t sz_io, const size_t sz_style, const size_t sz_vec2, const size_t sz_vec4, const size_t sz_vert, const size_t sz_idx) { bool error = false; if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatched version string!"); } @@ -4137,7 +4137,7 @@ static void SetupDrawData(ImVector* draw_lists, ImDrawData* draw_da } // When using this function it is sane to ensure that float are perfectly rounded to integer values, to that e.g. (int)(max.x-min.x) in user's render produce correct result. -void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect) +void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, const bool intersect_with_current_clip_rect) { ImGuiWindow* window = GetCurrentWindow(); window->DrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); @@ -4293,7 +4293,7 @@ void ImGui::Render() // Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. // CalcTextSize("") should return ImVec2(0.0f, GImGui->FontSize) -ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) +ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, const bool hide_text_after_double_hash, const float wrap_width) { const ImGuiContext & g = *GImGui; @@ -4361,7 +4361,7 @@ static void FindHoveredWindow() // Test if mouse cursor is hovering given rectangle // NB- Rectangle is clipped by our current clip setting // NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) -bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip) +bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, const bool clip) { const ImGuiContext & g = *GImGui; @@ -4377,7 +4377,7 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c return true; } -int ImGui::GetKeyIndex(ImGuiKey imgui_key) +int ImGui::GetKeyIndex(const ImGuiKey imgui_key) { IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT); const ImGuiContext & g = *GImGui; @@ -4385,7 +4385,7 @@ int ImGui::GetKeyIndex(ImGuiKey imgui_key) } // Note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]! -bool ImGui::IsKeyDown(int user_key_index) +bool ImGui::IsKeyDown(const int user_key_index) { if (user_key_index < 0) return false; @@ -4394,7 +4394,7 @@ bool ImGui::IsKeyDown(int user_key_index) return g.IO.KeysDown[user_key_index]; } -int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate) +int ImGui::CalcTypematicPressedRepeatAmount(const float t, const float t_prev, const float repeat_delay, const float repeat_rate) { if (t == 0.0f) return 1; @@ -4404,7 +4404,7 @@ int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_ return (count > 0) ? count : 0; } -int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate) +int ImGui::GetKeyPressedAmount(const int key_index, const float repeat_delay, const float repeat_rate) { const ImGuiContext & g = *GImGui; if (key_index < 0) @@ -4414,7 +4414,7 @@ int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_r return CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, repeat_delay, repeat_rate); } -bool ImGui::IsKeyPressed(int user_key_index, bool repeat) +bool ImGui::IsKeyPressed(const int user_key_index, const bool repeat) { const ImGuiContext & g = *GImGui; if (user_key_index < 0) @@ -4428,7 +4428,7 @@ bool ImGui::IsKeyPressed(int user_key_index, bool repeat) return false; } -bool ImGui::IsKeyReleased(int user_key_index) +bool ImGui::IsKeyReleased(const int user_key_index) { const ImGuiContext & g = *GImGui; if (user_key_index < 0) return false; @@ -4436,7 +4436,7 @@ bool ImGui::IsKeyReleased(int user_key_index) return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index]; } -bool ImGui::IsMouseDown(int button) +bool ImGui::IsMouseDown(const int button) { const ImGuiContext & g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); @@ -4452,7 +4452,7 @@ bool ImGui::IsAnyMouseDown() return false; } -bool ImGui::IsMouseClicked(int button, bool repeat) +bool ImGui::IsMouseClicked(const int button, const bool repeat) { const ImGuiContext & g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); @@ -4471,14 +4471,14 @@ bool ImGui::IsMouseClicked(int button, bool repeat) return false; } -bool ImGui::IsMouseReleased(int button) +bool ImGui::IsMouseReleased(const int button) { const ImGuiContext & g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); return g.IO.MouseReleased[button]; } -bool ImGui::IsMouseDoubleClicked(int button) +bool ImGui::IsMouseDoubleClicked(const int button) { const ImGuiContext & g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); @@ -4486,7 +4486,7 @@ bool ImGui::IsMouseDoubleClicked(int button) } // [Internal] This doesn't test if the button is pressed -bool ImGui::IsMouseDragPastThreshold(int button, float lock_threshold) +bool ImGui::IsMouseDragPastThreshold(const int button, float lock_threshold) { const ImGuiContext & g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); @@ -4495,7 +4495,7 @@ bool ImGui::IsMouseDragPastThreshold(int button, float lock_threshold) return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold; } -bool ImGui::IsMouseDragging(int button, float lock_threshold) +bool ImGui::IsMouseDragging(const int button, const float lock_threshold) { const ImGuiContext & g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); @@ -4532,7 +4532,7 @@ bool ImGui::IsMousePosValid(const ImVec2* mouse_pos) // Return the delta from the initial clicking position while the mouse button is clicked or was just released. // This is locked and return 0.0f until the mouse moves past a distance threshold at least once. // NB: This is only valid if IsMousePosValid(). Back-ends in theory should always keep mouse position valid when dragging even outside the client window. -ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold) +ImVec2 ImGui::GetMouseDragDelta(const int button, float lock_threshold) { const ImGuiContext & g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); @@ -4545,7 +4545,7 @@ ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold) return ImVec2(0.0f, 0.0f); } -void ImGui::ResetMouseDragDelta(int button) +void ImGui::ResetMouseDragDelta(const int button) { ImGuiContext& g = *GImGui; IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); @@ -4558,17 +4558,17 @@ ImGuiMouseCursor ImGui::GetMouseCursor() return GImGui->MouseCursor; } -void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type) +void ImGui::SetMouseCursor(const ImGuiMouseCursor cursor_type) { GImGui->MouseCursor = cursor_type; } -void ImGui::CaptureKeyboardFromApp(bool capture) +void ImGui::CaptureKeyboardFromApp(const bool capture) { GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0; } -void ImGui::CaptureMouseFromApp(bool capture) +void ImGui::CaptureMouseFromApp(const bool capture) { GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0; } @@ -4621,7 +4621,7 @@ bool ImGui::IsItemFocused() return true; } -bool ImGui::IsItemClicked(int mouse_button) +bool ImGui::IsItemClicked(const int mouse_button) { return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_None); } @@ -4696,7 +4696,7 @@ static ImRect GetViewportRect() return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); } -static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags) +static bool ImGui::BeginChildEx(const char* name, const ImGuiID id, const ImVec2& size_arg, const bool border, ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* parent_window = g.CurrentWindow; @@ -4747,13 +4747,13 @@ static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size return ret; } -bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, const bool border, const ImGuiWindowFlags extra_flags) { ImGuiWindow* window = GetCurrentWindow(); return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags); } -bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) +bool ImGui::BeginChild(const ImGuiID id, const ImVec2& size_arg, const bool border, const ImGuiWindowFlags extra_flags) { IM_ASSERT(id != 0); return BeginChildEx(NULL, id, size_arg, border, extra_flags); @@ -4799,7 +4799,7 @@ void ImGui::EndChild() } // Helper to create a child window / scrolling region that looks like a normal widget frame. -bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) +bool ImGui::BeginChildFrame(const ImGuiID id, const ImVec2& size, const ImGuiWindowFlags extra_flags) { const ImGuiContext & g = *GImGui; const ImGuiStyle& style = g.Style; @@ -4819,7 +4819,7 @@ void ImGui::EndChildFrame() } // Save and compare stack sizes on Begin()/End() to detect usage errors -static void CheckStacksSize(ImGuiWindow* window, bool write) +static void CheckStacksSize(ImGuiWindow* window, const bool write) { // NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin) const ImGuiContext & g = *GImGui; @@ -4840,14 +4840,14 @@ static void CheckStacksSize(ImGuiWindow* window, bool write) IM_ASSERT(p_backup == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup)); } -static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) +static void SetWindowConditionAllowFlags(ImGuiWindow* window, const ImGuiCond flags, const bool enabled) { window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags); window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags); window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags); } -ImGuiWindow* ImGui::FindWindowByID(ImGuiID id) +ImGuiWindow* ImGui::FindWindowByID(const ImGuiID id) { const ImGuiContext & g = *GImGui; return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id); @@ -4859,7 +4859,7 @@ ImGuiWindow* ImGui::FindWindowByName(const char* name) return FindWindowByID(id); } -static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags) +static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, const ImGuiWindowFlags flags) { ImGuiContext& g = *GImGui; //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); @@ -4998,7 +4998,7 @@ ImVec2 ImGui::CalcWindowExpectedSize(ImGuiWindow* window) return size_final; } -static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags) +static ImGuiCol GetWindowBgColorIdxFromFlags(const ImGuiWindowFlags flags) { if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) return ImGuiCol_PopupBg; @@ -5036,7 +5036,7 @@ static const ImGuiResizeGripDef resize_grip_def[4] = { ImVec2(1,0), ImVec2(-1,+1), 9,12 }, // Upper right }; -static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness) +static ImRect GetResizeBorderRect(ImGuiWindow* window, const int border_n, const float perp_padding, const float thickness) { ImRect rect = window->Rect(); if (thickness == 0.0f) rect.Max -= ImVec2(1,1); @@ -5050,7 +5050,7 @@ static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_ // Handle resize for: Resize Grips, Borders, Gamepad // Return true when using auto-fit (double click on resize grip) -static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]) +static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, const int resize_grip_count, ImU32 resize_grip_col[4]) { ImGuiContext& g = *GImGui; const ImGuiWindowFlags flags = window->Flags; @@ -5216,7 +5216,8 @@ static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window) } } -void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size) +void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, const bool title_bar_is_highlight, const int resize_grip_count, const ImU32 resize_grip_col[4], + const float resize_grip_draw_size) { ImGuiContext& g = *GImGui; const ImGuiStyle & style = g.Style; @@ -5376,7 +5377,7 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl } } -void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window) +void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, const ImGuiWindowFlags flags, ImGuiWindow* parent_window) { window->ParentWindow = parent_window; window->RootWindow = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window; @@ -6003,7 +6004,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()/SetNextWindowBgAlpha() + Begin() instead. #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use, float bg_alpha_override, ImGuiWindowFlags flags) +bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use, const float bg_alpha_override, const ImGuiWindowFlags flags) { // Old API feature: we could pass the initial window size as a parameter. This was misleading because it only had an effect if the window didn't have data in the .ini file. if (size_first_use.x != 0.0f || size_first_use.y != 0.0f) @@ -6154,14 +6155,14 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind FocusWindow(NULL); } -void ImGui::SetNextItemWidth(float item_width) +void ImGui::SetNextItemWidth(const float item_width) { ImGuiContext& g = *GImGui; g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth; g.NextItemData.Width = item_width; } -void ImGui::PushItemWidth(float item_width) +void ImGui::PushItemWidth(const float item_width) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -6170,7 +6171,7 @@ void ImGui::PushItemWidth(float item_width) g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; } -void ImGui::PushMultiItemsWidths(int components, float w_full) +void ImGui::PushMultiItemsWidths(const int components, const float w_full) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -6215,7 +6216,7 @@ float ImGui::CalcItemWidth() // Those two functions CalcItemWidth vs CalcItemSize are awkwardly named because they are not fully symmetrical. // Note that only CalcItemWidth() is publicly exposed. // The 4.0f here may be changed to match CalcItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable) -ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h) +ImVec2 ImGui::CalcItemSize(ImVec2 size, const float default_w, const float default_h) { const ImGuiWindow * window = GImGui->CurrentWindow; @@ -6269,7 +6270,7 @@ void ImGui::PopFont() SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back()); } -void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled) +void ImGui::PushItemFlag(const ImGuiItemFlags option, const bool enabled) { ImGuiWindow* window = GetCurrentWindow(); if (enabled) @@ -6287,7 +6288,7 @@ void ImGui::PopItemFlag() } // FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system. -void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus) +void ImGui::PushAllowKeyboardFocus(const bool allow_keyboard_focus) { PushItemFlag(ImGuiItemFlags_NoTabStop, !allow_keyboard_focus); } @@ -6297,7 +6298,7 @@ void ImGui::PopAllowKeyboardFocus() PopItemFlag(); } -void ImGui::PushButtonRepeat(bool repeat) +void ImGui::PushButtonRepeat(const bool repeat) { PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); } @@ -6307,7 +6308,7 @@ void ImGui::PopButtonRepeat() PopItemFlag(); } -void ImGui::PushTextWrapPos(float wrap_pos_x) +void ImGui::PushTextWrapPos(const float wrap_pos_x) { ImGuiWindow* window = GetCurrentWindow(); window->DC.TextWrapPos = wrap_pos_x; @@ -6322,7 +6323,7 @@ void ImGui::PopTextWrapPos() } // FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32 -void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) +void ImGui::PushStyleColor(const ImGuiCol idx, const ImU32 col) { ImGuiContext& g = *GImGui; ImGuiColorMod backup; @@ -6332,7 +6333,7 @@ void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) g.Style.Colors[idx] = ColorConvertU32ToFloat4(col); } -void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col) +void ImGui::PushStyleColor(const ImGuiCol idx, const ImVec4& col) { ImGuiContext& g = *GImGui; ImGuiColorMod backup; @@ -6389,14 +6390,14 @@ static const ImGuiStyleVarInfo GStyleVarInfo[] = { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign }; -static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx) +static const ImGuiStyleVarInfo* GetStyleVarInfo(const ImGuiStyleVar idx) { IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT); IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT); return &GStyleVarInfo[idx]; } -void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) +void ImGui::PushStyleVar(const ImGuiStyleVar idx, const float val) { const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) @@ -6410,7 +6411,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!"); } -void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) +void ImGui::PushStyleVar(const ImGuiStyleVar idx, const ImVec2& val) { const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2) @@ -6440,7 +6441,7 @@ void ImGui::PopStyleVar(int count) } } -const char* ImGui::GetStyleColorName(ImGuiCol idx) +const char* ImGui::GetStyleColorName(const ImGuiCol idx) { // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1"; switch (idx) @@ -6511,7 +6512,7 @@ bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent) return false; } -bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) +bool ImGui::IsWindowHovered(const ImGuiHoveredFlags flags) { IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function const ImGuiContext & g = *GImGui; @@ -6552,7 +6553,7 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) return true; } -bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) +bool ImGui::IsWindowFocused(const ImGuiFocusedFlags flags) { const ImGuiContext & g = *GImGui; @@ -6600,7 +6601,7 @@ ImVec2 ImGui::GetWindowPos() return window->Pos; } -void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) +void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, const ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowPosAllowFlags & cond) == 0) @@ -6619,13 +6620,13 @@ void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) window->DC.CursorStartPos += offset; } -void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond) +void ImGui::SetWindowPos(const ImVec2& pos, const ImGuiCond cond) { ImGuiWindow* window = GetCurrentWindowRead(); SetWindowPos(window, pos, cond); } -void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond) +void ImGui::SetWindowPos(const char* name, const ImVec2& pos, const ImGuiCond cond) { if (ImGuiWindow* window = FindWindowByName(name)) SetWindowPos(window, pos, cond); @@ -6637,7 +6638,7 @@ ImVec2 ImGui::GetWindowSize() return window->Size; } -void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond) +void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, const ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowSizeAllowFlags & cond) == 0) @@ -6669,18 +6670,18 @@ void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con } } -void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond) +void ImGui::SetWindowSize(const ImVec2& size, const ImGuiCond cond) { SetWindowSize(GImGui->CurrentWindow, size, cond); } -void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond) +void ImGui::SetWindowSize(const char* name, const ImVec2& size, const ImGuiCond cond) { if (ImGuiWindow* window = FindWindowByName(name)) SetWindowSize(window, size, cond); } -void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond) +void ImGui::SetWindowCollapsed(ImGuiWindow* window, const bool collapsed, const ImGuiCond cond) { // Test condition (NB: bit 0 is always true) and clear flags for next time if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0) @@ -6691,7 +6692,7 @@ void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond co window->Collapsed = collapsed; } -void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond) +void ImGui::SetWindowCollapsed(const bool collapsed, const ImGuiCond cond) { SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond); } @@ -6708,7 +6709,7 @@ bool ImGui::IsWindowAppearing() return window->Appearing; } -void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond) +void ImGui::SetWindowCollapsed(const char* name, const bool collapsed, const ImGuiCond cond) { if (ImGuiWindow* window = FindWindowByName(name)) SetWindowCollapsed(window, collapsed, cond); @@ -6732,7 +6733,7 @@ void ImGui::SetWindowFocus(const char* name) } } -void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot) +void ImGui::SetNextWindowPos(const ImVec2& pos, const ImGuiCond cond, const ImVec2& pivot) { ImGuiContext& g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. @@ -6742,7 +6743,7 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always; } -void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond) +void ImGui::SetNextWindowSize(const ImVec2& size, const ImGuiCond cond) { ImGuiContext& g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. @@ -6751,7 +6752,7 @@ void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond) g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always; } -void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data) +void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, const ImGuiSizeCallback custom_callback, void* custom_callback_user_data) { ImGuiContext& g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint; @@ -6769,7 +6770,7 @@ void ImGui::SetNextWindowContentSize(const ImVec2& size) g.NextWindowData.ContentSizeVal = size; } -void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond) +void ImGui::SetNextWindowCollapsed(const bool collapsed, const ImGuiCond cond) { ImGuiContext& g = *GImGui; IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. @@ -6784,7 +6785,7 @@ void ImGui::SetNextWindowFocus() g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasFocus; } -void ImGui::SetNextWindowBgAlpha(float alpha) +void ImGui::SetNextWindowBgAlpha(const float alpha) { ImGuiContext& g = *GImGui; g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasBgAlpha; @@ -6883,7 +6884,7 @@ ImVec2 ImGui::GetFontTexUvWhitePixel() return GImGui->DrawListSharedData.TexUvWhitePixel; } -void ImGui::SetWindowFontScale(float scale) +void ImGui::SetWindowFontScale(const float scale) { ImGuiContext& g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); @@ -6918,14 +6919,14 @@ void ImGui::SetCursorPos(const ImVec2& local_pos) window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); } -void ImGui::SetCursorPosX(float x) +void ImGui::SetCursorPosX(const float x) { ImGuiWindow* window = GetCurrentWindow(); window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x; window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x); } -void ImGui::SetCursorPosY(float y) +void ImGui::SetCursorPosY(const float y) { ImGuiWindow* window = GetCurrentWindow(); window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y; @@ -6951,13 +6952,13 @@ void ImGui::SetCursorScreenPos(const ImVec2& pos) window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); } -void ImGui::ActivateItem(ImGuiID id) +void ImGui::ActivateItem(const ImGuiID id) { ImGuiContext& g = *GImGui; g.NavNextActivateId = id; } -void ImGui::SetKeyboardFocusHere(int offset) +void ImGui::SetKeyboardFocusHere(const int offset) { IM_ASSERT(offset >= -1); // -1 is allowed but not below ImGuiContext& g = *GImGui; @@ -7014,14 +7015,14 @@ void ImGui::PushID(const void* ptr_id) window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id)); } -void ImGui::PushID(int int_id) +void ImGui::PushID(const int int_id) { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.push_back(window->GetIDNoKeepAlive(int_id)); } // Push a given id value ignoring the ID stack as a seed. -void ImGui::PushOverrideID(ImGuiID id) +void ImGui::PushOverrideID(const ImGuiID id) { ImGuiWindow* window = GImGui->CurrentWindow; window->IDStack.push_back(id); @@ -7148,7 +7149,7 @@ void ImGui::EndGroup() // offset_from_start_x != 0 : align to specified x position (relative to window/group left) // spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0 // spacing_w >= 0 : enforce spacing amount -void ImGui::SameLine(float offset_from_start_x, float spacing_w) +void ImGui::SameLine(const float offset_from_start_x, float spacing_w) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -7171,7 +7172,7 @@ void ImGui::SameLine(float offset_from_start_x, float spacing_w) window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset; } -void ImGui::Indent(float indent_w) +void ImGui::Indent(const float indent_w) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); @@ -7179,7 +7180,7 @@ void ImGui::Indent(float indent_w) window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; } -void ImGui::Unindent(float indent_w) +void ImGui::Unindent(const float indent_w) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); @@ -7192,7 +7193,7 @@ void ImGui::Unindent(float indent_w) // [SECTION] SCROLLING //----------------------------------------------------------------------------- -static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges) +static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, const bool snap_on_edges) { const ImGuiContext & g = *GImGui; ImVec2 scroll = window->Scroll; @@ -7282,34 +7283,34 @@ float ImGui::GetScrollMaxY() return window->ScrollMax.y; } -void ImGui::SetScrollX(float scroll_x) +void ImGui::SetScrollX(const float scroll_x) { ImGuiWindow* window = GetCurrentWindow(); window->ScrollTarget.x = scroll_x; window->ScrollTargetCenterRatio.x = 0.0f; } -void ImGui::SetScrollY(float scroll_y) +void ImGui::SetScrollY(const float scroll_y) { ImGuiWindow* window = GetCurrentWindow(); window->ScrollTarget.y = scroll_y; window->ScrollTargetCenterRatio.y = 0.0f; } -void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x) +void ImGui::SetScrollX(ImGuiWindow* window, const float new_scroll_x) { window->ScrollTarget.x = new_scroll_x; window->ScrollTargetCenterRatio.x = 0.0f; } -void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y) +void ImGui::SetScrollY(ImGuiWindow* window, const float new_scroll_y) { window->ScrollTarget.y = new_scroll_y; window->ScrollTargetCenterRatio.y = 0.0f; } -void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio) +void ImGui::SetScrollFromPosX(ImGuiWindow* window, const float local_x, const float center_x_ratio) { // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f); @@ -7317,7 +7318,7 @@ void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x window->ScrollTargetCenterRatio.x = center_x_ratio; } -void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio) +void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, const float center_y_ratio) { // We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); @@ -7327,20 +7328,20 @@ void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y window->ScrollTargetCenterRatio.y = center_y_ratio; } -void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio) +void ImGui::SetScrollFromPosX(const float local_x, const float center_x_ratio) { const ImGuiContext & g = *GImGui; SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio); } -void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio) +void ImGui::SetScrollFromPosY(const float local_y, const float center_y_ratio) { const ImGuiContext & g = *GImGui; SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio); } // center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item. -void ImGui::SetScrollHereX(float center_x_ratio) +void ImGui::SetScrollHereX(const float center_x_ratio) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -7351,7 +7352,7 @@ void ImGui::SetScrollHereX(float center_x_ratio) } // center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. -void ImGui::SetScrollHereY(float center_y_ratio) +void ImGui::SetScrollHereY(const float center_y_ratio) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -7386,7 +7387,7 @@ void ImGui::BeginTooltip() } // Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first. -void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip) +void ImGui::BeginTooltipEx(const ImGuiWindowFlags extra_flags, const bool override_previous_tooltip) { ImGuiContext& g = *GImGui; char window_name[16]; @@ -7410,7 +7411,7 @@ void ImGui::EndTooltip() End(); } -void ImGui::SetTooltipV(const char* fmt, va_list args) +void ImGui::SetTooltipV(const char* fmt, const va_list args) { const ImGuiContext & g = *GImGui; if (g.DragDropWithinSourceOrTarget) @@ -7433,7 +7434,7 @@ void ImGui::SetTooltip(const char* fmt, ...) // [SECTION] POPUPS //----------------------------------------------------------------------------- -bool ImGui::IsPopupOpen(ImGuiID id) +bool ImGui::IsPopupOpen(const ImGuiID id) { ImGuiContext& g = *GImGui; return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id; @@ -7465,7 +7466,7 @@ void ImGui::OpenPopup(const char* str_id) // Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. // Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). // One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL) -void ImGui::OpenPopupEx(ImGuiID id) +void ImGui::OpenPopupEx(const ImGuiID id) { ImGuiContext& g = *GImGui; ImGuiWindow* parent_window = g.CurrentWindow; @@ -7507,7 +7508,7 @@ void ImGui::OpenPopupEx(ImGuiID id) } } -bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button) +bool ImGui::OpenPopupOnItemClick(const char* str_id, const int mouse_button) { ImGuiWindow* window = GImGui->CurrentWindow; if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) @@ -7520,7 +7521,7 @@ bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button) return false; } -void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup) +void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, const bool restore_focus_to_window_under_popup) { ImGuiContext& g = *GImGui; if (g.OpenPopupStack.empty()) @@ -7558,7 +7559,7 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to } } -void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup) +void ImGui::ClosePopupToLevel(const int remaining, const bool restore_focus_to_window_under_popup) { ImGuiContext& g = *GImGui; IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size); @@ -7613,7 +7614,7 @@ void ImGui::CloseCurrentPopup() window->DC.NavHideHighlightOneFrame = true; } -bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags) +bool ImGui::BeginPopupEx(const ImGuiID id, const ImGuiWindowFlags extra_flags) { ImGuiContext& g = *GImGui; if (!IsPopupOpen(id)) @@ -7692,7 +7693,7 @@ void ImGui::EndPopup() // This is a helper to handle the simplest case of associating one named popup to one given widget. // You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters). // You can pass a NULL str_id to use the identifier of the last item. -bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button) +bool ImGui::BeginPopupContextItem(const char* str_id, const int mouse_button) { ImGuiWindow* window = GImGui->CurrentWindow; if (window->SkipItems) @@ -7704,7 +7705,7 @@ bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button) return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } -bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool also_over_items) +bool ImGui::BeginPopupContextWindow(const char* str_id, const int mouse_button, const bool also_over_items) { if (!str_id) str_id = "window_context"; @@ -7715,7 +7716,7 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool a return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } -bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) +bool ImGui::BeginPopupContextVoid(const char* str_id, const int mouse_button) { if (!str_id) str_id = "void_context"; @@ -7727,7 +7728,7 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) // r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.) // r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it. -ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy) +ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, const ImGuiPopupPositionPolicy policy) { const ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size); //GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255)); @@ -7837,14 +7838,14 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window) // [SECTION] KEYBOARD/GAMEPAD NAVIGATION //----------------------------------------------------------------------------- -ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy) +ImGuiDir ImGetDirQuadrantFromDelta(const float dx, const float dy) { if (ImFabs(dx) > ImFabs(dy)) return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left; return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up; } -static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1) +static float inline NavScoreItemDistInterval(const float a0, const float a1, const float b0, const float b1) { if (a1 < b0) return a1 - b0; @@ -7853,7 +7854,7 @@ static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float return 0.0f; } -static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect) +static void inline NavClampRectToVisibleAreaForMoveDir(const ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect) { if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) { @@ -8083,7 +8084,7 @@ void ImGui::NavMoveRequestCancel() NavUpdateAnyRequestFlag(); } -void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags) +void ImGui::NavMoveRequestForward(const ImGuiDir move_dir, const ImGuiDir clip_dir, const ImRect& bb_rel, const ImGuiNavMoveFlags move_flags) { ImGuiContext& g = *GImGui; IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_None); @@ -8095,7 +8096,7 @@ void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const Im g.NavWindow->NavRectRel[g.NavLayer] = bb_rel; } -void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags) +void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, const ImGuiNavMoveFlags move_flags) { const ImGuiContext & g = *GImGui; if (g.NavWindow != window || !NavMoveRequestButNoResultYet() || g.NavMoveRequestForward != ImGuiNavForward_None || g.NavLayer != 0) @@ -8148,7 +8149,7 @@ static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window) return window->NavLastChildNavWindow ? window->NavLastChildNavWindow : window; } -static void NavRestoreLayer(ImGuiNavLayer layer) +static void NavRestoreLayer(const ImGuiNavLayer layer) { ImGuiContext& g = *GImGui; g.NavLayer = layer; @@ -8169,7 +8170,7 @@ static inline void ImGui::NavUpdateAnyRequestFlag() } // This needs to be called before we submit any widget (aka in or before Begin) -void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit) +void ImGui::NavInitWindow(ImGuiWindow* window, const bool force_reinit) { ImGuiContext& g = *GImGui; IM_ASSERT(window == g.NavWindow); @@ -8212,7 +8213,7 @@ static ImVec2 ImGui::NavCalcPreferredRefPos() } } -float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode) +float ImGui::GetNavInputAmount(const ImGuiNavInput n, const ImGuiInputReadMode mode) { const ImGuiContext & g = *GImGui; if (mode == ImGuiInputReadMode_Down) @@ -8234,7 +8235,7 @@ float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode) return 0.0f; } -ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor) +ImVec2 ImGui::GetNavInputAmount2d(const ImGuiNavDirSourceFlags dir_sources, const ImGuiInputReadMode mode, const float slow_factor, const float fast_factor) { ImVec2 delta(0.0f, 0.0f); if (dir_sources & ImGuiNavDirSourceFlags_Keyboard) @@ -8590,7 +8591,7 @@ static void ImGui::NavUpdateMoveResult() } // Handle PageUp/PageDown/Home/End keys -static float ImGui::NavUpdatePageUpPageDown(int allowed_dir_flags) +static float ImGui::NavUpdatePageUpPageDown(const int allowed_dir_flags) { ImGuiContext& g = *GImGui; if (g.NavMoveDir != ImGuiDir_None || g.NavWindow == NULL) @@ -8670,7 +8671,7 @@ static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N) return -1; } -static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N) +static ImGuiWindow* FindWindowNavFocusable(const int i_start, const int i_stop, const int dir) // FIXME-OPT O(N) { ImGuiContext& g = *GImGui; for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir) @@ -8679,7 +8680,7 @@ static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // return NULL; } -static void NavUpdateWindowingHighlightWindow(int focus_change_dir) +static void NavUpdateWindowingHighlightWindow(const int focus_change_dir) { ImGuiContext& g = *GImGui; IM_ASSERT(g.NavWindowingTarget); @@ -8899,7 +8900,7 @@ void ImGui::ClearDragDrop() // Call when current ID is active. // When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource() -bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) +bool ImGui::BeginDragDropSource(const ImGuiDragDropFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -9013,7 +9014,7 @@ void ImGui::EndDragDropSource() } // Use 'cond' to choose to submit payload on drag start or every frame -bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond) +bool ImGui::SetDragDropPayload(const char* type, const void* data, const size_t data_size, ImGuiCond cond) { ImGuiContext& g = *GImGui; ImGuiPayload& payload = g.DragDropPayload; @@ -9056,7 +9057,7 @@ bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_s return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1); } -bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id) +bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, const ImGuiID id) { ImGuiContext& g = *GImGui; if (!g.DragDropActive) @@ -9249,7 +9250,7 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* } // Start logging/capturing text output -void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) +void ImGui::LogBegin(const ImGuiLogType type, const int auto_open_depth) { ImGuiContext& g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -9264,7 +9265,7 @@ void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) g.LogLineFirstItem = true; } -void ImGui::LogToTTY(int auto_open_depth) +void ImGui::LogToTTY(const int auto_open_depth) { ImGuiContext& g = *GImGui; if (g.LogEnabled) @@ -9274,7 +9275,7 @@ void ImGui::LogToTTY(int auto_open_depth) } // Start logging/capturing text output to given file -void ImGui::LogToFile(int auto_open_depth, const char* filename) +void ImGui::LogToFile(const int auto_open_depth, const char* filename) { ImGuiContext& g = *GImGui; if (g.LogEnabled) @@ -9299,7 +9300,7 @@ void ImGui::LogToFile(int auto_open_depth, const char* filename) } // Start logging/capturing text output to clipboard -void ImGui::LogToClipboard(int auto_open_depth) +void ImGui::LogToClipboard(const int auto_open_depth) { const ImGuiContext & g = *GImGui; if (g.LogEnabled) @@ -9307,7 +9308,7 @@ void ImGui::LogToClipboard(int auto_open_depth) LogBegin(ImGuiLogType_Clipboard, auto_open_depth); } -void ImGui::LogToBuffer(int auto_open_depth) +void ImGui::LogToBuffer(const int auto_open_depth) { const ImGuiContext & g = *GImGui; if (g.LogEnabled) @@ -9407,7 +9408,7 @@ ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name) return settings; } -ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id) +ImGuiWindowSettings* ImGui::FindWindowSettings(const ImGuiID id) { ImGuiContext& g = *GImGui; for (int i = 0; i != g.SettingsWindows.Size; i++) @@ -9755,7 +9756,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text) #pragma comment(lib, "imm32") #endif -static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) +static void ImeSetInputScreenPosFn_DefaultImpl(const int x, const int y) { // Notify OS Input Method Editor of text input position const ImGuiIO & io = ImGui::GetIO(); @@ -9816,7 +9817,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) // - NodeTabBar struct Funcs { - static ImRect GetWindowRect(ImGuiWindow* window, int rect_type) + static ImRect GetWindowRect(ImGuiWindow* window, const int rect_type) { if (rect_type == WRT_OuterRect) { return window->Rect(); } else diff --git a/imgui/imgui.h b/imgui/imgui.h index 2fc8c7cf..3eb3563f 100644 --- a/imgui/imgui.h +++ b/imgui/imgui.h @@ -180,9 +180,9 @@ struct ImVec2 { float x, y; ImVec2() { x = y = 0.0f; } - ImVec2(float _x, float _y) { x = _x; y = _y; } - float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. - float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. + ImVec2(const float _x, const float _y) { x = _x; y = _y; } + float operator[] (const size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. + float& operator[] (const size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. #ifdef IM_VEC2_CLASS_EXTRA IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2. #endif @@ -193,7 +193,7 @@ struct ImVec4 { float x, y, z, w; ImVec4() { x = y = z = w = 0.0f; } - ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } + ImVec4(const float _x, const float _y, const float _z, const float _w) { x = _x; y = _y; z = _z; w = _w; } #ifdef IM_VEC4_CLASS_EXTRA IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4. #endif @@ -1265,11 +1265,11 @@ struct ImVector const int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; } - int _grow_capacity(int sz) const { + int _grow_capacity(const int sz) const { const int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > sz ? new_capacity : sz; } - void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; } - void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; } - void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; } + void resize(const int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; } + void resize(const int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; } + void reserve(const int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; } // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden. void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; } @@ -1567,13 +1567,13 @@ namespace ImGui // OBSOLETED in 1.72 (from July 2019) static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); } // OBSOLETED in 1.71 (from June 2019) - static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); } + static inline void SetNextTreeNodeOpen(const bool open, const ImGuiCond cond = 0) { SetNextItemOpen(open, cond); } // OBSOLETED in 1.70 (from May 2019) static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; } // OBSOLETED in 1.69 (from Mar 2019) static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); } // OBSOLETED in 1.66 (from Sep 2018) - static inline void SetScrollHere(float center_ratio=0.5f){ SetScrollHereY(center_ratio); } + static inline void SetScrollHere(const float center_ratio=0.5f){ SetScrollHereY(center_ratio); } // OBSOLETED in 1.63 (between Aug 2018 and Sept 2018) static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); } // OBSOLETED in 1.61 (between Apr 2018 and Aug 2018) @@ -1584,18 +1584,18 @@ namespace ImGui // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018) static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } - static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; } + static inline ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, const bool on_edge = false, const float outward = 0.f) { IM_UNUSED(on_edge); IM_UNUSED(outward); IM_ASSERT(0); return pos; } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017) static inline void ShowTestWindow() { return ShowDemoWindow(); } static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); } static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); } - static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } + static inline void SetNextWindowContentWidth(const float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); } // OBSOLETED in 1.52 (between Aug 2017 and Oct 2017) IMGUI_API bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // Use SetNextWindowSize(size, ImGuiCond_FirstUseEver) + SetNextWindowBgAlpha() instead. static inline bool IsRootWindowOrAnyChildHovered() { return IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); } static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); } - static inline void SetNextWindowPosCenter(ImGuiCond c=0) { + static inline void SetNextWindowPosCenter(const ImGuiCond c=0) { const ImGuiIO & io = GetIO(); SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), c, ImVec2(0.5f, 0.5f)); } } typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent @@ -1650,13 +1650,13 @@ struct ImGuiTextBuffer IMGUI_API static char EmptyString[1]; ImGuiTextBuffer() { } - char operator[](int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; } + char operator[](const int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; } const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; } const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator int size() const { return Buf.Size ? Buf.Size - 1 : 0; } bool empty() { return Buf.Size <= 1; } void clear() { Buf.clear(); } - void reserve(int capacity) { Buf.reserve(capacity); } + void reserve(const int capacity) { Buf.reserve(capacity); } const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; } IMGUI_API void append(const char* str, const char* str_end = NULL); IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2); @@ -1678,9 +1678,9 @@ struct ImGuiStorage { ImGuiID key; union { int val_i; float val_f; void* val_p; }; - ImGuiStoragePair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } - ImGuiStoragePair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } - ImGuiStoragePair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } + ImGuiStoragePair(const ImGuiID _key, const int _val_i) { key = _key; val_i = _val_i; } + ImGuiStoragePair(const ImGuiID _key, const float _val_f) { key = _key; val_f = _val_f; } + ImGuiStoragePair(const ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } }; ImVector Data; @@ -1736,7 +1736,7 @@ struct ImGuiListClipper // items_count: Use -1 to ignore (you can call Begin later). Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step). // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). // If you don't specify an items_height, you NEED to call Step(). If you specify items_height you may call the old Begin()/End() api directly, but prefer calling Step(). - ImGuiListClipper(int items_count = -1, float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want). + ImGuiListClipper(const int items_count = -1, const float items_height = -1.0f) { Begin(items_count, items_height); } // NB: Begin() initialize every fields (as we allow user to call Begin/End multiple times on a same instance if they want). ~ImGuiListClipper() { IM_ASSERT(ItemsCount == -1); } // Assert if user forgot to call End() or Step() until false. IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items. @@ -1772,18 +1772,18 @@ struct ImColor ImVec4 Value; ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; } - ImColor(int r, int g, int b, int a = 255) { + ImColor(const int r, const int g, const int b, const int a = 255) { constexpr float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; } - ImColor(ImU32 rgba) { + ImColor(const ImU32 rgba) { constexpr float sc = 1.0f/255.0f; Value.x = (float)((rgba>>IM_COL32_R_SHIFT)&0xFF) * sc; Value.y = (float)((rgba>>IM_COL32_G_SHIFT)&0xFF) * sc; Value.z = (float)((rgba>>IM_COL32_B_SHIFT)&0xFF) * sc; Value.w = (float)((rgba>>IM_COL32_A_SHIFT)&0xFF) * sc; } - ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; } + ImColor(const float r, const float g, const float b, const float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; } ImColor(const ImVec4& col) { Value = col; } operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); } operator ImVec4() const { return Value; } // FIXME-OBSOLETE: May need to obsolete/cleanup those helpers. - void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; } - static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); } + void SetHSV(const float h, const float s, const float v, const float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; } + static ImColor HSV(const float h, const float s, const float v, const float a = 1.0f) { float r,g,b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r,g,b,a); } }; //----------------------------------------------------------------------------- @@ -1962,8 +1962,8 @@ struct ImDrawList void PathClear() { _Path.Size = 0; } void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); } void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size-1], &pos, 8) != 0) _Path.push_back(pos); } - void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order. - void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; } + void PathFillConvex(const ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order. + void PathStroke(const ImU32 col, const bool closed, const float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness); _Path.Size = 0; } IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 10); IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0); @@ -1977,9 +1977,9 @@ struct ImDrawList // Advanced: Channels // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives) // - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end) - void ChannelsSplit(int count) { _Splitter.Split(this, count); } + void ChannelsSplit(const int count) { _Splitter.Split(this, count); } void ChannelsMerge() { _Splitter.Merge(this); } - void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); } + void ChannelsSetCurrent(const int n) { _Splitter.SetCurrentChannel(this, n); } // Internal helpers // NB: all primitives needs to be reserved via PrimReserve() beforehand! @@ -1989,9 +1989,9 @@ struct ImDrawList IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles) IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col); IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col); - void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; } - void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; } - void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } + void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, const ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; } + void PrimWriteIdx(const ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; } + void PrimVtx(const ImVec2& pos, const ImVec2& uv, const ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } IMGUI_API void UpdateClipRect(); IMGUI_API void UpdateTextureID(); }; @@ -2066,13 +2066,13 @@ struct ImFontGlyphRangesBuilder ImFontGlyphRangesBuilder() { Clear(); } void Clear() { constexpr int size_in_bytes = 0x10000 / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); } - bool GetBit(int n) const { + bool GetBit(const int n) const { const int off = (n >> 5); const ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array - void SetBit(int n) { + void SetBit(const int n) { const int off = (n >> 5); const ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array - void AddChar(ImWchar c) { SetBit(c); } // Add character + void AddChar(const ImWchar c) { SetBit(c); } // Add character IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added) IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext IMGUI_API void BuildRanges(ImVector* out_ranges); // Output new ranges @@ -2139,7 +2139,7 @@ struct ImFontAtlas IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel bool IsBuilt() { return Fonts.Size > 0 && (TexPixelsAlpha8 != NULL || TexPixelsRGBA32 != NULL); } - void SetTexID(ImTextureID id) { TexID = id; } + void SetTexID(const ImTextureID id) { TexID = id; } //------------------------------------------- // Glyph Ranges @@ -2168,7 +2168,7 @@ struct ImFontAtlas // Read misc/fonts/README.txt for more details about using colorful icons. IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x10000. Id >= 0x80000000 are reserved for ImGui and ImDrawList IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x10000 to register a rectangle to map into a specific font. - const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; } + const ImFontAtlasCustomRect*GetCustomRectByIndex(const int index) const { if (index < 0) return NULL; return &CustomRects[index]; } // [Internal] IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max); @@ -2234,7 +2234,7 @@ struct ImFont IMGUI_API ~ImFont(); IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const; IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const; - float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; } + float GetCharAdvance(const ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; } bool IsLoaded() const { return ContainerAtlas != NULL; } const char* GetDebugName() const { return ConfigData ? ConfigData->Name : ""; } diff --git a/imgui/imgui_demo.cpp b/imgui/imgui_demo.cpp index effd6416..dfe51033 100644 --- a/imgui/imgui_demo.cpp +++ b/imgui/imgui_demo.cpp @@ -827,7 +827,7 @@ static void ShowDemoWindowWidgets() ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items)); // Simplified one-liner Combo() using an accessor function - struct FuncHolder { static bool ItemGetter(void* data, int idx, const char** out_str) { *out_str = ((const char**)data)[idx]; return true; } }; + struct FuncHolder { static bool ItemGetter(void* data, const int idx, const char** out_str) { *out_str = ((const char**)data)[idx]; return true; } }; static int item_current_4 = 0; ImGui::Combo("combo 4 (function)", &item_current_4, &FuncHolder::ItemGetter, items, IM_ARRAYSIZE(items)); @@ -1013,7 +1013,7 @@ static void ShowDemoWindowWidgets() // Tip: Because ImGui:: is a namespace you would typicall add your own function into the namespace in your own source files. // For example, you may add a function called ImGui::InputText(const char* label, MyString* my_str). - static bool MyInputTextMultiline(const char* label, ImVector* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0) + static bool MyInputTextMultiline(const char* label, ImVector* my_str, const ImVec2& size = ImVec2(0, 0), const ImGuiInputTextFlags flags = 0) { IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, MyResizeCallback, (void*)my_str); @@ -1063,8 +1063,8 @@ static void ShowDemoWindowWidgets() // FIXME: This is rather awkward because current plot API only pass in indices. We probably want an API passing floats and user provide sample rate/count. struct Funcs { - static float Sin(void*, int i) { return sinf(i * 0.1f); } - static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; } + static float Sin(void*, const int i) { return sinf(i * 0.1f); } + static float Saw(void*, const int i) { return (i & 1) ? 1.0f : -1.0f; } }; static int func_type = 0, display_count = 70; ImGui::Separator(); @@ -3956,7 +3956,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open) struct funcs { - static void ShowDummyObject(const char* prefix, int uid) + static void ShowDummyObject(const char* prefix, const int uid) { ImGui::PushID(uid); // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID. ImGui::AlignTextToFramePadding(); // Text and Tree nodes are less high than regular widgets, here we add vertical spacing to make the tree lines equal high. @@ -4365,7 +4365,7 @@ struct MyDocument bool WantClose; // Set when the document ImVec4 Color; // An arbitrary variable associated to the document - MyDocument(const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f,1.0f,1.0f,1.0f)) + MyDocument(const char* name, const bool open = true, const ImVec4& color = ImVec4(1.0f,1.0f,1.0f,1.0f)) { Name = name; Open = OpenPrev = open; diff --git a/imgui/imgui_draw.cpp b/imgui/imgui_draw.cpp index 9ece2fbd..eabe11ef 100644 --- a/imgui/imgui_draw.cpp +++ b/imgui/imgui_draw.cpp @@ -415,7 +415,7 @@ void ImDrawList::AddDrawCmd() CmdBuffer.push_back(draw_cmd); } -void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data) +void ImDrawList::AddCallback(const ImDrawCallback callback, void* callback_data) { ImDrawCmd* current_cmd = CmdBuffer.Size ? &CmdBuffer.back() : NULL; if (!current_cmd || current_cmd->ElemCount != 0 || current_cmd->UserCallback != NULL) @@ -473,7 +473,7 @@ void ImDrawList::UpdateTextureID() #undef GetCurrentTextureId // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) -void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect) +void ImDrawList::PushClipRect(const ImVec2 cr_min, const ImVec2 cr_max, const bool intersect_with_current_clip_rect) { ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y); if (intersect_with_current_clip_rect && _ClipRectStack.Size) @@ -503,7 +503,7 @@ void ImDrawList::PopClipRect() UpdateClipRect(); } -void ImDrawList::PushTextureID(ImTextureID texture_id) +void ImDrawList::PushTextureID(const ImTextureID texture_id) { _TextureIdStack.push_back(texture_id); UpdateTextureID(); @@ -517,7 +517,7 @@ void ImDrawList::PopTextureID() } // NB: this can be called with negative count for removing primitives (as long as the result does not underflow) -void ImDrawList::PrimReserve(int idx_count, int vtx_count) +void ImDrawList::PrimReserve(const int idx_count, const int vtx_count) { // Large mesh support (when enabled) if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset)) @@ -540,7 +540,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count) } // Fully unrolled with inline call to keep our debug builds decently fast. -void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col) +void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, const ImU32 col) { ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel); const ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; @@ -555,7 +555,7 @@ void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col) _IdxWritePtr += 6; } -void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col) +void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, const ImU32 col) { ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y); const ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; @@ -570,7 +570,7 @@ void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a _IdxWritePtr += 6; } -void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col) +void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, const ImU32 col) { const ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); @@ -591,7 +591,7 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c // TODO: Thickness anti-aliased lines cap are missing their AA fringe. // We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds. -void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, bool closed, float thickness) +void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, const ImU32 col, const bool closed, const float thickness) { if (points_count < 2) return; @@ -779,7 +779,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 } // We intentionally avoid using ImVec2 and its math operators here to reduce cost to a minimum for debug/non-inlined builds. -void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col) +void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, const ImU32 col) { if (points_count < 3) return; @@ -860,7 +860,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun } } -void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12) +void ImDrawList::PathArcToFast(const ImVec2& center, const float radius, const int a_min_of_12, const int a_max_of_12) { if (radius == 0.0f || a_min_of_12 > a_max_of_12) { @@ -875,7 +875,7 @@ void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_ } } -void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments) +void ImDrawList::PathArcTo(const ImVec2& center, const float radius, const float a_min, const float a_max, const int num_segments) { if (radius == 0.0f) { @@ -893,7 +893,8 @@ void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, floa } } -static void PathBezierToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) +static void PathBezierToCasteljau(ImVector* path, const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4, + const float tess_tol, const int level) { const float dx = x4 - x1; const float dy = y4 - y1; @@ -919,7 +920,7 @@ static void PathBezierToCasteljau(ImVector* path, float x1, float y1, fl } } -void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments) +void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const int num_segments) { const ImVec2 p1 = _Path.back(); if (num_segments == 0) @@ -943,7 +944,7 @@ void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImV } } -void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDrawCornerFlags rounding_corners) +void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, const ImDrawCornerFlags rounding_corners) { rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f); rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f); @@ -968,7 +969,7 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDr } } -void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness) +void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, const ImU32 col, const float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -979,7 +980,7 @@ void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float th // p_min = upper-left, p_max = lower-right // Note we don't render 1 pixels sized rectangles properly. -void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners, float thickness) +void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, const ImU32 col, const float rounding, const ImDrawCornerFlags rounding_corners, const float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -990,7 +991,7 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl PathStroke(col, true, thickness); } -void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners) +void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, const ImU32 col, const float rounding, const ImDrawCornerFlags rounding_corners) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1007,7 +1008,7 @@ void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 c } // p_min = upper-left, p_max = lower-right -void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left) +void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, const ImU32 col_upr_left, const ImU32 col_upr_right, const ImU32 col_bot_right, const ImU32 col_bot_left) { if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0) return; @@ -1022,7 +1023,7 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_ma PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left); } -void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness) +void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImU32 col, const float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1034,7 +1035,7 @@ void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, c PathStroke(col, true, thickness); } -void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col) +void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1046,7 +1047,7 @@ void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& PathFillConvex(col); } -void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness) +void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImU32 col, const float thickness) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1057,7 +1058,7 @@ void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p PathStroke(col, true, thickness); } -void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col) +void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1068,7 +1069,7 @@ void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImV PathFillConvex(col); } -void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness) +void ImDrawList::AddCircle(const ImVec2& center, const float radius, const ImU32 col, const int num_segments, const float thickness) { if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) return; @@ -1079,7 +1080,7 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu PathStroke(col, true, thickness); } -void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments) +void ImDrawList::AddCircleFilled(const ImVec2& center, const float radius, const ImU32 col, const int num_segments) { if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) return; @@ -1090,7 +1091,7 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, PathFillConvex(col); } -void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments) +void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, const ImU32 col, const float thickness, const int num_segments) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1100,7 +1101,7 @@ void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImV PathStroke(col, false, thickness); } -void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect) +void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, const ImU32 col, const char* text_begin, const char* text_end, const float wrap_width, const ImVec4* cpu_fine_clip_rect) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1129,12 +1130,12 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL); } -void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end) +void ImDrawList::AddText(const ImVec2& pos, const ImU32 col, const char* text_begin, const char* text_end) { AddText(NULL, 0.0f, pos, col, text_begin, text_end); } -void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col) +void ImDrawList::AddImage(const ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, const ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1150,7 +1151,7 @@ void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, cons PopTextureID(); } -void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col) +void ImDrawList::AddImageQuad(const ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, const ImU32 col) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1166,7 +1167,8 @@ void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, con PopTextureID(); } -void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawCornerFlags rounding_corners) +void ImDrawList::AddImageRounded(const ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, const ImU32 col, const float rounding, + const ImDrawCornerFlags rounding_corners) { if ((col & IM_COL32_A_MASK) == 0) return; @@ -1212,7 +1214,7 @@ void ImDrawListSplitter::ClearFreeMemory() _Channels.clear(); } -void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count) +void ImDrawListSplitter::Split(ImDrawList* draw_list, const int channels_count) { IM_ASSERT(_Current == 0 && _Count <= 1); const int old_channels_count = _Channels.Size; @@ -1305,7 +1307,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list) _Count = 1; } -void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx) +void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, const int idx) { IM_ASSERT(idx >= 0 && idx < _Count); if (_Current == idx) @@ -1363,7 +1365,8 @@ void ImDrawData::ScaleClipRects(const ImVec2& fb_scale) //----------------------------------------------------------------------------- // Generic linear color gradient, write to RGB fields, leave A untouched. -void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1) +void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, const int vert_start_idx, const int vert_end_idx, const ImVec2 gradient_p0, const ImVec2 gradient_p1, const ImU32 col0, + const ImU32 col1) { const ImVec2 gradient_extent = gradient_p1 - gradient_p0; const float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent); @@ -1381,7 +1384,7 @@ void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int ve } // Distribute UV over (a, b) rectangle -void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp) +void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, const int vert_start_idx, const int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, const bool clamp) { const ImVec2 size = b - a; const ImVec2 uv_size = uv_b - uv_a; @@ -1632,7 +1635,7 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg) static unsigned int stb_decompress_length(const unsigned char *input); static unsigned int stb_decompress(unsigned char *output, const unsigned char *input, unsigned int length); static const char* GetDefaultCompressedFontDataTTFBase85(); -static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; } +static unsigned int Decode85Byte(const char c) { return c >= '\\' ? c-36 : c-35; } static void Decode85(const unsigned char* src, unsigned char* dst) { while (*src) @@ -1666,7 +1669,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) return font; } -ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, const float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); size_t data_size = 0; @@ -1688,7 +1691,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, } // NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build(). -ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, const int ttf_size, const float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) { IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); @@ -1701,7 +1704,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float si return AddFont(&font_cfg); } -ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) +ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, const int compressed_ttf_size, const float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) { const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data); const auto buf_decompressed_data = (unsigned char *)IM_ALLOC(buf_decompressed_size); @@ -1713,7 +1716,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_d return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges); } -ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) +ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, const float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) { const int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4; void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size); @@ -1723,7 +1726,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed return font; } -int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height) +int ImFontAtlas::AddCustomRectRegular(const unsigned int id, const int width, const int height) { IM_ASSERT(id >= 0x10000); IM_ASSERT(width > 0 && width <= 0xFFFF); @@ -1736,7 +1739,7 @@ int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height) return CustomRects.Size - 1; // Return index } -int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset) +int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, const ImWchar id, const int width, const int height, const float advance_x, const ImVec2& offset) { IM_ASSERT(font != NULL); IM_ASSERT(width > 0 && width <= 0xFFFF); @@ -1760,7 +1763,7 @@ void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* ou *out_uv_max = ImVec2((float)(rect->X + rect->Width) * TexUvScale.x, (float)(rect->Y + rect->Height) * TexUvScale.y); } -bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]) +bool ImFontAtlas::GetMouseCursorTexData(const ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]) { if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_COUNT) return false; @@ -1788,7 +1791,7 @@ bool ImFontAtlas::Build() return ImFontAtlasBuildWithStbTruetype(this); } -void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor) +void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], const float in_brighten_factor) { for (unsigned int i = 0; i < 256; i++) { @@ -1797,7 +1800,7 @@ void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], fl } } -void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride) +void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, const int x, const int y, const int w, const int h, const int stride) { unsigned char* data = pixels + x + y * stride; for (int j = h; j > 0; j--, data += stride) @@ -2108,7 +2111,7 @@ void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas) atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2); } -void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent) +void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, const float ascent, const float descent) { if (!font_config->MergeMode) { @@ -2259,7 +2262,7 @@ const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull() return &ranges[0]; } -static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges) +static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, const int accumulative_offsets_count, ImWchar* out_ranges) { for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2) { @@ -2558,13 +2561,13 @@ void ImFont::BuildLookupTable() IndexAdvanceX[i] = FallbackAdvanceX; } -void ImFont::SetFallbackChar(ImWchar c) +void ImFont::SetFallbackChar(const ImWchar c) { FallbackChar = c; BuildLookupTable(); } -void ImFont::GrowIndex(int new_size) +void ImFont::GrowIndex(const int new_size) { IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size); if (new_size <= IndexLookup.Size) @@ -2575,7 +2578,7 @@ void ImFont::GrowIndex(int new_size) // x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero. // Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis). -void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) +void ImFont::AddGlyph(const ImWchar codepoint, const float x0, const float y0, const float x1, const float y1, const float u0, const float v0, const float u1, const float v1, const float advance_x) { Glyphs.resize(Glyphs.Size + 1); ImFontGlyph& glyph = Glyphs.back(); @@ -2598,7 +2601,7 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1, MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + 1.99f) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + 1.99f); } -void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) +void ImFont::AddRemapChar(const ImWchar dst, const ImWchar src, const bool overwrite_dst) { IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. const int index_size = IndexLookup.Size; @@ -2613,7 +2616,7 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f; } -const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const +const ImFontGlyph* ImFont::FindGlyph(const ImWchar c) const { if (c >= IndexLookup.Size) return FallbackGlyph; @@ -2623,7 +2626,7 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const return &Glyphs.Data[i]; } -const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const +const ImFontGlyph* ImFont::FindGlyphNoFallback(const ImWchar c) const { if (c >= IndexLookup.Size) return NULL; @@ -2633,7 +2636,7 @@ const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const return &Glyphs.Data[i]; } -const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const +const char* ImFont::CalcWordWrapPositionA(const float scale, const char* text, const char* text_end, float wrap_width) const { // Simple word-wrapping for English, not full-featured. Please submit failing cases! // FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.) @@ -2732,7 +2735,7 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c return s; } -ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const +ImVec2 ImFont::CalcTextSizeA(const float size, const float max_width, const float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const { if (!text_end) text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this. @@ -2826,7 +2829,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons return text_size; } -void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const +void ImFont::RenderChar(ImDrawList* draw_list, const float size, ImVec2 pos, const ImU32 col, const ImWchar c) const { if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded. return; @@ -2840,7 +2843,8 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col } } -void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const +void ImFont::RenderText(ImDrawList* draw_list, const float size, ImVec2 pos, const ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, const float wrap_width, + const bool cpu_fine_clip) const { if (!text_end) text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls. @@ -3038,7 +3042,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col // - RenderRectFilledRangeH() //----------------------------------------------------------------------------- -void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) +void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, const float scale, const ImGuiMouseCursor mouse_cursor, const ImU32 col_fill, const ImU32 col_border, const ImU32 col_shadow) { if (mouse_cursor == ImGuiMouseCursor_None) return; @@ -3060,7 +3064,7 @@ void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, Im } // Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side. -void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col) +void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, const ImVec2 pos, const ImVec2 half_sz, const ImGuiDir direction, const ImU32 col) { switch (direction) { @@ -3072,7 +3076,7 @@ void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half } } -static inline float ImAcos01(float x) +static inline float ImAcos01(const float x) { if (x <= 0.0f) return IM_PI * 0.5f; if (x >= 1.0f) return 0.0f; @@ -3081,7 +3085,7 @@ static inline float ImAcos01(float x) } // FIXME: Cleanup and move code to ImDrawList. -void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding) +void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, const ImU32 col, float x_start_norm, float x_end_norm, float rounding) { if (x_end_norm == x_start_norm) return; @@ -3167,7 +3171,7 @@ static void stb__match(const unsigned char *data, unsigned int length) while (length--) *stb__dout++ = *data++; } -static void stb__lit(const unsigned char *data, unsigned int length) +static void stb__lit(const unsigned char *data, const unsigned int length) { IM_ASSERT(stb__dout + length <= stb__barrier_out_e); if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; } @@ -3197,7 +3201,7 @@ static const unsigned char *stb_decompress_token(const unsigned char *i) return i; } -static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen) +static unsigned int stb_adler32(const unsigned int adler32, unsigned char *buffer, unsigned int buflen) { constexpr unsigned long ADLER_MOD = 65521; unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; diff --git a/imgui/imgui_impl_glfw.cpp b/imgui/imgui_impl_glfw.cpp index 6d378de5..7dc29426 100644 --- a/imgui/imgui_impl_glfw.cpp +++ b/imgui/imgui_impl_glfw.cpp @@ -79,7 +79,7 @@ static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text) glfwSetClipboardString((GLFWwindow*)user_data, text); } -void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods) +void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, const int button, const int action, const int mods) { if (g_PrevUserCallbackMousebutton != NULL) g_PrevUserCallbackMousebutton(window, button, action, mods); @@ -88,7 +88,7 @@ void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int acti g_MouseJustPressed[button] = true; } -void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset) +void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, const double xoffset, const double yoffset) { if (g_PrevUserCallbackScroll != NULL) g_PrevUserCallbackScroll(window, xoffset, yoffset); @@ -98,7 +98,7 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yo io.MouseWheel += (float)yoffset; } -void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) +void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, const int key, const int scancode, const int action, const int mods) { if (g_PrevUserCallbackKey != NULL) g_PrevUserCallbackKey(window, key, scancode, action, mods); @@ -116,7 +116,7 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int a io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER]; } -void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c) +void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, const unsigned int c) { if (g_PrevUserCallbackChar != NULL) g_PrevUserCallbackChar(window, c); @@ -125,7 +125,7 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c) io.AddInputCharacter(c); } -static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api) +static bool ImGui_ImplGlfw_Init(GLFWwindow* window, const bool install_callbacks, const GlfwClientApi client_api) { g_Window = window; g_Time = 0.0; @@ -193,12 +193,12 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw return true; } -bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks) +bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, const bool install_callbacks) { return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL); } -bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks) +bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, const bool install_callbacks) { return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan); } diff --git a/imgui/imgui_impl_opengl2.cpp b/imgui/imgui_impl_opengl2.cpp index 261bcb96..291133d2 100644 --- a/imgui/imgui_impl_opengl2.cpp +++ b/imgui/imgui_impl_opengl2.cpp @@ -57,7 +57,7 @@ void ImGui_ImplOpenGL2_NewFrame() ImGui_ImplOpenGL2_CreateDeviceObjects(); } -static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height) +static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, const int fb_width, const int fb_height) { // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill. glEnable(GL_BLEND); diff --git a/imgui/imgui_impl_opengl3.cpp b/imgui/imgui_impl_opengl3.cpp index d5e27b6b..8357a45e 100644 --- a/imgui/imgui_impl_opengl3.cpp +++ b/imgui/imgui_impl_opengl3.cpp @@ -132,7 +132,7 @@ void ImGui_ImplOpenGL3_NewFrame() ImGui_ImplOpenGL3_CreateDeviceObjects(); } -static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object) +static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, const int fb_width, const int fb_height, const GLuint vertex_array_object) { // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill glEnable(GL_BLEND); @@ -358,7 +358,7 @@ void ImGui_ImplOpenGL3_DestroyFontsTexture() } // If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file. -static bool CheckShader(GLuint handle, const char* desc) +static bool CheckShader(const GLuint handle, const char* desc) { GLint status = 0, log_length = 0; glGetShaderiv(handle, GL_COMPILE_STATUS, &status); @@ -376,7 +376,7 @@ static bool CheckShader(GLuint handle, const char* desc) } // If you get an error please report on GitHub. You may try different GL context version or GLSL version. -static bool CheckProgram(GLuint handle, const char* desc) +static bool CheckProgram(const GLuint handle, const char* desc) { GLint status = 0, log_length = 0; glGetProgramiv(handle, GL_LINK_STATUS, &status); diff --git a/imgui/imgui_internal.h b/imgui/imgui_internal.h index b1ebb5bf..7f645995 100644 --- a/imgui/imgui_internal.h +++ b/imgui/imgui_internal.h @@ -170,13 +170,13 @@ IMGUI_API ImU32 ImHashData(const void* data, size_t data_size, ImU32 see IMGUI_API ImU32 ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0); IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size = NULL, int padding_bytes = 0); IMGUI_API FILE* ImFileOpen(const char* filename, const char* file_open_mode); -static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; } -static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; } -static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; } +static inline bool ImCharIsBlankA(const char c) { return c == ' ' || c == '\t'; } +static inline bool ImCharIsBlankW(const unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; } +static inline bool ImIsPowerOfTwo(const int v) { return v != 0 && (v & (v - 1)) == 0; } static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } #define ImQsort qsort #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -static inline ImU32 ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68] +static inline ImU32 ImHash(const void* data, const int size, const ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68] #endif // Helpers: Geometry @@ -227,19 +227,19 @@ static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) // Helpers: Maths // - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy) #ifndef IMGUI_DISABLE_MATH_FUNCTIONS -static inline float ImFabs(float x) { return fabsf(x); } -static inline float ImSqrt(float x) { return sqrtf(x); } -static inline float ImPow(float x, float y) { return powf(x, y); } -static inline double ImPow(double x, double y) { return pow(x, y); } -static inline float ImFmod(float x, float y) { return fmodf(x, y); } -static inline double ImFmod(double x, double y) { return fmod(x, y); } -static inline float ImCos(float x) { return cosf(x); } -static inline float ImSin(float x) { return sinf(x); } -static inline float ImAcos(float x) { return acosf(x); } -static inline float ImAtan2(float y, float x) { return atan2f(y, x); } +static inline float ImFabs(const float x) { return fabsf(x); } +static inline float ImSqrt(const float x) { return sqrtf(x); } +static inline float ImPow(const float x, const float y) { return powf(x, y); } +static inline double ImPow(const double x, const double y) { return pow(x, y); } +static inline float ImFmod(const float x, const float y) { return fmodf(x, y); } +static inline double ImFmod(const double x, const double y) { return fmod(x, y); } +static inline float ImCos(const float x) { return cosf(x); } +static inline float ImSin(const float x) { return sinf(x); } +static inline float ImAcos(const float x) { return acosf(x); } +static inline float ImAtan2(const float y, const float x) { return atan2f(y, x); } static inline double ImAtof(const char* s) { return atof(s); } -static inline float ImFloorStd(float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype) -static inline float ImCeil(float x) { return ceilf(x); } +static inline float ImFloorStd(const float x) { return floorf(x); } // we already uses our own ImFloor() { return (float)(int)v } internally so the standard one wrapper is named differently (it's used by stb_truetype) +static inline float ImCeil(const float x) { return ceilf(x); } #endif // - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support for variety of types: signed/unsigned int/long long float/double // (Exceptionally using templates here but we could also redefine them for variety of types) @@ -253,21 +253,21 @@ template static inline T ImSubClampOverflow(T a, T b, T mn, T mx) // - Misc maths helpers static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); } static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); } -static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); } -static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } +static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, const ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); } +static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); } -static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } -static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; } +static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, const float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } +static inline float ImSaturate(const float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; } static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; } static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; } -static inline float ImInvLength(const ImVec2& lhs, float fail_value) { +static inline float ImInvLength(const ImVec2& lhs, const float fail_value) { const float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / ImSqrt(d); return fail_value; } -static inline float ImFloor(float f) { return (float)(int)f; } +static inline float ImFloor(const float f) { return (float)(int)f; } static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)v.x, (float)(int)v.y); } -static inline int ImModPositive(int a, int b) { return (a + b) % b; } +static inline int ImModPositive(const int a, const int b) { return (a + b) % b; } static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; } -static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); } -static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; } +static inline ImVec2 ImRotate(const ImVec2& v, const float cos_a, const float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); } +static inline float ImLinearSweep(const float current, const float target, const float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; } static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } // Helper: ImBoolVector. Store 1-bit per value. @@ -276,12 +276,12 @@ struct ImBoolVector { ImVector Storage; ImBoolVector() { } - void Resize(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); } + void Resize(const int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); } void Clear() { Storage.clear(); } - bool GetBit(int n) const { + bool GetBit(const int n) const { const int off = (n >> 5); const int mask = 1 << (n & 31); return (Storage[off] & mask) != 0; } - void SetBit(int n, bool v) { + void SetBit(const int n, const bool v) { const int off = (n >> 5); const int mask = 1 << (n & 31); if (v) Storage[off] |= mask; else Storage[off] &= ~mask; } }; @@ -298,15 +298,15 @@ struct IMGUI_API ImPool ImPool() { FreeIdx = 0; } ~ImPool() { Clear(); } - T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; } + T* GetByKey(const ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Data[idx] : NULL; } T* GetByIndex(ImPoolIdx n) { return &Data[n]; } ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Data.Data && p < Data.Data + Data.Size); return (ImPoolIdx)(p - Data.Data); } - T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); } + T* GetOrAddByKey(const ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Data[*p_idx]; *p_idx = FreeIdx; return Add(); } bool Contains(const T* p) const { return (p >= Data.Data && p < Data.Data + Data.Size); } void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Data[idx].~T(); } Map.Clear(); Data.clear(); FreeIdx = 0; } T* Add() { int idx = FreeIdx; if (idx == Data.Size) { Data.resize(Data.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Data[idx]; } IM_PLACEMENT_NEW(&Data[idx]) T(); return &Data[idx]; } - void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); } - void Remove(ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); } + void Remove(const ImGuiID key, const T* p) { Remove(key, GetIndex(p)); } + void Remove(const ImGuiID key, ImPoolIdx idx) { Data[idx].~T(); *(int*)&Data[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); } void Reserve(int capacity) { Data.reserve(capacity); Map.Data.reserve(capacity); } int GetSize() const { return Data.Size; } }; @@ -530,7 +530,7 @@ struct ImVec1 { float x; ImVec1() { x = 0.0f; } - ImVec1(float _x) { x = _x; } + ImVec1(const float _x) { x = _x; } }; // 2D vector (half-size integer) @@ -538,7 +538,7 @@ struct ImVec2ih { short x, y; ImVec2ih() { x = y = 0; } - ImVec2ih(short _x, short _y) { x = _x; y = _y; } + ImVec2ih(const short _x, const short _y) { x = _x; y = _y; } }; // 2D axis aligned bounding-box @@ -551,7 +551,7 @@ struct IMGUI_API ImRect ImRect() : Min(FLT_MAX,FLT_MAX), Max(-FLT_MAX,-FLT_MAX) {} ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {} ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {} - ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {} + ImRect(const float x1, const float y1, const float x2, const float y2) : Min(x1, y1), Max(x2, y2) {} ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); } ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); } @@ -569,8 +569,8 @@ struct IMGUI_API ImRect void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; } void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; } void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; } - void TranslateX(float dx) { Min.x += dx; Max.x += dx; } - void TranslateY(float dy) { Min.y += dy; Max.y += dy; } + void TranslateX(const float dx) { Min.x += dx; Max.x += dx; } + void TranslateY(const float dy) { Min.y += dy; Max.y += dy; } void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display. void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped. void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; } @@ -597,9 +597,9 @@ struct ImGuiStyleMod { ImGuiStyleVar VarIdx; union { int BackupInt[2]; float BackupFloat[2]; }; - ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; } - ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; } - ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; } + ImGuiStyleMod(const ImGuiStyleVar idx, const int v) { VarIdx = idx; BackupInt[0] = v; } + ImGuiStyleMod(const ImGuiStyleVar idx, const float v) { VarIdx = idx; BackupFloat[0] = v; } + ImGuiStyleMod(const ImGuiStyleVar idx, const ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; } }; // Stacked storage data for BeginGroup()/EndGroup() @@ -852,7 +852,7 @@ struct ImGuiPtrOrIndex int Index; // Usually index in a main pool. ImGuiPtrOrIndex(void* ptr) { Ptr = ptr; Index = -1; } - ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; } + ImGuiPtrOrIndex(const int index) { Ptr = NULL; Index = index; } }; //----------------------------------------------------------------------------- @@ -1601,10 +1601,10 @@ namespace ImGui // Inputs IMGUI_API bool IsMouseDragPastThreshold(int button, float lock_threshold = -1.0f); - inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { const int key_index = GImGui->IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; } - inline bool IsNavInputDown(ImGuiNavInput n) { return GImGui->IO.NavInputs[n] > 0.0f; } - inline bool IsNavInputPressed(ImGuiNavInput n, ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; } - inline bool IsNavInputPressedAnyOfTwo(ImGuiNavInput n1, ImGuiNavInput n2, ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; } + inline bool IsKeyPressedMap(const ImGuiKey key, const bool repeat = true) { const int key_index = GImGui->IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; } + inline bool IsNavInputDown(const ImGuiNavInput n) { return GImGui->IO.NavInputs[n] > 0.0f; } + inline bool IsNavInputPressed(const ImGuiNavInput n, const ImGuiInputReadMode mode) { return GetNavInputAmount(n, mode) > 0.0f; } + inline bool IsNavInputPressedAnyOfTwo(const ImGuiNavInput n1, const ImGuiNavInput n2, const ImGuiInputReadMode mode) { return (GetNavInputAmount(n1, mode) + GetNavInputAmount(n2, mode)) > 0.0f; } // Drag and Drop IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id); @@ -1658,9 +1658,9 @@ namespace ImGui #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS // 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while. - inline void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale=1.0f) { + inline void RenderArrow(const ImVec2 pos, const ImGuiDir dir, const float scale=1.0f) { const ImGuiWindow * window = GetCurrentWindow(); RenderArrow(window->DrawList, pos, GetColorU32(ImGuiCol_Text), dir, scale); } - inline void RenderBullet(ImVec2 pos) { + inline void RenderBullet(const ImVec2 pos) { const ImGuiWindow * window = GetCurrentWindow(); RenderBullet(window->DrawList, pos, GetColorU32(ImGuiCol_Text)); } #endif @@ -1701,7 +1701,7 @@ namespace ImGui // InputText IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); IMGUI_API bool TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format); - inline bool TempInputTextIsActive(ImGuiID id) { + inline bool TempInputTextIsActive(const ImGuiID id) { const ImGuiContext & g = *GImGui; return (g.ActiveId == id && g.TempInputTextId == id); } // Color diff --git a/imgui/imgui_widgets.cpp b/imgui/imgui_widgets.cpp index 82a630b5..6f11b002 100644 --- a/imgui/imgui_widgets.cpp +++ b/imgui/imgui_widgets.cpp @@ -133,7 +133,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const // - BulletTextV() //------------------------------------------------------------------------- -void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags) +void ImGui::TextEx(const char* text, const char* text_end, const ImGuiTextFlags flags) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -249,7 +249,7 @@ void ImGui::Text(const char* fmt, ...) va_end(args); } -void ImGui::TextV(const char* fmt, va_list args) +void ImGui::TextV(const char* fmt, const va_list args) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -268,7 +268,7 @@ void ImGui::TextColored(const ImVec4& col, const char* fmt, ...) va_end(args); } -void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args) +void ImGui::TextColoredV(const ImVec4& col, const char* fmt, const va_list args) { PushStyleColor(ImGuiCol_Text, col); TextV(fmt, args); @@ -283,7 +283,7 @@ void ImGui::TextDisabled(const char* fmt, ...) va_end(args); } -void ImGui::TextDisabledV(const char* fmt, va_list args) +void ImGui::TextDisabledV(const char* fmt, const va_list args) { PushStyleColor(ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled]); TextV(fmt, args); @@ -298,7 +298,7 @@ void ImGui::TextWrapped(const char* fmt, ...) va_end(args); } -void ImGui::TextWrappedV(const char* fmt, va_list args) +void ImGui::TextWrappedV(const char* fmt, const va_list args) { const ImGuiWindow * window = GetCurrentWindow(); const bool need_backup = (window->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set @@ -318,7 +318,7 @@ void ImGui::LabelText(const char* label, const char* fmt, ...) } // Add a label+text combo aligned to other label+value widgets -void ImGui::LabelTextV(const char* label, const char* fmt, va_list args) +void ImGui::LabelTextV(const char* label, const char* fmt, const va_list args) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -352,7 +352,7 @@ void ImGui::BulletText(const char* fmt, ...) } // Text with a little bullet aligned to the typical tree node. -void ImGui::BulletTextV(const char* fmt, va_list args) +void ImGui::BulletTextV(const char* fmt, const va_list args) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -687,7 +687,7 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg) return pressed; } -bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags) +bool ImGui::ArrowButtonEx(const char* str_id, const ImGuiDir dir, const ImVec2 size, ImGuiButtonFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -717,14 +717,14 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu return pressed; } -bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir) +bool ImGui::ArrowButton(const char* str_id, const ImGuiDir dir) { const float sz = GetFrameHeight(); return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), 0); } // Button to close a window -bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)//, float size) +bool ImGui::CloseButton(const ImGuiID id, const ImVec2& pos)//, float size) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -754,7 +754,7 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)//, float size) return pressed; } -bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos) +bool ImGui::CollapseButton(const ImGuiID id, const ImVec2& pos) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -779,7 +779,7 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos) return pressed; } -ImGuiID ImGui::GetScrollbarID(ImGuiWindow* window, ImGuiAxis axis) +ImGuiID ImGui::GetScrollbarID(ImGuiWindow* window, const ImGuiAxis axis) { return window->GetIDNoKeepAlive(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY"); } @@ -790,7 +790,8 @@ ImGuiID ImGui::GetScrollbarID(ImGuiWindow* window, ImGuiAxis axis) // - We store values as normalized ratio and in a form that allows the window content to change while we are holding on a scrollbar // - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal. // Still, the code should probably be made simpler.. -bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float size_avail_v, float size_contents_v, ImDrawCornerFlags rounding_corners) +bool ImGui::ScrollbarEx(const ImRect& bb_frame, const ImGuiID id, const ImGuiAxis axis, float* p_scroll_v, const float size_avail_v, const float size_contents_v, + const ImDrawCornerFlags rounding_corners) { ImGuiContext& g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -881,7 +882,7 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, floa return held; } -void ImGui::Scrollbar(ImGuiAxis axis) +void ImGui::Scrollbar(const ImGuiAxis axis) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -913,7 +914,7 @@ void ImGui::Scrollbar(ImGuiAxis axis) ScrollbarEx(bb, id, axis, &window->Scroll[axis], inner_rect.Max[axis] - inner_rect.Min[axis], window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f, rounding_corners); } -void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) +void ImGui::Image(const ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -941,7 +942,7 @@ void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& // frame_padding = 0: no framing // frame_padding > 0: set framing size // The color used are the button colors. -bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) +bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -1028,7 +1029,7 @@ bool ImGui::Checkbox(const char* label, bool* v) return pressed; } -bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value) +bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, const unsigned int flags_value) { bool v = ((*flags & flags_value) == flags_value); const bool pressed = Checkbox(label, &v); @@ -1043,7 +1044,7 @@ bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int f return pressed; } -bool ImGui::RadioButton(const char* label, bool active) +bool ImGui::RadioButton(const char* label, const bool active) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -1095,7 +1096,7 @@ bool ImGui::RadioButton(const char* label, bool active) } // FIXME: This would work nicely if it was a public template, e.g. 'template RadioButton(const char* label, T* v, T v_button)', but I'm not sure how we would expose it.. -bool ImGui::RadioButton(const char* label, int* v, int v_button) +bool ImGui::RadioButton(const char* label, int* v, const int v_button) { const bool pressed = RadioButton(label, *v == v_button); if (pressed) @@ -1223,7 +1224,7 @@ void ImGui::AlignTextToFramePadding() } // Horizontal/vertical separating line -void ImGui::SeparatorEx(ImGuiSeparatorFlags flags) +void ImGui::SeparatorEx(const ImGuiSeparatorFlags flags) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -1301,7 +1302,8 @@ void ImGui::Separator() } // Using 'hover_visibility_delay' allows us to hide the highlight and mouse cursor for a short time, which can be convenient to reduce visual noise. -bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend, float hover_visibility_delay) +bool ImGui::SplitterBehavior(const ImRect& bb, const ImGuiID id, const ImGuiAxis axis, float* size1, float* size2, const float min_size1, const float min_size2, const float hover_extend, + const float hover_visibility_delay) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -1368,7 +1370,7 @@ static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs) } // Shrink excess width from a set of item, by removing width from the larger items first. -void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess) +void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, const int count, float width_excess) { if (count == 1) { @@ -1411,7 +1413,7 @@ void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_exc // - Combo() //------------------------------------------------------------------------- -static float CalcMaxPopupHeightFromItemCount(int items_count) +static float CalcMaxPopupHeightFromItemCount(const int items_count) { const ImGuiContext & g = *GImGui; if (items_count <= 0) @@ -1531,7 +1533,7 @@ void ImGui::EndCombo() } // Getter for the old Combo() API: const char*[] -static bool Items_ArrayGetter(void* data, int idx, const char** out_text) +static bool Items_ArrayGetter(void* data, const int idx, const char** out_text) { const auto items = (const char* const*)data; if (out_text) @@ -1540,7 +1542,7 @@ static bool Items_ArrayGetter(void* data, int idx, const char** out_text) } // Getter for the old Combo() API: "item1\0item2\0item3\0" -static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) +static bool Items_SingleStringGetter(void* data, const int idx, const char** out_text) { // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. const auto items_separated_by_zeros = (const char*)data; @@ -1561,7 +1563,7 @@ static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) } // Old API, prefer using BeginCombo() nowadays if you can. -bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items) +bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, const int items_count, const int popup_max_height_in_items) { const ImGuiContext & g = *GImGui; @@ -1602,14 +1604,14 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi } // Combo box helper allowing to pass an array of strings. -bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items) +bool ImGui::Combo(const char* label, int* current_item, const char* const items[], const int items_count, const int height_in_items) { const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items); return value_changed; } // Combo box helper allowing to pass all items in a single string literal holding multiple zero-terminated items "item1\0item2\0" -bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items) +bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, const int height_in_items) { int items_count = 0; const char* p = items_separated_by_zeros; // FIXME-OPT: Avoid computing this, or at least only when combo is open @@ -1678,13 +1680,13 @@ static const char* PatchFormatStringFloatToInt(const char* fmt) return fmt; } -const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type) +const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(const ImGuiDataType data_type) { IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT); return &GDataTypeInfo[data_type]; } -int ImGui::DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* data_ptr, const char* format) +int ImGui::DataTypeFormatString(char* buf, const int buf_size, const ImGuiDataType data_type, const void* data_ptr, const char* format) { // Signedness doesn't matter when pushing integer arguments if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32) @@ -1707,7 +1709,7 @@ int ImGui::DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type return 0; } -void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg1, const void* arg2) +void ImGui::DataTypeApplyOp(const ImGuiDataType data_type, const int op, void* output, void* arg1, const void* arg2) { IM_ASSERT(op == '+' || op == '-'); switch (data_type) @@ -1759,7 +1761,7 @@ void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* // User can input math operators (e.g. +100) to edit a numerical values. // NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess.. -bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* data_ptr, const char* format) +bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, const ImGuiDataType data_type, void* data_ptr, const char* format) { while (ImCharIsBlankA(*buf)) buf++; @@ -1860,7 +1862,7 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b return memcmp(data_backup, data_ptr, type_info->Size) != 0; } -static float GetMinimumStepAtDecimalPrecision(int decimal_precision) +static float GetMinimumStepAtDecimalPrecision(const int decimal_precision) { static constexpr float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; if (decimal_precision < 0) @@ -1882,7 +1884,7 @@ static const char* ImAtoi(const char* src, TYPE* output) } template -TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v) +TYPE ImGui::RoundScalarWithFormatT(const char* format, const ImGuiDataType data_type, TYPE v) { const char* fmt_start = ImParseFormatFindStart(format); if (fmt_start[0] != '%' || fmt_start[1] == '%') // Don't apply if the value is not visible in the format string @@ -1920,7 +1922,7 @@ TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, // This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls) template -bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiDragFlags flags) +bool ImGui::DragBehaviorT(const ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, float power, const ImGuiDragFlags flags) { ImGuiContext& g = *GImGui; const ImGuiAxis axis = (flags & ImGuiDragFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X; @@ -2028,7 +2030,8 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const return true; } -bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power, ImGuiDragFlags flags) +bool ImGui::DragBehavior(const ImGuiID id, const ImGuiDataType data_type, void* v, const float v_speed, const void* v_min, const void* v_max, const char* format, const float power, + const ImGuiDragFlags flags) { const ImGuiContext & g = *GImGui; if (g.ActiveId == id) @@ -2063,7 +2066,7 @@ bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* v, float v_s return false; } -bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, float v_speed, const void* v_min, const void* v_max, const char* format, float power) +bool ImGui::DragScalar(const char* label, const ImGuiDataType data_type, void* v, const float v_speed, const void* v_min, const void* v_max, const char* format, const float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -2137,7 +2140,8 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa return value_changed; } -bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* v, int components, float v_speed, const void* v_min, const void* v_max, const char* format, float power) +bool ImGui::DragScalarN(const char* label, const ImGuiDataType data_type, void* v, const int components, const float v_speed, const void* v_min, const void* v_max, const char* format, + const float power) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -2172,27 +2176,28 @@ bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* v, int return value_changed; } -bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, float power) +bool ImGui::DragFloat(const char* label, float* v, const float v_speed, const float v_min, const float v_max, const char* format, const float power) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power); } -bool ImGui::DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, float power) +bool ImGui::DragFloat2(const char* label, float v[2], const float v_speed, const float v_min, const float v_max, const char* format, const float power) { return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power); } -bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, float power) +bool ImGui::DragFloat3(const char* label, float v[3], const float v_speed, const float v_min, const float v_max, const char* format, const float power) { return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power); } -bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, float power) +bool ImGui::DragFloat4(const char* label, float v[4], const float v_speed, const float v_min, const float v_max, const char* format, const float power) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power); } -bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* format, const char* format_max, float power) +bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, const float v_speed, const float v_min, const float v_max, const char* format, const char* format_max, + const float power) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -2217,27 +2222,27 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu } // NB: v_speed is float to allow adjusting the drag speed with more precision -bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* format) +bool ImGui::DragInt(const char* label, int* v, const float v_speed, const int v_min, const int v_max, const char* format) { return DragScalar(label, ImGuiDataType_S32, v, v_speed, &v_min, &v_max, format); } -bool ImGui::DragInt2(const char* label, int v[2], float v_speed, int v_min, int v_max, const char* format) +bool ImGui::DragInt2(const char* label, int v[2], const float v_speed, const int v_min, const int v_max, const char* format) { return DragScalarN(label, ImGuiDataType_S32, v, 2, v_speed, &v_min, &v_max, format); } -bool ImGui::DragInt3(const char* label, int v[3], float v_speed, int v_min, int v_max, const char* format) +bool ImGui::DragInt3(const char* label, int v[3], const float v_speed, const int v_min, const int v_max, const char* format) { return DragScalarN(label, ImGuiDataType_S32, v, 3, v_speed, &v_min, &v_max, format); } -bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int v_max, const char* format) +bool ImGui::DragInt4(const char* label, int v[4], const float v_speed, const int v_min, const int v_max, const char* format) { return DragScalarN(label, ImGuiDataType_S32, v, 4, v_speed, &v_min, &v_max, format); } -bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* format, const char* format_max) +bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, const float v_speed, const int v_min, const int v_max, const char* format, const char* format_max) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -2284,7 +2289,7 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_ //------------------------------------------------------------------------- template -float ImGui::SliderCalcRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_min, TYPE v_max, float power, float linear_zero_pos) +float ImGui::SliderCalcRatioFromValueT(const ImGuiDataType data_type, TYPE v, TYPE v_min, TYPE v_max, const float power, const float linear_zero_pos) { if (v_min == v_max) return 0.0f; @@ -2311,7 +2316,8 @@ float ImGui::SliderCalcRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_m // FIXME: Move some of the code into SliderBehavior(). Current responsability is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc. template -bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb) +bool ImGui::SliderBehaviorT(const ImRect& bb, const ImGuiID id, const ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, + const ImGuiSliderFlags flags, ImRect* out_grab_bb) { ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; @@ -2483,7 +2489,8 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ // For 32-bits and larger types, slider bounds are limited to half the natural type range. // So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2 will be ok. // It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders. -bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb) +bool ImGui::SliderBehavior(const ImRect& bb, const ImGuiID id, const ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, const float power, + const ImGuiSliderFlags flags, ImRect* out_grab_bb) { switch (data_type) { @@ -2519,7 +2526,7 @@ bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type return false; } -bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power) +bool ImGui::SliderScalar(const char* label, const ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, const float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -2596,7 +2603,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co } // Add multiple sliders on 1 line for compact edition of multiple components -bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, float power) +bool ImGui::SliderScalarN(const char* label, const ImGuiDataType data_type, void* v, const int components, const void* v_min, const void* v_max, const char* format, const float power) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -2631,27 +2638,27 @@ bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, i return value_changed; } -bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power) +bool ImGui::SliderFloat(const char* label, float* v, const float v_min, const float v_max, const char* format, const float power) { return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power); } -bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power) +bool ImGui::SliderFloat2(const char* label, float v[2], const float v_min, const float v_max, const char* format, const float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power); } -bool ImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power) +bool ImGui::SliderFloat3(const char* label, float v[3], const float v_min, const float v_max, const char* format, const float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power); } -bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) +bool ImGui::SliderFloat4(const char* label, float v[4], const float v_min, const float v_max, const char* format, const float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); } -bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max, const char* format) +bool ImGui::SliderAngle(const char* label, float* v_rad, const float v_degrees_min, const float v_degrees_max, const char* format) { if (format == NULL) format = "%.0f deg"; @@ -2661,27 +2668,27 @@ bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, fl return value_changed; } -bool ImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* format) +bool ImGui::SliderInt(const char* label, int* v, const int v_min, const int v_max, const char* format) { return SliderScalar(label, ImGuiDataType_S32, v, &v_min, &v_max, format); } -bool ImGui::SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format) +bool ImGui::SliderInt2(const char* label, int v[2], const int v_min, const int v_max, const char* format) { return SliderScalarN(label, ImGuiDataType_S32, v, 2, &v_min, &v_max, format); } -bool ImGui::SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format) +bool ImGui::SliderInt3(const char* label, int v[3], const int v_min, const int v_max, const char* format) { return SliderScalarN(label, ImGuiDataType_S32, v, 3, &v_min, &v_max, format); } -bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format) +bool ImGui::SliderInt4(const char* label, int v[4], const int v_min, const int v_max, const char* format) { return SliderScalarN(label, ImGuiDataType_S32, v, 4, &v_min, &v_max, format); } -bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, float power) +bool ImGui::VSliderScalar(const char* label, const ImVec2& size, const ImGuiDataType data_type, void* v, const void* v_min, const void* v_max, const char* format, const float power) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -2740,12 +2747,12 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d return value_changed; } -bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format, float power) +bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, const float v_min, const float v_max, const char* format, const float power) { return VSliderScalar(label, size, ImGuiDataType_Float, v, &v_min, &v_max, format, power); } -bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format) +bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, const int v_min, const int v_max, const char* format) { return VSliderScalar(label, size, ImGuiDataType_S32, v, &v_min, &v_max, format); } @@ -2807,7 +2814,7 @@ const char* ImParseFormatFindEnd(const char* fmt) // fmt = "%.3f" -> return fmt // fmt = "hello %.3f" -> return fmt + 6 // fmt = "%.3f hello" -> return buf written with "%.3f" -const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_size) +const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, const size_t buf_size) { const char* fmt_start = ImParseFormatFindStart(fmt); if (fmt_start[0] != '%') @@ -2821,7 +2828,7 @@ const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_ // Parse display precision back from the display format string // FIXME: This is still used by some navigation code path to infer a minimum tweak step, but we should aim to rework widgets so it isn't needed. -int ImParseFormatPrecision(const char* fmt, int default_precision) +int ImParseFormatPrecision(const char* fmt, const int default_precision) { fmt = ImParseFormatFindStart(fmt); if (fmt[0] != '%') @@ -2845,7 +2852,7 @@ int ImParseFormatPrecision(const char* fmt, int default_precision) // Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) // FIXME: Facilitate using this in variety of other situations. -bool ImGui::TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format) +bool ImGui::TempInputTextScalar(const ImRect& bb, const ImGuiID id, const char* label, const ImGuiDataType data_type, void* data_ptr, const char* format) { ImGuiContext& g = *GImGui; @@ -2880,7 +2887,7 @@ bool ImGui::TempInputTextScalar(const ImRect& bb, ImGuiID id, const char* label, return value_changed; } -bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_ptr, const void* step, const void* step_fast, const char* format, ImGuiInputTextFlags flags) +bool ImGui::InputScalar(const char* label, const ImGuiDataType data_type, void* data_ptr, const void* step, const void* step_fast, const char* format, ImGuiInputTextFlags flags) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -2952,7 +2959,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* data_p return value_changed; } -bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* step, const void* step_fast, const char* format, ImGuiInputTextFlags flags) +bool ImGui::InputScalarN(const char* label, const ImGuiDataType data_type, void* v, const int components, const void* step, const void* step_fast, const char* format, const ImGuiInputTextFlags flags) { const ImGuiWindow * window = GetCurrentWindow(); if (window->SkipItems) @@ -2993,24 +3000,24 @@ bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), format, flags); } -bool ImGui::InputFloat2(const char* label, float v[2], const char* format, ImGuiInputTextFlags flags) +bool ImGui::InputFloat2(const char* label, float v[2], const char* format, const ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags); } -bool ImGui::InputFloat3(const char* label, float v[3], const char* format, ImGuiInputTextFlags flags) +bool ImGui::InputFloat3(const char* label, float v[3], const char* format, const ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags); } -bool ImGui::InputFloat4(const char* label, float v[4], const char* format, ImGuiInputTextFlags flags) +bool ImGui::InputFloat4(const char* label, float v[4], const char* format, const ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags); } // Prefer using "const char* format" directly, which is more flexible and consistent with other API. #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, int decimal_precision, ImGuiInputTextFlags flags) +bool ImGui::InputFloat(const char* label, float* v, const float step, const float step_fast, const int decimal_precision, const ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) @@ -3018,7 +3025,7 @@ bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, return InputFloat(label, v, step, step_fast, format, flags); } -bool ImGui::InputFloat2(const char* label, float v[2], int decimal_precision, ImGuiInputTextFlags flags) +bool ImGui::InputFloat2(const char* label, float v[2], const int decimal_precision, const ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) @@ -3026,7 +3033,7 @@ bool ImGui::InputFloat2(const char* label, float v[2], int decimal_precision, Im return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags); } -bool ImGui::InputFloat3(const char* label, float v[3], int decimal_precision, ImGuiInputTextFlags flags) +bool ImGui::InputFloat3(const char* label, float v[3], const int decimal_precision, const ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) @@ -3034,7 +3041,7 @@ bool ImGui::InputFloat3(const char* label, float v[3], int decimal_precision, Im return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags); } -bool ImGui::InputFloat4(const char* label, float v[4], int decimal_precision, ImGuiInputTextFlags flags) +bool ImGui::InputFloat4(const char* label, float v[4], const int decimal_precision, const ImGuiInputTextFlags flags) { char format[16] = "%f"; if (decimal_precision >= 0) @@ -3043,24 +3050,24 @@ bool ImGui::InputFloat4(const char* label, float v[4], int decimal_precision, Im } #endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS -bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags flags) +bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, const ImGuiInputTextFlags flags) { // Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes. const char* format = (flags & ImGuiInputTextFlags_CharsHexadecimal) ? "%08X" : "%d"; return InputScalar(label, ImGuiDataType_S32, (void*)v, (void*)(step>0 ? &step : NULL), (void*)(step_fast>0 ? &step_fast : NULL), format, flags); } -bool ImGui::InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags) +bool ImGui::InputInt2(const char* label, int v[2], const ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_S32, v, 2, NULL, NULL, "%d", flags); } -bool ImGui::InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags) +bool ImGui::InputInt3(const char* label, int v[3], const ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_S32, v, 3, NULL, NULL, "%d", flags); } -bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags) +bool ImGui::InputInt4(const char* label, int v[4], const ImGuiInputTextFlags flags) { return InputScalarN(label, ImGuiDataType_S32, v, 4, NULL, NULL, "%d", flags); } @@ -3080,18 +3087,18 @@ bool ImGui::InputDouble(const char* label, double* v, double step, double step_f // - InputTextEx() [Internal] //------------------------------------------------------------------------- -bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +bool ImGui::InputText(const char* label, char* buf, const size_t buf_size, const ImGuiInputTextFlags flags, const ImGuiInputTextCallback callback, void* user_data) { IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() return InputTextEx(label, NULL, buf, (int)buf_size, ImVec2(0,0), flags, callback, user_data); } -bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +bool ImGui::InputTextMultiline(const char* label, char* buf, const size_t buf_size, const ImVec2& size, const ImGuiInputTextFlags flags, const ImGuiInputTextCallback callback, void* user_data) { return InputTextEx(label, NULL, buf, (int)buf_size, size, flags | ImGuiInputTextFlags_Multiline, callback, user_data); } -bool ImGui::InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +bool ImGui::InputTextWithHint(const char* label, const char* hint, char* buf, const size_t buf_size, const ImGuiInputTextFlags flags, const ImGuiInputTextCallback callback, void* user_data) { IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() return InputTextEx(label, hint, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data); @@ -3111,7 +3118,7 @@ static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** return line_count; } -static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, bool stop_on_new_line) +static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, const bool stop_on_new_line) { const ImGuiContext & g = *GImGui; const ImFont * font = g.Font; @@ -3161,13 +3168,13 @@ namespace ImStb { static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; } -static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->TextW[idx]; } -static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { +static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, const int idx) { return obj->TextW[idx]; } +static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, const int line_start_idx, const int char_idx) { const ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; const ImGuiContext & g = *GImGui; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); } -static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x10000 ? 0 : key; } +static int STB_TEXTEDIT_KEYTOTEXT(const int key) { return key >= 0x10000 ? 0 : key; } static ImWchar STB_TEXTEDIT_NEWLINE = '\n'; -static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx) +static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, const int line_start_idx) { const ImWchar* text = obj->TextW.Data; const ImWchar* text_remaining = NULL; @@ -3180,8 +3187,8 @@ static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* ob r->num_chars = (int)(text_remaining - (text + line_start_idx)); } -static bool is_separator(unsigned int c) { return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } -static int is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (is_separator( obj->TextW[idx-1] ) && !is_separator( obj->TextW[idx] ) ) : 1; } +static bool is_separator(const unsigned int c) { return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } +static int is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, const int idx) { return idx > 0 ? (is_separator( obj->TextW[idx-1] ) && !is_separator( obj->TextW[idx] ) ) : 1; } static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) { idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; } #ifdef __APPLE__ // FIXME: Move setting to IO structure static int is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx) { return idx > 0 ? (!is_separator( obj->TextW[idx-1] ) && is_separator( obj->TextW[idx] ) ) : 1; } @@ -3193,7 +3200,7 @@ static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx) #define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h #define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL -static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) +static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, const int pos, const int n) { ImWchar* dst = obj->TextW.Data + pos; @@ -3208,7 +3215,7 @@ static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) *dst = '\0'; } -static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len) +static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, const int pos, const ImWchar* new_text, const int new_text_len) { const bool is_resizable = (obj->UserFlags & ImGuiInputTextFlags_CallbackResize) != 0; const int text_len = obj->CurLenW; @@ -3261,7 +3268,7 @@ static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const Im } -void ImGuiInputTextState::OnKeyPressed(int key) +void ImGuiInputTextState::OnKeyPressed(const int key) { stb_textedit_key(this, &Stb, key); CursorFollow = true; @@ -3276,7 +3283,7 @@ ImGuiInputTextCallbackData::ImGuiInputTextCallbackData() // Public API to manipulate UTF-8 text // We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar) // FIXME: The existence of this rarely exercised code path is a bit of a nuisance. -void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count) +void ImGuiInputTextCallbackData::DeleteChars(const int pos, const int bytes_count) { IM_ASSERT(pos + bytes_count <= BufTextLen); char* dst = Buf + pos; @@ -3294,7 +3301,7 @@ void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count) BufTextLen -= bytes_count; } -void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end) +void ImGuiInputTextCallbackData::InsertChars(const int pos, const char* new_text, const char* new_text_end) { const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0; const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text); @@ -3327,7 +3334,7 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons } // Return false to discard a character. -static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) +static bool InputTextFilterCharacter(unsigned int* p_char, const ImGuiInputTextFlags flags, const ImGuiInputTextCallback callback, void* user_data) { unsigned int c = *p_char; @@ -4161,7 +4168,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ // - ColorPickerOptionsPopup() [Internal] //------------------------------------------------------------------------- -bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags) +bool ImGui::ColorEdit3(const char* label, float col[3], const ImGuiColorEditFlags flags) { return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha); } @@ -4400,7 +4407,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag return value_changed; } -bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags) +bool ImGui::ColorPicker3(const char* label, float col[3], const ImGuiColorEditFlags flags) { float col4[4] = { col[0], col[1], col[2], 1.0f }; if (!ColorPicker4(label, col4, flags | ImGuiColorEditFlags_NoAlpha)) @@ -4409,7 +4416,7 @@ bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags fl return true; } -static inline ImU32 ImAlphaBlendColor(ImU32 col_a, ImU32 col_b) +static inline ImU32 ImAlphaBlendColor(const ImU32 col_a, const ImU32 col_b) { const float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f; const int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t); @@ -4421,7 +4428,8 @@ static inline ImU32 ImAlphaBlendColor(ImU32 col_a, ImU32 col_b) // Helper for ColorPicker4() // NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that. // I spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether. -void ImGui::RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags) +void ImGui::RenderColorRectWithAlphaCheckerboard(const ImVec2 p_min, const ImVec2 p_max, const ImU32 col, const float grid_step, const ImVec2 grid_off, const float rounding, + const int rounding_corners_flags) { const ImGuiWindow * window = GetCurrentWindow(); if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF) @@ -4456,7 +4464,7 @@ void ImGui::RenderColorRectWithAlphaCheckerboard(ImVec2 p_min, ImVec2 p_max, ImU } // Helper for ColorPicker4() -static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w, float alpha) +static void RenderArrowsForVerticalBar(ImDrawList* draw_list, const ImVec2 pos, const ImVec2 half_sz, const float bar_w, const float alpha) { const ImU32 alpha8 = IM_F32_TO_INT8_SAT(alpha); ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32(0,0,0,alpha8)); @@ -4933,7 +4941,7 @@ void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags) } // Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. -void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags) +void ImGui::ColorTooltip(const char* text, const float* col, const ImGuiColorEditFlags flags) { const ImGuiContext & g = *GImGui; @@ -4967,7 +4975,7 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags EndTooltip(); } -void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags) +void ImGui::ColorEditOptionsPopup(const float* col, const ImGuiColorEditFlags flags) { const bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__DisplayMask); const bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask); @@ -5015,7 +5023,7 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags) EndPopup(); } -void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags) +void ImGui::ColorPickerOptionsPopup(const float* ref_col, const ImGuiColorEditFlags flags) { const bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask); const bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar); @@ -5094,17 +5102,17 @@ bool ImGui::TreeNode(const char* label) return TreeNodeBehavior(window->GetID(label), 0, label, NULL); } -bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args) +bool ImGui::TreeNodeV(const char* str_id, const char* fmt, const va_list args) { return TreeNodeExV(str_id, 0, fmt, args); } -bool ImGui::TreeNodeV(const void* ptr_id, const char* fmt, va_list args) +bool ImGui::TreeNodeV(const void* ptr_id, const char* fmt, const va_list args) { return TreeNodeExV(ptr_id, 0, fmt, args); } -bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags) +bool ImGui::TreeNodeEx(const char* label, const ImGuiTreeNodeFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -5113,7 +5121,7 @@ bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags) return TreeNodeBehavior(window->GetID(label), flags, label, NULL); } -bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) +bool ImGui::TreeNodeEx(const char* str_id, const ImGuiTreeNodeFlags flags, const char* fmt, ...) { va_list args; va_start(args, fmt); @@ -5122,7 +5130,7 @@ bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* return is_open; } -bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) +bool ImGui::TreeNodeEx(const void* ptr_id, const ImGuiTreeNodeFlags flags, const char* fmt, ...) { va_list args; va_start(args, fmt); @@ -5131,7 +5139,7 @@ bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* return is_open; } -bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) +bool ImGui::TreeNodeExV(const char* str_id, const ImGuiTreeNodeFlags flags, const char* fmt, const va_list args) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -5142,7 +5150,7 @@ bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end); } -bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) +bool ImGui::TreeNodeExV(const void* ptr_id, const ImGuiTreeNodeFlags flags, const char* fmt, const va_list args) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -5153,7 +5161,7 @@ bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end); } -bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) +bool ImGui::TreeNodeBehaviorIsOpen(const ImGuiID id, const ImGuiTreeNodeFlags flags) { if (flags & ImGuiTreeNodeFlags_Leaf) return true; @@ -5199,7 +5207,7 @@ bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) return is_open; } -bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end) +bool ImGui::TreeNodeBehavior(const ImGuiID id, const ImGuiTreeNodeFlags flags, const char* label, const char* label_end) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -5387,7 +5395,7 @@ void ImGui::TreePush(const void* ptr_id) PushID(ptr_id ? ptr_id : (const void*)"#TreePush"); } -void ImGui::TreePushOverrideID(ImGuiID id) +void ImGui::TreePushOverrideID(const ImGuiID id) { ImGuiWindow* window = GetCurrentWindow(); Indent(); @@ -5425,7 +5433,7 @@ float ImGui::GetTreeNodeToLabelSpacing() } // Set next TreeNode/CollapsingHeader open state. -void ImGui::SetNextItemOpen(bool is_open, ImGuiCond cond) +void ImGui::SetNextItemOpen(const bool is_open, const ImGuiCond cond) { ImGuiContext& g = *GImGui; if (g.CurrentWindow->SkipItems) @@ -5437,7 +5445,7 @@ void ImGui::SetNextItemOpen(bool is_open, ImGuiCond cond) // CollapsingHeader returns true when opened but do not indent nor push into the ID stack (because of the ImGuiTreeNodeFlags_NoTreePushOnOpen flag). // This is basically the same as calling TreeNodeEx(label, ImGuiTreeNodeFlags_CollapsingHeader). You can remove the _NoTreePushOnOpen flag if you want behavior closer to normal TreeNode(). -bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) +bool ImGui::CollapsingHeader(const char* label, const ImGuiTreeNodeFlags flags) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -5484,7 +5492,7 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags // Tip: pass a non-visible label (e.g. "##dummy") then you can use the space to draw other text or image. // But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id. -bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) +bool ImGui::Selectable(const char* label, bool selected, const ImGuiSelectableFlags flags, const ImVec2& size_arg) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -5605,7 +5613,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl return pressed; } -bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) +bool ImGui::Selectable(const char* label, bool* p_selected, const ImGuiSelectableFlags flags, const ImVec2& size_arg) { if (Selectable(label, *p_selected, flags, size_arg)) { @@ -5664,7 +5672,7 @@ bool ImGui::ListBoxHeader(const char* label, const ImVec2& size_arg) } // FIXME: In principle this function should be called EndListBox(). We should rename it after re-evaluating if we want to keep the same signature. -bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items) +bool ImGui::ListBoxHeader(const char* label, const int items_count, int height_in_items) { // Size default to hold ~7.25 items. // We add +25% worth of item height to allow the user to see at a glance if there are more items up/down, without looking at the scrollbar. @@ -5699,13 +5707,13 @@ void ImGui::ListBoxFooter() EndGroup(); } -bool ImGui::ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_items) +bool ImGui::ListBox(const char* label, int* current_item, const char* const items[], const int items_count, const int height_items) { const bool value_changed = ListBox(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_items); return value_changed; } -bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items) +bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, const int items_count, const int height_in_items) { if (!ListBoxHeader(label, items_count, height_in_items)) return false; @@ -5747,7 +5755,7 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v // - PlotHistogram() //------------------------------------------------------------------------- -void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size) +void ImGui::PlotEx(const ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, const int values_count, const int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -5866,34 +5874,38 @@ struct ImGuiPlotArrayGetterData const float* Values; int Stride; - ImGuiPlotArrayGetterData(const float* values, int stride) { Values = values; Stride = stride; } + ImGuiPlotArrayGetterData(const float* values, const int stride) { Values = values; Stride = stride; } }; -static float Plot_ArrayGetter(void* data, int idx) +static float Plot_ArrayGetter(void* data, const int idx) { const auto plot_data = (ImGuiPlotArrayGetterData*)data; const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride); return v; } -void ImGui::PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) +void ImGui::PlotLines(const char* label, const float* values, const int values_count, const int values_offset, const char* overlay_text, const float scale_min, const float scale_max, + const ImVec2 graph_size, const int stride) { ImGuiPlotArrayGetterData data(values, stride); PlotEx(ImGuiPlotType_Lines, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } -void ImGui::PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) +void ImGui::PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, const int values_count, const int values_offset, const char* overlay_text, const float scale_min, + const float scale_max, const ImVec2 graph_size) { PlotEx(ImGuiPlotType_Lines, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } -void ImGui::PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) +void ImGui::PlotHistogram(const char* label, const float* values, const int values_count, const int values_offset, const char* overlay_text, const float scale_min, const float scale_max, + const ImVec2 graph_size, const int stride) { ImGuiPlotArrayGetterData data(values, stride); PlotEx(ImGuiPlotType_Histogram, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } -void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) +void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, const int values_count, const int values_offset, const char* overlay_text, const float scale_min, + const float scale_max, const ImVec2 graph_size) { PlotEx(ImGuiPlotType_Histogram, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); } @@ -5905,22 +5917,22 @@ void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, // - Value() //------------------------------------------------------------------------- -void ImGui::Value(const char* prefix, bool b) +void ImGui::Value(const char* prefix, const bool b) { Text("%s: %s", prefix, (b ? "true" : "false")); } -void ImGui::Value(const char* prefix, int v) +void ImGui::Value(const char* prefix, const int v) { Text("%s: %d", prefix, v); } -void ImGui::Value(const char* prefix, unsigned int v) +void ImGui::Value(const char* prefix, const unsigned int v) { Text("%s: %d", prefix, v); } -void ImGui::Value(const char* prefix, float v, const char* float_format) +void ImGui::Value(const char* prefix, const float v, const char* float_format) { if (float_format) { @@ -5955,7 +5967,7 @@ ImGuiMenuColumns::ImGuiMenuColumns() memset(NextWidths, 0, sizeof(NextWidths)); } -void ImGuiMenuColumns::Update(int count, float spacing, bool clear) +void ImGuiMenuColumns::Update(const int count, const float spacing, const bool clear) { IM_ASSERT(count == IM_ARRAYSIZE(Pos)); IM_UNUSED(count); @@ -5973,7 +5985,7 @@ void ImGuiMenuColumns::Update(int count, float spacing, bool clear) } } -float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using va_arg because they promote float to double +float ImGuiMenuColumns::DeclColumns(const float w0, const float w1, const float w2) // not using va_arg because they promote float to double { NextWidth = 0.0f; NextWidths[0] = ImMax(NextWidths[0], w0); @@ -5984,7 +5996,7 @@ float ImGuiMenuColumns::DeclColumns(float w0, float w1, float w2) // not using v return ImMax(Width, NextWidth); } -float ImGuiMenuColumns::CalcExtraSpace(float avail_w) +float ImGuiMenuColumns::CalcExtraSpace(const float avail_w) { return ImMax(0.0f, avail_w - Width); } @@ -6096,7 +6108,7 @@ void ImGui::EndMenuBar() window->DC.MenuBarAppending = false; } -bool ImGui::BeginMenu(const char* label, bool enabled) +bool ImGui::BeginMenu(const char* label, const bool enabled) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -6255,7 +6267,7 @@ void ImGui::EndMenu() EndPopup(); } -bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled) +bool ImGui::MenuItem(const char* label, const char* shortcut, const bool selected, const bool enabled) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) @@ -6301,7 +6313,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo return pressed; } -bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled) +bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, const bool enabled) { if (MenuItem(label, shortcut, p_selected ? *p_selected : false, enabled)) { @@ -6381,7 +6393,7 @@ static ImGuiPtrOrIndex GetTabBarRefFromTabBar(ImGuiTabBar* tab_bar) return ImGuiPtrOrIndex(tab_bar); } -bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags) +bool ImGui::BeginTabBar(const char* str_id, const ImGuiTabBarFlags flags) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; @@ -6670,7 +6682,7 @@ static float ImGui::TabBarCalcMaxTabWidth() return g.FontSize * 20.0f; } -ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id) +ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, const ImGuiID tab_id) { if (tab_id != 0) for (int n = 0; n < tab_bar->Tabs.Size; n++) @@ -6680,7 +6692,7 @@ ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id) } // The *TabId fields be already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. -void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id) +void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, const ImGuiID tab_id) { if (const ImGuiTabItem * tab = TabBarFindTabByID(tab_bar, tab_id)) tab_bar->Tabs.erase(tab); @@ -6732,7 +6744,7 @@ static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) } } -void ImGui::TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int dir) +void ImGui::TabBarQueueChangeTabOrder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, const int dir) { IM_ASSERT(dir == -1 || dir == +1); IM_ASSERT(tab_bar->ReorderRequestTabId == 0); @@ -6844,7 +6856,7 @@ static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar) // - TabItemLabelAndCloseButton() [Internal] //------------------------------------------------------------------------- -bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags flags) +bool ImGui::BeginTabItem(const char* label, bool* p_open, const ImGuiTabItemFlags flags) { const ImGuiContext & g = *GImGui; const ImGuiWindow * window = g.CurrentWindow; @@ -7095,7 +7107,7 @@ void ImGui::SetTabItemClosed(const char* label) } } -ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button) +ImVec2 ImGui::TabItemCalcSize(const char* label, const bool has_close_button) { const ImGuiContext & g = *GImGui; const ImVec2 label_size = CalcTextSize(label, NULL, true); @@ -7107,7 +7119,7 @@ ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button) return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y); } -void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col) +void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, const ImGuiTabItemFlags flags, const ImU32 col) { // While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it. const ImGuiContext & g = *GImGui; @@ -7134,7 +7146,8 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI // Render text label (with custom clipping) + Unsaved Document marker + Close Button logic // We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter. -bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id) +bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, const ImGuiTabItemFlags flags, const ImVec2 frame_padding, const char* label, const ImGuiID tab_id, + const ImGuiID close_button_id) { const ImGuiContext & g = *GImGui; const ImVec2 label_size = CalcTextSize(label, NULL, true); @@ -7219,19 +7232,19 @@ int ImGui::GetColumnsCount() return window->DC.CurrentColumns ? window->DC.CurrentColumns->Count : 1; } -float ImGui::GetColumnOffsetFromNorm(const ImGuiColumns* columns, float offset_norm) +float ImGui::GetColumnOffsetFromNorm(const ImGuiColumns* columns, const float offset_norm) { return offset_norm * (columns->OffMaxX - columns->OffMinX); } -float ImGui::GetColumnNormFromOffset(const ImGuiColumns* columns, float offset) +float ImGui::GetColumnNormFromOffset(const ImGuiColumns* columns, const float offset) { return offset / (columns->OffMaxX - columns->OffMinX); } static constexpr float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f; -static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index) +static float GetDraggedColumnOffset(ImGuiColumns* columns, const int column_index) { // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning. @@ -7264,7 +7277,7 @@ float ImGui::GetColumnOffset(int column_index) return x_offset; } -static float GetColumnWidthEx(ImGuiColumns* columns, int column_index, bool before_resize = false) +static float GetColumnWidthEx(ImGuiColumns* columns, int column_index, const bool before_resize = false) { if (column_index < 0) column_index = columns->Current; @@ -7312,7 +7325,7 @@ void ImGui::SetColumnOffset(int column_index, float offset) SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width)); } -void ImGui::SetColumnWidth(int column_index, float width) +void ImGui::SetColumnWidth(int column_index, const float width) { const ImGuiWindow * window = GetCurrentWindowRead(); const ImGuiColumns * columns = window->DC.CurrentColumns; @@ -7358,7 +7371,7 @@ void ImGui::PopColumnsBackground() PopClipRect(); } -ImGuiColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id) +ImGuiColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, const ImGuiID id) { // We have few columns per window so for now we don't need bother much with turning this into a faster lookup. for (int n = 0; n < window->ColumnsStorage.Size; n++) @@ -7371,7 +7384,7 @@ ImGuiColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id) return columns; } -ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count) +ImGuiID ImGui::GetColumnsID(const char* str_id, const int columns_count) { ImGuiWindow* window = GetCurrentWindow(); @@ -7384,7 +7397,7 @@ ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count) return id; } -void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlags flags) +void ImGui::BeginColumns(const char* str_id, const int columns_count, const ImGuiColumnsFlags flags) { const ImGuiContext & g = *GImGui; ImGuiWindow* window = GetCurrentWindow(); @@ -7587,7 +7600,7 @@ void ImGui::EndColumns() } // [2018-03: This is currently the only public API, while we are working on making BeginColumns/EndColumns user-facing] -void ImGui::Columns(int columns_count, const char* id, bool border) +void ImGui::Columns(const int columns_count, const char* id, const bool border) { const ImGuiWindow * window = GetCurrentWindow(); IM_ASSERT(columns_count >= 1); @@ -7609,7 +7622,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border) // by zfedoran, https://github.com/ocornut/imgui/issues/1901 -bool ImGui::BufferingBar( const char* label, float value, const ImVec2& size_arg, const ImU32& bg_col, const ImU32& fg_col ) { +bool ImGui::BufferingBar( const char* label, const float value, const ImVec2& size_arg, const ImU32& bg_col, const ImU32& fg_col ) { ImGuiWindow* window = GetCurrentWindow(); if( window->SkipItems ) return false; @@ -7654,7 +7667,7 @@ bool ImGui::BufferingBar( const char* label, float value, const ImVec2& size_arg return true; } -bool ImGui::Spinner( const char* label, float radius, int thickness, const ImU32& color ) { +bool ImGui::Spinner( const char* label, const float radius, const int thickness, const ImU32& color ) { ImGuiWindow* window = GetCurrentWindow(); if( window->SkipItems ) return false; diff --git a/imgui/imstb_rectpack.h b/imgui/imstb_rectpack.h index ac73806b..8e2d89e6 100644 --- a/imgui/imstb_rectpack.h +++ b/imgui/imstb_rectpack.h @@ -227,7 +227,7 @@ enum STBRP__INIT_skyline = 1 }; -STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) +STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, const int heuristic) { switch (context->init_mode) { case STBRP__INIT_skyline: @@ -239,7 +239,7 @@ STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) } } -STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) +STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, const int allow_out_of_mem) { if (allow_out_of_mem) // if it's ok to run out of memory, then don't bother aligning them; @@ -259,7 +259,7 @@ STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_ou } } -STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) +STBRP_DEF void stbrp_init_target(stbrp_context *context, const int width, const int height, stbrp_node *nodes, const int num_nodes) { int i; #ifndef STBRP_LARGE_RECTS @@ -292,7 +292,7 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, } // find minimum y position if it starts at x1 -static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) +static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, const int x0, const int width, int *pwaste) { const stbrp_node *node = first; const int x1 = x0 + width; @@ -348,7 +348,7 @@ typedef struct stbrp_node **prev_link; } stbrp__findresult; -static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) +static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, const int height) { int best_waste = (1<<30), best_x, best_y = (1 << 30); stbrp__findresult fr; @@ -450,7 +450,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt return fr; } -static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) +static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, const int width, const int height) { // find best position according to heuristic stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); @@ -555,7 +555,7 @@ static int STBRP__CDECL rect_original_order(const void *a, const void *b) #define STBRP__MAXVAL 0xffff #endif -STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) +STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, const int num_rects) { int i, all_rects_packed = 1; diff --git a/imgui/imstb_truetype.h b/imgui/imstb_truetype.h index a49c88bb..cbfc73a1 100644 --- a/imgui/imstb_truetype.h +++ b/imgui/imstb_truetype.h @@ -1127,18 +1127,18 @@ static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) return b->data[b->cursor]; } -static void stbtt__buf_seek(stbtt__buf *b, int o) +static void stbtt__buf_seek(stbtt__buf *b, const int o) { STBTT_assert(!(o > b->size || o < 0)); b->cursor = (o > b->size || o < 0) ? b->size : o; } -static void stbtt__buf_skip(stbtt__buf *b, int o) +static void stbtt__buf_skip(stbtt__buf *b, const int o) { stbtt__buf_seek(b, b->cursor + o); } -static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) +static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, const int n) { stbtt_uint32 v = 0; int i; @@ -1148,7 +1148,7 @@ static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) return v; } -static stbtt__buf stbtt__new_buf(const void *p, size_t size) +static stbtt__buf stbtt__new_buf(const void *p, const size_t size) { stbtt__buf r; STBTT_assert(size < 0x40000000); @@ -1161,7 +1161,7 @@ static stbtt__buf stbtt__new_buf(const void *p, size_t size) #define stbtt__buf_get16(b) stbtt__buf_get((b), 2) #define stbtt__buf_get32(b) stbtt__buf_get((b), 4) -static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) +static stbtt__buf stbtt__buf_range(const stbtt__buf *b, const int o, const int s) { stbtt__buf r = stbtt__new_buf(NULL, 0); if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; @@ -1221,7 +1221,7 @@ static void stbtt__cff_skip_operand(stbtt__buf *b) { } } -static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) +static stbtt__buf stbtt__dict_get(stbtt__buf *b, const int key) { stbtt__buf_seek(b, 0); while (b->cursor < b->size) { @@ -1236,7 +1236,7 @@ static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) return stbtt__buf_range(b, 0, 0); } -static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) +static void stbtt__dict_get_ints(stbtt__buf *b, const int key, const int outcount, stbtt_uint32 *out) { int i; stbtt__buf operands = stbtt__dict_get(b, key); @@ -1250,7 +1250,7 @@ static int stbtt__cff_index_count(stbtt__buf *b) return stbtt__buf_get16(b); } -static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) +static stbtt__buf stbtt__cff_index_get(stbtt__buf b, const int i) { int count, offsize, start, end; stbtt__buf_seek(&b, 0); @@ -1296,7 +1296,7 @@ static int stbtt__isfont(stbtt_uint8 *font) } // @OPTIMIZE: binary search -static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) +static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, const stbtt_uint32 fontstart, const char *tag) { const stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); const stbtt_uint32 tabledir = fontstart + 12; @@ -1309,7 +1309,7 @@ static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, return 0; } -static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) +static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, const int index) { // if it's just a font, there's only one valid index if (stbtt__isfont(font_collection)) @@ -1357,7 +1357,7 @@ static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) return stbtt__cff_get_index(&cff); } -static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) +static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, const int fontstart) { stbtt_uint32 cmap, t; stbtt_int32 i,numTables; @@ -1468,7 +1468,7 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in return 1; } -STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) +STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, const int unicode_codepoint) { stbtt_uint8 *data = info->data; const stbtt_uint32 index_map = info->index_map; @@ -1578,12 +1578,12 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep return 0; } -STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) +STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, const int unicode_codepoint, stbtt_vertex **vertices) { return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); } -static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) +static void stbtt_setvertex(stbtt_vertex *v, const stbtt_uint8 type, const stbtt_int32 x, const stbtt_int32 y, const stbtt_int32 cx, const stbtt_int32 cy) { v->type = type; v->x = (stbtt_int16) x; @@ -1592,7 +1592,7 @@ static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, st v->cy = (stbtt_int16) cy; } -static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) +static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, const int glyph_index) { int g1,g2; @@ -1614,7 +1614,7 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); -STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, const int glyph_index, int *x0, int *y0, int *x1, int *y1) { if (info->cff.size) { stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); @@ -1630,12 +1630,12 @@ STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int return 1; } -STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) +STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, const int codepoint, int *x0, int *y0, int *x1, int *y1) { return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); } -STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) +STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, const int glyph_index) { stbtt_int16 numberOfContours; int g; @@ -1647,8 +1647,8 @@ STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) return numberOfContours == 0; } -static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, - stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) +static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, const int was_off, const int start_off, const stbtt_int32 sx, const stbtt_int32 sy, const stbtt_int32 scx, + const stbtt_int32 scy, const stbtt_int32 cx, const stbtt_int32 cy) { if (start_off) { if (was_off) @@ -1903,7 +1903,7 @@ typedef struct #define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} -static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) +static void stbtt__track_vertex(stbtt__csctx *c, const stbtt_int32 x, const stbtt_int32 y) { if (x > c->max_x || !c->started) c->max_x = x; if (y > c->max_y || !c->started) c->max_y = y; @@ -1912,7 +1912,7 @@ static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) c->started = 1; } -static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) +static void stbtt__csctx_v(stbtt__csctx *c, const stbtt_uint8 type, const stbtt_int32 x, const stbtt_int32 y, const stbtt_int32 cx, const stbtt_int32 cy, const stbtt_int32 cx1, const stbtt_int32 cy1) { if (c->bounds) { stbtt__track_vertex(c, x, y); @@ -1934,7 +1934,7 @@ static void stbtt__csctx_close_shape(stbtt__csctx *ctx) stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); } -static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) +static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, const float dx, const float dy) { stbtt__csctx_close_shape(ctx); ctx->first_x = ctx->x = ctx->x + dx; @@ -1942,14 +1942,14 @@ static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } -static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) +static void stbtt__csctx_rline_to(stbtt__csctx *ctx, const float dx, const float dy) { ctx->x += dx; ctx->y += dy; stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } -static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) +static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, const float dx1, const float dy1, const float dx2, const float dy2, const float dx3, const float dy3) { const float cx1 = ctx->x + dx1; const float cy1 = ctx->y + dy1; @@ -1974,7 +1974,7 @@ static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) return stbtt__cff_index_get(idx, n); } -static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) +static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, const int glyph_index) { stbtt__buf fdselect = info->fdselect; int nranges, start, end, v, fmt, fdselector = -1, i; @@ -2261,7 +2261,7 @@ static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, st #undef STBTT__CSERR } -static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, const int glyph_index, stbtt_vertex **pvertices) { // runs the charstring twice, once to count and once to output (to avoid realloc) stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); @@ -2278,7 +2278,7 @@ static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, s return 0; } -static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, const int glyph_index, int *x0, int *y0, int *x1, int *y1) { stbtt__csctx c = STBTT__CSCTX_INIT(1); const int r = stbtt__run_charstring(info, glyph_index, &c); @@ -2289,7 +2289,7 @@ static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, in return r ? c.num_vertices : 0; } -STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, const int glyph_index, stbtt_vertex **pvertices) { if (!info->cff.size) return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); @@ -2297,7 +2297,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); } -STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) +STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, const int glyph_index, int *advanceWidth, int *leftSideBearing) { const stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); if (glyph_index < numOfLongHorMetrics) { @@ -2309,7 +2309,7 @@ STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_inde } } -static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, const int glyph1, const int glyph2) { stbtt_uint8 *data = info->data + info->kern; stbtt_uint32 needle, straw; @@ -2339,7 +2339,7 @@ static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph return 0; } -static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) +static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, const int glyph) { const stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); switch(coverageFormat) { @@ -2398,7 +2398,7 @@ static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyp return -1; } -static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) +static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, const int glyph) { const stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); switch(classDefFormat) @@ -2452,7 +2452,7 @@ static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) // Define to STBTT_assert(x) if you want to break on unimplemented formats. #define STBTT_GPOS_TODO_assert(x) -static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) +static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, const int glyph1, const int glyph2) { stbtt_uint16 lookupListOffset; stbtt_uint8 *lookupList; @@ -2580,7 +2580,7 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, i return 0; } -STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) +STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, const int g1, const int g2) { int xAdvance = 0; @@ -2593,14 +2593,14 @@ STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int return xAdvance; } -STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) +STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, const int ch1, const int ch2) { if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs return 0; return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); } -STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) +STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, const int codepoint, int *advanceWidth, int *leftSideBearing) { stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); } @@ -2631,13 +2631,13 @@ STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y1 = ttSHORT(info->data + info->head + 42); } -STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) +STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, const float height) { const int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); return (float) height / fheight; } -STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) +STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, const float pixels) { const int unitsPerEm = ttUSHORT(info->data + info->head + 18); return pixels / unitsPerEm; @@ -2653,7 +2653,7 @@ STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) // antialiasing software rasterizer // -STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, const int glyph, const float scale_x, const float scale_y, const float shift_x, const float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { @@ -2671,17 +2671,17 @@ STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int g } } -STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, const int glyph, const float scale_x, const float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); } -STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) +STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, const int codepoint, const float scale_x, const float scale_y, const float shift_x, const float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); } -STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) +STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, const int codepoint, const float scale_x, const float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); } @@ -2702,7 +2702,7 @@ typedef struct stbtt__hheap int num_remaining_in_head_chunk; } stbtt__hheap; -static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) +static void *stbtt__hheap_alloc(stbtt__hheap *hh, const size_t size, void *userdata) { if (hh->first_free) { void *p = hh->first_free; @@ -2789,7 +2789,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i return z; } #elif STBTT_RASTERIZER_VERSION == 2 -static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) +static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, const float start_point, void *userdata) { auto z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); @@ -2960,7 +2960,7 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, // the edge passed in here does not cross the vertical line at x or the vertical line at x+1 // (i.e. it has already been clipped to those) -static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) +static void stbtt__handle_clipped_edge(float *scanline, const int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) { if (y0 == y1) return; STBTT_assert(y0 < y1); @@ -2997,7 +2997,7 @@ static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edg } } -static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) +static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, const int len, stbtt__active_edge *e, const float y_top) { const float y_bottom = y_top+1; @@ -3161,7 +3161,7 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, } // directly AA rasterize edges w/o supersampling -static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) +static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, const int n, const int vsubsample, const int off_x, const int off_y, void *userdata) { stbtt__hheap hh = { 0, 0, 0 }; stbtt__active_edge *active = NULL; @@ -3263,7 +3263,7 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, #define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) -static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) +static void stbtt__sort_edges_ins_sort(stbtt__edge *p, const int n) { int i,j; for (i=1; i < n; ++i) { @@ -3343,7 +3343,7 @@ static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) } } -static void stbtt__sort_edges(stbtt__edge *p, int n) +static void stbtt__sort_edges(stbtt__edge *p, const int n) { stbtt__sort_edges_quicksort(p, n); stbtt__sort_edges_ins_sort(p, n); @@ -3354,7 +3354,8 @@ typedef struct float x,y; } stbtt__point; -static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) +static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, const int windings, const float scale_x, const float scale_y, const float shift_x, const float shift_y, + const int off_x, const int off_y, const int invert, void *userdata) { const float y_scale_inv = invert ? -scale_y : scale_y; stbtt__edge *e; @@ -3411,7 +3412,7 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou STBTT_free(e, userdata); } -static void stbtt__add_point(stbtt__point *points, int n, float x, float y) +static void stbtt__add_point(stbtt__point *points, const int n, const float x, const float y) { if (!points) return; // during first pass, it's unallocated points[n].x = x; @@ -3419,7 +3420,8 @@ static void stbtt__add_point(stbtt__point *points, int n, float x, float y) } // tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching -static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) +static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, const float x0, const float y0, const float x1, const float y1, const float x2, const float y2, + const float objspace_flatness_squared, const int n) { // midpoint const float mx = (x0 + 2*x1 + x2)/4; @@ -3439,7 +3441,8 @@ static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x return 1; } -static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) +static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, const float x0, const float y0, const float x1, const float y1, const float x2, const float y2, const float x3, + const float y3, const float objspace_flatness_squared, const int n) { // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough const float dx0 = x1-x0; @@ -3482,7 +3485,7 @@ static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float } // returns number of contours -static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) +static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, const int num_verts, const float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) { stbtt__point *points=0; int num_points=0; @@ -3559,7 +3562,8 @@ error: return NULL; } -STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) +STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, const float flatness_in_pixels, stbtt_vertex *vertices, const int num_verts, const float scale_x, const float scale_y, const float shift_x, + const float shift_y, const int x_off, const int y_off, const int invert, void *userdata) { const float scale = scale_x > scale_y ? scale_y : scale_x; int winding_count = 0; @@ -3577,7 +3581,7 @@ STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) STBTT_free(bitmap, userdata); } -STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) +STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, const float shift_x, const float shift_y, const int glyph, int *width, int *height, int *xoff, int *yoff) { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; @@ -3617,12 +3621,13 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info return gbm.pixels; } -STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) +STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, const float scale_x, const float scale_y, const int glyph, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); } -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y, + const float shift_x, const float shift_y, const int glyph) { int ix0,iy0; stbtt_vertex *vertices; @@ -3641,32 +3646,37 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne STBTT_free(vertices, info->userdata); } -STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) +STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y, + const int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); } -STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, const float scale_x, const float scale_y, const float shift_x, const float shift_y, const int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); } -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, + const float scale_y, const float shift_x, const float shift_y, const int oversample_x, const int oversample_y, float *sub_x, float *sub_y, + const int codepoint) { stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); } -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y, + const float shift_x, const float shift_y, const int codepoint) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); } -STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) +STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, const float scale_x, const float scale_y, const int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); } -STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) +STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, const float scale_y, + const int codepoint) { stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); } @@ -3677,10 +3687,10 @@ STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned ch // // This is SUPER-CRAPPY packing to keep source code small -static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) - float pixel_height, // height of font in pixels - unsigned char *pixels, int pw, int ph, // bitmap to be filled in - int first_char, int num_chars, // characters to bake +static int stbtt_BakeFontBitmap_internal(unsigned char *data, const int offset, // font location (use offset=0 for plain .ttf) + const float pixel_height, // height of font in pixels + unsigned char *pixels, const int pw, const int ph, // bitmap to be filled in + const int first_char, const int num_chars, // characters to bake stbtt_bakedchar *chardata) { float scale; @@ -3723,7 +3733,7 @@ static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // fo return bottom_y; } -STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, const int pw, const int ph, const int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, const int opengl_fillrule) { const float d3d_bias = opengl_fillrule ? 0 : -0.5f; float ipw = 1.0f / pw, iph = 1.0f / ph; @@ -3821,7 +3831,7 @@ static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rect // This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If // stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. -STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) +STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, const int pw, const int ph, const int stride_in_bytes, const int padding, void *alloc_context) { auto context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); int num_nodes = pw - padding; @@ -3859,7 +3869,7 @@ STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) STBTT_free(spc->pack_info, spc->user_allocator_context); } -STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) +STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, const unsigned int h_oversample, const unsigned int v_oversample) { STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); @@ -3869,14 +3879,14 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h spc->v_oversample = v_oversample; } -STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip) +STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, const int skip) { spc->skip_missing = skip; } #define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) -static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +static void stbtt__h_prefilter(unsigned char *pixels, const int w, const int h, const int stride_in_bytes, const unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; const int safe_w = w - kernel_width; @@ -3938,7 +3948,7 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_i } } -static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) +static void stbtt__v_prefilter(unsigned char *pixels, const int w, const int h, const int stride_in_bytes, const unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; const int safe_h = h - kernel_width; @@ -4000,7 +4010,7 @@ static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_i } } -static float stbtt__oversample_shift(int oversample) +static float stbtt__oversample_shift(const int oversample) { if (!oversample) return 0.0f; @@ -4013,7 +4023,7 @@ static float stbtt__oversample_shift(int oversample) } // rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, const int num_ranges, stbrp_rect *rects) { int i,j,k; @@ -4045,7 +4055,9 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stb return k; } -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, const int out_w, const int out_h, const int out_stride, const float scale_x, + const float scale_y, const float shift_x, const float shift_y, const int prefilter_x, const int prefilter_y, float *sub_x, float *sub_y, + const int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, @@ -4069,7 +4081,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info } // rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, const int num_ranges, stbrp_rect *rects) { int i,j,k, return_value = 1; @@ -4151,12 +4163,12 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const return return_value; } -STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) +STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, const int num_rects) { stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); } -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, const int font_index, stbtt_pack_range *ranges, const int num_ranges) { stbtt_fontinfo info; int i,j,n, return_value = 1; @@ -4192,8 +4204,8 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char return return_value; } -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, - int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, const int font_index, const float font_size, const int first_unicode_codepoint_in_range, + const int num_chars_in_range, stbtt_packedchar *chardata_for_range) { stbtt_pack_range range; range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; @@ -4204,7 +4216,7 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char * return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); } -STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap) +STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, const int index, const float size, float *ascent, float *descent, float *lineGap) { int i_ascent, i_descent, i_lineGap; float scale; @@ -4217,7 +4229,7 @@ STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int in *lineGap = (float) i_lineGap * scale; } -STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, const int pw, const int ph, const int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, const int align_to_integer) { float ipw = 1.0f / pw, iph = 1.0f / ph; const stbtt_packedchar *b = chardata + char_index; @@ -4321,7 +4333,7 @@ static int equal(float *a, float *b) return (a[0] == b[0] && a[1] == b[1]); } -static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) +static int stbtt__compute_crossings_x(const float x, float y, const int nverts, stbtt_vertex *verts) { int i; float orig[2], ray[2] = { 1, 0 }; @@ -4390,7 +4402,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex return winding; } -static float stbtt__cuberoot( float x ) +static float stbtt__cuberoot(const float x ) { if (x<0) return -(float) STBTT_pow(-x,1.0f/3.0f); @@ -4399,7 +4411,7 @@ static float stbtt__cuberoot( float x ) } // x^3 + c*x^2 + b*x + a = 0 -static int stbtt__solve_cubic(float a, float b, float c, float* r) +static int stbtt__solve_cubic(const float a, const float b, const float c, float* r) { const float s = -a / 3; const float p = b - a*a / 3; @@ -4616,7 +4628,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc return data; } -STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, const float scale, const int codepoint, const int padding, const unsigned char onedge_value, const float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); } @@ -4632,7 +4644,7 @@ STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) // // check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string -static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, const stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; @@ -4671,14 +4683,14 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, s return i; } -static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) +static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, const int len1, char *s2, const int len2) { return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); } // returns results in whatever encoding you request... but note that 2-byte encodings // will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare -STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) +STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, const int platformID, const int encodingID, const int languageID, const int nameID) { stbtt_int32 i,count,stringOffset; stbtt_uint8 *fc = font->data; @@ -4699,7 +4711,7 @@ STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *l return NULL; } -static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) +static int stbtt__matchpair(stbtt_uint8 *fc, const stbtt_uint32 nm, stbtt_uint8 *name, const stbtt_int32 nlen, const stbtt_int32 target_id, const stbtt_int32 next_id) { stbtt_int32 i; const stbtt_int32 count = ttUSHORT(fc+nm+2); @@ -4746,7 +4758,7 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, return 0; } -static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) +static int stbtt__matches(stbtt_uint8 *fc, const stbtt_uint32 offset, stbtt_uint8 *name, const stbtt_int32 flags) { const stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); stbtt_uint32 nm,hd; @@ -4775,7 +4787,7 @@ static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *nam return 0; } -static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) +static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, const stbtt_int32 flags) { stbtt_int32 i; for (i=0;;++i) { @@ -4791,14 +4803,12 @@ static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char #pragma GCC diagnostic ignored "-Wcast-qual" #endif -STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, - float pixel_height, unsigned char *pixels, int pw, int ph, - int first_char, int num_chars, stbtt_bakedchar *chardata) +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, const int offset, const float pixel_height, unsigned char *pixels, const int pw, const int ph, const int first_char, const int num_chars, stbtt_bakedchar *chardata) { return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); } -STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, const int index) { return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); } @@ -4808,17 +4818,17 @@ STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) return stbtt_GetNumberOfFonts_internal((unsigned char *) data); } -STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, const int offset) { return stbtt_InitFont_internal(info, (unsigned char *) data, offset); } -STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, const int flags) { return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); } -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, const int len1, const char *s2, const int len2) { return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); } diff --git a/input/messaging.cpp b/input/messaging.cpp index be2bfc50..1684c18c 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -32,7 +32,7 @@ namespace multiplayer { constexpr std::uint32_t EU07_MESSAGEHEADER { MAKE_ID4( 'E','U','0','7' ) }; void -Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam) { +Navigate(std::string const &ClassName, const UINT Msg, const WPARAM wParam, const LPARAM lParam) { #ifdef _WIN32 // wysłanie komunikatu do sterującego HWND h = FindWindow(ClassName.c_str(), 0); // można by to zapamiętać @@ -219,7 +219,7 @@ WyslijEvent(const std::string &e, const std::string &d) } void -WyslijUszkodzenia(const std::string &t, char fl) +WyslijUszkodzenia(const std::string &t, const char fl) { // wysłanie informacji w postaci pojedynczego tekstu #ifdef _WIN32 DaneRozkaz r; @@ -239,7 +239,7 @@ WyslijUszkodzenia(const std::string &t, char fl) } void -WyslijString(const std::string &t, int n) +WyslijString(const std::string &t, const int n) { // wysłanie informacji w postaci pojedynczego tekstu #ifdef _WIN32 DaneRozkaz r; @@ -395,7 +395,7 @@ WyslijObsadzone() } void -WyslijParam(int nr, int fl) +WyslijParam(const int nr, const int fl) { // wysłanie parametrów symulacji w ramce (nr) z flagami (fl) #ifdef _WIN32 DaneRozkaz r; diff --git a/input/zmq_input.cpp b/input/zmq_input.cpp index 58906515..3d8c86f4 100644 --- a/input/zmq_input.cpp +++ b/input/zmq_input.cpp @@ -230,7 +230,7 @@ std::unordered_map zmq_input::output_fiel { "time_millisecond_of_day", output_fields::time_millisecond_of_day } }; -zmq::message_t zmq_input::pack_field(output_fields f) { +zmq::message_t zmq_input::pack_field(const output_fields f) { const SYSTEMTIME time = simulation::Time.data(); if (f == output_fields::time_month_of_era) diff --git a/launcher/scenery_list.cpp b/launcher/scenery_list.cpp index 3d34ed7b..aeb070ed 100644 --- a/launcher/scenery_list.cpp +++ b/launcher/scenery_list.cpp @@ -14,7 +14,7 @@ ui::scenerylist_panel::scenerylist_panel(scenery_scanner &scanner) { } -bool ui::scenerylist_panel::on_key(int key, int action) +bool ui::scenerylist_panel::on_key(const int key, int action) { if (!is_open) return false; @@ -332,7 +332,7 @@ void ui::scenerylist_panel::draw_trainset(trainset_desc &trainset) ImGui::PopID(); } -void ui::scenerylist_panel::draw_droptarget(trainset_desc &trainset, int position) +void ui::scenerylist_panel::draw_droptarget(trainset_desc &trainset, const int position) { ImGui::Dummy(ImVec2(15, 30)); if (ImGui::BeginDragDropTarget()) { diff --git a/launcher/scenery_list.h b/launcher/scenery_list.h index e34583c3..a356ab93 100644 --- a/launcher/scenery_list.h +++ b/launcher/scenery_list.h @@ -46,7 +46,7 @@ private: dynamic_desc &dynamic; int position; - vehicle_moved(trainset_desc &source, dynamic_desc &dynamic, int position) + vehicle_moved(trainset_desc &source, dynamic_desc &dynamic, const int position) : source(source), dynamic(dynamic), position(position) {} }; diff --git a/model/AnimModel.cpp b/model/AnimModel.cpp index b8b0c82d..171073c2 100644 --- a/model/AnimModel.cpp +++ b/model/AnimModel.cpp @@ -413,7 +413,7 @@ namespace { // doesn't match a recognised animation keyword — these are driven by event- // triggered SetRotate/SetTranslate at runtime, which would silently break if // the model were batched. -bool anim_type_unsafe_for_instancing( TAnimType a ) { +bool anim_type_unsafe_for_instancing(const TAnimType a ) { switch( a ) { case TAnimType::at_Rotate: case TAnimType::at_RotateXYZ: @@ -650,7 +650,7 @@ int TAnimModel::TerrainCount() return pModel ? pModel->TerrainCount() : 0; } -TSubModel * TAnimModel::TerrainSquare(int n) +TSubModel * TAnimModel::TerrainSquare(const int n) { // pobieranie wskaźników do pierwszego submodelu return pModel ? pModel->TerrainSquare(n) : 0; } diff --git a/model/MdlMngr.cpp b/model/MdlMngr.cpp index 235d4872..ec172c21 100644 --- a/model/MdlMngr.cpp +++ b/model/MdlMngr.cpp @@ -42,7 +42,7 @@ TModelsManager::stringmodelcontainerindex_map TModelsManager::m_modelsmap; // wczytanie modelu do tablicy TModel3d * -TModelsManager::LoadModel(std::string const &Name, std::string const &virtualName, bool dynamic) { +TModelsManager::LoadModel(std::string const &Name, std::string const &virtualName, const bool dynamic) { m_models.emplace_back(); const auto model = m_models.back().LoadModel( Name, dynamic ); @@ -57,7 +57,7 @@ TModelsManager::LoadModel(std::string const &Name, std::string const &virtualNam } TModel3d * -TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const Logerrors, int uid ) +TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const Logerrors, const int uid ) { // model może być we wpisie "node...model" albo "node...dynamic", a także być dodatkowym w dynamic // (kabina, wnętrze, ładunek) // dla "node...dynamic" mamy podaną ścieżkę w "\dynamic\" i musi być co najmniej 1 poziom, zwkle diff --git a/model/Model3d.cpp b/model/Model3d.cpp index d4661804..149a3f37 100644 --- a/model/Model3d.cpp +++ b/model/Model3d.cpp @@ -94,7 +94,7 @@ void TSubModel::SetDiffuseOverride(glm::vec3 const &Color, bool const Includechi } } -std::optional TSubModel::GetDiffuse(float Includesiblings) +std::optional TSubModel::GetDiffuse(const float Includesiblings) { if (eType == TP_FREESPOTLIGHT) { @@ -815,7 +815,7 @@ basic_vertex *TSubModel::TrianglePtr(int tex, int pos, glm::vec3 const &Ambient, }; */ -void TSubModel::InitialRotate(bool doit) +void TSubModel::InitialRotate(const bool doit) { // konwersja układu współrzędnych na zgodny ze scenerią if (iFlags & 0xC000) // jeśli jest animacja albo niejednostkowy transform { // niejednostkowy transform jest mnożony i wystarczy zabawy @@ -1020,7 +1020,7 @@ uint32_t TSubModel::FlagsCheck() return iFlags; }; -void TSubModel::SetRotate(float3 vNewRotateAxis, float fNewAngle) +void TSubModel::SetRotate(const float3 vNewRotateAxis, const float fNewAngle) { // obrócenie submodelu wg podanej // osi (np. wskazówki w kabinie) v_RotateAxis = vNewRotateAxis; @@ -1033,7 +1033,7 @@ void TSubModel::SetRotate(float3 vNewRotateAxis, float fNewAngle) iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } -void TSubModel::SetRotateXYZ(float3 vNewAngles) +void TSubModel::SetRotateXYZ(const float3 vNewAngles) { // obrócenie submodelu o // podane kąty wokół osi // lokalnego układu @@ -1055,7 +1055,7 @@ void TSubModel::SetRotateXYZ(glm::vec3 vNewAngles) iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } -void TSubModel::SetTranslate(float3 vNewTransVector) +void TSubModel::SetTranslate(const float3 vNewTransVector) { // przesunięcie submodelu (np. w kabinie) v_TransVector = vNewTransVector; b_Anim = TAnimType::at_Translate; @@ -1073,7 +1073,7 @@ void TSubModel::SetTranslate(glm::vec3 vNewTransVector) iAnimOwner = iInstance; // zapamiętanie czyja jest animacja } -void TSubModel::SetRotateIK1(float3 vNewAngles) +void TSubModel::SetRotateIK1(const float3 vNewAngles) { // obrócenie submodelu o // podane kąty wokół osi // lokalnego układu @@ -1083,13 +1083,13 @@ void TSubModel::SetRotateIK1(float3 vNewAngles) struct ToLower { - char operator()(char input) + char operator()(const char input) { return tolower(input); } }; -TSubModel *TSubModel::GetFromName(std::string const &search, bool i) +TSubModel *TSubModel::GetFromName(std::string const &search, const bool i) { TSubModel *result; // std::transform(search.begin(),search.end(),search.begin(),ToLower()); @@ -1121,14 +1121,14 @@ TSubModel *TSubModel::GetFromName(std::string const &search, bool i) // WORD hbIndices[18]={3,0,1,5,4,2,1,0,4,1,5,3,2,3,5,2,4,0}; -void TSubModel::RaAnimation(TAnimType a) +void TSubModel::RaAnimation(const TAnimType a) { glm::mat4 m = OpenGLMatrices.data(GL_MODELVIEW); RaAnimation(m, a); glLoadMatrixf(glm::value_ptr(m)); } -void TSubModel::RaAnimation(glm::mat4 &m, TAnimType a) +void TSubModel::RaAnimation(glm::mat4 &m, const TAnimType a) { // wykonanie animacji niezależnie od renderowania switch (a) { // korekcja położenia, jeśli submodel jest animowany @@ -1612,7 +1612,7 @@ glm::vec3 TSubModel::offset(float const Geometrytestoffsetthreshold) const return offset; } -bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic) +bool TModel3d::LoadFromFile(std::string const &FileName, const bool dynamic) { // wczytanie modelu z pliku /* @@ -1921,7 +1921,7 @@ void TSubModel::deserialize(std::istream &s) m_rotation_init_done = true; } -void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic) +void TModel3d::deserialize(std::istream &s, const size_t size, const bool dynamic) { Root = nullptr; if (m_geometrybank == null_handle) @@ -2356,7 +2356,7 @@ bool TSubModel::HasAnyVertexUserData() const return false; }; -void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic) +void TModel3d::LoadFromBinFile(std::string const &FileName, const bool dynamic) { // wczytanie modelu z pliku binarnego WriteLog("Loading binary format 3d model data from \"" + FileName + "\"...", logtype::model); @@ -2409,7 +2409,7 @@ TSubModel *TModel3d::AppendChildFromGeometry(const std::string &name, const std: return sm; } -void TModel3d::LoadFromTextFile(std::string const &FileName, bool dynamic) +void TModel3d::LoadFromTextFile(std::string const &FileName, const bool dynamic) { // wczytanie submodelu z pliku tekstowego WriteLog("Loading text format 3d model data from \"" + FileName + "\"...", logtype::model); iFlags |= 0x0200; // wczytano z pliku tekstowego (właścicielami tablic są submodle) @@ -2518,7 +2518,7 @@ int TModel3d::TerrainCount() const } return i; }; -TSubModel *TModel3d::TerrainSquare(int n) +TSubModel *TModel3d::TerrainSquare(const int n) { // pobieranie wskaźnika do submodelu (n) int i = 0; TSubModel *r = Root; diff --git a/model/Model3d.h b/model/Model3d.h index 8a8b3b41..2cac211d 100644 --- a/model/Model3d.h +++ b/model/Model3d.h @@ -208,7 +208,7 @@ public: iFlags |= 0x4000; }; void InitialRotate(bool doit); void BinInit(TSubModel *s, float4x4 *m, std::vector *t, std::vector *n, bool dynamic); - static void ReplacableSet(material_handle const *r, int a) { + static void ReplacableSet(material_handle const *r, const int a) { ReplacableSkinId = r; iAlpha = a; }; void Name_Material( std::string const &Name ); diff --git a/model/Texture.cpp b/model/Texture.cpp index 3da85b3f..125f795a 100644 --- a/model/Texture.cpp +++ b/model/Texture.cpp @@ -375,7 +375,7 @@ opengl_texture::make_stub() } void -opengl_texture::make_from_memory(size_t width, size_t height, const uint8_t *raw) +opengl_texture::make_from_memory(const size_t width, const size_t height, const uint8_t *raw) { release(); @@ -392,7 +392,7 @@ opengl_texture::make_from_memory(size_t width, size_t height, const uint8_t *raw is_texstub = false; } -void opengl_texture::update_from_memory(size_t width, size_t height, const uint8_t *raw) +void opengl_texture::update_from_memory(const size_t width, const size_t height, const uint8_t *raw) { if (id != -1 && (width != data_width || height != data_height || GL_SRGB8_ALPHA8 != data_format || GL_RGBA != data_components)) { @@ -878,7 +878,7 @@ opengl_texture::load_TGA() { } bool -opengl_texture::bind(size_t unit) { +opengl_texture::bind(const size_t unit) { if( false == is_ready && false == create() ) { @@ -906,7 +906,7 @@ opengl_texture::bind(size_t unit) { } void -opengl_texture::unbind(size_t unit) +opengl_texture::unbind(const size_t unit) { if (GLAD_GL_ARB_direct_state_access) { @@ -1137,7 +1137,7 @@ opengl_texture::release() { } void -opengl_texture::alloc_rendertarget( GLint format, GLint components, int width, int height, int l, int s, GLint wrap ) { +opengl_texture::alloc_rendertarget(const GLint format, const GLint components, const int width, const int height, const int l, const int s, const GLint wrap ) { data_width = width; data_height = height; @@ -1162,7 +1162,7 @@ opengl_texture::alloc_rendertarget( GLint format, GLint components, int width, i } void -opengl_texture::set_components_hint( GLint hint ) { +opengl_texture::set_components_hint(const GLint hint ) { components_hint = hint; } @@ -1267,7 +1267,7 @@ texture_manager::unit( GLint const Textureunit ) { // ustalenie numeru tekstury, wczytanie jeśli jeszcze takiej nie było texture_handle -texture_manager::create( std::string Filename, bool const Loadnow, GLint Formathint ) { +texture_manager::create( std::string Filename, bool const Loadnow, const GLint Formathint ) { if( contains( Filename, '|' ) ) { Filename.erase( Filename.find( '|' ) ); // po | może być nazwa kolejnej tekstury diff --git a/model/material.h b/model/material.h index ef369d9f..0cb52ecc 100644 --- a/model/material.h +++ b/model/material.h @@ -56,7 +56,7 @@ struct opengl_material : public IMaterial { { return shadow_rank; } - virtual texture_handle GetTexture(int slot) const override + virtual texture_handle GetTexture(const int slot) const override { return textures[slot]; } diff --git a/model/vertex.h b/model/vertex.h index d1ab1a9c..d83b78d8 100644 --- a/model/vertex.h +++ b/model/vertex.h @@ -17,7 +17,7 @@ struct world_vertex { glm::vec3 normal; glm::vec2 texture; - static world_vertex lerp(world_vertex const &a, world_vertex const &b, double factor) + static world_vertex lerp(world_vertex const &a, world_vertex const &b, const double factor) { return static_cast(a * (1.0f - factor) + b * factor); } diff --git a/network/backend/asio.cpp b/network/backend/asio.cpp index 2ef4d3c2..1801c882 100644 --- a/network/backend/asio.cpp +++ b/network/backend/asio.cpp @@ -3,7 +3,7 @@ #include "scene/sn_utils.h" #include "utilities/Logs.h" -network::tcp::connection::connection(asio::io_context &io_ctx, bool client, size_t counter) +network::tcp::connection::connection(asio::io_context &io_ctx, const bool client, const size_t counter) : network::connection(client, counter), m_socket(io_ctx) { @@ -39,7 +39,7 @@ void network::tcp::connection::read_header() std::placeholders::_1, std::placeholders::_2)); } -void network::tcp::connection::handle_header(const asio::error_code &err, size_t bytes_transferred) +void network::tcp::connection::handle_header(const asio::error_code &err, const size_t bytes_transferred) { if (err) { disconnect(); @@ -69,7 +69,7 @@ void network::tcp::connection::handle_header(const asio::error_code &err, size_t std::bind(&connection::handle_data, this, std::placeholders::_1, std::placeholders::_2)); } -void network::tcp::connection::handle_data(const asio::error_code &err, size_t bytes_transferred) +void network::tcp::connection::handle_data(const asio::error_code &err, const size_t bytes_transferred) { if (err) { disconnect(); @@ -133,7 +133,7 @@ void network::tcp::connection::send_message(const message &msg) // ----------------- -network::tcp::server::server(std::shared_ptr buf, asio::io_context &io_ctx, const std::string &host, uint32_t port) +network::tcp::server::server(std::shared_ptr buf, asio::io_context &io_ctx, const std::string &host, const uint32_t port) : network::server(buf), m_acceptor(io_ctx), m_io_ctx(io_ctx) { const auto endpoint = asio::ip::tcp::endpoint(asio::ip::make_address(host), port); @@ -172,7 +172,7 @@ void network::tcp::server::handle_accept(std::shared_ptr conn, const // ------------------ -network::tcp::client::client(asio::io_context &io_ctxx, const std::string &hostarg, uint32_t portarg) +network::tcp::client::client(asio::io_context &io_ctxx, const std::string &hostarg, const uint32_t portarg) : host(hostarg), port(portarg), io_ctx(io_ctxx) { } diff --git a/network/manager.cpp b/network/manager.cpp index acc8e26a..b57fa4f4 100644 --- a/network/manager.cpp +++ b/network/manager.cpp @@ -27,7 +27,7 @@ command_queue::commands_map network::server_manager::pop_commands() return map; } -void network::server_manager::push_delta(double render_dt, double dt, double sync, const command_queue::commands_map &commands) +void network::server_manager::push_delta(const double render_dt, const double dt, const double sync, const command_queue::commands_map &commands) { if (dt == 0.0 && commands.empty()) return; diff --git a/network/message.h b/network/message.h index 43ad13ec..eb16789b 100644 --- a/network/message.h +++ b/network/message.h @@ -18,7 +18,7 @@ struct message type_e type; - message(type_e t) : type(t) {} + message(const type_e t) : type(t) {} virtual void serialize(std::ostream &stream) const {} virtual void deserialize(std::istream &stream) {} }; @@ -49,7 +49,7 @@ struct server_hello : public message struct request_command : public message { - request_command(type_e type) : message(type) {} + request_command(const type_e type) : message(type) {} request_command() : message(REQUEST_COMMAND) {} command_queue::commands_map commands; diff --git a/network/network.cpp b/network/network.cpp index e028399b..2414045b 100644 --- a/network/network.cpp +++ b/network/network.cpp @@ -30,7 +30,7 @@ void network::connection::set_handler(std::function hand message_handler = handler; } -network::connection::connection(bool client, size_t counter) { +network::connection::connection(const bool client, const size_t counter) { packet_counter = counter; is_client = client; state = AWAITING_HELLO; @@ -173,7 +173,7 @@ void network::client::update() } // client -std::tuple network::client::get_next_delta(int counter) +std::tuple network::client::get_next_delta(const int counter) { const auto now = std::chrono::high_resolution_clock::now(); if (counter == 1) { diff --git a/rendering/geometrybank.cpp b/rendering/geometrybank.cpp index 47fc443f..d021624a 100644 --- a/rendering/geometrybank.cpp +++ b/rendering/geometrybank.cpp @@ -204,7 +204,7 @@ void calculate_tangents(vertex_array &vertices, index_array const &indices, int } } -void calculate_indices( index_array &Indices, vertex_array &Vertices, userdata_array &Userdata, float tolerancescale ) { +void calculate_indices( index_array &Indices, vertex_array &Vertices, userdata_array &Userdata, const float tolerancescale ) { Indices.resize( Vertices.size() ); std::iota( std::begin( Indices ), std::end( Indices ), 0 ); diff --git a/rendering/geometrybank.h b/rendering/geometrybank.h index 3a8a0eef..43bbedb8 100644 --- a/rendering/geometrybank.h +++ b/rendering/geometrybank.h @@ -75,7 +75,7 @@ struct geometry_handle { geometry_handle() : bank( 0 ), chunk( 0 ) {} - geometry_handle( std::uint32_t Bank, std::uint32_t Chunk ) : + geometry_handle(const std::uint32_t Bank, const std::uint32_t Chunk ) : bank( Bank ), chunk( Chunk ) {} // methods @@ -145,14 +145,14 @@ protected: index_array indices; // index data userdata_array userdata; // NOTE: constructor doesn't copy provided geometry data, but moves it - geometry_chunk( vertex_array &Vertices, userdata_array& Userdata, unsigned int Type ) : + geometry_chunk( vertex_array &Vertices, userdata_array& Userdata, const unsigned int Type ) : type( Type ) { vertices.swap( Vertices ); userdata.swap( Userdata ); } // NOTE: constructor doesn't copy provided geometry data, but moves it - geometry_chunk( index_array &Indices, vertex_array &Vertices, userdata_array& Userdata, unsigned int Type ) : + geometry_chunk( index_array &Indices, vertex_array &Vertices, userdata_array& Userdata, const unsigned int Type ) : type( Type ) { vertices.swap( Vertices ); diff --git a/rendering/opengl33geometrybank.cpp b/rendering/opengl33geometrybank.cpp index c4390f6c..4ccf0965 100644 --- a/rendering/opengl33geometrybank.cpp +++ b/rendering/opengl33geometrybank.cpp @@ -106,7 +106,7 @@ void opengl33_vaogeometrybank::setup_buffer() } void -opengl33_vaogeometrybank::setup_attrib(size_t offset) +opengl33_vaogeometrybank::setup_attrib(const size_t offset) { m_vao->setup_attrib( *m_vertexbuffer, 0, 3, GL_FLOAT, sizeof( basic_vertex ), offsetof(basic_vertex, position) + offset * sizeof( basic_vertex ) ); // NOTE: normal and color streams share the data @@ -115,7 +115,7 @@ opengl33_vaogeometrybank::setup_attrib(size_t offset) m_vao->setup_attrib( *m_vertexbuffer, 3, 4, GL_FLOAT, sizeof( basic_vertex ), offsetof(basic_vertex, tangent) + offset * sizeof( basic_vertex ) ); } -void opengl33_vaogeometrybank::setup_userdata(size_t offset) { +void opengl33_vaogeometrybank::setup_userdata(const size_t offset) { const size_t offset_evaluated = m_vertex_count * sizeof(basic_vertex) + offset * sizeof( vertex_userdata ); m_vao->setup_attrib( *m_vertexbuffer, 4, 4, GL_FLOAT, sizeof( vertex_userdata ), offsetof(vertex_userdata, data) + offset_evaluated );} diff --git a/rendering/opengl33renderer.cpp b/rendering/opengl33renderer.cpp index 5efe3f13..bc3ced6e 100644 --- a/rendering/opengl33renderer.cpp +++ b/rendering/opengl33renderer.cpp @@ -29,7 +29,7 @@ int constexpr EU07_PICKBUFFERSIZE{ 1024 }; // size of (square) textures bound wi int constexpr EU07_REFLECTIONFIDELITYOFFSET { 250 }; // artificial increase of range for reflection pass detail reduction void GLAPIENTRY -ErrorCallback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam ) { +ErrorCallback( GLenum source, const GLenum type, const GLuint id, const GLenum severity, GLsizei length, const GLchar* message, const void* userParam ) { /* auto const typestring { type == GL_DEBUG_TYPE_ERROR ? "error" : @@ -1461,7 +1461,7 @@ glm::mat4 opengl33_renderer::perspective_projection(const viewport_proj_config & return glm::translate(R * M, -c.pe); } -glm::mat4 opengl33_renderer::perspective_projection_raw(float fovy, float aspect, float znear, float zfar) +glm::mat4 opengl33_renderer::perspective_projection_raw(const float fovy, const float aspect, const float znear, const float zfar) { if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control) { @@ -1487,7 +1487,7 @@ glm::mat4 opengl33_renderer::perspective_projection_raw(float fovy, float aspect glm::perspective(fovy, aspect, znear, zfar); } -glm::mat4 opengl33_renderer::ortho_projection(float l, float r, float b, float t, float znear, float zfar) +glm::mat4 opengl33_renderer::ortho_projection(const float l, const float r, const float b, const float t, const float znear, const float zfar) { const glm::mat4 proj = glm::ortho(l, r, b, t, znear, zfar); if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control) @@ -1511,7 +1511,7 @@ glm::mat4 opengl33_renderer::ortho_projection(float l, float r, float b, float t proj; } -glm::mat4 opengl33_renderer::ortho_frustumtest_projection(float l, float r, float b, float t, float znear, float zfar) +glm::mat4 opengl33_renderer::ortho_frustumtest_projection(const float l, const float r, const float b, const float t, const float znear, const float zfar) { // for frustum calculation, use standard opengl matrix return glm::ortho(l, r, b, t, znear, zfar); @@ -2337,7 +2337,7 @@ opengl_material const & opengl33_renderer::Material( TSubModel const * Submodel return m_materials.material( material ); } -texture_handle opengl33_renderer::Fetch_Texture(std::string const &Filename, bool const Loadnow, GLint format_hint) +texture_handle opengl33_renderer::Fetch_Texture(std::string const &Filename, bool const Loadnow, const GLint format_hint) { return m_textures.create(Filename, Loadnow, format_hint); } @@ -2800,7 +2800,7 @@ void opengl33_renderer::Render(cell_sequence::iterator First, cell_sequence::ite m_frame_instance_buckets.clear(); } -void opengl33_renderer::Draw_Geometry(std::vector::iterator begin, std::vector::iterator end) +void opengl33_renderer::Draw_Geometry(const std::vector::iterator begin, const std::vector::iterator end) { m_geometry.draw(begin, end); } @@ -2825,7 +2825,7 @@ void opengl33_renderer::draw(const gfx::geometry_handle &handle) } } -void opengl33_renderer::draw(std::vector::iterator it, std::vector::iterator end) +void opengl33_renderer::draw(const std::vector::iterator it, const std::vector::iterator end) { model_ubs.set_modelview(OpenGLMatrices.data(GL_MODELVIEW)); model_ubo->update(model_ubs); @@ -3850,7 +3850,7 @@ void opengl33_renderer::Render(TTrack *Track) } // experimental, does track rendering in two passes, to take advantage of reduced texture switching -void opengl33_renderer::Render(scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last) +void opengl33_renderer::Render(const scene::basic_cell::path_sequence::const_iterator First, const scene::basic_cell::path_sequence::const_iterator Last) { // setup @@ -4826,7 +4826,7 @@ void opengl33_renderer::Render_Alpha(TSubModel *Submodel) Render_Alpha(Submodel->Next); }; -bool opengl33_renderer::Debug_Ui_State(std::optional param) +bool opengl33_renderer::Debug_Ui_State(const std::optional param) { if (param) { debug_ui_active = *param; @@ -4920,7 +4920,7 @@ void opengl33_renderer::Update_Pick_Node() } } -void opengl33_renderer::Pick_Control_Callback(std::function callback) +void opengl33_renderer::Pick_Control_Callback(const std::function callback) { if (!Global.render_cab) { callback(nullptr, glm::vec2()); @@ -4929,7 +4929,7 @@ void opengl33_renderer::Pick_Control_Callback(std::function callback) +void opengl33_renderer::Pick_Node_Callback(const std::function callback) { m_node_pick_requests.push_back(callback); } diff --git a/rendering/openglgeometrybank.cpp b/rendering/openglgeometrybank.cpp index 58bcc142..16859b92 100644 --- a/rendering/openglgeometrybank.cpp +++ b/rendering/openglgeometrybank.cpp @@ -224,7 +224,7 @@ opengl_vbogeometrybank::delete_buffer() { } void -opengl_vbogeometrybank::bind_streams( stream_units const &Units, unsigned int const Streams, size_t offset ) { +opengl_vbogeometrybank::bind_streams( stream_units const &Units, unsigned int const Streams, const size_t offset ) { if( Streams & position ) { ::glVertexPointer( 3, GL_FLOAT, sizeof( basic_vertex ), reinterpret_cast( offsetof(gfx::basic_vertex, position) + sizeof( basic_vertex ) * offset ) ); diff --git a/rendering/openglrenderer.cpp b/rendering/openglrenderer.cpp index f38d0b2c..8f7ac2e0 100644 --- a/rendering/openglrenderer.cpp +++ b/rendering/openglrenderer.cpp @@ -3093,7 +3093,7 @@ opengl_renderer::Render( TTrack *Track ) { // experimental, does track rendering in two passes, to take advantage of reduced texture switching void -opengl_renderer::Render( scene::basic_cell::path_sequence::const_iterator First, scene::basic_cell::path_sequence::const_iterator Last ) { +opengl_renderer::Render(const scene::basic_cell::path_sequence::const_iterator First, const scene::basic_cell::path_sequence::const_iterator Last ) { ::glColor3fv( glm::value_ptr( colors::white ) ); // setup diff --git a/rendering/renderer.cpp b/rendering/renderer.cpp index 86bef048..083fce94 100644 --- a/rendering/renderer.cpp +++ b/rendering/renderer.cpp @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. std::unique_ptr GfxRenderer; -bool gfx_renderer_factory::register_backend(const std::string &backend, create_method func) +bool gfx_renderer_factory::register_backend(const std::string &backend, const create_method func) { backends[backend] = func; return true; diff --git a/rendering/screenshot.cpp b/rendering/screenshot.cpp index cba86e68..fa9a84c0 100644 --- a/rendering/screenshot.cpp +++ b/rendering/screenshot.cpp @@ -4,7 +4,7 @@ #include "utilities/Logs.h" #include -void screenshot_manager::screenshot_save_thread( char *img, int w, int h ) +void screenshot_manager::screenshot_save_thread( char *img, const int w, const int h ) { png_image png; memset(&png, 0, sizeof(png_image)); diff --git a/scene/scene.cpp b/scene/scene.cpp index f9e0842d..920c275d 100644 --- a/scene/scene.cpp +++ b/scene/scene.cpp @@ -675,7 +675,7 @@ glm::vec3 basic_cell::find_nearest_track_point(const glm::dvec3 &pos) // executes event assigned to specified launcher void -basic_cell::launch_event( TEventLauncher *Launcher, bool local_only ) { +basic_cell::launch_event( TEventLauncher *Launcher, const bool local_only ) { WriteLog( "Eventlauncher: " + Launcher->name() ); if (!local_only) { if( Launcher->Event1 ) { diff --git a/scene/scene.h b/scene/scene.h index d12852ef..f14a434b 100644 --- a/scene/scene.h +++ b/scene/scene.h @@ -454,7 +454,7 @@ public: create_map_geometry(); void update_poi_geometry(); - basic_section* get_section(size_t section) + basic_section* get_section(const size_t section) { return m_sections[section]; } gfx::geometrybank_handle get_map_poi_geometry() { return m_map_poipoints; } diff --git a/scene/scenenode.h b/scene/scenenode.h index 31cdff4f..13cbde48 100644 --- a/scene/scenenode.h +++ b/scene/scenenode.h @@ -159,7 +159,7 @@ private: // set visibility inline void -shape_node::visible( bool State ) { +shape_node::visible(const bool State ) { m_data.visible = State; } // set origin point @@ -252,7 +252,7 @@ private: // set visibility inline void -lines_node::visible( bool State ) { +lines_node::visible(const bool State ) { m_data.visible = State; } // set origin point @@ -433,7 +433,7 @@ basic_node::visible() const { inline void -basic_node::group( group_handle Group ) { +basic_node::group(const group_handle Group ) { m_group = Group; } diff --git a/scene/scenenodegroups.cpp b/scene/scenenodegroups.cpp index be3560e7..2cb83e20 100644 --- a/scene/scenenodegroups.cpp +++ b/scene/scenenodegroups.cpp @@ -53,7 +53,7 @@ node_groups::close() return handle(); } -bool node_groups::assign_cross_switch(map::track_switch& sw, std::string &sw_name, std::string const &id, size_t idx) +bool node_groups::assign_cross_switch(map::track_switch& sw, std::string &sw_name, std::string const &id, const size_t idx) { sw.action[idx] = simulation::Events.FindEvent(sw_name + ":" + id); if (!sw.action[idx]) @@ -268,7 +268,7 @@ node_groups::insert( group_handle const Group, basic_event *Event ) { // sends basic content of the class in legacy (text) format to provided stream void -node_groups::export_as_text( std::ostream &Output, bool Dirty ) const { +node_groups::export_as_text( std::ostream &Output, const bool Dirty ) const { for( auto const &group : m_groupmap ) { bool any = false; for( auto *node : group.second.nodes ) { @@ -304,7 +304,7 @@ node_groups::export_as_text( std::ostream &Output, bool Dirty ) const { // removes specified group from the group list and group information from the group's nodes void -node_groups::erase( group_map::const_iterator Group ) { +node_groups::erase(const group_map::const_iterator Group ) { for( auto *node : Group->second.nodes ) { node->group( null_handle ); diff --git a/scene/sn_utils.cpp b/scene/sn_utils.cpp index 2a7bd5f7..584f6ba7 100644 --- a/scene/sn_utils.cpp +++ b/scene/sn_utils.cpp @@ -137,7 +137,7 @@ uint8_t sn_utils::d_uint8( std::istream& s ) { } -void sn_utils::ls_uint16(std::ostream &s, uint16_t v) +void sn_utils::ls_uint16(std::ostream &s, const uint16_t v) { uint8_t buf[2]; buf[0] = v; @@ -145,7 +145,7 @@ void sn_utils::ls_uint16(std::ostream &s, uint16_t v) s.write((char*)buf, 2); } -void sn_utils::ls_uint32(std::ostream &s, uint32_t v) +void sn_utils::ls_uint32(std::ostream &s, const uint32_t v) { uint8_t buf[4]; buf[0] = v; @@ -155,7 +155,7 @@ void sn_utils::ls_uint32(std::ostream &s, uint32_t v) s.write((char*)buf, 4); } -void sn_utils::ls_int32(std::ostream &s, int32_t v) +void sn_utils::ls_int32(std::ostream &s, const int32_t v) { uint8_t buf[4]; buf[0] = v; @@ -165,7 +165,7 @@ void sn_utils::ls_int32(std::ostream &s, int32_t v) s.write((char*)buf, 4); } -void sn_utils::ls_uint64(std::ostream &s, uint64_t v) +void sn_utils::ls_uint64(std::ostream &s, const uint64_t v) { uint8_t buf[8]; buf[0] = v; @@ -179,7 +179,7 @@ void sn_utils::ls_uint64(std::ostream &s, uint64_t v) s.write((char*)buf, 8); } -void sn_utils::ls_int64(std::ostream &s, int64_t v) +void sn_utils::ls_int64(std::ostream &s, const int64_t v) { uint8_t buf[8]; buf[0] = v; @@ -230,7 +230,7 @@ void sn_utils::s_str(std::ostream &s, std::string v) s.write(buf, v.size() + 1); } -void sn_utils::s_bool(std::ostream &s, bool v) +void sn_utils::s_bool(std::ostream &s, const bool v) { ls_uint16( s, diff --git a/scripting/ladderlogic.cpp b/scripting/ladderlogic.cpp index e24b9fcc..a7674c35 100644 --- a/scripting/ladderlogic.cpp +++ b/scripting/ladderlogic.cpp @@ -165,7 +165,7 @@ basic_controller::deserialize_operation( cParser &Input ) -> bool { } auto -basic_controller::insert( std::string const Name, basic_element Element ) -> element_handle { +basic_controller::insert( std::string const Name, const basic_element Element ) -> element_handle { m_elements.push_back( Element ); m_elementnames.push_back( Name ); diff --git a/scripting/ladderlogic.h b/scripting/ladderlogic.h index 9566cefc..23d99be0 100644 --- a/scripting/ladderlogic.h +++ b/scripting/ladderlogic.h @@ -126,7 +126,7 @@ private: }; template -basic_element::basic_element( type_e Type, Args_ ...Args ) +basic_element::basic_element(const type_e Type, Args_ ...Args ) { switch( Type ) { case type_e::variable: { diff --git a/scripting/pythonscreenviewer.cpp b/scripting/pythonscreenviewer.cpp index d6caefb2..db3fe308 100644 --- a/scripting/pythonscreenviewer.cpp +++ b/scripting/pythonscreenviewer.cpp @@ -5,25 +5,25 @@ #include "gl/vao.h" #include "utilities/Logs.h" -void texture_window_resize(GLFWwindow *win, int w, int h) +void texture_window_resize(GLFWwindow *win, const int w, const int h) { const auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win); texwindow->notify_window_size(win, w, h); } -void texture_window_fb_resize(GLFWwindow *win, int w, int h) +void texture_window_fb_resize(GLFWwindow *win, const int w, const int h) { const auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win); texwindow->notify_window_fb_size(win, w, h); } -void texture_window_mouse_button(GLFWwindow *win, int button, int action, int mods) +void texture_window_mouse_button(GLFWwindow *win, const int button, const int action, int mods) { const auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win); texwindow->notify_click(win, button, action); } -void texture_window_cursor_pos(GLFWwindow *win, double x, double y) +void texture_window_cursor_pos(GLFWwindow *win, const double x, const double y) { const auto texwindow = (python_screen_viewer*)glfwGetWindowUserPointer(win); texwindow->notify_cursor_pos(win, x, y); @@ -185,7 +185,7 @@ void python_screen_viewer::threadfunc() } } -void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, int w, int h) +void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, const int w, const int h) { for (const auto &conf : m_windows) { if (conf->window == window) { @@ -196,7 +196,7 @@ void python_screen_viewer::notify_window_fb_size(GLFWwindow *window, int w, int } } -void python_screen_viewer::notify_window_size(GLFWwindow *window, int w, int h) +void python_screen_viewer::notify_window_size(GLFWwindow *window, const int w, const int h) { for (const auto &conf : m_windows) { if (conf->window == window) { @@ -207,7 +207,7 @@ void python_screen_viewer::notify_window_size(GLFWwindow *window, int w, int h) } } -void python_screen_viewer::notify_cursor_pos(GLFWwindow *window, double x, double y) +void python_screen_viewer::notify_cursor_pos(GLFWwindow *window, const double x, const double y) { for (const auto &conf : m_windows) { if (conf->window == window) { diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index d3b996ee..9de3cada 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -104,7 +104,7 @@ state_manager::init_scripting_interface() { // legacy method, calculates changes in simulation state over specified time void -state_manager::update( double const Deltatime, int Iterationcount ) { +state_manager::update( double const Deltatime, const int Iterationcount ) { // aktualizacja animacji krokiem FPS: dt=krok czasu [s], dt*iter=czas od ostatnich przeliczeń if (Deltatime == 0.0) { return; } diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index c997fe92..4f4bac69 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -1281,7 +1281,7 @@ state_serializer::export_as_text(std::string const &Scenariofile) const { } void -state_serializer::export_nodes_to_stream(std::ostream &scmfile, bool Dirty) +state_serializer::export_nodes_to_stream(std::ostream &scmfile, const bool Dirty) { // groups scmfile << "// groups\n"; diff --git a/simulation/simulationtime.cpp b/simulation/simulationtime.cpp index 96540255..aee6f531 100644 --- a/simulation/simulationtime.cpp +++ b/simulation/simulationtime.cpp @@ -20,7 +20,7 @@ scenario_time Time; } // simulation void -scenario_time::init(std::time_t timestamp) { +scenario_time::init(const std::time_t timestamp) { const char monthdaycounts[ 2 ][ 13 ] = { { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; @@ -185,7 +185,7 @@ scenario_time::julian_day() const { return JD; } -void scenario_time::set_time(int yearday, int minute) { +void scenario_time::set_time(const int yearday, const int minute) { m_yearday = yearday; daymonth(m_time.wDay, m_time.wMonth, m_time.wYear, m_yearday); m_time.wHour = minute / 60; diff --git a/stb/stb_image.h b/stb/stb_image.h index 0e99b01c..1d7148ae 100644 --- a/stb/stb_image.h +++ b/stb/stb_image.h @@ -822,7 +822,7 @@ typedef struct static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context -static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) +static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, const int len) { s->io.read = NULL; s->read_from_callbacks = 0; @@ -846,12 +846,12 @@ static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void * #ifndef STBI_NO_STDIO -static int stbi__stdio_read(void *user, char *data, int size) +static int stbi__stdio_read(void *user, char *data, const int size) { return (int) fread(data,1,size,(FILE*) user); } -static void stbi__stdio_skip(void *user, int n) +static void stbi__stdio_skip(void *user, const int n) { int ch; fseek((FILE*) user, n, SEEK_CUR); @@ -981,7 +981,7 @@ static int stbi__err(const char *str) } #endif -static void *stbi__malloc(size_t size) +static void *stbi__malloc(const size_t size) { return STBI_MALLOC(size); } @@ -998,7 +998,7 @@ static void *stbi__malloc(size_t size) // return 1 if the sum is valid, 0 on overflow. // negative terms are considered invalid. -static int stbi__addsizes_valid(int a, int b) +static int stbi__addsizes_valid(const int a, const int b) { if (b < 0) return 0; // now 0 <= b <= INT_MAX, hence also @@ -1010,7 +1010,7 @@ static int stbi__addsizes_valid(int a, int b) // returns 1 if the product is valid, 0 on overflow. // negative factors are considered invalid. -static int stbi__mul2sizes_valid(int a, int b) +static int stbi__mul2sizes_valid(const int a, const int b) { if (a < 0 || b < 0) return 0; if (b == 0) return 1; // mul-by-0 is always safe @@ -1020,14 +1020,14 @@ static int stbi__mul2sizes_valid(int a, int b) #if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) // returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow -static int stbi__mad2sizes_valid(int a, int b, int add) +static int stbi__mad2sizes_valid(const int a, const int b, const int add) { return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); } #endif // returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow -static int stbi__mad3sizes_valid(int a, int b, int c, int add) +static int stbi__mad3sizes_valid(const int a, const int b, const int c, const int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__addsizes_valid(a*b*c, add); @@ -1035,7 +1035,7 @@ static int stbi__mad3sizes_valid(int a, int b, int c, int add) // returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) -static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) +static int stbi__mad4sizes_valid(const int a, const int b, const int c, const int d, const int add) { return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); @@ -1044,21 +1044,21 @@ static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) #if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) // mallocs with size overflow checking -static void *stbi__malloc_mad2(int a, int b, int add) +static void *stbi__malloc_mad2(const int a, const int b, const int add) { if (!stbi__mad2sizes_valid(a, b, add)) return NULL; return stbi__malloc(a*b + add); } #endif -static void *stbi__malloc_mad3(int a, int b, int c, int add) +static void *stbi__malloc_mad3(const int a, const int b, const int c, const int add) { if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; return stbi__malloc(a*b*c + add); } #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) -static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) +static void *stbi__malloc_mad4(const int a, const int b, const int c, const int d, const int add) { if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; return stbi__malloc(a*b*c*d + add); @@ -1066,7 +1066,7 @@ static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) #endif // returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow. -static int stbi__addints_valid(int a, int b) +static int stbi__addints_valid(const int a, const int b) { if ((a >= 0) != (b >= 0)) return 1; // a and b have different signs, so no overflow if (a < 0 && b < 0) return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0. @@ -1074,7 +1074,7 @@ static int stbi__addints_valid(int a, int b) } // returns 1 if the product of two ints fits in a signed short, 0 on overflow. -static int stbi__mul2shorts_valid(int a, int b) +static int stbi__mul2shorts_valid(const int a, const int b) { if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid @@ -1112,7 +1112,7 @@ static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); static int stbi__vertically_flip_on_load_global = 0; -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) +STBIDEF void stbi_set_flip_vertically_on_load(const int flag_true_if_should_flip) { stbi__vertically_flip_on_load_global = flag_true_if_should_flip; } @@ -1122,7 +1122,7 @@ STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) #else static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; -STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) +STBIDEF void stbi_set_flip_vertically_on_load_thread(const int flag_true_if_should_flip) { stbi__vertically_flip_on_load_local = flag_true_if_should_flip; stbi__vertically_flip_on_load_set = 1; @@ -1133,7 +1133,7 @@ STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_fli : stbi__vertically_flip_on_load_global) #endif // STBI_THREAD_LOCAL -static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) +static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, const int req_comp, stbi__result_info *ri, int bpc) { memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed @@ -1186,7 +1186,7 @@ static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int re return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } -static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) +static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, const int w, const int h, const int channels) { int i; const int img_len = w * h * channels; @@ -1202,7 +1202,7 @@ static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int chan return reduced; } -static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) +static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, const int w, const int h, const int channels) { int i; const int img_len = w * h * channels; @@ -1218,7 +1218,7 @@ static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int chan return enlarged; } -static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) +static void stbi__vertical_flip(void *image, const int w, const int h, const int bytes_per_pixel) { int row; const size_t bytes_per_row = (size_t)w * bytes_per_pixel; @@ -1243,7 +1243,7 @@ static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) } #ifndef STBI_NO_GIF -static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) +static void stbi__vertical_flip_slices(void *image, const int w, const int h, const int z, const int bytes_per_pixel) { int slice; const int slice_size = w * h * bytes_per_pixel; @@ -1256,7 +1256,7 @@ static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int byt } #endif -static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, const int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); @@ -1282,7 +1282,7 @@ static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, return (unsigned char *) result; } -static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, const int req_comp) { stbi__result_info ri; void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); @@ -1310,7 +1310,7 @@ static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, } #if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) -static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) +static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, const int req_comp) { if (stbi__vertically_flip_on_load && result != NULL) { const int channels = req_comp ? req_comp : *comp; @@ -1362,7 +1362,7 @@ static FILE *stbi__fopen(char const *filename, char const *mode) } -STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, const int req_comp) { FILE *f = stbi__fopen(filename, "rb"); unsigned char *result; @@ -1372,7 +1372,7 @@ STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int return result; } -STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, const int req_comp) { unsigned char *result; stbi__context s; @@ -1385,7 +1385,7 @@ STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req return result; } -STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) +STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, const int req_comp) { stbi__uint16 *result; stbi__context s; @@ -1398,7 +1398,7 @@ STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, return result; } -STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, const int req_comp) { FILE *f = stbi__fopen(filename, "rb"); stbi__uint16 *result; @@ -1411,28 +1411,28 @@ STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, i #endif //!STBI_NO_STDIO -STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, const int len, int *x, int *y, int *channels_in_file, const int desired_channels) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } -STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, const int desired_channels) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); } -STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, const int len, int *x, int *y, int *comp, const int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); } -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, const int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); @@ -1440,7 +1440,7 @@ STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *u } #ifndef STBI_NO_GIF -STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, const int len, int **delays, int *x, int *y, int *z, int *comp, const int req_comp) { unsigned char *result; stbi__context s; @@ -1456,7 +1456,7 @@ STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int * #endif #ifndef STBI_NO_LINEAR -static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, const int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR @@ -1474,14 +1474,14 @@ static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); } -STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, const int len, int *x, int *y, int *comp, const int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__loadf_main(&s,x,y,comp,req_comp); } -STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, const int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); @@ -1489,7 +1489,7 @@ STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *us } #ifndef STBI_NO_STDIO -STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, const int req_comp) { float *result; FILE *f = stbi__fopen(filename, "rb"); @@ -1499,7 +1499,7 @@ STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int r return result; } -STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, const int req_comp) { stbi__context s; stbi__start_file(&s,f); @@ -1571,14 +1571,14 @@ STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void #ifndef STBI_NO_LINEAR static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; -STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } -STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } +STBIDEF void stbi_ldr_to_hdr_gamma(const float gamma) { stbi__l2h_gamma = gamma; } +STBIDEF void stbi_ldr_to_hdr_scale(const float scale) { stbi__l2h_scale = scale; } #endif static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; -STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } -STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } +STBIDEF void stbi_hdr_to_ldr_gamma(const float gamma) { stbi__h2l_gamma_i = 1/gamma; } +STBIDEF void stbi_hdr_to_ldr_scale(const float scale) { stbi__h2l_scale_i = 1/scale; } ////////////////////////////////////////////////////////////////////////////// @@ -1640,7 +1640,7 @@ stbi_inline static int stbi__at_eof(stbi__context *s) #if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) // nothing #else -static void stbi__skip(stbi__context *s, int n) +static void stbi__skip(stbi__context *s, const int n) { if (n == 0) return; // already there! if (n < 0) { @@ -1662,7 +1662,7 @@ static void stbi__skip(stbi__context *s, int n) #if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) // nothing #else -static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) +static int stbi__getn(stbi__context *s, stbi_uc *buffer, const int n) { if (s->io.read) { const int blen = (int) (s->img_buffer_end - s->img_buffer); @@ -1742,7 +1742,7 @@ static stbi__uint32 stbi__get32le(stbi__context *s) // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing -static stbi_uc stbi__compute_y(int r, int g, int b) +static stbi_uc stbi__compute_y(const int r, const int g, const int b) { return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); } @@ -1751,7 +1751,7 @@ static stbi_uc stbi__compute_y(int r, int g, int b) #if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) // nothing #else -static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) +static unsigned char *stbi__convert_format(unsigned char *data, const int img_n, const int req_comp, const unsigned int x, const unsigned int y) { int i,j; unsigned char *good; @@ -1799,7 +1799,7 @@ static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int r #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) // nothing #else -static stbi__uint16 stbi__compute_y_16(int r, int g, int b) +static stbi__uint16 stbi__compute_y_16(const int r, const int g, const int b) { return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); } @@ -1808,7 +1808,7 @@ static stbi__uint16 stbi__compute_y_16(int r, int g, int b) #if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) // nothing #else -static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) +static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, const int img_n, const int req_comp, const unsigned int x, const unsigned int y) { int i,j; stbi__uint16 *good; @@ -1854,7 +1854,7 @@ static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int r #endif #ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) +static float *stbi__ldr_to_hdr(stbi_uc *data, const int x, const int y, const int comp) { int i,k,n; float *output; @@ -1880,7 +1880,7 @@ static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) #ifndef STBI_NO_HDR #define stbi__float2int(x) ((int) (x)) -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) +static stbi_uc *stbi__hdr_to_ldr(float *data, const int x, const int y, const int comp) { int i,k,n; stbi_uc *output; @@ -2149,7 +2149,7 @@ static const int stbi__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023, // combined JPEG 'receive' and JPEG 'extend', since baseline // always extends everything it receives. -stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n) +stbi_inline static int stbi__extend_receive(stbi__jpeg *j, const int n) { unsigned int k; int sgn; @@ -2165,7 +2165,7 @@ stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n) } // get some unsigned bits -stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) +stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, const int n) { unsigned int k; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); @@ -2206,7 +2206,7 @@ static const stbi_uc stbi__jpeg_dezigzag[64+15] = }; // decode one 64-entry block-- -static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, const int b, stbi__uint16 *dequant) { int diff,dc,k; int t; @@ -2261,7 +2261,7 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman return 1; } -static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, const int b) { int diff,dc; int t; @@ -2412,7 +2412,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ } // take a -128..127 value and stbi__clamp it and convert to 0..255 -stbi_inline static stbi_uc stbi__clamp(int x) +stbi_inline static stbi_uc stbi__clamp(const int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { @@ -3095,7 +3095,7 @@ static void stbi__jpeg_finish(stbi__jpeg *z) } } -static int stbi__process_marker(stbi__jpeg *z, int m) +static int stbi__process_marker(stbi__jpeg *z, const int m) { int L; switch (m) { @@ -3238,7 +3238,7 @@ static int stbi__process_scan_header(stbi__jpeg *z) return 1; } -static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) +static int stbi__free_jpeg_components(stbi__jpeg *z, const int ncomp, const int why) { int i; for (i=0; i < ncomp; ++i) { @@ -3260,7 +3260,7 @@ static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) return why; } -static int stbi__process_frame_header(stbi__jpeg *z, int scan) +static int stbi__process_frame_header(stbi__jpeg *z, const int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; @@ -3361,7 +3361,7 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) #define stbi__SOF_progressive(x) ((x) == 0xc2) -static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) +static int stbi__decode_jpeg_header(stbi__jpeg *z, const int scan) { int m; z->jfif = 0; @@ -3452,7 +3452,7 @@ typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, #define stbi__div4(x) ((stbi_uc) ((x) >> 2)) -static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, const int w, const int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); @@ -3461,7 +3461,7 @@ static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, return in_near; } -static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, const int w, const int hs) { // need to generate two samples vertically for every one in input int i; @@ -3471,7 +3471,7 @@ static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc * return out; } -static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, const int w, const int hs) { // need to generate two samples horizontally for every one in input int i; @@ -3501,7 +3501,7 @@ static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc #define stbi__div16(x) ((stbi_uc) ((x) >> 4)) -static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, const int w, const int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; @@ -3642,7 +3642,7 @@ static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stb } #endif -static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, const int w, const int hs) { // resample with nearest-neighbor int i,j; @@ -3656,7 +3656,7 @@ static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_ // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar #define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) -static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, const int count, const int step) { int i; for (i=0; i < count; ++i) { @@ -3855,13 +3855,13 @@ typedef struct } stbi__resample; // fast 0..255 * 0..255 => 0..255 rounded multiplication -static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) +static stbi_uc stbi__blinn_8x8(const stbi_uc x, const stbi_uc y) { const unsigned int t = x*y + 128; return (stbi_uc) ((t + (t >>8)) >> 8); } -static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, const int req_comp) { int n, decode_n, is_rgb; z->s->img_n = 0; // make stbi__cleanup_jpeg safe @@ -4024,7 +4024,7 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp } } -static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, const int req_comp, stbi__result_info *ri) { unsigned char* result; stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); @@ -4112,7 +4112,7 @@ stbi_inline static int stbi__bitreverse16(int n) return n; } -stbi_inline static int stbi__bit_reverse(int v, int bits) +stbi_inline static int stbi__bit_reverse(const int v, const int bits) { STBI_ASSERT(bits <= 16); // to bit reverse n bits, reverse 16 and shift @@ -4120,7 +4120,7 @@ stbi_inline static int stbi__bit_reverse(int v, int bits) return stbi__bitreverse16(v) >> (16-bits); } -static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) +static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, const int num) { int i,k=0; int code, next_code[16], sizes[17]; @@ -4210,7 +4210,7 @@ static void stbi__fill_bits(stbi__zbuf *z) } while (z->num_bits <= 24); } -stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) +stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, const int n) { unsigned int k; if (z->num_bits < n) stbi__fill_bits(z); @@ -4269,7 +4269,7 @@ stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) return stbi__zhuffman_decode_slowpath(a, z); } -static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes +static int stbi__zexpand(stbi__zbuf *z, char *zout, const int n) // need to make room for n bytes { char *q; unsigned int cur, limit, old_limit; @@ -4477,7 +4477,7 @@ Init algorithm: } */ -static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) +static int stbi__parse_zlib(stbi__zbuf *a, const int parse_header) { int final, type; if (parse_header) @@ -4506,7 +4506,7 @@ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) return 1; } -static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) +static int stbi__do_zlib(stbi__zbuf *a, char *obuf, const int olen, const int exp, const int parse_header) { a->zout_start = obuf; a->zout = obuf; @@ -4516,7 +4516,7 @@ static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse return stbi__parse_zlib(a, parse_header); } -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, const int len, const int initial_size, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); @@ -4532,12 +4532,12 @@ STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int } } -STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) +STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, const int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, const int len, const int initial_size, int *outlen, const int parse_header) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); @@ -4553,7 +4553,7 @@ STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, i } } -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, const int olen, char const *ibuffer, const int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; @@ -4564,7 +4564,7 @@ STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer return -1; } -STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) +STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, const int len, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(16384); @@ -4580,7 +4580,7 @@ STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int } } -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, const int olen, const char *ibuffer, const int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; @@ -4653,7 +4653,7 @@ static stbi_uc first_row_filter[5] = STBI__F_sub // Paeth with b=c=0 turns out to be equivalent to sub }; -static int stbi__paeth(int a, int b, int c) +static int stbi__paeth(const int a, const int b, const int c) { // This formulation looks very different from the reference in the PNG spec, but is // actually equivalent and has favorable data dependencies and admits straightforward @@ -4671,7 +4671,7 @@ static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0, // adds an extra all-255 alpha channel // dest == src is legal // img_n must be 1 or 3 -static void stbi__create_png_alpha_expand8(stbi_uc *dest, stbi_uc *src, stbi__uint32 x, int img_n) +static void stbi__create_png_alpha_expand8(stbi_uc *dest, stbi_uc *src, const stbi__uint32 x, const int img_n) { int i; // must process data backwards since we allow dest==src @@ -4692,7 +4692,7 @@ static void stbi__create_png_alpha_expand8(stbi_uc *dest, stbi_uc *src, stbi__ui } // create the png data from post-deflated data -static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) +static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, const stbi__uint32 raw_len, const int out_n, const stbi__uint32 x, const stbi__uint32 y, const int depth, const int color) { const int bytes = (depth == 16 ? 2 : 1); const stbi__context *s = a->s; @@ -4857,7 +4857,7 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r return 1; } -static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) +static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, const int out_n, const int depth, const int color, const int interlaced) { const int bytes = (depth == 16 ? 2 : 1); const int out_bytes = out_n * bytes; @@ -4902,7 +4902,7 @@ static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint3 return 1; } -static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) +static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], const int out_n) { const stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; @@ -4927,7 +4927,7 @@ static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) return 1; } -static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) +static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], const int out_n) { const stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; @@ -4952,7 +4952,7 @@ static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int ou return 1; } -static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) +static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, const int len, const int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi_uc *p, *temp_out, *orig = a->out; @@ -4992,12 +4992,12 @@ static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int static int stbi__unpremultiply_on_load_global = 0; static int stbi__de_iphone_flag_global = 0; -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) +STBIDEF void stbi_set_unpremultiply_on_load(const int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load_global = flag_true_if_should_unpremultiply; } -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) +STBIDEF void stbi_convert_iphone_png_to_rgb(const int flag_true_if_should_convert) { stbi__de_iphone_flag_global = flag_true_if_should_convert; } @@ -5009,13 +5009,13 @@ STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set; static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set; -STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply) +STBIDEF void stbi_set_unpremultiply_on_load_thread(const int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply; stbi__unpremultiply_on_load_set = 1; } -STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert) +STBIDEF void stbi_convert_iphone_png_to_rgb_thread(const int flag_true_if_should_convert) { stbi__de_iphone_flag_local = flag_true_if_should_convert; stbi__de_iphone_flag_set = 1; @@ -5074,7 +5074,7 @@ static void stbi__de_iphone(stbi__png *z) #define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) -static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) +static int stbi__parse_png_file(stbi__png *z, const int scan, const int req_comp) { stbi_uc palette[1024], pal_img_n=0; stbi_uc has_trans=0, tc[3]={0}; @@ -5257,7 +5257,7 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) } } -static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) +static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, const int req_comp, stbi__result_info *ri) { void *result=NULL; if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); @@ -5289,7 +5289,7 @@ static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, st return result; } -static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, const int req_comp, stbi__result_info *ri) { stbi__png p; p.s = s; @@ -5389,7 +5389,7 @@ static int stbi__bitcount(unsigned int a) // extract an arbitrarily-aligned N-bit value (N=bits) // from v, and then make it 8-bits long and fractionally // extend it to full full range. -static int stbi__shiftsigned(unsigned int v, int shift, int bits) +static int stbi__shiftsigned(unsigned int v, const int shift, const int bits) { static unsigned int mul_table[9] = { 0, @@ -5416,7 +5416,7 @@ typedef struct int extra_read; } stbi__bmp_data; -static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, int compress) +static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, const int compress) { // BI_BITFIELDS specifies masks explicitly, don't override if (compress == 3) @@ -5733,7 +5733,7 @@ static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error -static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) +static int stbi__tga_get_comp(const int bits_per_pixel, const int is_grey, int* is_rgb16) { // only RGB or RGBA (incl. 16bit) or grey allowed if (is_rgb16) *is_rgb16 = 0; @@ -5865,7 +5865,7 @@ static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) // so let's treat all 15 and 16bit TGAs as RGB with no alpha. } -static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, const int req_comp, stbi__result_info *ri) { // read in the TGA header stuff const int tga_offset = stbi__get8(s); @@ -6082,7 +6082,7 @@ static int stbi__psd_test(stbi__context *s) return r; } -static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) +static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, const int pixelCount) { int count, nleft, len; @@ -6120,7 +6120,7 @@ static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) return 1; } -static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, const int req_comp, stbi__result_info *ri, const int bpc) { int pixelCount; int channelCount, compression; @@ -6361,7 +6361,7 @@ typedef struct stbi_uc size,type,channel; } stbi__pic_packet; -static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) +static stbi_uc *stbi__readval(stbi__context *s, const int channel, stbi_uc *dest) { int mask=0x80, i; @@ -6375,7 +6375,7 @@ static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) return dest; } -static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) +static void stbi__copyval(const int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; @@ -6384,7 +6384,7 @@ static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) dest[i]=src[i]; } -static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) +static stbi_uc *stbi__pic_load_core(stbi__context *s, const int width, const int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; stbi__pic_packet packets[10]; @@ -6591,7 +6591,7 @@ static int stbi__gif_test(stbi__context *s) return r; } -static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) +static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], const int num_entries, const int transp) { int i; for (i=0; i < num_entries; ++i) { @@ -6602,7 +6602,7 @@ static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], in } } -static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) +static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, const int is_info) { stbi_uc version; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') @@ -6648,7 +6648,7 @@ static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) return 1; } -static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) +static void stbi__out_gif_code(stbi__gif *g, const stbi__uint16 code) { stbi_uc *p, *c; int idx; @@ -6772,7 +6772,7 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) // this function is designed to support animated gifs, although stb_image doesn't support it // two back is the image from two frames ago, used for a very specific disposal format -static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, const int req_comp, stbi_uc *two_back) { int dispose; int first_frame; @@ -6957,7 +6957,7 @@ static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **dela return stbi__errpuc("outofmem", "Out of memory"); } -static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, const int req_comp) { if (stbi__gif_test(s)) { int layers = 0; @@ -7042,7 +7042,7 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, } } -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, const int req_comp, stbi__result_info *ri) { stbi_uc *u = 0; stbi__gif g; @@ -7125,7 +7125,7 @@ static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) return buffer; } -static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) +static void stbi__hdr_convert(float *output, stbi_uc *input, const int req_comp) { if ( input[3] != 0 ) { float f1; @@ -7500,7 +7500,7 @@ static int stbi__pnm_test(stbi__context *s) return 1; } -static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, const int req_comp, stbi__result_info *ri) { stbi_uc *out; STBI_NOTUSED(ri); @@ -7537,7 +7537,7 @@ static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req return out; } -static int stbi__pnm_isspace(char c) +static int stbi__pnm_isspace(const char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; } @@ -7556,7 +7556,7 @@ static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) } } -static int stbi__pnm_isdigit(char c) +static int stbi__pnm_isdigit(const char c) { return c >= '0' && c <= '9'; } @@ -7730,7 +7730,7 @@ STBIDEF int stbi_is_16_bit_from_file(FILE *f) } #endif // !STBI_NO_STDIO -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, const int len, int *x, int *y, int *comp) { stbi__context s; stbi__start_mem(&s,buffer,len); @@ -7744,7 +7744,7 @@ STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int return stbi__info_main(&s,x,y,comp); } -STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, const int len) { stbi__context s; stbi__start_mem(&s,buffer,len); diff --git a/stb/stb_image_write.h b/stb/stb_image_write.h index 47eaffd4..e6b86c4b 100644 --- a/stb/stb_image_write.h +++ b/stb/stb_image_write.h @@ -258,7 +258,7 @@ int stbi_write_force_png_filter = -1; static int stbi__flip_vertically_on_write = 0; -STBIWDEF void stbi_flip_vertically_on_write(int flag) +STBIWDEF void stbi_flip_vertically_on_write(const int flag) { stbi__flip_vertically_on_write = flag; } @@ -280,7 +280,7 @@ static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func #ifndef STBI_WRITE_NO_STDIO -static void stbi__stdio_write(void *context, void *data, int size) +static void stbi__stdio_write(void *context, void *data, const int size) { fwrite(data,1,size,(FILE*) context); } @@ -397,14 +397,14 @@ static void stbiw__putc(stbi__write_context *s, unsigned char c) s->func(s->context, &c, 1); } -static void stbiw__write1(stbi__write_context *s, unsigned char a) +static void stbiw__write1(stbi__write_context *s, const unsigned char a) { if (s->buf_used + 1 > sizeof(s->buffer)) stbiw__write_flush(s); s->buffer[s->buf_used++] = a; } -static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) +static void stbiw__write3(stbi__write_context *s, const unsigned char a, const unsigned char b, const unsigned char c) { int n; if (s->buf_used + 3 > sizeof(s->buffer)) @@ -416,7 +416,7 @@ static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char s->buffer[n+2] = c; } -static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) +static void stbiw__write_pixel(stbi__write_context *s, const int rgb_dir, const int comp, const int write_alpha, const int expand_mono, unsigned char *d) { unsigned char bg[3] = { 255, 0, 255}, px[3]; int k; @@ -449,7 +449,8 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in stbiw__write1(s, d[comp - 1]); } -static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) +static void stbiw__write_pixels(stbi__write_context *s, const int rgb_dir, int vdir, const int x, const int y, const int comp, void *data, const int write_alpha, const int scanline_pad, + const int expand_mono) { stbiw_uint32 zero = 0; int i,j, j_end; @@ -476,7 +477,7 @@ static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, i } } -static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) +static int stbiw__outfile(stbi__write_context *s, const int rgb_dir, const int vdir, const int x, const int y, const int comp, const int expand_mono, void *data, const int alpha, const int pad, const char *fmt, ...) { if (y < 0 || x < 0) { return 0; @@ -490,7 +491,7 @@ static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, } } -static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) +static int stbi_write_bmp_core(stbi__write_context *s, const int x, const int y, const int comp, const void *data) { const int pad = (-x*3) & 3; return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, @@ -499,7 +500,7 @@ static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, c 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header } -STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) +STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, const int x, const int y, const int comp, const void *data) { stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); @@ -507,7 +508,7 @@ STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, } #ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) +STBIWDEF int stbi_write_bmp(char const *filename, const int x, const int y, const int comp, const void *data) { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { @@ -519,7 +520,7 @@ STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const } #endif //!STBI_WRITE_NO_STDIO -static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) +static int stbi_write_tga_core(stbi__write_context *s, const int x, const int y, const int comp, void *data) { const int has_alpha = (comp == 2 || comp == 4); const int colorbytes = has_alpha ? comp-1 : comp; @@ -598,7 +599,7 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v return 1; } -STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) +STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, const int x, const int y, const int comp, const void *data) { stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); @@ -606,7 +607,7 @@ STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, } #ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) +STBIWDEF int stbi_write_tga(char const *filename, const int x, const int y, const int comp, const void *data) { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { @@ -641,7 +642,7 @@ static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) } } -static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) +static void stbiw__write_run_data(stbi__write_context *s, const int length, unsigned char databyte) { unsigned char lengthbyte = STBIW_UCHAR(length+128); STBIW_ASSERT(length+128 <= 255); @@ -649,7 +650,7 @@ static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned c s->func(s->context, &databyte, 1); } -static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) +static void stbiw__write_dump_data(stbi__write_context *s, const int length, unsigned char *data) { unsigned char lengthbyte = STBIW_UCHAR(length); STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code @@ -657,7 +658,7 @@ static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned s->func(s->context, data, length); } -static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) +static void stbiw__write_hdr_scanline(stbi__write_context *s, const int width, const int ncomp, unsigned char *scratch, float *scanline) { unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; unsigned char rgbe[4]; @@ -746,7 +747,7 @@ static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int nco } } -static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) +static int stbi_write_hdr_core(stbi__write_context *s, const int x, const int y, const int comp, float *data) { if (y <= 0 || x <= 0 || data == NULL) return 0; @@ -772,7 +773,7 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f } } -STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) +STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, const int x, const int y, const int comp, const float *data) { stbi__write_context s = { 0 }; stbi__start_write_callbacks(&s, func, context); @@ -780,7 +781,7 @@ STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, } #ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) +STBIWDEF int stbi_write_hdr(char const *filename, const int x, const int y, const int comp, const float *data) { stbi__write_context s = { 0 }; if (stbi__start_write_file(&s,filename)) { @@ -812,7 +813,7 @@ STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const #define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) #define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) -static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) +static void *stbiw__sbgrowf(void **arr, const int increment, const int itemsize) { const int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); @@ -845,7 +846,7 @@ static int stbiw__zlib_bitrev(int code, int codebits) return res; } -static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) +static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, const int limit) { int i; for (i=0; i < limit && i < 258; ++i) @@ -1046,13 +1047,13 @@ static unsigned int stbiw__crc32(unsigned char *buffer, int len) #define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); #define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) -static void stbiw__wpcrc(unsigned char **data, int len) +static void stbiw__wpcrc(unsigned char **data, const int len) { const unsigned int crc = stbiw__crc32(*data - len - 4, len+4); stbiw__wp32(*data, crc); } -static unsigned char stbiw__paeth(int a, int b, int c) +static unsigned char stbiw__paeth(const int a, const int b, const int c) { int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); @@ -1061,7 +1062,7 @@ static unsigned char stbiw__paeth(int a, int b, int c) } // @OPTIMIZE: provide an option that always forces left-predict or paeth predict -static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) +static void stbiw__encode_png_line(unsigned char *pixels, const int stride_bytes, const int width, const int height, const int y, const int n, const int filter_type, signed char *line_buffer) { static int mapping[] = { 0,1,2,3,4 }; static int firstmap[] = { 0,1,0,5,6 }; @@ -1097,7 +1098,7 @@ static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int } } -STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) +STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, const int x, const int y, const int n, int *out_len) { int force_filter = stbi_write_force_png_filter; const int ctype[5] = { -1, 0, 4, 2, 6 }; @@ -1184,7 +1185,7 @@ STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int s } #ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) +STBIWDEF int stbi_write_png(char const *filename, const int x, const int y, const int comp, const void *data, const int stride_bytes) { FILE *f; int len; @@ -1200,7 +1201,7 @@ STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const } #endif -STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) +STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, const int x, const int y, const int comp, const void *data, const int stride_bytes) { int len; unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); @@ -1297,7 +1298,7 @@ static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { bits[0] = val & ((1< -static void ParseOne(cParser& parser, T& out, int tokenCount = 1, bool convert = false) +static void ParseOne(cParser& parser, T& out, const int tokenCount = 1, const bool convert = false) { parser.getTokens(tokenCount, convert); parser >> out; } template -static void ParseOneClamped(cParser& parser, T& out, T minValue, T maxValue, int tokenCount = 1, bool convert = false) +static void ParseOneClamped(cParser& parser, T& out, T minValue, T maxValue, const int tokenCount = 1, const bool convert = false) { parser.getTokens(tokenCount, convert); parser >> out; diff --git a/utilities/Logs.cpp b/utilities/Logs.cpp index c0030613..7832a91b 100644 --- a/utilities/Logs.cpp +++ b/utilities/Logs.cpp @@ -158,7 +158,7 @@ void LogService() } -bool ShouldSkipLog(std::string_view str, logtype type) +bool ShouldSkipLog(const std::string_view str, logtype type) { return str.empty() || TestFlag(Global.DisabledLogTypes, static_cast(type)); @@ -173,7 +173,7 @@ std::string FormatLogMessage(std::string_view str) return std::format("[ {:8.3f} ]\t\t{}", seconds, str); } -void WriteLog(std::string_view str, logtype type, bool isError) +void WriteLog(const std::string_view str, const logtype type, bool isError) { if (ShouldSkipLog(str, type)) return; @@ -184,7 +184,7 @@ void WriteLog(std::string_view str, logtype type, bool isError) InfoStack.push_back({message, isError}); } -void ErrorLog(std::string_view str, logtype type) +void ErrorLog(const std::string_view str, const logtype type) { if (ShouldSkipLog(str, type)) return; @@ -195,7 +195,7 @@ void ErrorLog(std::string_view str, logtype type) ErrorStack.push_back(message); } -void WriteLog(const char* str, logtype type, bool isError) +void WriteLog(const char* str, const logtype type, const bool isError) { if (str == nullptr || *str == '\0') return; @@ -203,7 +203,7 @@ void WriteLog(const char* str, logtype type, bool isError) WriteLog(std::string_view{str}, type, isError); } -void ErrorLog(const char* str, logtype type) +void ErrorLog(const char* str, const logtype type) { if (str == nullptr || *str == '\0') return; diff --git a/utilities/Timer.cpp b/utilities/Timer.cpp index 3fc68128..12cb77f4 100644 --- a/utilities/Timer.cpp +++ b/utilities/Timer.cpp @@ -47,7 +47,7 @@ double GetDeltaRenderTime() return DeltaRenderTime; } -void set_delta_override(double t) +void set_delta_override(const double t) { override_delta = t; } @@ -61,7 +61,7 @@ void ResetTimers() uint64_t fr, count, oldCount; -void UpdateTimers(bool pause) +void UpdateTimers(const bool pause) { #ifdef _WIN32 QueryPerformanceFrequency((LARGE_INTEGER *)&fr); diff --git a/utilities/headtrack.cpp b/utilities/headtrack.cpp index caf62bee..5729c5ef 100644 --- a/utilities/headtrack.cpp +++ b/utilities/headtrack.cpp @@ -22,7 +22,7 @@ void headtrack::find_joy() { joy_id = -1; } -float headtrack::get_axis(const float *data, int count, int axis, float mul) { +float headtrack::get_axis(const float *data, const int count, const int axis, const float mul) { if (axis < 0) return 0.0f; if (axis >= count) diff --git a/utilities/parser.cpp b/utilities/parser.cpp index e052439d..7e53abe2 100644 --- a/utilities/parser.cpp +++ b/utilities/parser.cpp @@ -34,7 +34,7 @@ std::array makeBreakTable(const char *brk) return arr; } -char toLowerChar(char c) +char toLowerChar(const char c) { // Only fold ASCII letters. Bytes >= 0x80 belong to multibyte UTF-8 // sequences and must be passed through untouched, otherwise a non-"C" @@ -55,7 +55,7 @@ bool startsWithBOM(const std::string &s) } // namespace // constructors -cParser::cParser(std::string const &Stream, buffertype const Type, std::string Path, bool const Loadtraction, std::vector Parameters, bool allowRandom) +cParser::cParser(std::string const &Stream, buffertype const Type, std::string Path, bool const Loadtraction, std::vector Parameters, const bool allowRandom) : allowRandomIncludes(allowRandom), LoadTraction(Loadtraction), mPath(Path) { // store to calculate sub-sequent includes from relative path @@ -177,7 +177,7 @@ cParser &cParser::autoclear(bool const Autoclear) return *this; } -bool cParser::getTokens(unsigned int Count, bool ToLower, const char *Break) +bool cParser::getTokens(const unsigned int Count, const bool ToLower, const char *Break) { if (true == m_autoclear) { @@ -224,7 +224,7 @@ bool cParser::getTokens(unsigned int Count, bool ToLower, const char *Break) return true; } -std::string cParser::readTokenFromStream(bool ToLower, const char *Break) +std::string cParser::readTokenFromStream(const bool ToLower, const char *Break) { std::string token; token.reserve(64); @@ -263,7 +263,7 @@ std::string cParser::readTokenFromStream(bool ToLower, const char *Break) return token; } -void cParser::stripFirstTokenBOM(std::string& token, bool ToLower, const char* Break) { +void cParser::stripFirstTokenBOM(std::string& token, const bool ToLower, const char* Break) { if (!mFirstToken) return; mFirstToken = false; @@ -279,7 +279,7 @@ void cParser::stripFirstTokenBOM(std::string& token, bool ToLower, const char* B } } -void cParser::substituteParameters(std::string& token, bool ToLower) { +void cParser::substituteParameters(std::string& token, const bool ToLower) { if (parameters.empty()) return; // Replace occurrences of "(pN)" anywhere in token. @@ -357,7 +357,7 @@ void cParser::startIncludeFromParser(cParser& srcParser, bool ToLower, std::stri } } -bool cParser::handleIncludeIfPresent(std::string& token, bool ToLower, const char* Break) { +bool cParser::handleIncludeIfPresent(std::string& token, const bool ToLower, const char* Break) { // token-mode include: token == "include" if (expandIncludes && token == "include") { std::string includefile; @@ -391,7 +391,7 @@ bool cParser::handleIncludeIfPresent(std::string& token, bool ToLower, const cha return false; } -void cParser::readToken(std::string &out, bool ToLower, const char *Break) +void cParser::readToken(std::string &out, const bool ToLower, const char *Break) { if (mIncludeParser) { diff --git a/utilities/translation.cpp b/utilities/translation.cpp index 5cb3cbfd..d56372d0 100644 --- a/utilities/translation.cpp +++ b/utilities/translation.cpp @@ -33,7 +33,7 @@ void locale::init() WriteLog("translation: " + std::to_string(lang_mapping.size()) + " strings loaded"); } -const std::string& locale::lookup_s(const std::string &msg, bool constant) +const std::string& locale::lookup_s(const std::string &msg, const bool constant) { if (constant) { const auto it = pointer_cache.find(&msg); @@ -53,7 +53,7 @@ const std::string& locale::lookup_s(const std::string &msg, bool constant) return msg; } -const char* locale::lookup_c(const char *msg, bool constant) +const char* locale::lookup_c(const char *msg, const bool constant) { if (constant) { const auto it = pointer_cache.find(msg); diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index c7895c9d..4d975e5b 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -74,7 +74,7 @@ std::filesystem::path user_config_path(const std::string &filename) // zwraca różnicę czasu // jeśli pierwsza jest aktualna, a druga rozkładowa, to ujemna oznacza opóżnienie // na dłuższą metę trzeba uwzględnić datę, jakby opóżnienia miały przekraczać 12h (towarowych) -double CompareTime(double t1h, double t1m, double t2h, double t2m) +double CompareTime(const double t1h, const double t1m, const double t2h, const double t2m) { if (t2h < 0) @@ -170,7 +170,7 @@ double LocalRandom(double a, double b) return dist(Global.local_random_engine); } -bool FuzzyLogic(double Test, double Threshold, double Probability) +bool FuzzyLogic(const double Test, const double Threshold, const double Probability) { if (Test > Threshold && !DebugModeFlag) return Random() < Probability * Threshold * 1.0 / Test /*im wiekszy Test tym wieksza szansa*/; @@ -178,7 +178,7 @@ bool FuzzyLogic(double Test, double Threshold, double Probability) return false; } -bool FuzzyLogicAI(double Test, double Threshold, double Probability) +bool FuzzyLogicAI(const double Test, const double Threshold, const double Probability) { if (Test > Threshold) return Random() < Probability * Threshold * 1.0 / Test /*im wiekszy Test tym wieksza szansa*/; @@ -206,14 +206,14 @@ std::pair split_string_and_number(std::string const &Key) return {Key, 0}; } -std::string to_string(int Value, int width) +std::string to_string(const int Value, const int width) { std::ostringstream o; o << std::setw(width) << Value; return std::move(o).str(); }; -std::string to_string(double Value, int precision) +std::string to_string(const double Value, const int precision) { std::ostringstream o; o << std::fixed << std::setprecision(precision) << Value; @@ -260,7 +260,7 @@ std::string ToLower(std::string const &text) { auto lowercase{text}; - std::transform(std::begin(text), std::end(text), std::begin(lowercase), [](unsigned char c) { return std::tolower(c); }); + std::transform(std::begin(text), std::end(text), std::begin(lowercase), [](const unsigned char c) { return std::tolower(c); }); return lowercase; } @@ -268,7 +268,7 @@ std::string ToUpper(std::string const &text) { auto uppercase{text}; - std::transform(std::begin(text), std::end(text), std::begin(uppercase), [](unsigned char c) { return std::toupper(c); }); + std::transform(std::begin(text), std::end(text), std::begin(uppercase), [](const unsigned char c) { return std::toupper(c); }); return uppercase; } @@ -438,13 +438,13 @@ std::ptrdiff_t len_common_prefix(std::string_view a, std::string_view b) } // returns true if provided string contains another provided string -bool contains(std::string_view const String, std::string_view Substring) +bool contains(std::string_view const String, const std::string_view Substring) { // To be replaced with string::contains in C++ 23 return String.find(Substring) != std::string::npos; } -bool contains(std::string_view const String, char Character) +bool contains(std::string_view const String, const char Character) { // To be replaced with string::contains in C++ 23 return String.find(Character) != std::string::npos; diff --git a/utilities/utilities.h b/utilities/utilities.h index a9454981..384388da 100644 --- a/utilities/utilities.h +++ b/utilities/utilities.h @@ -49,7 +49,7 @@ extern bool DebugCameraFlag; extern bool DebugTractionFlag; /*funkcje matematyczne*/ -inline double Sign(double x) +inline double Sign(const double x) { return x >= 0 ? 1.0 : -1.0; } @@ -70,7 +70,7 @@ inline double Random() return Random(0.0, 1.0); } -inline double Random(double b) +inline double Random(const double b) { return Random(0.0, b); } @@ -80,7 +80,7 @@ inline double LocalRandom() return LocalRandom(0.0, 1.0); } -inline double LocalRandom(double b) +inline double LocalRandom(const double b) { return LocalRandom(0.0, b); } diff --git a/utilities/uuid.hpp b/utilities/uuid.hpp index a3128265..af2f9667 100644 --- a/utilities/uuid.hpp +++ b/utilities/uuid.hpp @@ -29,7 +29,7 @@ public: std::string to_string() const { std::ostringstream os; os << std::hex << std::setfill('0'); - auto put = [&](int i){ + auto put = [&](const int i){ os << std::setw(2) << static_cast(bytes[i]); }; // format 8-4-4-4-12 diff --git a/vehicle/Button.cpp b/vehicle/Button.cpp index d4d31877..43299266 100644 --- a/vehicle/Button.cpp +++ b/vehicle/Button.cpp @@ -16,7 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "rendering/renderer.h" -void TButton::Clear(int i) +void TButton::Clear(const int i) { *this = TButton(); if( i >= 0 ) { @@ -25,7 +25,7 @@ void TButton::Clear(int i) Update(); // kasowanie bitu Feedback, o ile jakiś ustawiony }; -bool TButton::Init( std::string const &asName, TModel3d const *pModel, bool bNewOn ) { +bool TButton::Init( std::string const &asName, TModel3d const *pModel, const bool bNewOn ) { if( pModel == nullptr ) { return false; } @@ -157,7 +157,7 @@ TButton::play() { } void -TButton::gain(float new_volume) { +TButton::gain(const float new_volume) { m_soundfxincrease.gain(new_volume); m_soundfxdecrease.gain(new_volume); } diff --git a/vehicle/Camera.cpp b/vehicle/Camera.cpp index 3c8bdd10..961aa482 100644 --- a/vehicle/Camera.cpp +++ b/vehicle/Camera.cpp @@ -39,12 +39,12 @@ void TCamera::Reset() { }; -void TCamera::OnCursorMove(double x, double y) { +void TCamera::OnCursorMove(const double x, const double y) { m_rotationoffsets.x += y; m_rotationoffsets.y += x; } -static double ComputeAxisSpeed(double param, double walkspeed, double maxspeed, double threshold) { +static double ComputeAxisSpeed(const double param, const double walkspeed, const double maxspeed, const double threshold) { const double absval = std::abs(param); // 2/3rd of the stick range lerps walk speed, past that we lerp between max walk and run speed const double walk = walkspeed * std::min(absval / threshold, 1.0); @@ -118,7 +118,7 @@ TCamera::OnCommand( command_data const &Command ) { return iscameracommand; } -static void UpdateVelocityAxis(double& velocity, double moverate, double deltatime) +static void UpdateVelocityAxis(double& velocity, const double moverate, const double deltatime) { velocity = std::clamp(velocity + moverate * 10.0 * deltatime, -std::abs(moverate), std::abs(moverate)); } diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index fdb3f74a..ad5d5654 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -366,7 +366,7 @@ std::string TSpeedPos::TableText() const return "Empty"; } -bool TSpeedPos::IsProperSemaphor(TOrders order) +bool TSpeedPos::IsProperSemaphor(const TOrders order) { // sprawdzenie czy semafor jest zgodny z trybem jazdy if (order < Obey_train) // Wait_for_orders, Prepare_engine, Change_direction, Connect, Disconnect, Shunt { @@ -383,7 +383,7 @@ bool TSpeedPos::IsProperSemaphor(TOrders order) return false; // true gdy zatrzymanie, wtedy nie ma po co skanować dalej } -bool TSpeedPos::Set(basic_event *event, double dist, double length, TOrders order) +bool TSpeedPos::Set(basic_event *event, const double dist, const double length, const TOrders order) { // zapamiętanie zdarzenia fDist = dist; iFlags = spEvent; @@ -414,7 +414,7 @@ bool TSpeedPos::Set(basic_event *event, double dist, double length, TOrders orde return false; // true gdy zatrzymanie, wtedy nie ma po co skanować dalej }; -void TSpeedPos::Set(TTrack *track, double dist, int flag) +void TSpeedPos::Set(TTrack *track, const double dist, const int flag) { // zapamiętanie zmiany prędkości w torze fDist = dist; // odległość do początku toru trTrack = track; // TODO: (t) może być NULL i nie odczytamy końca poprzedniego :/ @@ -768,7 +768,7 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle) } }; -void TController::TableCheck(double fDistance) +void TController::TableCheck(const double fDistance) { // przeliczenie odległości w tabelce, ewentualnie doskanowanie (bez analizy prędkości itp.) if( iTableDirection != iDirection ) { // jak zmiana kierunku, to skanujemy od końca składu @@ -1818,7 +1818,7 @@ void TController::TableSort() { //--------------------------------------------------------------------------- -TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, bool Primary) :// czy ma aktywnie prowadzić? +TController::TController(const bool AI, TDynamicObject *NewControll, bool InitPsyche, const bool Primary) :// czy ma aktywnie prowadzić? AIControllFlag( AI ), pVehicle( NewControll ) { if( pVehicle != nullptr ) { @@ -1918,7 +1918,7 @@ TController::~TController() }; // zamiana kodu rozkazu na opis -std::string TController::Order2Str(TOrders Order) +std::string TController::Order2Str(const TOrders Order) { if( (Order & Change_direction) != 0 @@ -2292,7 +2292,7 @@ void TController::AutoRewident() } -double TController::ESMVelocity(bool Main) +double TController::ESMVelocity(const bool Main) { constexpr double fCurrentCoeff = 0.9; constexpr double fFrictionCoeff = 0.85; @@ -2342,7 +2342,7 @@ int TController::CheckDirection() { return d; } -bool TController::CheckVehicles(TOrders user) +bool TController::CheckVehicles(const TOrders user) { // sprawdzenie stanu posiadanych pojazdów w składzie i zapalenie świateł TDynamicObject *p; // roboczy wskaźnik na pojazd iVehicles = 0; // ilość pojazdów w składzie @@ -2554,7 +2554,7 @@ bool TController::CheckVehicles(TOrders user) return true; } -void TController::Lights(int head, int rear) +void TController::Lights(const int head, const int rear) { // zapalenie świateł w skłądzie pVehicles[ front ]->RaLightsSet(head, -1); // zapalenie przednich w pierwszym pVehicles[ end::rear ]->RaLightsSet(-1, rear); // zapalenie końcówek w ostatnim @@ -2603,7 +2603,7 @@ TBrakeSystem TController::consist_brake_system() const { return isepcapable ? TBrakeSystem::ElectroPneumatic : TBrakeSystem::Pneumatic; } -int TController::OrderDirectionChange(int newdir, TMoverParameters *Vehicle) +int TController::OrderDirectionChange(const int newdir, TMoverParameters *Vehicle) { // zmiana kierunku jazdy, niezależnie od kabiny const int testd = newdir; if (Vehicle->Vel < 0.5) @@ -2633,12 +2633,12 @@ int TController::OrderDirectionChange(int newdir, TMoverParameters *Vehicle) return (int)VelforDriver; // zwraca prędkość mechanika } -void TController::WaitingSet(double Seconds) +void TController::WaitingSet(const double Seconds) { // ustawienie odczekania po zatrzymaniu (ustawienie w trakcie jazdy zatrzyma) fStopTime = -Seconds; // ujemna wartość oznacza oczekiwanie (potem >=0.0) } -void TController::SetVelocity(double NewVel, double NewVelNext, TStopReason r) +void TController::SetVelocity(const double NewVel, const double NewVelNext, const TStopReason r) { // ustawienie nowej prędkości WaitingTime = -WaitingExpireTime; // przypisujemy -WaitingExpireTime, a potem porównujemy z zerem if (NewVel == 0.0) { // jeśli ma stanąć @@ -3613,7 +3613,7 @@ void TController::ZeroSpeed( bool const Enforce ) { } } -bool TController::DecSpeed(bool force) +bool TController::DecSpeed(const bool force) { // zmniejszenie prędkości (ale nie hamowanie) bool OK = false; // domyślnie false, aby wyszło z pętli while switch (mvOccupied->EngineType) @@ -3751,7 +3751,7 @@ bool TController::DecSpeedEIM( int const Amount ) return OK; } -void TController::BrakeLevelSet(double b) +void TController::BrakeLevelSet(const double b) { // ustawienie pozycji hamulca na wartość (b) w zakresie od -2 do BrakeCtrlPosNo // jedyny dopuszczalny sposób przestawienia hamulca zasadniczego if (BrakeCtrlPosition == b) @@ -3759,7 +3759,7 @@ void TController::BrakeLevelSet(double b) BrakeCtrlPosition = std::clamp(b, (double)gbh_MIN, (double)gbh_MAX); } -bool TController::BrakeLevelAdd(double b) +bool TController::BrakeLevelAdd(const double b) { // dodanie wartości (b) do pozycji hamulca (w tym ujemnej) // zwraca false, gdy po dodaniu było by poza zakresem BrakeLevelSet(BrakeCtrlPosition + b); @@ -5102,7 +5102,7 @@ void TController::OrderCheck() OrdersClear(); // czyszczenie rozkazów i przeskok do zerowej pozycji } -void TController::OrderNext(TOrders NewOrder) +void TController::OrderNext(const TOrders NewOrder) { // ustawienie rozkazu do wykonania jako następny if (OrderList[OrderPos] == NewOrder) return; // jeśli robi to, co trzeba, to koniec @@ -5127,7 +5127,7 @@ void TController::OrderNext(TOrders NewOrder) #endif } -void TController::OrderPush(TOrders NewOrder) +void TController::OrderPush(const TOrders NewOrder) { // zapisanie na stosie kolejnego rozkazu do wykonania if (OrderPos == OrderTop) // jeśli miałby być zapis na aktalnej pozycji if (OrderList[OrderPos] < Shunt) // ale nie jedzie @@ -5155,7 +5155,7 @@ void TController::OrdersDump( std::string const Neworder, bool const Verbose ) } }; -void TController::OrdersInit(double fVel) +void TController::OrdersInit(const double fVel) { // wypełnianie tabelki rozkazów na podstawie rozkładu // ustawienie kolejności komend, niezależnie kto prowadzi OrdersClear(); // usunięcie poprzedniej tabeli @@ -5378,7 +5378,7 @@ TTrack * TController::BackwardTraceRoute(double &fDistance, double &fDirection, } // sprawdzanie zdarzeń semaforów i ograniczeń szlakowych -void TController::SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos ) +void TController::SetProximityVelocity(const double dist, const double vel, glm::dvec3 const *pos ) { // Ra:przeslanie do AI prędkości /* //!!!! zastąpić prawidłową reakcją AI na SetProximityVelocity !!!! @@ -5669,7 +5669,7 @@ void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck } }; -void TController::DirectionForward(bool forward) +void TController::DirectionForward(const bool forward) { // ustawienie jazdy do przodu dla true i do tyłu dla false (zależy od kabiny) ZeroSpeed( true ); // TODO: check if force switch is needed anymore here // HACK: make sure the master controller isn't set in position which prevents direction change @@ -5882,7 +5882,7 @@ std::string TController::OwnerName() const }; void -TController::update_timers( double dt ) { +TController::update_timers(const double dt ) { ElapsedTime += dt; WaitingTime += dt; diff --git a/vehicle/Driver.h b/vehicle/Driver.h index fe1b66d7..c94019e4 100644 --- a/vehicle/Driver.h +++ b/vehicle/Driver.h @@ -173,7 +173,7 @@ class TSpeedPos bool Update(); // aktualizuje odległość we wpisie void - UpdateDistance( double dist ) { + UpdateDistance(const double dist ) { fDist -= dist; } bool Set(basic_event *e, double d, double length, TOrders order = Wait_for_orders); void Set(TTrack *t, double d, int f); @@ -483,7 +483,7 @@ private: // methods public: int CrossRoute( TTrack *tr ); - void MoveDistanceAdd( double distance ) { + void MoveDistanceAdd(const double distance ) { dMoveLen += distance * iDirection; } //jak jedzie do tyłu to trzeba uwzględniać, że distance jest ujemna private: diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index 262aff71..f2c181e7 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -150,7 +150,7 @@ void TAnimPant::DSAx() common_pantograph_settings(); }; //--------------------------------------------------------------------------- -int TAnim::TypeSet(int i, TMoverParameters currentMover, int fl) +int TAnim::TypeSet(const int i, TMoverParameters currentMover, const int fl) { // ustawienie typu animacji i zależnej od niego ilości animowanych submodeli fMaxDist = -1.0; // normalnie nie pokazywać switch (i) @@ -329,7 +329,7 @@ bool TDynamicObject::destination_data::deserialize_mapping( cParser &Input ) { //--------------------------------------------------------------------------- -TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, int cf) +TDynamicObject * TDynamicObject::FirstFind(int &coupler_nr, const int cf) { // szukanie skrajnego połączonego pojazdu w pociagu // od strony sprzegu (coupler_nr) obiektu (start) auto temp = this; @@ -445,7 +445,7 @@ float TDynamicObject::GetEPP() }; //--------------------------------------------------------------------------- -TDynamicObject * TDynamicObject::GetFirstDynamic(int cpl_type, int cf) +TDynamicObject * TDynamicObject::GetFirstDynamic(int cpl_type, const int cf) { // Szukanie skrajnego połączonego pojazdu w pociagu // od strony sprzegu (cpl_type) obiektu szukajacego // Ra: wystarczy jedna funkcja do szukania w obu kierunkach @@ -457,7 +457,7 @@ void TDynamicObject::ABuSetModelShake(glm::dvec3 mShake) modelShake = mShake; }; -int TDynamicObject::GetPneumatic(bool front, bool red) +int TDynamicObject::GetPneumatic(const bool front, const bool red) { int x, y, z; // 1=prosty, 2=skośny if (red) @@ -494,7 +494,7 @@ int TDynamicObject::GetPneumatic(bool front, bool red) return z; } -void TDynamicObject::SetPneumatic(bool front, bool red) +void TDynamicObject::SetPneumatic(const bool front, const bool red) { int x = 0, ten = 0, @@ -1585,7 +1585,7 @@ TDynamicObject::ABuFindObject( int &Foundcoupler, double &Distance, TTrack const return foundobject; } -int TDynamicObject::DettachStatus(int dir) +int TDynamicObject::DettachStatus(const int dir) { // sprawdzenie odległości sprzęgów // rzeczywistych od strony (dir): // 0=przód,1=tył @@ -1596,7 +1596,7 @@ int TDynamicObject::DettachStatus(int dir) return MoverParameters->DettachStatus(dir); // czy jest w odpowiedniej odległości? } -int TDynamicObject::Dettach(int dir) +int TDynamicObject::Dettach(const int dir) { // rozłączenie sprzęgów rzeczywistych od // strony (dir): 0=przód,1=tył // zwraca maskę bitową aktualnych sprzegów (0 jeśli rozłączony) @@ -1885,7 +1885,7 @@ TDynamicObject::~TDynamicObject() { SafeDeleteArray( pAnimated ); // lista animowanych submodeli } -void TDynamicObject::place_on_track(TTrack *Track, double fDist, bool Reversed) +void TDynamicObject::place_on_track(TTrack *Track, double fDist, const bool Reversed) { for( auto &axle : m_axlesounds ) { // wyszukiwanie osi (0 jest na końcu, dlatego dodajemy długość?) @@ -2575,7 +2575,7 @@ TDynamicObject::create_controller( std::string const Type, bool const Trainset ) } } -void TDynamicObject::FastMove(double fDistance) +void TDynamicObject::FastMove(const double fDistance) { MoverParameters->dMoveLen = MoverParameters->dMoveLen + fDistance; } @@ -2726,7 +2726,7 @@ void TDynamicObject::Move(double fDistance) } }; -void TDynamicObject::AttachNext(TDynamicObject *Object, int iType) +void TDynamicObject::AttachNext(TDynamicObject *Object, const int iType) { // Ra: doczepia Object na końcu składu (nazwa funkcji może być myląca) // Ra: używane tylko przy wczytywaniu scenerii auto const vehicleend { iDirection }; @@ -2773,7 +2773,7 @@ void TDynamicObject::AttachNext(TDynamicObject *Object, int iType) Object->update_neighbours(); } -bool TDynamicObject::UpdateForce(double dt) +bool TDynamicObject::UpdateForce(const double dt) { if (!bEnabled) return false; @@ -4217,7 +4217,7 @@ glm::dvec3 TDynamicObject::get_future_movement() const return m_future_movement; } -void TDynamicObject::move_set(double distance) +void TDynamicObject::move_set(const double distance) { auto d = this; while( d ) { @@ -4231,7 +4231,7 @@ void TDynamicObject::move_set(double distance) } } -bool TDynamicObject::FastUpdate(double dt) +bool TDynamicObject::FastUpdate(const double dt) { if (dt == 0.0) return true; // Ra: pauza @@ -7157,7 +7157,7 @@ void TDynamicObject::RadioStop() }; //--------------------------------------------------------------------------- -void TDynamicObject::Damage(char flag) +void TDynamicObject::Damage(const char flag) { if (flag & 1) //różnicówka nie robi nic { @@ -7258,7 +7258,7 @@ void TDynamicObject::SetLights() { } }; -void TDynamicObject::RaLightsSet(int head, int rear) +void TDynamicObject::RaLightsSet(const int head, int rear) { // zapalenie świateł z przodu i z // tyłu, zależne od kierunku // pojazdu @@ -7461,7 +7461,7 @@ bool TDynamicObject::has_signal_on( int const Side, int const Pattern ) const { return MoverParameters->iLights[Side] == (Pattern & iInventory[Side]); } -int TDynamicObject::DirectionSet(int d) +int TDynamicObject::DirectionSet(const int d) { // ustawienie kierunku w składzie (wykonuje AI) auto const lastdirection { iDirection }; iDirection = d > 0 ? 1 : 0; // d:1=zgodny,-1=przeciwny; iDirection:1=zgodny,0=przeciwny; @@ -7488,10 +7488,10 @@ int TDynamicObject::DirectionSet(int d) TDynamicObject * TDynamicObject::PrevAny() const { return MoverParameters->Neighbours[ iDirection ^ 1 ].vehicle; } -TDynamicObject * TDynamicObject::Prev(int C) const { +TDynamicObject * TDynamicObject::Prev(const int C) const { return MoverParameters->Couplers[iDirection ^ 1].CouplingFlag & C ? MoverParameters->Neighbours[iDirection ^ 1].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było } -TDynamicObject * TDynamicObject::Next(int C) const { +TDynamicObject * TDynamicObject::Next(const int C) const { return MoverParameters->Couplers[iDirection].CouplingFlag & C ? MoverParameters->Neighbours[iDirection].vehicle : nullptr;// gdy sprzęg wirtualny, to jakby nic nie było } @@ -7719,7 +7719,7 @@ TDynamicObject::FindPantographCarrier() { //--------------------------------------------------------------------------- -void TDynamicObject::ParamSet(int what, int into) +void TDynamicObject::ParamSet(const int what, const int into) { // ustawienie lokalnego parametru (what) na stan (into) switch (what & 0xFF00) { @@ -7921,7 +7921,7 @@ followup: } } -void TDynamicObject::OverheadTrack(float o) +void TDynamicObject::OverheadTrack(const float o) { // ewentualne wymuszanie jazdy // bezprądowej z powodu informacji // w torze @@ -8574,7 +8574,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // legacy method, calculates changes in simulation state over specified time void -vehicle_table::update( double Deltatime, int Iterationcount ) { +vehicle_table::update(const double Deltatime, const int Iterationcount ) { // Ra: w zasadzie to trzeba by utworzyć oddzielną listę taboru do liczenia fizyki // na którą by się zapisywały wszystkie pojazdy będące w ruchu // pojazdy stojące nie potrzebują aktualizacji, chyba że np. ktoś im zmieni nastawę hamulca diff --git a/vehicle/DynObj.h b/vehicle/DynObj.h index 151ff2f6..7c48d4c8 100644 --- a/vehicle/DynObj.h +++ b/vehicle/DynObj.h @@ -621,7 +621,7 @@ private: TDynamicObject * PrevAny() const; TDynamicObject * Prev(int C = -1) const; TDynamicObject * Next(int C = -1) const; - void SetdMoveLen(double dMoveLen) { + void SetdMoveLen(const double dMoveLen) { MoverParameters->dMoveLen = dMoveLen; } void ResetdMoveLen() { MoverParameters->dMoveLen = 0; } diff --git a/vehicle/Gauge.cpp b/vehicle/Gauge.cpp index 9dd97766..ae5421d8 100644 --- a/vehicle/Gauge.cpp +++ b/vehicle/Gauge.cpp @@ -284,7 +284,7 @@ TGauge::Load_mapping( cParser &Input, scratch_data &Scratchpad ) { // ustawienie wartości docelowej. plays provided fallback sound, if no sound was defined in the control itself bool -TGauge::UpdateValue( float fNewDesired, std::optional &Fallbacksound ) { +TGauge::UpdateValue(const float fNewDesired, std::optional &Fallbacksound ) { if( false == UpdateValue( fNewDesired ) ) { if( Fallbacksound ) { @@ -296,7 +296,7 @@ TGauge::UpdateValue( float fNewDesired, std::optional &Fallbacksou } bool -TGauge::UpdateValue( float fNewDesired ) { +TGauge::UpdateValue(const float fNewDesired ) { auto const desiredtimes100 = static_cast( std::round( 100.0 * fNewDesired ) ); if( desiredtimes100 == static_cast( std::round( 100.0 * m_targetvalue ) ) ) { @@ -338,7 +338,7 @@ TGauge::UpdateValue( float fNewDesired ) { return false; // no suitable sound was found }; -void TGauge::PutValue(float fNewDesired) +void TGauge::PutValue(const float fNewDesired) { // McZapkie-281102: natychmiastowe wpisanie wartosci m_targetvalue = fNewDesired; m_value = m_targetvalue; diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index 980b7dc9..2ca45bce 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -162,7 +162,7 @@ void TCab::Load(cParser &Parser) bOccupied = true; } -TGauge &TCab::Gauge(int n) +TGauge &TCab::Gauge(const int n) { // pobranie adresu obiektu aniomowanego ruchem /* if (n < 0) @@ -185,7 +185,7 @@ TGauge &TCab::Gauge(int n) } }; -TButton &TCab::Button(int n) +TButton &TCab::Button(const int n) { // pobranie adresu obiektu animowanego wyborem 1 z 2 /* if (n < 0) @@ -633,7 +633,7 @@ TTrain::TTrain() TTrain::~TTrain() {} -bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d) +bool TTrain::Init(TDynamicObject *NewDynamicObject, const bool e3d) { // powiązanie ręcznego sterowania kabiną z pojazdem if (NewDynamicObject->Mechanik == nullptr) { @@ -10286,7 +10286,7 @@ void TTrain::update_sounds_radio() } } -void TTrain::update_screens(double dt) +void TTrain::update_screens(const double dt) { for (auto &screen : m_screens) { @@ -10322,7 +10322,7 @@ void TTrain::add_distance(double const Distance) } } -bool TTrain::CabChange(int iDirection) +bool TTrain::CabChange(const int iDirection) { // McZapkie-090902: zmiana kabiny 1->0->2 i z powrotem if (DynamicObject->Mechanik == nullptr || true == DynamicObject->Mechanik->AIControllFlag) { @@ -10823,7 +10823,7 @@ return (token == "none"); return true; } -glm::dvec3 TTrain::MirrorPosition(bool lewe) +glm::dvec3 TTrain::MirrorPosition(const bool lewe) { // zwraca współrzędne widoku kamery z lusterka auto const shiftdirection{(lewe ? -1 : 1) * (iCabn == 2 ? 1 : -1)}; @@ -12472,7 +12472,7 @@ void train_table::updateAsync(double dt) } } -void train_table::update(double dt) +void train_table::update(const double dt) { for (TTrain *train : m_items) { diff --git a/vr/openvr_imp.cpp b/vr/openvr_imp.cpp index 6c37ff3c..ea5557b0 100644 --- a/vr/openvr_imp.cpp +++ b/vr/openvr_imp.cpp @@ -30,7 +30,7 @@ vr_openvr::vr_openvr() hiddenarea_mesh[(size_t)eye_right] = create_hiddenarea_model(eye_right); } -std::unique_ptr vr_openvr::create_hiddenarea_model(eye_e e) +std::unique_ptr vr_openvr::create_hiddenarea_model(const eye_e e) { vr::HiddenAreaMesh_t mesh = vr_system->GetHiddenAreaMesh(e == eye_left ? vr::Eye_Left : vr::Eye_Right, vr::k_eHiddenAreaMesh_Standard); if (!mesh.unTriangleCount) @@ -52,7 +52,7 @@ std::unique_ptr vr_openvr::create_hiddenarea_model(eye_e e) return model; } -TModel3d* vr_openvr::get_hiddenarea_mesh(eye_e eye) +TModel3d* vr_openvr::get_hiddenarea_mesh(const eye_e eye) { return hiddenarea_mesh[(size_t)eye].get(); }; @@ -64,7 +64,7 @@ glm::ivec2 vr_openvr::get_target_size() return glm::ivec2(vr_w, vr_h); } -viewport_proj_config vr_openvr::get_proj_config(eye_e e) +viewport_proj_config vr_openvr::get_proj_config(const eye_e e) { vr::EVREye eye = e == eye_left ? vr::Eye_Left : vr::Eye_Right; @@ -351,7 +351,7 @@ bool vr_openvr::update_component(const std::string &rendermodel, vr::VRInputValu return !(component_state.uProperties & vr::VRComponentProperty_IsStatic); } -void vr_openvr::submit(eye_e eye, opengl_texture* tex) +void vr_openvr::submit(const eye_e eye, opengl_texture* tex) { vr::Texture_t hmd_tex = { (void*)(uint64_t)tex->id, diff --git a/vr/vr_interface.cpp b/vr/vr_interface.cpp index 06baab3d..e7395460 100644 --- a/vr/vr_interface.cpp +++ b/vr/vr_interface.cpp @@ -4,7 +4,7 @@ vr_interface::~vr_interface() {} -bool vr_interface_factory::register_backend(const std::string &backend, create_method func) +bool vr_interface_factory::register_backend(const std::string &backend, const create_method func) { backends[backend] = func; return true; diff --git a/widgets/cameraview_extcam.cpp b/widgets/cameraview_extcam.cpp index 36116a9c..f0e85065 100644 --- a/widgets/cameraview_extcam.cpp +++ b/widgets/cameraview_extcam.cpp @@ -70,7 +70,7 @@ void ui::cameraview_panel::render() ImGui::End(); } -bool ui::cameraview_panel::set_state(bool rec) +bool ui::cameraview_panel::set_state(const bool rec) { if (recording == rec) return false; diff --git a/windows.cpp b/windows.cpp index df036435..212d6524 100644 --- a/windows.cpp +++ b/windows.cpp @@ -15,8 +15,8 @@ WNDPROC BaseWindowProc; PCOPYDATASTRUCT pDane; LRESULT APIENTRY WndProc( HWND hWnd, // handle for this window - UINT uMsg, // message for this window - WPARAM wParam, // additional message information + const UINT uMsg, // message for this window + const WPARAM wParam, // additional message information LPARAM lParam) // additional message information { switch( uMsg ) // check for windows messages diff --git a/world/Event.cpp b/world/Event.cpp index b6011978..e3ca78e1 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -2351,7 +2351,7 @@ event_manager::insert( basic_event *Event ) { return true; } -basic_event * event_manager::FindEventById(uint32_t id) +basic_event * event_manager::FindEventById(const uint32_t id) { if (id < m_events.size()) return m_events[id]; @@ -2381,7 +2381,7 @@ event_manager::FindEvent( std::string const &Name ) // legacy method, inserts specified event in the event query bool -event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, double delay ) { +event_manager::AddToQuery( basic_event *Event, TDynamicObject const *Owner, const double delay ) { if( Event->m_passive ) { return false; } // jeśli może być dodany do kolejki (nie używany w skanowaniu) if( Event->m_inqueue > 0 ) { return false; } // jeśli nie dodany jeszcze do kolejki diff --git a/world/Event.h b/world/Event.h index f189e74c..11ddf99f 100644 --- a/world/Event.h +++ b/world/Event.h @@ -723,7 +723,7 @@ private: inline void -basic_event::group( scene::group_handle Group ) { +basic_event::group(const scene::group_handle Group ) { m_group = Group; } diff --git a/world/Segment.cpp b/world/Segment.cpp index 387522df..91c9bbd1 100644 --- a/world/Segment.cpp +++ b/world/Segment.cpp @@ -304,7 +304,7 @@ glm::dvec3 TSegment::GetDirection(double const fDistance) const return FastGetPoint(t2) - FastGetPoint(t1); } -glm::dvec3 TSegment::FastGetDirection(double fDistance, double fOffset) +glm::dvec3 TSegment::FastGetDirection(const double fDistance, const double fOffset) { // takie toporne liczenie pochodnej dla parametru 0.0÷1.0 const double t1 = fDistance - fOffset; if (t1 <= 0.0) diff --git a/world/Spring.cpp b/world/Spring.cpp index b58d8859..2c08a587 100644 --- a/world/Spring.cpp +++ b/world/Spring.cpp @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "world/Spring.h" -void TSpring::Init(double nKs, double nKd) { +void TSpring::Init(const double nKs, const double nKd) { Ks = nKs; Kd = nKd; ks = Ks; diff --git a/world/Track.cpp b/world/Track.cpp index 641d09db..65e77d34 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -117,7 +117,7 @@ TIsolated::AssignEvents() { evDec = simulation::Events.FindEvent( asName + ":dec" ); } -void TIsolated::Modify(int i, TDynamicObject *o) +void TIsolated::Modify(const int i, TDynamicObject *o) { // dodanie lub odjęcie osi if (iAxles) { // grupa zajęta @@ -207,7 +207,7 @@ TTrack::sort_by_material( TTrack const *Left, TTrack const *Right ) { return std::tie( Left->m_material1, Left->m_material2 ) < std::tie( Right->m_material1, Right->m_material2 ); } -TTrack * TTrack::Create400m(int what, double dx) +TTrack * TTrack::Create400m(const int what, const double dx) { // tworzenie toru do wstawiania taboru podczas konwersji na E3D scene::node_data nodedata; nodedata.name = "auto_400m"; // track isn't visible so only name is needed @@ -321,7 +321,7 @@ TTrack * TTrack::NullCreate(int dir) return trk; }; -void TTrack::ConnectPrevPrev(TTrack *pTrack, int typ) +void TTrack::ConnectPrevPrev(TTrack *pTrack, const int typ) { //łączenie torów - Point1 własny do Point1 cudzego if (pTrack) { //(pTrack) może być zwrotnicą, a (this) tylko zwykłym odcinkiem @@ -331,7 +331,7 @@ void TTrack::ConnectPrevPrev(TTrack *pTrack, int typ) pTrack->iPrevDirection = 0; } } -void TTrack::ConnectPrevNext(TTrack *pTrack, int typ) +void TTrack::ConnectPrevNext(TTrack *pTrack, const int typ) { //łaczenie torów - Point1 własny do Point2 cudzego if (pTrack) { @@ -350,7 +350,7 @@ void TTrack::ConnectPrevNext(TTrack *pTrack, int typ) pTrack->iTrapezoid |= 2; // to rysujemy potworka } } -void TTrack::ConnectNextPrev(TTrack *pTrack, int typ) +void TTrack::ConnectNextPrev(TTrack *pTrack, const int typ) { //łaczenie torów - Point2 własny do Point1 cudzego if (pTrack) { @@ -369,7 +369,7 @@ void TTrack::ConnectNextPrev(TTrack *pTrack, int typ) iTrapezoid |= 2; // to rysujemy potworka } } -void TTrack::ConnectNextNext(TTrack *pTrack, int typ) +void TTrack::ConnectNextNext(TTrack *pTrack, const int typ) { //łaczenie torów - Point2 własny do Point2 cudzego if (pTrack) { @@ -1252,7 +1252,7 @@ void TTrack::get_map_active_paths(map_colored_paths &handles) } } -void TTrack::get_map_paths_for_state(map_colored_paths &handles, int state) +void TTrack::get_map_paths_for_state(map_colored_paths &handles, const int state) { if (iCategoryFlag != 1 || eType != tt_Switch) return; @@ -1759,7 +1759,7 @@ void TTrack::RenderDynSounds() } }; //--------------------------------------------------------------------------- -bool TTrack::SetConnections(int i) +bool TTrack::SetConnections(const int i) { // przepisanie aktualnych połączeń toru do odpowiedniego segmentu if (SwitchExtension) { @@ -1887,7 +1887,7 @@ bool TTrack::Switch(int i, float const t, float const d) return false; }; -bool TTrack::SwitchForced(int i, TDynamicObject *o) +bool TTrack::SwitchForced(const int i, TDynamicObject *o) { // rozprucie rozjazdu if (SwitchExtension) if (eType == tt_Switch) @@ -1915,7 +1915,7 @@ bool TTrack::SwitchForced(int i, TDynamicObject *o) return true; }; -int TTrack::CrossSegment(int from, int into) +int TTrack::CrossSegment(const int from, const int into) { // ustawienie wskaźnika na segement w pożądanym kierunku (into) od strony (from) // zwraca kod segmentu, z kierunkiem jazdy jako znakiem ± int i = 0; @@ -2540,7 +2540,7 @@ void TTrack::MovedUp1(float const dh) }; // ustawienie prędkości z ograniczeniem do pierwotnej wartości (zapisanej w scenerii) -void TTrack::VelocitySet(float v) { +void TTrack::VelocitySet(const float v) { // TBD, TODO: add a variable to preserve potential speed limit set by the track configuration on basic track pieces if( SwitchExtension && SwitchExtension->fVelocity != -1 ) { @@ -2602,7 +2602,7 @@ TTrack::DoubleSlip() const { } -TTrack * TTrack::Connected(int s, double &d) const +TTrack * TTrack::Connected(const int s, double &d) const { // zwraca wskaźnik na sąsiedni tor, w kierunku określonym znakiem (s), odwraca (d) w razie // niezgodności kierunku torów TTrack *t; // nie zmieniamy kierunku (d), jeśli nie ma toru dalej diff --git a/world/Track.h b/world/Track.h index 366a10bf..2e87437c 100644 --- a/world/Track.h +++ b/world/Track.h @@ -309,7 +309,7 @@ public: TTrack * RaAnimate(); void RadioStop(); - void AxleCounter(int i, TDynamicObject *o) { + void AxleCounter(const int i, TDynamicObject *o) { for (TIsolated *iso : Isolated) iso->Modify(i, o); }; // dodanie lub odjęcie osi std::string RemoteIsolatedName(); diff --git a/world/Traction.cpp b/world/Traction.cpp index 575ab172..2f05a31f 100644 --- a/world/Traction.cpp +++ b/world/Traction.cpp @@ -358,7 +358,7 @@ int TTraction::TestPoint(glm::dvec3 const &Point) //łączenie segmentu (with) od strony (my) do jego (to) void -TTraction::Connect(int my, TTraction *with, int to) { +TTraction::Connect(const int my, TTraction *with, const int to) { hvNext[ my ] = with; iNext[ my ] = to; @@ -463,7 +463,7 @@ void TTraction::PowerSet(TTractionPowerSource *ps) } }; -double TTraction::VoltageGet(double u, double i) +double TTraction::VoltageGet(const double u, const double i) { // pobranie napięcia na przęśle po podłączeniu do niego rezystancji (res) - na razie jest to prąd if (!psSection) if (!psPowered) diff --git a/world/TractionPower.cpp b/world/TractionPower.cpp index e70674ab..b07a681f 100644 --- a/world/TractionPower.cpp +++ b/world/TractionPower.cpp @@ -71,7 +71,7 @@ bool TTractionPowerSource::Load(cParser *parser) { return true; }; -bool TTractionPowerSource::Update(double dt) +bool TTractionPowerSource::Update(const double dt) { // powinno być wykonane raz na krok fizyki // iloczyn napięcia i admitancji daje prąd if( FastFuse || SlowFuse ) { @@ -114,7 +114,7 @@ bool TTractionPowerSource::Update(double dt) return true; }; -double TTractionPowerSource::CurrentGet(double res) +double TTractionPowerSource::CurrentGet(const double res) { // pobranie wartości prądu przypadającego na rezystancję (res) // niech pamięta poprzednią admitancję i wg niej przydziela prąd if (SlowFuse || FastFuse) diff --git a/world/TrkFoll.cpp b/world/TrkFoll.cpp index 1bd8b679..4c2861b6 100644 --- a/world/TrkFoll.cpp +++ b/world/TrkFoll.cpp @@ -26,7 +26,7 @@ TTrackFollower::~TTrackFollower() { } -bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, double fDir) +bool TTrackFollower::Init(TTrack *pTrack, TDynamicObject *NewOwner, const double fDir) { fDirection = fDir; Owner = NewOwner; @@ -44,7 +44,7 @@ void TTrackFollower::Reset() fDirection = 1.0; } -TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end) +TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, const int end) { // przejechanie na inny odcinkek toru, z ewentualnym rozpruciem if (pTrack) switch (pTrack->eType) @@ -97,7 +97,7 @@ TTrack * TTrackFollower::SetCurrentTrack(TTrack *pTrack, int end) return pCurrentTrack; }; -bool TTrackFollower::Move(double fDistance, bool bPrimary) +bool TTrackFollower::Move(double fDistance, const bool bPrimary) { // przesuwanie wózka po torach o odległość (fDistance), z wyzwoleniem eventów // bPrimary=true - jest pierwszą osią w pojeździe, czyli generuje eventy i przepisuje pojazd // Ra: zwraca false, jeśli pojazd ma być usunięty diff --git a/world/mtable.cpp b/world/mtable.cpp index 19b58748..3313c38a 100644 --- a/world/mtable.cpp +++ b/world/mtable.cpp @@ -22,7 +22,7 @@ double TTrainParameters::CheckTrainLatency() return 0; } -double TTrainParameters::WatchMTable(double DistCounter) +double TTrainParameters::WatchMTable(const double DistCounter) { // zwraca odleglość do najblizszej stacji z zatrzymaniem double dist; @@ -105,7 +105,7 @@ bool TTrainParameters::UpdateMTable( scenario_time const &Time, std::string cons return UpdateMTable( Time.data().wHour, Time.data().wMinute + Time.data().wSecond * 0.0167, NewName ); } -bool TTrainParameters::UpdateMTable(double hh, double mm, std::string const &NewName) +bool TTrainParameters::UpdateMTable(const double hh, const double mm, std::string const &NewName) /*odfajkowanie dojechania do stacji (NewName) i przeliczenie opóźnienia*/ { bool OK; @@ -163,7 +163,7 @@ void TTrainParameters::StationIndexInc() ++StationIndex; } -bool TTrainParameters::IsTimeToGo(double hh, double mm) +bool TTrainParameters::IsTimeToGo(const double hh, const double mm) // sprawdzenie, czy można już odjechać z aktualnego zatrzymania // StationIndex to numer następnego po dodarciu do aktualnego { @@ -231,7 +231,7 @@ void TTrainParameters::NewName(std::string const &NewTrainName) LocLoad = 0; } -void TTrainParameters::UpdateVelocity(int StationCount, double vActual) +void TTrainParameters::UpdateVelocity(const int StationCount, const double vActual) // zapisywanie prędkości maksymalnej do wcześniejszych odcinków // wywoływane z numerem ostatniego przetworzonego przystanku { @@ -674,7 +674,7 @@ void TTrainParameters::serialize( dictionary_source *Output ) const { } } -void TMTableTime::UpdateMTableTime(double deltaT) +void TMTableTime::UpdateMTableTime(const double deltaT) // dodanie czasu (deltaT) w sekundach, z przeliczeniem godziny { mr += deltaT; // dodawanie sekund diff --git a/world/mtable.h b/world/mtable.h index d8d06fa0..d0b0e0c0 100644 --- a/world/mtable.h +++ b/world/mtable.h @@ -105,7 +105,7 @@ class TMTableTime int mm = 0; double mr = 0.0; void UpdateMTableTime(double deltaT); - TMTableTime(int InitH, int InitM ) : + TMTableTime(const int InitH, const int InitM ) : hh( InitH ), mm( InitM ) {}