Skip to content

Commit

Permalink
xrCore: Rewrite of CInifile
Browse files Browse the repository at this point in the history
  • Loading branch information
AMS21 committed Dec 4, 2023
1 parent 3fbf7f4 commit bfa0361
Show file tree
Hide file tree
Showing 46 changed files with 1,482 additions and 904 deletions.
2 changes: 1 addition & 1 deletion src/Layers/xrRender/ModelPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void CModelPool::Prefetch()
for (auto I = sect.Data.cbegin(); I != sect.Data.cend(); ++I)
{
const CInifile::Item& item = *I;
dxRender_Visual* V = Create(item.first.c_str());
dxRender_Visual* V = Create(item.name.c_str());
Delete(V, FALSE);
}
Logging(TRUE);
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool is_enough_address_space_available() { return true; }

int get_texture_load_lod(LPCSTR fn)
{
CInifile::Sect& sect = pSettings->r_section("reduce_lod_texture_list");
const CInifile::Sect& sect = pSettings->r_section("reduce_lod_texture_list");
auto it_ = sect.Data.cbegin();
auto it_e_ = sect.Data.cend();

Expand All @@ -38,7 +38,7 @@ int get_texture_load_lod(LPCSTR fn)

for (; it != it_e; ++it)
{
if (strstr(fn, it->first.c_str()))
if (strstr(fn, it->name.c_str()))
{
if (psTextureLOD < 1)
{
Expand Down
24 changes: 12 additions & 12 deletions src/Layers/xrRender/TextureDescrManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ void CTextureDescrMngr::LoadLTX(pcstr initial, bool listTHM)
const auto processAssociation = [&](const CInifile::Item& item)
{
if (listTHM)
Msg("\t\t%s = %s", item.first.c_str(), item.second.c_str());
Msg("\t\t%s = %s", item.name.c_str(), item.value.c_str());

lock.Enter();
texture_desc& desc = m_texture_details[item.first];
cl_dt_scaler*& dts = m_detail_scalers[item.first];
texture_desc& desc = m_texture_details[item.name];
cl_dt_scaler*& dts = m_detail_scalers[item.name];
lock.Leave();

if (desc.m_assoc)
Expand All @@ -68,19 +68,19 @@ void CTextureDescrMngr::LoadLTX(pcstr initial, bool listTHM)
string_path T;
float s;

const int res = sscanf(*item.second, "%[^,],%f", T, &s);
R_ASSERT4(res == 2, "Bad texture association", item.first.c_str(), fname);
const int res = sscanf(*item.value, "%[^,],%f", T, &s);
R_ASSERT4(res == 2, "Bad texture association", item.name.c_str(), fname);
desc.m_assoc->detail_name = T;
if (dts)
dts->scale = s;
else
dts = xr_new<cl_dt_scaler>(s);

if (strstr(item.second.c_str(), "usage[diffuse_or_bump]"))
if (strstr(item.value.c_str(), "usage[diffuse_or_bump]"))
desc.m_assoc->usage.set(texture_assoc::flDiffuseDetail | texture_assoc::flBumpDetail);
else if (strstr(item.second.c_str(), "usage[bump]"))
else if (strstr(item.value.c_str(), "usage[bump]"))
desc.m_assoc->usage.set(texture_assoc::flBumpDetail);
else if (strstr(item.second.c_str(), "usage[diffuse]"))
else if (strstr(item.value.c_str(), "usage[diffuse]"))
desc.m_assoc->usage.set(texture_assoc::flDiffuseDetail);
};
xr_parallel_for_each(data.Data, processAssociation);
Expand All @@ -97,10 +97,10 @@ void CTextureDescrMngr::LoadLTX(pcstr initial, bool listTHM)
const auto processSpecification = [&](const CInifile::Item& item)
{
if (listTHM)
Msg("\t\t%s = %s", item.first.c_str(), item.second.c_str());
Msg("\t\t%s = %s", item.name.c_str(), item.value.c_str());

lock.Enter();
texture_desc& desc = m_texture_details[item.first];
texture_desc& desc = m_texture_details[item.name];
lock.Leave();

if (desc.m_spec)
Expand All @@ -110,8 +110,8 @@ void CTextureDescrMngr::LoadLTX(pcstr initial, bool listTHM)

string_path bmode;
const int res =
sscanf(item.second.c_str(), "bump_mode[%[^]]], material[%f]", bmode, &desc.m_spec->m_material);
R_ASSERT4(res == 2, "Bad texture specification", item.first.c_str(), fname);
sscanf(item.value.c_str(), "bump_mode[%[^]]], material[%f]", bmode, &desc.m_spec->m_material);
R_ASSERT4(res == 2, "Bad texture specification", item.name.c_str(), fname);
if ((bmode[0] == 'u') && (bmode[1] == 's') && (bmode[2] == 'e') && (bmode[3] == ':'))
{
// bump-map specified
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderDX11/dx11Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void fix_texture_name(pstr fn)

int get_texture_load_lod(LPCSTR fn)
{
CInifile::Sect& sect = pSettings->r_section("reduce_lod_texture_list");
const CInifile::Sect& sect = pSettings->r_section("reduce_lod_texture_list");
auto it_ = sect.Data.cbegin();
auto it_e_ = sect.Data.cend();

Expand All @@ -29,7 +29,7 @@ int get_texture_load_lod(LPCSTR fn)

for (; it != it_e; ++it)
{
if (strstr(fn, it->first.c_str()))
if (strstr(fn, it->name.c_str()))
{
if (psTextureLOD < 1)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderGL/glTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ void fix_texture_name(pstr fn)

int get_texture_load_lod(LPCSTR fn)
{
CInifile::Sect& sect = pSettings->r_section("reduce_lod_texture_list");
const CInifile::Sect& sect = pSettings->r_section("reduce_lod_texture_list");

for (const auto& item : sect.Data)
{
if (strstr(fn, item.first.c_str()))
if (strstr(fn, item.name.c_str()))
{
if (psTextureLOD < 1)
return 0;
Expand Down
16 changes: 8 additions & 8 deletions src/utils/mp_configs_verifyer/configs_dump_verifyer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ LPCSTR configs_verifyer::get_section_diff(CInifile::Sect* sect_ptr, CInifile& ac

for (auto cit = sect_ptr->Data.cbegin(), ciet = sect_ptr->Data.cend(); cit != ciet; ++cit)
{
shared_str const& tmp_value = cit->second;
shared_str const& tmp_value = cit->value;
shared_str real_value;
if (tmp_active_param)
{
if (active_params.line_exist(sect_ptr->Name.c_str(), cit->first))
if (active_params.line_exist(sect_ptr->Name.c_str(), cit->name))
{
real_value = active_params.r_string(sect_ptr->Name.c_str(), cit->first.c_str());
real_value = active_params.r_string(sect_ptr->Name.c_str(), cit->name.c_str());
if (tmp_value != real_value)
{
pcstr tmp_key_str = nullptr;
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->first.c_str());
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->name.c_str());
STRCONCAT(diff_str, tmp_key_str, " = ", tmp_value.c_str(), ",right = ", real_value.c_str());
strncpy_s(dst_diff, diff_str, sizeof(dst_diff) - 1);
dst_diff[sizeof(dst_diff) - 1] = 0;
Expand All @@ -112,18 +112,18 @@ LPCSTR configs_verifyer::get_section_diff(CInifile::Sect* sect_ptr, CInifile& ac
continue;
}
}
if (!pSettings->line_exist(sect_ptr->Name, cit->first))
if (!pSettings->line_exist(sect_ptr->Name, cit->name))
{
STRCONCAT(diff_str, "line ", sect_ptr->Name.c_str(), "::", cit->first.c_str(), " not found");
STRCONCAT(diff_str, "line ", sect_ptr->Name.c_str(), "::", cit->name.c_str(), " not found");
strncpy_s(dst_diff, diff_str, sizeof(dst_diff) - 1);
dst_diff[sizeof(dst_diff) - 1] = 0;
return dst_diff;
}
real_value = pSettings->r_string(sect_ptr->Name.c_str(), cit->first.c_str());
real_value = pSettings->r_string(sect_ptr->Name.c_str(), cit->name.c_str());
if (tmp_value != real_value)
{
pcstr tmp_key_str = nullptr;
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->first.c_str());
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->name.c_str());
STRCONCAT(diff_str, tmp_key_str, " = ", tmp_value.c_str(), ",right = ", real_value.c_str());
strncpy_s(dst_diff, diff_str, sizeof(dst_diff) - 1);
dst_diff[sizeof(dst_diff) - 1] = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/mp_configs_verifyer/mp_config_sections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ bool mp_config_sections::dump_one(CMemoryWriter& dest)
return false;

R_ASSERT(pSettings->section_exist(m_current_dump_sect->c_str()));
CInifile::Sect& tmp_sect = pSettings->r_section(m_current_dump_sect->c_str());
const CInifile::Sect& tmp_sect = pSettings->r_section(m_current_dump_sect->c_str());

m_tmp_dumper.sections().push_back(&tmp_sect);
m_tmp_dumper.sections().push_back(const_cast<CInifile::Sect*>(&tmp_sect));
m_tmp_dumper.save_as(dest);
m_tmp_dumper.sections().pop_back();
++m_current_dump_sect;
Expand Down
14 changes: 7 additions & 7 deletions src/utils/xrCompress/xrCompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void xrCompressor::OpenPack(LPCSTR tgt_folder, int num)
W.w_string(buff);
for (const auto& it : S.Data)
{
xr_sprintf(buff, "%s = %s", it.first.c_str(), it.second.c_str());
xr_sprintf(buff, "%s = %s", it.name.c_str(), it.value.c_str());
W.w_string(buff);
}
W.seek(0);
Expand Down Expand Up @@ -470,15 +470,15 @@ bool xrCompressor::IsFolderAccepted(const CInifile& ltx, LPCSTR path, bool& recu
const auto& ef_sect = ltx.r_section("exclude_folders");
for (const auto& it : ef_sect.Data)
{
recurse = CInifile::isBool(it.second.c_str());
recurse = CInifile::isBool(it.value.c_str());
if (recurse)
{
if (path == strstr(path, it.first.c_str()))
if (path == strstr(path, it.name.c_str()))
return false;
}
else
{
if (0 == xr_strcmp(path, it.first.c_str()))
if (0 == xr_strcmp(path, it.name.c_str()))
return false;
}
}
Expand All @@ -501,11 +501,11 @@ void xrCompressor::ProcessLTX(CInifile& ltx)
const CInifile::Sect& if_sect = ltx.r_section("include_folders");
for (const auto& it : if_sect.Data)
{
const BOOL ifRecurse = CInifile::isBool(it.second.c_str());
const BOOL ifRecurse = CInifile::isBool(it.value.c_str());
const u32 folder_mask = FS_ListFolders | (ifRecurse ? 0 : FS_RootOnly);

string_path path;
const LPCSTR _path = 0 == xr_strcmp(it.first.c_str(), ".\\") ? "" : it.first.c_str();
const LPCSTR _path = 0 == xr_strcmp(it.name.c_str(), ".\\") ? "" : it.name.c_str();
xr_strcpy(path, _path);
const size_t path_len = xr_strlen(path);
if ((0 != path_len) && (path[path_len - 1] != '\\'))
Expand Down Expand Up @@ -556,7 +556,7 @@ void xrCompressor::ProcessLTX(CInifile& ltx)
{
const CInifile::Sect& if_sect = ltx.r_section("include_files");
for (const auto& it : if_sect.Data)
files_list->push_back(xr_strdup(it.first.c_str()));
files_list->push_back(xr_strdup(it.name.c_str()));
}

PerformWork();
Expand Down
6 changes: 3 additions & 3 deletions src/xrCore/Animation/SkeletonMotions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ void CPartition::load(IKinematics* V, LPCSTR model_name)
for (; it != it_e; ++it)
{
const CInifile::Item& I = *it;
if (I.first == part_name)
if (I.name == part_name)
{
P[i].Name = I.second;
P[i].Name = I.value;
}
else
{
u32 bid = V->LL_BoneID(I.first.c_str());
u32 bid = V->LL_BoneID(I.name.c_str());
P[i].bones.push_back(bid);
}
}
Expand Down
Loading

0 comments on commit bfa0361

Please sign in to comment.