1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)

* Code modernization: src/p*, src/q*, src/r*, src/s* (partial)

* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* C++ STL header style
* Spelling: vertice -> vertex
This commit is contained in:
Loïc Blot 2017-08-19 14:25:35 +02:00 committed by GitHub
parent 1992db1395
commit 7528986e44
28 changed files with 363 additions and 443 deletions

View file

@ -359,10 +359,8 @@ Server::~Server()
delete m_script;
// Delete detached inventories
for (std::map<std::string, Inventory*>::iterator
i = m_detached_inventories.begin();
i != m_detached_inventories.end(); ++i) {
delete i->second;
for (auto &detached_inventory : m_detached_inventories) {
delete detached_inventory.second;
}
}
@ -2298,14 +2296,12 @@ void Server::fillMediaCache()
paths.push_back(porting::path_user + DIR_DELIM + "textures" + DIR_DELIM + "server");
// Collect media file information from paths into cache
for(std::vector<std::string>::iterator i = paths.begin();
i != paths.end(); ++i) {
std::string mediapath = *i;
for (const std::string &mediapath : paths) {
std::vector<fs::DirListNode> dirlist = fs::GetDirListing(mediapath);
for (u32 j = 0; j < dirlist.size(); j++) {
if (dirlist[j].dir) // Ignode dirs
for (const fs::DirListNode &dln : dirlist) {
if (dln.dir) // Ignode dirs
continue;
std::string filename = dirlist[j].name;
std::string filename = dln.name;
// If name contains illegal characters, ignore the file
if (!string_allowed(filename, TEXTURENAME_ALLOWED_CHARS)) {
infostream<<"Server: ignoring illegal file name: \""
@ -2326,7 +2322,9 @@ void Server::fillMediaCache()
continue;
}
// Ok, attempt to load the file and add to cache
std::string filepath = mediapath + DIR_DELIM + filename;
std::string filepath;
filepath.append(mediapath).append(DIR_DELIM).append(filename);
// Read data
std::ifstream fis(filepath.c_str(), std::ios_base::binary);
if (!fis.good()) {