mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 03:29:19 +02:00
reformat: parameters can be made const
This commit is contained in:
@@ -17,7 +17,7 @@ class float3
|
||||
public:
|
||||
float x, y, z;
|
||||
float3(void){};
|
||||
float3(float a, float b, float c)
|
||||
float3(const float a, const float b, const float c)
|
||||
{
|
||||
x = a;
|
||||
y = b;
|
||||
@@ -102,7 +102,7 @@ class float4
|
||||
x = y = z = 0.f;
|
||||
w = 1.f;
|
||||
};
|
||||
float4(float a, float b, float c, float d)
|
||||
float4(const float a, const float b, const float c, const float d)
|
||||
{
|
||||
x = a;
|
||||
y = b;
|
||||
@@ -164,7 +164,7 @@ inline float4 &operator*=(float4 &v1, float const d)
|
||||
v1.w *= d;
|
||||
return v1;
|
||||
};
|
||||
inline float4 Slerp(const float4 &q0, const float4 &q1, float t)
|
||||
inline float4 Slerp(const float4 &q0, const float4 &q1, const float t)
|
||||
// void Slerp(QUATERNION *Out, const QUATERNION &q0, const QUATERNION &q1, float t)
|
||||
{ // interpolacja sweryczna
|
||||
float cosOmega = Dot(q0, q1);
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
for (int i = 0; i < 16; ++i)
|
||||
e[i] = f[i];
|
||||
};
|
||||
float * operator()(int i)
|
||||
float * operator()(const int i)
|
||||
{
|
||||
return &e[i << 2];
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
e[i] = 0;
|
||||
e[0] = e[5] = e[10] = e[15] = 1.0f;
|
||||
}
|
||||
const float *operator[](int i) const
|
||||
const float *operator[](const int i) const
|
||||
{
|
||||
return &e[i << 2];
|
||||
};
|
||||
@@ -331,13 +331,12 @@ inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2)
|
||||
};
|
||||
|
||||
// From code in Graphics Gems; p. 766
|
||||
inline float Det2x2(float a, float b, float c, float d)
|
||||
inline float Det2x2(const float a, const float b, const float c, const float d)
|
||||
{ // obliczenie wyznacznika macierzy 2×2
|
||||
return a * d - b * c;
|
||||
};
|
||||
|
||||
inline float Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2,
|
||||
float c3)
|
||||
inline float Det3x3(const float a1, const float a2, const float a3, const float b1, const float b2, const float b3, const float c1, const float c2, const float c3)
|
||||
{ // obliczenie wyznacznika macierzy 3×3
|
||||
return +a1 * Det2x2(b2, b3, c2, c3) - b1 * Det2x2(a2, a3, c2, c3) + c1 * Det2x2(a2, a3, b2, b3);
|
||||
};
|
||||
|
||||
@@ -44,14 +44,14 @@ void global_settings::LoadIniFile(std::string asFileName)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
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 <typename T>
|
||||
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;
|
||||
|
||||
@@ -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<unsigned int>(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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -34,7 +34,7 @@ std::array<bool, 256> 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<std::string> Parameters, bool allowRandom)
|
||||
cParser::cParser(std::string const &Stream, buffertype const Type, std::string Path, bool const Loadtraction, std::vector<std::string> 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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<std::string, int> 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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<int>(bytes[i]);
|
||||
};
|
||||
// format 8-4-4-4-12
|
||||
|
||||
Reference in New Issue
Block a user