mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 15:09:19 +02:00
reformat: use contains()
This commit is contained in:
@@ -937,7 +937,7 @@ std::vector<editor_terrain *> editor_mode::active_terrains()
|
|||||||
void editor_mode::add_grid_chunk(int Cx, int Cz)
|
void editor_mode::add_grid_chunk(int Cx, int Cz)
|
||||||
{
|
{
|
||||||
std::pair<int, int> const key{Cx, Cz};
|
std::pair<int, int> const key{Cx, Cz};
|
||||||
if (m_grid_chunks.count(key))
|
if (m_grid_chunks.contains(key))
|
||||||
return; // already occupied
|
return; // already occupied
|
||||||
|
|
||||||
double const size = chunk_grid_size();
|
double const size = chunk_grid_size();
|
||||||
@@ -984,7 +984,7 @@ void editor_mode::handle_chunk_edit_click(bool DeleteMode)
|
|||||||
// side); otherwise fill the clicked cell
|
// side); otherwise fill the clicked cell
|
||||||
bool const occupied = streaming
|
bool const occupied = streaming
|
||||||
? m_streamer.terrain_at(world.x, world.z) != nullptr
|
? m_streamer.terrain_at(world.x, world.z) != nullptr
|
||||||
: m_grid_chunks.count({cx, cz}) > 0;
|
: m_grid_chunks.contains({cx, cz});
|
||||||
int tcx = cx, tcz = cz;
|
int tcx = cx, tcz = cz;
|
||||||
if (occupied)
|
if (occupied)
|
||||||
{
|
{
|
||||||
@@ -1023,7 +1023,7 @@ void editor_mode::create_chunked_terrain()
|
|||||||
for (int dx = 0; dx < chunks; ++dx)
|
for (int dx = 0; dx < chunks; ++dx)
|
||||||
{
|
{
|
||||||
int const cx = ccx - half + dx, cz = ccz - half + dz;
|
int const cx = ccx - half + dx, cz = ccz - half + dz;
|
||||||
if (!m_grid_chunks.count({cx, cz}))
|
if (!m_grid_chunks.contains({cx, cz}))
|
||||||
{
|
{
|
||||||
add_grid_chunk(cx, cz);
|
add_grid_chunk(cx, cz);
|
||||||
++created;
|
++created;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ void terrain_streamer::update(glm::dvec3 const &CameraPos)
|
|||||||
for (int dx = -m_radius; dx <= m_radius && !built; ++dx)
|
for (int dx = -m_radius; dx <= m_radius && !built; ++dx)
|
||||||
{
|
{
|
||||||
chunk_key const key{camera.first + dx, camera.second + dz};
|
chunk_key const key{camera.first + dx, camera.second + dz};
|
||||||
if (m_chunks.count(key))
|
if (m_chunks.contains(key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// only stream chunks that were actually authored (exist on disk); empty space stays empty
|
// only stream chunks that were actually authored (exist on disk); empty space stays empty
|
||||||
@@ -236,7 +236,7 @@ void terrain_streamer::save_chunk(int Cx, int Cz, editor_terrain const &Terrain)
|
|||||||
void terrain_streamer::add_chunk(int Cx, int Cz)
|
void terrain_streamer::add_chunk(int Cx, int Cz)
|
||||||
{
|
{
|
||||||
chunk_key const key{Cx, Cz};
|
chunk_key const key{Cx, Cz};
|
||||||
if (m_chunks.count(key))
|
if (m_chunks.contains(key))
|
||||||
return; // already resident
|
return; // already resident
|
||||||
|
|
||||||
glm::dvec3 const centre = chunk_centre(Cx, Cz);
|
glm::dvec3 const centre = chunk_centre(Cx, Cz);
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ void gl::shader::parse_texture_entries(std::string &str)
|
|||||||
{
|
{
|
||||||
std::string comp;
|
std::string comp;
|
||||||
token_ss >> comp;
|
token_ss >> comp;
|
||||||
if (components_mapping.find(comp) == components_mapping.end())
|
if (!components_mapping.contains(comp))
|
||||||
log_error("unknown components: " + comp);
|
log_error("unknown components: " + comp);
|
||||||
else
|
else
|
||||||
conf.components = components_mapping[comp];
|
conf.components = components_mapping[comp];
|
||||||
@@ -272,7 +272,7 @@ void gl::shader::parse_param_entries(std::string &str)
|
|||||||
{
|
{
|
||||||
std::string tok;
|
std::string tok;
|
||||||
token_ss >> tok;
|
token_ss >> tok;
|
||||||
if (defaultparams_mapping.find(tok) == defaultparams_mapping.end())
|
if (!defaultparams_mapping.contains(tok))
|
||||||
log_error("unknown param default: " + tok);
|
log_error("unknown param default: " + tok);
|
||||||
conf.defaultparam = defaultparams_mapping[tok];
|
conf.defaultparam = defaultparams_mapping[tok];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ texture_manager::texture_manager() {
|
|||||||
void opengl_texture::gles_match_internalformat(GLuint internalformat)
|
void opengl_texture::gles_match_internalformat(GLuint internalformat)
|
||||||
{
|
{
|
||||||
// ignore compressed formats (and hope that GLES driver will support it)
|
// ignore compressed formats (and hope that GLES driver will support it)
|
||||||
if (precompressed_formats.find(internalformat) != precompressed_formats.end())
|
if (precompressed_formats.contains(internalformat))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// don't care about sRGB here
|
// don't care about sRGB here
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void opengl_material::finalize(bool Loadnow)
|
|||||||
key.erase(0, 1);
|
key.erase(0, 1);
|
||||||
key.pop_back();
|
key.pop_back();
|
||||||
std::map<std::string, int>::iterator lookup;
|
std::map<std::string, int>::iterator lookup;
|
||||||
if( shader && shader->texture_conf.find( key ) != shader->texture_conf.end() ) {
|
if( shader && shader->texture_conf.contains(key) ) {
|
||||||
textures[ shader->texture_conf[ key ].id ] = GfxRenderer->Fetch_Texture( value, Loadnow );
|
textures[ shader->texture_conf[ key ].id ] = GfxRenderer->Fetch_Texture( value, Loadnow );
|
||||||
}
|
}
|
||||||
else if( shader == nullptr
|
else if( shader == nullptr
|
||||||
@@ -161,7 +161,7 @@ void opengl_material::finalize(bool Loadnow)
|
|||||||
{
|
{
|
||||||
key.erase(0, 1);
|
key.erase(0, 1);
|
||||||
key.pop_back();
|
key.pop_back();
|
||||||
if (shader->param_conf.find(key) != shader->param_conf.end())
|
if (shader->param_conf.contains(key))
|
||||||
{
|
{
|
||||||
gl::shader::param_entry entry = shader->param_conf[key];
|
gl::shader::param_entry entry = shader->param_conf[key];
|
||||||
for (size_t i = 0; i < entry.size; i++)
|
for (size_t i = 0; i < entry.size; i++)
|
||||||
@@ -277,7 +277,7 @@ std::unordered_set<std::string> seasons = {
|
|||||||
|
|
||||||
bool is_season( std::string const &String ) {
|
bool is_season( std::string const &String ) {
|
||||||
|
|
||||||
return seasons.find(String) != seasons.end();
|
return seasons.contains(String);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_set<std::string> weather = {
|
std::unordered_set<std::string> weather = {
|
||||||
@@ -285,7 +285,7 @@ std::unordered_set<std::string> weather = {
|
|||||||
|
|
||||||
bool is_weather( std::string const &String ) {
|
bool is_weather( std::string const &String ) {
|
||||||
|
|
||||||
return weather.find(String) != weather.end();
|
return weather.contains(String);
|
||||||
}
|
}
|
||||||
|
|
||||||
// imports member data pair from the config file
|
// imports member data pair from the config file
|
||||||
|
|||||||
@@ -989,7 +989,7 @@ bool global_settings::ConfigParseHardware(cParser& Parser, const std::string& to
|
|||||||
Parser.getTokens(1);
|
Parser.getTokens(1);
|
||||||
std::string firstToken = Parser.peek();
|
std::string firstToken = Parser.peek();
|
||||||
|
|
||||||
if (firstToken.find('|') != std::string::npos || firstToken == "none" || uartfeatures_map.count(firstToken))
|
if (firstToken.find('|') != std::string::npos || firstToken == "none" || uartfeatures_map.contains(firstToken))
|
||||||
{
|
{
|
||||||
for (auto const& x : uartfeatures_map)
|
for (auto const& x : uartfeatures_map)
|
||||||
{
|
{
|
||||||
@@ -1003,7 +1003,7 @@ bool global_settings::ConfigParseHardware(cParser& Parser, const std::string& to
|
|||||||
{
|
{
|
||||||
std::getline(firstTokenStream, key, '|');
|
std::getline(firstTokenStream, key, '|');
|
||||||
|
|
||||||
if (uartfeatures_map.count(key))
|
if (uartfeatures_map.contains(key))
|
||||||
{
|
{
|
||||||
*uartfeatures_map[key] = true;
|
*uartfeatures_map[key] = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ std::string control_mapper::find(TSubModel const *Control) const
|
|||||||
bool control_mapper::contains(std::string const Control) const
|
bool control_mapper::contains(std::string const Control) const
|
||||||
{
|
{
|
||||||
|
|
||||||
return m_names.find(Control) != m_names.end();
|
return m_names.contains(Control);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::screen_entry::deserialize(cParser &Input)
|
void TTrain::screen_entry::deserialize(cParser &Input)
|
||||||
|
|||||||
Reference in New Issue
Block a user