aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Color.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/Color.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.World/Color.cpp')
-rw-r--r--Minecraft.World/Color.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/Minecraft.World/Color.cpp b/Minecraft.World/Color.cpp
index 256e9017..554ee379 100644
--- a/Minecraft.World/Color.cpp
+++ b/Minecraft.World/Color.cpp
@@ -18,7 +18,7 @@ Color::Color( float r, float g, float b)
assert( b >= 0.0f && b <= 1.0f );
//argb
- colour = ( (0xFF<<24) | ( (int)(r*255)<<16 ) | ( (int)(g*255)<<8 ) | ( (int)(b*255) ) );
+ colour = ( (0xFF<<24) | ( static_cast<int>(r * 255)<<16 ) | ( static_cast<int>(g * 255)<<8 ) | static_cast<int>(b * 255) );
}
Color::Color( int r, int g, int b)
@@ -43,7 +43,7 @@ Color Color::getHSBColor(float hue, float saturation, float brightness)
int r = 0, g = 0, b = 0;
if (saturation == 0)
{
- r = g = b = (int) (brightness * 255.0f + 0.5f);
+ r = g = b = static_cast<int>(brightness * 255.0f + 0.5f);
}
else
{
@@ -52,37 +52,37 @@ Color Color::getHSBColor(float hue, float saturation, float brightness)
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
- switch ((int) h)
+ switch (static_cast<int>(h))
{
case 0:
- r = (int) (brightness * 255.0f + 0.5f);
- g = (int) (t * 255.0f + 0.5f);
- b = (int) (p * 255.0f + 0.5f);
+ r = static_cast<int>(brightness * 255.0f + 0.5f);
+ g = static_cast<int>(t * 255.0f + 0.5f);
+ b = static_cast<int>(p * 255.0f + 0.5f);
break;
case 1:
- r = (int) (q * 255.0f + 0.5f);
- g = (int) (brightness * 255.0f + 0.5f);
- b = (int) (p * 255.0f + 0.5f);
+ r = static_cast<int>(q * 255.0f + 0.5f);
+ g = static_cast<int>(brightness * 255.0f + 0.5f);
+ b = static_cast<int>(p * 255.0f + 0.5f);
break;
case 2:
- r = (int) (p * 255.0f + 0.5f);
- g = (int) (brightness * 255.0f + 0.5f);
- b = (int) (t * 255.0f + 0.5f);
+ r = static_cast<int>(p * 255.0f + 0.5f);
+ g = static_cast<int>(brightness * 255.0f + 0.5f);
+ b = static_cast<int>(t * 255.0f + 0.5f);
break;
case 3:
- r = (int) (p * 255.0f + 0.5f);
- g = (int) (q * 255.0f + 0.5f);
- b = (int) (brightness * 255.0f + 0.5f);
+ r = static_cast<int>(p * 255.0f + 0.5f);
+ g = static_cast<int>(q * 255.0f + 0.5f);
+ b = static_cast<int>(brightness * 255.0f + 0.5f);
break;
case 4:
- r = (int) (t * 255.0f + 0.5f);
- g = (int) (p * 255.0f + 0.5f);
- b = (int) (brightness * 255.0f + 0.5f);
+ r = static_cast<int>(t * 255.0f + 0.5f);
+ g = static_cast<int>(p * 255.0f + 0.5f);
+ b = static_cast<int>(brightness * 255.0f + 0.5f);
break;
case 5:
- r = (int) (brightness * 255.0f + 0.5f);
- g = (int) (p * 255.0f + 0.5f);
- b = (int) (q * 255.0f + 0.5f);
+ r = static_cast<int>(brightness * 255.0f + 0.5f);
+ g = static_cast<int>(p * 255.0f + 0.5f);
+ b = static_cast<int>(q * 255.0f + 0.5f);
break;
}
}