mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Migrate to STL containers/algorithms.
This commit is contained in:
parent
e204bedf1d
commit
6a1670dbc3
63 changed files with 1330 additions and 1417 deletions
|
@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "profiler.h"
|
||||
#include "settings.h"
|
||||
#include "util/mathconstants.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
|
||||
|
||||
|
@ -83,7 +84,7 @@ MapSector * ClientMap::emergeSector(v2s16 p2d)
|
|||
|
||||
{
|
||||
//JMutexAutoLock lock(m_sector_mutex); // Bulk comment-out
|
||||
m_sectors.insert(p2d, sector);
|
||||
m_sectors[p2d] = sector;
|
||||
}
|
||||
|
||||
return sector;
|
||||
|
@ -164,11 +165,11 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
|
|||
|
||||
INodeDefManager *nodemgr = m_gamedef->ndef();
|
||||
|
||||
for(core::map<v3s16, MapBlock*>::Iterator
|
||||
i = m_drawlist.getIterator();
|
||||
i.atEnd() == false; i++)
|
||||
for(std::map<v3s16, MapBlock*>::iterator
|
||||
i = m_drawlist.begin();
|
||||
i != m_drawlist.end(); ++i)
|
||||
{
|
||||
MapBlock *block = i.getNode()->getValue();
|
||||
MapBlock *block = i->second;
|
||||
block->refDrop();
|
||||
}
|
||||
m_drawlist.clear();
|
||||
|
@ -215,11 +216,11 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
|
|||
// Blocks from which stuff was actually drawn
|
||||
//u32 blocks_without_stuff = 0;
|
||||
|
||||
for(core::map<v2s16, MapSector*>::Iterator
|
||||
si = m_sectors.getIterator();
|
||||
si.atEnd() == false; si++)
|
||||
for(std::map<v2s16, MapSector*>::iterator
|
||||
si = m_sectors.begin();
|
||||
si != m_sectors.end(); ++si)
|
||||
{
|
||||
MapSector *sector = si.getNode()->getValue();
|
||||
MapSector *sector = si->second;
|
||||
v2s16 sp = sector->getPos();
|
||||
|
||||
if(m_control.range_all == false)
|
||||
|
@ -231,7 +232,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
|
|||
continue;
|
||||
}
|
||||
|
||||
core::list< MapBlock * > sectorblocks;
|
||||
std::list< MapBlock * > sectorblocks;
|
||||
sector->getBlocks(sectorblocks);
|
||||
|
||||
/*
|
||||
|
@ -240,7 +241,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
|
|||
|
||||
u32 sector_blocks_drawn = 0;
|
||||
|
||||
core::list< MapBlock * >::Iterator i;
|
||||
std::list< MapBlock * >::iterator i;
|
||||
for(i=sectorblocks.begin(); i!=sectorblocks.end(); i++)
|
||||
{
|
||||
MapBlock *block = *i;
|
||||
|
@ -350,7 +351,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
|
|||
} // foreach sectorblocks
|
||||
|
||||
if(sector_blocks_drawn != 0)
|
||||
m_last_drawn_sectors[sp] = true;
|
||||
m_last_drawn_sectors.insert(sp);
|
||||
}
|
||||
|
||||
m_control.blocks_would_have_drawn = blocks_would_have_drawn;
|
||||
|
@ -368,12 +369,12 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
|
|||
struct MeshBufList
|
||||
{
|
||||
video::SMaterial m;
|
||||
core::list<scene::IMeshBuffer*> bufs;
|
||||
std::list<scene::IMeshBuffer*> bufs;
|
||||
};
|
||||
|
||||
struct MeshBufListList
|
||||
{
|
||||
core::list<MeshBufList> lists;
|
||||
std::list<MeshBufList> lists;
|
||||
|
||||
void clear()
|
||||
{
|
||||
|
@ -382,8 +383,8 @@ struct MeshBufListList
|
|||
|
||||
void add(scene::IMeshBuffer *buf)
|
||||
{
|
||||
for(core::list<MeshBufList>::Iterator i = lists.begin();
|
||||
i != lists.end(); i++){
|
||||
for(std::list<MeshBufList>::iterator i = lists.begin();
|
||||
i != lists.end(); ++i){
|
||||
MeshBufList &l = *i;
|
||||
if(l.m == buf->getMaterial()){
|
||||
l.bufs.push_back(buf);
|
||||
|
@ -487,11 +488,11 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||
|
||||
MeshBufListList drawbufs;
|
||||
|
||||
for(core::map<v3s16, MapBlock*>::Iterator
|
||||
i = m_drawlist.getIterator();
|
||||
i.atEnd() == false; i++)
|
||||
for(std::map<v3s16, MapBlock*>::iterator
|
||||
i = m_drawlist.begin();
|
||||
i != m_drawlist.end(); ++i)
|
||||
{
|
||||
MapBlock *block = i.getNode()->getValue();
|
||||
MapBlock *block = i->second;
|
||||
|
||||
// If the mesh of the block happened to get deleted, ignore it
|
||||
if(block->mesh == NULL)
|
||||
|
@ -569,11 +570,11 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||
}
|
||||
}
|
||||
|
||||
core::list<MeshBufList> &lists = drawbufs.lists;
|
||||
std::list<MeshBufList> &lists = drawbufs.lists;
|
||||
|
||||
int timecheck_counter = 0;
|
||||
for(core::list<MeshBufList>::Iterator i = lists.begin();
|
||||
i != lists.end(); i++)
|
||||
for(std::list<MeshBufList>::iterator i = lists.begin();
|
||||
i != lists.end(); ++i)
|
||||
{
|
||||
{
|
||||
timecheck_counter++;
|
||||
|
@ -595,8 +596,8 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||
|
||||
driver->setMaterial(list.m);
|
||||
|
||||
for(core::list<scene::IMeshBuffer*>::Iterator j = list.bufs.begin();
|
||||
j != list.bufs.end(); j++)
|
||||
for(std::list<scene::IMeshBuffer*>::iterator j = list.bufs.begin();
|
||||
j != list.bufs.end(); ++j)
|
||||
{
|
||||
scene::IMeshBuffer *buf = *j;
|
||||
driver->drawMeshBuffer(buf);
|
||||
|
@ -769,7 +770,7 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
|
|||
float sunlight_min_d = max_d*0.8;
|
||||
if(sunlight_min_d > 35*BS)
|
||||
sunlight_min_d = 35*BS;
|
||||
core::array<int> values;
|
||||
std::vector<int> values;
|
||||
for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
|
||||
v3f z_dir = z_directions[i];
|
||||
z_dir.normalize();
|
||||
|
@ -798,7 +799,7 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
|
|||
}
|
||||
int brightness_sum = 0;
|
||||
int brightness_count = 0;
|
||||
values.sort();
|
||||
std::sort(values.begin(), values.end());
|
||||
u32 num_values_to_use = values.size();
|
||||
if(num_values_to_use >= 10)
|
||||
num_values_to_use -= num_values_to_use/2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue