Skip to content

Commit da52591

Browse files
committed
Fix a mistake and simplify LoadItemData as suggested by @ForserX
1 parent d4e58e1 commit da52591

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

src/xrGame/character_community.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ struct COMMUNITY_DATA
2222
class CHARACTER_COMMUNITY;
2323

2424
class CHARACTER_COMMUNITY
25-
: public CIni_IdToIndex<1, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
25+
: public CIni_IdToIndex<true, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
2626
{
2727
private:
28-
typedef CIni_IdToIndex<1, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
28+
typedef CIni_IdToIndex<true, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
2929
inherited;
3030
friend inherited;
3131

src/xrGame/character_rank.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct RANK_DATA
2121

2222
class CHARACTER_RANK;
2323

24-
typedef CIni_IdToIndex<1, RANK_DATA, shared_str, int, CHARACTER_RANK> CHARACTER_RANK_base;
24+
typedef CIni_IdToIndex<true, RANK_DATA, shared_str, int, CHARACTER_RANK> CHARACTER_RANK_base;
2525

2626
class CHARACTER_RANK : public CHARACTER_RANK_base
2727
{

src/xrGame/character_reputation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ struct REPUTATION_DATA
2121

2222
class CHARACTER_REPUTATION;
2323

24-
class CHARACTER_REPUTATION : public CIni_IdToIndex<1, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION>
24+
class CHARACTER_REPUTATION : public CIni_IdToIndex<true, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION>
2525
{
2626
private:
27-
typedef CIni_IdToIndex<1, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION> inherited;
27+
typedef CIni_IdToIndex<true, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION> inherited;
2828
friend inherited;
2929

3030
public:

src/xrGame/ini_id_loader.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// функция инициализации section_name и line_name
1818

1919
#define TEMPLATE_SPECIALIZATION \
20-
template <u32 ITEM_REC_NUM, typename ITEM_DATA, typename T_ID, typename T_INDEX, typename T_INIT>
20+
template <bool ITEM_REC_NUM, typename ITEM_DATA, typename T_ID, typename T_INDEX, typename T_INIT>
2121
#define CSINI_IdToIndex CIni_IdToIndex<ITEM_REC_NUM, ITEM_DATA, T_ID, T_INDEX, T_INIT>
2222

2323
TEMPLATE_SPECIALIZATION
@@ -31,22 +31,25 @@ class CIni_IdToIndex
3131
typedef xr_vector<ITEM_DATA> T_VECTOR;
3232
static T_VECTOR* m_pItemDataVector;
3333

34-
template <u32 NUM>
34+
template <bool isNum>
3535
static void LoadItemData(u32 count, LPCSTR cfgRecord)
3636
{
37-
static_assert(NUM < 2, "Specialization for LoadItemData in CIni_IdToIndex not found."); // Xottab_DUTY: Is this correct?
3837
for (u32 k = 0; k < count; k += 1)
3938
{
4039
string64 buf;
4140
LPCSTR id_str = _GetItem(cfgRecord, k, buf);
42-
char* id_str_lwr = xr_strdup(id_str); // not used
41+
char* id_str_lwr = xr_strdup(id_str); // not used?
4342
xr_strlwr(id_str_lwr);
44-
if constexpr (NUM == 0) {
43+
44+
if constexpr (!isNum)
45+
{
4546
ITEM_DATA item_data(T_INDEX(m_pItemDataVector->size()), T_ID(id_str));
4647
m_pItemDataVector->push_back(item_data);
47-
} else {
48+
}
49+
else
50+
{
4851
string64 buf1;
49-
LPCSTR rec1 = _GetItem(cfgRecord, k + 1, buf1);
52+
LPCSTR rec1 = _GetItem(cfgRecord, ++k, buf1);
5053
ITEM_DATA item_data(T_INDEX(m_pItemDataVector->size()), T_ID(id_str), rec1);
5154
m_pItemDataVector->push_back(item_data);
5255
}

src/xrGame/monster_community.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ struct MONSTER_COMMUNITY_DATA
2424
class MONSTER_COMMUNITY;
2525

2626
class MONSTER_COMMUNITY
27-
: public CIni_IdToIndex<1, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
27+
: public CIni_IdToIndex<true, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
2828
{
2929
private:
30-
typedef CIni_IdToIndex<1, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
30+
typedef CIni_IdToIndex<true, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
3131
inherited;
3232
friend inherited;
3333

0 commit comments

Comments
 (0)