Remove AUTO_VAR macro and _toString function (#592)
This commit is contained in:
@@ -47,20 +47,20 @@ void AABB::ReleaseThreadStorage()
|
||||
delete tls;
|
||||
}
|
||||
|
||||
AABB *AABB::newPermanent(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
AABB *AABB::newPermanent(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
{
|
||||
return new AABB(x0, y0, z0, x1, y1, z1);
|
||||
}
|
||||
|
||||
void AABB::clearPool()
|
||||
void AABB::clearPool()
|
||||
{
|
||||
}
|
||||
|
||||
void AABB::resetPool()
|
||||
void AABB::resetPool()
|
||||
{
|
||||
}
|
||||
|
||||
AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
{
|
||||
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx);
|
||||
AABB *thisAABB = &tls->pool[tls->poolPointer];
|
||||
@@ -69,7 +69,7 @@ AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, doubl
|
||||
return thisAABB;
|
||||
}
|
||||
|
||||
AABB::AABB(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
AABB::AABB(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
{
|
||||
this->x0 = x0;
|
||||
this->y0 = y0;
|
||||
@@ -80,7 +80,7 @@ AABB::AABB(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
}
|
||||
|
||||
|
||||
AABB *AABB::set(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
AABB *AABB::set(double x0, double y0, double z0, double x1, double y1, double z1)
|
||||
{
|
||||
this->x0 = x0;
|
||||
this->y0 = y0;
|
||||
@@ -91,7 +91,7 @@ AABB *AABB::set(double x0, double y0, double z0, double x1, double y1, double z1
|
||||
return this;
|
||||
}
|
||||
|
||||
AABB *AABB::expand(double xa, double ya, double za)
|
||||
AABB *AABB::expand(double xa, double ya, double za)
|
||||
{
|
||||
double _x0 = x0;
|
||||
double _y0 = y0;
|
||||
@@ -112,7 +112,7 @@ AABB *AABB::expand(double xa, double ya, double za)
|
||||
return AABB::newTemp(_x0, _y0, _z0, _x1, _y1, _z1);
|
||||
}
|
||||
|
||||
AABB *AABB::grow(double xa, double ya, double za)
|
||||
AABB *AABB::grow(double xa, double ya, double za)
|
||||
{
|
||||
double _x0 = x0 - xa;
|
||||
double _y0 = y0 - ya;
|
||||
@@ -136,22 +136,22 @@ AABB *AABB::minmax(AABB *other)
|
||||
return newTemp(_x0, _y0, _z0, _x1, _y1, _z1);
|
||||
}
|
||||
|
||||
AABB *AABB::cloneMove(double xa, double ya, double za)
|
||||
AABB *AABB::cloneMove(double xa, double ya, double za)
|
||||
{
|
||||
return AABB::newTemp(x0 + xa, y0 + ya, z0 + za, x1 + xa, y1 + ya, z1 + za);
|
||||
}
|
||||
|
||||
double AABB::clipXCollide(AABB *c, double xa)
|
||||
double AABB::clipXCollide(AABB *c, double xa)
|
||||
{
|
||||
if (c->y1 <= y0 || c->y0 >= y1) return xa;
|
||||
if (c->z1 <= z0 || c->z0 >= z1) return xa;
|
||||
|
||||
if (xa > 0 && c->x1 <= x0)
|
||||
if (xa > 0 && c->x1 <= x0)
|
||||
{
|
||||
double max = x0 - c->x1;
|
||||
if (max < xa) xa = max;
|
||||
}
|
||||
if (xa < 0 && c->x0 >= x1)
|
||||
if (xa < 0 && c->x0 >= x1)
|
||||
{
|
||||
double max = x1 - c->x0;
|
||||
if (max > xa) xa = max;
|
||||
@@ -165,12 +165,12 @@ double AABB::clipYCollide(AABB *c, double ya)
|
||||
if (c->x1 <= x0 || c->x0 >= x1) return ya;
|
||||
if (c->z1 <= z0 || c->z0 >= z1) return ya;
|
||||
|
||||
if (ya > 0 && c->y1 <= y0)
|
||||
if (ya > 0 && c->y1 <= y0)
|
||||
{
|
||||
double max = y0 - c->y1;
|
||||
if (max < ya) ya = max;
|
||||
}
|
||||
if (ya < 0 && c->y0 >= y1)
|
||||
if (ya < 0 && c->y0 >= y1)
|
||||
{
|
||||
double max = y1 - c->y0;
|
||||
if (max > ya) ya = max;
|
||||
@@ -179,17 +179,17 @@ double AABB::clipYCollide(AABB *c, double ya)
|
||||
return ya;
|
||||
}
|
||||
|
||||
double AABB::clipZCollide(AABB *c, double za)
|
||||
double AABB::clipZCollide(AABB *c, double za)
|
||||
{
|
||||
if (c->x1 <= x0 || c->x0 >= x1) return za;
|
||||
if (c->y1 <= y0 || c->y0 >= y1) return za;
|
||||
|
||||
if (za > 0 && c->z1 <= z0)
|
||||
if (za > 0 && c->z1 <= z0)
|
||||
{
|
||||
double max = z0 - c->z1;
|
||||
if (max < za) za = max;
|
||||
}
|
||||
if (za < 0 && c->z0 >= z1)
|
||||
if (za < 0 && c->z0 >= z1)
|
||||
{
|
||||
double max = z1 - c->z0;
|
||||
if (max > za) za = max;
|
||||
@@ -198,7 +198,7 @@ double AABB::clipZCollide(AABB *c, double za)
|
||||
return za;
|
||||
}
|
||||
|
||||
bool AABB::intersects(AABB *c)
|
||||
bool AABB::intersects(AABB *c)
|
||||
{
|
||||
if (c->x1 <= x0 || c->x0 >= x1) return false;
|
||||
if (c->y1 <= y0 || c->y0 >= y1) return false;
|
||||
@@ -206,7 +206,7 @@ bool AABB::intersects(AABB *c)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AABB::intersectsInner(AABB *c)
|
||||
bool AABB::intersectsInner(AABB *c)
|
||||
{
|
||||
if (c->x1 < x0 || c->x0 > x1) return false;
|
||||
if (c->y1 < y0 || c->y0 > y1) return false;
|
||||
@@ -214,7 +214,7 @@ bool AABB::intersectsInner(AABB *c)
|
||||
return true;
|
||||
}
|
||||
|
||||
AABB *AABB::move(double xa, double ya, double za)
|
||||
AABB *AABB::move(double xa, double ya, double za)
|
||||
{
|
||||
x0 += xa;
|
||||
y0 += ya;
|
||||
@@ -225,7 +225,7 @@ AABB *AABB::move(double xa, double ya, double za)
|
||||
return this;
|
||||
}
|
||||
|
||||
bool AABB::intersects(double x02, double y02, double z02, double x12, double y12, double z12)
|
||||
bool AABB::intersects(double x02, double y02, double z02, double x12, double y12, double z12)
|
||||
{
|
||||
if (x12 <= x0 || x02 >= x1) return false;
|
||||
if (y12 <= y0 || y02 >= y1) return false;
|
||||
@@ -233,7 +233,7 @@ bool AABB::intersects(double x02, double y02, double z02, double x12, double y12
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AABB::contains(Vec3 *p)
|
||||
bool AABB::contains(Vec3 *p)
|
||||
{
|
||||
if (p->x <= x0 || p->x >= x1) return false;
|
||||
if (p->y <= y0 || p->y >= y1) return false;
|
||||
@@ -242,7 +242,7 @@ bool AABB::contains(Vec3 *p)
|
||||
}
|
||||
|
||||
// 4J Added
|
||||
bool AABB::containsIncludingLowerBound(Vec3 *p)
|
||||
bool AABB::containsIncludingLowerBound(Vec3 *p)
|
||||
{
|
||||
if (p->x < x0 || p->x >= x1) return false;
|
||||
if (p->y < y0 || p->y >= y1) return false;
|
||||
@@ -250,7 +250,7 @@ bool AABB::containsIncludingLowerBound(Vec3 *p)
|
||||
return true;
|
||||
}
|
||||
|
||||
double AABB::getSize()
|
||||
double AABB::getSize()
|
||||
{
|
||||
double xs = x1 - x0;
|
||||
double ys = y1 - y0;
|
||||
@@ -258,7 +258,7 @@ double AABB::getSize()
|
||||
return (xs + ys + zs) / 3.0f;
|
||||
}
|
||||
|
||||
AABB *AABB::shrink(double xa, double ya, double za)
|
||||
AABB *AABB::shrink(double xa, double ya, double za)
|
||||
{
|
||||
double _x0 = x0 + xa;
|
||||
double _y0 = y0 + ya;
|
||||
@@ -270,12 +270,12 @@ AABB *AABB::shrink(double xa, double ya, double za)
|
||||
return AABB::newTemp(_x0, _y0, _z0, _x1, _y1, _z1);
|
||||
}
|
||||
|
||||
AABB *AABB::copy()
|
||||
AABB *AABB::copy()
|
||||
{
|
||||
return AABB::newTemp(x0, y0, z0, x1, y1, z1);
|
||||
}
|
||||
|
||||
HitResult *AABB::clip(Vec3 *a, Vec3 *b)
|
||||
HitResult *AABB::clip(Vec3 *a, Vec3 *b)
|
||||
{
|
||||
Vec3 *xh0 = a->clipX(b, x0);
|
||||
Vec3 *xh1 = a->clipX(b, x1);
|
||||
@@ -317,26 +317,26 @@ HitResult *AABB::clip(Vec3 *a, Vec3 *b)
|
||||
}
|
||||
|
||||
|
||||
bool AABB::containsX(Vec3 *v)
|
||||
bool AABB::containsX(Vec3 *v)
|
||||
{
|
||||
if (v == NULL) return false;
|
||||
return v->y >= y0 && v->y <= y1 && v->z >= z0 && v->z <= z1;
|
||||
}
|
||||
|
||||
bool AABB::containsY(Vec3 *v)
|
||||
bool AABB::containsY(Vec3 *v)
|
||||
{
|
||||
if (v == NULL) return false;
|
||||
return v->x >= x0 && v->x <= x1 && v->z >= z0 && v->z <= z1;
|
||||
}
|
||||
|
||||
bool AABB::containsZ(Vec3 *v)
|
||||
bool AABB::containsZ(Vec3 *v)
|
||||
{
|
||||
if (v == NULL) return false;
|
||||
return v->x >= x0 && v->x <= x1 && v->y >= y0 && v->y <= y1;
|
||||
}
|
||||
|
||||
|
||||
void AABB::set(AABB *b)
|
||||
void AABB::set(AABB *b)
|
||||
{
|
||||
x0 = b->x0;
|
||||
y0 = b->y0;
|
||||
@@ -346,9 +346,9 @@ void AABB::set(AABB *b)
|
||||
z1 = b->z1;
|
||||
}
|
||||
|
||||
wstring AABB::toString()
|
||||
wstring AABB::toString()
|
||||
{
|
||||
return L"box[" + _toString<double>(x0) + L", " + _toString<double>(y0) + L", " + _toString<double>(z0) + L" -> " +
|
||||
_toString<double>(x1) + L", " + _toString<double>(y1) + L", " + _toString<double>(z1) + L"]";
|
||||
return L"box[" + std::to_wstring(x0) + L", " + std::to_wstring(y0) + L", " + std::to_wstring(z0) + L" -> " +
|
||||
std::to_wstring(x1) + L", " + std::to_wstring(y1) + L", " + std::to_wstring(z1) + L"]";
|
||||
}
|
||||
|
||||
|
||||
@@ -48,27 +48,25 @@ void AbstractContainerMenu::addSlotListener(ContainerListener *listener)
|
||||
|
||||
void AbstractContainerMenu::removeSlotListener(ContainerListener *listener)
|
||||
{
|
||||
AUTO_VAR(it, std::find(containerListeners.begin(), containerListeners.end(), listener) );
|
||||
auto it = std::find(containerListeners.begin(), containerListeners.end(), listener);
|
||||
if(it != containerListeners.end()) containerListeners.erase(it);
|
||||
}
|
||||
|
||||
vector<shared_ptr<ItemInstance> > *AbstractContainerMenu::getItems()
|
||||
{
|
||||
vector<shared_ptr<ItemInstance> > *items = new vector<shared_ptr<ItemInstance> >();
|
||||
AUTO_VAR(itEnd, slots.end());
|
||||
for (AUTO_VAR(it, slots.begin()); it != itEnd; it++)
|
||||
for ( Slot* it : slots )
|
||||
{
|
||||
items->push_back((*it)->getItem());
|
||||
items->push_back(it->getItem());
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
void AbstractContainerMenu::sendData(int id, int value)
|
||||
{
|
||||
AUTO_VAR(itEnd, containerListeners.end());
|
||||
for (AUTO_VAR(it, containerListeners.begin()); it != itEnd; it++)
|
||||
for ( auto& it : containerListeners )
|
||||
{
|
||||
(*it)->setContainerData(this, id, value);
|
||||
it->setContainerData(this, id, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +84,9 @@ void AbstractContainerMenu::broadcastChanges()
|
||||
lastSlots[i] = expected;
|
||||
m_bNeedsRendered = true;
|
||||
|
||||
AUTO_VAR(itEnd, containerListeners.end());
|
||||
for (AUTO_VAR(it, containerListeners.begin()); it != itEnd; it++)
|
||||
for ( auto& it : containerListeners )
|
||||
{
|
||||
(*it)->slotChanged(this, i, expected);
|
||||
it->slotChanged(this, i, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,10 +119,8 @@ bool AbstractContainerMenu::clickMenuButton(shared_ptr<Player> player, int butto
|
||||
|
||||
Slot *AbstractContainerMenu::getSlotFor(shared_ptr<Container> c, int index)
|
||||
{
|
||||
AUTO_VAR(itEnd, slots.end());
|
||||
for (AUTO_VAR(it, slots.begin()); it != itEnd; it++)
|
||||
for ( Slot *slot : slots )
|
||||
{
|
||||
Slot *slot = *it; //slots->at(i);
|
||||
if (slot->isAt(c, index))
|
||||
{
|
||||
return slot;
|
||||
@@ -197,10 +192,9 @@ shared_ptr<ItemInstance> AbstractContainerMenu::clicked(int slotIndex, int butto
|
||||
shared_ptr<ItemInstance> source = inventory->getCarried()->copy();
|
||||
int remaining = inventory->getCarried()->count;
|
||||
|
||||
for(AUTO_VAR(it, quickcraftSlots.begin()); it != quickcraftSlots.end(); ++it)
|
||||
for ( Slot *slot : quickcraftSlots )
|
||||
{
|
||||
Slot *slot = *it;
|
||||
if (slot != NULL && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && inventory->getCarried()->count >= quickcraftSlots.size() && canDragTo(slot))
|
||||
if (slot != nullptr && canItemQuickReplace(slot, inventory->getCarried(), true) && slot->mayPlace(inventory->getCarried()) && inventory->getCarried()->count >= quickcraftSlots.size() && canDragTo(slot))
|
||||
{
|
||||
shared_ptr<ItemInstance> copy = source->copy();
|
||||
int carry = slot->hasItem() ? slot->getItem()->count : 0;
|
||||
@@ -582,7 +576,7 @@ void AbstractContainerMenu::setSynched(shared_ptr<Player> player, bool synched)
|
||||
{
|
||||
if (synched)
|
||||
{
|
||||
AUTO_VAR(it, unSynchedPlayers.find(player));
|
||||
auto it = unSynchedPlayers.find(player);
|
||||
|
||||
if(it != unSynchedPlayers.end()) unSynchedPlayers.erase( it );
|
||||
}
|
||||
|
||||
@@ -229,45 +229,12 @@ shared_ptr<Entity> Animal::findAttackTarget()
|
||||
if (getInLoveValue() > 0)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *others = level->getEntitiesOfClass(typeid(*this), bb->grow(r, r, r));
|
||||
//for (int i = 0; i < others->size(); i++)
|
||||
for(AUTO_VAR(it, others->begin()); it != others->end(); ++it)
|
||||
if ( others )
|
||||
{
|
||||
shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(*it);
|
||||
if (p != shared_from_this() && p->getInLoveValue() > 0)
|
||||
for (auto& it : *others)
|
||||
{
|
||||
delete others;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
delete others;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getAge() == 0)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *players = level->getEntitiesOfClass(typeid(Player), bb->grow(r, r, r));
|
||||
//for (int i = 0; i < players.size(); i++)
|
||||
for(AUTO_VAR(it, players->begin()); it != players->end(); ++it)
|
||||
{
|
||||
setDespawnProtected();
|
||||
|
||||
shared_ptr<Player> p = dynamic_pointer_cast<Player>(*it);
|
||||
if (p->getSelectedItem() != NULL && this->isFood(p->getSelectedItem()))
|
||||
{
|
||||
delete players;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
delete players;
|
||||
}
|
||||
else if (getAge() > 0)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *others = level->getEntitiesOfClass(typeid(*this), bb->grow(r, r, r));
|
||||
//for (int i = 0; i < others.size(); i++)
|
||||
for(AUTO_VAR(it, others->begin()); it != others->end(); ++it)
|
||||
{
|
||||
shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(*it);
|
||||
if (p != shared_from_this() && p->getAge() < 0)
|
||||
shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(it);
|
||||
if (p != shared_from_this() && p->getInLoveValue() > 0)
|
||||
{
|
||||
delete others;
|
||||
return p;
|
||||
@@ -276,6 +243,46 @@ shared_ptr<Entity> Animal::findAttackTarget()
|
||||
delete others;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getAge() == 0)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *players = level->getEntitiesOfClass(typeid(Player), bb->grow(r, r, r));
|
||||
if ( players )
|
||||
{
|
||||
for (auto& it : *players)
|
||||
{
|
||||
setDespawnProtected();
|
||||
|
||||
shared_ptr<Player> p = dynamic_pointer_cast<Player>(it);
|
||||
if (p->getSelectedItem() != NULL && this->isFood(p->getSelectedItem()))
|
||||
{
|
||||
delete players;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
delete players;
|
||||
}
|
||||
}
|
||||
else if (getAge() > 0)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *others = level->getEntitiesOfClass(typeid(*this), bb->grow(r, r, r));
|
||||
|
||||
if ( others )
|
||||
{
|
||||
for (auto& it : *others)
|
||||
{
|
||||
shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(it);
|
||||
if (p != shared_from_this() && p->getAge() < 0)
|
||||
{
|
||||
delete others;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
delete others;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,64 +134,67 @@ void AnvilMenu::createResult()
|
||||
|
||||
unordered_map<int, int> *additionalEnchantments = EnchantmentHelper::getEnchantments(addition);
|
||||
|
||||
for(AUTO_VAR(it, additionalEnchantments->begin()); it != additionalEnchantments->end(); ++it)
|
||||
if ( additionalEnchantments )
|
||||
{
|
||||
int id = it->first;
|
||||
Enchantment *enchantment = Enchantment::enchantments[id];
|
||||
AUTO_VAR(localIt, enchantments->find(id));
|
||||
int current = localIt != enchantments->end() ? localIt->second : 0;
|
||||
int level = it->second;
|
||||
level = (current == level) ? level += 1 : max(level, current);
|
||||
int extra = level - current;
|
||||
bool compatible = enchantment->canEnchant(input);
|
||||
|
||||
if (player->abilities.instabuild || input->id == EnchantedBookItem::enchantedBook_Id) compatible = true;
|
||||
|
||||
for(AUTO_VAR(it2, enchantments->begin()); it2 != enchantments->end(); ++it2)
|
||||
for (const auto& it : *additionalEnchantments)
|
||||
{
|
||||
int other = it2->first;
|
||||
if (other != id && !enchantment->isCompatibleWith(Enchantment::enchantments[other]))
|
||||
{
|
||||
compatible = false;
|
||||
int id = it.first;
|
||||
Enchantment* enchantment = Enchantment::enchantments[id];
|
||||
auto localIt = enchantments->find(id);
|
||||
int current = localIt != enchantments->end() ? localIt->second : 0;
|
||||
int level = it.second;
|
||||
level = (current == level) ? level += 1 : std::max<int>(level, current);
|
||||
int extra = level - current;
|
||||
bool compatible = enchantment->canEnchant(input);
|
||||
|
||||
price += extra;
|
||||
if (DEBUG_COST)
|
||||
if (player->abilities.instabuild || input->id == EnchantedBookItem::enchantedBook_Id) compatible = true;
|
||||
|
||||
for (auto& it2 : *enchantments)
|
||||
{
|
||||
int other = it2.first;
|
||||
if (other != id && !enchantment->isCompatibleWith(Enchantment::enchantments[other]))
|
||||
{
|
||||
app.DebugPrintf("Enchantment incompatibility fee; price is now %d (went up by %d)\n", price, extra);
|
||||
compatible = false;
|
||||
|
||||
price += extra;
|
||||
if (DEBUG_COST)
|
||||
{
|
||||
app.DebugPrintf("Enchantment incompatibility fee; price is now %d (went up by %d)\n", price, extra);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!compatible) continue;
|
||||
if (level > enchantment->getMaxLevel()) level = enchantment->getMaxLevel();
|
||||
(*enchantments)[id] = level;
|
||||
int fee = 0;
|
||||
|
||||
switch (enchantment->getFrequency())
|
||||
{
|
||||
case Enchantment::FREQ_COMMON:
|
||||
fee = 1;
|
||||
break;
|
||||
case Enchantment::FREQ_UNCOMMON:
|
||||
fee = 2;
|
||||
break;
|
||||
case Enchantment::FREQ_RARE:
|
||||
fee = 4;
|
||||
break;
|
||||
case Enchantment::FREQ_VERY_RARE:
|
||||
fee = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
if (usingBook) fee = max(1, fee / 2);
|
||||
|
||||
price += fee * extra;
|
||||
if (DEBUG_COST)
|
||||
{
|
||||
app.DebugPrintf("Enchantment increase fee; price is now %d (went up by %d)\n", price, fee * extra);
|
||||
}
|
||||
}
|
||||
|
||||
if (!compatible) continue;
|
||||
if (level > enchantment->getMaxLevel()) level = enchantment->getMaxLevel();
|
||||
(*enchantments)[id] = level;
|
||||
int fee = 0;
|
||||
|
||||
switch (enchantment->getFrequency())
|
||||
{
|
||||
case Enchantment::FREQ_COMMON:
|
||||
fee = 1;
|
||||
break;
|
||||
case Enchantment::FREQ_UNCOMMON:
|
||||
fee = 2;
|
||||
break;
|
||||
case Enchantment::FREQ_RARE:
|
||||
fee = 4;
|
||||
break;
|
||||
case Enchantment::FREQ_VERY_RARE:
|
||||
fee = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
if (usingBook) fee = max(1, fee / 2);
|
||||
|
||||
price += fee * extra;
|
||||
if (DEBUG_COST)
|
||||
{
|
||||
app.DebugPrintf("Enchantment increase fee; price is now %d (went up by %d)\n", price, fee*extra);
|
||||
}
|
||||
delete additionalEnchantments;
|
||||
}
|
||||
delete additionalEnchantments;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,11 +236,11 @@ void AnvilMenu::createResult()
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for(AUTO_VAR(it, enchantments->begin()); it != enchantments->end(); ++it)
|
||||
for( const auto& it : *enchantments )
|
||||
{
|
||||
int id = it->first;
|
||||
int id = it.first;
|
||||
Enchantment *enchantment = Enchantment::enchantments[id];
|
||||
int level = it->second;
|
||||
int level = it.second;
|
||||
int fee = 0;
|
||||
|
||||
count++;
|
||||
@@ -258,7 +261,7 @@ void AnvilMenu::createResult()
|
||||
break;
|
||||
}
|
||||
|
||||
if (usingBook) fee = max(1, fee / 2);
|
||||
if (usingBook) fee = std::max<int>(1, fee / 2);
|
||||
|
||||
tax += count + level * fee;
|
||||
if (DEBUG_COST)
|
||||
|
||||
@@ -173,15 +173,11 @@ void ArmorDyeRecipe::requires(INGREDIENTS_REQUIRED *pIngReq)
|
||||
ZeroMemory(TempIngReq.uiGridA,sizeof(unsigned int)*9);
|
||||
|
||||
#if 0
|
||||
AUTO_VAR(citEnd, ingredients->end());
|
||||
|
||||
for (vector<ItemInstance *>::const_iterator ingredient = ingredients->begin(); ingredient != citEnd; ingredient++)
|
||||
for ( ItemInstance *expected : *ingredients )
|
||||
{
|
||||
ItemInstance *expected = *ingredient;
|
||||
|
||||
if (expected!=NULL)
|
||||
{
|
||||
int iAuxVal = (*ingredient)->getAuxValue();
|
||||
int iAuxVal = expected->getAuxValue();
|
||||
TempIngReq.uiGridA[iCount++]=expected->id | iAuxVal<<24;
|
||||
// 4J-PB - put the ingredients in boxes 1,2,4,5 so we can see them in a 2x2 crafting screen
|
||||
if(iCount==2) iCount=3;
|
||||
|
||||
@@ -249,10 +249,8 @@ void Arrow::tick()
|
||||
shared_ptr<Entity> hitEntity = nullptr;
|
||||
vector<shared_ptr<Entity> > *objects = level->getEntities(shared_from_this(), this->bb->expand(xd, yd, zd)->grow(1, 1, 1));
|
||||
double nearest = 0;
|
||||
AUTO_VAR(itEnd, objects->end());
|
||||
for (AUTO_VAR(it, objects->begin()); it != itEnd; it++)
|
||||
for ( auto& e : *objects )
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //objects->at(i);
|
||||
if (!e->isPickable() || (e == owner && flightTime < 5)) continue;
|
||||
|
||||
float rr = 0.3f;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
BaseAttributeMap::~BaseAttributeMap()
|
||||
{
|
||||
for(AUTO_VAR(it,attributesById.begin()); it != attributesById.end(); ++it)
|
||||
for( auto& it : attributesById )
|
||||
{
|
||||
delete it->second;
|
||||
delete it.second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ AttributeInstance *BaseAttributeMap::getInstance(Attribute *attribute)
|
||||
|
||||
AttributeInstance *BaseAttributeMap::getInstance(eATTRIBUTE_ID id)
|
||||
{
|
||||
AUTO_VAR(it,attributesById.find(id));
|
||||
auto it = attributesById.find(id);
|
||||
if(it != attributesById.end())
|
||||
{
|
||||
return it->second;
|
||||
@@ -30,9 +30,9 @@ AttributeInstance *BaseAttributeMap::getInstance(eATTRIBUTE_ID id)
|
||||
|
||||
void BaseAttributeMap::getAttributes(vector<AttributeInstance *>& atts)
|
||||
{
|
||||
for(AUTO_VAR(it,attributesById.begin()); it != attributesById.end(); ++it)
|
||||
for( auto& it : attributesById )
|
||||
{
|
||||
atts.push_back(it->second);
|
||||
atts.push_back(it.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,40 +43,44 @@ void BaseAttributeMap::onAttributeModified(ModifiableAttributeInstance *attribut
|
||||
void BaseAttributeMap::removeItemModifiers(shared_ptr<ItemInstance> item)
|
||||
{
|
||||
attrAttrModMap *modifiers = item->getAttributeModifiers();
|
||||
|
||||
for(AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
if ( modifiers )
|
||||
{
|
||||
AttributeInstance *attribute = getInstance(it->first);
|
||||
AttributeModifier *modifier = it->second;
|
||||
|
||||
if (attribute != NULL)
|
||||
for (auto& it : *modifiers)
|
||||
{
|
||||
attribute->removeModifier(modifier);
|
||||
AttributeInstance* attribute = getInstance(it.first);
|
||||
AttributeModifier* modifier = it.second;
|
||||
|
||||
if (attribute != NULL)
|
||||
{
|
||||
attribute->removeModifier(modifier);
|
||||
}
|
||||
|
||||
delete modifier;
|
||||
}
|
||||
|
||||
delete modifier;
|
||||
delete modifiers;
|
||||
}
|
||||
|
||||
delete modifiers;
|
||||
}
|
||||
|
||||
void BaseAttributeMap::addItemModifiers(shared_ptr<ItemInstance> item)
|
||||
{
|
||||
attrAttrModMap *modifiers = item->getAttributeModifiers();
|
||||
|
||||
for(AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
if ( modifiers )
|
||||
{
|
||||
AttributeInstance *attribute = getInstance(it->first);
|
||||
AttributeModifier *modifier = it->second;
|
||||
|
||||
if (attribute != NULL)
|
||||
for (auto& it : *modifiers)
|
||||
{
|
||||
attribute->removeModifier(modifier);
|
||||
attribute->addModifier(new AttributeModifier(*modifier));
|
||||
}
|
||||
|
||||
delete modifier;
|
||||
}
|
||||
AttributeInstance* attribute = getInstance(it.first);
|
||||
AttributeModifier* modifier = it.second;
|
||||
|
||||
delete modifiers;
|
||||
if (attribute != NULL)
|
||||
{
|
||||
attribute->removeModifier(modifier);
|
||||
attribute->addModifier(new AttributeModifier(*modifier));
|
||||
}
|
||||
|
||||
delete modifier;
|
||||
}
|
||||
|
||||
delete modifiers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ BaseMobSpawner::~BaseMobSpawner()
|
||||
{
|
||||
if(spawnPotentials)
|
||||
{
|
||||
for(AUTO_VAR(it,spawnPotentials->begin()); it != spawnPotentials->end(); ++it)
|
||||
for( auto& it : *spawnPotentials )
|
||||
{
|
||||
delete *it;
|
||||
delete it;
|
||||
}
|
||||
delete spawnPotentials;
|
||||
}
|
||||
@@ -137,12 +137,14 @@ shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entit
|
||||
entity->save(data);
|
||||
|
||||
vector<Tag *> *tags = getNextSpawnData()->tag->getAllTags();
|
||||
for (AUTO_VAR(it, tags->begin()); it != tags->end(); ++it)
|
||||
if ( tags )
|
||||
{
|
||||
Tag *tag = *it;
|
||||
data->put(tag->getName(), tag->copy());
|
||||
for (auto& tag : *tags)
|
||||
{
|
||||
data->put(tag->getName(), tag->copy());
|
||||
}
|
||||
delete tags;
|
||||
}
|
||||
delete tags;
|
||||
|
||||
entity->load(data);
|
||||
if (entity->level != NULL) entity->level->addEntity(entity);
|
||||
@@ -159,12 +161,14 @@ shared_ptr<Entity> BaseMobSpawner::loadDataAndAddEntity(shared_ptr<Entity> entit
|
||||
mount->save(mountData);
|
||||
|
||||
vector<Tag *> *ridingTags = ridingTag->getAllTags();
|
||||
for (AUTO_VAR(it, ridingTags->begin()); it != ridingTags->end(); ++it)
|
||||
if ( ridingTags )
|
||||
{
|
||||
Tag *tag = *it;
|
||||
mountData->put(tag->getName(), tag->copy());
|
||||
for (auto& tag : *ridingTags)
|
||||
{
|
||||
mountData->put(tag->getName(), tag->copy());
|
||||
}
|
||||
delete ridingTags;
|
||||
}
|
||||
delete ridingTags;
|
||||
mount->load(mountData);
|
||||
mount->moveTo(rider->x, rider->y, rider->z, rider->yRot, rider->xRot);
|
||||
|
||||
@@ -274,11 +278,10 @@ void BaseMobSpawner::save(CompoundTag *tag)
|
||||
{
|
||||
ListTag<CompoundTag> *list = new ListTag<CompoundTag>();
|
||||
|
||||
if (spawnPotentials != NULL && spawnPotentials->size() > 0)
|
||||
if (spawnPotentials && spawnPotentials->size() > 0)
|
||||
{
|
||||
for (AUTO_VAR(it, spawnPotentials->begin()); it != spawnPotentials->end(); ++it)
|
||||
for ( auto& data : *spawnPotentials )
|
||||
{
|
||||
SpawnData *data = *it;
|
||||
list->add(data->save());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,10 +142,8 @@ bool BaseRailTile::Rail::connectsTo(Rail *rail)
|
||||
{
|
||||
if(m_bValidRail)
|
||||
{
|
||||
AUTO_VAR(itEnd, connections.end());
|
||||
for (AUTO_VAR(it, connections.begin()); it != itEnd; it++)
|
||||
for ( const auto& p : connections )
|
||||
{
|
||||
TilePos *p = *it; //connections[i];
|
||||
if (p->x == rail->x && p->z == rail->z)
|
||||
{
|
||||
return true;
|
||||
@@ -159,10 +157,8 @@ bool BaseRailTile::Rail::hasConnection(int x, int y, int z)
|
||||
{
|
||||
if(m_bValidRail)
|
||||
{
|
||||
AUTO_VAR(itEnd, connections.end());
|
||||
for (AUTO_VAR(it, connections.begin()); it != itEnd; it++)
|
||||
for ( const auto& p : connections )
|
||||
{
|
||||
TilePos *p = *it; //connections[i];
|
||||
if (p->x == x && p->z == z)
|
||||
{
|
||||
return true;
|
||||
@@ -332,10 +328,9 @@ void BaseRailTile::Rail::place(bool hasSignal, bool first)
|
||||
{
|
||||
level->setData(x, y, z, data, Tile::UPDATE_ALL);
|
||||
|
||||
AUTO_VAR(itEnd, connections.end());
|
||||
for (AUTO_VAR(it, connections.begin()); it != itEnd; it++)
|
||||
for ( auto& it : connections )
|
||||
{
|
||||
Rail *neighbor = getRail(*it);
|
||||
Rail *neighbor = getRail(it);
|
||||
if (neighbor == NULL) continue;
|
||||
neighbor->removeSoftConnections();
|
||||
|
||||
|
||||
@@ -80,21 +80,26 @@ void BeaconTileEntity::applyEffects()
|
||||
AABB *bb = AABB::newTemp(x, y, z, x + 1, y + 1, z + 1)->grow(range, range, range);
|
||||
bb->y1 = level->getMaxBuildHeight();
|
||||
vector<shared_ptr<Entity> > *players = level->getEntitiesOfClass(typeid(Player), bb);
|
||||
for (AUTO_VAR(it,players->begin()); it != players->end(); ++it)
|
||||
if ( players )
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(*it);
|
||||
player->addEffect(new MobEffectInstance(primaryPower, SharedConstants::TICKS_PER_SECOND * 9, baseAmp, true));
|
||||
}
|
||||
|
||||
if (levels >= 4 && primaryPower != secondaryPower && secondaryPower > 0)
|
||||
{
|
||||
for (AUTO_VAR(it,players->begin()); it != players->end(); ++it)
|
||||
for (auto& it : *players)
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(*it);
|
||||
player->addEffect(new MobEffectInstance(secondaryPower, SharedConstants::TICKS_PER_SECOND * 9, 0, true));
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(it);
|
||||
if ( player )
|
||||
player->addEffect(new MobEffectInstance(primaryPower, SharedConstants::TICKS_PER_SECOND * 9, baseAmp, true));
|
||||
}
|
||||
|
||||
if (levels >= 4 && primaryPower != secondaryPower && secondaryPower > 0)
|
||||
{
|
||||
for ( auto& it : *players )
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(it);
|
||||
if ( player )
|
||||
player->addEffect(new MobEffectInstance(secondaryPower, SharedConstants::TICKS_PER_SECOND * 9, 0, true));
|
||||
}
|
||||
}
|
||||
delete players;
|
||||
}
|
||||
delete players;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,10 +108,8 @@ bool BedTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player,
|
||||
if (isOccupied(data))
|
||||
{
|
||||
shared_ptr<Player> sleepingPlayer = nullptr;
|
||||
AUTO_VAR(itEnd, level->players.end());
|
||||
for (AUTO_VAR(it, level->players.begin()); it != itEnd; it++ )
|
||||
for ( auto& p : level->players )
|
||||
{
|
||||
shared_ptr<Player> p = *it;
|
||||
if (p->isSleeping())
|
||||
{
|
||||
Pos pos = p->bedPosition;
|
||||
|
||||
@@ -9,9 +9,9 @@ BehaviorRegistry::BehaviorRegistry(DispenseItemBehavior *defaultValue)
|
||||
|
||||
BehaviorRegistry::~BehaviorRegistry()
|
||||
{
|
||||
for(AUTO_VAR(it, storage.begin()); it != storage.end(); ++it)
|
||||
for( auto& it : storage )
|
||||
{
|
||||
delete it->second;
|
||||
delete it.second;
|
||||
}
|
||||
|
||||
delete defaultBehavior;
|
||||
@@ -19,7 +19,7 @@ BehaviorRegistry::~BehaviorRegistry()
|
||||
|
||||
DispenseItemBehavior *BehaviorRegistry::get(Item *key)
|
||||
{
|
||||
AUTO_VAR(it, storage.find(key));
|
||||
auto it = storage.find(key);
|
||||
|
||||
return (it == storage.end()) ? defaultBehavior : it->second;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ BiomeCache::~BiomeCache()
|
||||
// 4J Stu - Delete source?
|
||||
// delete source;
|
||||
|
||||
for(AUTO_VAR(it, all.begin()); it != all.end(); ++it)
|
||||
for( auto& it : all )
|
||||
{
|
||||
delete (*it);
|
||||
delete it;
|
||||
}
|
||||
DeleteCriticalSection(&m_CS);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ BiomeCache::Block *BiomeCache::getBlockAt(int x, int z)
|
||||
x >>= ZONE_SIZE_BITS;
|
||||
z >>= ZONE_SIZE_BITS;
|
||||
__int64 slot = (((__int64) x) & 0xffffffffl) | ((((__int64) z) & 0xffffffffl) << 32l);
|
||||
AUTO_VAR(it, cached.find(slot));
|
||||
auto it = cached.find(slot);
|
||||
Block *block = NULL;
|
||||
if (it == cached.end())
|
||||
{
|
||||
@@ -130,7 +130,7 @@ void BiomeCache::update()
|
||||
{
|
||||
lastUpdateTime = now;
|
||||
|
||||
for (AUTO_VAR(it, all.begin()); it != all.end();)
|
||||
for (auto it = all.begin(); it != all.end();)
|
||||
{
|
||||
Block *block = *it;
|
||||
__int64 time = now - block->lastUse;
|
||||
|
||||
@@ -405,13 +405,12 @@ void Boat::tick()
|
||||
if(level->isClientSide) return;
|
||||
|
||||
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, 0, 0.2f));
|
||||
if (entities != NULL && !entities->empty())
|
||||
if (entities && !entities->empty())
|
||||
{
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
auto riderPtr = rider.lock();
|
||||
for ( auto& e : *entities )
|
||||
{
|
||||
shared_ptr<Entity> e = (*it); // entities->at(i);
|
||||
if (e != rider.lock() && e->isPushable() && e->GetType() == eTYPE_BOAT)
|
||||
if (e != riderPtr && e->isPushable() && e->GetType() == eTYPE_BOAT)
|
||||
{
|
||||
e->push(shared_from_this());
|
||||
}
|
||||
|
||||
@@ -81,10 +81,9 @@ shared_ptr<ItemInstance> BoatItem::use(shared_ptr<ItemInstance> itemInstance, Le
|
||||
bool hitEntity = false;
|
||||
float overlap = 1;
|
||||
vector<shared_ptr<Entity> > *objects = level->getEntities(player, player->bb->expand(b->x * (range), b->y * (range), b->z * (range))->grow(overlap, overlap, overlap));
|
||||
//for (int i = 0; i < objects.size(); i++) {
|
||||
for(AUTO_VAR(it, objects->begin()); it != objects->end(); ++it)
|
||||
|
||||
for( auto& e : *objects )
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //objects.get(i);
|
||||
if (!e->isPickable()) continue;
|
||||
|
||||
float rr = e->getPickRadius();
|
||||
|
||||
@@ -175,7 +175,7 @@ int BoundingBox::getZCenter()
|
||||
|
||||
wstring BoundingBox::toString()
|
||||
{
|
||||
return L"(" + _toString<int>(x0) + L", " + _toString<int>(y0) + L", " + _toString<int>(z0) + L"; " + _toString<int>(x1) + L", " + _toString<int>(y1) + L", " + _toString<int>(z1) + L")";
|
||||
return L"(" + std::to_wstring(x0) + L", " + std::to_wstring(y0) + L", " + std::to_wstring(z0) + L"; " + std::to_wstring(x1) + L", " + std::to_wstring(y1) + L", " + std::to_wstring(z1) + L")";
|
||||
}
|
||||
|
||||
IntArrayTag *BoundingBox::createTag(const wstring &name)
|
||||
|
||||
@@ -53,16 +53,19 @@ shared_ptr<Animal> BreedGoal::getFreePartner()
|
||||
vector<shared_ptr<Entity> > *others = level->getEntitiesOfClass(typeid(*animal), animal->bb->grow(r, r, r));
|
||||
double dist = Double::MAX_VALUE;
|
||||
shared_ptr<Animal> partner = nullptr;
|
||||
for(AUTO_VAR(it, others->begin()); it != others->end(); ++it)
|
||||
if ( others )
|
||||
{
|
||||
shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(*it);
|
||||
if (animal->canMate(p) && animal->distanceToSqr(p) < dist)
|
||||
for ( auto& it : *others )
|
||||
{
|
||||
partner = p;
|
||||
dist = animal->distanceToSqr(p);
|
||||
shared_ptr<Animal> p = dynamic_pointer_cast<Animal>(it);
|
||||
if ( p && animal->canMate(p) && animal->distanceToSqr(p) < dist)
|
||||
{
|
||||
partner = p;
|
||||
dist = animal->distanceToSqr(p);
|
||||
}
|
||||
}
|
||||
delete others;
|
||||
}
|
||||
delete others;
|
||||
return partner;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,8 @@ void BrewingStandMenu::broadcastChanges()
|
||||
{
|
||||
AbstractContainerMenu::broadcastChanges();
|
||||
|
||||
//for (int i = 0; i < containerListeners->size(); i++)
|
||||
for(AUTO_VAR(it, containerListeners.begin()); it != containerListeners.end(); ++it)
|
||||
for( auto& listener : containerListeners )
|
||||
{
|
||||
ContainerListener *listener = *it; //containerListeners.at(i);
|
||||
if (tc != brewingStand->getBrewTime())
|
||||
{
|
||||
listener->setContainerData(this, 0, brewingStand->getBrewTime());
|
||||
|
||||
@@ -183,7 +183,7 @@ C4JThread::~C4JThread()
|
||||
|
||||
EnterCriticalSection(&ms_threadListCS);
|
||||
|
||||
for( AUTO_VAR(it,ms_threadList.begin()); it != ms_threadList.end(); it++ )
|
||||
for (auto it = ms_threadList.begin(); it != ms_threadList.end(); it++)
|
||||
{
|
||||
if( (*it) == this )
|
||||
{
|
||||
|
||||
@@ -37,6 +37,6 @@ void CarrotTile::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" + _toString(i));
|
||||
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" + std::to_wstring(i));
|
||||
}
|
||||
}
|
||||
@@ -70,17 +70,13 @@ bool CaveFeature::place(Level *level, Random *random, int x, int y, int z)
|
||||
}
|
||||
}
|
||||
|
||||
AUTO_VAR(itEnd, toRemove.end());
|
||||
for (AUTO_VAR(it, toRemove.begin()); it != itEnd; it++)
|
||||
for ( auto& p : toRemove )
|
||||
{
|
||||
TilePos *p = *it; //toRemove[i];
|
||||
level->setTileAndData(p->x, p->y, p->z, 0, 0, Tile::UPDATE_CLIENTS);
|
||||
}
|
||||
|
||||
itEnd = toRemove.end();
|
||||
for (AUTO_VAR(it, toRemove.begin()); it != itEnd; it++)
|
||||
for ( auto& p : toRemove )
|
||||
{
|
||||
TilePos *p = *it; //toRemove[i];
|
||||
if (level->getTile(p->x, p->y - 1, p->z) == Tile::dirt_Id && level->getDaytimeRawBrightness(p->x, p->y, p->z) > 8)
|
||||
{
|
||||
level->setTileAndData(p->x, p->y - 1, p->z, Tile::grass_Id, 0, Tile::UPDATE_CLIENTS);
|
||||
|
||||
@@ -337,16 +337,19 @@ int ChestTile::getDirectSignal(LevelSource *level, int x, int y, int z, int dir)
|
||||
bool ChestTile::isCatSittingOnChest(Level *level, int x, int y, int z)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = level->getEntitiesOfClass(typeid(Ocelot), AABB::newTemp(x, y + 1, z, x + 1, y + 2, z + 1));
|
||||
for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
|
||||
if ( entities )
|
||||
{
|
||||
shared_ptr<Ocelot> ocelot = dynamic_pointer_cast<Ocelot>(*it);
|
||||
if(ocelot->isSitting())
|
||||
for (auto& it : *entities)
|
||||
{
|
||||
delete entities;
|
||||
return true;
|
||||
shared_ptr<Ocelot> ocelot = dynamic_pointer_cast<Ocelot>(it);
|
||||
if ( ocelot && ocelot->isSitting())
|
||||
{
|
||||
delete entities;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
delete entities;
|
||||
}
|
||||
delete entities;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,23 +271,26 @@ void ChestTileEntity::tick()
|
||||
|
||||
float range = 5;
|
||||
vector<shared_ptr<Entity> > *players = level->getEntitiesOfClass(typeid(Player), AABB::newTemp(x - range, y - range, z - range, x + 1 + range, y + 1 + range, z + 1 + range));
|
||||
for (AUTO_VAR(it,players->begin()); it != players->end(); ++it)
|
||||
if ( players )
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(*it);
|
||||
|
||||
ContainerMenu *containerMenu = dynamic_cast<ContainerMenu*>(player->containerMenu);
|
||||
if (containerMenu != NULL)
|
||||
for (auto& it : *players)
|
||||
{
|
||||
shared_ptr<Container> container = containerMenu->getContainer();
|
||||
shared_ptr<Container> thisContainer = dynamic_pointer_cast<Container>(shared_from_this());
|
||||
shared_ptr<CompoundContainer> compoundContainer = dynamic_pointer_cast<CompoundContainer>( container );
|
||||
if ( (container == thisContainer) || (compoundContainer != NULL && compoundContainer->contains(thisContainer)) )
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(it);
|
||||
|
||||
ContainerMenu* containerMenu = dynamic_cast<ContainerMenu*>(player->containerMenu);
|
||||
if (containerMenu)
|
||||
{
|
||||
openCount++;
|
||||
shared_ptr<Container> container = containerMenu->getContainer();
|
||||
shared_ptr<Container> thisContainer = dynamic_pointer_cast<Container>(shared_from_this());
|
||||
shared_ptr<CompoundContainer> compoundContainer = dynamic_pointer_cast<CompoundContainer>(container);
|
||||
if ((container == thisContainer) || (compoundContainer != NULL && compoundContainer->contains(thisContainer)))
|
||||
{
|
||||
openCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete players;
|
||||
}
|
||||
delete players;
|
||||
}
|
||||
|
||||
oOpenness = openness;
|
||||
|
||||
@@ -53,14 +53,14 @@ int ChunkPos::getMiddleBlockZ()
|
||||
return ( z << 4 ) + 8;
|
||||
}
|
||||
|
||||
TilePos ChunkPos::getMiddleBlockPosition(int y)
|
||||
TilePos ChunkPos::getMiddleBlockPosition(int y)
|
||||
{
|
||||
return TilePos(getMiddleBlockX(), y, getMiddleBlockZ());
|
||||
}
|
||||
|
||||
wstring ChunkPos::toString()
|
||||
{
|
||||
return L"[" + _toString<int>(x) + L", " + _toString<int>(z) + L"]";
|
||||
return L"[" + std::to_wstring(x) + L", " + std::to_wstring(z) + L"]";
|
||||
}
|
||||
|
||||
__int64 ChunkPos::hash_fnct(const ChunkPos &k)
|
||||
|
||||
@@ -371,9 +371,9 @@ public:
|
||||
|
||||
m_parents.push_back(id);
|
||||
|
||||
for (AUTO_VAR(itr, parent->m_parents.begin()); itr != parent->m_parents.end(); itr++)
|
||||
for ( auto& it : parent->m_parents )
|
||||
{
|
||||
m_parents.push_back(*itr);
|
||||
m_parents.push_back(it);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
@@ -33,6 +33,6 @@ void ClothTile::registerIcons(IconRegister *iconRegister)
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(L"cloth_" + _toString(i) );
|
||||
icons[i] = iconRegister->registerIcon(L"cloth_" + std::to_wstring(i) );
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,9 @@ CombatTracker::CombatTracker(LivingEntity *mob)
|
||||
|
||||
CombatTracker::~CombatTracker()
|
||||
{
|
||||
for (AUTO_VAR(it,entries.begin()); it != entries.end(); ++it)
|
||||
for ( auto& it : entries )
|
||||
{
|
||||
delete (*it);
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +138,8 @@ shared_ptr<LivingEntity> CombatTracker::getKiller()
|
||||
float bestMobDamage = 0;
|
||||
float bestPlayerDamage = 0;
|
||||
|
||||
for (AUTO_VAR(it,entries.begin()); it != entries.end(); ++it)
|
||||
for ( CombatEntry *entry : entries )
|
||||
{
|
||||
CombatEntry *entry = *it;
|
||||
if ( entry->getSource() != NULL && entry->getSource()->getEntity() != NULL && entry->getSource()->getEntity()->instanceof(eTYPE_PLAYER) && (bestPlayer == NULL || entry->getDamage() > bestPlayerDamage))
|
||||
{
|
||||
bestPlayerDamage = entry->getDamage();
|
||||
@@ -241,9 +240,9 @@ void CombatTracker::recheckStatus()
|
||||
|
||||
if (takingDamage && mob->tickCount - lastDamageTime > reset)
|
||||
{
|
||||
for (AUTO_VAR(it,entries.begin()); it != entries.end(); ++it)
|
||||
for ( auto& it : entries )
|
||||
{
|
||||
delete (*it);
|
||||
delete it;
|
||||
}
|
||||
entries.clear();
|
||||
takingDamage = false;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
int CommandDispatcher::performCommand(shared_ptr<CommandSender> sender, EGameCommand command, byteArray commandData)
|
||||
{
|
||||
AUTO_VAR(it, commandsById.find(command));
|
||||
auto it = commandsById.find(command);
|
||||
|
||||
if(it != commandsById.end())
|
||||
{
|
||||
|
||||
@@ -22,10 +22,9 @@ public:
|
||||
|
||||
void write(DataOutput *dos)
|
||||
{
|
||||
AUTO_VAR(itEnd, tags.end());
|
||||
for( unordered_map<wstring, Tag *>::iterator it = tags.begin(); it != itEnd; it++ )
|
||||
for( auto& tag : tags )
|
||||
{
|
||||
Tag::writeNamedTag(it->second, dos);
|
||||
Tag::writeNamedTag(tag.second, dos);
|
||||
}
|
||||
dos->writeByte(Tag::TAG_End);
|
||||
}
|
||||
@@ -55,10 +54,9 @@ public:
|
||||
// 4J - was return tags.values();
|
||||
vector<Tag *> *ret = new vector<Tag *>;
|
||||
|
||||
AUTO_VAR(itEnd, tags.end());
|
||||
for( unordered_map<wstring, Tag *>::iterator it = tags.begin(); it != itEnd; it++ )
|
||||
for( auto& tag : tags )
|
||||
{
|
||||
ret->push_back(it->second);
|
||||
ret->push_back(tag.second);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -130,7 +128,7 @@ public:
|
||||
|
||||
Tag *get(const wstring &name)
|
||||
{
|
||||
AUTO_VAR(it, tags.find(name));
|
||||
auto it = tags.find(name);
|
||||
if(it != tags.end()) return it->second;
|
||||
return NULL;
|
||||
}
|
||||
@@ -213,7 +211,7 @@ public:
|
||||
|
||||
void remove(const wstring &name)
|
||||
{
|
||||
AUTO_VAR(it, tags.find(name));
|
||||
auto it = tags.find(name);
|
||||
if(it != tags.end()) tags.erase(it);
|
||||
//tags.remove(name);
|
||||
}
|
||||
@@ -222,7 +220,7 @@ public:
|
||||
{
|
||||
static const int bufSize = 32;
|
||||
static wchar_t buf[bufSize];
|
||||
swprintf(buf,bufSize,L"%d entries",tags.size());
|
||||
swprintf(buf,bufSize,L"%zu entries",tags.size());
|
||||
return wstring( buf );
|
||||
}
|
||||
|
||||
@@ -236,10 +234,9 @@ public:
|
||||
strcpy( newPrefix, prefix);
|
||||
strcat( newPrefix, " ");
|
||||
|
||||
AUTO_VAR(itEnd, tags.end());
|
||||
for( unordered_map<string, Tag *>::iterator it = tags.begin(); it != itEnd; it++ )
|
||||
for( auto& it : tags )
|
||||
{
|
||||
it->second->print(newPrefix, out);
|
||||
it.second->print(newPrefix, out);
|
||||
}
|
||||
delete[] newPrefix;
|
||||
out << prefix << "}" << endl;
|
||||
@@ -253,10 +250,9 @@ public:
|
||||
|
||||
virtual ~CompoundTag()
|
||||
{
|
||||
AUTO_VAR(itEnd, tags.end());
|
||||
for( AUTO_VAR(it, tags.begin()); it != itEnd; it++ )
|
||||
for( auto& tag : tags )
|
||||
{
|
||||
delete it->second;
|
||||
delete tag.second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,10 +260,9 @@ public:
|
||||
{
|
||||
CompoundTag *tag = new CompoundTag(getName());
|
||||
|
||||
AUTO_VAR(itEnd, tags.end());
|
||||
for( AUTO_VAR(it, tags.begin()); it != itEnd; it++ )
|
||||
for( auto& it : tags )
|
||||
{
|
||||
tag->put((wchar_t *)it->first.c_str(), it->second->copy());
|
||||
tag->put((wchar_t *)it.first.c_str(), it.second->copy());
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
@@ -281,11 +276,10 @@ public:
|
||||
if(tags.size() == o->tags.size())
|
||||
{
|
||||
bool equal = true;
|
||||
AUTO_VAR(itEnd, tags.end());
|
||||
for( AUTO_VAR(it, tags.begin()); it != itEnd; it++ )
|
||||
for( auto& it : tags )
|
||||
{
|
||||
AUTO_VAR(itFind, o->tags.find(it->first));
|
||||
if(itFind == o->tags.end() || !it->second->equals(itFind->second) )
|
||||
auto itFind = o->tags.find(it.first);
|
||||
if(itFind == o->tags.end() || !it.second->equals(itFind->second) )
|
||||
{
|
||||
equal = false;
|
||||
break;
|
||||
|
||||
@@ -273,27 +273,29 @@ void ConsoleSaveFileConverter::ConvertSave(ConsoleSaveFile *sourceSave, ConsoleS
|
||||
// 4J Stu - Old version that just changes the compression of chunks, not usable for XboxOne style split saves or compressed tile formats
|
||||
// Process region files
|
||||
vector<FileEntry *> *allFilesInSave = sourceSave->getFilesWithPrefix(wstring(L""));
|
||||
for(AUTO_VAR(it, allFilesInSave->begin()); it < allFilesInSave->end(); ++it)
|
||||
if ( allFilesInSave )
|
||||
{
|
||||
FileEntry *fe = *it;
|
||||
if( fe != sourceLdatFe )
|
||||
for ( FileEntry* fe : *allFilesInSave )
|
||||
{
|
||||
wstring fName( fe->data.filename );
|
||||
wstring suffix(L".mcr");
|
||||
if( fName.compare(fName.length() - suffix.length(), suffix.length(), suffix) == 0 )
|
||||
if (fe != sourceLdatFe)
|
||||
{
|
||||
wstring fName(fe->data.filename);
|
||||
wstring suffix(L".mcr");
|
||||
if (fName.compare(fName.length() - suffix.length(), suffix.length(), suffix) == 0)
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(L"Processing a region file: %s\n", fe->data.filename);
|
||||
wprintf(L"Processing a region file: %s\n", fe->data.filename);
|
||||
#endif
|
||||
ProcessStandardRegionFile(sourceSave, File(fe->data.filename), targetSave, File(fe->data.filename) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessStandardRegionFile(sourceSave, File(fe->data.filename), targetSave, File(fe->data.filename));
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(L"%s is not a region file, ignoring\n", fe->data.filename);
|
||||
wprintf(L"%s is not a region file, ignoring\n", fe->data.filename);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1043,19 +1043,21 @@ void ConsoleSaveFileOriginal::ConvertToLocalPlatform()
|
||||
}
|
||||
// convert each of the region files to the local platform
|
||||
vector<FileEntry *> *allFilesInSave = getFilesWithPrefix(wstring(L""));
|
||||
for(AUTO_VAR(it, allFilesInSave->begin()); it < allFilesInSave->end(); ++it)
|
||||
if ( allFilesInSave )
|
||||
{
|
||||
FileEntry *fe = *it;
|
||||
wstring fName( fe->data.filename );
|
||||
wstring suffix(L".mcr");
|
||||
if( fName.compare(fName.length() - suffix.length(), suffix.length(), suffix) == 0 )
|
||||
for (FileEntry* fe : *allFilesInSave)
|
||||
{
|
||||
app.DebugPrintf("Processing a region file: %ls\n",fName.c_str());
|
||||
ConvertRegionFile(File(fe->data.filename) );
|
||||
}
|
||||
else
|
||||
{
|
||||
app.DebugPrintf("%ls is not a region file, ignoring\n", fName.c_str());
|
||||
wstring fName(fe->data.filename);
|
||||
wstring suffix(L".mcr");
|
||||
if (fName.compare(fName.length() - suffix.length(), suffix.length(), suffix) == 0)
|
||||
{
|
||||
app.DebugPrintf("Processing a region file: %ls\n", fName.c_str());
|
||||
ConvertRegionFile(File(fe->data.filename));
|
||||
}
|
||||
else
|
||||
{
|
||||
app.DebugPrintf("%ls is not a region file, ignoring\n", fName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,6 @@ void CropTile::registerIcons(IconRegister *iconRegister)
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(L"crops_" + _toString(i));
|
||||
icons[i] = iconRegister->registerIcon(L"crops_" + std::to_wstring(i));
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int &id, int centreX, int
|
||||
//__int64 xShifted = xMasked << 5;
|
||||
//app.DebugPrintf("xShifted = %d (0x%016x), zShifted = %I64d (0x%016llx)\n", xShifted, xShifted, zShifted, zShifted);
|
||||
__int64 index = ( ((__int64)(centreZ & 0x1FFFFFFF)) << 34) | ( ((__int64)(centreX & 0x1FFFFFFF)) << 5) | ( (scale & 0x7) << 2) | (dimension & 0x3);
|
||||
AUTO_VAR(it,m_mappings.find(index));
|
||||
auto it = m_mappings.find(index);
|
||||
if(it != m_mappings.end())
|
||||
{
|
||||
id = it->second;
|
||||
@@ -138,11 +138,11 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int &id, int centreX, int
|
||||
void DirectoryLevelStorage::PlayerMappings::writeMappings(DataOutputStream *dos)
|
||||
{
|
||||
dos->writeInt(m_mappings.size());
|
||||
for(AUTO_VAR(it, m_mappings.begin()); it != m_mappings.end(); ++it)
|
||||
for ( auto& it : m_mappings )
|
||||
{
|
||||
app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", it->first, it->first, it->second);
|
||||
dos->writeLong(it->first);
|
||||
dos->writeInt(it->second);
|
||||
app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", it.first, it.first, it.second);
|
||||
dos->writeLong(it.first);
|
||||
dos->writeInt(it.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,9 +174,9 @@ DirectoryLevelStorage::~DirectoryLevelStorage()
|
||||
{
|
||||
delete m_saveFile;
|
||||
|
||||
for(AUTO_VAR(it,m_cachedSaveData.begin()); it != m_cachedSaveData.end(); ++it)
|
||||
for( auto& it : m_cachedSaveData )
|
||||
{
|
||||
delete it->second;
|
||||
delete it.second;
|
||||
}
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
@@ -233,7 +233,7 @@ ChunkStorage *DirectoryLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
return new OldChunkStorage(dir, true);
|
||||
}
|
||||
|
||||
LevelData *DirectoryLevelStorage::prepareLevel()
|
||||
LevelData *DirectoryLevelStorage::prepareLevel()
|
||||
{
|
||||
// 4J Stu Added
|
||||
#ifdef _LARGE_WORLDS
|
||||
@@ -295,7 +295,7 @@ LevelData *DirectoryLevelStorage::prepareLevel()
|
||||
#else
|
||||
|
||||
if(getSaveFile()->getSaveVersion() < END_DIMENSION_MAP_MAPPINGS_SAVE_VERSION)
|
||||
{
|
||||
{
|
||||
MapDataMappings_old oldMapDataMappings;
|
||||
getSaveFile()->readFile( fileEntry,
|
||||
&oldMapDataMappings, // data buffer
|
||||
@@ -334,7 +334,7 @@ LevelData *DirectoryLevelStorage::prepareLevel()
|
||||
|
||||
ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
|
||||
|
||||
if ( m_saveFile->doesFileExist( dataFile ) )
|
||||
if ( m_saveFile->doesFileExist( dataFile ) )
|
||||
{
|
||||
ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(m_saveFile, dataFile);
|
||||
CompoundTag *root = NbtIo::readCompressed(&fis);
|
||||
@@ -398,7 +398,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
|
||||
#elif defined(_DURANGO)
|
||||
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + player->getXuid().toString() + L".dat" );
|
||||
#else
|
||||
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + _toString( player->getXuid() ) + L".dat" );
|
||||
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( player->getXuid() ) + L".dat" );
|
||||
#endif
|
||||
// If saves are disabled (e.g. because we are writing the save buffer to disk) then cache this player data
|
||||
if(StorageManager.GetSaveDisabled())
|
||||
@@ -406,7 +406,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
|
||||
ByteArrayOutputStream *bos = new ByteArrayOutputStream();
|
||||
NbtIo::writeCompressed(tag,bos);
|
||||
|
||||
AUTO_VAR(it, m_cachedSaveData.find(realFile.getName()));
|
||||
auto it = m_cachedSaveData.find(realFile.getName());
|
||||
if(it != m_cachedSaveData.end() )
|
||||
{
|
||||
delete it->second;
|
||||
@@ -429,7 +429,7 @@ void DirectoryLevelStorage::save(shared_ptr<Player> player)
|
||||
}
|
||||
|
||||
// 4J Changed return val to bool to check if new player or loaded player
|
||||
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
|
||||
CompoundTag *DirectoryLevelStorage::load(shared_ptr<Player> player)
|
||||
{
|
||||
CompoundTag *tag = loadPlayerDataTag( player->getXuid() );
|
||||
if (tag != NULL)
|
||||
@@ -447,9 +447,9 @@ CompoundTag *DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid)
|
||||
#elif defined(_DURANGO)
|
||||
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + xuid.toString() + L".dat" );
|
||||
#else
|
||||
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + _toString( xuid ) + L".dat" );
|
||||
ConsoleSavePath realFile = ConsoleSavePath( playerDir.getName() + std::to_wstring( xuid ) + L".dat" );
|
||||
#endif
|
||||
AUTO_VAR(it, m_cachedSaveData.find(realFile.getName()));
|
||||
auto it = m_cachedSaveData.find(realFile.getName());
|
||||
if(it != m_cachedSaveData.end() )
|
||||
{
|
||||
ByteArrayOutputStream *bos = it->second;
|
||||
@@ -496,7 +496,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles()
|
||||
m_saveFile->deleteFile( playerFiles->at(i) );
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
#endif
|
||||
if( playerFiles->size() > MAX_PLAYER_DATA_SAVES )
|
||||
{
|
||||
@@ -520,12 +520,12 @@ void DirectoryLevelStorage::clearOldPlayerFiles()
|
||||
}
|
||||
}
|
||||
|
||||
PlayerIO *DirectoryLevelStorage::getPlayerIO()
|
||||
PlayerIO *DirectoryLevelStorage::getPlayerIO()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void DirectoryLevelStorage::closeAll()
|
||||
void DirectoryLevelStorage::closeAll()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -567,11 +567,10 @@ void DirectoryLevelStorage::resetNetherPlayerPositions()
|
||||
vector<FileEntry *> *playerFiles = m_saveFile->getFilesWithPrefix( playerDir.getName() );
|
||||
#endif
|
||||
|
||||
if( playerFiles != NULL )
|
||||
if ( playerFiles )
|
||||
{
|
||||
for( AUTO_VAR(it, playerFiles->begin()); it != playerFiles->end(); ++it)
|
||||
for ( FileEntry * realFile : *playerFiles )
|
||||
{
|
||||
FileEntry * realFile = *it;
|
||||
ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(m_saveFile, realFile);
|
||||
CompoundTag *tag = NbtIo::readCompressed(&fis);
|
||||
if (tag != NULL)
|
||||
@@ -579,7 +578,7 @@ void DirectoryLevelStorage::resetNetherPlayerPositions()
|
||||
// If the player is in the nether, set their y position above the top of the nether
|
||||
// This will force the player to be spawned in a valid position in the overworld when they are loaded
|
||||
if(tag->contains(L"Dimension") && tag->getInt(L"Dimension") == LevelData::DIMENSION_NETHER && tag->contains(L"Pos"))
|
||||
{
|
||||
{
|
||||
ListTag<DoubleTag> *pos = (ListTag<DoubleTag> *) tag->getList(L"Pos");
|
||||
pos->get(1)->data = DBL_MAX;
|
||||
|
||||
@@ -600,7 +599,7 @@ int DirectoryLevelStorage::getAuxValueForMap(PlayerUID xuid, int dimension, int
|
||||
bool foundMapping = false;
|
||||
|
||||
#ifdef _LARGE_WORLDS
|
||||
AUTO_VAR(it, m_playerMappings.find(xuid) );
|
||||
auto it = m_playerMappings.find(xuid);
|
||||
if(it != m_playerMappings.end())
|
||||
{
|
||||
foundMapping = it->second.getMapping(mapId, centreXC, centreZC, dimension, scale);
|
||||
@@ -647,12 +646,12 @@ int DirectoryLevelStorage::getAuxValueForMap(PlayerUID xuid, int dimension, int
|
||||
m_saveableMapDataMappings.setMapping(mapId, xuid, dimension);
|
||||
|
||||
// If we had an old map file for a mapping that is no longer valid, delete it
|
||||
std::wstring id = wstring( L"map_" ) + _toString(mapId);
|
||||
std::wstring id = wstring( L"map_" ) + std::to_wstring(mapId);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
|
||||
if(m_saveFile->doesFileExist(file) )
|
||||
{
|
||||
AUTO_VAR(it, find(m_mapFilesToDelete.begin(), m_mapFilesToDelete.end(), mapId));
|
||||
auto it = find(m_mapFilesToDelete.begin(), m_mapFilesToDelete.end(), mapId);
|
||||
if(it != m_mapFilesToDelete.end()) m_mapFilesToDelete.erase(it);
|
||||
|
||||
m_saveFile->deleteFile( m_saveFile->createFile(file) );
|
||||
@@ -683,15 +682,15 @@ void DirectoryLevelStorage::saveMapIdLookup()
|
||||
DataOutputStream dos(&baos);
|
||||
dos.writeInt(m_playerMappings.size());
|
||||
app.DebugPrintf("Saving %d mappings\n", m_playerMappings.size());
|
||||
for(AUTO_VAR(it,m_playerMappings.begin()); it != m_playerMappings.end(); ++it)
|
||||
for ( auto& it : m_playerMappings )
|
||||
{
|
||||
#ifdef _WINDOWS64
|
||||
app.DebugPrintf(" -- %d\n", it->first);
|
||||
app.DebugPrintf(" -- %d\n", it.first);
|
||||
#else
|
||||
app.DebugPrintf(" -- %ls\n", it->first.toString().c_str());
|
||||
app.DebugPrintf(" -- %ls\n", it.first.toString().c_str());
|
||||
#endif
|
||||
dos.writePlayerUID(it->first);
|
||||
it->second.writeMappings(&dos);
|
||||
dos.writePlayerUID(it.first);
|
||||
it.second.writeMappings(&dos);
|
||||
}
|
||||
dos.write(m_usedMappings);
|
||||
m_saveFile->writeFile( fileEntry,
|
||||
@@ -713,10 +712,10 @@ void DirectoryLevelStorage::saveMapIdLookup()
|
||||
void DirectoryLevelStorage::dontSaveMapMappingForPlayer(PlayerUID xuid)
|
||||
{
|
||||
#ifdef _LARGE_WORLDS
|
||||
AUTO_VAR(it, m_playerMappings.find(xuid) );
|
||||
auto it = m_playerMappings.find(xuid);
|
||||
if(it != m_playerMappings.end())
|
||||
{
|
||||
for(AUTO_VAR(itMap, it->second.m_mappings.begin()); itMap != it->second.m_mappings.end(); ++itMap)
|
||||
for (auto itMap = it->second.m_mappings.begin(); itMap != it->second.m_mappings.end(); ++itMap)
|
||||
{
|
||||
int index = itMap->second / 8;
|
||||
int offset = itMap->second % 8;
|
||||
@@ -744,12 +743,12 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(shared_ptr<Player> player)
|
||||
void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid)
|
||||
{
|
||||
#ifdef _LARGE_WORLDS
|
||||
AUTO_VAR(it, m_playerMappings.find(xuid) );
|
||||
auto it = m_playerMappings.find(xuid);
|
||||
if(it != m_playerMappings.end())
|
||||
{
|
||||
for(AUTO_VAR(itMap, it->second.m_mappings.begin()); itMap != it->second.m_mappings.end(); ++itMap)
|
||||
for (auto itMap = it->second.m_mappings.begin(); itMap != it->second.m_mappings.end(); ++itMap)
|
||||
{
|
||||
std::wstring id = wstring( L"map_" ) + _toString(itMap->second);
|
||||
std::wstring id = wstring( L"map_" ) + std::to_wstring(itMap->second);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
|
||||
if(m_saveFile->doesFileExist(file) )
|
||||
@@ -773,7 +772,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid)
|
||||
{
|
||||
changed = true;
|
||||
|
||||
std::wstring id = wstring( L"map_" ) + _toString(i);
|
||||
std::wstring id = wstring( L"map_" ) + std::to_wstring(i);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
|
||||
if(m_saveFile->doesFileExist(file) )
|
||||
@@ -795,22 +794,22 @@ void DirectoryLevelStorage::saveAllCachedData()
|
||||
if(StorageManager.GetSaveDisabled() ) return;
|
||||
|
||||
// Save any files that were saved while saving was disabled
|
||||
for(AUTO_VAR(it, m_cachedSaveData.begin()); it != m_cachedSaveData.end(); ++it)
|
||||
for ( auto& it : m_cachedSaveData )
|
||||
{
|
||||
ByteArrayOutputStream *bos = it->second;
|
||||
ByteArrayOutputStream *bos = it.second;
|
||||
|
||||
ConsoleSavePath realFile = ConsoleSavePath( it->first );
|
||||
ConsoleSavePath realFile = ConsoleSavePath( it.first );
|
||||
ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream( m_saveFile, realFile );
|
||||
|
||||
app.DebugPrintf("Actually writing cached file %ls\n",it->first.c_str() );
|
||||
app.DebugPrintf("Actually writing cached file %ls\n",it.first.c_str() );
|
||||
fos.write(bos->buf, 0, bos->size() );
|
||||
delete bos;
|
||||
}
|
||||
m_cachedSaveData.clear();
|
||||
|
||||
for(AUTO_VAR(it, m_mapFilesToDelete.begin()); it != m_mapFilesToDelete.end(); ++it)
|
||||
for (auto& it : m_mapFilesToDelete )
|
||||
{
|
||||
std::wstring id = wstring( L"map_" ) + _toString(*it);
|
||||
std::wstring id = wstring( L"map_" ) + std::to_wstring(it);
|
||||
ConsoleSavePath file = getDataFile(id);
|
||||
if(m_saveFile->doesFileExist(file) )
|
||||
{
|
||||
|
||||
@@ -27,12 +27,12 @@ vector<LevelSummary *> *DirectoryLevelStorageSource::getLevelList()
|
||||
// 4J Stu - We don't use directory list with the Xbox save locations
|
||||
vector<LevelSummary *> *levels = new vector<LevelSummary *>;
|
||||
#if 0
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
wstring levelId = wstring(L"World").append( _toString( (i+1) ) );
|
||||
wstring levelId = wstring(L"World").append( std::to_wstring( (i+1) ) );
|
||||
|
||||
LevelData *levelData = getDataTagFor(saveFile, levelId);
|
||||
if (levelData != NULL)
|
||||
if (levelData != NULL)
|
||||
{
|
||||
levels->push_back(new LevelSummary(levelId, L"", levelData->getLastPlayed(), levelData->getSizeOnDisk(), levelData.getGameType(), false, levelData->isHardcore()));
|
||||
}
|
||||
@@ -45,7 +45,7 @@ void DirectoryLevelStorageSource::clearAll()
|
||||
{
|
||||
}
|
||||
|
||||
LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile, const wstring& levelId)
|
||||
LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile, const wstring& levelId)
|
||||
{
|
||||
//File dataFile(dir, L"level.dat");
|
||||
ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
|
||||
@@ -63,12 +63,12 @@ LevelData *DirectoryLevelStorageSource::getDataTagFor(ConsoleSaveFile *saveFile,
|
||||
}
|
||||
|
||||
void DirectoryLevelStorageSource::renameLevel(const wstring& levelId, const wstring& newLevelName)
|
||||
{
|
||||
{
|
||||
ConsoleSaveFileOriginal tempSave(levelId);
|
||||
|
||||
//File dataFile = File(dir, L"level.dat");
|
||||
ConsoleSavePath dataFile = ConsoleSavePath( wstring( L"level.dat" ) );
|
||||
if ( tempSave.doesFileExist( dataFile ) )
|
||||
if ( tempSave.doesFileExist( dataFile ) )
|
||||
{
|
||||
ConsoleSaveFileInputStream fis = ConsoleSaveFileInputStream(&tempSave, dataFile);
|
||||
CompoundTag *root = NbtIo::readCompressed(&fis);
|
||||
@@ -80,7 +80,7 @@ void DirectoryLevelStorageSource::renameLevel(const wstring& levelId, const wstr
|
||||
}
|
||||
}
|
||||
|
||||
bool DirectoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId)
|
||||
bool DirectoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId)
|
||||
{
|
||||
// 4J Jev, removed try/catch.
|
||||
|
||||
@@ -95,7 +95,7 @@ bool DirectoryLevelStorageSource::isNewLevelIdAcceptable(const wstring& levelId)
|
||||
return true;
|
||||
}
|
||||
|
||||
void DirectoryLevelStorageSource::deleteLevel(const wstring& levelId)
|
||||
void DirectoryLevelStorageSource::deleteLevel(const wstring& levelId)
|
||||
{
|
||||
File dir = File(baseDir, levelId);
|
||||
if (!dir.exists()) return;
|
||||
@@ -106,15 +106,16 @@ void DirectoryLevelStorageSource::deleteLevel(const wstring& levelId)
|
||||
|
||||
void DirectoryLevelStorageSource::deleteRecursive(vector<File *> *files)
|
||||
{
|
||||
AUTO_VAR(itEnd, files->end());
|
||||
for (AUTO_VAR(it, files->begin()); it != itEnd; it++)
|
||||
if ( files )
|
||||
{
|
||||
File *file = *it;
|
||||
if (file->isDirectory())
|
||||
for (File* file : *files)
|
||||
{
|
||||
deleteRecursive(file->listFiles());
|
||||
if (file->isDirectory())
|
||||
{
|
||||
deleteRecursive(file->listFiles());
|
||||
}
|
||||
file->_delete();
|
||||
}
|
||||
file->_delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ bool DirectoryLevelStorageSource::requiresConversion(ConsoleSaveFile *saveFile,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DirectoryLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const wstring& levelId, ProgressListener *progress)
|
||||
bool DirectoryLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const wstring& levelId, ProgressListener *progress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,27 +33,27 @@ void DragonFireball::onHit(HitResult *res)
|
||||
{
|
||||
AABB *aoe = bb->grow(SPLASH_RANGE, SPLASH_RANGE / 2, SPLASH_RANGE);
|
||||
vector<shared_ptr<Entity> > *entitiesOfClass = level->getEntitiesOfClass(typeid(LivingEntity), aoe);
|
||||
|
||||
if (entitiesOfClass != NULL && !entitiesOfClass->empty())
|
||||
if ( entitiesOfClass )
|
||||
{
|
||||
//for (Entity e : entitiesOfClass)
|
||||
for( AUTO_VAR(it, entitiesOfClass->begin()); it != entitiesOfClass->end(); ++it)
|
||||
if (!entitiesOfClass->empty())
|
||||
{
|
||||
//shared_ptr<Entity> e = *it;
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>( *it );
|
||||
double dist = distanceToSqr(e);
|
||||
if (dist < SPLASH_RANGE_SQ)
|
||||
for (auto& it : *entitiesOfClass)
|
||||
{
|
||||
double scale = 1.0 - (sqrt(dist) / SPLASH_RANGE);
|
||||
if (e == res->entity)
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>(it);
|
||||
double dist = distanceToSqr(e);
|
||||
if (dist < SPLASH_RANGE_SQ)
|
||||
{
|
||||
scale = 1;
|
||||
double scale = 1.0 - (sqrt(dist) / SPLASH_RANGE);
|
||||
if (e == res->entity)
|
||||
{
|
||||
scale = 1;
|
||||
}
|
||||
e->hurt(DamageSource::dragonbreath, 8 * scale);
|
||||
}
|
||||
e->hurt(DamageSource::dragonbreath, 8*scale);
|
||||
}
|
||||
}
|
||||
delete entitiesOfClass;
|
||||
}
|
||||
delete entitiesOfClass;
|
||||
level->levelEvent(LevelEvent::ENDERDRAGON_FIREBALL_SPLASH, (int) Math::round(x), (int) Math::round(y), (int) Math::round(z), 0);
|
||||
|
||||
remove();
|
||||
|
||||
@@ -57,19 +57,19 @@ void EnchantmentHelper::setEnchantments(unordered_map<int, int> *enchantments, s
|
||||
ListTag<CompoundTag> *list = new ListTag<CompoundTag>();
|
||||
|
||||
//for (int id : enchantments.keySet())
|
||||
for(AUTO_VAR(it, enchantments->begin()); it != enchantments->end(); ++it)
|
||||
for ( const auto& it : *enchantments )
|
||||
{
|
||||
int id = it->first;
|
||||
int id = it.first;
|
||||
CompoundTag *tag = new CompoundTag();
|
||||
|
||||
tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_ID, (short) id);
|
||||
tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short)(int)it->second);
|
||||
tag->putShort((wchar_t *)ItemInstance::TAG_ENCH_LEVEL, (short)(int)it.second);
|
||||
|
||||
list->add(tag);
|
||||
|
||||
if (item->id == Item::enchantedBook_Id)
|
||||
{
|
||||
Item::enchantedBook->addEnchantment(item, new EnchantmentInstance(id, it->second));
|
||||
Item::enchantedBook->addEnchantment(item, new EnchantmentInstance(id, it.second));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,20 +301,22 @@ shared_ptr<ItemInstance> EnchantmentHelper::enchantItem(Random *random, shared_p
|
||||
|
||||
if (isBook) itemInstance->id = Item::enchantedBook_Id;
|
||||
|
||||
if (newEnchantment != NULL)
|
||||
if ( newEnchantment )
|
||||
{
|
||||
for(AUTO_VAR(it, newEnchantment->begin()); it != newEnchantment->end(); ++it)
|
||||
for ( EnchantmentInstance *e : *newEnchantment )
|
||||
{
|
||||
EnchantmentInstance *e = *it;
|
||||
if (isBook)
|
||||
if ( e )
|
||||
{
|
||||
Item::enchantedBook->addEnchantment(itemInstance, e);
|
||||
if (isBook)
|
||||
{
|
||||
Item::enchantedBook->addEnchantment(itemInstance, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInstance->enchant(e->enchantment, e->level);
|
||||
}
|
||||
delete e;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInstance->enchant(e->enchantment, e->level);
|
||||
}
|
||||
delete e;
|
||||
}
|
||||
delete newEnchantment;
|
||||
}
|
||||
@@ -355,17 +357,17 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
|
||||
vector<EnchantmentInstance *> *results = NULL;
|
||||
|
||||
unordered_map<int, EnchantmentInstance *> *availableEnchantments = getAvailableEnchantmentResults(realValue, itemInstance);
|
||||
if (availableEnchantments != NULL && !availableEnchantments->empty())
|
||||
if (availableEnchantments && !availableEnchantments->empty())
|
||||
{
|
||||
vector<WeighedRandomItem *> values;
|
||||
for(AUTO_VAR(it, availableEnchantments->begin()); it != availableEnchantments->end(); ++it)
|
||||
for( auto& it : *availableEnchantments )
|
||||
{
|
||||
values.push_back(it->second);
|
||||
values.push_back(it.second);
|
||||
}
|
||||
EnchantmentInstance *instance = (EnchantmentInstance *) WeighedRandom::getRandomItem(random, &values);
|
||||
values.clear();
|
||||
|
||||
if (instance != NULL)
|
||||
if (instance)
|
||||
{
|
||||
results = new vector<EnchantmentInstance *>();
|
||||
results->push_back( instance->copy() ); // 4J Stu - Inserting a copy so we can clear memory from the availableEnchantments collection
|
||||
@@ -377,14 +379,12 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
|
||||
// remove incompatible enchantments from previous result
|
||||
//final Iterator<Integer> mapIter = availableEnchantments.keySet().iterator();
|
||||
//while (mapIter.hasNext())
|
||||
for(AUTO_VAR(it, availableEnchantments->begin()); it != availableEnchantments->end();)
|
||||
for (auto it = availableEnchantments->begin(); it != availableEnchantments->end();)
|
||||
{
|
||||
int nextEnchantment = it->first;//mapIter.next();
|
||||
bool valid = true;
|
||||
//for (EnchantmentInstance *current : results)
|
||||
for(AUTO_VAR(resIt, results->begin()); resIt != results->end(); ++resIt)
|
||||
for ( const EnchantmentInstance *current : *results )
|
||||
{
|
||||
EnchantmentInstance *current = *resIt;
|
||||
if (!current->enchantment->isCompatibleWith(Enchantment::enchantments[nextEnchantment]))
|
||||
{
|
||||
valid = false;
|
||||
@@ -405,9 +405,9 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
|
||||
|
||||
if (!availableEnchantments->empty())
|
||||
{
|
||||
for(AUTO_VAR(it, availableEnchantments->begin()); it != availableEnchantments->end(); ++it)
|
||||
for (auto& it : *availableEnchantments )
|
||||
{
|
||||
values.push_back(it->second);
|
||||
values.push_back(it.second);
|
||||
}
|
||||
EnchantmentInstance *nextInstance = (EnchantmentInstance *) WeighedRandom::getRandomItem(random, &values);
|
||||
values.clear();
|
||||
@@ -418,11 +418,11 @@ vector<EnchantmentInstance *> *EnchantmentHelper::selectEnchantment(Random *rand
|
||||
}
|
||||
}
|
||||
}
|
||||
if(availableEnchantments != NULL)
|
||||
if( availableEnchantments )
|
||||
{
|
||||
for(AUTO_VAR(it, availableEnchantments->begin()); it != availableEnchantments->end(); ++it)
|
||||
for (auto& it : *availableEnchantments )
|
||||
{
|
||||
delete it->second;
|
||||
delete it.second;
|
||||
}
|
||||
delete availableEnchantments;
|
||||
}
|
||||
@@ -460,7 +460,7 @@ unordered_map<int, EnchantmentInstance *> *EnchantmentHelper::getAvailableEnchan
|
||||
{
|
||||
results = new unordered_map<int, EnchantmentInstance *>();
|
||||
}
|
||||
AUTO_VAR(it, results->find(e->id));
|
||||
auto it = results->find(e->id);
|
||||
if(it != results->end())
|
||||
{
|
||||
delete it->second;
|
||||
|
||||
@@ -110,12 +110,10 @@ bool EnderCrystal::hurt(DamageSource *source, float damage)
|
||||
|
||||
vector<shared_ptr<Entity> > entities = level->getAllEntities();
|
||||
shared_ptr<EnderDragon> dragon = nullptr;
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
for ( auto& e : entities )
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
dragon = dynamic_pointer_cast<EnderDragon>(e);
|
||||
if(dragon != NULL)
|
||||
if ( dragon )
|
||||
{
|
||||
dragon->handleCrystalDestroyed(source);
|
||||
break;
|
||||
|
||||
@@ -444,13 +444,16 @@ void EnderDragon::aiStep()
|
||||
{
|
||||
vector<shared_ptr<Entity> > *targets = level->getEntities(shared_from_this(), m_acidArea);
|
||||
|
||||
for( AUTO_VAR(it, targets->begin() ); it != targets->end(); ++it)
|
||||
if ( targets )
|
||||
{
|
||||
if ( (*it)->instanceof(eTYPE_LIVINGENTITY) )
|
||||
for (auto& it : *targets )
|
||||
{
|
||||
//app.DebugPrintf("Attacking entity with acid\n");
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>( *it );
|
||||
e->hurt(DamageSource::dragonbreath, 2);
|
||||
if ( it->instanceof(eTYPE_LIVINGENTITY))
|
||||
{
|
||||
//app.DebugPrintf("Attacking entity with acid\n");
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>(it);
|
||||
e->hurt(DamageSource::dragonbreath, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -796,24 +799,23 @@ void EnderDragon::checkCrystals()
|
||||
{
|
||||
float maxDist = 32;
|
||||
vector<shared_ptr<Entity> > *crystals = level->getEntitiesOfClass(typeid(EnderCrystal), bb->grow(maxDist, maxDist, maxDist));
|
||||
|
||||
shared_ptr<EnderCrystal> crystal = nullptr;
|
||||
double nearest = Double::MAX_VALUE;
|
||||
//for (Entity ec : crystals)
|
||||
for(AUTO_VAR(it, crystals->begin()); it != crystals->end(); ++it)
|
||||
if ( crystals )
|
||||
{
|
||||
shared_ptr<EnderCrystal> ec = dynamic_pointer_cast<EnderCrystal>( *it );
|
||||
double dist = ec->distanceToSqr(shared_from_this() );
|
||||
if (dist < nearest)
|
||||
shared_ptr<EnderCrystal> crystal = nullptr;
|
||||
double nearest = Double::MAX_VALUE;
|
||||
for (auto& it : *crystals )
|
||||
{
|
||||
nearest = dist;
|
||||
crystal = ec;
|
||||
shared_ptr<EnderCrystal> ec = dynamic_pointer_cast<EnderCrystal>(it);
|
||||
double dist = ec->distanceToSqr(shared_from_this());
|
||||
if (dist < nearest)
|
||||
{
|
||||
nearest = dist;
|
||||
crystal = ec;
|
||||
}
|
||||
}
|
||||
delete crystals;
|
||||
nearestCrystal = crystal;
|
||||
}
|
||||
delete crystals;
|
||||
|
||||
|
||||
nearestCrystal = crystal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,33 +841,39 @@ void EnderDragon::knockBack(vector<shared_ptr<Entity> > *entities)
|
||||
// double ym = (body.bb.y0 + body.bb.y1) / 2;
|
||||
double zm = (body->bb->z0 + body->bb->z1) / 2;
|
||||
|
||||
//for (Entity e : entities)
|
||||
for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
|
||||
if ( entities )
|
||||
{
|
||||
|
||||
if ( (*it)->instanceof(eTYPE_LIVINGENTITY) )//(e instanceof Mob)
|
||||
for ( auto& it : *entities )
|
||||
{
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>( *it );
|
||||
double xd = e->x - xm;
|
||||
double zd = e->z - zm;
|
||||
double dd = xd * xd + zd * zd;
|
||||
e->push(xd / dd * 4, 0.2f, zd / dd * 4);
|
||||
if (it->instanceof(eTYPE_LIVINGENTITY))
|
||||
{
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>(it);
|
||||
double xd = e->x - xm;
|
||||
double zd = e->z - zm;
|
||||
double dd = xd * xd + zd * zd;
|
||||
e->push(xd / dd * 4, 0.2f, zd / dd * 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnderDragon::hurt(vector<shared_ptr<Entity> > *entities)
|
||||
{
|
||||
//for (int i = 0; i < entities->size(); i++)
|
||||
for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
|
||||
if ( entities )
|
||||
{
|
||||
|
||||
if ( (*it)->instanceof(eTYPE_LIVINGENTITY) ) //(e instanceof Mob)
|
||||
for ( auto& it : *entities )
|
||||
{
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>( *it );//entities.get(i);
|
||||
DamageSource *damageSource = DamageSource::mobAttack( dynamic_pointer_cast<LivingEntity>( shared_from_this() ));
|
||||
e->hurt(damageSource, 10);
|
||||
delete damageSource;
|
||||
|
||||
if ( it->instanceof(eTYPE_LIVINGENTITY))
|
||||
{
|
||||
shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>(it);
|
||||
DamageSource* damageSource = DamageSource::mobAttack(dynamic_pointer_cast<LivingEntity>(shared_from_this()));
|
||||
if ( damageSource )
|
||||
{
|
||||
e->hurt(damageSource, 10);
|
||||
delete damageSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,9 +753,6 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
AABBList *aABBs = level->getCubes(shared_from_this(), bb->expand(xa, ya, za), noEntityCubes, true);
|
||||
|
||||
|
||||
// LAND FIRST, then x and z
|
||||
AUTO_VAR(itEndAABB, aABBs->end());
|
||||
|
||||
// 4J Stu - Particles (and possibly other entities) don't have xChunk and zChunk set, so calculate the chunk instead
|
||||
int xc = Mth::floor(x / 16);
|
||||
int zc = Mth::floor(z / 16);
|
||||
@@ -763,8 +760,8 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
{
|
||||
// 4J Stu - It's horrible that the client is doing any movement at all! But if we don't have the chunk
|
||||
// data then all the collision info will be incorrect as well
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
ya = (*it)->clipYCollide(bb, ya);
|
||||
for ( auto& it : *aABBs )
|
||||
ya = it->clipYCollide(bb, ya);
|
||||
bb->move(0, ya, 0);
|
||||
}
|
||||
|
||||
@@ -775,9 +772,8 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
|
||||
bool og = onGround || (yaOrg != ya && yaOrg < 0);
|
||||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
xa = (*it)->clipXCollide(bb, xa);
|
||||
for ( auto& it : *aABBs )
|
||||
xa = it->clipXCollide(bb, xa);
|
||||
|
||||
bb->move(xa, 0, 0);
|
||||
|
||||
@@ -786,9 +782,8 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
xa = ya = za = 0;
|
||||
}
|
||||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
za = (*it)->clipZCollide(bb, za);
|
||||
for ( auto& it : *aABBs )
|
||||
za = it->clipZCollide(bb, za);
|
||||
bb->move(0, 0, za);
|
||||
|
||||
if (!slide && zaOrg != za)
|
||||
@@ -812,15 +807,12 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
// so we'd better include cubes under our feet in this list of things we might possibly collide with
|
||||
aABBs = level->getCubes(shared_from_this(), bb->expand(xa, ya, za)->expand(0,-ya,0),false,true);
|
||||
|
||||
// LAND FIRST, then x and z
|
||||
itEndAABB = aABBs->end();
|
||||
|
||||
if(!level->isClientSide || level->reallyHasChunk(xc, zc))
|
||||
{
|
||||
// 4J Stu - It's horrible that the client is doing any movement at all! But if we don't have the chunk
|
||||
// data then all the collision info will be incorrect as well
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
ya = (*it)->clipYCollide(bb, ya);
|
||||
for ( auto& it : *aABBs )
|
||||
ya = it->clipYCollide(bb, ya);
|
||||
bb->move(0, ya, 0);
|
||||
}
|
||||
|
||||
@@ -830,9 +822,8 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
}
|
||||
|
||||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
xa = (*it)->clipXCollide(bb, xa);
|
||||
for ( auto& it : *aABBs )
|
||||
xa = it->clipXCollide(bb, xa);
|
||||
bb->move(xa, 0, 0);
|
||||
|
||||
if (!slide && xaOrg != xa)
|
||||
@@ -840,9 +831,8 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
xa = ya = za = 0;
|
||||
}
|
||||
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
za = (*it)->clipZCollide(bb, za);
|
||||
for ( auto& it : *aABBs )
|
||||
za = it->clipZCollide(bb, za);
|
||||
bb->move(0, 0, za);
|
||||
|
||||
if (!slide && zaOrg != za)
|
||||
@@ -859,9 +849,8 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
|
||||
{
|
||||
ya = -footSize;
|
||||
// LAND FIRST, then x and z
|
||||
itEndAABB = aABBs->end();
|
||||
for (AUTO_VAR(it, aABBs->begin()); it != itEndAABB; it++)
|
||||
ya = (*it)->clipYCollide(bb, ya);
|
||||
for ( auto& it : *aABBs )
|
||||
ya = it->clipYCollide(bb, ya);
|
||||
bb->move(0, ya, 0);
|
||||
}
|
||||
|
||||
@@ -1667,14 +1656,12 @@ void Entity::lerpTo(double x, double y, double z, float yRot, float xRot, int st
|
||||
if( GetType() != eTYPE_ARROW )
|
||||
{
|
||||
AABBList *collisions = level->getCubes(shared_from_this(), bb->shrink(1 / 32.0, 0, 1 / 32.0));
|
||||
if (!collisions->empty())
|
||||
if ( collisions && !collisions->empty())
|
||||
{
|
||||
double yTop = 0;
|
||||
AUTO_VAR(itEnd, collisions->end());
|
||||
for (AUTO_VAR(it, collisions->begin()); it != itEnd; it++)
|
||||
for ( const AABB *ab : *collisions )
|
||||
{
|
||||
AABB *ab = *it; //collisions->at(i);
|
||||
if (ab->y1 > yTop) yTop = ab->y1;
|
||||
if ( ab && ab->y1 > yTop) yTop = ab->y1;
|
||||
}
|
||||
|
||||
y += yTop - bb->y0;
|
||||
@@ -1942,7 +1929,7 @@ wstring Entity::getAName()
|
||||
#ifdef _DEBUG
|
||||
wstring id = EntityIO::getEncodeId(shared_from_this());
|
||||
if (id.empty()) id = L"generic";
|
||||
return L"entity." + id + _toString(entityId);
|
||||
return L"entity." + id + std::to_wstring(entityId);
|
||||
#else
|
||||
return L"";
|
||||
#endif
|
||||
|
||||
@@ -440,7 +440,7 @@ void EntityHorse::causeFallDamage(float fallDistance)
|
||||
|
||||
/**
|
||||
* Different inventory sizes depending on the kind of horse
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int EntityHorse::getInventorySize()
|
||||
@@ -523,9 +523,8 @@ shared_ptr<EntityHorse> EntityHorse::getClosestMommy(shared_ptr<Entity> baby, do
|
||||
shared_ptr<Entity> mommy = nullptr;
|
||||
vector<shared_ptr<Entity> > *list = level->getEntities(baby, baby->bb->expand(searchRadius, searchRadius, searchRadius), PARENT_HORSE_SELECTOR);
|
||||
|
||||
for(AUTO_VAR(it,list->begin()); it != list->end(); ++it)
|
||||
for( auto& horse : *list )
|
||||
{
|
||||
shared_ptr<Entity> horse = *it;
|
||||
double distanceSquared = horse->distanceToSqr(baby->x, baby->y, baby->z);
|
||||
|
||||
if (distanceSquared < closestDistance)
|
||||
@@ -767,7 +766,7 @@ void EntityHorse::rebuildLayeredTextureInfo()
|
||||
else
|
||||
{
|
||||
layerTextureLayers[0] = -1;
|
||||
layerTextureHashName += L"_" + _toString<int>(type) + L"_";
|
||||
layerTextureHashName += L"_" + std::to_wstring(type) + L"_";
|
||||
armorIndex = 1;
|
||||
}
|
||||
|
||||
@@ -1036,7 +1035,7 @@ bool EntityHorse::canWearArmor()
|
||||
|
||||
/**
|
||||
* able to carry bags
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
bool EntityHorse::canWearBags()
|
||||
@@ -1065,7 +1064,7 @@ bool EntityHorse::isPureBreed()
|
||||
|
||||
/**
|
||||
* Is this an Undead Horse?
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
bool EntityHorse::isUndead()
|
||||
@@ -1675,7 +1674,7 @@ MobGroupData *EntityHorse::finalizeMobSpawn(MobGroupData *groupData, int extraDa
|
||||
setAge(AgableMob::BABY_START_AGE);
|
||||
}
|
||||
|
||||
if (type == TYPE_SKELETON || type == TYPE_UNDEAD)
|
||||
if (type == TYPE_SKELETON || type == TYPE_UNDEAD)
|
||||
{
|
||||
getAttribute(SharedMonsterAttributes::MAX_HEALTH)->setBaseValue(15);
|
||||
getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED)->setBaseValue(0.2f);
|
||||
@@ -1791,7 +1790,7 @@ void EntityHorse::positionRider()
|
||||
float height = .15f * standAnimO;
|
||||
|
||||
rider.lock()->setPos(x + dist * sin, y + getRideHeight() + rider.lock()->getRidingHeight() + height, z - dist * cos);
|
||||
|
||||
|
||||
if ( rider.lock()->instanceof(eTYPE_LIVINGENTITY) )
|
||||
{
|
||||
shared_ptr<LivingEntity> livingRider = dynamic_pointer_cast<LivingEntity>(rider.lock());
|
||||
|
||||
@@ -131,7 +131,7 @@ shared_ptr<Entity> EntityIO::newEntity(const wstring& id, Level *level)
|
||||
{
|
||||
shared_ptr<Entity> entity;
|
||||
|
||||
AUTO_VAR(it, idCreateMap->find(id));
|
||||
auto it = idCreateMap->find(id);
|
||||
if(it != idCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it->second;
|
||||
@@ -169,7 +169,7 @@ shared_ptr<Entity> EntityIO::loadStatic(CompoundTag *tag, Level *level)
|
||||
tag->remove(L"Type");
|
||||
}
|
||||
|
||||
AUTO_VAR(it, idCreateMap->find(tag->getString(L"id")));
|
||||
auto it = idCreateMap->find(tag->getString(L"id"));
|
||||
if(it != idCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it->second;
|
||||
@@ -197,7 +197,7 @@ shared_ptr<Entity> EntityIO::newById(int id, Level *level)
|
||||
{
|
||||
shared_ptr<Entity> entity;
|
||||
|
||||
AUTO_VAR(it, numCreateMap->find(id));
|
||||
auto it = numCreateMap->find(id);
|
||||
if(it != numCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it->second;
|
||||
@@ -222,10 +222,10 @@ shared_ptr<Entity> EntityIO::newByEnumType(eINSTANCEOF eType, Level *level)
|
||||
{
|
||||
shared_ptr<Entity> entity;
|
||||
|
||||
unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classNumMap->find( eType );
|
||||
auto it = classNumMap->find( eType );
|
||||
if( it != classNumMap->end() )
|
||||
{
|
||||
AUTO_VAR(it2, numCreateMap->find(it->second));
|
||||
auto it2 = numCreateMap->find(it->second);
|
||||
if(it2 != numCreateMap->end() )
|
||||
{
|
||||
entityCreateFn create = it2->second;
|
||||
@@ -257,7 +257,7 @@ wstring EntityIO::getEncodeId(shared_ptr<Entity> entity)
|
||||
|
||||
int EntityIO::getId(const wstring &encodeId)
|
||||
{
|
||||
AUTO_VAR(it, idNumMap->find(encodeId));
|
||||
auto it = idNumMap->find(encodeId);
|
||||
if (it == idNumMap->end())
|
||||
{
|
||||
// defaults to pig...
|
||||
@@ -274,7 +274,7 @@ wstring EntityIO::getEncodeId(int entityIoValue)
|
||||
//return classIdMap.get(class1);
|
||||
//}
|
||||
|
||||
AUTO_VAR(it, numClassMap->find(entityIoValue));
|
||||
auto it = numClassMap->find(entityIoValue);
|
||||
if(it != numClassMap->end() )
|
||||
{
|
||||
unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator classIdIt = classIdMap->find( it->second );
|
||||
@@ -291,7 +291,7 @@ int EntityIO::getNameId(int entityIoValue)
|
||||
{
|
||||
int id = -1;
|
||||
|
||||
AUTO_VAR(it, idsSpawnableInCreative.find(entityIoValue));
|
||||
auto it = idsSpawnableInCreative.find(entityIoValue);
|
||||
if(it != idsSpawnableInCreative.end())
|
||||
{
|
||||
id = it->second->nameId;
|
||||
@@ -302,7 +302,7 @@ int EntityIO::getNameId(int entityIoValue)
|
||||
|
||||
eINSTANCEOF EntityIO::getType(const wstring &idString)
|
||||
{
|
||||
AUTO_VAR(it, numClassMap->find(getId(idString)));
|
||||
auto it = numClassMap->find(getId(idString));
|
||||
if(it != numClassMap->end() )
|
||||
{
|
||||
return it->second;
|
||||
@@ -312,7 +312,7 @@ eINSTANCEOF EntityIO::getType(const wstring &idString)
|
||||
|
||||
eINSTANCEOF EntityIO::getClass(int id)
|
||||
{
|
||||
AUTO_VAR(it, numClassMap->find(id));
|
||||
auto it = numClassMap->find(id);
|
||||
if(it != numClassMap->end() )
|
||||
{
|
||||
return it->second;
|
||||
|
||||
@@ -27,16 +27,12 @@ ExplodePacket::ExplodePacket(double x, double y, double z, float r, unordered_se
|
||||
this->r = r;
|
||||
m_bKnockbackOnly = knockBackOnly;
|
||||
|
||||
if(toBlow != NULL)
|
||||
if(toBlow != nullptr)
|
||||
{
|
||||
this->toBlow.assign(toBlow->begin(),toBlow->end());
|
||||
//for( AUTO_VAR(it, toBlow->begin()); it != toBlow->end(); it++ )
|
||||
//{
|
||||
// this->toBlow.push_back(*it);
|
||||
//}
|
||||
}
|
||||
|
||||
if (knockback != NULL)
|
||||
if (knockback != nullptr)
|
||||
{
|
||||
knockbackX = (float) knockback->x;
|
||||
knockbackY = (float) knockback->y;
|
||||
@@ -89,13 +85,8 @@ void ExplodePacket::write(DataOutputStream *dos) //throws IOException
|
||||
int yp = (int)y;
|
||||
int zp = (int)z;
|
||||
|
||||
//(Myset::const_iterator it = c1.begin();
|
||||
//it != c1.end(); ++it)
|
||||
|
||||
for( AUTO_VAR(it, toBlow.begin()); it != toBlow.end(); it++ )
|
||||
for ( const TilePos& tp : toBlow )
|
||||
{
|
||||
TilePos tp = *it;
|
||||
|
||||
int xx = tp.x-xp;
|
||||
int yy = tp.y-yp;
|
||||
int zz = tp.z-zp;
|
||||
|
||||
@@ -29,9 +29,9 @@ Explosion::Explosion(Level *level, shared_ptr<Entity> source, double x, double y
|
||||
Explosion::~Explosion()
|
||||
{
|
||||
delete random;
|
||||
for(AUTO_VAR(it, hitPlayers.begin()); it != hitPlayers.end(); ++it)
|
||||
for( auto& it : hitPlayers )
|
||||
{
|
||||
delete it->second;
|
||||
delete it.second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,17 +105,14 @@ void Explosion::explode()
|
||||
vector<shared_ptr<Entity> > entities(levelEntities->begin(), levelEntities->end() );
|
||||
Vec3 *center = Vec3::newTemp(x, y, z);
|
||||
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
for ( auto& e : entities )
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
|
||||
// 4J Stu - If the entity is not in a block that would be blown up, then they should not be damaged
|
||||
// Fix for #46606 - TU5: Content: Gameplay: The player can be damaged and killed by explosions behind obsidian walls
|
||||
bool canDamage = false;
|
||||
for(AUTO_VAR(it2, toBlow.begin()); it2 != toBlow.end(); ++it2)
|
||||
for ( auto& it2 : toBlow )
|
||||
{
|
||||
if(e->bb->intersects(it2->x,it2->y,it2->z,it2->x + 1,it2->y + 1,it2->z + 1))
|
||||
if(e->bb->intersects(it2.x,it2.y,it2.z,it2.x + 1,it2.y + 1,it2.z + 1))
|
||||
{
|
||||
canDamage = true;
|
||||
break;
|
||||
@@ -192,7 +189,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
|
||||
if( fraction == 0 ) fraction = 1;
|
||||
size_t j = toBlowArray->size() - 1;
|
||||
//for (size_t j = toBlowArray->size() - 1; j >= 0; j--)
|
||||
for(AUTO_VAR(it,toBlowArray->rbegin()); it != toBlowArray->rend(); ++it)
|
||||
for (auto it = toBlowArray->rbegin(); it != toBlowArray->rend(); ++it)
|
||||
{
|
||||
TilePos *tp = &(*it); //&toBlowArray->at(j);
|
||||
int xt = tp->x;
|
||||
@@ -249,8 +246,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
|
||||
|
||||
if (fire)
|
||||
{
|
||||
//for (size_t j = toBlowArray->size() - 1; j >= 0; j--)
|
||||
for(AUTO_VAR(it,toBlowArray->rbegin()); it != toBlowArray->rend(); ++it)
|
||||
for (auto it = toBlowArray->rbegin(); it != toBlowArray->rend(); ++it)
|
||||
{
|
||||
TilePos *tp = &(*it); //&toBlowArray->at(j);
|
||||
int xt = tp->x;
|
||||
@@ -276,7 +272,7 @@ Explosion::playerVec3Map *Explosion::getHitPlayers()
|
||||
|
||||
Vec3 *Explosion::getHitPlayerKnockback( shared_ptr<Player> player )
|
||||
{
|
||||
AUTO_VAR(it, hitPlayers.find(player));
|
||||
auto it = hitPlayers.find(player);
|
||||
|
||||
if(it == hitPlayers.end() ) return Vec3::newTemp(0.0,0.0,0.0);
|
||||
|
||||
|
||||
@@ -145,13 +145,15 @@ void FallingTile::tick()
|
||||
CompoundTag *swap = new CompoundTag();
|
||||
tileEntity->save(swap);
|
||||
vector<Tag *> *allTags = tileData->getAllTags();
|
||||
for(AUTO_VAR(it, allTags->begin()); it != allTags->end(); ++it)
|
||||
if ( allTags )
|
||||
{
|
||||
Tag *tag = *it;
|
||||
if (tag->getName().compare(L"x") == 0 || tag->getName().compare(L"y") == 0 || tag->getName().compare(L"z") == 0) continue;
|
||||
swap->put(tag->getName(), tag->copy());
|
||||
for ( Tag* tag : *allTags )
|
||||
{
|
||||
if (tag->getName().compare(L"x") == 0 || tag->getName().compare(L"y") == 0 || tag->getName().compare(L"z") == 0) continue;
|
||||
swap->put(tag->getName(), tag->copy());
|
||||
}
|
||||
delete allTags;
|
||||
}
|
||||
delete allTags;
|
||||
tileEntity->load(swap);
|
||||
tileEntity->setChanged();
|
||||
}
|
||||
@@ -181,12 +183,14 @@ void FallingTile::causeFallDamage(float distance)
|
||||
// 4J: Copy vector since it might be modified when we hurt the entities (invalidating our iterator)
|
||||
vector<shared_ptr<Entity> > *entities = new vector<shared_ptr<Entity> >(*level->getEntities(shared_from_this(), bb));
|
||||
DamageSource *source = tile == Tile::anvil_Id ? DamageSource::anvil : DamageSource::fallingBlock;
|
||||
//for (Entity entity : entities)
|
||||
for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
|
||||
if ( source )
|
||||
{
|
||||
(*it)->hurt(source, min(Mth::floor(dmg * fallDamageAmount), fallDamageMax));
|
||||
for (auto& it : *entities)
|
||||
{
|
||||
it->hurt(source, static_cast<float>(std::min<int>(Mth::floor(dmg * fallDamageAmount), fallDamageMax)));
|
||||
}
|
||||
delete entities;
|
||||
}
|
||||
delete entities;
|
||||
|
||||
if (tile == Tile::anvil_Id && random->nextFloat() < 0.05f + (dmg * 0.05))
|
||||
{
|
||||
|
||||
@@ -152,17 +152,16 @@ bool File::mkdirs() const
|
||||
std::vector<std::wstring> path = stringSplit( m_abstractPathName, pathSeparator );
|
||||
|
||||
std::wstring pathToHere = L"";
|
||||
AUTO_VAR(itEnd, path.end());
|
||||
for( AUTO_VAR(it, path.begin()); it != itEnd; it++ )
|
||||
for( auto& it : path )
|
||||
{
|
||||
// If this member of the vector is the root then just skip to the next
|
||||
if( pathRoot.compare( *it ) == 0 )
|
||||
if( pathRoot.compare(it) == 0 )
|
||||
{
|
||||
pathToHere = *it;
|
||||
pathToHere = it;
|
||||
continue;
|
||||
}
|
||||
|
||||
pathToHere = pathToHere + pathSeparator + *it;
|
||||
pathToHere = pathToHere + pathSeparator + it;
|
||||
|
||||
// if not exists
|
||||
#ifdef _UNICODE
|
||||
|
||||
@@ -53,7 +53,7 @@ void FileHeader::RemoveFile( FileEntry *file )
|
||||
|
||||
AdjustStartOffsets(file, file->getFileSize(), true);
|
||||
|
||||
AUTO_VAR(it, find(fileTable.begin(), fileTable.end(),file));
|
||||
auto it = find(fileTable.begin(), fileTable.end(), file);
|
||||
|
||||
if( it < fileTable.end() )
|
||||
{
|
||||
|
||||
@@ -200,11 +200,9 @@ void Fireball::tick()
|
||||
shared_ptr<Entity> hitEntity = nullptr;
|
||||
vector<shared_ptr<Entity> > *objects = level->getEntities(shared_from_this(), bb->expand(xd, yd, zd)->grow(1, 1, 1));
|
||||
double nearest = 0;
|
||||
AUTO_VAR(itEnd, objects->end());
|
||||
for (AUTO_VAR(it, objects->begin()); it != itEnd; it++)
|
||||
for ( auto& e : *objects )
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //objects->at(i);
|
||||
if (!e->isPickable() || (e->is(owner) )) continue; //4J Stu - Never collide with the owner (Enderdragon) // && flightTime < 25)) continue;
|
||||
if ( e == nullptr || !e->isPickable() || (e->is(owner) )) continue; //4J Stu - Never collide with the owner (Enderdragon) // && flightTime < 25)) continue;
|
||||
|
||||
float rr = 0.3f;
|
||||
AABB *bb = e->bb->grow(rr, rr, rr);
|
||||
|
||||
@@ -52,7 +52,7 @@ void FireworksItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, share
|
||||
}
|
||||
if (fireTag->contains(TAG_FLIGHT))
|
||||
{
|
||||
lines->push_back(wstring(app.GetString(IDS_ITEM_FIREWORKS_FLIGHT)) + L" " + _toString<int>((fireTag->getByte(TAG_FLIGHT))));
|
||||
lines->push_back(wstring(app.GetString(IDS_ITEM_FIREWORKS_FLIGHT)) + L" " + std::to_wstring((fireTag->getByte(TAG_FLIGHT))));
|
||||
}
|
||||
|
||||
ListTag<CompoundTag> *explosions = (ListTag<CompoundTag> *) fireTag->getList(TAG_EXPLOSIONS);
|
||||
|
||||
@@ -233,8 +233,7 @@ void FishingHook::tick()
|
||||
shared_ptr<Entity> hitEntity = nullptr;
|
||||
vector<shared_ptr<Entity> > *objects = level->getEntities(shared_from_this(), bb->expand(xd, yd, zd)->grow(1, 1, 1));
|
||||
double nearest = 0;
|
||||
AUTO_VAR(itEnd, objects->end());
|
||||
for (AUTO_VAR(it, objects->begin()); it != itEnd; it++)
|
||||
for (auto it = objects->begin(); it != objects->end(); it++)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; // objects->at(i);
|
||||
if (!e->isPickable() || (e == owner && flightTime < 5)) continue;
|
||||
|
||||
@@ -20,9 +20,9 @@ FlatGeneratorInfo::FlatGeneratorInfo()
|
||||
|
||||
FlatGeneratorInfo::~FlatGeneratorInfo()
|
||||
{
|
||||
for(AUTO_VAR(it, layers.begin()); it != layers.end(); ++it)
|
||||
for(auto& layer : layers)
|
||||
{
|
||||
delete *it;
|
||||
delete layer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,8 @@ void FlatGeneratorInfo::updateLayers()
|
||||
{
|
||||
int y = 0;
|
||||
|
||||
for(AUTO_VAR(it, layers.begin()); it != layers.end(); ++it)
|
||||
for(auto& layer : layers)
|
||||
{
|
||||
FlatLayerInfo *layer = *it;
|
||||
layer->setStart(y);
|
||||
y += layer->getHeight();
|
||||
}
|
||||
@@ -113,7 +112,7 @@ wstring FlatGeneratorInfo::toString()
|
||||
#endif
|
||||
}
|
||||
|
||||
FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int yOffset)
|
||||
FlatLayerInfo *FlatGeneratorInfo::getLayerFromString(const wstring &input, int yOffset)
|
||||
{
|
||||
return NULL;
|
||||
#if 0
|
||||
@@ -159,9 +158,9 @@ vector<FlatLayerInfo *> *FlatGeneratorInfo::getLayersFromString(const wstring &i
|
||||
|
||||
int yOffset = 0;
|
||||
|
||||
for(AUTO_VAR(it, depths.begin()); it != depths.end(); ++it)
|
||||
for(auto& depth : depths)
|
||||
{
|
||||
FlatLayerInfo *layer = getLayerFromString(*it, yOffset);
|
||||
FlatLayerInfo *layer = getLayerFromString(depth, yOffset);
|
||||
if (layer == NULL) return NULL;
|
||||
result->push_back(layer);
|
||||
yOffset += layer->getHeight();
|
||||
@@ -203,8 +202,8 @@ FlatGeneratorInfo *FlatGeneratorInfo::fromValue(const wstring &input)
|
||||
{
|
||||
std::vector<std::wstring> structures = stringSplit(parts[index++], L',');
|
||||
|
||||
for(AUTO_VAR(it, structures.begin()); it != structures.end(); ++it)
|
||||
{
|
||||
for (auto it = structures.begin(); it != structures.end(); ++it)
|
||||
{
|
||||
std::vector<std::wstring> separated = stringSplit(parts[index++], L"\\(");
|
||||
|
||||
unordered_map<wstring, wstring> structureOptions;
|
||||
|
||||
@@ -63,15 +63,15 @@ void FlatLayerInfo::setStart(int start)
|
||||
|
||||
wstring FlatLayerInfo::toString()
|
||||
{
|
||||
wstring result = _toString<int>(id);
|
||||
wstring result = std::to_wstring(id);
|
||||
|
||||
if (height > 1)
|
||||
{
|
||||
result = _toString<int>(height) + L"x" + result;
|
||||
result = std::to_wstring(height) + L"x" + result;
|
||||
}
|
||||
if (data > 0)
|
||||
{
|
||||
result += L":" + _toString<int>(data);
|
||||
result += L":" + std::to_wstring(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -22,9 +22,9 @@ bool FollowParentGoal::canUse()
|
||||
|
||||
shared_ptr<Animal> closest = nullptr;
|
||||
double closestDistSqr = Double::MAX_VALUE;
|
||||
for(AUTO_VAR(it, parents->begin()); it != parents->end(); ++it)
|
||||
for(auto& it : *parents)
|
||||
{
|
||||
shared_ptr<Animal> parent = dynamic_pointer_cast<Animal>(*it);
|
||||
shared_ptr<Animal> parent = dynamic_pointer_cast<Animal>(it);
|
||||
if (parent->getAge() < 0) continue;
|
||||
double distSqr = animal->distanceToSqr(parent);
|
||||
if (distSqr > closestDistSqr) continue;
|
||||
|
||||
@@ -44,12 +44,10 @@ void FurnaceMenu::addSlotListener(ContainerListener *listener)
|
||||
void FurnaceMenu::broadcastChanges()
|
||||
{
|
||||
AbstractContainerMenu::broadcastChanges();
|
||||
|
||||
AUTO_VAR(itEnd, containerListeners.end());
|
||||
for (AUTO_VAR(it, containerListeners.begin()); it != itEnd; it++)
|
||||
|
||||
for (auto& listener : containerListeners)
|
||||
{
|
||||
ContainerListener *listener = *it; //containerListeners->at(i);
|
||||
if (tc != furnace->tickCount)
|
||||
if (tc != furnace->tickCount)
|
||||
{
|
||||
listener->setContainerData(this, 0, furnace->tickCount);
|
||||
}
|
||||
@@ -57,7 +55,7 @@ void FurnaceMenu::broadcastChanges()
|
||||
{
|
||||
listener->setContainerData(this, 1, furnace->litTime);
|
||||
}
|
||||
if (ld != furnace->litDuration)
|
||||
if (ld != furnace->litDuration)
|
||||
{
|
||||
listener->setContainerData(this, 2, furnace->litDuration);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ void FurnaceRecipes::staticCtor()
|
||||
FurnaceRecipes::instance = new FurnaceRecipes();
|
||||
}
|
||||
|
||||
FurnaceRecipes *FurnaceRecipes::getInstance()
|
||||
FurnaceRecipes *FurnaceRecipes::getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
FurnaceRecipes::FurnaceRecipes()
|
||||
FurnaceRecipes::FurnaceRecipes()
|
||||
{
|
||||
addFurnaceRecipy(Tile::ironOre_Id, new ItemInstance(Item::ironIngot), .7f);
|
||||
addFurnaceRecipy(Tile::goldOre_Id, new ItemInstance(Item::goldIngot), 1);
|
||||
@@ -33,7 +33,7 @@ FurnaceRecipes::FurnaceRecipes()
|
||||
addFurnaceRecipy(Tile::emeraldOre_Id, new ItemInstance(Item::emerald), 1);
|
||||
addFurnaceRecipy(Item::potato_Id, new ItemInstance(Item::potatoBaked), .35f);
|
||||
addFurnaceRecipy(Tile::netherRack_Id, new ItemInstance(Item::netherbrick), .1f);
|
||||
|
||||
|
||||
// special silk touch related recipes:
|
||||
addFurnaceRecipy(Tile::coalOre_Id, new ItemInstance(Item::coal), .1f);
|
||||
addFurnaceRecipy(Tile::redStoneOre_Id, new ItemInstance(Item::redStone), .7f);
|
||||
@@ -43,38 +43,38 @@ FurnaceRecipes::FurnaceRecipes()
|
||||
|
||||
}
|
||||
|
||||
void FurnaceRecipes::addFurnaceRecipy(int itemId, ItemInstance *result, float value)
|
||||
void FurnaceRecipes::addFurnaceRecipy(int itemId, ItemInstance *result, float value)
|
||||
{
|
||||
//recipies->put(itemId, result);
|
||||
recipies[itemId]=result;
|
||||
recipeValue[result->id] = value;
|
||||
}
|
||||
|
||||
bool FurnaceRecipes::isFurnaceItem(int itemId)
|
||||
bool FurnaceRecipes::isFurnaceItem(int itemId)
|
||||
{
|
||||
AUTO_VAR(it, recipies.find(itemId));
|
||||
return it != recipies.end();
|
||||
auto it = recipies.find(itemId);
|
||||
return it != recipies.end();
|
||||
}
|
||||
|
||||
ItemInstance *FurnaceRecipes::getResult(int itemId)
|
||||
ItemInstance *FurnaceRecipes::getResult(int itemId)
|
||||
{
|
||||
AUTO_VAR(it, recipies.find(itemId));
|
||||
if(it != recipies.end())
|
||||
auto it = recipies.find(itemId);
|
||||
if(it != recipies.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unordered_map<int, ItemInstance *> *FurnaceRecipes::getRecipies()
|
||||
unordered_map<int, ItemInstance *> *FurnaceRecipes::getRecipies()
|
||||
{
|
||||
return &recipies;
|
||||
}
|
||||
|
||||
float FurnaceRecipes::getRecipeValue(int itemId)
|
||||
{
|
||||
AUTO_VAR(it, recipeValue.find(itemId));
|
||||
if (it != recipeValue.end())
|
||||
auto it = recipeValue.find(itemId);
|
||||
if (it != recipeValue.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
@@ -14,27 +14,6 @@ const int GameRules::RULE_DOTILEDROPS = 5;
|
||||
const int GameRules::RULE_NATURAL_REGENERATION = 7;
|
||||
const int GameRules::RULE_DAYLIGHT = 8;
|
||||
|
||||
GameRules::GameRules()
|
||||
{
|
||||
/*registerRule(RULE_DOFIRETICK, L"1");
|
||||
registerRule(RULE_MOBGRIEFING, L"1");
|
||||
registerRule(RULE_KEEPINVENTORY, L"0");
|
||||
registerRule(RULE_DOMOBSPAWNING, L"1");
|
||||
registerRule(RULE_DOMOBLOOT, L"1");
|
||||
registerRule(RULE_DOTILEDROPS, L"1");
|
||||
registerRule(RULE_COMMANDBLOCKOUTPUT, L"1");
|
||||
registerRule(RULE_NATURAL_REGENERATION, L"1");
|
||||
registerRule(RULE_DAYLIGHT, L"1");*/
|
||||
}
|
||||
|
||||
GameRules::~GameRules()
|
||||
{
|
||||
/*for(AUTO_VAR(it,rules.begin()); it != rules.end(); ++it)
|
||||
{
|
||||
delete it->second;
|
||||
}*/
|
||||
}
|
||||
|
||||
bool GameRules::getBoolean(const int rule)
|
||||
{
|
||||
switch(rule)
|
||||
@@ -60,134 +39,3 @@ bool GameRules::getBoolean(const int rule)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void GameRules::registerRule(const wstring &name, const wstring &startValue)
|
||||
{
|
||||
rules[name] = new GameRule(startValue);
|
||||
}
|
||||
|
||||
void GameRules::set(const wstring &ruleName, const wstring &newValue)
|
||||
{
|
||||
AUTO_VAR(it, rules.find(ruleName));
|
||||
if(it != rules.end() )
|
||||
{
|
||||
GameRule *gameRule = it->second;
|
||||
gameRule->set(newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
registerRule(ruleName, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
wstring GameRules::get(const wstring &ruleName)
|
||||
{
|
||||
AUTO_VAR(it, rules.find(ruleName));
|
||||
if(it != rules.end() )
|
||||
{
|
||||
GameRule *gameRule = it->second;
|
||||
return gameRule->get();
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
int GameRules::getInt(const wstring &ruleName)
|
||||
{
|
||||
AUTO_VAR(it, rules.find(ruleName));
|
||||
if(it != rules.end() )
|
||||
{
|
||||
GameRule *gameRule = it->second;
|
||||
return gameRule->getInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double GameRules::getDouble(const wstring &ruleName)
|
||||
{
|
||||
AUTO_VAR(it, rules.find(ruleName));
|
||||
if(it != rules.end() )
|
||||
{
|
||||
GameRule *gameRule = it->second;
|
||||
return gameRule->getDouble();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CompoundTag *GameRules::createTag()
|
||||
{
|
||||
CompoundTag *result = new CompoundTag(L"GameRules");
|
||||
|
||||
for(AUTO_VAR(it,rules.begin()); it != rules.end(); ++it)
|
||||
{
|
||||
GameRule *gameRule = it->second;
|
||||
result->putString(it->first, gameRule->get());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void GameRules::loadFromTag(CompoundTag *tag)
|
||||
{
|
||||
vector<Tag *> *allTags = tag->getAllTags();
|
||||
for (AUTO_VAR(it, allTags->begin()); it != allTags->end(); ++it)
|
||||
{
|
||||
Tag *ruleTag = *it;
|
||||
wstring ruleName = ruleTag->getName();
|
||||
wstring value = tag->getString(ruleTag->getName());
|
||||
|
||||
set(ruleName, value);
|
||||
}
|
||||
delete allTags;
|
||||
}
|
||||
|
||||
// Need to delete returned vector.
|
||||
vector<wstring> *GameRules::getRuleNames()
|
||||
{
|
||||
vector<wstring> *out = new vector<wstring>();
|
||||
for (AUTO_VAR(it, rules.begin()); it != rules.end(); it++) out->push_back(it->first);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool GameRules::contains(const wstring &rule)
|
||||
{
|
||||
AUTO_VAR(it, rules.find(rule));
|
||||
return it != rules.end();
|
||||
}
|
||||
|
||||
GameRules::GameRule::GameRule(const wstring &startValue)
|
||||
{
|
||||
value = L"";
|
||||
booleanValue = false;
|
||||
intValue = 0;
|
||||
doubleValue = 0.0;
|
||||
set(startValue);
|
||||
}
|
||||
|
||||
void GameRules::GameRule::set(const wstring &newValue)
|
||||
{
|
||||
value = newValue;
|
||||
booleanValue = _fromString<bool>(newValue);
|
||||
intValue = _fromString<int>(newValue);
|
||||
doubleValue = _fromString<double>(newValue);
|
||||
}
|
||||
|
||||
wstring GameRules::GameRule::get()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool GameRules::GameRule::getBoolean()
|
||||
{
|
||||
return booleanValue;
|
||||
}
|
||||
|
||||
int GameRules::GameRule::getInt()
|
||||
{
|
||||
return intValue;
|
||||
}
|
||||
|
||||
double GameRules::GameRule::getDouble()
|
||||
{
|
||||
return doubleValue;
|
||||
}*/
|
||||
@@ -34,23 +34,9 @@ public:
|
||||
static const int RULE_NATURAL_REGENERATION;
|
||||
static const int RULE_DAYLIGHT;
|
||||
|
||||
private:
|
||||
unordered_map<wstring, GameRule *> rules;
|
||||
|
||||
public:
|
||||
GameRules();
|
||||
~GameRules();
|
||||
GameRules() = default;
|
||||
~GameRules() = default;
|
||||
|
||||
bool getBoolean(const int rule);
|
||||
|
||||
// 4J: Removed unused functions
|
||||
/*void set(const wstring &ruleName, const wstring &newValue);
|
||||
void registerRule(const wstring &name, const wstring &startValue);
|
||||
wstring get(const wstring &ruleName);
|
||||
int getInt(const wstring &ruleName);
|
||||
double getDouble(const wstring &ruleName);
|
||||
CompoundTag *createTag();
|
||||
void loadFromTag(CompoundTag *tag);
|
||||
vector<wstring> *getRuleNames();
|
||||
bool contains(const wstring &rule);*/
|
||||
};
|
||||
@@ -18,10 +18,10 @@ GoalSelector::GoalSelector()
|
||||
|
||||
GoalSelector::~GoalSelector()
|
||||
{
|
||||
for(AUTO_VAR(it, goals.begin()); it != goals.end(); ++it)
|
||||
for(auto& goal : goals)
|
||||
{
|
||||
if((*it)->canDeletePointer) delete (*it)->goal;
|
||||
delete (*it);
|
||||
if(goal->canDeletePointer) delete goal->goal;
|
||||
delete goal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,15 +32,15 @@ void GoalSelector::addGoal(int prio, Goal *goal, bool canDeletePointer /*= true*
|
||||
|
||||
void GoalSelector::removeGoal(Goal *toRemove)
|
||||
{
|
||||
for(AUTO_VAR(it, goals.begin()); it != goals.end(); )
|
||||
{
|
||||
for (auto it = goals.begin(); it != goals.end();)
|
||||
{
|
||||
InternalGoal *ig = *it;
|
||||
Goal *goal = ig->goal;
|
||||
|
||||
if (goal == toRemove)
|
||||
{
|
||||
AUTO_VAR(it2, find(usingGoals.begin(), usingGoals.end(), ig) );
|
||||
if (it2 != usingGoals.end())
|
||||
auto it2 = find(usingGoals.begin(), usingGoals.end(), ig);
|
||||
if (it2 != usingGoals.end())
|
||||
{
|
||||
goal->stop();
|
||||
usingGoals.erase(it2);
|
||||
@@ -63,14 +63,11 @@ void GoalSelector::tick()
|
||||
|
||||
if(tickCount++ % newGoalRate == 0)
|
||||
{
|
||||
//for (InternalGoal ig : goals)
|
||||
for(AUTO_VAR(it, goals.begin()); it != goals.end(); ++it)
|
||||
for(auto& ig : goals)
|
||||
{
|
||||
InternalGoal *ig = *it;
|
||||
//bool isUsing = usingGoals.contains(ig);
|
||||
AUTO_VAR(usingIt, find(usingGoals.begin(), usingGoals.end(), ig));
|
||||
auto usingIt = find(usingGoals.begin(), usingGoals.end(), ig);
|
||||
|
||||
//if (isUsing)
|
||||
//if (isUsing)
|
||||
if(usingIt != usingGoals.end())
|
||||
{
|
||||
if (!canUseInSystem(ig) || !canContinueToUse(ig))
|
||||
@@ -90,8 +87,8 @@ void GoalSelector::tick()
|
||||
}
|
||||
else
|
||||
{
|
||||
for(AUTO_VAR(it, usingGoals.begin() ); it != usingGoals.end(); )
|
||||
{
|
||||
for (auto it = usingGoals.begin(); it != usingGoals.end();)
|
||||
{
|
||||
InternalGoal *ig = *it;
|
||||
if (!ig->goal->canContinueToUse())
|
||||
{
|
||||
@@ -106,21 +103,14 @@ void GoalSelector::tick()
|
||||
}
|
||||
|
||||
|
||||
//bool debug = false;
|
||||
//if (debug && toStart.size() > 0) System.out.println("Starting: ");
|
||||
//for (InternalGoal ig : toStart)
|
||||
for(AUTO_VAR(it, toStart.begin()); it != toStart.end(); ++it)
|
||||
for(auto & ig : toStart)
|
||||
{
|
||||
//if (debug) System.out.println(ig.goal.toString() + ", ");
|
||||
(*it)->goal->start();
|
||||
ig->goal->start();
|
||||
}
|
||||
|
||||
//if (debug && usingGoals.size() > 0) System.out.println("Running: ");
|
||||
//for (InternalGoal ig : usingGoals)
|
||||
for(AUTO_VAR(it, usingGoals.begin()); it != usingGoals.end(); ++it)
|
||||
for(auto& ig : usingGoals)
|
||||
{
|
||||
//if (debug) System.out.println(ig.goal.toString());
|
||||
(*it)->goal->tick();
|
||||
ig->goal->tick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,14 +127,13 @@ bool GoalSelector::canContinueToUse(InternalGoal *ig)
|
||||
bool GoalSelector::canUseInSystem(GoalSelector::InternalGoal *goal)
|
||||
{
|
||||
//for (InternalGoal ig : goals)
|
||||
for(AUTO_VAR(it, goals.begin()); it != goals.end(); ++it)
|
||||
for(auto& ig : goals)
|
||||
{
|
||||
InternalGoal *ig = *it;
|
||||
if (ig == goal) continue;
|
||||
|
||||
AUTO_VAR(usingIt, find(usingGoals.begin(), usingGoals.end(), ig));
|
||||
auto usingIt = find(usingGoals.begin(), usingGoals.end(), ig);
|
||||
|
||||
if (goal->prio >= ig->prio)
|
||||
if (goal->prio >= ig->prio)
|
||||
{
|
||||
if (usingIt != usingGoals.end() && !canCoExist(goal, ig)) return false;
|
||||
}
|
||||
@@ -166,9 +155,8 @@ void GoalSelector::setNewGoalRate(int newGoalRate)
|
||||
|
||||
void GoalSelector::setLevel(Level *level)
|
||||
{
|
||||
for(AUTO_VAR(it, goals.begin()); it != goals.end(); ++it)
|
||||
for(auto& ig : goals)
|
||||
{
|
||||
InternalGoal *ig = *it;
|
||||
ig->goal->setLevel(level);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
void HangingEntity::_init(Level *level)
|
||||
{
|
||||
{
|
||||
checkInterval = 0;
|
||||
dir = 0;
|
||||
xTile = yTile = zTile = 0;
|
||||
@@ -32,7 +32,7 @@ HangingEntity::HangingEntity(Level *level, int xTile, int yTile, int zTile, int
|
||||
this->zTile = zTile;
|
||||
}
|
||||
|
||||
void HangingEntity::setDir(int dir)
|
||||
void HangingEntity::setDir(int dir)
|
||||
{
|
||||
this->dir = dir;
|
||||
yRotO = yRot = (float)(dir * 90);
|
||||
@@ -41,12 +41,12 @@ void HangingEntity::setDir(int dir)
|
||||
float h = (float)getHeight();
|
||||
float d = (float)getWidth();
|
||||
|
||||
if (dir == Direction::NORTH || dir == Direction::SOUTH)
|
||||
if (dir == Direction::NORTH || dir == Direction::SOUTH)
|
||||
{
|
||||
d = 0.5f;
|
||||
yRot = yRotO = (float)(Direction::DIRECTION_OPPOSITE[dir] * 90);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
w = 0.5f;
|
||||
}
|
||||
@@ -86,14 +86,14 @@ void HangingEntity::setDir(int dir)
|
||||
bb->set(min(x0,x1), min(y0,y1), min(z0,z1), max(x0,x1), max(y0,y1), max(z0,z1));
|
||||
}
|
||||
|
||||
float HangingEntity::offs(int w)
|
||||
float HangingEntity::offs(int w)
|
||||
{
|
||||
if (w == 32) return 0.5f;
|
||||
if (w == 64) return 0.5f;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void HangingEntity::tick()
|
||||
void HangingEntity::tick()
|
||||
{
|
||||
xo = x;
|
||||
yo = y;
|
||||
@@ -101,7 +101,7 @@ void HangingEntity::tick()
|
||||
if (checkInterval++ == 20 * 5 && !level->isClientSide)
|
||||
{
|
||||
checkInterval = 0;
|
||||
if (!removed && !survives())
|
||||
if (!removed && !survives())
|
||||
{
|
||||
remove();
|
||||
dropItem(nullptr);
|
||||
@@ -109,13 +109,13 @@ void HangingEntity::tick()
|
||||
}
|
||||
}
|
||||
|
||||
bool HangingEntity::survives()
|
||||
bool HangingEntity::survives()
|
||||
{
|
||||
if (level->getCubes(shared_from_this(), bb)->size()!=0)//isEmpty())
|
||||
if (level->getCubes(shared_from_this(), bb)->size()!=0)//isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
int ws = max(1, getWidth() / 16);
|
||||
int hs = max(1, getHeight() / 16);
|
||||
@@ -131,18 +131,18 @@ bool HangingEntity::survives()
|
||||
|
||||
for (int ss = 0; ss < ws; ss++)
|
||||
{
|
||||
for (int yy = 0; yy < hs; yy++)
|
||||
for (int yy = 0; yy < hs; yy++)
|
||||
{
|
||||
Material *m;
|
||||
if (dir == Direction::NORTH || dir == Direction::SOUTH)
|
||||
if (dir == Direction::NORTH || dir == Direction::SOUTH)
|
||||
{
|
||||
m = level->getMaterial(xt + ss, yt + yy, zTile);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
m = level->getMaterial(xTile, yt + yy, zt + ss);
|
||||
}
|
||||
if (!m->isSolid())
|
||||
if (!m->isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -152,11 +152,9 @@ bool HangingEntity::survives()
|
||||
|
||||
if (entities != NULL && entities->size() > 0)
|
||||
{
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
for (auto& e : *entities)
|
||||
{
|
||||
shared_ptr<Entity> e = (*it);
|
||||
if( e->instanceof(eTYPE_HANGING_ENTITY) )
|
||||
if( e && e->instanceof(eTYPE_HANGING_ENTITY) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -167,12 +165,12 @@ bool HangingEntity::survives()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HangingEntity::isPickable()
|
||||
bool HangingEntity::isPickable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HangingEntity::skipAttackInteraction(shared_ptr<Entity> source)
|
||||
bool HangingEntity::skipAttackInteraction(shared_ptr<Entity> source)
|
||||
{
|
||||
if(source->GetType()==eTYPE_PLAYER)
|
||||
{
|
||||
@@ -181,10 +179,10 @@ bool HangingEntity::skipAttackInteraction(shared_ptr<Entity> source)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HangingEntity::hurt(DamageSource *source, float damage)
|
||||
bool HangingEntity::hurt(DamageSource *source, float damage)
|
||||
{
|
||||
if (isInvulnerable()) return false;
|
||||
if (!removed && !level->isClientSide)
|
||||
if (!removed && !level->isClientSide)
|
||||
{
|
||||
if (dynamic_cast<EntityDamageSource *>(source) != NULL)
|
||||
{
|
||||
@@ -206,7 +204,7 @@ bool HangingEntity::hurt(DamageSource *source, float damage)
|
||||
player = dynamic_pointer_cast<Player>( e );
|
||||
}
|
||||
|
||||
if (player != NULL && player->abilities.instabuild)
|
||||
if (player != NULL && player->abilities.instabuild)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -217,25 +215,25 @@ bool HangingEntity::hurt(DamageSource *source, float damage)
|
||||
}
|
||||
|
||||
// 4J - added noEntityCubes parameter
|
||||
void HangingEntity::move(double xa, double ya, double za, bool noEntityCubes)
|
||||
void HangingEntity::move(double xa, double ya, double za, bool noEntityCubes)
|
||||
{
|
||||
if (!level->isClientSide && !removed && (xa * xa + ya * ya + za * za) > 0)
|
||||
if (!level->isClientSide && !removed && (xa * xa + ya * ya + za * za) > 0)
|
||||
{
|
||||
remove();
|
||||
dropItem(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void HangingEntity::push(double xa, double ya, double za)
|
||||
void HangingEntity::push(double xa, double ya, double za)
|
||||
{
|
||||
if (!level->isClientSide && !removed && (xa * xa + ya * ya + za * za) > 0)
|
||||
if (!level->isClientSide && !removed && (xa * xa + ya * ya + za * za) > 0)
|
||||
{
|
||||
remove();
|
||||
dropItem(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void HangingEntity::addAdditonalSaveData(CompoundTag *tag)
|
||||
void HangingEntity::addAdditonalSaveData(CompoundTag *tag)
|
||||
{
|
||||
tag->putByte(L"Direction", (byte) dir);
|
||||
tag->putInt(L"TileX", xTile);
|
||||
@@ -243,7 +241,7 @@ void HangingEntity::addAdditonalSaveData(CompoundTag *tag)
|
||||
tag->putInt(L"TileZ", zTile);
|
||||
|
||||
// Back compat
|
||||
switch (dir)
|
||||
switch (dir)
|
||||
{
|
||||
case Direction::NORTH:
|
||||
tag->putByte(L"Dir", (byte) 0);
|
||||
@@ -260,15 +258,15 @@ void HangingEntity::addAdditonalSaveData(CompoundTag *tag)
|
||||
}
|
||||
}
|
||||
|
||||
void HangingEntity::readAdditionalSaveData(CompoundTag *tag)
|
||||
void HangingEntity::readAdditionalSaveData(CompoundTag *tag)
|
||||
{
|
||||
if (tag->contains(L"Direction"))
|
||||
if (tag->contains(L"Direction"))
|
||||
{
|
||||
dir = tag->getByte(L"Direction");
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (tag->getByte(L"Dir"))
|
||||
switch (tag->getByte(L"Dir"))
|
||||
{
|
||||
case 0:
|
||||
dir = Direction::NORTH;
|
||||
|
||||
@@ -19,7 +19,7 @@ wstring Hasher::getHash(wstring &name)
|
||||
//return new BigInteger(1, m.digest()).toString(16);
|
||||
|
||||
// TODO 4J Stu - Will this hash us with the same distribution as the MD5?
|
||||
return _toString(std::hash<wstring>{}( s ) );
|
||||
return std::to_wstring(std::hash<wstring>{}( s ) );
|
||||
//}
|
||||
//catch (NoSuchAlgorithmException e)
|
||||
//{
|
||||
|
||||
@@ -10,9 +10,8 @@ int HealthCriteria::getScoreModifier(vector<shared_ptr<Player> > *players)
|
||||
{
|
||||
float health = 0;
|
||||
|
||||
for (AUTO_VAR(it,players->begin()); it != players->end(); ++it)
|
||||
for (auto& player : *players)
|
||||
{
|
||||
shared_ptr<Player> player = *it;
|
||||
health += player->getHealth() + player->getAbsorptionAmount();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@ void HurtByTargetGoal::start()
|
||||
{
|
||||
double within = getFollowDistance();
|
||||
vector<shared_ptr<Entity> > *nearby = mob->level->getEntitiesOfClass(typeid(*mob), AABB::newTemp(mob->x, mob->y, mob->z, mob->x + 1, mob->y + 1, mob->z + 1)->grow(within, 4, within));
|
||||
for(AUTO_VAR(it, nearby->begin()); it != nearby->end(); ++it)
|
||||
for(auto& it : *nearby)
|
||||
{
|
||||
shared_ptr<PathfinderMob> other = dynamic_pointer_cast<PathfinderMob>(*it);
|
||||
shared_ptr<PathfinderMob> other = dynamic_pointer_cast<PathfinderMob>(it);
|
||||
if (this->mob->shared_from_this() == other) continue;
|
||||
if (other->getTarget() != NULL) continue;
|
||||
if (other->isAlliedTo(mob->getLastHurtByMob())) continue; // don't target allies
|
||||
|
||||
@@ -72,7 +72,7 @@ void ItemEntity::defineSynchedData()
|
||||
void ItemEntity::tick()
|
||||
{
|
||||
Entity::tick();
|
||||
|
||||
|
||||
if (throwTime > 0) throwTime--;
|
||||
xo = x;
|
||||
yo = y;
|
||||
@@ -80,7 +80,7 @@ void ItemEntity::tick()
|
||||
|
||||
yd -= 0.04f;
|
||||
noPhysics = checkInTile(x, (bb->y0 + bb->y1) / 2, z);
|
||||
|
||||
|
||||
// 4J - added parameter here so that these don't care about colliding with other entities
|
||||
move(xd, yd, zd, true);
|
||||
|
||||
@@ -133,11 +133,11 @@ void ItemEntity::tick()
|
||||
}
|
||||
|
||||
void ItemEntity::mergeWithNeighbours()
|
||||
{
|
||||
{
|
||||
vector<shared_ptr<Entity> > *neighbours = level->getEntitiesOfClass(typeid(*this), bb->grow(0.5, 0, 0.5));
|
||||
for(AUTO_VAR(it, neighbours->begin()); it != neighbours->end(); ++it)
|
||||
for(auto& neighbour : *neighbours)
|
||||
{
|
||||
shared_ptr<ItemEntity> entity = dynamic_pointer_cast<ItemEntity>(*it);
|
||||
shared_ptr<ItemEntity> entity = dynamic_pointer_cast<ItemEntity>(neighbour);
|
||||
merge(entity);
|
||||
}
|
||||
delete neighbours;
|
||||
@@ -189,7 +189,7 @@ bool ItemEntity::hurt(DamageSource *source, float damage)
|
||||
// 4J - added next line: found whilst debugging an issue with item entities getting into a bad state when being created by a cactus, since entities insides cactuses get hurt
|
||||
// and therefore depending on the timing of things they could get removed from the client when they weren't supposed to be. Are there really any cases were we would want
|
||||
// an itemEntity to be locally hurt?
|
||||
if (level->isClientSide ) return false;
|
||||
if (level->isClientSide ) return false;
|
||||
|
||||
if (isInvulnerable()) return false;
|
||||
if (getItem() != NULL && getItem()->id == Item::netherStar_Id && source->isExplosion()) return false;
|
||||
@@ -253,7 +253,7 @@ void ItemEntity::playerTouch(shared_ptr<Player> player)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (item->id == Item::blazeRod_Id)
|
||||
if (item->id == Item::blazeRod_Id)
|
||||
player->awardStat(GenericStats::blazeRod(), GenericStats::param_blazeRod());
|
||||
|
||||
playSound(eSoundType_RANDOM_POP, 0.2f, ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f);
|
||||
|
||||
@@ -588,7 +588,7 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
|
||||
|
||||
/*if (!hasCustomHoverName() && id == Item::map_Id)
|
||||
{
|
||||
title.text += L" #" + _toString(auxValue);
|
||||
title.text += L" #" + std::to_wstring(auxValue);
|
||||
}*/
|
||||
|
||||
lines->push_back(title);
|
||||
@@ -652,20 +652,20 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
|
||||
if (!modifiers->empty())
|
||||
{
|
||||
// New line
|
||||
lines->push_back(HtmlString(L""));
|
||||
lines->emplace_back(L"");
|
||||
|
||||
// Modifier descriptions
|
||||
for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
for (auto& modifier : *modifiers)
|
||||
{
|
||||
// 4J: Moved modifier string building to AttributeModifier
|
||||
lines->push_back(it->second->getHoverText(it->first));
|
||||
lines->push_back(modifier.second->getHoverText(modifier.first));
|
||||
}
|
||||
}
|
||||
|
||||
// Delete modifiers map
|
||||
for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
for (auto& it : *modifiers)
|
||||
{
|
||||
AttributeModifier *modifier = it->second;
|
||||
AttributeModifier *modifier = it.second;
|
||||
delete modifier;
|
||||
}
|
||||
delete modifiers;
|
||||
@@ -674,7 +674,7 @@ vector<HtmlString> *ItemInstance::getHoverText(shared_ptr<Player> player, bool a
|
||||
{
|
||||
if (isDamaged())
|
||||
{
|
||||
wstring damageStr = L"Durability: LOCALISE " + _toString<int>((getMaxDamage()) - getDamageValue()) + L" / " + _toString<int>(getMaxDamage());
|
||||
wstring damageStr = L"Durability: LOCALISE " + std::to_wstring((getMaxDamage()) - getDamageValue()) + L" / " + std::to_wstring(getMaxDamage());
|
||||
lines->push_back(HtmlString(damageStr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +79,9 @@ bool LeashFenceKnotEntity::interact(shared_ptr<Player> player)
|
||||
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
|
||||
if (mobs != NULL)
|
||||
{
|
||||
for(AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it)
|
||||
for(auto& it : *mobs)
|
||||
{
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>( *it );
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>( it );
|
||||
if (mob->isLeashed() && mob->getLeashHolder() == player)
|
||||
{
|
||||
mob->setLeashedTo(shared_from_this(), true);
|
||||
@@ -103,9 +103,9 @@ bool LeashFenceKnotEntity::interact(shared_ptr<Player> player)
|
||||
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
|
||||
if (mobs != NULL)
|
||||
{
|
||||
for(AUTO_VAR(it, mobs->begin()); it != mobs->end(); ++it)
|
||||
for(auto& it : *mobs)
|
||||
{
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>( *it );
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>( it );
|
||||
if (mob->isLeashed() && mob->getLeashHolder() == shared_from_this())
|
||||
{
|
||||
mob->dropLeash(true, false);
|
||||
@@ -142,9 +142,9 @@ shared_ptr<LeashFenceKnotEntity> LeashFenceKnotEntity::findKnotAt(Level *level,
|
||||
vector<shared_ptr<Entity> > *knots = level->getEntitiesOfClass(typeid(LeashFenceKnotEntity), AABB::newTemp(x - 1.0, y - 1.0, z - 1.0, x + 1.0, y + 1.0, z + 1.0));
|
||||
if (knots != NULL)
|
||||
{
|
||||
for(AUTO_VAR(it, knots->begin()); it != knots->end(); ++it)
|
||||
{
|
||||
shared_ptr<LeashFenceKnotEntity> knot = dynamic_pointer_cast<LeashFenceKnotEntity>( *it );
|
||||
for (auto& it : *knots )
|
||||
{
|
||||
shared_ptr<LeashFenceKnotEntity> knot = dynamic_pointer_cast<LeashFenceKnotEntity>( it );
|
||||
if (knot->xTile == x && knot->yTile == y && knot->zTile == z)
|
||||
{
|
||||
delete knots;
|
||||
|
||||
@@ -38,9 +38,9 @@ bool LeashItem::bindPlayerMobs(shared_ptr<Player> player, Level *level, int x, i
|
||||
vector<shared_ptr<Entity> > *mobs = level->getEntitiesOfClass(typeid(Mob), AABB::newTemp(x - range, y - range, z - range, x + range, y + range, z + range));
|
||||
if (mobs != NULL)
|
||||
{
|
||||
for(AUTO_VAR(it,mobs->begin()); it != mobs->end(); ++it)
|
||||
for(auto& it : *mobs)
|
||||
{
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(*it);
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(it);
|
||||
if (mob->isLeashed() && mob->getLeashHolder() == player)
|
||||
{
|
||||
if (activeKnot == NULL)
|
||||
@@ -64,9 +64,9 @@ bool LeashItem::bindPlayerMobsTest(shared_ptr<Player> player, Level *level, int
|
||||
|
||||
if (mobs != NULL)
|
||||
{
|
||||
for(AUTO_VAR(it,mobs->begin()); it != mobs->end(); ++it)
|
||||
for(auto& it : *mobs)
|
||||
{
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(*it);
|
||||
shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>(it);
|
||||
if (mob->isLeashed() && mob->getLeashHolder() == player) return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ void Level::_init(shared_ptr<LevelStorage>levelStorage, const wstring& levelName
|
||||
//{
|
||||
// dimension = Dimension::getNew(levelData->getDimension());
|
||||
//}
|
||||
else
|
||||
else
|
||||
{
|
||||
dimension = Dimension::getNew(0);
|
||||
}
|
||||
@@ -740,7 +740,7 @@ Level::~Level()
|
||||
DeleteCriticalSection(&m_checkLightCS);
|
||||
|
||||
// 4J-PB - savedDataStorage is shared between overworld and nether levels in the server, so it will already have been deleted on the first level delete
|
||||
if(savedDataStorage!=NULL) delete savedDataStorage;
|
||||
if(savedDataStorage!=NULL) delete savedDataStorage;
|
||||
|
||||
DeleteCriticalSection(&m_entitiesCS);
|
||||
DeleteCriticalSection(&m_tileEntityListCS);
|
||||
@@ -934,7 +934,7 @@ bool Level::setTileAndData(int x, int y, int z, int tile, int data, int updateFl
|
||||
int olddata = c->getData( x & 15, y, z & 15);
|
||||
#endif
|
||||
result = c->setTileAndData(x & 15, y, z & 15, tile, data);
|
||||
if( updateFlags != Tile::UPDATE_INVISIBLE_NO_LIGHT)
|
||||
if( updateFlags != Tile::UPDATE_INVISIBLE_NO_LIGHT)
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
PIXBeginNamedEvent(0,"Checking light %d %d %d",x,y,z);
|
||||
@@ -1019,7 +1019,7 @@ bool Level::setData(int x, int y, int z, int data, int updateFlags, bool forceUp
|
||||
|
||||
/**
|
||||
* Sets a tile to air without dropping resources or showing any animation.
|
||||
*
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
@@ -1033,7 +1033,7 @@ bool Level::removeTile(int x, int y, int z)
|
||||
/**
|
||||
* Sets a tile to air and plays a destruction animation, with option to also
|
||||
* drop resources.
|
||||
*
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
@@ -1063,10 +1063,9 @@ bool Level::setTileAndUpdate(int x, int y, int z, int tile)
|
||||
|
||||
void Level::sendTileUpdated(int x, int y, int z)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->tileChanged(x, y, z);
|
||||
listener->tileChanged(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1105,20 +1104,18 @@ void Level::lightColumnChanged(int x, int z, int y0, int y1)
|
||||
|
||||
void Level::setTileDirty(int x, int y, int z)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->setTilesDirty(x, y, z, x, y, z, this);
|
||||
listener->setTilesDirty(x, y, z, x, y, z, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Level::setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->setTilesDirty(x0, y0, z0, x1, y1, z1, this);
|
||||
listener->setTilesDirty(x0, y0, z0, x1, y1, z1, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1351,7 +1348,7 @@ int Level::getBrightness(LightLayer::variety layer, int x, int y, int z)
|
||||
// the level chunk once
|
||||
void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety layer, int x, int y, int z)
|
||||
{
|
||||
if( ( ( ( x & 15 ) == 0 ) || ( ( x & 15 ) == 15 ) ) ||
|
||||
if( ( ( ( x & 15 ) == 0 ) || ( ( x & 15 ) == 15 ) ) ||
|
||||
( ( ( z & 15 ) == 0 ) || ( ( z & 15 ) == 15 ) ) ||
|
||||
( ( y <= 0 ) || ( y >= 127 ) ) )
|
||||
{
|
||||
@@ -1443,20 +1440,18 @@ void Level::setBrightness(LightLayer::variety layer, int x, int y, int z, int br
|
||||
}
|
||||
else
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->tileLightChanged(x, y, z);
|
||||
listener->tileLightChanged(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Level::setTileBrightnessChanged(int x, int y, int z)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->tileLightChanged(x, y, z);
|
||||
listener->tileLightChanged(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1637,19 +1632,18 @@ HitResult *Level::clip(Vec3 *a, Vec3 *b, bool liquid, bool solidOnly)
|
||||
void Level::playEntitySound(shared_ptr<Entity> entity, int iSound, float volume, float pitch)
|
||||
{
|
||||
if(entity == NULL) return;
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
// 4J-PB - if the entity is a local player, don't play the sound
|
||||
if(entity->GetType() == eTYPE_SERVERPLAYER)
|
||||
{
|
||||
//app.DebugPrintf("ENTITY is serverplayer\n");
|
||||
|
||||
(*it)->playSound(iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch);
|
||||
listener->playSound(iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it)->playSound(iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch);
|
||||
listener->playSound(iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1657,20 +1651,18 @@ void Level::playEntitySound(shared_ptr<Entity> entity, int iSound, float volume,
|
||||
void Level::playPlayerSound(shared_ptr<Player> entity, int iSound, float volume, float pitch)
|
||||
{
|
||||
if (entity == NULL) return;
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->playSoundExceptPlayer(entity, iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch);
|
||||
listener->playSoundExceptPlayer(entity, iSound, entity->x, entity->y - entity->heightOffset, entity->z, volume, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
//void Level::playSound(double x, double y, double z, const wstring& name, float volume, float pitch)
|
||||
void Level::playSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->playSound(iSound, x, y, z, volume, pitch, fClipSoundDist);
|
||||
listener->playSound(iSound, x, y, z, volume, pitch, fClipSoundDist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1680,10 +1672,9 @@ void Level::playLocalSound(double x, double y, double z, int iSound, float volum
|
||||
|
||||
void Level::playStreamingMusic(const wstring& name, int x, int y, int z)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->playStreamingMusic(name, x, y, z);
|
||||
listener->playStreamingMusic(name, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1692,22 +1683,11 @@ void Level::playMusic(double x, double y, double z, const wstring& string, float
|
||||
{
|
||||
}
|
||||
|
||||
// 4J removed -
|
||||
/*
|
||||
void Level::addParticle(const wstring& id, double x, double y, double z, double xd, double yd, double zd)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
(*it)->addParticle(id, x, y, z, xd, yd, zd);
|
||||
}
|
||||
*/
|
||||
|
||||
// 4J-PB added
|
||||
void Level::addParticle(ePARTICLE_TYPE id, double x, double y, double z, double xd, double yd, double zd)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
(*it)->addParticle(id, x, y, z, xd, yd, zd);
|
||||
for (auto& listener : listeners)
|
||||
listener->addParticle(id, x, y, z, xd, yd, zd);
|
||||
}
|
||||
|
||||
bool Level::addGlobalEntity(shared_ptr<Entity> e)
|
||||
@@ -1768,48 +1748,45 @@ bool Level::addEntity(shared_ptr<Entity> e)
|
||||
|
||||
void Level::entityAdded(shared_ptr<Entity> e)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->entityAdded(e);
|
||||
listener->entityAdded(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Level::entityRemoved(shared_ptr<Entity> e)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->entityRemoved(e);
|
||||
listener->entityRemoved(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 4J added
|
||||
void Level::playerRemoved(shared_ptr<Entity> e)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->playerRemoved(e);
|
||||
listener->playerRemoved(e);
|
||||
}
|
||||
}
|
||||
|
||||
void Level::removeEntity(shared_ptr<Entity> e)
|
||||
{
|
||||
if (e->rider.lock() != NULL)
|
||||
if (e->rider.lock())
|
||||
{
|
||||
e->rider.lock()->ride(nullptr);
|
||||
}
|
||||
if (e->riding != NULL)
|
||||
if (e->riding)
|
||||
{
|
||||
e->ride(nullptr);
|
||||
}
|
||||
e->remove();
|
||||
if (e->instanceof(eTYPE_PLAYER))
|
||||
{
|
||||
vector<shared_ptr<Player> >::iterator it = players.begin();
|
||||
vector<shared_ptr<Player> >::iterator itEnd = players.end();
|
||||
auto it = players.begin();
|
||||
auto itEnd = players.end();
|
||||
while( it != itEnd && *it != dynamic_pointer_cast<Player>(e) )
|
||||
it++;
|
||||
|
||||
@@ -1958,16 +1935,15 @@ AABBList *Level::getCubes(shared_ptr<Entity> source, AABB *box, bool noEntities/
|
||||
|
||||
double r = 0.25;
|
||||
vector<shared_ptr<Entity> > *ee = getEntities(source, box->grow(r, r, r));
|
||||
vector<shared_ptr<Entity> >::iterator itEnd = ee->end();
|
||||
for (AUTO_VAR(it, ee->begin()); it != itEnd; it++)
|
||||
for (auto& it : *ee)
|
||||
{
|
||||
AABB *collideBox = (*it)->getCollideBox();
|
||||
AABB *collideBox = it->getCollideBox();
|
||||
if (collideBox != NULL && collideBox->intersects(box))
|
||||
{
|
||||
boxes.push_back(collideBox);
|
||||
}
|
||||
|
||||
collideBox = source->getCollideAgainstBox(*it);
|
||||
collideBox = source->getCollideAgainstBox(it);
|
||||
if (collideBox != NULL && collideBox->intersects(box))
|
||||
{
|
||||
boxes.push_back(collideBox);
|
||||
@@ -2277,12 +2253,12 @@ void Level::tickEntities()
|
||||
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
|
||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); )
|
||||
{
|
||||
for (auto it = entities.begin(); it != entities.end();)
|
||||
{
|
||||
bool found = false;
|
||||
for( AUTO_VAR(it2, entitiesToRemove.begin()); it2 != entitiesToRemove.end(); it2++ )
|
||||
for(auto& it2 : entitiesToRemove)
|
||||
{
|
||||
if( (*it) == (*it2) )
|
||||
if( (*it) == it2 )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
@@ -2299,10 +2275,8 @@ void Level::tickEntities()
|
||||
}
|
||||
LeaveCriticalSection(&m_entitiesCS);
|
||||
|
||||
AUTO_VAR(itETREnd, entitiesToRemove.end());
|
||||
for (AUTO_VAR(it, entitiesToRemove.begin()); it != itETREnd; it++)
|
||||
for (auto& e : entitiesToRemove)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entitiesToRemove.at(j);
|
||||
int xc = e->xChunk;
|
||||
int zc = e->zChunk;
|
||||
if (e->inChunk && hasChunk(xc, zc))
|
||||
@@ -2311,12 +2285,11 @@ void Level::tickEntities()
|
||||
}
|
||||
}
|
||||
|
||||
itETREnd = entitiesToRemove.end();
|
||||
for (AUTO_VAR(it, entitiesToRemove.begin()); it != itETREnd; it++)
|
||||
for (auto& it : entitiesToRemove)
|
||||
{
|
||||
entityRemoved(*it);
|
||||
entityRemoved(it);
|
||||
}
|
||||
//
|
||||
//
|
||||
entitiesToRemove.clear();
|
||||
|
||||
//for (int i = 0; i < entities.size(); i++)
|
||||
@@ -2348,7 +2321,7 @@ void Level::tickEntities()
|
||||
{
|
||||
#ifndef _FINAL_BUILD
|
||||
if ( !( app.DebugSettingsOn() && app.GetMobsDontTickEnabled() && e->instanceof(eTYPE_MOB) && !e->instanceof(eTYPE_PLAYER)) )
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
tick(e);
|
||||
}
|
||||
@@ -2367,8 +2340,8 @@ void Level::tickEntities()
|
||||
|
||||
// 4J Find the entity again before deleting, as things might have moved in the entity array eg
|
||||
// from the explosion created by tnt
|
||||
AUTO_VAR(it, find(entities.begin(), entities.end(), e));
|
||||
if( it != entities.end() )
|
||||
auto it = find(entities.begin(), entities.end(), e);
|
||||
if( it != entities.end() )
|
||||
{
|
||||
entities.erase(it);
|
||||
}
|
||||
@@ -2385,8 +2358,8 @@ void Level::tickEntities()
|
||||
EnterCriticalSection(&m_tileEntityListCS);
|
||||
|
||||
updatingTileEntities = true;
|
||||
for (AUTO_VAR(it, tileEntityList.begin()); it != tileEntityList.end();)
|
||||
{
|
||||
for (auto it = tileEntityList.begin(); it != tileEntityList.end();)
|
||||
{
|
||||
shared_ptr<TileEntity> te = *it;//tilevector<shared_ptr<Entity> >.at(i);
|
||||
if( !te->isRemoved() && te->hasLevel() )
|
||||
{
|
||||
@@ -2421,15 +2394,15 @@ void Level::tickEntities()
|
||||
// 4J-PB - Stuart - check this is correct here
|
||||
|
||||
if (!tileEntitiesToUnload.empty())
|
||||
{
|
||||
{
|
||||
//tileEntityList.removeAll(tileEntitiesToUnload);
|
||||
|
||||
for( AUTO_VAR(it, tileEntityList.begin()); it != tileEntityList.end(); )
|
||||
{
|
||||
for (auto it = tileEntityList.begin(); it != tileEntityList.end();)
|
||||
{
|
||||
bool found = false;
|
||||
for( AUTO_VAR(it2, tileEntitiesToUnload.begin()); it2 != tileEntitiesToUnload.end(); it2++ )
|
||||
for(auto& it2 : tileEntitiesToUnload)
|
||||
{
|
||||
if( (*it) == (*it2) )
|
||||
if( (*it) == it2 )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
@@ -2453,10 +2426,9 @@ void Level::tickEntities()
|
||||
|
||||
if( !pendingTileEntities.empty() )
|
||||
{
|
||||
for( AUTO_VAR(it, pendingTileEntities.begin()); it != pendingTileEntities.end(); it++ )
|
||||
for(auto& e : pendingTileEntities)
|
||||
{
|
||||
shared_ptr<TileEntity> e = *it;
|
||||
if( !e->isRemoved() )
|
||||
if( e && !e->isRemoved() )
|
||||
{
|
||||
if( find(tileEntityList.begin(),tileEntityList.end(),e) == tileEntityList.end() )
|
||||
{
|
||||
@@ -2481,16 +2453,16 @@ void Level::addAllPendingTileEntities(vector< shared_ptr<TileEntity> >& entities
|
||||
EnterCriticalSection(&m_tileEntityListCS);
|
||||
if( updatingTileEntities )
|
||||
{
|
||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
|
||||
for(auto& it : entities)
|
||||
{
|
||||
pendingTileEntities.push_back(*it);
|
||||
pendingTileEntities.push_back(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
|
||||
for(auto& it : entities)
|
||||
{
|
||||
tileEntityList.push_back(*it);
|
||||
tileEntityList.push_back(it);
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&m_tileEntityListCS);
|
||||
@@ -2602,11 +2574,9 @@ bool Level::isUnobstructed(AABB *aabb)
|
||||
bool Level::isUnobstructed(AABB *aabb, shared_ptr<Entity> ignore)
|
||||
{
|
||||
vector<shared_ptr<Entity> > *ents = getEntities(nullptr, aabb);
|
||||
AUTO_VAR(itEnd, ents->end());
|
||||
for (AUTO_VAR(it, ents->begin()); it != itEnd; it++)
|
||||
for (auto& e : *ents)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
if (!e->removed && e->blocksBuilding && e != ignore) return false;
|
||||
if (e && !e->removed && e->blocksBuilding && e != ignore) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2841,7 +2811,7 @@ shared_ptr<Explosion> Level::explode(shared_ptr<Entity> source, double x, double
|
||||
shared_ptr<Explosion> Level::explode(shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks)
|
||||
{
|
||||
shared_ptr<Explosion> explosion = shared_ptr<Explosion>( new Explosion(this, source, x, y, z, r) );
|
||||
explosion->fire = fire;
|
||||
explosion->fire = fire;
|
||||
explosion->destroyBlocks = destroyBlocks;
|
||||
explosion->explode();
|
||||
explosion->finalizeExplosion(true);
|
||||
@@ -2950,11 +2920,9 @@ shared_ptr<TileEntity> Level::getTileEntity(int x, int y, int z)
|
||||
if (tileEntity == NULL)
|
||||
{
|
||||
EnterCriticalSection(&m_tileEntityListCS);
|
||||
for( AUTO_VAR(it, pendingTileEntities.begin()); it != pendingTileEntities.end(); it++ )
|
||||
for(auto& e : pendingTileEntities)
|
||||
{
|
||||
shared_ptr<TileEntity> e = *it;
|
||||
|
||||
if (!e->isRemoved() && e->x == x && e->y == y && e->z == z)
|
||||
if ( e && !e->isRemoved() && e->x == x && e->y == y && e->z == z)
|
||||
{
|
||||
tileEntity = e;
|
||||
break;
|
||||
@@ -2978,8 +2946,8 @@ void Level::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileEntity
|
||||
tileEntity->z = z;
|
||||
|
||||
// avoid adding duplicates
|
||||
for( AUTO_VAR(it, pendingTileEntities.begin()); it != pendingTileEntities.end();)
|
||||
{
|
||||
for (auto it = pendingTileEntities.begin(); it != pendingTileEntities.end();)
|
||||
{
|
||||
shared_ptr<TileEntity> next = *it;
|
||||
if (next->x == x && next->y == y && next->z == z)
|
||||
{
|
||||
@@ -3012,8 +2980,8 @@ void Level::removeTileEntity(int x, int y, int z)
|
||||
if (te != NULL && updatingTileEntities)
|
||||
{
|
||||
te->setRemoved();
|
||||
AUTO_VAR(it, find(pendingTileEntities.begin(), pendingTileEntities.end(), te ));
|
||||
if( it != pendingTileEntities.end() )
|
||||
auto it = find(pendingTileEntities.begin(), pendingTileEntities.end(), te);
|
||||
if( it != pendingTileEntities.end() )
|
||||
{
|
||||
pendingTileEntities.erase(it);
|
||||
}
|
||||
@@ -3022,13 +2990,13 @@ void Level::removeTileEntity(int x, int y, int z)
|
||||
{
|
||||
if (te != NULL)
|
||||
{
|
||||
AUTO_VAR(it, find(pendingTileEntities.begin(), pendingTileEntities.end(), te ));
|
||||
if( it != pendingTileEntities.end() )
|
||||
auto it = find(pendingTileEntities.begin(), pendingTileEntities.end(), te);
|
||||
if( it != pendingTileEntities.end() )
|
||||
{
|
||||
pendingTileEntities.erase(it);
|
||||
}
|
||||
AUTO_VAR(it2, find(tileEntityList.begin(), tileEntityList.end(), te));
|
||||
if( it2 != tileEntityList.end() )
|
||||
auto it2 = find(tileEntityList.begin(), tileEntityList.end(), te);
|
||||
if( it2 != tileEntityList.end() )
|
||||
{
|
||||
tileEntityList.erase(it2);
|
||||
}
|
||||
@@ -3126,7 +3094,7 @@ bool Level::isTopSolidBlocking(Tile *tile, int data)
|
||||
if (tile == NULL) return false;
|
||||
|
||||
if (tile->material->isSolidBlocking() && tile->isCubeShaped()) return true;
|
||||
if (dynamic_cast<StairTile *>(tile) != NULL)
|
||||
if (dynamic_cast<StairTile *>(tile) != NULL)
|
||||
{
|
||||
return (data & StairTile::UPSIDEDOWN_BIT) == StairTile::UPSIDEDOWN_BIT;
|
||||
}
|
||||
@@ -3273,11 +3241,9 @@ void Level::toggleDownfall()
|
||||
|
||||
void Level::buildAndPrepareChunksToPoll()
|
||||
{
|
||||
#if 0
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
#if 0
|
||||
for (auto& player : players)
|
||||
{
|
||||
shared_ptr<Player> player = *it;
|
||||
int xx = Mth::floor(player->x / 16);
|
||||
int zz = Mth::floor(player->z / 16);
|
||||
|
||||
@@ -3295,7 +3261,7 @@ void Level::buildAndPrepareChunksToPoll()
|
||||
int playerCount = (int)players.size();
|
||||
int *xx = new int[playerCount];
|
||||
int *zz = new int[playerCount];
|
||||
for (int i = 0; i < playerCount; i++)
|
||||
for (size_t i = 0; i < playerCount; i++)
|
||||
{
|
||||
shared_ptr<Player> player = players[i];
|
||||
xx[i] = Mth::floor(player->x / 16);
|
||||
@@ -3534,7 +3500,7 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool f
|
||||
{
|
||||
int centerCurrent = getBrightnessCached(cache, layer, xc, yc, zc);
|
||||
int centerExpected = getExpectedLight(cache, xc, yc, zc, layer, false);
|
||||
|
||||
|
||||
if( centerExpected != centerCurrent && cache )
|
||||
{
|
||||
initCacheComplete(cache, xc, yc, zc);
|
||||
@@ -3802,9 +3768,8 @@ shared_ptr<Entity> Level::getClosestEntityOfClass(const type_info& baseClass, AA
|
||||
shared_ptr<Entity> closest = nullptr;
|
||||
double closestDistSqr = Double::MAX_VALUE;
|
||||
//for (Entity entity : entities)
|
||||
for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
|
||||
for(auto& entity : *entities)
|
||||
{
|
||||
shared_ptr<Entity> entity = *it;
|
||||
if (entity == source) continue;
|
||||
double distSqr = source->distanceToSqr(entity);
|
||||
if (distSqr > closestDistSqr) continue;
|
||||
@@ -3837,10 +3802,8 @@ unsigned int Level::countInstanceOf(BaseObject::Class *clas)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
for (auto& e : entities)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
if (clas->isAssignableFrom(e->getClass())) count++;
|
||||
}
|
||||
LeaveCriticalSection(&m_entitiesCS);
|
||||
@@ -3857,10 +3820,8 @@ unsigned int Level::countInstanceOf(eINSTANCEOF clas, bool singleType, unsigned
|
||||
if( protectedCount ) *protectedCount = 0;
|
||||
if( couldWanderCount ) *couldWanderCount = 0;
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
for (auto& e : entities)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
if( singleType )
|
||||
{
|
||||
if (e->GetType() == clas)
|
||||
@@ -3892,11 +3853,8 @@ unsigned int Level::countInstanceOfInRange(eINSTANCEOF clas, bool singleType, in
|
||||
{
|
||||
unsigned int count = 0;
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
AUTO_VAR(itEnd, entities.end());
|
||||
for (AUTO_VAR(it, entities.begin()); it != itEnd; it++)
|
||||
for (auto& e : entities)
|
||||
{
|
||||
shared_ptr<Entity> e = *it;//entities.at(i);
|
||||
|
||||
float sd = e->distanceTo(x,y,z);
|
||||
if (sd * sd > range * range)
|
||||
{
|
||||
@@ -3925,14 +3883,13 @@ void Level::addEntities(vector<shared_ptr<Entity> > *list)
|
||||
//entities.addAll(list);
|
||||
EnterCriticalSection(&m_entitiesCS);
|
||||
entities.insert(entities.end(), list->begin(), list->end());
|
||||
AUTO_VAR(itEnd, list->end());
|
||||
bool deleteDragons = false;
|
||||
for (AUTO_VAR(it, list->begin()); it != itEnd; it++)
|
||||
for (auto& it : *list)
|
||||
{
|
||||
entityAdded(*it);
|
||||
entityAdded(it);
|
||||
|
||||
// 4J Stu - Special change to remove duplicate enderdragons that a previous bug might have produced
|
||||
if( (*it)->GetType() == eTYPE_ENDERDRAGON)
|
||||
if( it->GetType() == eTYPE_ENDERDRAGON)
|
||||
{
|
||||
deleteDragons = true;
|
||||
}
|
||||
@@ -3941,14 +3898,14 @@ void Level::addEntities(vector<shared_ptr<Entity> > *list)
|
||||
if(deleteDragons)
|
||||
{
|
||||
deleteDragons = false;
|
||||
for(AUTO_VAR(it, entities.begin()); it != entities.end(); ++it)
|
||||
for(auto& it : entities)
|
||||
{
|
||||
// 4J Stu - Special change to remove duplicate enderdragons that a previous bug might have produced
|
||||
if( (*it)->GetType() == eTYPE_ENDERDRAGON)
|
||||
if( it->GetType() == eTYPE_ENDERDRAGON)
|
||||
{
|
||||
if(deleteDragons)
|
||||
{
|
||||
(*it)->remove();
|
||||
it->remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4118,10 +4075,8 @@ shared_ptr<Player> Level::getNearestPlayer(double x, double y, double z, double
|
||||
MemSect(21);
|
||||
double best = -1;
|
||||
shared_ptr<Player> result = nullptr;
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
for (auto& p : players)
|
||||
{
|
||||
shared_ptr<Player> p = *it;//players.at(i);
|
||||
double dist = p->distanceToSqr(x, y, z);
|
||||
|
||||
// Allow specifying shorter distances in the vertical
|
||||
@@ -4142,10 +4097,8 @@ shared_ptr<Player> Level::getNearestPlayer(double x, double z, double maxDist)
|
||||
{
|
||||
double best = -1;
|
||||
shared_ptr<Player> result = nullptr;
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
for (auto& p : players)
|
||||
{
|
||||
shared_ptr<Player> p = *it;
|
||||
double dist = p->distanceToSqr(x, p->y, z);
|
||||
if ((maxDist < 0 || dist < maxDist * maxDist) && (best == -1 || dist < best))
|
||||
{
|
||||
@@ -4166,11 +4119,8 @@ shared_ptr<Player> Level::getNearestAttackablePlayer(double x, double y, double
|
||||
double best = -1;
|
||||
|
||||
shared_ptr<Player> result = nullptr;
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
for (auto& p : players)
|
||||
{
|
||||
shared_ptr<Player> p = *it;
|
||||
|
||||
// 4J Stu - Added privilege check
|
||||
if (p->abilities.invulnerable || !p->isAlive() || p->hasInvisiblePrivilege() )
|
||||
{
|
||||
@@ -4207,28 +4157,26 @@ shared_ptr<Player> Level::getNearestAttackablePlayer(double x, double y, double
|
||||
|
||||
shared_ptr<Player> Level::getPlayerByName(const wstring& name)
|
||||
{
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
for (auto& player : players)
|
||||
{
|
||||
if (name.compare( (*it)->getName()) == 0)
|
||||
if (name.compare( player->getName()) == 0)
|
||||
{
|
||||
return *it; //players.at(i);
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return shared_ptr<Player>();
|
||||
return {};
|
||||
}
|
||||
|
||||
shared_ptr<Player> Level::getPlayerByUUID(const wstring& name)
|
||||
{
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
|
||||
for (auto& player : players)
|
||||
{
|
||||
if (name.compare( (*it)->getUUID() ) == 0)
|
||||
if (name.compare( player->getUUID() ) == 0)
|
||||
{
|
||||
return *it; //players.at(i);
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return shared_ptr<Player>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// 4J Stu - Removed in 1.2.3 ?
|
||||
@@ -4355,10 +4303,9 @@ void Level::setGameTime(__int64 time)
|
||||
// Apply stat to each player.
|
||||
if ( timeDiff > 0 && levelData->getGameTime() != -1 )
|
||||
{
|
||||
AUTO_VAR(itEnd, players.end());
|
||||
for (vector<shared_ptr<Player> >::iterator it = players.begin(); it != itEnd; it++)
|
||||
for (auto& player : players)
|
||||
{
|
||||
(*it)->awardStat( GenericStats::timePlayed(), GenericStats::param_time(timeDiff) );
|
||||
player->awardStat( GenericStats::timePlayed(), GenericStats::param_time(timeDiff) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4538,12 +4485,11 @@ int Level::getAuxValueForMap(PlayerUID xuid, int dimension, int centreXC, int ce
|
||||
return savedDataStorage->getAuxValueForMap(xuid, dimension, centreXC, centreZC, scale);
|
||||
}
|
||||
|
||||
void Level::globalLevelEvent(int type, int sourceX, int sourceY, int sourceZ, int data)
|
||||
void Level::globalLevelEvent(int type, int sourceX, int sourceY, int sourceZ, int data)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->globalLevelEvent(type, sourceX, sourceY, sourceZ, data);
|
||||
listener->globalLevelEvent(type, sourceX, sourceY, sourceZ, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4555,10 +4501,9 @@ void Level::levelEvent(int type, int x, int y, int z, int data)
|
||||
|
||||
void Level::levelEvent(shared_ptr<Player> source, int type, int x, int y, int z, int data)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->levelEvent(source, type, x, y, z, data);
|
||||
listener->levelEvent(source, type, x, y, z, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4594,9 +4539,9 @@ bool Level::isAllEmpty()
|
||||
return false;
|
||||
}
|
||||
|
||||
double Level::getHorizonHeight()
|
||||
double Level::getHorizonHeight()
|
||||
{
|
||||
if (levelData->getGenerator() == LevelType::lvl_flat)
|
||||
if (levelData->getGenerator() == LevelType::lvl_flat)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@@ -4605,10 +4550,9 @@ double Level::getHorizonHeight()
|
||||
|
||||
void Level::destroyTileProgress(int id, int x, int y, int z, int progress)
|
||||
{
|
||||
AUTO_VAR(itEnd, listeners.end());
|
||||
for (AUTO_VAR(it, listeners.begin()); it != itEnd; it++)
|
||||
for (auto& listener : listeners)
|
||||
{
|
||||
(*it)->destroyTileProgress(id, x, y, z, progress);
|
||||
listener->destroyTileProgress(id, x, y, z, progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void LevelChunk::init(Level *level, int x, int z)
|
||||
biomes = byteArray(16 * 16);
|
||||
for(int i = 0; i < 16 * 16; i++ )
|
||||
{
|
||||
biomes[i] = 0xff;
|
||||
biomes[i] = 0xff;
|
||||
}
|
||||
#ifdef _ENTITIES_RW_SECTION
|
||||
EnterCriticalRWSection(&m_csEntities, true);
|
||||
@@ -109,12 +109,12 @@ void LevelChunk::init(Level *level, int x, int z)
|
||||
// Optimisation brought forward from 1.8.2, change from int to unsigned char & this special value changed from -999 to 255
|
||||
for(int i = 0; i < 16 * 16; i++ )
|
||||
{
|
||||
rainHeights[i] = 255;
|
||||
rainHeights[i] = 255;
|
||||
}
|
||||
// 4J - lighting change brought forward from 1.8.2, introduced an array of bools called gapsToRecheck, which are now a single bit in array of nybble flags in this version
|
||||
for(int i = 0; i < 8 * 16; i++ )
|
||||
{
|
||||
columnFlags[i] = 0;
|
||||
columnFlags[i] = 0;
|
||||
}
|
||||
|
||||
// 4J added - to flag if any emissive tile has been added to this chunk (will be cleared when lighting has been successfully completed for this chunk). Defaulting to true
|
||||
@@ -128,7 +128,7 @@ void LevelChunk::init(Level *level, int x, int z)
|
||||
}
|
||||
|
||||
// This ctor is used for loading a save into
|
||||
LevelChunk::LevelChunk(Level *level, int x, int z) : ENTITY_BLOCKS_LENGTH( Level::maxBuildHeight/16 )
|
||||
LevelChunk::LevelChunk(Level *level, int x, int z)
|
||||
{
|
||||
init(level, x, z);
|
||||
lowerBlocks = new CompressedTileStorage();
|
||||
@@ -160,7 +160,7 @@ LevelChunk::LevelChunk(Level *level, int x, int z) : ENTITY_BLOCKS_LENGTH( Level
|
||||
|
||||
// 4J - note that since we now compress the block storage, the parameter blocks is used as a source of data, but doesn't get used As the source data so needs
|
||||
// to be deleted after calling this ctor.
|
||||
LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z) : ENTITY_BLOCKS_LENGTH( Level::maxBuildHeight/16 )
|
||||
LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z)
|
||||
{
|
||||
init(level, x, z);
|
||||
|
||||
@@ -189,7 +189,7 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z) : ENTITY_BL
|
||||
// skyLight = new DataLayer(blocks.length, level->depthBits);
|
||||
// blockLight = new DataLayer(blocks.length, level->depthBits);
|
||||
|
||||
if(Level::maxBuildHeight > Level::COMPRESSED_CHUNK_SECTION_HEIGHT)
|
||||
if(Level::maxBuildHeight > Level::COMPRESSED_CHUNK_SECTION_HEIGHT)
|
||||
{
|
||||
if(blocks.length > Level::COMPRESSED_CHUNK_SECTION_TILES) upperBlocks = new CompressedTileStorage(blocks,Level::COMPRESSED_CHUNK_SECTION_TILES);
|
||||
else upperBlocks = new CompressedTileStorage(true);
|
||||
@@ -213,7 +213,7 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z) : ENTITY_BL
|
||||
|
||||
// 4J - this ctor added to be able to make a levelchunk that shares its underlying block data between the server chunk cache & the multiplayer chunk cache.
|
||||
// The original version this is shared from owns all the data that is shared into this copy, so it isn't deleted in the dtor.
|
||||
LevelChunk::LevelChunk(Level *level, int x, int z, LevelChunk *lc) : ENTITY_BLOCKS_LENGTH( Level::maxBuildHeight/16 )
|
||||
LevelChunk::LevelChunk(Level *level, int x, int z, LevelChunk *lc)
|
||||
{
|
||||
init(level, x, z);
|
||||
|
||||
@@ -705,7 +705,7 @@ void LevelChunk::recheckGaps(bool bForce)
|
||||
// 4J added - otherwise we can end up doing a very broken kind of lighting since for an empty chunk, the heightmap is all zero, but it
|
||||
// still has an x and z of 0 which means that the level->getHeightmap references in here find a real chunk near the origin, and then attempt
|
||||
// to light massive gaps between the height of 0 and whatever heights are in those.
|
||||
if( isEmpty() ) return;
|
||||
if( isEmpty() ) return;
|
||||
|
||||
// 4J added
|
||||
int minXZ = - (level->dimension->getXZSize() * 16 ) / 2;
|
||||
@@ -773,7 +773,7 @@ void LevelChunk::lightGap(int x, int z, int source)
|
||||
{
|
||||
lightGap(x, z, source, height + 1);
|
||||
}
|
||||
else if (height < source)
|
||||
else if (height < source)
|
||||
{
|
||||
lightGap(x, z, height, source + 1);
|
||||
}
|
||||
@@ -900,7 +900,7 @@ void LevelChunk::recalcHeight(int x, int yStart, int z)
|
||||
/**
|
||||
* The purpose of this method is to allow the EmptyLevelChunk to be all air
|
||||
* but still block light. See EmptyLevelChunk.java
|
||||
*
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
@@ -1240,7 +1240,7 @@ void LevelChunk::removeEntity(shared_ptr<Entity> e, int yc)
|
||||
#endif
|
||||
|
||||
// 4J - was entityBlocks[yc]->remove(e);
|
||||
AUTO_VAR(it, find(entityBlocks[yc]->begin(),entityBlocks[yc]->end(),e));
|
||||
auto it = find(entityBlocks[yc]->begin(), entityBlocks[yc]->end(), e);
|
||||
if( it != entityBlocks[yc]->end() )
|
||||
{
|
||||
entityBlocks[yc]->erase(it);
|
||||
@@ -1250,7 +1250,7 @@ void LevelChunk::removeEntity(shared_ptr<Entity> e, int yc)
|
||||
// MGH - have to sort this C++11 code
|
||||
static bool bShowMsg = true;
|
||||
if(bShowMsg)
|
||||
{
|
||||
{
|
||||
app.DebugPrintf("Need to add C++11 shrink_to_fit for PS3\n");
|
||||
bShowMsg = false;
|
||||
}
|
||||
@@ -1292,7 +1292,7 @@ shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
|
||||
//shared_ptr<TileEntity> tileEntity = tileEntities[pos];
|
||||
EnterCriticalSection(&m_csTileEntities);
|
||||
shared_ptr<TileEntity> tileEntity = nullptr;
|
||||
AUTO_VAR(it, tileEntities.find(pos));
|
||||
auto it = tileEntities.find(pos);
|
||||
|
||||
if (it == tileEntities.end())
|
||||
{
|
||||
@@ -1320,8 +1320,8 @@ shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
|
||||
|
||||
// 4J Stu - It should have been inserted by now, but check to be sure
|
||||
EnterCriticalSection(&m_csTileEntities);
|
||||
AUTO_VAR(newIt, tileEntities.find(pos));
|
||||
if (newIt != tileEntities.end())
|
||||
auto newIt = tileEntities.find(pos);
|
||||
if (newIt != tileEntities.end())
|
||||
{
|
||||
tileEntity = newIt->second;
|
||||
}
|
||||
@@ -1371,8 +1371,8 @@ void LevelChunk::setTileEntity(int x, int y, int z, shared_ptr<TileEntity> tileE
|
||||
app.DebugPrintf("Attempted to place a tile entity where there was no entity tile!\n");
|
||||
return;
|
||||
}
|
||||
AUTO_VAR(it, tileEntities.find(pos) );
|
||||
if(it != tileEntities.end()) it->second->setRemoved();
|
||||
auto it = tileEntities.find(pos);
|
||||
if(it != tileEntities.end()) it->second->setRemoved();
|
||||
|
||||
tileEntity->clearRemoved();
|
||||
|
||||
@@ -1393,8 +1393,8 @@ void LevelChunk::removeTileEntity(int x, int y, int z)
|
||||
// removeThis.setRemoved();
|
||||
// }
|
||||
EnterCriticalSection(&m_csTileEntities);
|
||||
AUTO_VAR(it, tileEntities.find(pos));
|
||||
if( it != tileEntities.end() )
|
||||
auto it = tileEntities.find(pos);
|
||||
if( it != tileEntities.end() )
|
||||
{
|
||||
shared_ptr<TileEntity> te = tileEntities[pos];
|
||||
tileEntities.erase(pos);
|
||||
@@ -1456,9 +1456,9 @@ void LevelChunk::load()
|
||||
|
||||
vector< shared_ptr<TileEntity> > values;
|
||||
EnterCriticalSection(&m_csTileEntities);
|
||||
for( AUTO_VAR(it, tileEntities.begin()); it != tileEntities.end(); it++ )
|
||||
for(auto& it : tileEntities)
|
||||
{
|
||||
values.push_back(it->second);
|
||||
values.push_back(it.second);
|
||||
}
|
||||
LeaveCriticalSection(&m_csTileEntities);
|
||||
level->addAllPendingTileEntities(values);
|
||||
@@ -1492,10 +1492,10 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
if( unloadTileEntities )
|
||||
{
|
||||
EnterCriticalSection(&m_csTileEntities);
|
||||
for( AUTO_VAR(it, tileEntities.begin()); it != tileEntities.end(); it++ )
|
||||
for(auto& it : tileEntities)
|
||||
{
|
||||
// 4J-PB -m 1.7.3 was it->second->setRemoved();
|
||||
level->markForRemoval(it->second);
|
||||
level->markForRemoval(it.second);
|
||||
}
|
||||
LeaveCriticalSection(&m_csTileEntities);
|
||||
}
|
||||
@@ -1531,16 +1531,13 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
EnterCriticalSection(&m_csEntities);
|
||||
for (int i = 0; i < ENTITY_BLOCKS_LENGTH; i++)
|
||||
{
|
||||
AUTO_VAR(itEnd, entityBlocks[i]->end());
|
||||
for( vector<shared_ptr<Entity> >::iterator it = entityBlocks[i]->begin(); it != itEnd; it++ )
|
||||
for(auto& e : *entityBlocks[i])
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
if (e->save(teTag))
|
||||
{
|
||||
entityTags->add(teTag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Clear out this list
|
||||
@@ -1554,13 +1551,10 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter
|
||||
PIXBeginNamedEvent(0,"Saving tile entities");
|
||||
ListTag<CompoundTag> *tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
AUTO_VAR(itEnd,tileEntities.end());
|
||||
for( unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = tileEntities.begin();
|
||||
it != itEnd; it++)
|
||||
for(auto& it : tileEntities)
|
||||
{
|
||||
shared_ptr<TileEntity> te = it->second;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
te->save(teTag);
|
||||
it.second->save(teTag);
|
||||
tileEntityTags->add(teTag);
|
||||
}
|
||||
// Clear out the tileEntities list
|
||||
@@ -1632,20 +1626,18 @@ void LevelChunk::getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = entityBlocks[yc];
|
||||
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
for (auto& e : *entities)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
if (e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
|
||||
if ( e && e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
|
||||
{
|
||||
es.push_back(e);
|
||||
vector<shared_ptr<Entity> > *subs = e->getSubEntities();
|
||||
if (subs != NULL)
|
||||
{
|
||||
for (int j = 0; j < subs->size(); j++)
|
||||
for (const auto& sub : *subs)
|
||||
{
|
||||
e = subs->at(j);
|
||||
if (e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
|
||||
e = sub;
|
||||
if ( e && e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
|
||||
{
|
||||
es.push_back(e);
|
||||
}
|
||||
@@ -1689,11 +1681,8 @@ void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = entityBlocks[yc];
|
||||
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
for (auto& e : *entities)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
|
||||
bool isAssignableFrom = false;
|
||||
// Some special cases where the base class is a general type that our class may be derived from, otherwise do a direct comparison of type_info
|
||||
if ( ec==typeid(Player) ) isAssignableFrom = e->instanceof(eTYPE_PLAYER);
|
||||
@@ -1929,9 +1918,9 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1,
|
||||
}
|
||||
*/
|
||||
|
||||
for(AUTO_VAR(it, tileEntities.begin()); it != tileEntities.end(); ++it)
|
||||
for(auto& it : tileEntities)
|
||||
{
|
||||
it->second->clearCache();
|
||||
it.second->clearCache();
|
||||
}
|
||||
// recalcHeightmap();
|
||||
|
||||
@@ -2216,7 +2205,7 @@ void LevelChunk::setSkyLightDataAllBright()
|
||||
void LevelChunk::compressLighting()
|
||||
{
|
||||
// The lighting data is now generally not shared between host & local client, but is for a while at the start of level creation (until the point where the chunk data would be transferred by network
|
||||
// data for remote clients). We'll therefore either be compressing a shared copy here or one of the server or client copies depending on
|
||||
// data for remote clients). We'll therefore either be compressing a shared copy here or one of the server or client copies depending on
|
||||
lowerSkyLight->compress();
|
||||
upperSkyLight->compress();
|
||||
lowerBlockLight->compress();
|
||||
@@ -2532,7 +2521,7 @@ void LevelChunk::reorderBlocksAndDataToXZY(int y0, int xs, int ys, int zs, byteA
|
||||
//setBlocksAndData(*data, x0, y0, z0, x1, y1, z1, p);
|
||||
|
||||
//// If it is a full chunk, we'll need to rearrange into the order the rest of the game expects
|
||||
//if( xs == 16 && ys == 128 && zs == 16 && ( ( x & 15 ) == 0 ) && ( y == 0 ) && ( ( z & 15 ) == 0 ) )
|
||||
//if( xs == 16 && ys == 128 && zs == 16 && ( ( x & 15 ) == 0 ) && ( y == 0 ) && ( ( z & 15 ) == 0 ) )
|
||||
//{
|
||||
// byteArray newBuffer = byteArray(81920);
|
||||
// for( int x = 0; x < 16; x++ )
|
||||
|
||||
@@ -29,9 +29,8 @@ class LevelChunk
|
||||
public:
|
||||
byteArray biomes; // 4J Stu - Made public
|
||||
|
||||
// 4J Stu - No longer static in 1.8.2
|
||||
const int ENTITY_BLOCKS_LENGTH;
|
||||
static const int BLOCKS_LENGTH = Level::CHUNK_TILE_COUNT; // 4J added
|
||||
static constexpr int ENTITY_BLOCKS_LENGTH = Level::maxBuildHeight/16;
|
||||
static constexpr int BLOCKS_LENGTH = Level::CHUNK_TILE_COUNT; // 4J added
|
||||
|
||||
static bool touchedSky;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "net.minecraft.world.level.dimension.h"
|
||||
|
||||
|
||||
LightningBolt::LightningBolt(Level *level, double x, double y, double z) :
|
||||
LightningBolt::LightningBolt(Level *level, double x, double y, double z) :
|
||||
life( 0 ),
|
||||
seed( 0 ),
|
||||
flashes( 0 ),
|
||||
@@ -103,10 +103,8 @@ void LightningBolt::tick()
|
||||
{
|
||||
double r = 3;
|
||||
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), AABB::newTemp(x - r, y - r, z - r, x + r, y + 6 + r, z + r));
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
for (auto& e : *entities)
|
||||
{
|
||||
shared_ptr<Entity> e = (*it); //entities->at(i);
|
||||
e->thunderHit(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,8 @@ public:
|
||||
dos->writeByte(type);
|
||||
dos->writeInt((int)list.size());
|
||||
|
||||
AUTO_VAR(itEnd, list.end());
|
||||
for (AUTO_VAR(it, list.begin()); it != itEnd; it++)
|
||||
(*it)->write(dos);
|
||||
for ( auto& it : list )
|
||||
it->write(dos);
|
||||
}
|
||||
|
||||
void load(DataInput *dis, int tagDepth)
|
||||
@@ -52,7 +51,7 @@ public:
|
||||
wstring toString()
|
||||
{
|
||||
static wchar_t buf[64];
|
||||
swprintf(buf,64,L"%d entries of type %ls",list.size(),Tag::getTagName(type));
|
||||
swprintf(buf,64,L"%zu entries of type %ls",list.size(),Tag::getTagName(type));
|
||||
return wstring( buf );
|
||||
}
|
||||
|
||||
@@ -65,9 +64,8 @@ public:
|
||||
char *newPrefix = new char[ strlen(prefix) + 4 ];
|
||||
strcpy( newPrefix, prefix);
|
||||
strcat( newPrefix, " ");
|
||||
AUTO_VAR(itEnd, list.end());
|
||||
for (AUTO_VAR(it, list.begin()); it != itEnd; it++)
|
||||
(*it)->print(newPrefix, out);
|
||||
for ( auto& it : list )
|
||||
it->print(newPrefix, out);
|
||||
delete[] newPrefix;
|
||||
out << prefix << "}" << endl;
|
||||
}
|
||||
@@ -95,10 +93,9 @@ public:
|
||||
|
||||
virtual ~ListTag()
|
||||
{
|
||||
AUTO_VAR(itEnd, list.end());
|
||||
for (AUTO_VAR(it, list.begin()); it != itEnd; it++)
|
||||
for ( auto& it : list )
|
||||
{
|
||||
delete *it;
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,10 +103,9 @@ public:
|
||||
{
|
||||
ListTag<T> *res = new ListTag<T>(getName());
|
||||
res->type = type;
|
||||
AUTO_VAR(itEnd, list.end());
|
||||
for (AUTO_VAR(it, list.begin()); it != itEnd; it++)
|
||||
for ( auto& it : list )
|
||||
{
|
||||
T *copy = (T *) (*it)->copy();
|
||||
T *copy = (T *) it->copy();
|
||||
res->list.push_back(copy);
|
||||
}
|
||||
return res;
|
||||
@@ -126,14 +122,13 @@ public:
|
||||
if(list.size() == o->list.size())
|
||||
{
|
||||
equal = true;
|
||||
AUTO_VAR(itEnd, list.end());
|
||||
// 4J Stu - Pretty inefficient method, but I think we can live with it give how often it will happen, and the small sizes of the data sets
|
||||
for (AUTO_VAR(it, list.begin()); it != itEnd; ++it)
|
||||
for ( auto& it : list )
|
||||
{
|
||||
bool thisMatches = false;
|
||||
for(AUTO_VAR(it2, o->list.begin()); it2 != o->list.end(); ++it2)
|
||||
for( auto it2 : o->list )
|
||||
{
|
||||
if((*it)->equals(*it2))
|
||||
if(it->equals(it2))
|
||||
{
|
||||
thisMatches = true;
|
||||
break;
|
||||
|
||||
@@ -118,9 +118,9 @@ LivingEntity::LivingEntity( Level* level) : Entity(level)
|
||||
|
||||
LivingEntity::~LivingEntity()
|
||||
{
|
||||
for(AUTO_VAR(it, activeEffects.begin()); it != activeEffects.end(); ++it)
|
||||
for(auto& it : activeEffects)
|
||||
{
|
||||
delete it->second;
|
||||
delete it.second;
|
||||
}
|
||||
|
||||
delete attributes;
|
||||
@@ -129,7 +129,7 @@ LivingEntity::~LivingEntity()
|
||||
if(lastEquipment.data != NULL) delete [] lastEquipment.data;
|
||||
}
|
||||
|
||||
void LivingEntity::defineSynchedData()
|
||||
void LivingEntity::defineSynchedData()
|
||||
{
|
||||
entityData->define(DATA_EFFECT_COLOR_ID, 0);
|
||||
entityData->define(DATA_EFFECT_AMBIENCE_ID, (byte) 0);
|
||||
@@ -186,12 +186,12 @@ bool LivingEntity::isWaterMob()
|
||||
return false;
|
||||
}
|
||||
|
||||
void LivingEntity::baseTick()
|
||||
void LivingEntity::baseTick()
|
||||
{
|
||||
oAttackAnim = attackAnim;
|
||||
Entity::baseTick();
|
||||
|
||||
if (isAlive() && isInWall())
|
||||
if (isAlive() && isInWall())
|
||||
{
|
||||
hurt(DamageSource::inWall, 1);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ void LivingEntity::baseTick()
|
||||
|
||||
if (isAlive() && isUnderLiquid(Material::water))
|
||||
{
|
||||
if(!isWaterMob() && !hasEffect(MobEffect::waterBreathing->id) && !isInvulnerable)
|
||||
if(!isWaterMob() && !hasEffect(MobEffect::waterBreathing->id) && !isInvulnerable)
|
||||
{
|
||||
setAirSupply(decreaseAirSupply(getAirSupply()));
|
||||
if (getAirSupply() == -20)
|
||||
@@ -227,8 +227,8 @@ void LivingEntity::baseTick()
|
||||
{
|
||||
ride(nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
setAirSupply(TOTAL_AIR_SUPPLY);
|
||||
}
|
||||
@@ -238,7 +238,7 @@ void LivingEntity::baseTick()
|
||||
if (attackTime > 0) attackTime--;
|
||||
if (hurtTime > 0) hurtTime--;
|
||||
if (invulnerableTime > 0) invulnerableTime--;
|
||||
if (getHealth() <= 0)
|
||||
if (getHealth() <= 0)
|
||||
{
|
||||
tickDeath();
|
||||
}
|
||||
@@ -281,9 +281,9 @@ bool LivingEntity::isBaby()
|
||||
}
|
||||
|
||||
void LivingEntity::tickDeath()
|
||||
{
|
||||
{
|
||||
deathTime++;
|
||||
if (deathTime == 20)
|
||||
if (deathTime == 20)
|
||||
{
|
||||
// 4J Stu - Added level->isClientSide check from 1.2 to fix XP orbs being created client side
|
||||
if(!level->isClientSide && (lastHurtByPlayerTime > 0 || isAlwaysExperienceDropper()) )
|
||||
@@ -301,7 +301,7 @@ void LivingEntity::tickDeath()
|
||||
}
|
||||
|
||||
remove();
|
||||
for (int i = 0; i < 20; i++)
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
double xa = random->nextGaussian() * 0.02;
|
||||
double ya = random->nextGaussian() * 0.02;
|
||||
@@ -422,16 +422,16 @@ void LivingEntity::addAdditonalSaveData(CompoundTag *entityTag)
|
||||
{
|
||||
ListTag<CompoundTag> *listTag = new ListTag<CompoundTag>();
|
||||
|
||||
for(AUTO_VAR(it, activeEffects.begin()); it != activeEffects.end(); ++it)
|
||||
for(auto & it : activeEffects)
|
||||
{
|
||||
MobEffectInstance *effect = it->second;
|
||||
MobEffectInstance *effect = it.second;
|
||||
listTag->add(effect->save(new CompoundTag()));
|
||||
}
|
||||
entityTag->put(L"ActiveEffects", listTag);
|
||||
}
|
||||
}
|
||||
|
||||
void LivingEntity::readAdditionalSaveData(CompoundTag *tag)
|
||||
void LivingEntity::readAdditionalSaveData(CompoundTag *tag)
|
||||
{
|
||||
setAbsorptionAmount(tag->getFloat(L"AbsorptionAmount"));
|
||||
|
||||
@@ -481,8 +481,8 @@ void LivingEntity::readAdditionalSaveData(CompoundTag *tag)
|
||||
void LivingEntity::tickEffects()
|
||||
{
|
||||
bool removed = false;
|
||||
for(AUTO_VAR(it, activeEffects.begin()); it != activeEffects.end();)
|
||||
{
|
||||
for (auto it = activeEffects.begin(); it != activeEffects.end();)
|
||||
{
|
||||
MobEffectInstance *effect = it->second;
|
||||
removed = false;
|
||||
if (!effect->tick(dynamic_pointer_cast<LivingEntity>(shared_from_this())))
|
||||
@@ -520,9 +520,9 @@ void LivingEntity::tickEffects()
|
||||
else
|
||||
{
|
||||
vector<MobEffectInstance *> values;
|
||||
for(AUTO_VAR(it, activeEffects.begin()); it != activeEffects.end();++it)
|
||||
for(auto& it : activeEffects)
|
||||
{
|
||||
values.push_back(it->second);
|
||||
values.push_back(it.second);
|
||||
}
|
||||
int colorValue = PotionBrewing::getColorValue(&values);
|
||||
entityData->set(DATA_EFFECT_AMBIENCE_ID, PotionBrewing::areAllEffectsAmbient(&values) ? (byte) 1 : (byte) 0);
|
||||
@@ -570,16 +570,12 @@ void LivingEntity::tickEffects()
|
||||
|
||||
void LivingEntity::removeAllEffects()
|
||||
{
|
||||
//Iterator<Integer> effectIdIterator = activeEffects.keySet().iterator();
|
||||
//while (effectIdIterator.hasNext())
|
||||
for(AUTO_VAR(it, activeEffects.begin()); it != activeEffects.end(); )
|
||||
{
|
||||
//Integer effectId = effectIdIterator.next();
|
||||
for (auto it = activeEffects.begin(); it != activeEffects.end();)
|
||||
{
|
||||
MobEffectInstance *effect = it->second;//activeEffects.get(effectId);
|
||||
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
//effectIdIterator.remove();
|
||||
it = activeEffects.erase(it);
|
||||
onEffectRemoved(effect);
|
||||
delete effect;
|
||||
@@ -595,9 +591,9 @@ vector<MobEffectInstance *> *LivingEntity::getActiveEffects()
|
||||
{
|
||||
vector<MobEffectInstance *> *active = new vector<MobEffectInstance *>();
|
||||
|
||||
for(AUTO_VAR(it, activeEffects.begin()); it != activeEffects.end(); ++it)
|
||||
for(auto& it : activeEffects)
|
||||
{
|
||||
active->push_back(it->second);
|
||||
active->push_back(it.second);
|
||||
}
|
||||
|
||||
return active;
|
||||
@@ -617,8 +613,8 @@ MobEffectInstance *LivingEntity::getEffect(MobEffect *effect)
|
||||
{
|
||||
MobEffectInstance *effectInst = NULL;
|
||||
|
||||
AUTO_VAR(it, activeEffects.find(effect->id));
|
||||
if(it != activeEffects.end() ) effectInst = it->second;
|
||||
auto it = activeEffects.find(effect->id);
|
||||
if(it != activeEffects.end() ) effectInst = it->second;
|
||||
|
||||
return effectInst;
|
||||
}
|
||||
@@ -685,8 +681,8 @@ bool LivingEntity::isInvertedHealAndHarm()
|
||||
|
||||
void LivingEntity::removeEffectNoUpdate(int effectId)
|
||||
{
|
||||
AUTO_VAR(it, activeEffects.find(effectId));
|
||||
if (it != activeEffects.end())
|
||||
auto it = activeEffects.find(effectId);
|
||||
if (it != activeEffects.end())
|
||||
{
|
||||
MobEffectInstance *effect = it->second;
|
||||
if(effect != NULL)
|
||||
@@ -699,8 +695,8 @@ void LivingEntity::removeEffectNoUpdate(int effectId)
|
||||
|
||||
void LivingEntity::removeEffect(int effectId)
|
||||
{
|
||||
AUTO_VAR(it, activeEffects.find(effectId));
|
||||
if (it != activeEffects.end())
|
||||
auto it = activeEffects.find(effectId);
|
||||
if (it != activeEffects.end())
|
||||
{
|
||||
MobEffectInstance *effect = it->second;
|
||||
if(effect != NULL)
|
||||
@@ -734,7 +730,7 @@ void LivingEntity::onEffectRemoved(MobEffectInstance *effect)
|
||||
if (!level->isClientSide) MobEffect::effects[effect->getId()]->removeAttributeModifiers(dynamic_pointer_cast<LivingEntity>(shared_from_this()), getAttributes(), effect->getAmplifier());
|
||||
}
|
||||
|
||||
void LivingEntity::heal(float heal)
|
||||
void LivingEntity::heal(float heal)
|
||||
{
|
||||
float health = getHealth();
|
||||
if (health > 0)
|
||||
@@ -753,7 +749,7 @@ void LivingEntity::setHealth(float health)
|
||||
entityData->set(DATA_HEALTH_ID, Mth::clamp(health, 0.0f, getMaxHealth()));
|
||||
}
|
||||
|
||||
bool LivingEntity::hurt(DamageSource *source, float dmg)
|
||||
bool LivingEntity::hurt(DamageSource *source, float dmg)
|
||||
{
|
||||
if (isInvulnerable()) return false;
|
||||
|
||||
@@ -786,14 +782,14 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
|
||||
walkAnimSpeed = 1.5f;
|
||||
|
||||
bool sound = true;
|
||||
if (invulnerableTime > invulnerableDuration / 2.0f)
|
||||
if (invulnerableTime > invulnerableDuration / 2.0f)
|
||||
{
|
||||
if (dmg <= lastHurt) return false;
|
||||
if(!level->isClientSide) actuallyHurt(source, dmg - lastHurt);
|
||||
lastHurt = dmg;
|
||||
sound = false;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
lastHurt = dmg;
|
||||
lastHealth = getHealth();
|
||||
@@ -837,31 +833,31 @@ bool LivingEntity::hurt(DamageSource *source, float dmg)
|
||||
{
|
||||
level->broadcastEntityEvent(shared_from_this(), EntityEvent::HURT);
|
||||
if (source != DamageSource::drown) markHurt();
|
||||
if (sourceEntity != NULL)
|
||||
if (sourceEntity != NULL)
|
||||
{
|
||||
double xd = sourceEntity->x - x;
|
||||
double zd = sourceEntity->z - z;
|
||||
while (xd * xd + zd * zd < 0.0001)
|
||||
while (xd * xd + zd * zd < 0.0001)
|
||||
{
|
||||
xd = (Math::random() - Math::random()) * 0.01;
|
||||
zd = (Math::random() - Math::random()) * 0.01;
|
||||
}
|
||||
hurtDir = (float) (atan2(zd, xd) * 180 / PI) - yRot;
|
||||
knockback(sourceEntity, dmg, xd, zd);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
hurtDir = (float) (int) ((Math::random() * 2) * 180); // 4J This cast is the same as Java
|
||||
}
|
||||
}
|
||||
|
||||
MemSect(31);
|
||||
if (getHealth() <= 0)
|
||||
if (getHealth() <= 0)
|
||||
{
|
||||
if (sound) playSound(getDeathSound(), getSoundVolume(), getVoicePitch());
|
||||
die(source);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sound) playSound(getHurtSound(), getSoundVolume(), getVoicePitch());
|
||||
}
|
||||
@@ -888,7 +884,7 @@ void LivingEntity::breakItem(shared_ptr<ItemInstance> itemInstance)
|
||||
}
|
||||
}
|
||||
|
||||
void LivingEntity::die(DamageSource *source)
|
||||
void LivingEntity::die(DamageSource *source)
|
||||
{
|
||||
shared_ptr<Entity> sourceEntity = source->getEntity();
|
||||
shared_ptr<LivingEntity> killer = getKillCredit();
|
||||
@@ -898,11 +894,11 @@ void LivingEntity::die(DamageSource *source)
|
||||
|
||||
dead = true;
|
||||
|
||||
if (!level->isClientSide)
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
int playerBonus = 0;
|
||||
|
||||
shared_ptr<Player> player = nullptr;
|
||||
shared_ptr<Player> player = nullptr;
|
||||
if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER) )
|
||||
{
|
||||
player = dynamic_pointer_cast<Player>(sourceEntity);
|
||||
@@ -937,7 +933,7 @@ void LivingEntity::dropEquipment(bool byPlayer, int playerBonusLevel)
|
||||
{
|
||||
}
|
||||
|
||||
void LivingEntity::knockback(shared_ptr<Entity> source, float dmg, double xd, double zd)
|
||||
void LivingEntity::knockback(shared_ptr<Entity> source, float dmg, double xd, double zd)
|
||||
{
|
||||
if (random->nextDouble() < getAttribute(SharedMonsterAttributes::KNOCKBACK_RESISTANCE)->getValue())
|
||||
{
|
||||
@@ -959,12 +955,12 @@ void LivingEntity::knockback(shared_ptr<Entity> source, float dmg, double xd, do
|
||||
if (yd > 0.4f) yd = 0.4f;
|
||||
}
|
||||
|
||||
int LivingEntity::getHurtSound()
|
||||
int LivingEntity::getHurtSound()
|
||||
{
|
||||
return eSoundType_DAMAGE_HURT;
|
||||
}
|
||||
|
||||
int LivingEntity::getDeathSound()
|
||||
int LivingEntity::getDeathSound()
|
||||
{
|
||||
return eSoundType_DAMAGE_HURT;
|
||||
}
|
||||
@@ -972,7 +968,7 @@ int LivingEntity::getDeathSound()
|
||||
/**
|
||||
* Drop extra rare loot. Only occurs roughly 5% of the time, rareRootLevel
|
||||
* is set to 1 (otherwise 0) 1% of the time.
|
||||
*
|
||||
*
|
||||
* @param rareLootLevel
|
||||
*/
|
||||
void LivingEntity::dropRareDeathLoot(int rareLootLevel)
|
||||
@@ -980,11 +976,11 @@ void LivingEntity::dropRareDeathLoot(int rareLootLevel)
|
||||
|
||||
}
|
||||
|
||||
void LivingEntity::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
|
||||
void LivingEntity::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
|
||||
{
|
||||
}
|
||||
|
||||
bool LivingEntity::onLadder()
|
||||
bool LivingEntity::onLadder()
|
||||
{
|
||||
int xt = Mth::floor(x);
|
||||
int yt = Mth::floor(bb->y0);
|
||||
@@ -995,24 +991,24 @@ bool LivingEntity::onLadder()
|
||||
return (iTile== Tile::ladder_Id) || (iTile== Tile::vine_Id);
|
||||
}
|
||||
|
||||
bool LivingEntity::isShootable()
|
||||
bool LivingEntity::isShootable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LivingEntity::isAlive()
|
||||
bool LivingEntity::isAlive()
|
||||
{
|
||||
return !removed && getHealth() > 0;
|
||||
}
|
||||
|
||||
void LivingEntity::causeFallDamage(float distance)
|
||||
void LivingEntity::causeFallDamage(float distance)
|
||||
{
|
||||
Entity::causeFallDamage(distance);
|
||||
MobEffectInstance *jumpBoost = getEffect(MobEffect::jump);
|
||||
float padding = jumpBoost != NULL ? jumpBoost->getAmplifier() + 1 : 0;
|
||||
|
||||
int dmg = (int) ceil(distance - 3 - padding);
|
||||
if (dmg > 0)
|
||||
if (dmg > 0)
|
||||
{
|
||||
// 4J - new sounds here brought forward from 1.2.3
|
||||
if (dmg > 4)
|
||||
@@ -1026,7 +1022,7 @@ void LivingEntity::causeFallDamage(float distance)
|
||||
hurt(DamageSource::fall, dmg);
|
||||
|
||||
int t = level->getTile( Mth::floor(x), Mth::floor(y - 0.2f - this->heightOffset), Mth::floor(z));
|
||||
if (t > 0)
|
||||
if (t > 0)
|
||||
{
|
||||
const Tile::SoundType *soundType = Tile::tiles[t]->soundType;
|
||||
MemSect(31);
|
||||
@@ -1036,7 +1032,7 @@ void LivingEntity::causeFallDamage(float distance)
|
||||
}
|
||||
}
|
||||
|
||||
void LivingEntity::animateHurt()
|
||||
void LivingEntity::animateHurt()
|
||||
{
|
||||
hurtTime = hurtDuration = 10;
|
||||
hurtDir = 0;
|
||||
@@ -1044,7 +1040,7 @@ void LivingEntity::animateHurt()
|
||||
|
||||
/**
|
||||
* Fetches the mob's armor value, from 0 (no armor) to 20 (full armor)
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int LivingEntity::getArmorValue()
|
||||
@@ -1111,7 +1107,7 @@ float LivingEntity::getDamageAfterMagicAbsorb(DamageSource *damageSource, float
|
||||
return damage;
|
||||
}
|
||||
|
||||
void LivingEntity::actuallyHurt(DamageSource *source, float dmg)
|
||||
void LivingEntity::actuallyHurt(DamageSource *source, float dmg)
|
||||
{
|
||||
if (isInvulnerable()) return;
|
||||
dmg = getDamageAfterArmorAbsorb(source, dmg);
|
||||
@@ -1183,9 +1179,9 @@ void LivingEntity::swing()
|
||||
}
|
||||
}
|
||||
|
||||
void LivingEntity::handleEntityEvent(byte id)
|
||||
void LivingEntity::handleEntityEvent(byte id)
|
||||
{
|
||||
if (id == EntityEvent::HURT)
|
||||
if (id == EntityEvent::HURT)
|
||||
{
|
||||
walkAnimSpeed = 1.5f;
|
||||
|
||||
@@ -1197,32 +1193,32 @@ void LivingEntity::handleEntityEvent(byte id)
|
||||
// 4J-PB -added because villagers have no sounds
|
||||
int iHurtSound=getHurtSound();
|
||||
if(iHurtSound!=-1)
|
||||
{
|
||||
{
|
||||
playSound(iHurtSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
|
||||
}
|
||||
MemSect(0);
|
||||
hurt(DamageSource::genericSource, 0);
|
||||
}
|
||||
else if (id == EntityEvent::DEATH)
|
||||
}
|
||||
else if (id == EntityEvent::DEATH)
|
||||
{
|
||||
MemSect(31);
|
||||
// 4J-PB -added because villagers have no sounds
|
||||
int iDeathSound=getDeathSound();
|
||||
if(iDeathSound!=-1)
|
||||
{
|
||||
{
|
||||
playSound(iDeathSound, getSoundVolume(), (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f);
|
||||
}
|
||||
MemSect(0);
|
||||
setHealth(0);
|
||||
die(DamageSource::genericSource);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
Entity::handleEntityEvent(id);
|
||||
}
|
||||
}
|
||||
|
||||
void LivingEntity::outOfWorld()
|
||||
void LivingEntity::outOfWorld()
|
||||
{
|
||||
hurt(DamageSource::outOfWorld, 4);
|
||||
}
|
||||
@@ -1282,7 +1278,7 @@ void LivingEntity::setSprinting(bool value)
|
||||
}
|
||||
}
|
||||
|
||||
float LivingEntity::getSoundVolume()
|
||||
float LivingEntity::getSoundVolume()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1297,12 +1293,12 @@ float LivingEntity::getVoicePitch()
|
||||
return (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f;
|
||||
}
|
||||
|
||||
bool LivingEntity::isImmobile()
|
||||
bool LivingEntity::isImmobile()
|
||||
{
|
||||
return getHealth() <= 0;
|
||||
}
|
||||
|
||||
void LivingEntity::teleportTo(double x, double y, double z)
|
||||
void LivingEntity::teleportTo(double x, double y, double z)
|
||||
{
|
||||
moveTo(x, y, z, yRot, xRot);
|
||||
}
|
||||
@@ -1352,12 +1348,12 @@ bool LivingEntity::shouldShowName()
|
||||
return false;
|
||||
}
|
||||
|
||||
Icon *LivingEntity::getItemInHandIcon(shared_ptr<ItemInstance> item, int layer)
|
||||
Icon *LivingEntity::getItemInHandIcon(shared_ptr<ItemInstance> item, int layer)
|
||||
{
|
||||
return item->getIcon();
|
||||
}
|
||||
|
||||
void LivingEntity::jumpFromGround()
|
||||
void LivingEntity::jumpFromGround()
|
||||
{
|
||||
yd = 0.42f;
|
||||
if (hasEffect(MobEffect::jump))
|
||||
@@ -1374,7 +1370,7 @@ void LivingEntity::jumpFromGround()
|
||||
this->hasImpulse = true;
|
||||
}
|
||||
|
||||
void LivingEntity::travel(float xa, float ya)
|
||||
void LivingEntity::travel(float xa, float ya)
|
||||
{
|
||||
#ifdef __PSVITA__
|
||||
// AP - dynamic_pointer_cast is a non-trivial call
|
||||
@@ -1386,7 +1382,7 @@ void LivingEntity::travel(float xa, float ya)
|
||||
#else
|
||||
shared_ptr<Player> thisPlayer = dynamic_pointer_cast<Player>(shared_from_this());
|
||||
#endif
|
||||
if (isInWater() && !(thisPlayer && thisPlayer->abilities.flying) )
|
||||
if (isInWater() && !(thisPlayer && thisPlayer->abilities.flying) )
|
||||
{
|
||||
double yo = y;
|
||||
moveRelative(xa, ya, useNewAi() ? 0.04f : 0.02f);
|
||||
@@ -1397,12 +1393,12 @@ void LivingEntity::travel(float xa, float ya)
|
||||
zd *= 0.80f;
|
||||
yd -= 0.02;
|
||||
|
||||
if (horizontalCollision && isFree(xd, yd + 0.6f - y + yo, zd))
|
||||
if (horizontalCollision && isFree(xd, yd + 0.6f - y + yo, zd))
|
||||
{
|
||||
yd = 0.3f;
|
||||
}
|
||||
}
|
||||
else if (isInLava() && !(thisPlayer && thisPlayer->abilities.flying) )
|
||||
}
|
||||
else if (isInLava() && !(thisPlayer && thisPlayer->abilities.flying) )
|
||||
{
|
||||
double yo = y;
|
||||
moveRelative(xa, ya, 0.02f);
|
||||
@@ -1412,19 +1408,19 @@ void LivingEntity::travel(float xa, float ya)
|
||||
zd *= 0.50f;
|
||||
yd -= 0.02;
|
||||
|
||||
if (horizontalCollision && isFree(xd, yd + 0.6f - y + yo, zd))
|
||||
if (horizontalCollision && isFree(xd, yd + 0.6f - y + yo, zd))
|
||||
{
|
||||
yd = 0.3f;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
float friction = 0.91f;
|
||||
if (onGround)
|
||||
if (onGround)
|
||||
{
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1, Mth::floor(z));
|
||||
if (t > 0)
|
||||
if (t > 0)
|
||||
{
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
}
|
||||
@@ -1445,16 +1441,16 @@ void LivingEntity::travel(float xa, float ya)
|
||||
moveRelative(xa, ya, speed);
|
||||
|
||||
friction = 0.91f;
|
||||
if (onGround)
|
||||
if (onGround)
|
||||
{
|
||||
friction = 0.6f * 0.91f;
|
||||
int t = level->getTile( Mth::floor(x), Mth::floor(bb->y0) - 1, Mth::floor(z));
|
||||
if (t > 0)
|
||||
if (t > 0)
|
||||
{
|
||||
friction = Tile::tiles[t]->friction * 0.91f;
|
||||
}
|
||||
}
|
||||
if (onLadder())
|
||||
if (onLadder())
|
||||
{
|
||||
float max = 0.15f;
|
||||
if (xd < -max) xd = -max;
|
||||
@@ -1469,7 +1465,7 @@ void LivingEntity::travel(float xa, float ya)
|
||||
|
||||
move(xd, yd, zd);
|
||||
|
||||
if (horizontalCollision && onLadder())
|
||||
if (horizontalCollision && onLadder())
|
||||
{
|
||||
yd = 0.2;
|
||||
}
|
||||
@@ -1570,12 +1566,12 @@ bool LivingEntity::doHurtTarget(shared_ptr<Entity> target)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LivingEntity::isSleeping()
|
||||
bool LivingEntity::isSleeping()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void LivingEntity::tick()
|
||||
void LivingEntity::tick()
|
||||
{
|
||||
Entity::tick();
|
||||
|
||||
@@ -1622,17 +1618,17 @@ void LivingEntity::tick()
|
||||
float walkSpeed = 0;
|
||||
oRun = run;
|
||||
float tRun = 0;
|
||||
if (sideDist > 0.05f * 0.05f)
|
||||
if (sideDist > 0.05f * 0.05f)
|
||||
{
|
||||
tRun = 1;
|
||||
walkSpeed = sqrt(sideDist) * 3;
|
||||
yBodyRotT = ((float) atan2(zd, xd) * 180 / (float) PI - 90);
|
||||
}
|
||||
if (attackAnim > 0)
|
||||
if (attackAnim > 0)
|
||||
{
|
||||
yBodyRotT = yRot;
|
||||
}
|
||||
if (!onGround)
|
||||
if (!onGround)
|
||||
{
|
||||
tRun = 0;
|
||||
}
|
||||
@@ -1686,10 +1682,10 @@ float LivingEntity::tickHeadTurn(float yBodyRotT, float walkSpeed)
|
||||
return walkSpeed;
|
||||
}
|
||||
|
||||
void LivingEntity::aiStep()
|
||||
void LivingEntity::aiStep()
|
||||
{
|
||||
if (noJumpDelay > 0) noJumpDelay--;
|
||||
if (lSteps > 0)
|
||||
if (lSteps > 0)
|
||||
{
|
||||
double xt = x + (lx - x) / lSteps;
|
||||
double yt = y + (ly - y) / lSteps;
|
||||
@@ -1716,10 +1712,8 @@ void LivingEntity::aiStep()
|
||||
if (collisions->size() > 0)
|
||||
{
|
||||
double yTop = 0;
|
||||
AUTO_VAR(itEnd, collisions->end());
|
||||
for (AUTO_VAR(it, collisions->begin()); it != itEnd; it++)
|
||||
for (const auto& ab : *collisions)
|
||||
{
|
||||
AABB *ab = *it; //collisions->at(i);
|
||||
if (ab->y1 > yTop) yTop = ab->y1;
|
||||
}
|
||||
|
||||
@@ -1740,14 +1734,14 @@ void LivingEntity::aiStep()
|
||||
if (abs(yd) < MIN_MOVEMENT_DISTANCE) yd = 0;
|
||||
if (abs(zd) < MIN_MOVEMENT_DISTANCE) zd = 0;
|
||||
|
||||
if (isImmobile())
|
||||
if (isImmobile())
|
||||
{
|
||||
jumping = false;
|
||||
xxa = 0;
|
||||
yya = 0;
|
||||
yRotA = 0;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
MemSect(25);
|
||||
if (isEffectiveAi())
|
||||
@@ -1765,13 +1759,13 @@ void LivingEntity::aiStep()
|
||||
MemSect(0);
|
||||
}
|
||||
|
||||
if (jumping)
|
||||
if (jumping)
|
||||
{
|
||||
if (isInWater() || isInLava() )
|
||||
if (isInWater() || isInLava() )
|
||||
{
|
||||
yd += 0.04f;
|
||||
}
|
||||
else if (onGround)
|
||||
else if (onGround)
|
||||
{
|
||||
if (noJumpDelay == 0)
|
||||
{
|
||||
@@ -1806,13 +1800,12 @@ void LivingEntity::pushEntities()
|
||||
{
|
||||
|
||||
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), this->bb->grow(0.2f, 0, 0.2f));
|
||||
if (entities != NULL && !entities->empty())
|
||||
if (entities != NULL && !entities->empty())
|
||||
{
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
for (auto& e : *entities)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
if (e->isPushable()) e->push(shared_from_this());
|
||||
if ( e && e->isPushable())
|
||||
e->push(shared_from_this());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1822,7 +1815,7 @@ void LivingEntity::doPush(shared_ptr<Entity> e)
|
||||
e->push(shared_from_this());
|
||||
}
|
||||
|
||||
void LivingEntity::rideTick()
|
||||
void LivingEntity::rideTick()
|
||||
{
|
||||
Entity::rideTick();
|
||||
oRun = run;
|
||||
@@ -1830,7 +1823,7 @@ void LivingEntity::rideTick()
|
||||
fallDistance = 0;
|
||||
}
|
||||
|
||||
void LivingEntity::lerpTo(double x, double y, double z, float yRot, float xRot, int steps)
|
||||
void LivingEntity::lerpTo(double x, double y, double z, float yRot, float xRot, int steps)
|
||||
{
|
||||
heightOffset = 0;
|
||||
lx = x;
|
||||
@@ -1846,7 +1839,7 @@ void LivingEntity::serverAiMobStep()
|
||||
{
|
||||
}
|
||||
|
||||
void LivingEntity::serverAiStep()
|
||||
void LivingEntity::serverAiStep()
|
||||
{
|
||||
noActionTime++;
|
||||
}
|
||||
@@ -1876,7 +1869,7 @@ void LivingEntity::take(shared_ptr<Entity> e, int orgCount)
|
||||
}
|
||||
}
|
||||
|
||||
bool LivingEntity::canSee(shared_ptr<Entity> target)
|
||||
bool LivingEntity::canSee(shared_ptr<Entity> target)
|
||||
{
|
||||
HitResult *hres = level->clip(Vec3::newTemp(x, y + getHeadHeight(), z), Vec3::newTemp(target->x, target->y + target->getHeadHeight(), target->z));
|
||||
bool retVal = (hres == NULL);
|
||||
@@ -1884,14 +1877,14 @@ bool LivingEntity::canSee(shared_ptr<Entity> target)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
Vec3 *LivingEntity::getLookAngle()
|
||||
Vec3 *LivingEntity::getLookAngle()
|
||||
{
|
||||
return getViewVector(1);
|
||||
}
|
||||
|
||||
Vec3 *LivingEntity::getViewVector(float a)
|
||||
Vec3 *LivingEntity::getViewVector(float a)
|
||||
{
|
||||
if (a == 1)
|
||||
if (a == 1)
|
||||
{
|
||||
float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||
float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - PI);
|
||||
@@ -1911,16 +1904,16 @@ Vec3 *LivingEntity::getViewVector(float a)
|
||||
return Vec3::newTemp(ySin * xCos, xSin, yCos * xCos);
|
||||
}
|
||||
|
||||
float LivingEntity::getAttackAnim(float a)
|
||||
float LivingEntity::getAttackAnim(float a)
|
||||
{
|
||||
float diff = attackAnim - oAttackAnim;
|
||||
if (diff < 0) diff += 1;
|
||||
return oAttackAnim + diff * a;
|
||||
}
|
||||
|
||||
Vec3 *LivingEntity::getPos(float a)
|
||||
Vec3 *LivingEntity::getPos(float a)
|
||||
{
|
||||
if (a == 1)
|
||||
if (a == 1)
|
||||
{
|
||||
return Vec3::newTemp(x, y, z);
|
||||
}
|
||||
@@ -1931,7 +1924,7 @@ Vec3 *LivingEntity::getPos(float a)
|
||||
return Vec3::newTemp(x, y, z);
|
||||
}
|
||||
|
||||
HitResult *LivingEntity::pick(double range, float a)
|
||||
HitResult *LivingEntity::pick(double range, float a)
|
||||
{
|
||||
Vec3 *from = getPos(a);
|
||||
Vec3 *b = getViewVector(a);
|
||||
@@ -1944,17 +1937,17 @@ bool LivingEntity::isEffectiveAi()
|
||||
return !level->isClientSide;
|
||||
}
|
||||
|
||||
bool LivingEntity::isPickable()
|
||||
bool LivingEntity::isPickable()
|
||||
{
|
||||
return !removed;
|
||||
}
|
||||
|
||||
bool LivingEntity::isPushable()
|
||||
bool LivingEntity::isPushable()
|
||||
{
|
||||
return !removed;
|
||||
}
|
||||
|
||||
float LivingEntity::getHeadHeight()
|
||||
float LivingEntity::getHeadHeight()
|
||||
{
|
||||
return bbHeight * 0.85f;
|
||||
}
|
||||
|
||||
@@ -20,18 +20,18 @@ MapItem::MapItem(int id) : ComplexItem(id)
|
||||
}
|
||||
|
||||
shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum, Level *level)
|
||||
{
|
||||
std::wstring id = wstring( L"map_" ) + _toString(idNum);
|
||||
{
|
||||
std::wstring id = wstring( L"map_" ) + std::to_wstring(idNum);
|
||||
shared_ptr<MapItemSavedData> mapItemSavedData = dynamic_pointer_cast<MapItemSavedData>(level->getSavedData(typeid(MapItemSavedData), id));
|
||||
|
||||
if (mapItemSavedData == NULL)
|
||||
if (mapItemSavedData == NULL)
|
||||
{
|
||||
// 4J Stu - This call comes from ClientConnection, but i don't see why we should be trying to work out
|
||||
// the id again when it's passed as a param. In any case that won't work with the new map setup
|
||||
//int aux = level->getFreeAuxValueFor(L"map");
|
||||
int aux = idNum;
|
||||
|
||||
id = wstring( L"map_" ) + _toString(aux);
|
||||
id = wstring( L"map_" ) + std::to_wstring(aux);
|
||||
mapItemSavedData = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
|
||||
|
||||
level->setSavedData(id, (shared_ptr<SavedData> ) mapItemSavedData);
|
||||
@@ -43,7 +43,7 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(short idNum, Level *level)
|
||||
shared_ptr<MapItemSavedData> MapItem::getSavedData(shared_ptr<ItemInstance> itemInstance, Level *level)
|
||||
{
|
||||
MemSect(31);
|
||||
std::wstring id = wstring( L"map_" ) + _toString(itemInstance->getAuxValue() );
|
||||
std::wstring id = wstring( L"map_" ) + std::to_wstring(itemInstance->getAuxValue() );
|
||||
MemSect(0);
|
||||
shared_ptr<MapItemSavedData> mapItemSavedData = dynamic_pointer_cast<MapItemSavedData>( level->getSavedData(typeid(MapItemSavedData), id ) );
|
||||
|
||||
@@ -54,7 +54,7 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(shared_ptr<ItemInstance> item
|
||||
// In any case that won't work with the new map setup
|
||||
//itemInstance->setAuxValue(level->getFreeAuxValueFor(L"map"));
|
||||
|
||||
id = wstring( L"map_" ) + _toString(itemInstance->getAuxValue() );
|
||||
id = wstring( L"map_" ) + std::to_wstring(itemInstance->getAuxValue() );
|
||||
mapItemSavedData = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
|
||||
|
||||
newData = true;
|
||||
@@ -75,7 +75,7 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(shared_ptr<ItemInstance> item
|
||||
mapItemSavedData->z = Math::round(level->getLevelData()->getZSpawn() / scale) * scale;
|
||||
#endif
|
||||
mapItemSavedData->dimension = (byte) level->dimension->id;
|
||||
|
||||
|
||||
mapItemSavedData->setDirty();
|
||||
|
||||
level->setSavedData(id, (shared_ptr<SavedData> ) mapItemSavedData);
|
||||
@@ -86,7 +86,7 @@ shared_ptr<MapItemSavedData> MapItem::getSavedData(shared_ptr<ItemInstance> item
|
||||
|
||||
void MapItem::update(Level *level, shared_ptr<Entity> player, shared_ptr<MapItemSavedData> data)
|
||||
{
|
||||
if ( (level->dimension->id != data->dimension) || !player->instanceof(eTYPE_PLAYER) )
|
||||
if ( (level->dimension->id != data->dimension) || !player->instanceof(eTYPE_PLAYER) )
|
||||
{
|
||||
// Wrong dimension, abort
|
||||
return;
|
||||
@@ -148,8 +148,8 @@ void MapItem::update(Level *level, shared_ptr<Entity> player, shared_ptr<MapItem
|
||||
if (((ss >> 20) & 1) == 0) count[Tile::dirt_Id] += 10;
|
||||
else count[Tile::stone_Id] += 10;
|
||||
hh = 100;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int xs = 0; xs < scale; xs++)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ void MapItem::update(Level *level, shared_ptr<Entity> player, shared_ptr<MapItem
|
||||
{
|
||||
int yy = lc->getHeightmap(xs + xso, zs + zso) + 1;
|
||||
int t = 0;
|
||||
if (yy > 1)
|
||||
if (yy > 1)
|
||||
{
|
||||
bool ok = false;
|
||||
do
|
||||
@@ -215,7 +215,7 @@ void MapItem::update(Level *level, shared_ptr<Entity> player, shared_ptr<MapItem
|
||||
if (diff < -0.6) br = 0;
|
||||
|
||||
int col = 0;
|
||||
if (tBest > 0)
|
||||
if (tBest > 0)
|
||||
{
|
||||
MaterialColor *mc = Tile::tiles[tBest]->material->color;
|
||||
if (mc == MaterialColor::water)
|
||||
@@ -245,7 +245,7 @@ void MapItem::update(Level *level, shared_ptr<Entity> player, shared_ptr<MapItem
|
||||
data->colors[x + z * w] = newColor;
|
||||
}
|
||||
}
|
||||
if (yd0 <= yd1)
|
||||
if (yd0 <= yd1)
|
||||
{
|
||||
data->setDirty(x, yd0, yd1);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ void MapItem::inventoryTick(shared_ptr<ItemInstance> itemInstance, Level *level,
|
||||
if (level->isClientSide) return;
|
||||
|
||||
shared_ptr<MapItemSavedData> data = getSavedData(itemInstance, level);
|
||||
if ( owner->instanceof(eTYPE_PLAYER) )
|
||||
if ( owner->instanceof(eTYPE_PLAYER) )
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(owner);
|
||||
|
||||
@@ -276,7 +276,7 @@ void MapItem::inventoryTick(shared_ptr<ItemInstance> itemInstance, Level *level,
|
||||
ownersData->tickCarriedBy(player, itemInstance );
|
||||
ownersData->mergeInMapData(data);
|
||||
player->inventoryMenu->broadcastChanges();
|
||||
|
||||
|
||||
data = ownersData;
|
||||
}
|
||||
else
|
||||
@@ -285,13 +285,13 @@ void MapItem::inventoryTick(shared_ptr<ItemInstance> itemInstance, Level *level,
|
||||
}
|
||||
}
|
||||
|
||||
if (selected)
|
||||
if (selected)
|
||||
{
|
||||
update(level, owner, data);
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<Packet> MapItem::getUpdatePacket(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
||||
shared_ptr<Packet> MapItem::getUpdatePacket(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
||||
{
|
||||
charArray data = MapItem::getSavedData(itemInstance, level)->getUpdatePacket(itemInstance, level, player);
|
||||
|
||||
@@ -302,7 +302,7 @@ shared_ptr<Packet> MapItem::getUpdatePacket(shared_ptr<ItemInstance> itemInstanc
|
||||
return retval;
|
||||
}
|
||||
|
||||
void MapItem::onCraftedBy(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
||||
void MapItem::onCraftedBy(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
||||
{
|
||||
wchar_t buf[64];
|
||||
|
||||
@@ -318,7 +318,7 @@ void MapItem::onCraftedBy(shared_ptr<ItemInstance> itemInstance, Level *level, s
|
||||
#endif
|
||||
|
||||
itemInstance->setAuxValue(level->getAuxValueForMap(player->getXuid(), player->dimension, centreXC, centreZC, mapScale));
|
||||
|
||||
|
||||
swprintf(buf,64,L"map_%d", itemInstance->getAuxValue());
|
||||
std::wstring id = wstring(buf);
|
||||
|
||||
@@ -330,7 +330,7 @@ void MapItem::onCraftedBy(shared_ptr<ItemInstance> itemInstance, Level *level, s
|
||||
data = shared_ptr<MapItemSavedData>( new MapItemSavedData(id) );
|
||||
}
|
||||
level->setSavedData(id, (shared_ptr<SavedData> ) data);
|
||||
|
||||
|
||||
data->scale = mapScale;
|
||||
// 4J-PB - for Xbox maps, we'll centre them on the origin of the world, since we can fit the whole world in our map
|
||||
data->x = centreXC;
|
||||
|
||||
@@ -64,7 +64,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
|
||||
if (--sendPosTick < 0)
|
||||
{
|
||||
sendPosTick = 4;
|
||||
|
||||
|
||||
unsigned int playerDecorationsSize = (int)parent->decorations.size();
|
||||
unsigned int nonPlayerDecorationsSize = (int)parent->nonPlayerDecorations.size();
|
||||
charArray data = charArray( (playerDecorationsSize + nonPlayerDecorationsSize ) * DEC_PACKET_BYTES + 1);
|
||||
@@ -79,7 +79,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
|
||||
data[i * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF));
|
||||
#endif
|
||||
data[i * DEC_PACKET_BYTES + 2] = md->x;
|
||||
data[i * DEC_PACKET_BYTES + 3] = md->y;
|
||||
data[i * DEC_PACKET_BYTES + 3] = md->y;
|
||||
data[i * DEC_PACKET_BYTES + 4] = md->entityId & 0xFF;
|
||||
data[i * DEC_PACKET_BYTES + 5] = (md->entityId>>8) & 0xFF;
|
||||
data[i * DEC_PACKET_BYTES + 6] = (md->entityId>>16) & 0xFF;
|
||||
@@ -87,9 +87,9 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
|
||||
data[i * DEC_PACKET_BYTES + 7] |= md->visible ? 0x80 : 0x0;
|
||||
}
|
||||
unsigned int dataIndex = playerDecorationsSize;
|
||||
for(AUTO_VAR(it, parent->nonPlayerDecorations.begin()); it != parent->nonPlayerDecorations.end(); ++it)
|
||||
for(auto it : parent->nonPlayerDecorations)
|
||||
{
|
||||
MapDecoration *md = it->second;
|
||||
MapDecoration *md = it.second;
|
||||
#ifdef _LARGE_WORLDS
|
||||
data[dataIndex * DEC_PACKET_BYTES + 1] = (char) (md->img);
|
||||
data[dataIndex * DEC_PACKET_BYTES + 8] = (char) (md->rot & 0xF);
|
||||
@@ -97,7 +97,7 @@ charArray MapItemSavedData::HoldingPlayer::nextUpdatePacket(shared_ptr<ItemInsta
|
||||
data[dataIndex * DEC_PACKET_BYTES + 1] = (char) ((md->img << 4) | (md->rot & 0xF));
|
||||
#endif
|
||||
data[dataIndex * DEC_PACKET_BYTES + 2] = md->x;
|
||||
data[dataIndex * DEC_PACKET_BYTES + 3] = md->y;
|
||||
data[dataIndex * DEC_PACKET_BYTES + 3] = md->y;
|
||||
data[dataIndex * DEC_PACKET_BYTES + 4] = md->entityId & 0xFF;
|
||||
data[dataIndex * DEC_PACKET_BYTES + 5] = (md->entityId>>8) & 0xFF;
|
||||
data[dataIndex * DEC_PACKET_BYTES + 6] = (md->entityId>>16) & 0xFF;
|
||||
@@ -246,21 +246,21 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
delete decorations[i];
|
||||
}
|
||||
decorations.clear();
|
||||
|
||||
|
||||
// 4J Stu - Put this block back in if you want to display entity positions on a map (see below)
|
||||
#if 0
|
||||
nonPlayerDecorations.clear();
|
||||
#endif
|
||||
bool addedPlayers = false;
|
||||
for (AUTO_VAR(it, carriedBy.begin()); it != carriedBy.end(); )
|
||||
{
|
||||
for (auto it = carriedBy.begin(); it != carriedBy.end();)
|
||||
{
|
||||
shared_ptr<HoldingPlayer> hp = *it;
|
||||
|
||||
// 4J Stu - Players in the same dimension as an item frame with a map need to be sent this data, so don't remove them
|
||||
if (hp->player->removed ) //|| (!hp->player->inventory->contains(item) && !item->isFramed() ))
|
||||
{
|
||||
AUTO_VAR(it2, carriedByPlayers.find( (shared_ptr<Player> ) hp->player ));
|
||||
if( it2 != carriedByPlayers.end() )
|
||||
auto it2 = carriedByPlayers.find(shared_ptr<Player>(hp->player));
|
||||
if( it2 != carriedByPlayers.end() )
|
||||
{
|
||||
carriedByPlayers.erase( it2 );
|
||||
}
|
||||
@@ -275,9 +275,8 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
{
|
||||
bool atLeastOnePlayerInTheEnd = false;
|
||||
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
|
||||
for(AUTO_VAR(it3, players->players.begin()); it3 != players->players.end(); ++it3)
|
||||
for( const auto& serverPlayer : players->players)
|
||||
{
|
||||
shared_ptr<ServerPlayer> serverPlayer = *it3;
|
||||
if(serverPlayer->dimension == 1)
|
||||
{
|
||||
atLeastOnePlayerInTheEnd = true;
|
||||
@@ -285,8 +284,8 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
}
|
||||
}
|
||||
|
||||
AUTO_VAR(currentPortalDecoration, nonPlayerDecorations.find( END_PORTAL_DECORATION_KEY ));
|
||||
if( currentPortalDecoration == nonPlayerDecorations.end() && atLeastOnePlayerInTheEnd)
|
||||
auto currentPortalDecoration = nonPlayerDecorations.find(END_PORTAL_DECORATION_KEY);
|
||||
if( currentPortalDecoration == nonPlayerDecorations.end() && atLeastOnePlayerInTheEnd)
|
||||
{
|
||||
float origX = 0.0f;
|
||||
float origZ = 0.0f;
|
||||
@@ -330,7 +329,7 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
if (item->isFramed())
|
||||
{
|
||||
//addDecoration(1, player.level, "frame-" + item.getFrame().entityId, item.getFrame().xTile, item.getFrame().zTile, item.getFrame().dir * 90);
|
||||
|
||||
|
||||
if( nonPlayerDecorations.find( item->getFrame()->entityId ) == nonPlayerDecorations.end() )
|
||||
{
|
||||
float xd = (float) ( item->getFrame()->xTile - x ) / (1 << scale);
|
||||
@@ -361,10 +360,8 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
|
||||
// 4J Stu - Put this block back in if you want to display entity positions on a map (see above as well)
|
||||
#if 0
|
||||
for(AUTO_VAR(it,playerLevel->entities.begin()); it != playerLevel->entities.end(); ++it)
|
||||
for(auto& ent : playerLevel->entities)
|
||||
{
|
||||
shared_ptr<Entity> ent = *it;
|
||||
|
||||
if((ent->GetType() & eTYPE_ENEMY) == 0) continue;
|
||||
|
||||
float xd = (float) ( ent->x - x ) / (1 << scale);
|
||||
@@ -400,9 +397,8 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
addedPlayers = true;
|
||||
|
||||
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
|
||||
for(AUTO_VAR(it3, players->players.begin()); it3 != players->players.end(); ++it3)
|
||||
for(auto& decorationPlayer : players->players)
|
||||
{
|
||||
shared_ptr<ServerPlayer> decorationPlayer = *it3;
|
||||
if(decorationPlayer!=NULL && decorationPlayer->dimension == this->dimension)
|
||||
{
|
||||
float xd = (float) (decorationPlayer->x - x) / (1 << scale);
|
||||
@@ -481,8 +477,8 @@ void MapItemSavedData::tickCarriedBy(shared_ptr<Player> player, shared_ptr<ItemI
|
||||
|
||||
charArray MapItemSavedData::getUpdatePacket(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
||||
{
|
||||
AUTO_VAR(it, carriedByPlayers.find(player));
|
||||
if (it == carriedByPlayers.end() ) return charArray();
|
||||
auto it = carriedByPlayers.find(player);
|
||||
if (it == carriedByPlayers.end() ) return charArray();
|
||||
|
||||
shared_ptr<HoldingPlayer> hp = it->second;
|
||||
return hp->nextUpdatePacket(itemInstance);
|
||||
@@ -492,10 +488,8 @@ void MapItemSavedData::setDirty(int x, int y0, int y1)
|
||||
{
|
||||
SavedData::setDirty();
|
||||
|
||||
AUTO_VAR(itEnd, carriedBy.end());
|
||||
for (AUTO_VAR(it, carriedBy.begin()); it != itEnd; it++)
|
||||
for (auto& hp : carriedBy)
|
||||
{
|
||||
shared_ptr<HoldingPlayer> hp = *it; //carriedBy.at(i);
|
||||
if (hp->rowsDirtyMin[x] < 0 || hp->rowsDirtyMin[x] > y0) hp->rowsDirtyMin[x] = y0;
|
||||
if (hp->rowsDirtyMax[x] < 0 || hp->rowsDirtyMax[x] < y1) hp->rowsDirtyMax[x] = y1;
|
||||
}
|
||||
@@ -547,9 +541,9 @@ void MapItemSavedData::handleComplexItemData(charArray &data)
|
||||
shared_ptr<MapItemSavedData::HoldingPlayer> MapItemSavedData::getHoldingPlayer(shared_ptr<Player> player)
|
||||
{
|
||||
shared_ptr<HoldingPlayer> hp = nullptr;
|
||||
AUTO_VAR(it,carriedByPlayers.find(player));
|
||||
auto it = carriedByPlayers.find(player);
|
||||
|
||||
if (it == carriedByPlayers.end())
|
||||
if (it == carriedByPlayers.end())
|
||||
{
|
||||
hp = shared_ptr<HoldingPlayer>( new HoldingPlayer(player, this) );
|
||||
carriedByPlayers[player] = hp;
|
||||
@@ -587,7 +581,7 @@ void MapItemSavedData::mergeInMapData(shared_ptr<MapItemSavedData> dataToAdd)
|
||||
colors[x + z * w] = newColor;
|
||||
}
|
||||
}
|
||||
if (yd0 <= yd1)
|
||||
if (yd0 <= yd1)
|
||||
{
|
||||
setDirty(x, yd0, yd1);
|
||||
}
|
||||
@@ -598,7 +592,7 @@ void MapItemSavedData::removeItemFrameDecoration(shared_ptr<ItemInstance> item)
|
||||
{
|
||||
if ( !item )
|
||||
return;
|
||||
|
||||
|
||||
std::shared_ptr<ItemFrame> frame = item->getFrame();
|
||||
if ( !frame )
|
||||
return;
|
||||
|
||||
@@ -32,7 +32,7 @@ McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstr
|
||||
m_saveFile->createFile(ConsoleSavePath(L"r.-1.0.mcr"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef SPLIT_SAVES
|
||||
ConsoleSavePath currentFile = ConsoleSavePath( m_prefix + wstring( L"entities.dat" ) );
|
||||
|
||||
@@ -64,9 +64,9 @@ McRegionChunkStorage::McRegionChunkStorage(ConsoleSaveFile *saveFile, const wstr
|
||||
|
||||
McRegionChunkStorage::~McRegionChunkStorage()
|
||||
{
|
||||
for(AUTO_VAR(it,m_entityData.begin()); it != m_entityData.end(); ++it)
|
||||
for(auto& it : m_entityData)
|
||||
{
|
||||
delete it->second.data;
|
||||
delete it.second.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ LevelChunk *McRegionChunkStorage::load(Level *level, int x, int z)
|
||||
{
|
||||
__int64 index = ((__int64)(x) << 32) | (((__int64)(z))&0x00000000FFFFFFFF);
|
||||
|
||||
AUTO_VAR(it, m_entityData.find(index));
|
||||
if(it != m_entityData.end())
|
||||
auto it = m_entityData.find(index);
|
||||
if(it != m_entityData.end())
|
||||
{
|
||||
delete it->second.data;
|
||||
m_entityData.erase(it);
|
||||
@@ -262,8 +262,8 @@ void McRegionChunkStorage::saveEntities(Level *level, LevelChunk *levelChunk)
|
||||
}
|
||||
else
|
||||
{
|
||||
AUTO_VAR(it, m_entityData.find(index));
|
||||
if(it != m_entityData.end())
|
||||
auto it = m_entityData.find(index);
|
||||
if(it != m_entityData.end())
|
||||
{
|
||||
m_entityData.erase(it);
|
||||
}
|
||||
@@ -277,9 +277,9 @@ void McRegionChunkStorage::loadEntities(Level *level, LevelChunk *levelChunk)
|
||||
{
|
||||
#ifdef SPLIT_SAVES
|
||||
__int64 index = ((__int64)(levelChunk->x) << 32) | (((__int64)(levelChunk->z))&0x00000000FFFFFFFF);
|
||||
|
||||
AUTO_VAR(it, m_entityData.find(index));
|
||||
if(it != m_entityData.end())
|
||||
|
||||
auto it = m_entityData.find(index);
|
||||
if(it != m_entityData.end())
|
||||
{
|
||||
ByteArrayInputStream bais(it->second);
|
||||
DataInputStream dis(&bais);
|
||||
@@ -308,10 +308,10 @@ void McRegionChunkStorage::flush()
|
||||
PIXBeginNamedEvent(0,"Writing to stream");
|
||||
dos.writeInt(m_entityData.size());
|
||||
|
||||
for(AUTO_VAR(it,m_entityData.begin()); it != m_entityData.end(); ++it)
|
||||
for(auto& it : m_entityData)
|
||||
{
|
||||
dos.writeLong(it->first);
|
||||
dos.write(it->second,0,it->second.length);
|
||||
dos.writeLong(it.first);
|
||||
dos.write(it.second,0,it.second.length);
|
||||
}
|
||||
bos.flush();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
@@ -20,13 +20,13 @@ McRegionLevelStorage::~McRegionLevelStorage()
|
||||
RegionFileCache::clear();
|
||||
}
|
||||
|
||||
ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
{
|
||||
//File folder = getFolder();
|
||||
|
||||
if (dynamic_cast<HellDimension *>(dimension) != NULL)
|
||||
{
|
||||
|
||||
|
||||
if(app.GetResetNether())
|
||||
{
|
||||
#ifdef SPLIT_SAVES
|
||||
@@ -34,19 +34,19 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
if(netherFiles!=NULL)
|
||||
{
|
||||
DWORD bytesWritten = 0;
|
||||
for(AUTO_VAR(it, netherFiles->begin()); it != netherFiles->end(); ++it)
|
||||
for(auto& netherFile : *netherFiles)
|
||||
{
|
||||
m_saveFile->zeroFile(*it, (*it)->getFileSize(), &bytesWritten);
|
||||
m_saveFile->zeroFile(netherFile, netherFile->getFileSize(), &bytesWritten);
|
||||
}
|
||||
delete netherFiles;
|
||||
}
|
||||
#else
|
||||
vector<FileEntry *> *netherFiles = m_saveFile->getFilesWithPrefix(LevelStorage::NETHER_FOLDER);
|
||||
if(netherFiles!=NULL)
|
||||
{
|
||||
for(AUTO_VAR(it, netherFiles->begin()); it != netherFiles->end(); ++it)
|
||||
{
|
||||
for(auto& netherFile : *netherFiles)
|
||||
{
|
||||
m_saveFile->deleteFile(*it);
|
||||
m_saveFile->deleteFile(netherFile);
|
||||
}
|
||||
delete netherFiles;
|
||||
}
|
||||
@@ -56,13 +56,13 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
|
||||
return new McRegionChunkStorage(m_saveFile, LevelStorage::NETHER_FOLDER);
|
||||
}
|
||||
|
||||
|
||||
if (dynamic_cast<TheEndDimension *>(dimension))
|
||||
{
|
||||
//File dir2 = new File(folder, LevelStorage.ENDER_FOLDER);
|
||||
//dir2.mkdirs();
|
||||
//return new ThreadedMcRegionChunkStorage(dir2);
|
||||
|
||||
|
||||
// 4J-PB - save version 0 at this point means it's a create new world
|
||||
int iSaveVersion=m_saveFile->getSaveVersion();
|
||||
|
||||
@@ -75,10 +75,10 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
|
||||
// 4J-PB - There will be no End in early saves
|
||||
if(endFiles!=NULL)
|
||||
{
|
||||
for(AUTO_VAR(it, endFiles->begin()); it != endFiles->end(); ++it)
|
||||
{
|
||||
for(auto& endFile : *endFiles)
|
||||
{
|
||||
m_saveFile->deleteFile(*it);
|
||||
m_saveFile->deleteFile(endFile);
|
||||
}
|
||||
delete endFiles;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension)
|
||||
return new McRegionChunkStorage(m_saveFile, L"");
|
||||
}
|
||||
|
||||
void McRegionLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
|
||||
void McRegionLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr<Player> > *players)
|
||||
{
|
||||
levelData->setVersion(MCREGION_VERSION_ID);
|
||||
MemSect(38);
|
||||
@@ -97,7 +97,7 @@ void McRegionLevelStorage::saveLevelData(LevelData *levelData, vector<shared_ptr
|
||||
MemSect(0);
|
||||
}
|
||||
|
||||
void McRegionLevelStorage::closeAll()
|
||||
void McRegionLevelStorage::closeAll()
|
||||
{
|
||||
RegionFileCache::clear();
|
||||
}
|
||||
@@ -39,12 +39,11 @@ vector<LevelSummary *> *McRegionLevelStorageSource::getLevelList()
|
||||
#if 0
|
||||
vector<File *> *subFolders = baseDir.listFiles();
|
||||
File *file;
|
||||
AUTO_VAR(itEnd, subFolders->end());
|
||||
for (AUTO_VAR(it, subFolders->begin()); it != itEnd; it++)
|
||||
for (auto& subFolder : *subFolders)
|
||||
{
|
||||
file = *it; //subFolders->at(i);
|
||||
file = subFolder; //subFolders->at(i);
|
||||
|
||||
if (file->isDirectory())
|
||||
if (file->isDirectory())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -74,13 +73,13 @@ void McRegionLevelStorageSource::clearAll()
|
||||
{
|
||||
}
|
||||
|
||||
shared_ptr<LevelStorage> McRegionLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir)
|
||||
shared_ptr<LevelStorage> McRegionLevelStorageSource::selectLevel(ConsoleSaveFile *saveFile, const wstring& levelId, bool createPlayerDir)
|
||||
{
|
||||
// return new LevelStorageProfilerDecorator(new McRegionLevelStorage(baseDir, levelId, createPlayerDir));
|
||||
return shared_ptr<LevelStorage>(new McRegionLevelStorage(saveFile, baseDir, levelId, createPlayerDir));
|
||||
}
|
||||
|
||||
bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId)
|
||||
bool McRegionLevelStorageSource::isConvertible(ConsoleSaveFile *saveFile, const wstring& levelId)
|
||||
{
|
||||
// check if there is old file format level data
|
||||
LevelData *levelData = getDataTagFor(saveFile, levelId);
|
||||
@@ -145,7 +144,7 @@ bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const w
|
||||
}
|
||||
|
||||
int totalCount = normalRegions->size() + netherRegions->size() + enderRegions.size() + normalBaseFolders->size() + netherBaseFolders->size() + enderBaseFolders.size();
|
||||
|
||||
|
||||
// System.out.println("Total conversion count is " + totalCount); 4J Jev, TODO
|
||||
|
||||
// convert normal world
|
||||
@@ -173,16 +172,15 @@ bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile *saveFile, const w
|
||||
|
||||
#if 0
|
||||
// 4J - not required anymore
|
||||
void McRegionLevelStorageSource::addRegions(File &baseFolder, vector<ChunkFile *> *dest, vector<File *> *firstLevelFolders)
|
||||
void McRegionLevelStorageSource::addRegions(File &baseFolder, vector<ChunkFile *> *dest, vector<File *> *firstLevelFolders)
|
||||
{
|
||||
FolderFilter folderFilter;
|
||||
ChunkFilter chunkFilter;
|
||||
|
||||
File *folder1;
|
||||
vector<File *> *folderLevel1 = baseFolder.listFiles((FileFilter *) &folderFilter);
|
||||
AUTO_VAR(itEnd, folderLevel1->end());
|
||||
for (AUTO_VAR(it, folderLevel1->begin()); it != itEnd; it++)
|
||||
{
|
||||
for (auto it = folderLevel1->begin(); it != folderLevel1->end(); it++)
|
||||
{
|
||||
folder1 = *it; //folderLevel1->at(i1);
|
||||
|
||||
// keep this for the clean-up process later on
|
||||
@@ -190,17 +188,17 @@ void McRegionLevelStorageSource::addRegions(File &baseFolder, vector<ChunkFile *
|
||||
|
||||
File *folder2;
|
||||
vector<File *> *folderLevel2 = folder1->listFiles(&folderFilter);
|
||||
AUTO_VAR(itEnd2, folderLevel2->end());
|
||||
for (AUTO_VAR(it2, folderLevel2->begin()); it2 != itEnd; it2++)
|
||||
auto itEnd2 = folderLevel2->end();
|
||||
for ( auto it2 = folderLevel2->begin(); it2 != itEnd2; it2++)
|
||||
{
|
||||
folder2 = *it2; //folderLevel2->at(i2);
|
||||
|
||||
vector<File *> *chunkFiles = folder2->listFiles((FileFilter *) &chunkFilter);
|
||||
|
||||
File *chunk;
|
||||
AUTO_VAR(itEndFile, chunkFiles->end());
|
||||
for (AUTO_VAR(itFile, chunkFiles->begin()); itFile != itEndFile; itFile++)
|
||||
{
|
||||
auto itEndFile = chunkFiles->end();
|
||||
for (auto itFile = chunkFiles->begin(); itFile != itEndFile; itFile++)
|
||||
{
|
||||
chunk = *itFile; //chunkFiles->at(i3);
|
||||
|
||||
dest->push_back(new ChunkFile(chunk));
|
||||
@@ -210,7 +208,7 @@ void McRegionLevelStorageSource::addRegions(File &baseFolder, vector<ChunkFile *
|
||||
}
|
||||
#endif
|
||||
|
||||
void McRegionLevelStorageSource::convertRegions(File &baseFolder, vector<ChunkFile *> *chunkFiles, int currentCount, int totalCount, ProgressListener *progress)
|
||||
void McRegionLevelStorageSource::convertRegions(File &baseFolder, vector<ChunkFile *> *chunkFiles, int currentCount, int totalCount, ProgressListener *progress)
|
||||
{
|
||||
assert( false );
|
||||
|
||||
@@ -222,10 +220,9 @@ void McRegionLevelStorageSource::convertRegions(File &baseFolder, vector<ChunkFi
|
||||
byteArray buffer = byteArray(4096);
|
||||
|
||||
ChunkFile *chunkFile;
|
||||
AUTO_VAR(itEnd, chunkFiles->end());
|
||||
for (AUTO_VAR(it, chunkFiles->begin()); it != itEnd; it++)
|
||||
for (auto& it : *chunkFiles)
|
||||
{
|
||||
chunkFile = *it; //chunkFiles->at(i1);
|
||||
chunkFile = it; //chunkFiles->at(i1);
|
||||
|
||||
// Matcher matcher = ChunkFilter.chunkFilePattern.matcher(chunkFile.getName());
|
||||
// if (!matcher.matches()) {
|
||||
@@ -238,7 +235,7 @@ void McRegionLevelStorageSource::convertRegions(File &baseFolder, vector<ChunkFi
|
||||
int z = chunkFile->getZ();
|
||||
|
||||
RegionFile *region = RegionFileCache::getRegionFile(baseFolder, x, z);
|
||||
if (!region->hasChunk(x & 31, z & 31))
|
||||
if (!region->hasChunk(x & 31, z & 31))
|
||||
{
|
||||
FileInputStream fis = new BufferedInputStream(FileInputStream(*chunkFile->getFile()));
|
||||
DataInputStream istream = DataInputStream(&fis); // 4J - was new GZIPInputStream as well
|
||||
@@ -271,12 +268,8 @@ void McRegionLevelStorageSource::convertRegions(File &baseFolder, vector<ChunkFi
|
||||
|
||||
void McRegionLevelStorageSource::eraseFolders(vector<File *> *folders, int currentCount, int totalCount, ProgressListener *progress)
|
||||
{
|
||||
File *folder;
|
||||
AUTO_VAR(itEnd, folders->end());
|
||||
for (AUTO_VAR(it, folders->begin()); it != itEnd; it++)
|
||||
for (File *folder : *folders)
|
||||
{
|
||||
folder = *it; //folders->at(i);
|
||||
|
||||
vector<File *> *files = folder->listFiles();
|
||||
deleteRecursive(files);
|
||||
folder->_delete();
|
||||
@@ -289,7 +282,7 @@ void McRegionLevelStorageSource::eraseFolders(vector<File *> *folders, int curre
|
||||
|
||||
#if 0
|
||||
// 4J - not required anymore
|
||||
bool McRegionLevelStorageSource::FolderFilter::accept(File *file)
|
||||
bool McRegionLevelStorageSource::FolderFilter::accept(File *file)
|
||||
{
|
||||
if (file->isDirectory())
|
||||
{
|
||||
@@ -300,23 +293,23 @@ bool McRegionLevelStorageSource::FolderFilter::accept(File *file)
|
||||
}
|
||||
|
||||
|
||||
bool McRegionLevelStorageSource::ChunkFilter::accept(File *dir, const wstring& name)
|
||||
bool McRegionLevelStorageSource::ChunkFilter::accept(File *dir, const wstring& name)
|
||||
{
|
||||
Matcher matcher( chunkFilePattern, name );
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
|
||||
McRegionLevelStorageSource::ChunkFile::ChunkFile(File *file)
|
||||
McRegionLevelStorageSource::ChunkFile::ChunkFile(File *file)
|
||||
{
|
||||
this->file = file;
|
||||
|
||||
Matcher matcher( ChunkFilter::chunkFilePattern, file->getName() );
|
||||
if (matcher.matches())
|
||||
if (matcher.matches())
|
||||
{
|
||||
x = Integer::parseInt(matcher.group(1), 36);
|
||||
z = Integer::parseInt(matcher.group(2), 36);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x = 0;
|
||||
@@ -348,17 +341,17 @@ bool McRegionLevelStorageSource::ChunkFile::operator<( ChunkFile *b )
|
||||
return compareTo( b ) < 0;
|
||||
}
|
||||
|
||||
File *McRegionLevelStorageSource::ChunkFile::getFile()
|
||||
File *McRegionLevelStorageSource::ChunkFile::getFile()
|
||||
{
|
||||
return (File *) file;
|
||||
}
|
||||
|
||||
int McRegionLevelStorageSource::ChunkFile::getX()
|
||||
int McRegionLevelStorageSource::ChunkFile::getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
int McRegionLevelStorageSource::ChunkFile::getZ()
|
||||
int McRegionLevelStorageSource::ChunkFile::getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ MerchantRecipeList::MerchantRecipeList(CompoundTag *tag)
|
||||
|
||||
MerchantRecipeList::~MerchantRecipeList()
|
||||
{
|
||||
for(AUTO_VAR(it, m_recipes.begin()); it != m_recipes.end(); ++it)
|
||||
for(auto& it : m_recipes)
|
||||
{
|
||||
delete (*it);
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ MineShaftFeature::MineShaftFeature(unordered_map<wstring, wstring> options)
|
||||
{
|
||||
chance = 0.01;
|
||||
|
||||
for(AUTO_VAR(it,options.begin()); it != options.end(); ++it)
|
||||
for(auto& option : options)
|
||||
{
|
||||
if (it->first.compare(OPTION_CHANCE) == 0)
|
||||
if (option.first.compare(OPTION_CHANCE) == 0)
|
||||
{
|
||||
chance = Mth::getDouble(it->second, chance);
|
||||
chance = Mth::getDouble(option.second, chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ MineShaftPieces::MineShaftRoom::MineShaftRoom(int genDepth, Random *random, int
|
||||
|
||||
MineShaftPieces::MineShaftRoom::~MineShaftRoom()
|
||||
{
|
||||
for(AUTO_VAR(it, childEntranceBoxes.begin()); it != childEntranceBoxes.end(); ++it)
|
||||
for(auto& it : childEntranceBoxes)
|
||||
{
|
||||
delete (*it);
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,9 +204,8 @@ bool MineShaftPieces::MineShaftRoom::postProcess(Level *level, Random *random, B
|
||||
|
||||
// room air
|
||||
generateBox(level, chunkBB, boundingBox->x0, boundingBox->y0 + 1, boundingBox->z0, boundingBox->x1, min(boundingBox->y0 + 3, boundingBox->y1), boundingBox->z1, 0, 0, false);
|
||||
for(AUTO_VAR(it, childEntranceBoxes.begin()); it != childEntranceBoxes.end(); ++it)
|
||||
for(auto& entranceBox : childEntranceBoxes)
|
||||
{
|
||||
BoundingBox *entranceBox = *it;
|
||||
generateBox(level, chunkBB, entranceBox->x0, entranceBox->y1 - (DEFAULT_SHAFT_HEIGHT - 1), entranceBox->z0, entranceBox->x1, entranceBox->y1, entranceBox->z1, 0, 0, false);
|
||||
}
|
||||
generateUpperHalfSphere(level, chunkBB, boundingBox->x0, boundingBox->y0 + 4, boundingBox->z0, boundingBox->x1, boundingBox->y1, boundingBox->z1, 0, false);
|
||||
@@ -217,9 +216,8 @@ bool MineShaftPieces::MineShaftRoom::postProcess(Level *level, Random *random, B
|
||||
void MineShaftPieces::MineShaftRoom::addAdditonalSaveData(CompoundTag *tag)
|
||||
{
|
||||
ListTag<IntArrayTag> *entrances = new ListTag<IntArrayTag>(L"Entrances");
|
||||
for (AUTO_VAR(it,childEntranceBoxes.begin()); it != childEntranceBoxes.end(); ++it)
|
||||
for (auto& bb : childEntranceBoxes)
|
||||
{
|
||||
BoundingBox *bb =*it;
|
||||
entrances->add(bb->createTag(L""));
|
||||
}
|
||||
tag->put(L"Entrances", entrances);
|
||||
@@ -523,12 +521,12 @@ bool MineShaftPieces::MineShaftCorridor::postProcess(Level *level, Random *rando
|
||||
}
|
||||
|
||||
// prevent air floating
|
||||
for (int x = x0; x <= x1; x++)
|
||||
for (int x = x0; x <= x1; x++)
|
||||
{
|
||||
for (int z = 0; z <= length; z++)
|
||||
for (int z = 0; z <= length; z++)
|
||||
{
|
||||
int block = getBlock(level, x, -1, z, chunkBB);
|
||||
if (block == 0)
|
||||
if (block == 0)
|
||||
{
|
||||
placeBlock(level, Tile::wood_Id, 0, x, -1, z, chunkBB);
|
||||
}
|
||||
@@ -687,12 +685,12 @@ bool MineShaftPieces::MineShaftCrossing::postProcess(Level *level, Random *rando
|
||||
// prevent air floating
|
||||
// note: use world coordinates because the corridor hasn't defined
|
||||
// orientation
|
||||
for (int x = boundingBox->x0; x <= boundingBox->x1; x++)
|
||||
for (int x = boundingBox->x0; x <= boundingBox->x1; x++)
|
||||
{
|
||||
for (int z = boundingBox->z0; z <= boundingBox->z1; z++)
|
||||
for (int z = boundingBox->z0; z <= boundingBox->z1; z++)
|
||||
{
|
||||
int block = getBlock(level, x, boundingBox->y0 - 1, z, chunkBB);
|
||||
if (block == 0)
|
||||
if (block == 0)
|
||||
{
|
||||
placeBlock(level, Tile::wood_Id, 0, x, boundingBox->y0 - 1, z, chunkBB);
|
||||
}
|
||||
|
||||
@@ -346,11 +346,9 @@ void Minecart::tick()
|
||||
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), bb->grow(0.2f, 0, 0.2f));
|
||||
if (entities != NULL && !entities->empty())
|
||||
{
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
for (auto& e : *entities)
|
||||
{
|
||||
shared_ptr<Entity> e = (*it); //entities->at(i);
|
||||
if (e != rider.lock() && e->isPushable() && e->instanceof(eTYPE_MINECART))
|
||||
if ( e && e != rider.lock() && e->isPushable() && e->instanceof(eTYPE_MINECART))
|
||||
{
|
||||
shared_ptr<Minecart> cart = dynamic_pointer_cast<Minecart>(e);
|
||||
cart->m_bHasPushedCartThisTick = false;
|
||||
@@ -455,7 +453,7 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sl
|
||||
xd = pow * xD / dd;
|
||||
zd = pow * zD / dd;
|
||||
|
||||
|
||||
|
||||
if ( rider.lock() != NULL && rider.lock()->instanceof(eTYPE_LIVINGENTITY) )
|
||||
{
|
||||
shared_ptr<LivingEntity> living = dynamic_pointer_cast<LivingEntity>(rider.lock());
|
||||
|
||||
@@ -707,6 +707,9 @@
|
||||
<IncludePath>$(ProjectDir)\x64headers;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)\$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)_$(Configuration)\</IntDir>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64EC'">
|
||||
<OutputFile>$(OutDir)$(ProjectName).lib</OutputFile>
|
||||
@@ -735,6 +738,9 @@
|
||||
<IncludePath>$(ProjectDir)\x64headers;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)\$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)_$(Configuration)\</IntDir>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64EC'">
|
||||
<OutputFile>$(OutDir)$(ProjectName).lib</OutputFile>
|
||||
@@ -753,6 +759,9 @@
|
||||
<IncludePath>$(ProjectDir)\x64headers;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)\$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)_$(Configuration)\</IntDir>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage_Vita|ARM64EC'">
|
||||
<OutputFile>$(OutDir)$(ProjectName).lib</OutputFile>
|
||||
@@ -834,6 +843,9 @@
|
||||
<IncludePath>$(ProjectDir)\x64header;$(DXSDK_DIR)include;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)\$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)_$(Configuration)\</IntDir>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage|ARM64EC'">
|
||||
<OutputFile>$(OutDir)$(ProjectName).lib</OutputFile>
|
||||
@@ -852,6 +864,9 @@
|
||||
<IncludePath>$(ProjectDir)\x64header;$(DXSDK_DIR)include;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)\$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)_$(Configuration)\</IntDir>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='CONTENTPACKAGE_SYMBOLS|ARM64EC'">
|
||||
<OutputFile>$(OutDir)$(ProjectName).lib</OutputFile>
|
||||
@@ -870,6 +885,9 @@
|
||||
<IncludePath>$(ProjectDir)\x64header;$(DXSDK_DIR)include;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)\$(Platform)_$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)_$(Configuration)\</IntDir>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseForArt|ARM64EC'">
|
||||
<OutputFile>$(OutDir)$(ProjectName).lib</OutputFile>
|
||||
@@ -888,6 +906,9 @@
|
||||
<IncludePath>$(ProjectDir)\x64header;$(DXSDK_DIR)include;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\$(Configuration)\</IntDir>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
<EnableMicrosoftCodeAnalysis>false</EnableMicrosoftCodeAnalysis>
|
||||
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ContentPackage_NO_TU|ARM64EC'">
|
||||
<OutputFile>$(OutDir)$(ProjectName).lib</OutputFile>
|
||||
@@ -4958,4 +4979,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -152,38 +152,38 @@ void Mob::ate()
|
||||
{
|
||||
}
|
||||
|
||||
void Mob::defineSynchedData()
|
||||
void Mob::defineSynchedData()
|
||||
{
|
||||
LivingEntity::defineSynchedData();
|
||||
entityData->define(DATA_CUSTOM_NAME_VISIBLE, (byte) 0);
|
||||
entityData->define(DATA_CUSTOM_NAME, L"");
|
||||
}
|
||||
|
||||
int Mob::getAmbientSoundInterval()
|
||||
int Mob::getAmbientSoundInterval()
|
||||
{
|
||||
return 20 * 4;
|
||||
}
|
||||
|
||||
void Mob::playAmbientSound()
|
||||
void Mob::playAmbientSound()
|
||||
{
|
||||
MemSect(31);
|
||||
int ambient = getAmbientSound();
|
||||
if (ambient != -1)
|
||||
if (ambient != -1)
|
||||
{
|
||||
playSound(ambient, getSoundVolume(), getVoicePitch());
|
||||
}
|
||||
MemSect(0);
|
||||
}
|
||||
|
||||
void Mob::baseTick()
|
||||
void Mob::baseTick()
|
||||
{
|
||||
LivingEntity::baseTick();
|
||||
|
||||
if (isAlive() && random->nextInt(1000) < ambientSoundTime++)
|
||||
if (isAlive() && random->nextInt(1000) < ambientSoundTime++)
|
||||
{
|
||||
ambientSoundTime = -getAmbientSoundInterval();
|
||||
|
||||
playAmbientSound();
|
||||
playAmbientSound();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,9 +209,9 @@ int Mob::getExperienceReward(shared_ptr<Player> killedBy)
|
||||
return xpReward;
|
||||
}
|
||||
}
|
||||
void Mob::spawnAnim()
|
||||
void Mob::spawnAnim()
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
double xa = random->nextGaussian() * 0.02;
|
||||
double ya = random->nextGaussian() * 0.02;
|
||||
@@ -222,7 +222,7 @@ void Mob::spawnAnim()
|
||||
}
|
||||
}
|
||||
|
||||
void Mob::tick()
|
||||
void Mob::tick()
|
||||
{
|
||||
LivingEntity::tick();
|
||||
|
||||
@@ -245,7 +245,7 @@ float Mob::tickHeadTurn(float yBodyRotT, float walkSpeed)
|
||||
}
|
||||
}
|
||||
|
||||
int Mob::getAmbientSound()
|
||||
int Mob::getAmbientSound()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -255,10 +255,10 @@ int Mob::getDeathLoot()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Mob::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
|
||||
void Mob::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
|
||||
{
|
||||
int loot = getDeathLoot();
|
||||
if (loot > 0)
|
||||
if (loot > 0)
|
||||
{
|
||||
int count = random->nextInt(3);
|
||||
if (playerBonusLevel > 0)
|
||||
@@ -270,7 +270,7 @@ void Mob::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel)
|
||||
}
|
||||
}
|
||||
|
||||
void Mob::addAdditonalSaveData(CompoundTag *entityTag)
|
||||
void Mob::addAdditonalSaveData(CompoundTag *entityTag)
|
||||
{
|
||||
LivingEntity::addAdditonalSaveData(entityTag);
|
||||
entityTag->putBoolean(L"CanPickUpLoot", canPickUpLoot());
|
||||
@@ -288,7 +288,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag)
|
||||
ListTag<FloatTag> *dropChanceList = new ListTag<FloatTag>();
|
||||
for (int i = 0; i < dropChances.length; i++)
|
||||
{
|
||||
dropChanceList->add(new FloatTag( _toString(i), dropChances[i]));
|
||||
dropChanceList->add(new FloatTag( std::to_wstring(i), dropChances[i]));
|
||||
}
|
||||
entityTag->put(L"DropChances", dropChanceList);
|
||||
entityTag->putString(L"CustomName", getCustomName());
|
||||
@@ -316,7 +316,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag)
|
||||
}
|
||||
}
|
||||
|
||||
void Mob::readAdditionalSaveData(CompoundTag *tag)
|
||||
void Mob::readAdditionalSaveData(CompoundTag *tag)
|
||||
{
|
||||
LivingEntity::readAdditionalSaveData(tag);
|
||||
|
||||
@@ -362,16 +362,16 @@ void Mob::setSpeed(float speed)
|
||||
setYya(speed);
|
||||
}
|
||||
|
||||
void Mob::aiStep()
|
||||
void Mob::aiStep()
|
||||
{
|
||||
LivingEntity::aiStep();
|
||||
|
||||
if (!level->isClientSide && canPickUpLoot() && !dead && level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING))
|
||||
{
|
||||
vector<shared_ptr<Entity> > *entities = level->getEntitiesOfClass(typeid(ItemEntity), bb->grow(1, 0, 1));
|
||||
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it)
|
||||
for (auto& it : *entities)
|
||||
{
|
||||
shared_ptr<ItemEntity> entity = dynamic_pointer_cast<ItemEntity>(*it);
|
||||
shared_ptr<ItemEntity> entity = dynamic_pointer_cast<ItemEntity>(it);
|
||||
if (entity->removed || entity->getItem() == NULL) continue;
|
||||
shared_ptr<ItemInstance> item = entity->getItem();
|
||||
int slot = getEquipmentSlotForItem(item);
|
||||
@@ -457,12 +457,12 @@ bool Mob::useNewAi()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Mob::removeWhenFarAway()
|
||||
bool Mob::removeWhenFarAway()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void Mob::checkDespawn()
|
||||
void Mob::checkDespawn()
|
||||
{
|
||||
if (persistenceRequired)
|
||||
{
|
||||
@@ -470,23 +470,23 @@ void Mob::checkDespawn()
|
||||
return;
|
||||
}
|
||||
shared_ptr<Entity> player = level->getNearestPlayer(shared_from_this(), -1);
|
||||
if (player != NULL)
|
||||
if (player != NULL)
|
||||
{
|
||||
double xd = player->x - x;
|
||||
double yd = player->y - y;
|
||||
double zd = player->z - z;
|
||||
double sd = xd * xd + yd * yd + zd * zd;
|
||||
|
||||
if (removeWhenFarAway() && sd > 128 * 128)
|
||||
if (removeWhenFarAway() && sd > 128 * 128)
|
||||
{
|
||||
remove();
|
||||
}
|
||||
|
||||
if (noActionTime > 20 * 30 && random->nextInt(800) == 0 && sd > 32 * 32 && removeWhenFarAway())
|
||||
if (noActionTime > 20 * 30 && random->nextInt(800) == 0 && sd > 32 * 32 && removeWhenFarAway())
|
||||
{
|
||||
remove();
|
||||
}
|
||||
else if (sd < 32 * 32)
|
||||
else if (sd < 32 * 32)
|
||||
{
|
||||
noActionTime = 0;
|
||||
}
|
||||
@@ -502,7 +502,7 @@ void Mob::newServerAiStep()
|
||||
checkDespawn();
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Tick sensing");
|
||||
sensing->tick();
|
||||
sensing->tick();
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Tick target selector");
|
||||
targetSelector.tick();
|
||||
@@ -534,7 +534,7 @@ void Mob::newServerAiStep()
|
||||
PIXEndNamedEvent();
|
||||
}
|
||||
|
||||
void Mob::serverAiStep()
|
||||
void Mob::serverAiStep()
|
||||
{
|
||||
LivingEntity::serverAiStep();
|
||||
|
||||
@@ -544,15 +544,15 @@ void Mob::serverAiStep()
|
||||
checkDespawn();
|
||||
|
||||
float lookDistance = 8;
|
||||
if (random->nextFloat() < 0.02f)
|
||||
if (random->nextFloat() < 0.02f)
|
||||
{
|
||||
shared_ptr<Player> player = level->getNearestPlayer(shared_from_this(), lookDistance);
|
||||
if (player != NULL)
|
||||
if (player != NULL)
|
||||
{
|
||||
lookingAt = player;
|
||||
lookTime = 10 + random->nextInt(20);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
yRotA = (random->nextFloat() - 0.5f) * 20;
|
||||
}
|
||||
@@ -561,14 +561,14 @@ void Mob::serverAiStep()
|
||||
if (lookingAt != NULL)
|
||||
{
|
||||
lookAt(lookingAt, 10.0f, (float) getMaxHeadXRot());
|
||||
if (lookTime-- <= 0 || lookingAt->removed || lookingAt->distanceToSqr(shared_from_this()) > lookDistance * lookDistance)
|
||||
if (lookTime-- <= 0 || lookingAt->removed || lookingAt->distanceToSqr(shared_from_this()) > lookDistance * lookDistance)
|
||||
{
|
||||
lookingAt = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (random->nextFloat() < 0.05f)
|
||||
if (random->nextFloat() < 0.05f)
|
||||
{
|
||||
yRotA = (random->nextFloat() - 0.5f) * 20;
|
||||
}
|
||||
@@ -581,24 +581,24 @@ void Mob::serverAiStep()
|
||||
if (inWater || inLava) jumping = random->nextFloat() < 0.8f;
|
||||
}
|
||||
|
||||
int Mob::getMaxHeadXRot()
|
||||
int Mob::getMaxHeadXRot()
|
||||
{
|
||||
return 40;
|
||||
}
|
||||
|
||||
void Mob::lookAt(shared_ptr<Entity> e, float yMax, float xMax)
|
||||
void Mob::lookAt(shared_ptr<Entity> e, float yMax, float xMax)
|
||||
{
|
||||
double xd = e->x - x;
|
||||
double yd;
|
||||
double zd = e->z - z;
|
||||
|
||||
|
||||
|
||||
if ( e->instanceof(eTYPE_LIVINGENTITY) )
|
||||
{
|
||||
shared_ptr<LivingEntity> mob = dynamic_pointer_cast<LivingEntity>(e);
|
||||
yd = (mob->y + mob->getHeadHeight()) - (y + getHeadHeight());
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
yd = (e->bb->y0 + e->bb->y1) / 2 - (y + getHeadHeight());
|
||||
}
|
||||
@@ -611,31 +611,31 @@ void Mob::lookAt(shared_ptr<Entity> e, float yMax, float xMax)
|
||||
yRot = rotlerp(yRot, yRotD, yMax);
|
||||
}
|
||||
|
||||
bool Mob::isLookingAtAnEntity()
|
||||
bool Mob::isLookingAtAnEntity()
|
||||
{
|
||||
return lookingAt != NULL;
|
||||
}
|
||||
|
||||
shared_ptr<Entity> Mob::getLookingAt()
|
||||
shared_ptr<Entity> Mob::getLookingAt()
|
||||
{
|
||||
return lookingAt;
|
||||
}
|
||||
|
||||
float Mob::rotlerp(float a, float b, float max)
|
||||
float Mob::rotlerp(float a, float b, float max)
|
||||
{
|
||||
float diff = Mth::wrapDegrees(b - a);
|
||||
if (diff > max)
|
||||
if (diff > max)
|
||||
{
|
||||
diff = max;
|
||||
}
|
||||
if (diff < -max)
|
||||
if (diff < -max)
|
||||
{
|
||||
diff = -max;
|
||||
}
|
||||
return a + diff;
|
||||
}
|
||||
|
||||
bool Mob::canSpawn()
|
||||
bool Mob::canSpawn()
|
||||
{
|
||||
// 4J - altered to use special containsAnyLiquid variant
|
||||
return level->isUnobstructed(bb) && level->getCubes(shared_from_this(), bb)->empty() && !level->containsAnyLiquid_NoLoad(bb);
|
||||
@@ -651,7 +651,7 @@ float Mob::getHeadSizeScale()
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
int Mob::getMaxSpawnClusterSize()
|
||||
int Mob::getMaxSpawnClusterSize()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
@@ -815,7 +815,7 @@ void Mob::populateDefaultEquipmentEnchantments()
|
||||
/**
|
||||
* Added this method so mobs can handle their own spawn settings instead of
|
||||
* hacking MobSpawner.java
|
||||
*
|
||||
*
|
||||
* @param groupData
|
||||
* TODO
|
||||
* @return TODO
|
||||
@@ -918,7 +918,7 @@ bool Mob::interact(shared_ptr<Player> player)
|
||||
if (canBeLeashed())
|
||||
{
|
||||
shared_ptr<TamableAnimal> tamableAnimal = nullptr;
|
||||
if ( shared_from_this()->instanceof(eTYPE_TAMABLE_ANIMAL)
|
||||
if ( shared_from_this()->instanceof(eTYPE_TAMABLE_ANIMAL)
|
||||
&& (tamableAnimal = dynamic_pointer_cast<TamableAnimal>(shared_from_this()))->isTame() ) // 4J-JEV: excuse the assignment operator in here, don't want to dyn-cast if it's avoidable.
|
||||
{
|
||||
if (player->getUUID().compare(tamableAnimal->getOwnerUUID()) == 0)
|
||||
@@ -1007,7 +1007,7 @@ void Mob::setLeashedTo(shared_ptr<Entity> holder, bool synch)
|
||||
{
|
||||
_isLeashed = true;
|
||||
leashHolder = holder;
|
||||
|
||||
|
||||
ServerLevel *serverLevel = dynamic_cast<ServerLevel *>(level);
|
||||
if (!level->isClientSide && synch && serverLevel)
|
||||
{
|
||||
@@ -1024,9 +1024,9 @@ void Mob::restoreLeashFromSave()
|
||||
{
|
||||
wstring leashUuid = leashInfoTag->getString(L"UUID");
|
||||
vector<shared_ptr<Entity> > *livingEnts = level->getEntitiesOfClass(typeid(LivingEntity), bb->grow(10, 10, 10));
|
||||
for(AUTO_VAR(it, livingEnts->begin()); it != livingEnts->end(); ++it)
|
||||
for(auto& livingEnt : *livingEnts)
|
||||
{
|
||||
shared_ptr<LivingEntity> le = dynamic_pointer_cast<LivingEntity>(*it);
|
||||
shared_ptr<LivingEntity> le = dynamic_pointer_cast<LivingEntity>(livingEnt);
|
||||
if (le->getUUID().compare(leashUuid) == 0)
|
||||
{
|
||||
leashHolder = le;
|
||||
|
||||
@@ -15,26 +15,26 @@ MobEffect *MobEffect::voidEffect;
|
||||
MobEffect *MobEffect::movementSpeed;
|
||||
MobEffect *MobEffect::movementSlowdown;
|
||||
MobEffect *MobEffect::digSpeed;
|
||||
MobEffect *MobEffect::digSlowdown;
|
||||
MobEffect *MobEffect::damageBoost;
|
||||
MobEffect *MobEffect::heal;
|
||||
MobEffect *MobEffect::harm;
|
||||
MobEffect *MobEffect::digSlowdown;
|
||||
MobEffect *MobEffect::damageBoost;
|
||||
MobEffect *MobEffect::heal;
|
||||
MobEffect *MobEffect::harm;
|
||||
MobEffect *MobEffect::jump;
|
||||
MobEffect *MobEffect::confusion;
|
||||
MobEffect *MobEffect::regeneration;
|
||||
MobEffect *MobEffect::regeneration;
|
||||
MobEffect *MobEffect::damageResistance;
|
||||
MobEffect *MobEffect::fireResistance;
|
||||
MobEffect *MobEffect::waterBreathing;
|
||||
MobEffect *MobEffect::invisibility;
|
||||
MobEffect *MobEffect::blindness;
|
||||
MobEffect *MobEffect::nightVision;
|
||||
MobEffect *MobEffect::hunger;
|
||||
MobEffect *MobEffect::weakness;
|
||||
MobEffect *MobEffect::poison;
|
||||
MobEffect *MobEffect::wither;
|
||||
MobEffect *MobEffect::healthBoost;
|
||||
MobEffect *MobEffect::absorption;
|
||||
MobEffect *MobEffect::saturation;
|
||||
MobEffect *MobEffect::fireResistance;
|
||||
MobEffect *MobEffect::waterBreathing;
|
||||
MobEffect *MobEffect::invisibility;
|
||||
MobEffect *MobEffect::blindness;
|
||||
MobEffect *MobEffect::nightVision;
|
||||
MobEffect *MobEffect::hunger;
|
||||
MobEffect *MobEffect::weakness;
|
||||
MobEffect *MobEffect::poison;
|
||||
MobEffect *MobEffect::wither;
|
||||
MobEffect *MobEffect::healthBoost;
|
||||
MobEffect *MobEffect::absorption;
|
||||
MobEffect *MobEffect::saturation;
|
||||
MobEffect *MobEffect::reserved_24;
|
||||
MobEffect *MobEffect::reserved_25;
|
||||
MobEffect *MobEffect::reserved_26;
|
||||
@@ -121,7 +121,7 @@ int MobEffect::getId()
|
||||
* This method should perform periodic updates on the player. Mainly used
|
||||
* for regeneration effects and the like. Other effects, such as blindness,
|
||||
* are in effect for the whole duration of the effect.
|
||||
*
|
||||
*
|
||||
* @param mob
|
||||
* @param amplification
|
||||
*/
|
||||
@@ -201,7 +201,7 @@ bool MobEffect::isInstantenous()
|
||||
* This parameter says if the applyEffect method should be called depending
|
||||
* on the remaining duration ticker. For instance, the regeneration will be
|
||||
* activated every 8 ticks, healing one point of health.
|
||||
*
|
||||
*
|
||||
* @param remainingDuration
|
||||
* @param amplification
|
||||
* Effect amplification, starts at 0 (weakest)
|
||||
@@ -355,26 +355,26 @@ unordered_map<Attribute *, AttributeModifier *> *MobEffect::getAttributeModifier
|
||||
|
||||
void MobEffect::removeAttributeModifiers(shared_ptr<LivingEntity> entity, BaseAttributeMap *attributes, int amplifier)
|
||||
{
|
||||
for (AUTO_VAR(it, attributeModifiers.begin()); it != attributeModifiers.end(); ++it)
|
||||
for (auto& it : attributeModifiers)
|
||||
{
|
||||
AttributeInstance *attribute = attributes->getInstance(it->first);
|
||||
AttributeInstance *attribute = attributes->getInstance(it.first);
|
||||
|
||||
if (attribute != NULL)
|
||||
{
|
||||
attribute->removeModifier(it->second);
|
||||
attribute->removeModifier(it.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MobEffect::addAttributeModifiers(shared_ptr<LivingEntity> entity, BaseAttributeMap *attributes, int amplifier)
|
||||
{
|
||||
for (AUTO_VAR(it, attributeModifiers.begin()); it != attributeModifiers.end(); ++it)
|
||||
for (auto& it : attributeModifiers)
|
||||
{
|
||||
AttributeInstance *attribute = attributes->getInstance(it->first);
|
||||
AttributeInstance *attribute = attributes->getInstance(it.first);
|
||||
|
||||
if (attribute != NULL)
|
||||
{
|
||||
AttributeModifier *original = it->second;
|
||||
AttributeModifier *original = it.second;
|
||||
attribute->removeModifier(original);
|
||||
attribute->addModifier(new AttributeModifier(original->getId(), getAttributeModifierValue(amplifier, original), original->getOperation()));
|
||||
}
|
||||
|
||||
@@ -100,12 +100,10 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
|
||||
}
|
||||
MemSect(20);
|
||||
chunksToPoll.clear();
|
||||
|
||||
|
||||
#if 0
|
||||
AUTO_VAR(itEnd, level->players.end());
|
||||
for (AUTO_VAR(it, level->players.begin()); it != itEnd; it++)
|
||||
for (auto& player : level->players)
|
||||
{
|
||||
shared_ptr<Player> player = *it; //level->players.at(i);
|
||||
int xx = Mth::floor(player->x / 16);
|
||||
int zz = Mth::floor(player->z / 16);
|
||||
|
||||
@@ -164,20 +162,20 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
|
||||
#ifdef __PSVITA__
|
||||
ChunkPos cp = ChunkPos( ( xx[i] - r ) + l , ( zz[i] - r ));
|
||||
if( chunksToPoll.find( cp ) ) chunksToPoll.insert(cp, true);
|
||||
cp = ChunkPos( ( xx[i] + r ), ( zz[i] - r ) + l );
|
||||
cp = ChunkPos( ( xx[i] + r ), ( zz[i] - r ) + l );
|
||||
if( chunksToPoll.find( cp ) ) chunksToPoll.insert(cp, true);
|
||||
cp = ChunkPos( ( xx[i] + r ) - l , ( zz[i] + r ));
|
||||
cp = ChunkPos( ( xx[i] + r ) - l , ( zz[i] + r ));
|
||||
if( chunksToPoll.find( cp ) ) chunksToPoll.insert(cp, true);
|
||||
cp = ChunkPos( ( xx[i] - r ), ( zz[i] + r ) - l);
|
||||
cp = ChunkPos( ( xx[i] - r ), ( zz[i] + r ) - l);
|
||||
if( chunksToPoll.find( cp ) ) chunksToPoll.insert(cp, true);
|
||||
#else
|
||||
ChunkPos cp = ChunkPos( ( xx[i] - r ) + l , ( zz[i] - r ));
|
||||
if( chunksToPoll.find( cp ) == chunksToPoll.end() ) chunksToPoll.insert(std::pair<ChunkPos,bool>(cp, true));
|
||||
cp = ChunkPos( ( xx[i] + r ), ( zz[i] - r ) + l );
|
||||
cp = ChunkPos( ( xx[i] + r ), ( zz[i] - r ) + l );
|
||||
if( chunksToPoll.find( cp ) == chunksToPoll.end() ) chunksToPoll.insert(std::pair<ChunkPos,bool>(cp, true));
|
||||
cp = ChunkPos( ( xx[i] + r ) - l , ( zz[i] + r ));
|
||||
cp = ChunkPos( ( xx[i] + r ) - l , ( zz[i] + r ));
|
||||
if( chunksToPoll.find( cp ) == chunksToPoll.end() ) chunksToPoll.insert(std::pair<ChunkPos,bool>(cp, true));
|
||||
cp = ChunkPos( ( xx[i] - r ), ( zz[i] + r ) - l);
|
||||
cp = ChunkPos( ( xx[i] - r ), ( zz[i] + r ) - l);
|
||||
if( chunksToPoll.find( cp ) == chunksToPoll.end() ) chunksToPoll.insert(std::pair<ChunkPos,bool>(cp, true));
|
||||
#endif
|
||||
|
||||
@@ -224,16 +222,15 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
|
||||
{
|
||||
SCustomMapNode *it = chunksToPoll.get(i);
|
||||
#else
|
||||
AUTO_VAR(itEndCTP, chunksToPoll.end());
|
||||
for (AUTO_VAR(it, chunksToPoll.begin()); it != itEndCTP; it++)
|
||||
for (auto& it : chunksToPoll)
|
||||
{
|
||||
#endif
|
||||
if( it->second )
|
||||
if( it.second )
|
||||
{
|
||||
// don't add mobs to edge chunks, to prevent adding mobs "outside" of the active playground
|
||||
continue;
|
||||
}
|
||||
ChunkPos *cp = (ChunkPos *) (&it->first);
|
||||
ChunkPos *cp = (ChunkPos *) (&it.first);
|
||||
|
||||
// 4J - don't let this actually create/load a chunk that isn't here already - we'll let the normal updateDirtyChunks etc. processes do that, so it can happen on another thread
|
||||
if( !level->hasChunk(cp->x,cp->z) ) continue;
|
||||
@@ -399,7 +396,7 @@ bool MobSpawner::isSpawnPositionOk(MobCategory *category, Level *level, int x, i
|
||||
// 4J - changed to spawn water things only in deep water
|
||||
int yo = 0;
|
||||
int liquidCount = 0;
|
||||
|
||||
|
||||
while( ( y - yo ) >= 0 && ( yo < 5 ) )
|
||||
{
|
||||
if( level->getMaterial(x, y - yo, z)->isLiquid() ) liquidCount++;
|
||||
|
||||
@@ -15,12 +15,12 @@ ModifiableAttributeInstance::ModifiableAttributeInstance(BaseAttributeMap *attri
|
||||
|
||||
ModifiableAttributeInstance::~ModifiableAttributeInstance()
|
||||
{
|
||||
for (int i = 0; i < AttributeModifier::TOTAL_OPERATIONS; i++)
|
||||
for (auto& modifier : modifiers)
|
||||
{
|
||||
for (AUTO_VAR(it, modifiers[i].begin()); it != modifiers[i].end(); ++it)
|
||||
for (auto it : modifier)
|
||||
{
|
||||
// Delete all modifiers
|
||||
delete *it;
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,14 +51,12 @@ unordered_set<AttributeModifier *> *ModifiableAttributeInstance::getModifiers(in
|
||||
// Returns a pointer to a new vector of all modifiers
|
||||
void ModifiableAttributeInstance::getModifiers(unordered_set<AttributeModifier *>& result)
|
||||
{
|
||||
for (int i = 0; i < AttributeModifier::TOTAL_OPERATIONS; i++)
|
||||
for (auto& modifier : modifiers)
|
||||
{
|
||||
unordered_set<AttributeModifier *> *opModifiers = &modifiers[i];
|
||||
|
||||
for (AUTO_VAR(it, opModifiers->begin()); it != opModifiers->end(); ++it)
|
||||
for (auto& opModifier : modifier)
|
||||
{
|
||||
result.insert(*it);
|
||||
}
|
||||
result.insert(opModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,20 +64,20 @@ AttributeModifier *ModifiableAttributeInstance::getModifier(eMODIFIER_ID id)
|
||||
{
|
||||
AttributeModifier *modifier = NULL;
|
||||
|
||||
AUTO_VAR(it, modifierById.find(id));
|
||||
if(it != modifierById.end())
|
||||
auto it = modifierById.find(id);
|
||||
if(it != modifierById.end())
|
||||
{
|
||||
modifier = it->second;
|
||||
}
|
||||
|
||||
return modifier;
|
||||
return modifier;
|
||||
}
|
||||
|
||||
void ModifiableAttributeInstance::addModifiers(unordered_set<AttributeModifier *> *modifiers)
|
||||
{
|
||||
for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
for (auto& modifier : *modifiers)
|
||||
{
|
||||
addModifier(*it);
|
||||
addModifier(modifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +85,7 @@ void ModifiableAttributeInstance::addModifiers(unordered_set<AttributeModifier *
|
||||
void ModifiableAttributeInstance::addModifier(AttributeModifier *modifier)
|
||||
{
|
||||
// Can't add modifiers with the same ID (unless the modifier is anonymous)
|
||||
if (modifier->getId() != eModifierId_ANONYMOUS && getModifier(modifier->getId()) != NULL)
|
||||
if (modifier->getId() != eModifierId_ANONYMOUS && getModifier(modifier->getId()) != NULL)
|
||||
{
|
||||
assert(0);
|
||||
// throw new IllegalArgumentException("Modifier is already applied on this attribute!");
|
||||
@@ -108,13 +106,13 @@ void ModifiableAttributeInstance::setDirty()
|
||||
|
||||
void ModifiableAttributeInstance::removeModifier(AttributeModifier *modifier)
|
||||
{
|
||||
for (int i = 0; i < AttributeModifier::TOTAL_OPERATIONS; i++)
|
||||
for (auto& mod : modifiers)
|
||||
{
|
||||
for (AUTO_VAR(it, modifiers[i].begin()); it != modifiers[i].end(); ++it)
|
||||
{
|
||||
if (modifier->equals(*it))
|
||||
for (auto& it : mod )
|
||||
{
|
||||
if (modifier->equals(it))
|
||||
{
|
||||
modifiers[i].erase(it);
|
||||
mod.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -136,9 +134,9 @@ void ModifiableAttributeInstance::removeModifiers()
|
||||
unordered_set<AttributeModifier *> removingModifiers;
|
||||
getModifiers(removingModifiers);
|
||||
|
||||
for (AUTO_VAR(it, removingModifiers.begin()); it != removingModifiers.end(); ++it)
|
||||
for (auto& it : removingModifiers)
|
||||
{
|
||||
removeModifier(*it);
|
||||
removeModifier(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,25 +157,22 @@ double ModifiableAttributeInstance::calculateValue()
|
||||
unordered_set<AttributeModifier *> *modifiers;
|
||||
|
||||
modifiers = getModifiers(AttributeModifier::OPERATION_ADDITION);
|
||||
for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
for (auto& modifier : *modifiers)
|
||||
{
|
||||
AttributeModifier *modifier = *it;
|
||||
base += modifier->getAmount();
|
||||
}
|
||||
|
||||
double result = base;
|
||||
|
||||
modifiers = getModifiers(AttributeModifier::OPERATION_MULTIPLY_BASE);
|
||||
for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
for (auto& modifier : *modifiers)
|
||||
{
|
||||
AttributeModifier *modifier = *it;
|
||||
result += base * modifier->getAmount();
|
||||
}
|
||||
|
||||
|
||||
modifiers = getModifiers(AttributeModifier::OPERATION_MULTIPLY_TOTAL);
|
||||
for (AUTO_VAR(it, modifiers->begin()); it != modifiers->end(); ++it)
|
||||
for (auto& modifier : *modifiers)
|
||||
{
|
||||
AttributeModifier *modifier = *it;
|
||||
result *= 1 + modifier->getAmount();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ wstring MonsterPlacerItem::getHoverName(shared_ptr<ItemInstance> itemInstance)
|
||||
//elementName += " " + I18n.get("entity." + encodeId + ".name");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
elementName = replaceAll(elementName,L"{*CREATURE*}",L"");
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ wstring MonsterPlacerItem::getHoverName(shared_ptr<ItemInstance> itemInstance)
|
||||
|
||||
int MonsterPlacerItem::getColor(shared_ptr<ItemInstance> item, int spriteLayer)
|
||||
{
|
||||
AUTO_VAR(it, EntityIO::idsSpawnableInCreative.find(item->getAuxValue()));
|
||||
if (it != EntityIO::idsSpawnableInCreative.end())
|
||||
auto it = EntityIO::idsSpawnableInCreative.find(item->getAuxValue());
|
||||
if (it != EntityIO::idsSpawnableInCreative.end())
|
||||
{
|
||||
EntityIO::SpawnableMobInfo *spawnableMobInfo = it->second;
|
||||
if (spriteLayer == 0) {
|
||||
@@ -193,7 +193,7 @@ bool MonsterPlacerItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<
|
||||
x += Facing::STEP_X[face];
|
||||
y += Facing::STEP_Y[face];
|
||||
z += Facing::STEP_Z[face];
|
||||
|
||||
|
||||
double yOff = 0;
|
||||
// 4J-PB - missing parentheses added
|
||||
if (face == Facing::UP && (tile == Tile::fence_Id || tile == Tile::netherFence_Id))
|
||||
@@ -211,11 +211,11 @@ bool MonsterPlacerItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<
|
||||
}
|
||||
|
||||
if (spawned)
|
||||
{
|
||||
{
|
||||
if (!player->abilities.instabuild)
|
||||
{
|
||||
itemInstance->count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -87,10 +87,8 @@ shared_ptr<DoorInfo> MoveThroughVillageGoal::getNextDoorInfo(shared_ptr<Village>
|
||||
shared_ptr<DoorInfo> closest = nullptr;
|
||||
int closestDistSqr = Integer::MAX_VALUE;
|
||||
vector<shared_ptr<DoorInfo> > *doorInfos = village->getDoorInfos();
|
||||
//for (DoorInfo di : doorInfos)
|
||||
for(AUTO_VAR(it, doorInfos->begin()); it != doorInfos->end(); ++it)
|
||||
for(auto& di : *doorInfos)
|
||||
{
|
||||
shared_ptr<DoorInfo> di = *it;
|
||||
int distSqr = di->distanceToSqr(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z));
|
||||
if (distSqr < closestDistSqr)
|
||||
{
|
||||
@@ -104,11 +102,10 @@ shared_ptr<DoorInfo> MoveThroughVillageGoal::getNextDoorInfo(shared_ptr<Village>
|
||||
|
||||
bool MoveThroughVillageGoal::hasVisited(shared_ptr<DoorInfo>di)
|
||||
{
|
||||
//for (DoorInfo di2 : visited)
|
||||
for(AUTO_VAR(it, visited.begin()); it != visited.end(); )
|
||||
{
|
||||
for (auto it = visited.begin(); it != visited.end();)
|
||||
{
|
||||
shared_ptr<DoorInfo> di2 = (*it).lock();
|
||||
if( di2 == NULL )
|
||||
if( di2 )
|
||||
{
|
||||
it = visited.erase(it);
|
||||
}
|
||||
|
||||
@@ -89,11 +89,8 @@ vector<CompoundTag *> *NbtSlotFile::readAll(int slot)
|
||||
vector<int> *fileSlots = fileSlotMap[slot];
|
||||
int skipped = 0;
|
||||
|
||||
AUTO_VAR(itEnd, fileSlots->end());
|
||||
for (AUTO_VAR(it, fileSlots->begin()); it != itEnd; it++)
|
||||
for (int c : *fileSlots)
|
||||
{
|
||||
int c = *it; //fileSlots->at(i);
|
||||
|
||||
int pos = 0;
|
||||
int continuesAt = -1;
|
||||
int expectedSlot = slot + 1;
|
||||
@@ -115,8 +112,6 @@ vector<CompoundTag *> *NbtSlotFile::readAll(int slot)
|
||||
goto fileSlotLoop; // 4J - used to be continue fileSlotLoop, with for loop labelled as fileSlotLoop
|
||||
}
|
||||
|
||||
// if (oldSlot != expectedSlot) throw new IOException("Wrong slot! Got " + oldSlot + ", expected " + expectedSlot); // 4J - TODO
|
||||
|
||||
ReadFile(raf,READ_BUFFER.data + pos,size,&numberOfBytesRead,NULL);
|
||||
|
||||
if (continuesAt >= 0)
|
||||
@@ -144,12 +139,12 @@ int NbtSlotFile::getFreeSlot()
|
||||
// fileSlot = toReplace->back();
|
||||
// toReplace->pop_back();
|
||||
// } else
|
||||
|
||||
|
||||
if (freeFileSlots.size() > 0)
|
||||
{
|
||||
fileSlot = freeFileSlots.back();
|
||||
freeFileSlots.pop_back();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileSlot = totalFileSlots++;
|
||||
@@ -164,11 +159,9 @@ void NbtSlotFile::replaceSlot(int slot, vector<CompoundTag *> *tags)
|
||||
DWORD numberOfBytesWritten;
|
||||
toReplace = fileSlotMap[slot];
|
||||
fileSlotMap[slot] = new vector<int>();
|
||||
|
||||
AUTO_VAR(itEndTags, tags->end());
|
||||
for (AUTO_VAR(it, tags->begin()); it != itEndTags; it++)
|
||||
|
||||
for (auto tag : *tags)
|
||||
{
|
||||
CompoundTag *tag = *it; //tags->at(i);
|
||||
byteArray compressed = NbtIo::compress(tag);
|
||||
if (compressed.length > largest)
|
||||
{
|
||||
@@ -227,12 +220,9 @@ void NbtSlotFile::replaceSlot(int slot, vector<CompoundTag *> *tags)
|
||||
}
|
||||
delete[] compressed.data;
|
||||
}
|
||||
|
||||
AUTO_VAR(itEndToRep, toReplace->end());
|
||||
for (AUTO_VAR(it, toReplace->begin()); it != itEndToRep; it++)
|
||||
{
|
||||
int c = *it; //toReplace->at(i);
|
||||
|
||||
for (int c : *toReplace)
|
||||
{
|
||||
freeFileSlots.push_back(c);
|
||||
|
||||
seekSlotHeader(c);
|
||||
|
||||
@@ -13,7 +13,7 @@ NetherBridgeFeature::NetherBridgeFeature() : StructureFeature()
|
||||
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_BLAZE, 10, 2, 3));
|
||||
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_PIGZOMBIE, 5, 4, 4));
|
||||
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_SKELETON, 10, 4, 4));
|
||||
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_LAVASLIME, 3, 4, 4));
|
||||
bridgeEnemies.push_back(new Biome::MobSpawnerData(eTYPE_LAVASLIME, 3, 4, 4));
|
||||
isSpotSelected=false;
|
||||
netherFortressPos = NULL;
|
||||
|
||||
@@ -38,7 +38,7 @@ bool NetherBridgeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat)
|
||||
{
|
||||
// 4J Stu - New implementation to force a nether fortress
|
||||
if (!isSpotSelected)
|
||||
{
|
||||
{
|
||||
// Set the random
|
||||
random->setSeed(level->getSeed());
|
||||
random->nextInt();
|
||||
@@ -119,8 +119,8 @@ NetherBridgeFeature::NetherBridgeStart::NetherBridgeStart(Level *level, Random *
|
||||
while (!pendingChildren->empty())
|
||||
{
|
||||
int pos = random->nextInt((int)pendingChildren->size());
|
||||
AUTO_VAR(it, pendingChildren->begin() + pos);
|
||||
StructurePiece *structurePiece = *it;
|
||||
auto it = pendingChildren->begin() + pos;
|
||||
StructurePiece *structurePiece = *it;
|
||||
pendingChildren->erase(it);
|
||||
structurePiece->addChildren(start, &pieces, random);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ NetherBridgePieces::PieceWeight *NetherBridgePieces::bridgePieceWeights[NetherBr
|
||||
new PieceWeight(EPieceClass_StairsRoom, 10, 3),
|
||||
};
|
||||
|
||||
NetherBridgePieces::PieceWeight *NetherBridgePieces::castlePieceWeights[NetherBridgePieces::CASTLE_PIECEWEIGHTS_COUNT] =
|
||||
NetherBridgePieces::PieceWeight *NetherBridgePieces::castlePieceWeights[NetherBridgePieces::CASTLE_PIECEWEIGHTS_COUNT] =
|
||||
{
|
||||
new PieceWeight(EPieceClass_CastleStalkRoom, 30, 2), // 4J Stu - Increased weight to ensure that we have these (was 5), required for Nether Wart, and therefore required for brewing
|
||||
new PieceWeight(EPieceClass_CastleSmallCorridorPiece, 25, 0, true),
|
||||
@@ -171,10 +171,8 @@ int NetherBridgePieces::NetherBridgePiece::updatePieceWeight(list<PieceWeight *>
|
||||
{
|
||||
bool hasAnyPieces = false;
|
||||
int totalWeight = 0;
|
||||
for( AUTO_VAR(it, currentPieces->begin()); it != currentPieces->end(); it++ )
|
||||
for(auto& piece : *currentPieces)
|
||||
{
|
||||
PieceWeight *piece = *it;
|
||||
|
||||
if (piece->maxPlaceCount > 0 && piece->placeCount < piece->maxPlaceCount)
|
||||
{
|
||||
hasAnyPieces = true;
|
||||
@@ -195,9 +193,8 @@ NetherBridgePieces::NetherBridgePiece *NetherBridgePieces::NetherBridgePiece::ge
|
||||
numAttempts++;
|
||||
|
||||
int weightSelection = random->nextInt(totalWeight);
|
||||
for( AUTO_VAR(it, currentPieces->begin()); it != currentPieces->end(); it++ )
|
||||
{
|
||||
PieceWeight *piece = *it;
|
||||
for ( PieceWeight *piece : *currentPieces )
|
||||
{
|
||||
weightSelection -= piece->weight;
|
||||
if (weightSelection < 0)
|
||||
{
|
||||
@@ -378,7 +375,7 @@ NetherBridgePieces::BridgeStraight *NetherBridgePieces::BridgeStraight::createPi
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -444,7 +441,7 @@ NetherBridgePieces::BridgeEndFiller *NetherBridgePieces::BridgeEndFiller::create
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -3, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -552,7 +549,7 @@ NetherBridgePieces::BridgeCrossing *NetherBridgePieces::BridgeCrossing::createPi
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -8, -3, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -671,7 +668,7 @@ NetherBridgePieces::RoomCrossing *NetherBridgePieces::RoomCrossing::createPiece(
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -741,7 +738,7 @@ NetherBridgePieces::StairsRoom *NetherBridgePieces::StairsRoom::createPiece(list
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -815,7 +812,7 @@ NetherBridgePieces::MonsterThrone *NetherBridgePieces::MonsterThrone::createPiec
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -2, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -911,7 +908,7 @@ NetherBridgePieces::CastleEntrance *NetherBridgePieces::CastleEntrance::createPi
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -1041,7 +1038,7 @@ NetherBridgePieces::CastleStalkRoom *NetherBridgePieces::CastleStalkRoom::create
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -5, -3, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -1207,7 +1204,7 @@ NetherBridgePieces::CastleSmallCorridorPiece *NetherBridgePieces::CastleSmallCor
|
||||
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -1271,7 +1268,7 @@ NetherBridgePieces::CastleSmallCorridorCrossingPiece *NetherBridgePieces::Castle
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -1347,7 +1344,7 @@ NetherBridgePieces::CastleSmallCorridorRightTurnPiece *NetherBridgePieces::Castl
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -1439,7 +1436,7 @@ NetherBridgePieces::CastleSmallCorridorLeftTurnPiece *NetherBridgePieces::Castle
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -1515,7 +1512,7 @@ NetherBridgePieces::CastleCorridorStairsPiece *NetherBridgePieces::CastleCorrido
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -1, -7, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
@@ -1597,7 +1594,7 @@ NetherBridgePieces::CastleCorridorTBalconyPiece *NetherBridgePieces::CastleCorri
|
||||
{
|
||||
BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, -3, 0, 0, width, height, depth, direction);
|
||||
|
||||
StartPiece *startPiece = NULL;
|
||||
StartPiece *startPiece = NULL;
|
||||
if(pieces != NULL) startPiece = ((NetherBridgePieces::StartPiece *) pieces->front());
|
||||
|
||||
if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL)
|
||||
|
||||
@@ -107,6 +107,6 @@ void NetherWartTile::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
for (int i = 0; i < NETHER_STALK_TEXTURE_COUNT; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" + _toString<int>(i) );
|
||||
icons[i] = iconRegister->registerIcon(getIconName() + L"_stage_" + std::to_wstring(i) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ hash(createHash(x, y, z))
|
||||
//hash = createHash(x, y, z);
|
||||
}
|
||||
|
||||
int Node::createHash(const int x, const int y, const int z)
|
||||
int Node::createHash(const int x, const int y, const int z)
|
||||
{
|
||||
return (y & 0xff) | ((x & 0x7fff) << 8) | ((z & 0x7fff) << 24) | ((x < 0) ? 0x0080000000 : 0) | ((z < 0) ? 0x0000008000 : 0);
|
||||
}
|
||||
|
||||
float Node::distanceTo(Node *to)
|
||||
float Node::distanceTo(Node *to)
|
||||
{
|
||||
float xd = (float) ( to->x - x );
|
||||
float yd = (float) ( to->y - y );
|
||||
@@ -49,27 +49,27 @@ float Node::distanceToSqr(Node *to)
|
||||
return xd * xd + yd * yd + zd * zd;
|
||||
}
|
||||
|
||||
bool Node::equals(Node *o)
|
||||
bool Node::equals(Node *o)
|
||||
{
|
||||
//4J Jev, never used anything other than a node.
|
||||
//if (dynamic_cast<Node *>((Node *) o) != NULL)
|
||||
//if (dynamic_cast<Node *>((Node *) o) != NULL)
|
||||
//{
|
||||
return hash == o->hash && x == o->x && y == o->y && z == o->z;
|
||||
//}
|
||||
//return false;
|
||||
}
|
||||
|
||||
int Node::hashCode()
|
||||
int Node::hashCode()
|
||||
{
|
||||
return hash;
|
||||
}
|
||||
|
||||
bool Node::inOpenSet()
|
||||
bool Node::inOpenSet()
|
||||
{
|
||||
return heapIdx >= 0;
|
||||
}
|
||||
|
||||
wstring Node::toString()
|
||||
wstring Node::toString()
|
||||
{
|
||||
return _toString<int>(x) + L", " + _toString<int>(y) + L", " + _toString<int>(z);
|
||||
return std::to_wstring(x) + L", " + std::to_wstring(y) + L", " + std::to_wstring(z);
|
||||
}
|
||||
@@ -28,10 +28,9 @@ bool NotGateTile::isToggledTooFrequently(Level *level, int x, int y, int z, bool
|
||||
if (add) recentToggles[level]->push_back(Toggle(x, y, z, level->getGameTime()));
|
||||
int count = 0;
|
||||
|
||||
AUTO_VAR(itEnd, recentToggles[level]->end());
|
||||
for (AUTO_VAR(it, recentToggles[level]->begin()); it != itEnd; it++)
|
||||
for (const auto& it : *recentToggles[level])
|
||||
{
|
||||
if (it->x == x && it->y == y && it->z == z)
|
||||
if (it.x == x && it.y == y && it.z == z)
|
||||
{
|
||||
count++;
|
||||
if (count >= MAX_RECENT_TOGGLES)
|
||||
@@ -122,7 +121,7 @@ void NotGateTile::tick(Level *level, int x, int y, int z, Random *random)
|
||||
}
|
||||
}
|
||||
|
||||
if (on)
|
||||
if (on)
|
||||
{
|
||||
if (neighborSignal)
|
||||
{
|
||||
@@ -153,7 +152,7 @@ void NotGateTile::tick(Level *level, int x, int y, int z, Random *random)
|
||||
level->setTileAndData(x, y, z, Tile::redstoneTorch_on_Id, level->getData(x, y, z), Tile::UPDATE_ALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
app.DebugPrintf("Torch at (%d,%d,%d) has toggled too many times\n",x,y,z);
|
||||
}
|
||||
}
|
||||
@@ -236,9 +235,9 @@ void NotGateTile::levelTimeChanged(Level *level, __int64 delta, __int64 newTime)
|
||||
|
||||
if (toggles != NULL)
|
||||
{
|
||||
for (AUTO_VAR(it,toggles->begin()); it != toggles->end(); ++it)
|
||||
for (auto& toggle : *toggles)
|
||||
{
|
||||
(*it).when += delta;
|
||||
toggle.when += delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ File OldChunkStorage::getFile(int x, int z)
|
||||
file = File( file, wstring( name ) );
|
||||
if ( !file.exists() )
|
||||
{
|
||||
if (!create)
|
||||
if (!create)
|
||||
{
|
||||
return File(L"");
|
||||
}
|
||||
@@ -163,7 +163,7 @@ void OldChunkStorage::save(Level *level, LevelChunk *levelChunk)
|
||||
{
|
||||
LevelData *levelData = level->getLevelData();
|
||||
levelData->setSizeOnDisk( levelData->getSizeOnDisk() - file.length() );
|
||||
}
|
||||
}
|
||||
|
||||
// 4J - removed try/catch
|
||||
// try {
|
||||
@@ -202,7 +202,7 @@ bool OldChunkStorage::saveEntities(LevelChunk *lc, Level *level, CompoundTag *ta
|
||||
|
||||
lc->lastSaveHadEntities = false;
|
||||
ListTag<CompoundTag> *entityTags = new ListTag<CompoundTag>();
|
||||
|
||||
|
||||
#ifdef _ENTITIES_RW_SECTION
|
||||
EnterCriticalRWSection(&lc->m_csEntities, true);
|
||||
#else
|
||||
@@ -210,17 +210,14 @@ bool OldChunkStorage::saveEntities(LevelChunk *lc, Level *level, CompoundTag *ta
|
||||
#endif
|
||||
for (int i = 0; i < lc->ENTITY_BLOCKS_LENGTH; i++)
|
||||
{
|
||||
AUTO_VAR(itEnd, lc->entityBlocks[i]->end());
|
||||
for( vector<shared_ptr<Entity> >::iterator it = lc->entityBlocks[i]->begin(); it != itEnd; it++ )
|
||||
for( auto& e : *lc->entityBlocks[i] )
|
||||
{
|
||||
shared_ptr<Entity> e = *it;
|
||||
lc->lastSaveHadEntities = true;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
if (e->save(teTag))
|
||||
if ( e && e->save(teTag))
|
||||
{
|
||||
entityTags->add(teTag);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#ifdef _ENTITIES_RW_SECTION
|
||||
@@ -264,15 +261,13 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, DataOutputStream *dos)
|
||||
#ifndef SPLIT_SAVES
|
||||
saveEntities(lc, level, tag);
|
||||
#endif
|
||||
|
||||
|
||||
PIXBeginNamedEvent(0,"Saving tile entities");
|
||||
ListTag<CompoundTag> *tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
AUTO_VAR(itEnd, lc->tileEntities.end());
|
||||
for( unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
it != itEnd; it++)
|
||||
for(auto& it : lc->tileEntities)
|
||||
{
|
||||
shared_ptr<TileEntity> te = it->second;
|
||||
shared_ptr<TileEntity> te = it.second;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
te->save(teTag);
|
||||
tileEntityTags->add(teTag);
|
||||
@@ -358,11 +353,9 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag)
|
||||
PIXBeginNamedEvent(0,"Saving tile entities");
|
||||
ListTag<CompoundTag> *tileEntityTags = new ListTag<CompoundTag>();
|
||||
|
||||
AUTO_VAR(itEnd, lc->tileEntities.end());
|
||||
for( unordered_map<TilePos, shared_ptr<TileEntity>, TilePosKeyHash, TilePosKeyEq>::iterator it = lc->tileEntities.begin();
|
||||
it != itEnd; it++)
|
||||
for(auto& it : lc->tileEntities)
|
||||
{
|
||||
shared_ptr<TileEntity> te = it->second;
|
||||
shared_ptr<TileEntity> te = it.second;
|
||||
CompoundTag *teTag = new CompoundTag();
|
||||
te->save(teTag);
|
||||
tileEntityTags->add(teTag);
|
||||
@@ -451,7 +444,7 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis)
|
||||
|
||||
dis->readFully(levelChunk->heightmap);
|
||||
|
||||
levelChunk->terrainPopulated = dis->readShort();
|
||||
levelChunk->terrainPopulated = dis->readShort();
|
||||
// If all neighbours have been post-processed, then we should have done the post-post-processing now. Check that this is set as if it isn't then we won't be able
|
||||
// to send network data for chunks, and we won't ever try and set it again as all the directional flags are now already set - should only be an issue for old maps
|
||||
// before this flag was added.
|
||||
@@ -537,13 +530,13 @@ LevelChunk *OldChunkStorage::load(Level *level, CompoundTag *tag)
|
||||
if( tag->get(L"TerrainPopulated") )
|
||||
{
|
||||
// Java bool type or byte bitfield
|
||||
levelChunk->terrainPopulated = tag->getByte(L"TerrainPopulated");
|
||||
levelChunk->terrainPopulated = tag->getByte(L"TerrainPopulated");
|
||||
if( levelChunk->terrainPopulated >= 1 ) levelChunk->terrainPopulated = LevelChunk::sTerrainPopulatedAllNeighbours | LevelChunk::sTerrainPostPostProcessed; // Convert from old bool type to new bitfield
|
||||
}
|
||||
else
|
||||
{
|
||||
// New style short
|
||||
levelChunk->terrainPopulated = tag->getShort(L"TerrainPopulatedFlags");
|
||||
levelChunk->terrainPopulated = tag->getShort(L"TerrainPopulatedFlags");
|
||||
// If all neighbours have been post-processed, then we should have done the post-post-processing now. Check that this is set as if it isn't then we won't be able
|
||||
// to send network data for chunks, and we won't ever try and set it again as all the directional flags are now already set - should only be an issue for old maps
|
||||
// before this flag was added.
|
||||
|
||||
@@ -30,7 +30,7 @@ void Packet::staticCtor()
|
||||
map(8, true, false, true, true, typeid(SetHealthPacket), SetHealthPacket::create);
|
||||
map(9, true, true, true, false, typeid(RespawnPacket), RespawnPacket::create);
|
||||
|
||||
map(10, true, true, true, false, typeid(MovePlayerPacket), MovePlayerPacket::create);
|
||||
map(10, true, true, true, false, typeid(MovePlayerPacket), MovePlayerPacket::create);
|
||||
map(11, true, true, true, true, typeid(MovePlayerPacket::Pos), MovePlayerPacket::Pos::create);
|
||||
map(12, true, true, true, true, typeid(MovePlayerPacket::Rot), MovePlayerPacket::Rot::create);
|
||||
map(13, true, true, true, true, typeid(MovePlayerPacket::PosRot), MovePlayerPacket::PosRot::create);
|
||||
@@ -182,7 +182,7 @@ int Packet::renderPos = 0;
|
||||
void Packet::map(int id, bool receiveOnClient, bool receiveOnServer, bool sendToAnyClient, bool renderStats, const type_info& clazz, packetCreateFn createFn)
|
||||
{
|
||||
#if 0
|
||||
if (idToClassMap.count(id) > 0) throw new IllegalArgumentException(wstring(L"Duplicate packet id:") + _toString<int>(id));
|
||||
if (idToClassMap.count(id) > 0) throw new IllegalArgumentException(wstring(L"Duplicate packet id:") + std::to_wstring(id));
|
||||
if (classToIdMap.count(clazz) > 0) throw new IllegalArgumentException(L"Duplicate packet class:"); // TODO + clazz);
|
||||
#endif
|
||||
|
||||
@@ -228,7 +228,7 @@ void Packet::recordOutgoingPacket(shared_ptr<Packet> packet, int playerIndex)
|
||||
idx = 100;
|
||||
}
|
||||
#endif
|
||||
AUTO_VAR(it, outgoingStatistics.find(idx));
|
||||
auto it = outgoingStatistics.find(idx);
|
||||
|
||||
if( it == outgoingStatistics.end() )
|
||||
{
|
||||
@@ -248,8 +248,8 @@ void Packet::updatePacketStatsPIX()
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
#if PACKET_ENABLE_STAT_TRACKING
|
||||
|
||||
for( AUTO_VAR(it, outgoingStatistics.begin()); it != outgoingStatistics.end(); it++ )
|
||||
|
||||
for( auto it = outgoingStatistics.begin(); it != outgoingStatistics.end(); it++ )
|
||||
{
|
||||
Packet::PacketStatistics *stat = it->second;
|
||||
__int64 count = stat->getRunningCount();
|
||||
@@ -265,7 +265,7 @@ void Packet::updatePacketStatsPIX()
|
||||
#endif
|
||||
}
|
||||
|
||||
shared_ptr<Packet> Packet::getPacket(int id)
|
||||
shared_ptr<Packet> Packet::getPacket(int id)
|
||||
{
|
||||
// 4J: Removed try/catch
|
||||
return idToCreateMap[id]();
|
||||
@@ -332,16 +332,16 @@ shared_ptr<Packet> Packet::readPacket(DataInputStream *dis, bool isServer) // th
|
||||
//app.DebugPrintf("Bad packet id %d\n", id);
|
||||
__debugbreak();
|
||||
assert(false);
|
||||
// throw new IOException(wstring(L"Bad packet id ") + _toString<int>(id));
|
||||
// throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id));
|
||||
}
|
||||
|
||||
packet = getPacket(id);
|
||||
if (packet == NULL) assert(false);//throw new IOException(wstring(L"Bad packet id ") + _toString<int>(id));
|
||||
|
||||
if (packet == NULL) assert(false);//throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id));
|
||||
|
||||
//app.DebugPrintf("%s reading packet %d\n", isServer ? "Server" : "Client", packet->getId());
|
||||
packet->read(dis);
|
||||
// }
|
||||
// catch (EOFException e)
|
||||
// catch (EOFException e)
|
||||
// {
|
||||
// // reached end of stream
|
||||
// OutputDebugString("Reached end of stream");
|
||||
@@ -352,7 +352,7 @@ shared_ptr<Packet> Packet::readPacket(DataInputStream *dis, bool isServer) // th
|
||||
// 4J Stu - This changes a bit in 1.0.1, but we don't really use it so stick with what we have
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
#if PACKET_ENABLE_STAT_TRACKING
|
||||
AUTO_VAR(it, statistics.find(id));
|
||||
auto it = statistics.find(id);
|
||||
|
||||
if( it == statistics.end() )
|
||||
{
|
||||
@@ -380,7 +380,7 @@ void Packet::writePacket(shared_ptr<Packet> packet, DataOutputStream *dos) // th
|
||||
void Packet::writeUtf(const wstring& value, DataOutputStream *dos) // throws IOException TODO 4J JEV, should this declare a throws?
|
||||
{
|
||||
#if 0
|
||||
if (value.length() > Short::MAX_VALUE)
|
||||
if (value.length() > Short::MAX_VALUE)
|
||||
{
|
||||
throw new IOException(L"String too big");
|
||||
}
|
||||
@@ -408,7 +408,7 @@ wstring Packet::readUtf(DataInputStream *dis, int maxLength) // throws IOExcepti
|
||||
}
|
||||
|
||||
wstring builder = L"";
|
||||
for (int i = 0; i < stringLength; i++)
|
||||
for (int i = 0; i < stringLength; i++)
|
||||
{
|
||||
wchar_t rc = dis->readChar();
|
||||
builder.push_back( rc );
|
||||
@@ -432,7 +432,7 @@ void Packet::PacketStatistics::addPacket(int bytes)
|
||||
count++;
|
||||
}
|
||||
|
||||
int Packet::PacketStatistics::getCount()
|
||||
int Packet::PacketStatistics::getCount()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ double Packet::PacketStatistics::getAverageSize()
|
||||
return (double) totalSize / count;
|
||||
}
|
||||
|
||||
int Packet::PacketStatistics::getTotalSize()
|
||||
int Packet::PacketStatistics::getTotalSize()
|
||||
{
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@@ -26,14 +26,13 @@ PathFinder::~PathFinder()
|
||||
// references to the same things, so just need to destroy their containers
|
||||
delete [] neighbors->data;
|
||||
delete neighbors;
|
||||
AUTO_VAR(itEnd, nodes.end());
|
||||
for( AUTO_VAR(it, nodes.begin()); it != itEnd; it++ )
|
||||
for(auto& node : nodes)
|
||||
{
|
||||
delete it->second;
|
||||
delete node.second;
|
||||
}
|
||||
}
|
||||
|
||||
Path *PathFinder::findPath(Entity *from, Entity *to, float maxDist)
|
||||
Path *PathFinder::findPath(Entity *from, Entity *to, float maxDist)
|
||||
{
|
||||
return findPath(from, to->x, to->bb->y0, to->z, maxDist);
|
||||
}
|
||||
@@ -187,9 +186,9 @@ Node *PathFinder::getNode(Entity *entity, int x, int y, int z, Node *size, int j
|
||||
/*final*/ Node *PathFinder::getNode(int x, int y, int z)
|
||||
{
|
||||
int i = Node::createHash(x, y, z);
|
||||
Node *node;
|
||||
AUTO_VAR(it, nodes.find(i));
|
||||
if ( it == nodes.end() )
|
||||
Node *node = nullptr;
|
||||
auto it = nodes.find(i);
|
||||
if ( it == nodes.end() )
|
||||
{
|
||||
MemSect(54);
|
||||
node = new Node(x, y, z);
|
||||
@@ -279,7 +278,7 @@ Path *PathFinder::reconstruct_path(Node *from, Node *to)
|
||||
NodeArray nodes = NodeArray(count);
|
||||
n = to;
|
||||
nodes.data[--count] = n;
|
||||
while (n->cameFrom != NULL)
|
||||
while (n->cameFrom != NULL)
|
||||
{
|
||||
n = n->cameFrom;
|
||||
nodes.data[--count] = n;
|
||||
|
||||
@@ -70,7 +70,7 @@ void PigZombie::tick()
|
||||
Zombie::tick();
|
||||
}
|
||||
|
||||
bool PigZombie::canSpawn()
|
||||
bool PigZombie::canSpawn()
|
||||
{
|
||||
return level->difficulty > Difficulty::PEACEFUL && level->isUnobstructed(bb) && level->getCubes(shared_from_this(), bb)->empty() && !level->containsAnyLiquid(bb);
|
||||
}
|
||||
@@ -107,11 +107,9 @@ bool PigZombie::hurt(DamageSource *source, float dmg)
|
||||
shared_ptr<Entity> sourceEntity = source->getEntity();
|
||||
if ( sourceEntity != NULL && sourceEntity->instanceof(eTYPE_PLAYER) )
|
||||
{
|
||||
vector<shared_ptr<Entity> > *nearby = level->getEntities( shared_from_this(), bb->grow(32, 32, 32));
|
||||
AUTO_VAR(itEnd, nearby->end());
|
||||
for (AUTO_VAR(it, nearby->begin()); it != itEnd; it++)
|
||||
vector<shared_ptr<Entity> > *nearby = level->getEntities( shared_from_this(), bb->grow(32, 32, 32));
|
||||
for (auto& e : *nearby)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //nearby->at(i);
|
||||
if ( e->instanceof(eTYPE_PIGZOMBIE) )
|
||||
{
|
||||
shared_ptr<PigZombie> pigZombie = dynamic_pointer_cast<PigZombie>(e);
|
||||
|
||||
@@ -123,14 +123,14 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount)
|
||||
if (!entities->empty())
|
||||
{
|
||||
vector< shared_ptr<Entity> > collisionHolder;
|
||||
for( AUTO_VAR(it, entities->begin()); it != entities->end(); it++ )
|
||||
for(auto& it : *entities)
|
||||
{
|
||||
collisionHolder.push_back(*it);
|
||||
collisionHolder.push_back(it);
|
||||
}
|
||||
|
||||
for( AUTO_VAR(it, collisionHolder.begin()); it != collisionHolder.end(); it++ )
|
||||
for(auto& it : collisionHolder)
|
||||
{
|
||||
(*it)->move(amount * Facing::STEP_X[facing],
|
||||
it->move(amount * Facing::STEP_X[facing],
|
||||
amount * Facing::STEP_Y[facing],
|
||||
amount * Facing::STEP_Z[facing]);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,8 @@ bool PlayGoal::canUse()
|
||||
|
||||
vector<shared_ptr<Entity> > *children = mob->level->getEntitiesOfClass(typeid(Villager), mob->bb->grow(6, 3, 6));
|
||||
double closestDistSqr = Double::MAX_VALUE;
|
||||
//for (Entity c : children)
|
||||
for(AUTO_VAR(it, children->begin()); it != children->end(); ++it)
|
||||
for(auto& c : *children)
|
||||
{
|
||||
shared_ptr<Entity> c = *it;
|
||||
if (c.get() == mob) continue;
|
||||
shared_ptr<Villager> friendV = dynamic_pointer_cast<Villager>(c);
|
||||
if (friendV->isChasing()) continue;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// All the instanceof s from Java have been converted to dynamic_cast in this file
|
||||
// Once all the classes are finished it may be that we do not need to use dynamic_cast
|
||||
// for every test and a simple virtual function should suffice. We probably only need
|
||||
// for every test and a simple virtual function should suffice. We probably only need
|
||||
// dynamic_cast to find one of the classes that an object derives from, and not to find
|
||||
// the derived class itself (which should own the virtual GetType function)
|
||||
|
||||
@@ -348,7 +348,7 @@ void Player::tick()
|
||||
zCloak += zca * 0.25;
|
||||
yCloak += yca * 0.25;
|
||||
|
||||
if (riding == NULL)
|
||||
if (riding == NULL)
|
||||
{
|
||||
if( minecartAchievementPos != NULL )
|
||||
{
|
||||
@@ -458,7 +458,7 @@ void Player::tick()
|
||||
// minecart. For some reason some of the torches come off so it will also need some fixing along the way.
|
||||
static bool madeTrack = false;
|
||||
if( !madeTrack )
|
||||
{
|
||||
{
|
||||
this->drop( shared_ptr<ItemInstance>( new ItemInstance( Item::minecart, 1 ) ) );
|
||||
this->drop( shared_ptr<ItemInstance>( new ItemInstance( Tile::goldenRail, 10 ) ) );
|
||||
this->drop( shared_ptr<ItemInstance>( new ItemInstance( Tile::lever, 10 ) ) );
|
||||
@@ -631,8 +631,8 @@ void Player::ride(shared_ptr<Entity> e)
|
||||
LivingEntity::ride(e);
|
||||
}
|
||||
|
||||
void Player::setPlayerDefaultSkin(EDefaultSkins skin)
|
||||
{
|
||||
void Player::setPlayerDefaultSkin(EDefaultSkins skin)
|
||||
{
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
wprintf(L"Setting default skin to %d for player %ls\n", skin, name.c_str() );
|
||||
#endif
|
||||
@@ -651,8 +651,8 @@ void Player::setCustomSkin(DWORD skinId)
|
||||
|
||||
setAnimOverrideBitmask(getSkinAnimOverrideBitmask(skinId));
|
||||
if( !GET_IS_DLC_SKIN_FROM_BITMASK(skinId) )
|
||||
{
|
||||
// GET_UGC_SKIN_ID_FROM_BITMASK will always be zero - this was for a possible custom skin editor skin
|
||||
{
|
||||
// GET_UGC_SKIN_ID_FROM_BITMASK will always be zero - this was for a possible custom skin editor skin
|
||||
DWORD ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId);
|
||||
DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId);
|
||||
if( ugcSkinIndex == 0 && defaultSkinIndex > 0 )
|
||||
@@ -722,7 +722,7 @@ unsigned int Player::getSkinAnimOverrideBitmask(DWORD skinId)
|
||||
{
|
||||
unsigned long bitmask = 0L;
|
||||
if( GET_IS_DLC_SKIN_FROM_BITMASK(skinId) )
|
||||
{
|
||||
{
|
||||
// Temp check for anim override
|
||||
switch( GET_DLC_SKIN_ID_FROM_BITMASK(skinId) )
|
||||
{
|
||||
@@ -785,7 +785,7 @@ void Player::setCustomCape(DWORD capeId)
|
||||
else
|
||||
{
|
||||
MOJANG_DATA *pMojangData=app.GetMojangDataForXuid(getOnlineXuid());
|
||||
if(pMojangData)
|
||||
if(pMojangData)
|
||||
{
|
||||
// Cape
|
||||
if(pMojangData->wchCape)
|
||||
@@ -822,7 +822,7 @@ void Player::setCustomCape(DWORD capeId)
|
||||
|
||||
DWORD Player::getCapeIdFromPath(const wstring &cape)
|
||||
{
|
||||
bool dlcCape = false;
|
||||
bool dlcCape = false;
|
||||
unsigned int capeId = 0;
|
||||
|
||||
if(cape.size() >= 14)
|
||||
@@ -886,7 +886,7 @@ void Player::ChangePlayerSkin()
|
||||
this->customTextureUrl=L"";
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if(m_uiPlayerCurrentSkin>0)
|
||||
{
|
||||
// change this players custom texture url
|
||||
@@ -900,7 +900,7 @@ void Player::prepareCustomTextures()
|
||||
{
|
||||
MOJANG_DATA *pMojangData=app.GetMojangDataForXuid(getOnlineXuid());
|
||||
|
||||
if(pMojangData)
|
||||
if(pMojangData)
|
||||
{
|
||||
// Skin
|
||||
if(pMojangData->wchSkin)
|
||||
@@ -1054,11 +1054,9 @@ void Player::aiStep()
|
||||
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), pickupArea);
|
||||
if (entities != NULL)
|
||||
{
|
||||
AUTO_VAR(itEnd, entities->end());
|
||||
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
|
||||
for (auto& e : *entities)
|
||||
{
|
||||
shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
if (!e->removed)
|
||||
if ( e && !e->removed)
|
||||
{
|
||||
touch(e);
|
||||
}
|
||||
@@ -1135,11 +1133,14 @@ void Player::awardKillScore(shared_ptr<Entity> victim, int awardPoints)
|
||||
|
||||
if(objectives)
|
||||
{
|
||||
for (AUTO_VAR(it,objectives->begin()); it != objectives->end(); ++it)
|
||||
for (auto& objective : *objectives)
|
||||
{
|
||||
Objective *objective = *it;
|
||||
Score *score = getScoreboard()->getPlayerScore(getAName(), objective);
|
||||
score->increment();
|
||||
if ( objective )
|
||||
{
|
||||
Score *score = getScoreboard()->getPlayerScore(getAName(), objective);
|
||||
if ( score )
|
||||
score->increment();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1546,7 +1547,7 @@ bool Player::interact(shared_ptr<Entity> entity)
|
||||
}
|
||||
|
||||
if ( (item != NULL) && entity->instanceof(eTYPE_LIVINGENTITY) )
|
||||
{
|
||||
{
|
||||
// 4J - PC Comments
|
||||
// Hack to prevent item stacks from decrementing if the player has
|
||||
// the ability to instabuild
|
||||
@@ -1597,7 +1598,7 @@ void Player::attack(shared_ptr<Entity> entity)
|
||||
|
||||
int knockback = 0;
|
||||
float magicBoost = 0;
|
||||
|
||||
|
||||
if ( entity->instanceof(eTYPE_LIVINGENTITY) )
|
||||
{
|
||||
shared_ptr<Player> thisPlayer = dynamic_pointer_cast<Player>(shared_from_this());
|
||||
@@ -1657,7 +1658,7 @@ void Player::attack(shared_ptr<Entity> entity)
|
||||
}
|
||||
setLastHurtMob(entity);
|
||||
|
||||
|
||||
|
||||
if ( entity->instanceof(eTYPE_LIVINGENTITY) )
|
||||
{
|
||||
shared_ptr<LivingEntity> mob = dynamic_pointer_cast<LivingEntity>(entity);
|
||||
@@ -1800,11 +1801,11 @@ Player::BedSleepingResult Player::startSleepInBed(int x, int y, int z, bool bTes
|
||||
}
|
||||
|
||||
// This causes a message to be displayed, so we do want to show the tooltip in test mode
|
||||
if (!bTestUse && level->isDay())
|
||||
if (!bTestUse && level->isDay())
|
||||
{
|
||||
// may not sleep during day
|
||||
return NOT_POSSIBLE_NOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(bTestUse)
|
||||
@@ -1889,7 +1890,7 @@ void Player::setBedOffset(int bedDirection)
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param forcefulWakeUp
|
||||
* If the player has been forced to wake up. When this happens,
|
||||
* the client will skip the wake-up animation. For example, when
|
||||
@@ -2193,7 +2194,7 @@ void Player::checkMovementStatistiscs(double dx, double dy, double dz)
|
||||
|
||||
|
||||
void Player::checkRidingStatistiscs(double dx, double dy, double dz)
|
||||
{
|
||||
{
|
||||
if (riding != NULL)
|
||||
{
|
||||
int distance = (int) Math::round(sqrt(dx * dx + dy * dy + dz * dz) * 100.0f);
|
||||
@@ -2215,7 +2216,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz)
|
||||
minecartAchievementPos = new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z));
|
||||
}
|
||||
// 4J-PB - changed this because our world isn't big enough to go 1000m
|
||||
else
|
||||
else
|
||||
{
|
||||
// 4-JEV, changed slightly to add extra parameters for event on durango.
|
||||
int dist = minecartAchievementPos->dist(Mth::floor(x), Mth::floor(y), Mth::floor(z));
|
||||
@@ -2242,7 +2243,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz)
|
||||
awardStat(GenericStats::onARail(), GenericStats::param_onARail(dist));
|
||||
m_bAwardedOnARail=true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2304,13 +2305,13 @@ void Player::killed(shared_ptr<LivingEntity> mob)
|
||||
case eTYPE_SKELETON:
|
||||
if( mob->isRiding() && mob->riding->GetType() == eTYPE_SPIDER )
|
||||
awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs());
|
||||
else
|
||||
else
|
||||
awardStat(GenericStats::killsSkeleton(), GenericStats::param_noArgs());
|
||||
break;
|
||||
case eTYPE_SPIDER:
|
||||
if( mob->rider.lock() != NULL && mob->rider.lock()->GetType() == eTYPE_SKELETON )
|
||||
awardStat(GenericStats::killsSpiderJockey(), GenericStats::param_noArgs());
|
||||
else
|
||||
else
|
||||
awardStat(GenericStats::killsSpider(), GenericStats::param_noArgs());
|
||||
break;
|
||||
case eTYPE_ZOMBIE:
|
||||
@@ -2432,7 +2433,7 @@ int Player::getXpNeededForNextLevel()
|
||||
/**
|
||||
* This method adds on to the player's exhaustion, which may decrease the
|
||||
* player's food level.
|
||||
*
|
||||
*
|
||||
* @param amount
|
||||
* Amount of exhaustion to add, between 0 and 20 (setting it to
|
||||
* 20 will guarantee that at least 1, and at most 4, food points
|
||||
@@ -2769,7 +2770,7 @@ void Player::setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGameP
|
||||
}
|
||||
}
|
||||
else if (privilege < ePlayerGamePrivilege_MAX )
|
||||
{
|
||||
{
|
||||
if(value!=0)
|
||||
{
|
||||
uiGamePrivileges|=(1<<privilege);
|
||||
@@ -3073,7 +3074,7 @@ void Player::enableAllPlayerPrivileges(unsigned int &uigamePrivileges, bool enab
|
||||
}
|
||||
|
||||
void Player::enableAllPlayerPrivileges(bool enable)
|
||||
{
|
||||
{
|
||||
Player::enableAllPlayerPrivileges(m_uiGamePrivileges,enable);
|
||||
}
|
||||
|
||||
@@ -3082,8 +3083,8 @@ bool Player::canCreateParticles()
|
||||
return !hasInvisiblePrivilege();
|
||||
}
|
||||
|
||||
vector<ModelPart *> *Player::GetAdditionalModelParts()
|
||||
{
|
||||
vector<ModelPart *> *Player::GetAdditionalModelParts()
|
||||
{
|
||||
if(m_ppAdditionalModelParts==NULL && !m_bCheckedForModelParts)
|
||||
{
|
||||
bool hasCustomTexture = !customTextureUrl.empty();
|
||||
@@ -3127,8 +3128,8 @@ vector<ModelPart *> *Player::GetAdditionalModelParts()
|
||||
return m_ppAdditionalModelParts;
|
||||
}
|
||||
|
||||
void Player::SetAdditionalModelParts(vector<ModelPart *> *ppAdditionalModelParts)
|
||||
{
|
||||
void Player::SetAdditionalModelParts(vector<ModelPart *> *ppAdditionalModelParts)
|
||||
{
|
||||
m_ppAdditionalModelParts=ppAdditionalModelParts;
|
||||
}
|
||||
|
||||
@@ -3139,7 +3140,7 @@ Player::ePlayerNameValidState Player::GetPlayerNameValidState(void)
|
||||
return m_ePlayerNameValidState;
|
||||
}
|
||||
|
||||
void Player::SetPlayerNameValidState(bool bState)
|
||||
void Player::SetPlayerNameValidState(bool bState)
|
||||
{
|
||||
if(bState)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user