1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

General code refactoring/improvements in server, treegen and connection

This commit is contained in:
sfan5 2024-03-12 14:13:24 +01:00
parent 24f2c38093
commit bc4ab8b99e
34 changed files with 330 additions and 439 deletions

View file

@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// myrand
PcgRandom g_pcgrand;
static PcgRandom g_pcgrand;
u32 myrand()
{
@ -187,7 +187,7 @@ s16 adjustDist(s16 dist, float zoom_fov)
return std::round(adjustDist((float)dist, zoom_fov));
}
void setPitchYawRollRad(core::matrix4 &m, const v3f &rot)
void setPitchYawRollRad(core::matrix4 &m, v3f rot)
{
f64 a1 = rot.Z, a2 = rot.X, a3 = rot.Y;
f64 c1 = cos(a1), s1 = sin(a1);

View file

@ -250,6 +250,16 @@ int myrand_range(int min, int max);
float myrand_range(float min, float max);
float myrand_float();
// Implements a C++11 UniformRandomBitGenerator using the above functions
struct MyRandGenerator {
typedef u32 result_type;
static constexpr result_type min() { return 0; }
static constexpr result_type max() { return MYRAND_RANGE; }
inline result_type operator()() {
return myrand();
}
};
/*
Miscellaneous functions
*/
@ -448,18 +458,18 @@ inline void wrappedApproachShortest(T &current, const T target, const T stepsize
}
}
void setPitchYawRollRad(core::matrix4 &m, const v3f &rot);
void setPitchYawRollRad(core::matrix4 &m, v3f rot);
inline void setPitchYawRoll(core::matrix4 &m, const v3f &rot)
inline void setPitchYawRoll(core::matrix4 &m, v3f rot)
{
setPitchYawRollRad(m, rot * core::DEGTORAD64);
setPitchYawRollRad(m, rot * core::DEGTORAD);
}
v3f getPitchYawRollRad(const core::matrix4 &m);
inline v3f getPitchYawRoll(const core::matrix4 &m)
{
return getPitchYawRollRad(m) * core::RADTODEG64;
return getPitchYawRollRad(m) * core::RADTODEG;
}
// Muliply the RGB value of a color linearly, and clamp to black/white

View file

@ -574,7 +574,7 @@ bool parseColorString(const std::string &value, video::SColor &color, bool quiet
return success;
}
std::string encodeHexColorString(const video::SColor &color)
std::string encodeHexColorString(video::SColor color)
{
std::string color_string = "#";
const char red = color.getRed();

View file

@ -97,7 +97,7 @@ char *mystrtok_r(char *s, const char *sep, char **lasts) noexcept;
u64 read_seed(const char *str);
bool parseColorString(const std::string &value, video::SColor &color, bool quiet,
unsigned char default_alpha = 0xff);
std::string encodeHexColorString(const video::SColor &color);
std::string encodeHexColorString(video::SColor color);
/**