From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: 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 --- Minecraft.World/Stats.cpp | 64 +++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'Minecraft.World/Stats.cpp') diff --git a/Minecraft.World/Stats.cpp b/Minecraft.World/Stats.cpp index c8a615ff..43ff486c 100644 --- a/Minecraft.World/Stats.cpp +++ b/Minecraft.World/Stats.cpp @@ -27,30 +27,30 @@ vector *Stats::itemsCraftedStats = new vector; vector *Stats::blocksPlacedStats = new vector; #endif -Stat *Stats::walkOneM = NULL; -Stat *Stats::swimOneM = NULL; -Stat *Stats::fallOneM = NULL; -Stat *Stats::climbOneM = NULL; -Stat *Stats::minecartOneM = NULL; -Stat *Stats::boatOneM = NULL; -Stat *Stats::pigOneM = NULL; -Stat *Stats::portalsCreated = NULL; -Stat *Stats::cowsMilked = NULL; -Stat *Stats::netherLavaCollected = NULL; -Stat *Stats::killsZombie = NULL; -Stat *Stats::killsSkeleton = NULL; -Stat *Stats::killsCreeper = NULL; -Stat *Stats::killsSpider = NULL; -Stat *Stats::killsSpiderJockey = NULL; -Stat *Stats::killsZombiePigman = NULL; -Stat *Stats::killsSlime = NULL; -Stat *Stats::killsGhast = NULL; -Stat *Stats::killsNetherZombiePigman = NULL; +Stat *Stats::walkOneM = nullptr; +Stat *Stats::swimOneM = nullptr; +Stat *Stats::fallOneM = nullptr; +Stat *Stats::climbOneM = nullptr; +Stat *Stats::minecartOneM = nullptr; +Stat *Stats::boatOneM = nullptr; +Stat *Stats::pigOneM = nullptr; +Stat *Stats::portalsCreated = nullptr; +Stat *Stats::cowsMilked = nullptr; +Stat *Stats::netherLavaCollected = nullptr; +Stat *Stats::killsZombie = nullptr; +Stat *Stats::killsSkeleton = nullptr; +Stat *Stats::killsCreeper = nullptr; +Stat *Stats::killsSpider = nullptr; +Stat *Stats::killsSpiderJockey = nullptr; +Stat *Stats::killsZombiePigman = nullptr; +Stat *Stats::killsSlime = nullptr; +Stat *Stats::killsGhast = nullptr; +Stat *Stats::killsNetherZombiePigman = nullptr; // 4J : WESTY : Added for new achievements. -Stat *Stats::befriendsWolf = NULL; -Stat *Stats::totalBlocksMined = NULL; -Stat *Stats::timePlayed = NULL; +Stat *Stats::befriendsWolf = nullptr; +Stat *Stats::totalBlocksMined = nullptr; +Stat *Stats::timePlayed = nullptr; StatArray Stats::blocksMined; StatArray Stats::itemsCollected; @@ -62,18 +62,18 @@ StatArray Stats::rainbowCollection; StatArray Stats::biomesVisisted; #endif -Stat *Stats::killsEnderdragon = NULL; // The number of times this player has dealt the killing blow to the Enderdragon -Stat *Stats::completeTheEnd = NULL; // The number of times this player has been present when the Enderdragon has died +Stat *Stats::killsEnderdragon = nullptr; // The number of times this player has dealt the killing blow to the Enderdragon +Stat *Stats::completeTheEnd = nullptr; // The number of times this player has been present when the Enderdragon has died void Stats::staticCtor() { - Stats::walkOneM = (new GeneralStat(2000, L"stat.walkOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::swimOneM = (new GeneralStat(2001, L"stat.swimOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::fallOneM = (new GeneralStat(2002, L"stat.fallOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::climbOneM = (new GeneralStat(2003, L"stat.climbOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::minecartOneM = (new GeneralStat(2004, L"stat.minecartOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::boatOneM = (new GeneralStat(2005, L"stat.boatOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); - Stats::pigOneM = (new GeneralStat(2006, L"stat.pigOneM", (StatFormatter *) Stat::distanceFormatter))->setAwardLocallyOnly()->postConstruct(); + Stats::walkOneM = (new GeneralStat(2000, L"stat.walkOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::swimOneM = (new GeneralStat(2001, L"stat.swimOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::fallOneM = (new GeneralStat(2002, L"stat.fallOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::climbOneM = (new GeneralStat(2003, L"stat.climbOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::minecartOneM = (new GeneralStat(2004, L"stat.minecartOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::boatOneM = (new GeneralStat(2005, L"stat.boatOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); + Stats::pigOneM = (new GeneralStat(2006, L"stat.pigOneM", static_cast(Stat::distanceFormatter)))->setAwardLocallyOnly()->postConstruct(); Stats::portalsCreated = (new GeneralStat(2007, L"stat.portalsUsed"))->postConstruct(); Stats::cowsMilked = (new GeneralStat(2008, L"stat.cowsMilked"))->postConstruct(); Stats::netherLavaCollected = (new GeneralStat(2009, L"stat.netherLavaCollected"))->postConstruct(); @@ -517,7 +517,7 @@ void Stats::buildAdditionalStats() blocksPlaced[itemStat->getItemId()] = itemStat; itemStat->postConstruct(); - GeneralStat *generalStat = NULL; + GeneralStat *generalStat = nullptr; rainbowCollection = StatArray(16); for (unsigned int i = 0; i < 16; i++) -- cgit v1.2.3