Skip to content

Commit

Permalink
Fix a mistake and simplify LoadItemData as suggested by @ForserX
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegeri committed Sep 17, 2018
1 parent d4e58e1 commit da52591
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/xrGame/character_community.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ struct COMMUNITY_DATA
class CHARACTER_COMMUNITY;

class CHARACTER_COMMUNITY
: public CIni_IdToIndex<1, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
: public CIni_IdToIndex<true, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
{
private:
typedef CIni_IdToIndex<1, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
typedef CIni_IdToIndex<true, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY>
inherited;
friend inherited;

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/character_rank.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct RANK_DATA

class CHARACTER_RANK;

typedef CIni_IdToIndex<1, RANK_DATA, shared_str, int, CHARACTER_RANK> CHARACTER_RANK_base;
typedef CIni_IdToIndex<true, RANK_DATA, shared_str, int, CHARACTER_RANK> CHARACTER_RANK_base;

class CHARACTER_RANK : public CHARACTER_RANK_base
{
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/character_reputation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ struct REPUTATION_DATA

class CHARACTER_REPUTATION;

class CHARACTER_REPUTATION : public CIni_IdToIndex<1, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION>
class CHARACTER_REPUTATION : public CIni_IdToIndex<true, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION>
{
private:
typedef CIni_IdToIndex<1, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION> inherited;
typedef CIni_IdToIndex<true, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION> inherited;
friend inherited;

public:
Expand Down
17 changes: 10 additions & 7 deletions src/xrGame/ini_id_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// функция инициализации section_name и line_name

#define TEMPLATE_SPECIALIZATION \
template <u32 ITEM_REC_NUM, typename ITEM_DATA, typename T_ID, typename T_INDEX, typename T_INIT>
template <bool ITEM_REC_NUM, typename ITEM_DATA, typename T_ID, typename T_INDEX, typename T_INIT>
#define CSINI_IdToIndex CIni_IdToIndex<ITEM_REC_NUM, ITEM_DATA, T_ID, T_INDEX, T_INIT>

TEMPLATE_SPECIALIZATION
Expand All @@ -31,22 +31,25 @@ class CIni_IdToIndex
typedef xr_vector<ITEM_DATA> T_VECTOR;
static T_VECTOR* m_pItemDataVector;

template <u32 NUM>
template <bool isNum>
static void LoadItemData(u32 count, LPCSTR cfgRecord)
{
static_assert(NUM < 2, "Specialization for LoadItemData in CIni_IdToIndex not found."); // Xottab_DUTY: Is this correct?
for (u32 k = 0; k < count; k += 1)
{
string64 buf;
LPCSTR id_str = _GetItem(cfgRecord, k, buf);
char* id_str_lwr = xr_strdup(id_str); // not used
char* id_str_lwr = xr_strdup(id_str); // not used?
xr_strlwr(id_str_lwr);
if constexpr (NUM == 0) {

if constexpr (!isNum)
{
ITEM_DATA item_data(T_INDEX(m_pItemDataVector->size()), T_ID(id_str));
m_pItemDataVector->push_back(item_data);
} else {
}
else
{
string64 buf1;
LPCSTR rec1 = _GetItem(cfgRecord, k + 1, buf1);
LPCSTR rec1 = _GetItem(cfgRecord, ++k, buf1);
ITEM_DATA item_data(T_INDEX(m_pItemDataVector->size()), T_ID(id_str), rec1);
m_pItemDataVector->push_back(item_data);
}
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/monster_community.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ struct MONSTER_COMMUNITY_DATA
class MONSTER_COMMUNITY;

class MONSTER_COMMUNITY
: public CIni_IdToIndex<1, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
: public CIni_IdToIndex<true, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
{
private:
typedef CIni_IdToIndex<1, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
typedef CIni_IdToIndex<true, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY>
inherited;
friend inherited;

Expand Down

0 comments on commit da52591

Please sign in to comment.