Project modernization (#630)
* 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
This commit is contained in:
@@ -72,10 +72,10 @@ void Explosion::explode()
|
||||
if (t > 0)
|
||||
{
|
||||
Tile *tile = Tile::tiles[t];
|
||||
float resistance = source != NULL ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source);
|
||||
float resistance = source != nullptr ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source);
|
||||
remainingPower -= (resistance + 0.3f) * stepSize;
|
||||
}
|
||||
if (remainingPower > 0&& (source == NULL || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower)))
|
||||
if (remainingPower > 0&& (source == nullptr || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower)))
|
||||
{
|
||||
toBlow.insert(TilePos(xt, yt, zt));
|
||||
}
|
||||
@@ -143,7 +143,7 @@ void Explosion::explode()
|
||||
|
||||
double sp = level->getSeenPercent(center, e->bb);
|
||||
double pow = (1 - dist) * sp;
|
||||
if(canDamage) e->hurt(DamageSource::explosion(this), (int) ((pow * pow + pow) / 2 * 8 * r + 1));
|
||||
if(canDamage) e->hurt(DamageSource::explosion(this), static_cast<int>((pow * pow + pow) / 2 * 8 * r + 1));
|
||||
|
||||
double kbPower = ProtectionEnchantment::getExplosionKnockbackAfterDampener(e, pow);
|
||||
e->xd += xa *kbPower;
|
||||
@@ -163,7 +163,7 @@ void Explosion::explode()
|
||||
}
|
||||
|
||||
|
||||
void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect/*=NULL*/) // 4J - added toBlowDirect parameter
|
||||
void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect/*=nullptr*/) // 4J - added toBlowDirect parameter
|
||||
{
|
||||
level->playSound(x, y, z, eSoundType_RANDOM_EXPLODE, 4, (1 + (level->random->nextFloat() - level->random->nextFloat()) * 0.2f) * 0.7f);
|
||||
if (r < 2 || !destroyBlocks)
|
||||
@@ -185,7 +185,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
|
||||
app.DebugPrintf("Finalizing explosion size %d\n",toBlow.size());
|
||||
static const int MAX_EXPLODE_PARTICLES = 50;
|
||||
// 4J - try and make at most MAX_EXPLODE_PARTICLES pairs of particles
|
||||
int fraction = (int)toBlowArray->size() / MAX_EXPLODE_PARTICLES;
|
||||
int fraction = static_cast<int>(toBlowArray->size()) / MAX_EXPLODE_PARTICLES;
|
||||
if( fraction == 0 ) fraction = 1;
|
||||
size_t j = toBlowArray->size() - 1;
|
||||
//for (size_t j = toBlowArray->size() - 1; j >= 0; j--)
|
||||
@@ -262,7 +262,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
|
||||
}
|
||||
|
||||
PIXEndNamedEvent();
|
||||
if( toBlowDirect == NULL ) delete toBlowArray;
|
||||
if( toBlowDirect == nullptr ) delete toBlowArray;
|
||||
}
|
||||
|
||||
Explosion::playerVec3Map *Explosion::getHitPlayers()
|
||||
@@ -281,7 +281,7 @@ Vec3 *Explosion::getHitPlayerKnockback( shared_ptr<Player> player )
|
||||
|
||||
shared_ptr<LivingEntity> Explosion::getSourceMob()
|
||||
{
|
||||
if (source == NULL) return nullptr;
|
||||
if (source == nullptr) return nullptr;
|
||||
if (source->instanceof(eTYPE_PRIMEDTNT)) return dynamic_pointer_cast<PrimedTnt>(source)->getOwner();
|
||||
if (source->instanceof(eTYPE_LIVINGENTITY)) return dynamic_pointer_cast<LivingEntity>(source);
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user