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) { if (m_is_player) {
// Move minimal Y position to 0 (feet position) // Move minimal Y position to 0 (feet position)
for (video::S3DVertex &vertex : vertices) for (size_t i = 0; i < 4; i++)
vertex.Pos.Y += dy; vertices[i].Pos.Y += dy;
} }
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
buf->append(vertices, 4, indices, 6); buf->append(vertices, 4, indices, 6);
@ -861,8 +861,8 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr,
}; };
if (m_is_player) { if (m_is_player) {
// Move minimal Y position to 0 (feet position) // Move minimal Y position to 0 (feet position)
for (video::S3DVertex &vertex : vertices) for (size_t i = 0; i < 4; i++)
vertex.Pos.Y += dy; vertices[i].Pos.Y += dy;
} }
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
buf->append(vertices, 4, indices, 6); 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() // Force update each ClientEnvironment::step()
bool is_first = collision_info->empty(); bool is_first = collision_info->empty();
for (const auto &colinfo : result.collisions) { for (std::vector<CollisionInfo>::const_iterator
collision_info->push_back(colinfo); colinfo = result.collisions.begin();
colinfo != result.collisions.end(); ++colinfo) {
collision_info->push_back(*colinfo);
if (colinfo.type != COLLISION_NODE || if (colinfo->type != COLLISION_NODE ||
colinfo.new_speed.Y != 0 || colinfo->new_speed.Y != 0 ||
(could_sneak && m_sneak_node_exists)) (could_sneak && m_sneak_node_exists))
continue; continue;
diff = intToFloat(colinfo.node_p, BS) - position; diff = intToFloat(colinfo->node_p, BS) - position;
// Find nearest colliding node // Find nearest colliding node
f32 len = diff.getLength(); f32 len = diff.getLength();
if (is_first || len < distance) { if (is_first || len < distance) {
m_standing_node = colinfo.node_p; m_standing_node = colinfo->node_p;
distance = len; distance = len;
} }
} }

View File

@ -249,7 +249,11 @@ void transformNodeBox(const MapNode &n, const NodeBox &nodebox,
int facedir = n.getFaceDir(nodemgr); int facedir = n.getFaceDir(nodemgr);
u8 axisdir = facedir>>2; u8 axisdir = facedir>>2;
facedir&=0x03; 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) if (nodebox.type == NODEBOX_LEVELED)
box.MaxEdge.Y = (-0.5f + n.getLevel(nodemgr) / 64.0f) * BS; 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); Send(&pkt);
} else { } else {
for (u16 id : m_clients.getClientIDs()) std::vector<u16> clients = m_clients.getClientIDs();
SendChatMessage(id, message); 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) { for (; it != m_lbm_lookup.end(); ++it) {
// Cache previous version to speedup lookup which has a very high performance // Cache previous version to speedup lookup which has a very high performance
// penalty on each call // penalty on each call
content_t previous_c{}; content_t previous_c = CONTENT_IGNORE;
std::vector<LoadingBlockModifierDef *> *lbm_list = NULL; std::vector<LoadingBlockModifierDef *> *lbm_list = NULL;
for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++) for (pos.X = 0; pos.X < MAP_BLOCKSIZE; pos.X++)
@ -1026,9 +1026,10 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
infostream << "ServerEnvironment::clearObjects(): " infostream << "ServerEnvironment::clearObjects(): "
<< "Removing all active objects" << std::endl; << "Removing all active objects" << std::endl;
std::vector<u16> objects_to_remove; std::vector<u16> objects_to_remove;
for (auto &it : m_active_objects) { for (ActiveObjectMap::iterator it = m_active_objects.begin();
u16 id = it.first; it != m_active_objects.end(); ++it) {
ServerActiveObject* obj = it.second; u16 id = it->first;
ServerActiveObject* obj = it->second;
if (obj->getType() == ACTIVEOBJECT_TYPE_PLAYER) if (obj->getType() == ACTIVEOBJECT_TYPE_PLAYER)
continue; continue;
@ -1054,8 +1055,9 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
} }
// Remove references from m_active_objects // Remove references from m_active_objects
for (u16 i : objects_to_remove) { for (std::vector<u16>::iterator it = objects_to_remove.begin();
m_active_objects.erase(i); it != objects_to_remove.end(); ++it) {
m_active_objects.erase(*it);
} }
// Get list of loaded blocks // Get list of loaded blocks
@ -1822,8 +1824,9 @@ void ServerEnvironment::removeRemovedObjects()
objects_to_remove.push_back(id); objects_to_remove.push_back(id);
} }
// Remove references from m_active_objects // Remove references from m_active_objects
for (u16 i : objects_to_remove) { for (std::vector<u16>::iterator it = objects_to_remove.begin();
m_active_objects.erase(i); 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 // Remove references from m_active_objects
for (u16 i : objects_to_remove) { for (std::vector<u16>::iterator it = objects_to_remove.begin();
m_active_objects.erase(i); it != objects_to_remove.end(); ++it) {
m_active_objects.erase(*it);
} }
} }
@ -2128,7 +2132,7 @@ bool ServerEnvironment::saveStaticToBlock(
ServerActiveObject *obj, const StaticObject &s_obj, ServerActiveObject *obj, const StaticObject &s_obj,
u32 mod_reason) u32 mod_reason)
{ {
MapBlock *block = nullptr; MapBlock *block = NULL;
try { try {
block = m_map->emergeBlock(blockpos); block = m_map->emergeBlock(blockpos);
} catch (InvalidPositionException &e) { } catch (InvalidPositionException &e) {

View File

@ -408,7 +408,7 @@ public:
alSource3f(sound->source_id, AL_POSITION, 0, 0, 0); alSource3f(sound->source_id, AL_POSITION, 0, 0, 0);
alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0); alSource3f(sound->source_id, AL_VELOCITY, 0, 0, 0);
alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE); 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); alSourcef(sound->source_id, AL_GAIN, volume);
alSourcePlay(sound->source_id); alSourcePlay(sound->source_id);
warn_if_error(alGetError(), "createPlayingSound"); warn_if_error(alGetError(), "createPlayingSound");
@ -436,7 +436,7 @@ public:
alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE); alSourcei(sound->source_id, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
// Multiply by 3 to compensate for reducing AL_REFERENCE_DISTANCE from // Multiply by 3 to compensate for reducing AL_REFERENCE_DISTANCE from
// the previous value of 30 to the new value of 10 // 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); alSourcef(sound->source_id, AL_GAIN, volume);
alSourcePlay(sound->source_id); alSourcePlay(sound->source_id);
warn_if_error(alGetError(), "createPlayingSoundAt"); warn_if_error(alGetError(), "createPlayingSoundAt");