From da525910b20f3f22e6b78af0a808380644a3136c Mon Sep 17 00:00:00 2001 From: Zegeri Date: Mon, 17 Sep 2018 20:21:37 +0200 Subject: [PATCH] Fix a mistake and simplify LoadItemData as suggested by @ForserX --- src/xrGame/character_community.h | 4 ++-- src/xrGame/character_rank.h | 2 +- src/xrGame/character_reputation.h | 4 ++-- src/xrGame/ini_id_loader.h | 17 ++++++++++------- src/xrGame/monster_community.h | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/xrGame/character_community.h b/src/xrGame/character_community.h index 546046c12fe..e9df9a4ca0e 100644 --- a/src/xrGame/character_community.h +++ b/src/xrGame/character_community.h @@ -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 { private: - typedef CIni_IdToIndex<1, COMMUNITY_DATA, CHARACTER_COMMUNITY_ID, CHARACTER_COMMUNITY_INDEX, CHARACTER_COMMUNITY> + typedef CIni_IdToIndex inherited; friend inherited; diff --git a/src/xrGame/character_rank.h b/src/xrGame/character_rank.h index 77122583ff6..f8567197c85 100644 --- a/src/xrGame/character_rank.h +++ b/src/xrGame/character_rank.h @@ -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 CHARACTER_RANK_base; class CHARACTER_RANK : public CHARACTER_RANK_base { diff --git a/src/xrGame/character_reputation.h b/src/xrGame/character_reputation.h index 0f7092d7519..f2509e6e279 100644 --- a/src/xrGame/character_reputation.h +++ b/src/xrGame/character_reputation.h @@ -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 { private: - typedef CIni_IdToIndex<1, REPUTATION_DATA, shared_str, int, CHARACTER_REPUTATION> inherited; + typedef CIni_IdToIndex inherited; friend inherited; public: diff --git a/src/xrGame/ini_id_loader.h b/src/xrGame/ini_id_loader.h index 38ec64a5ec5..d0660e3531f 100644 --- a/src/xrGame/ini_id_loader.h +++ b/src/xrGame/ini_id_loader.h @@ -17,7 +17,7 @@ // функция инициализации section_name и line_name #define TEMPLATE_SPECIALIZATION \ - template + template #define CSINI_IdToIndex CIni_IdToIndex TEMPLATE_SPECIALIZATION @@ -31,22 +31,25 @@ class CIni_IdToIndex typedef xr_vector T_VECTOR; static T_VECTOR* m_pItemDataVector; - template + template 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); } diff --git a/src/xrGame/monster_community.h b/src/xrGame/monster_community.h index 4d16a258c27..2c4dc181510 100644 --- a/src/xrGame/monster_community.h +++ b/src/xrGame/monster_community.h @@ -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 { private: - typedef CIni_IdToIndex<1, MONSTER_COMMUNITY_DATA, MONSTER_COMMUNITY_ID, MONSTER_COMMUNITY_INDEX, MONSTER_COMMUNITY> + typedef CIni_IdToIndex inherited; friend inherited;