Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a.
This commit is contained in:
@@ -38,7 +38,7 @@ void Villager::_init(int profession)
|
||||
village = weak_ptr<Village>();
|
||||
|
||||
tradingPlayer = weak_ptr<Player>();
|
||||
offers = nullptr;
|
||||
offers = NULL;
|
||||
updateMerchantTimer = 0;
|
||||
addRecipeOnUpdate = false;
|
||||
riches = 0;
|
||||
@@ -102,11 +102,11 @@ void Villager::serverAiMobStep()
|
||||
|
||||
shared_ptr<Village> _village = level->villages->getClosestVillage(Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist);
|
||||
village = _village;
|
||||
if (_village == nullptr) clearRestriction();
|
||||
if (_village == NULL) clearRestriction();
|
||||
else
|
||||
{
|
||||
Pos *center = _village->getCenter();
|
||||
restrictTo(center->x, center->y, center->z, static_cast<int>((float)_village->getRadius() * 0.6f));
|
||||
restrictTo(center->x, center->y, center->z, (int)((float)_village->getRadius() * 0.6f));
|
||||
if (rewardPlayersOnFirstVillage)
|
||||
{
|
||||
rewardPlayersOnFirstVillage = false;
|
||||
@@ -137,7 +137,7 @@ void Villager::serverAiMobStep()
|
||||
addOffers(1);
|
||||
addRecipeOnUpdate = false;
|
||||
|
||||
if (village.lock() != nullptr && !lastPlayerTradeName.empty())
|
||||
if (village.lock() != NULL && !lastPlayerTradeName.empty())
|
||||
{
|
||||
level->broadcastEntityEvent(shared_from_this(), EntityEvent::VILLAGER_HAPPY);
|
||||
village.lock()->modifyStanding(lastPlayerTradeName, 1);
|
||||
@@ -154,7 +154,7 @@ bool Villager::mobInteract(shared_ptr<Player> player)
|
||||
{
|
||||
// [EB]: Truly dislike this code but I don't see another easy way
|
||||
shared_ptr<ItemInstance> item = player->inventory->getSelected();
|
||||
bool holdingSpawnEgg = item != nullptr && item->id == Item::spawnEgg_Id;
|
||||
bool holdingSpawnEgg = item != NULL && item->id == Item::spawnEgg_Id;
|
||||
|
||||
if (!holdingSpawnEgg && isAlive() && !isTrading() && !isBaby())
|
||||
{
|
||||
@@ -182,7 +182,7 @@ void Villager::addAdditonalSaveData(CompoundTag *tag)
|
||||
AgableMob::addAdditonalSaveData(tag);
|
||||
tag->putInt(L"Profession", getProfession());
|
||||
tag->putInt(L"Riches", riches);
|
||||
if (offers != nullptr)
|
||||
if (offers != NULL)
|
||||
{
|
||||
tag->putCompound(L"Offers", offers->createTag());
|
||||
}
|
||||
@@ -259,7 +259,7 @@ void Villager::setLastHurtByMob(shared_ptr<LivingEntity> mob)
|
||||
{
|
||||
AgableMob::setLastHurtByMob(mob);
|
||||
shared_ptr<Village> _village = village.lock();
|
||||
if (_village != nullptr && mob != nullptr)
|
||||
if (_village != NULL && mob != NULL)
|
||||
{
|
||||
_village->addAggressor(mob);
|
||||
|
||||
@@ -282,10 +282,10 @@ void Villager::setLastHurtByMob(shared_ptr<LivingEntity> mob)
|
||||
void Villager::die(DamageSource *source)
|
||||
{
|
||||
shared_ptr<Village> _village = village.lock();
|
||||
if (_village != nullptr)
|
||||
if (_village != NULL)
|
||||
{
|
||||
shared_ptr<Entity> sourceEntity = source->getEntity();
|
||||
if (sourceEntity != nullptr)
|
||||
if (sourceEntity != NULL)
|
||||
{
|
||||
if ( sourceEntity->instanceof(eTYPE_PLAYER) )
|
||||
{
|
||||
@@ -296,12 +296,12 @@ void Villager::die(DamageSource *source)
|
||||
_village->resetNoBreedTimer();
|
||||
}
|
||||
}
|
||||
else if (sourceEntity == nullptr)
|
||||
else if (sourceEntity == NULL)
|
||||
{
|
||||
// if the villager was killed by the world (such as lava or falling), blame
|
||||
// the nearest player by not reproducing for a while
|
||||
shared_ptr<Player> nearestPlayer = level->getNearestPlayer(shared_from_this(), 16.0f);
|
||||
if (nearestPlayer != nullptr)
|
||||
if (nearestPlayer != NULL)
|
||||
{
|
||||
_village->resetNoBreedTimer();
|
||||
}
|
||||
@@ -335,7 +335,7 @@ shared_ptr<Player> Villager::getTradingPlayer()
|
||||
|
||||
bool Villager::isTrading()
|
||||
{
|
||||
return tradingPlayer.lock() != nullptr;
|
||||
return tradingPlayer.lock() != NULL;
|
||||
}
|
||||
|
||||
void Villager::notifyTrade(MerchantRecipe *activeRecipe)
|
||||
@@ -349,7 +349,7 @@ void Villager::notifyTrade(MerchantRecipe *activeRecipe)
|
||||
{
|
||||
updateMerchantTimer = SharedConstants::TICKS_PER_SECOND * 2;
|
||||
addRecipeOnUpdate = true;
|
||||
if (tradingPlayer.lock() != nullptr)
|
||||
if (tradingPlayer.lock() != NULL)
|
||||
{
|
||||
lastPlayerTradeName = tradingPlayer.lock()->getName();
|
||||
}
|
||||
@@ -370,7 +370,7 @@ void Villager::notifyTradeUpdated(shared_ptr<ItemInstance> item)
|
||||
if (!level->isClientSide && (ambientSoundTime > (-getAmbientSoundInterval() + SharedConstants::TICKS_PER_SECOND)))
|
||||
{
|
||||
ambientSoundTime = -getAmbientSoundInterval();
|
||||
if (item != nullptr)
|
||||
if (item != NULL)
|
||||
{
|
||||
playSound(eSoundType_MOB_VILLAGER_YES, getSoundVolume(), getVoicePitch());
|
||||
}
|
||||
@@ -383,7 +383,7 @@ void Villager::notifyTradeUpdated(shared_ptr<ItemInstance> item)
|
||||
|
||||
MerchantRecipeList *Villager::getOffers(shared_ptr<Player> forPlayer)
|
||||
{
|
||||
if (offers == nullptr)
|
||||
if (offers == NULL)
|
||||
{
|
||||
addOffers(1);
|
||||
}
|
||||
@@ -420,7 +420,7 @@ void Villager::addOffers(int addCount)
|
||||
addItemForPurchase(newOffers, Item::arrow_Id, random, getRecipeChance(.5f));
|
||||
if (random->nextFloat() < getRecipeChance(.5f))
|
||||
{
|
||||
newOffers->push_back(new MerchantRecipe(std::make_shared<ItemInstance>(Tile::gravel, 10), std::make_shared<ItemInstance>(Item::emerald), std::make_shared<ItemInstance>(Item::flint_Id, 4 + random->nextInt(2), 0)));
|
||||
newOffers->push_back(new MerchantRecipe(shared_ptr<ItemInstance>( new ItemInstance(Tile::gravel, 10) ), shared_ptr<ItemInstance>( new ItemInstance(Item::emerald) ), shared_ptr<ItemInstance>( new ItemInstance(Item::flint_Id, 4 + random->nextInt(2), 0))));
|
||||
}
|
||||
break;
|
||||
case PROFESSION_BUTCHER:
|
||||
@@ -480,7 +480,7 @@ void Villager::addOffers(int addCount)
|
||||
shared_ptr<ItemInstance> book = Item::enchantedBook->createForEnchantment(new EnchantmentInstance(enchantment, level));
|
||||
int cost = 2 + random->nextInt(5 + (level * 10)) + 3 * level;
|
||||
|
||||
newOffers->push_back(new MerchantRecipe(std::make_shared<ItemInstance>(Item::book), std::make_shared<ItemInstance>(Item::emerald, cost), book));
|
||||
newOffers->push_back(new MerchantRecipe(shared_ptr<ItemInstance>(new ItemInstance(Item::book)), shared_ptr<ItemInstance>(new ItemInstance(Item::emerald, cost)), book));
|
||||
}
|
||||
break;
|
||||
case PROFESSION_PRIEST:
|
||||
@@ -498,9 +498,9 @@ void Villager::addOffers(int addCount)
|
||||
int id = enchantItems[i];
|
||||
if (random->nextFloat() < getRecipeChance(.05f))
|
||||
{
|
||||
newOffers->push_back(new MerchantRecipe(std::make_shared<ItemInstance>(id, 1, 0),
|
||||
std::make_shared<ItemInstance>(Item::emerald, 2 + random->nextInt(3), 0),
|
||||
EnchantmentHelper::enchantItem(random, std::make_shared<ItemInstance>(id, 1, 0), 5 + random->nextInt(15))));
|
||||
newOffers->push_back(new MerchantRecipe(shared_ptr<ItemInstance>(new ItemInstance(id, 1, 0)),
|
||||
shared_ptr<ItemInstance>(new ItemInstance(Item::emerald, 2 + random->nextInt(3), 0)),
|
||||
EnchantmentHelper::enchantItem(random, shared_ptr<ItemInstance>(new ItemInstance(id, 1, 0)), 5 + random->nextInt(15))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -515,7 +515,7 @@ void Villager::addOffers(int addCount)
|
||||
// shuffle the list to make it more interesting
|
||||
std::shuffle(newOffers->begin(), newOffers->end(), std::mt19937{std::random_device{}()});
|
||||
|
||||
if (offers == nullptr)
|
||||
if (offers == NULL)
|
||||
{
|
||||
offers = new MerchantRecipeList();
|
||||
}
|
||||
@@ -622,7 +622,7 @@ void Villager::addItemForTradeIn(MerchantRecipeList *list, int itemId, Random *r
|
||||
|
||||
shared_ptr<ItemInstance> Villager::getItemTradeInValue(int itemId, Random *random)
|
||||
{
|
||||
return std::make_shared<ItemInstance>(itemId, getTradeInValue(itemId, random), 0);
|
||||
return shared_ptr<ItemInstance>(new ItemInstance(itemId, getTradeInValue(itemId, random), 0));
|
||||
}
|
||||
|
||||
int Villager::getTradeInValue(int itemId, Random *random)
|
||||
@@ -658,13 +658,13 @@ void Villager::addItemForPurchase(MerchantRecipeList *list, int itemId, Random *
|
||||
shared_ptr<ItemInstance> resultItem;
|
||||
if (purchaseCost < 0)
|
||||
{
|
||||
rubyItem = std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0);
|
||||
resultItem = std::make_shared<ItemInstance>(itemId, -purchaseCost, 0);
|
||||
rubyItem = shared_ptr<ItemInstance>( new ItemInstance(Item::emerald_Id, 1, 0) );
|
||||
resultItem = shared_ptr<ItemInstance>( new ItemInstance(itemId, -purchaseCost, 0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
rubyItem = std::make_shared<ItemInstance>(Item::emerald_Id, purchaseCost, 0);
|
||||
resultItem = std::make_shared<ItemInstance>(itemId, 1, 0);
|
||||
rubyItem = shared_ptr<ItemInstance>( new ItemInstance(Item::emerald_Id, purchaseCost, 0) );
|
||||
resultItem = shared_ptr<ItemInstance>( new ItemInstance(itemId, 1, 0) );
|
||||
}
|
||||
list->push_back(new MerchantRecipe(rubyItem, resultItem));
|
||||
}
|
||||
@@ -735,8 +735,8 @@ shared_ptr<AgableMob> Villager::getBreedOffspring(shared_ptr<AgableMob> target)
|
||||
// 4J - added limit to villagers that can be bred
|
||||
if(level->canCreateMore(GetType(), Level::eSpawnType_Breed) )
|
||||
{
|
||||
shared_ptr<Villager> villager = std::make_shared<Villager>(level);
|
||||
villager->finalizeMobSpawn(nullptr);
|
||||
shared_ptr<Villager> villager = shared_ptr<Villager>(new Villager(level));
|
||||
villager->finalizeMobSpawn(NULL);
|
||||
return villager;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user