Added persistante SavedFames, improvements
[ryzomcore.git] / ryzom / common / src / game_share / pvp_clan.cpp
blob0a467027e774ec62c54d66523c2d160efeea2251
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2018 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "stdpch.h"
22 #include "nel/misc/string_conversion.h"
23 #include "nel/misc/sstring.h"
25 #include "pvp_clan.h"
26 #include "fame.h"
28 using namespace std;
29 using namespace NLMISC;
31 namespace PVP_CLAN
34 NL_BEGIN_STRING_CONVERSION_TABLE (TPVPClan)
35 NL_STRING_CONVERSION_TABLE_ENTRY(None)
36 NL_STRING_CONVERSION_TABLE_ENTRY(Neutral)
37 NL_STRING_CONVERSION_TABLE_ENTRY(Kami)
38 NL_STRING_CONVERSION_TABLE_ENTRY(Karavan)
39 NL_STRING_CONVERSION_TABLE_ENTRY(Fyros)
40 NL_STRING_CONVERSION_TABLE_ENTRY(Matis)
41 NL_STRING_CONVERSION_TABLE_ENTRY(Tryker)
42 NL_STRING_CONVERSION_TABLE_ENTRY(Zorai)
43 NL_STRING_CONVERSION_TABLE_ENTRY(Marauder)
44 NL_END_STRING_CONVERSION_TABLE(TPVPClan, PVPClanConversion, Unknown)
46 TPVPClan fromString(const std::string & str)
48 return PVPClanConversion.fromString(str);
51 const std::string & toString(TPVPClan clan)
53 return PVPClanConversion.toString(clan);
56 std::string toLowerString(TPVPClan clan)
58 return toLowerAscii(PVPClanConversion.toString(clan));
61 uint32 getFactionIndex(TPVPClan clan)
63 static vector<uint32> factionIndexes;
64 if ( factionIndexes.empty() )
66 factionIndexes.resize(NbClans, CStaticFames::INVALID_FACTION_INDEX);
68 factionIndexes[Kami] = CStaticFames::getInstance().getFactionIndex("kami");
69 factionIndexes[Karavan] = CStaticFames::getInstance().getFactionIndex("karavan");
70 factionIndexes[Fyros] = CStaticFames::getInstance().getFactionIndex("fyros");
71 factionIndexes[Matis] = CStaticFames::getInstance().getFactionIndex("matis");
72 factionIndexes[Tryker] = CStaticFames::getInstance().getFactionIndex("tryker");
73 factionIndexes[Zorai] = CStaticFames::getInstance().getFactionIndex("zorai");
74 factionIndexes[Marauder] = CStaticFames::getInstance().getFactionIndex("black_kami");
76 for (uint i = BeginClans; i <= EndClans; i++)
77 nlassert( factionIndexes[i] != CStaticFames::INVALID_FACTION_INDEX );
80 if (clan >= NbClans)
81 return CStaticFames::INVALID_FACTION_INDEX;
83 return factionIndexes[clan];
86 TPVPClan getClanFromIndex(uint32 theIndex)
88 // These names are in order of the enum TPVPClan
89 // The first two clans, "None" and "Neutral", don't count. Subtract 2 from the lookup.
90 std::string FactionNames[] = { "kami","karavan","fyros","matis","tryker","zorai","black_kami" };
92 for (int looper = BeginClans; looper <= EndClans; looper += 1)
94 if (CStaticFames::getInstance().getFactionIndex(FactionNames[looper-BeginClans]) == theIndex)
96 return (TPVPClan)looper;
100 // It wasn't found, return unknown to indicate error.
101 return Unknown;
104 NLMISC::CSheetId getFactionSheetId(TPVPClan clan)
106 static vector<NLMISC::CSheetId> factionSheetIds;
107 if ( factionSheetIds.empty() )
109 factionSheetIds.resize(NbClans, NLMISC::CSheetId::Unknown);
111 factionSheetIds[Kami] = "kami.faction";
112 factionSheetIds[Karavan] = "karavan.faction";
113 factionSheetIds[Fyros] = "fyros.faction";
114 factionSheetIds[Matis] = "matis.faction";
115 factionSheetIds[Tryker] = "tryker.faction";
116 factionSheetIds[Zorai] = "zorai.faction";
117 factionSheetIds[Marauder] = "marauder.faction";
119 for (uint i = BeginClans; i <= EndClans; i++)
120 nlassert( factionSheetIds[i] != NLMISC::CSheetId::Unknown );
123 if (clan >= NbClans)
124 return NLMISC::CSheetId::Unknown;
126 return factionSheetIds[clan];
129 std::string toIconDefineString( TPVPClan clan )
131 return string("pvp_faction_icon_") + PVP_CLAN::toString(clan);
134 TPVPClan getClanFromPeople( EGSPD::CPeople::TPeople people )
136 static vector<TPVPClan> peopleToClan;
137 if( peopleToClan.empty() )
139 peopleToClan.resize( EGSPD::CPeople::EndPlayable );
140 peopleToClan[ EGSPD::CPeople::Fyros ] = Fyros;
141 peopleToClan[ EGSPD::CPeople::Matis ] = Matis;
142 peopleToClan[ EGSPD::CPeople::Tryker ] = Tryker;
143 peopleToClan[ EGSPD::CPeople::Zorai ] = Zorai;
146 if( people < EGSPD::CPeople::EndPlayable && people >= EGSPD::CPeople::Playable )
147 return peopleToClan[ people ];
149 return Unknown;
152 } // namespace PVP_CLAN