Skip to content

Commit bfa0361

Browse files
committed
xrCore: Rewrite of CInifile
1 parent 3fbf7f4 commit bfa0361

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1482
-904
lines changed

src/Layers/xrRender/ModelPool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void CModelPool::Prefetch()
396396
for (auto I = sect.Data.cbegin(); I != sect.Data.cend(); ++I)
397397
{
398398
const CInifile::Item& item = *I;
399-
dxRender_Visual* V = Create(item.first.c_str());
399+
dxRender_Visual* V = Create(item.name.c_str());
400400
Delete(V, FALSE);
401401
}
402402
Logging(TRUE);

src/Layers/xrRender/Texture.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bool is_enough_address_space_available() { return true; }
2727

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

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

3939
for (; it != it_e; ++it)
4040
{
41-
if (strstr(fn, it->first.c_str()))
41+
if (strstr(fn, it->name.c_str()))
4242
{
4343
if (psTextureLOD < 1)
4444
{

src/Layers/xrRender/TextureDescrManager.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ void CTextureDescrMngr::LoadLTX(pcstr initial, bool listTHM)
5353
const auto processAssociation = [&](const CInifile::Item& item)
5454
{
5555
if (listTHM)
56-
Msg("\t\t%s = %s", item.first.c_str(), item.second.c_str());
56+
Msg("\t\t%s = %s", item.name.c_str(), item.value.c_str());
5757

5858
lock.Enter();
59-
texture_desc& desc = m_texture_details[item.first];
60-
cl_dt_scaler*& dts = m_detail_scalers[item.first];
59+
texture_desc& desc = m_texture_details[item.name];
60+
cl_dt_scaler*& dts = m_detail_scalers[item.name];
6161
lock.Leave();
6262

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

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

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

102102
lock.Enter();
103-
texture_desc& desc = m_texture_details[item.first];
103+
texture_desc& desc = m_texture_details[item.name];
104104
lock.Leave();
105105

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

111111
string_path bmode;
112112
const int res =
113-
sscanf(item.second.c_str(), "bump_mode[%[^]]], material[%f]", bmode, &desc.m_spec->m_material);
114-
R_ASSERT4(res == 2, "Bad texture specification", item.first.c_str(), fname);
113+
sscanf(item.value.c_str(), "bump_mode[%[^]]], material[%f]", bmode, &desc.m_spec->m_material);
114+
R_ASSERT4(res == 2, "Bad texture specification", item.name.c_str(), fname);
115115
if ((bmode[0] == 'u') && (bmode[1] == 's') && (bmode[2] == 'e') && (bmode[3] == ':'))
116116
{
117117
// bump-map specified

src/Layers/xrRenderDX11/dx11Texture.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void fix_texture_name(pstr fn)
1717

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

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

3030
for (; it != it_e; ++it)
3131
{
32-
if (strstr(fn, it->first.c_str()))
32+
if (strstr(fn, it->name.c_str()))
3333
{
3434
if (psTextureLOD < 1)
3535
{

src/Layers/xrRenderGL/glTexture.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ void fix_texture_name(pstr fn)
2121

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

2626
for (const auto& item : sect.Data)
2727
{
28-
if (strstr(fn, item.first.c_str()))
28+
if (strstr(fn, item.name.c_str()))
2929
{
3030
if (psTextureLOD < 1)
3131
return 0;

src/utils/mp_configs_verifyer/configs_dump_verifyer.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ LPCSTR configs_verifyer::get_section_diff(CInifile::Sect* sect_ptr, CInifile& ac
9393

9494
for (auto cit = sect_ptr->Data.cbegin(), ciet = sect_ptr->Data.cend(); cit != ciet; ++cit)
9595
{
96-
shared_str const& tmp_value = cit->second;
96+
shared_str const& tmp_value = cit->value;
9797
shared_str real_value;
9898
if (tmp_active_param)
9999
{
100-
if (active_params.line_exist(sect_ptr->Name.c_str(), cit->first))
100+
if (active_params.line_exist(sect_ptr->Name.c_str(), cit->name))
101101
{
102-
real_value = active_params.r_string(sect_ptr->Name.c_str(), cit->first.c_str());
102+
real_value = active_params.r_string(sect_ptr->Name.c_str(), cit->name.c_str());
103103
if (tmp_value != real_value)
104104
{
105105
pcstr tmp_key_str = nullptr;
106-
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->first.c_str());
106+
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->name.c_str());
107107
STRCONCAT(diff_str, tmp_key_str, " = ", tmp_value.c_str(), ",right = ", real_value.c_str());
108108
strncpy_s(dst_diff, diff_str, sizeof(dst_diff) - 1);
109109
dst_diff[sizeof(dst_diff) - 1] = 0;
@@ -112,18 +112,18 @@ LPCSTR configs_verifyer::get_section_diff(CInifile::Sect* sect_ptr, CInifile& ac
112112
continue;
113113
}
114114
}
115-
if (!pSettings->line_exist(sect_ptr->Name, cit->first))
115+
if (!pSettings->line_exist(sect_ptr->Name, cit->name))
116116
{
117-
STRCONCAT(diff_str, "line ", sect_ptr->Name.c_str(), "::", cit->first.c_str(), " not found");
117+
STRCONCAT(diff_str, "line ", sect_ptr->Name.c_str(), "::", cit->name.c_str(), " not found");
118118
strncpy_s(dst_diff, diff_str, sizeof(dst_diff) - 1);
119119
dst_diff[sizeof(dst_diff) - 1] = 0;
120120
return dst_diff;
121121
}
122-
real_value = pSettings->r_string(sect_ptr->Name.c_str(), cit->first.c_str());
122+
real_value = pSettings->r_string(sect_ptr->Name.c_str(), cit->name.c_str());
123123
if (tmp_value != real_value)
124124
{
125125
pcstr tmp_key_str = nullptr;
126-
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->first.c_str());
126+
STRCONCAT(tmp_key_str, sect_ptr->Name.c_str(), "::", cit->name.c_str());
127127
STRCONCAT(diff_str, tmp_key_str, " = ", tmp_value.c_str(), ",right = ", real_value.c_str());
128128
strncpy_s(dst_diff, diff_str, sizeof(dst_diff) - 1);
129129
dst_diff[sizeof(dst_diff) - 1] = 0;

src/utils/mp_configs_verifyer/mp_config_sections.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ bool mp_config_sections::dump_one(CMemoryWriter& dest)
3939
return false;
4040

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

44-
m_tmp_dumper.sections().push_back(&tmp_sect);
44+
m_tmp_dumper.sections().push_back(const_cast<CInifile::Sect*>(&tmp_sect));
4545
m_tmp_dumper.save_as(dest);
4646
m_tmp_dumper.sections().pop_back();
4747
++m_current_dump_sect;

src/utils/xrCompress/xrCompress.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void xrCompressor::OpenPack(LPCSTR tgt_folder, int num)
320320
W.w_string(buff);
321321
for (const auto& it : S.Data)
322322
{
323-
xr_sprintf(buff, "%s = %s", it.first.c_str(), it.second.c_str());
323+
xr_sprintf(buff, "%s = %s", it.name.c_str(), it.value.c_str());
324324
W.w_string(buff);
325325
}
326326
W.seek(0);
@@ -470,15 +470,15 @@ bool xrCompressor::IsFolderAccepted(const CInifile& ltx, LPCSTR path, bool& recu
470470
const auto& ef_sect = ltx.r_section("exclude_folders");
471471
for (const auto& it : ef_sect.Data)
472472
{
473-
recurse = CInifile::isBool(it.second.c_str());
473+
recurse = CInifile::isBool(it.value.c_str());
474474
if (recurse)
475475
{
476-
if (path == strstr(path, it.first.c_str()))
476+
if (path == strstr(path, it.name.c_str()))
477477
return false;
478478
}
479479
else
480480
{
481-
if (0 == xr_strcmp(path, it.first.c_str()))
481+
if (0 == xr_strcmp(path, it.name.c_str()))
482482
return false;
483483
}
484484
}
@@ -501,11 +501,11 @@ void xrCompressor::ProcessLTX(CInifile& ltx)
501501
const CInifile::Sect& if_sect = ltx.r_section("include_folders");
502502
for (const auto& it : if_sect.Data)
503503
{
504-
const BOOL ifRecurse = CInifile::isBool(it.second.c_str());
504+
const BOOL ifRecurse = CInifile::isBool(it.value.c_str());
505505
const u32 folder_mask = FS_ListFolders | (ifRecurse ? 0 : FS_RootOnly);
506506

507507
string_path path;
508-
const LPCSTR _path = 0 == xr_strcmp(it.first.c_str(), ".\\") ? "" : it.first.c_str();
508+
const LPCSTR _path = 0 == xr_strcmp(it.name.c_str(), ".\\") ? "" : it.name.c_str();
509509
xr_strcpy(path, _path);
510510
const size_t path_len = xr_strlen(path);
511511
if ((0 != path_len) && (path[path_len - 1] != '\\'))
@@ -556,7 +556,7 @@ void xrCompressor::ProcessLTX(CInifile& ltx)
556556
{
557557
const CInifile::Sect& if_sect = ltx.r_section("include_files");
558558
for (const auto& it : if_sect.Data)
559-
files_list->push_back(xr_strdup(it.first.c_str()));
559+
files_list->push_back(xr_strdup(it.name.c_str()));
560560
}
561561

562562
PerformWork();

src/xrCore/Animation/SkeletonMotions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ void CPartition::load(IKinematics* V, LPCSTR model_name)
5252
for (; it != it_e; ++it)
5353
{
5454
const CInifile::Item& I = *it;
55-
if (I.first == part_name)
55+
if (I.name == part_name)
5656
{
57-
P[i].Name = I.second;
57+
P[i].Name = I.value;
5858
}
5959
else
6060
{
61-
u32 bid = V->LL_BoneID(I.first.c_str());
61+
u32 bid = V->LL_BoneID(I.name.c_str());
6262
P[i].bones.push_back(bid);
6363
}
6464
}

0 commit comments

Comments
 (0)