16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 12:29:18 +02:00

reformat: use auto on certain types

This commit is contained in:
jerrrrycho
2026-07-04 05:22:52 +02:00
parent f61068ff89
commit 20e7a99516
118 changed files with 2118 additions and 2063 deletions

View File

@@ -629,7 +629,7 @@ void TAnimModel::RaPrepare()
TSubModel::iInstance = reinterpret_cast<std::uintptr_t>( this ); //żeby nie robić cudzych animacji
TSubModel::pasText = &asText; // przekazanie tekstu do wyświetlacza (!!!! do przemyślenia)
for (auto entry : m_animlist) {
for (const auto entry : m_animlist) {
entry->PrepareModel();
}
}
@@ -690,7 +690,7 @@ void TAnimModel::AnimUpdate(double dt)
{ // wykonanie zakolejkowanych animacji, nawet gdy modele nie są aktualnie wyświetlane
acAnimList.remove_if([](std::weak_ptr<TAnimContainer> ptr)
{
std::shared_ptr<TAnimContainer> container = ptr.lock();
const std::shared_ptr<TAnimContainer> container = ptr.lock();
if (!container)
return true;

View File

@@ -45,7 +45,7 @@ TModel3d *
TModelsManager::LoadModel(std::string const &Name, std::string const &virtualName, bool dynamic) {
m_models.emplace_back();
auto model = m_models.back().LoadModel( Name, dynamic );
const auto model = m_models.back().LoadModel( Name, dynamic );
if( model != nullptr ) {
m_modelsmap.emplace( virtualName, m_models.size() - 1 );
}
@@ -95,7 +95,7 @@ TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const
postfix = "^^" + std::to_string(uid);
// see if we have it in the databank
auto banklookup { find_in_databank( filename + postfix ) };
const auto banklookup { find_in_databank( filename + postfix ) };
TModel3d *model { banklookup.second };
if( true == banklookup.first ) {
Global.asCurrentTexturePath = buftp;
@@ -103,7 +103,7 @@ TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const
}
// first load attempt, check if it's on disk
std::string disklookup { find_on_disk( filename ) };
const std::string disklookup { find_on_disk( filename ) };
if( false == disklookup.empty() ) {
model = LoadModel( disklookup, disklookup + postfix, Dynamic ); // model nie znaleziony, to wczytać
@@ -123,7 +123,7 @@ TModelsManager::GetModel(std::string const &Name, bool const Dynamic, bool const
std::pair<bool, TModel3d *>
TModelsManager::find_in_databank( std::string const &Name ) {
std::vector<std::string> filenames {
const std::vector<std::string> filenames {
Name,
paths::models + Name };
@@ -141,7 +141,7 @@ TModelsManager::find_in_databank( std::string const &Name ) {
std::string
TModelsManager::find_on_disk( std::string const &Name ) {
std::vector<std::string> extensions { { ".e3d" }, { ".t3d" } };
const std::vector<std::string> extensions { { ".e3d" }, { ".t3d" } };
for( auto const &extension : extensions ) {
auto lookup = FileExists(Name + extension) ? Name : FileExists(paths::models + Name + extension) ? paths::models + Name : "";

View File

@@ -183,7 +183,7 @@ void TSubModel::SetSelfIllum(float const Threshold, bool const Includechildren,
int TSubModel::SeekFaceNormal(std::vector<unsigned int> const &Masks, int const Startface, unsigned int const Mask, glm::vec3 const &Position, gfx::vertex_array const &Vertices)
{ // szukanie punktu stycznego do (pt), zwraca numer wierzchołka, a nie trójkąta
int facecount = m_geometry.vertex_count / 3;
const int facecount = m_geometry.vertex_count / 3;
for (int faceidx = Startface; faceidx < facecount; ++faceidx)
{
// pętla po trójkątach, od trójkąta (f)
@@ -913,7 +913,7 @@ int TSubModel::count_siblings()
{
auto siblingcount{0};
auto *sibling{Next};
const auto *sibling{Next};
while (sibling != nullptr)
{
++siblingcount;
@@ -1179,7 +1179,7 @@ void TSubModel::RaAnimation(glm::mat4 &m, TAnimType a)
case TAnimType::at_Billboard: // obrót w pionie do kamery
{
glm::mat4 mat = glm::make_mat4(OpenGLMatrices.data_array(GL_MODELVIEW));
auto gdzie = float3(mat[3][0], mat[3][1], mat[3][2]); // początek układu współrzędnych submodelu względem kamery
const auto gdzie = float3(mat[3][0], mat[3][1], mat[3][2]); // początek układu współrzędnych submodelu względem kamery
m = glm::mat4(1.0f);
m = glm::translate(m, glm::vec3(gdzie.x, gdzie.y, gdzie.z)); // początek układu zostaje bez zmian
m = glm::rotate(m, (float)atan2(gdzie.x, gdzie.z), glm::vec3(0.0f, 1.0f, 0.0f)); // jedynie obracamy w pionie o kąt
@@ -1231,9 +1231,9 @@ void TSubModel::serialize_geometry(std::ostream &Output, bool const Packed, bool
{
if (Packed)
{
auto vertices = GfxRenderer->Vertices(m_geometry.handle);
auto userdatas = GfxRenderer->UserData(m_geometry.handle);
bool has_userdata = !userdatas.empty();
const auto vertices = GfxRenderer->Vertices(m_geometry.handle);
const auto userdatas = GfxRenderer->UserData(m_geometry.handle);
const bool has_userdata = !userdatas.empty();
for (int i = 0; i < vertices.size(); ++i)
{
vertices[i].serialize_packed(Output, Indexed);
@@ -1248,9 +1248,9 @@ void TSubModel::serialize_geometry(std::ostream &Output, bool const Packed, bool
}
else
{
auto vertices = GfxRenderer->Vertices(m_geometry.handle);
auto userdatas = GfxRenderer->UserData(m_geometry.handle);
bool has_userdata = !userdatas.empty();
const auto vertices = GfxRenderer->Vertices(m_geometry.handle);
const auto userdatas = GfxRenderer->UserData(m_geometry.handle);
const bool has_userdata = !userdatas.empty();
for (int i = 0; i < vertices.size(); ++i)
{
vertices[i].serialize(Output, Indexed);
@@ -1682,7 +1682,7 @@ template <typename L, typename T> size_t get_container_pos(L &list, T o)
// strukturę TModel3d::SerializerContext?
void TSubModel::serialize(std::ostream &s, std::vector<TSubModel *> &models, std::vector<std::string> &names, std::vector<std::string> &textures, std::vector<float4x4> &transforms)
{
size_t end = (size_t)s.tellp() + 256;
const size_t end = (size_t)s.tellp() + 256;
if (!Next)
sn_utils::ls_int32(s, -1);
@@ -1743,7 +1743,7 @@ void TSubModel::serialize(std::ostream &s, std::vector<TSubModel *> &models, std
sn_utils::ls_float32(s, diffuseMultiplier);
// fill empty space
size_t fill = end - s.tellp();
const size_t fill = end - s.tellp();
for (size_t i = 0; i < fill; i++)
s.put(0);
}
@@ -1929,15 +1929,15 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
m_geometrybank = GfxRenderer->Create_Bank();
}
std::streampos end = s.tellg() + (std::streampos)size;
const std::streampos end = s.tellg() + (std::streampos)size;
bool hastangents{false};
bool hasuserdata{false};
while (s.tellg() < end)
{
uint32_t type = sn_utils::ld_uint32(s);
uint32_t size = sn_utils::ld_uint32(s) - 8;
size_t pos = s.tellg();
const uint32_t type = sn_utils::ld_uint32(s);
const uint32_t size = sn_utils::ld_uint32(s) - 8;
const size_t pos = s.tellg();
std::streampos end = pos + (std::streampos)size;
if ((type & 0x00FFFFFF) == MAKE_ID4('S', 'U', 'B', 0)) // submodels
@@ -1945,8 +1945,8 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
if (Root != nullptr)
throw std::runtime_error("e3d: duplicated SUB chunk");
size_t sm_size = 256 + 64 * (((type & 0xFF000000) >> 24) - '0');
size_t sm_cnt = size / sm_size;
const size_t sm_size = 256 + 64 * (((type & 0xFF000000) >> 24) - '0');
const size_t sm_cnt = size / sm_size;
iSubModelsCount = (int)sm_cnt;
Root = new TSubModel[sm_cnt];
for (size_t i = 0; i < sm_cnt; ++i)
@@ -2126,7 +2126,7 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
{
if (false == Matrices.empty())
throw std::runtime_error("e3d: duplicated TRA chunk");
size_t t_cnt = size / 64;
const size_t t_cnt = size / 64;
Matrices.resize(t_cnt);
for (size_t i = 0; i < t_cnt; ++i)
@@ -2136,7 +2136,7 @@ void TModel3d::deserialize(std::istream &s, size_t size, bool dynamic)
{
if (false == Matrices.empty())
throw std::runtime_error("e3d: duplicated TRA chunk");
size_t t_cnt = size / 128;
const size_t t_cnt = size / 128;
Matrices.resize(t_cnt);
for (size_t i = 0; i < t_cnt; ++i)
@@ -2362,8 +2362,8 @@ void TModel3d::LoadFromBinFile(std::string const &FileName, bool dynamic)
std::ifstream file(FileName, std::ios::binary);
uint32_t type = sn_utils::ld_uint32(file);
uint32_t size = sn_utils::ld_uint32(file) - 8;
const uint32_t type = sn_utils::ld_uint32(file);
const uint32_t size = sn_utils::ld_uint32(file) - 8;
if (type == MAKE_ID4('E', '3', 'D', '0'))
{
@@ -2384,7 +2384,7 @@ TSubModel *TModel3d::AppendChildFromGeometry(const std::string &name, const std:
{
iFlags |= 0x0200;
auto sm = new TSubModel();
const auto sm = new TSubModel();
sm->Parent = AddToNamed(parent.c_str(), sm);
sm->m_geometry.vertex_count = vertices.size();
sm->m_geometry.index_count = indices.size();

View File

@@ -137,7 +137,7 @@ void opengl_texture::gles_match_internalformat(GLuint internalformat)
for (int y = 0; y < data_height; y++)
for (int x = 0; x < data_width; x++)
{
int offset = (y * data_width + x) * 3;
const int offset = (y * data_width + x) * 3;
reverse[offset + 0] = data[offset + 2];
reverse[offset + 1] = data[offset + 1];
reverse[offset + 2] = data[offset + 0];
@@ -154,7 +154,7 @@ void opengl_texture::gles_match_internalformat(GLuint internalformat)
for (int y = 0; y < data_height; y++)
for (int x = 0; x < data_width; x++)
{
int offset = (y * data_width + x) * 4;
const int offset = (y * data_width + x) * 4;
reverse[offset + 0] = data[offset + 2];
reverse[offset + 1] = data[offset + 1];
reverse[offset + 2] = data[offset + 0];
@@ -206,9 +206,9 @@ void opengl_texture::gles_match_internalformat(GLuint internalformat)
for (int y = 0; y < data_height; y++)
for (int x = 0; x < data_width; x++)
{
int pixel = y * data_width + x;
int in_off = pixel * in_c;
int out_off = pixel * out_c;
const int pixel = y * data_width + x;
const int in_off = pixel * in_c;
const int out_off = pixel * out_c;
for (int i = 0; i < out_c; i++)
{
if (i < in_c)
@@ -426,9 +426,9 @@ opengl_texture::make_request() {
auto const components { Split( name, '?' ) };
auto dictionary = std::make_shared<dictionary_source>( components.back() );
const auto dictionary = std::make_shared<dictionary_source>( components.back() );
auto rt = std::make_shared<python_rt>();
const auto rt = std::make_shared<python_rt>();
rt->shared_tex = this;
Application.request( { ToLower( components.front() ), dictionary, rt } );
@@ -623,7 +623,7 @@ opengl_texture::load_DDS() {
void
opengl_texture::load_KTX() {
std::ifstream file( name + type, std::ios::binary | std::ios::ate ); file.unsetf( std::ios::skipws );
std::size_t filesize = static_cast<size_t>(file.tellg()); // ios::ate already positioned us at the end of the file
const std::size_t filesize = static_cast<size_t>(file.tellg()); // ios::ate already positioned us at the end of the file
file.seekg( 0, std::ios::beg ); // rewind the caret afterwards
std::vector<char> filecontent;
@@ -665,7 +665,7 @@ opengl_texture::load_KTX() {
started = true;
}
size_t data_offset = data.size();
const size_t data_offset = data.size();
data.resize(data.size() + sub_data.size_bytes);
memcpy(data.data() + data_offset, sub_data.buff, sub_data.size_bytes);
}
@@ -705,7 +705,7 @@ opengl_texture::load_TEX() {
file.read( (char *)&data_width, sizeof( int ) );
file.read( (char *)&data_height, sizeof( int ) );
std::size_t datasize = data_width * data_height * ( hasalpha ? 4 : 3 );
const std::size_t datasize = data_width * data_height * ( hasalpha ? 4 : 3 );
data.resize( datasize );
file.read( reinterpret_cast<char *>( &data[0] ), datasize );
@@ -772,7 +772,7 @@ opengl_texture::load_TGA() {
unsigned char buffer[ 4 ] = { 255, 255, 255, 255 }; // alpha channel will be white
auto datapointer = (unsigned int*)&data[0];
auto bufferpointer = (unsigned int*)&buffer[ 0 ];
const auto bufferpointer = (unsigned int*)&buffer[ 0 ];
int const pixelcount = data_width * data_height;
@@ -798,7 +798,7 @@ opengl_texture::load_TGA() {
const int pixelcount = data_width * data_height;
auto datapointer = (unsigned int *)&data[0];
auto bufferpointer = (unsigned int *)&buffer[ 0 ];
const auto bufferpointer = (unsigned int *)&buffer[ 0 ];
do {
unsigned char chunkheader = 0;
@@ -963,7 +963,7 @@ opengl_texture::create( bool const Static ) {
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
wrap_mode_s = GL_CLAMP_TO_BORDER;
wrap_mode_t = GL_CLAMP_TO_BORDER;
float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
const float borderColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor);
}
glTexParameteri( target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
@@ -1006,7 +1006,7 @@ opengl_texture::create( bool const Static ) {
// now map that mess into opengl internal format
GLint components = data_components;
auto f_it = precompressed_formats.find(data_format);
const auto f_it = precompressed_formats.find(data_format);
if (f_it != precompressed_formats.end())
components = data_format;
@@ -1024,7 +1024,7 @@ opengl_texture::create( bool const Static ) {
gles_match_internalformat(internal_format);
}
auto blocksize_it = precompressed_formats.find(internal_format);
const auto blocksize_it = precompressed_formats.find(internal_format);
if ( data_mapcount == 1 && !glGenerateMipmap ) {
glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
@@ -1411,7 +1411,7 @@ std::string
texture_manager::info() const {
// TODO: cache this data and update only during resource sweep
std::size_t totaltexturecount{ m_textures.size() - 1 };
const std::size_t totaltexturecount{ m_textures.size() - 1 };
std::size_t totaltexturesize{ 0 };
#ifdef EU07_DEFERRED_TEXTURE_UPLOAD
std::size_t readytexturecount{ 0 };