C++03 oldify in various source files

This commit is contained in:
SmallJoker 2018-05-18 11:10:53 +02:00
parent 695d02e6bd
commit 263400b3d8
6 changed files with 38 additions and 26 deletions

View File

@ -837,8 +837,8 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
};
if (m_is_player) {
// Move minimal Y position to 0 (feet position)
for (video::S3DVertex &vertex : vertices)
vertex.Pos.Y += dy;
for (size_t i = 0; i < 4; i++)
vertices[i].Pos.Y += dy;
}
u16 indices[] = {0,1,2,2,3,0};
buf->append(vertices, 4, indices, 6);
@ -861,8 +861,8 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
};
if (m_is_player) {
// Move minimal Y position to 0 (feet position)
for (video::S3DVertex &vertex : vertices)
vertex.Pos.Y += dy;
for (size_t i = 0; i < 4; i++)
vertices[i].Pos.Y += dy;
}
u16 indices[] = {0,1,2,2,3,0};
buf->append(vertices, 4, indices, 6);

View File

@ -362,20 +362,22 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
// Force update each ClientEnvironment::step()
bool is_first = collision_info->empty();
for (const auto &colinfo : result.collisions) {
collision_info->push_back(colinfo);
for (std::vector<CollisionInfo>::const_iterator
colinfo = result.collisions.begin();
colinfo != result.collisions.end(); ++colinfo) {
collision_info->push_back(*colinfo);
if (colinfo.type != COLLISION_NODE ||
colinfo.new_speed.Y != 0 ||
if (colinfo->type != COLLISION_NODE ||
colinfo->new_speed.Y != 0 ||
(could_sneak && m_sneak_node_exists))
continue;
diff = intToFloat(colinfo.node_p, BS) - position;
diff = intToFloat(colinfo->node_p, BS) - position;
// Find nearest colliding node
f32 len = diff.getLength();
if (is_first || len < distance) {
m_standing_node = colinfo.node_p;
m_standing_node = colinfo->node_p;
distance = len;
}
}

View File

@ -249,7 +249,11 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox,
int facedir = n.getFaceDir(nodemgr);
u8 axisdir = facedir>>2;
facedir&=0x03;
for (aabb3f box : fixed) {
for (std::vector<aabb3f>::const_iterator
i = fixed.begin();
i != fixed.end(); ++i) {
aabb3f box = *i;
if (nodebox.type == NODEBOX_LEVELED)
box.MaxEdge.Y = (-0.5f + n.getLevel(nodemgr) / 64.0f) * BS;

View File

@ -1660,8 +1660,10 @@ void Server::SendChatMessage(u16 peer_id, const std::wstring &message)
Send(&pkt);
} else {
for (u16 id : m_clients.getClientIDs())
SendChatMessage(id, message);
std::vector<u16> clients = m_clients.getClientIDs();
for (std::vector<u16>::iterator it = clients.begin();
it != clients.end(); ++it)
SendChatMessage(*it, message);
}
}

View File

@ -265,7 +265,7 @@ void LBMManager::applyLBMs(ServerEnvironment *env, MapBlock *block, u32 stamp)
for (; it != m_lbm_lookup.end(); ++it) {
// Cache previous version to speedup lookup which has a very high performance
// penalty on each call
content_t previous_c{};
content_t previous_c = CONTENT_IGNORE;
std::vector<LoadingBlockModifierDef *> *lbm_list = NULL;
for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++)
@ -1026,9 +1026,10 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
infostream << "ServerEnvironment::clearObjects(): "
<< "Removing all active objects" << std::endl;
std::vector<u16> objects_to_remove;
for (auto &it : m_active_objects) {
u16 id = it.first;
ServerActiveObject* obj = it.second;
for (ActiveObjectMap::iterator it = m_active_objects.begin();
it != m_active_objects.end(); ++it) {
u16 id = it->first;
ServerActiveObject* obj = it->second;
if (obj->getType() == ACTIVEOBJECT_TYPE_PLAYER)
continue;
@ -1054,8 +1055,9 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
}
// Remove references from m_active_objects
for (u16 i : objects_to_remove) {
m_active_objects.erase(i);
for (std::vector<u16>::iterator it = objects_to_remove.begin();
it != objects_to_remove.end(); ++it) {
m_active_objects.erase(*it);
}
// Get list of loaded blocks
@ -1822,8 +1824,9 @@ void ServerEnvironment::removeRemovedObjects()
objects_to_remove.push_back(id);
}
// Remove references from m_active_objects
for (u16 i : objects_to_remove) {
m_active_objects.erase(i);
for (std::vector<u16>::iterator it = objects_to_remove.begin();
it != objects_to_remove.end(); ++it) {
m_active_objects.erase(*it);
}
}
@ -2093,8 +2096,9 @@ void ServerEnvironment::deactivateFarObjects(bool _force_delete)
}
// Remove references from m_active_objects
for (u16 i : objects_to_remove) {
m_active_objects.erase(i);
for (std::vector<u16>::iterator it = objects_to_remove.begin();
it != objects_to_remove.end(); ++it) {
m_active_objects.erase(*it);
}
}
@ -2128,7 +2132,7 @@ bool ServerEnvironment::saveStaticToBlock(
ServerActiveObject *obj, const StaticObject &s_obj,
u32 mod_reason)
{
MapBlock *block = nullptr;
MapBlock *block = NULL;
try {
block = m_map->emergeBlock(blockpos);
} catch (InvalidPositionException &e) {

View File

@ -408,7 +408,7 @@ public:
alSource3f(sound->source_id, AL_POSITION, 0, 0, 0);
alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0);
alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
volume = std::fmax(0.0f, volume);
volume = MYMAX(0.0f, volume);
alSourcef(sound->source_id, AL_GAIN, volume);
alSourcePlay(sound->source_id);
warn_if_error(alGetError(), "createPlayingSound");
@ -436,7 +436,7 @@ public:
alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
// Multiply by 3 to compensate for reducing AL_REFERENCE_DISTANCE from
// the previous value of 30 to the new value of 10
volume = std::fmax(0.0f, volume * 3.0f);
volume = MYMAX(0.0f, volume * 3.0f);
alSourcef(sound->source_id, AL_GAIN, volume);
alSourcePlay(sound->source_id);
warn_if_error(alGetError(), "createPlayingSoundAt");