fix: achievements crashes

This commit is contained in:
Byte
2026-06-24 22:27:22 +02:00
parent 028dcdce41
commit e7a44db374
8 changed files with 16 additions and 11 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ public:
*/
static const int GAME_DEFINED_PROFILE_DATA_BYTES = 2*972; // per user
#else
static const int GAME_DEFINED_PROFILE_DATA_BYTES = 2*972; // per user
static const int GAME_DEFINED_PROFILE_DATA_BYTES = 3*972; // per user
#endif
unsigned int uiGameDefinedDataChangedBitmask;
+1 -1
View File
@@ -978,7 +978,7 @@ void LocalPlayer::awardStat(Stat *stat, byteArray param)
// AWARD : Porkchop, cook and eat a porkchop.
{
Stat *cookPorkchop, *eatPorkchop;
cookPorkchop = GenericStats::itemsCrafted(Item::porkChop_cooked_Id);
cookPorkchop = GenericStats::itemsSmelted(Item::porkChop_cooked_Id);
eatPorkchop = GenericStats::itemsUsed(Item::porkChop_cooked_Id);
if ( stat == cookPorkchop || stat == eatPorkchop )
+1 -1
View File
@@ -120,7 +120,7 @@ void Achievements::staticCtor()
#ifdef _EXTENDED_ACHIEVEMENTS
Achievements::eatPorkChop = (new Achievement(eAward_eatPorkChop, L"eatPorkChop", 0, 0, Tile::treeTrunk, (Achievement *) buildSword))->setAwardLocallyOnly()->postConstruct();
#else
Achievements::eatPorkChop = (new Achievement(eAward_eatPorkChop, L"eatPorkChop", 0, 0, Tile::treeTrunk, (Achievement *) buildSword, "034", IDS_ACHIEVE_NAME_EAT_PORKCHOP, IDS_ACHIEVE_DESC_EAT_PORKCHOP))->postConstruct();
Achievements::eatPorkChop = (new Achievement(eAward_eatPorkChop, L"eatPorkChop", 0, 0, Tile::treeTrunk, (Achievement *) buildSword, "034", IDS_ACHIEVE_NAME_EAT_PORKCHOP, IDS_ACHIEVE_DESC_EAT_PORKCHOP))->setAwardLocallyOnly()->postConstruct();
#endif
Achievements::play100Days = (new Achievement(eAward_play100Days, L"play100Days", 0, 0, Tile::treeTrunk, (Achievement *) buildSword, "035", IDS_ACHIEVE_NAME_PLAY_100_DAYS, IDS_ACHIEVE_DESC_PLAY_100_DAYS))->setAwardLocallyOnly()->postConstruct();
Achievements::arrowKillCreeper = (new Achievement(eAward_arrowKillCreeper, L"arrowKillCreeper", 0, 0, Tile::treeTrunk, (Achievement *) buildSword, "036", IDS_ACHIEVE_NAME_ARROW_KILL_CREEPER, IDS_ACHIEVE_DESC_ARROW_KILL_CREEPER))->postConstruct();
+1
View File
@@ -113,6 +113,7 @@ Stat *CommonStats::get_itemsUsed(int itemId)
#endif
if (itemId == Item::porkChop_cooked_Id) return Stats::blocksPlaced[itemId];
else return nullptr;
//return nullptr;
}
+3 -3
View File
@@ -77,7 +77,7 @@ void FurnaceResultSlot::checkTakeAchievements(shared_ptr<ItemInstance> carried)
}
}
#ifdef _DURANGO
if (!player->level->isClientSide && removeCount > 0)
{
player->awardStat(
@@ -85,11 +85,11 @@ void FurnaceResultSlot::checkTakeAchievements(shared_ptr<ItemInstance> carried)
GenericStats::param_itemsSmelted(carried->id, carried->getAuxValue(), removeCount)
);
}
#else
if (carried->id == Item::ironIngot_Id) player->awardStat(GenericStats::acquireIron(), GenericStats::param_acquireIron());
if (carried->id == Item::fish_cooked_Id) player->awardStat(GenericStats::cookFish(), GenericStats::param_cookFish());
//if (carried->id == Item::porkChop_cooked_Id) GenericStats::itemsCrafted(Item::porkChop_cooked_Id);
#endif
removeCount = 0;
}
+5 -1
View File
@@ -2,6 +2,7 @@
#include "Monster.h"
#include "Item.h"
#include "GenericStats.h"
GenericStats *GenericStats::instance = nullptr;
@@ -835,7 +836,10 @@ byteArray GenericStats::param_itemsSmelted(int id, int aux, int count)
byteArray GenericStats::param_itemsUsed(shared_ptr<Player> plr, shared_ptr<ItemInstance> itm)
{
if ( (plr != nullptr) && (itm != nullptr) ) return instance->getParam_itemsUsed(plr, itm);
if ((plr != nullptr) && (itm != nullptr)) {
if (itm->id == Item::porkChop_cooked_Id) return instance->param_eatPorkChop();
return instance->getParam_itemsUsed(plr, itm);
}
else return instance->getParam_noArgs();
}
+2 -2
View File
@@ -16,12 +16,12 @@ void Stat::_init()
awardLocallyOnly = false;
}
Stat::Stat(int id, const wstring& name, StatFormatter *formatter) : id(id), name(name), formatter(formatter)
Stat::Stat(int id, const wstring& name1, StatFormatter *formatter) : id(id), name(name1), formatter(formatter)
{
_init();
}
Stat::Stat(int id, const wstring& name) : id(id), name(name), formatter(defaultFormatter)
Stat::Stat(int id, const wstring& name1) : id(id), name(name1), formatter(defaultFormatter)
{
_init();
}
+2 -2
View File
@@ -527,8 +527,8 @@ void Stats::buildAdditionalStats()
generalStat->postConstruct();
}
biomesVisisted = StatArray(23);
for (unsigned int i = 0; i < 23; i++)
biomesVisisted = StatArray(170);
for (unsigned int i = 0; i < 170; i++)
{
generalStat = new GeneralStat(offset++, L"biomesVisited." + std::to_wstring(i));
generalStats->push_back(generalStat);