Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / item_origin.cpp
blobe67005e283dd7ba484260872f5c19ed4c53a2f72
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
21 #include "nel/misc/debug.h"
22 #include "nel/misc/common.h"
23 #include "item_origin.h"
25 using namespace std;
26 using namespace NLMISC;
28 namespace ITEM_ORIGIN
31 // ***************************************************************************
33 /* Warning : if you add an enum here, you MUST add it in translation/work/en.uxt prefixed with "io" like this :
34 ioUnknown [Unknown]
35 ioCommon [Common]
37 static const string StringArray[NUM_ITEM_ORIGIN+1]=
39 "Common",
40 "Fyros",
41 "Matis",
42 "Tryker",
43 "Zorai",
44 "Refugee",
45 "Tribe",
46 "Kami",
47 "Karavan",
48 "Unknown",
51 // ***************************************************************************
52 EItemOrigin stringToEnum(const std::string &str)
54 for(uint i=0;i<NUM_ITEM_ORIGIN;i++)
56 if(nlstricmp(StringArray[i], str)==0)
57 return (EItemOrigin)i;
59 return UNKNOWN;
62 // ***************************************************************************
63 const std::string & enumToString (EItemOrigin e)
65 nlassert((sint)e<=NUM_ITEM_ORIGIN);
66 return StringArray[e];
69 // ***************************************************************************
70 EGSPD::CPeople::TPeople itemOriginStringToPeopleEnum( const std::string &str )
72 switch( ITEM_ORIGIN::stringToEnum( str ) )
74 case COMMON:
75 return EGSPD::CPeople::Common;
76 case FYROS:
77 return EGSPD::CPeople::Fyros;
78 case MATIS:
79 return EGSPD::CPeople::Matis;
80 case TRYKER:
81 return EGSPD::CPeople::Tryker;
82 case ZORAI:
83 return EGSPD::CPeople::Zorai;
84 case REFUGEE:
85 return EGSPD::CPeople::Common;
86 case TRIBE:
87 return EGSPD::CPeople::Tribe;
88 case KAMI:
89 return EGSPD::CPeople::Kami;
90 case KARAVAN:
91 return EGSPD::CPeople::Karavan;
92 default:
93 return EGSPD::CPeople::EndPeople;