Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / client / src / client_sheets / attack_id_sheet.cpp
blob4ad810fa425cf596d2165fc90c8ff3a9da410024
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"
20 #include "attack_id_sheet.h"
22 #include "nel/georges/u_form_elm.h"
25 // *****************************************************************************************
26 void CAttackIDSheet::build(const NLGEORGES::UFormElm &item, const std::string &prefix)
28 uint32 attackType = 0;
29 item.getValueByName(attackType, (prefix + "AttackType").c_str());
30 Type = (TType) attackType;
31 switch(Type)
33 case Melee:
34 // currently no additionnal infos for melee
35 break;
36 case Range:
38 std::string rangeWeaponType;
39 if (item.getValueByName(rangeWeaponType, (prefix + "RangeWeaponType").c_str()))
41 RangeWeaponType = RANGE_WEAPON_TYPE::stringToRangeWeaponType(rangeWeaponType);
44 break;
45 case Magic:
46 SpellInfo.build(item, prefix);
47 break;
48 case Creature:
49 item.getValueByName(CreatureAttackIndex, (prefix + "CreatureAttackIndex").c_str());
50 break;
51 case DamageShield:
52 item.getValueByName(DamageShieldType, (prefix + "DamageShieldType").c_str());
53 break;
54 default:
55 nlwarning("Bad attack type");
56 break;
60 // *****************************************************************************************
61 void CAttackIDSheet::serial(NLMISC::IStream &f)
63 f.serialEnum(Type);
64 switch(Type)
66 case Melee:
67 // currently no additionnal infos for melee
68 break;
69 case Range:
70 f.serialEnum(RangeWeaponType);
71 break;
72 case Magic:
73 f.serial(SpellInfo);
74 break;
75 case Creature:
76 f.serial(CreatureAttackIndex);
77 break;
78 case DamageShield:
79 f.serial(DamageShieldType);
80 break;
81 default:
82 nlwarning("Bad attack type");
83 break;
87 // *****************************************************************************************
88 void CAttackIDSheet::CSpellInfo::build(const NLGEORGES::UFormElm &item, const std::string &prefix)
90 uint32 spellID = 0;
91 item.getValueByName(spellID, (prefix + ".SpellID").c_str());
92 ID = (MAGICFX::TMagicFx) spellID;
93 uint32 spellMode = 0;
94 item.getValueByName(spellMode, (prefix + ".SpellMode").c_str());
95 Mode = (MAGICFX::TSpellMode) spellMode;
98 // *****************************************************************************************
99 void CAttackIDSheet::CSpellInfo::serial(NLMISC::IStream &f)
101 f.serialEnum(Mode);
102 f.serialEnum(ID);
105 // *****************************************************************************************
106 bool operator == (const CAttackIDSheet &lhs, const CAttackIDSheet &rhs)
108 if (lhs.Type != rhs.Type) return false;
109 switch(lhs.Type)
111 case CAttackIDSheet::Melee: return true;
112 case CAttackIDSheet::Range: return lhs.RangeWeaponType == rhs.RangeWeaponType;
113 case CAttackIDSheet::Magic: return lhs.SpellInfo == rhs.SpellInfo;
114 case CAttackIDSheet::Creature: return lhs.CreatureAttackIndex == rhs.CreatureAttackIndex;
115 case CAttackIDSheet::DamageShield: return lhs.DamageShieldType == rhs.DamageShieldType;
116 default: return false;
120 // *****************************************************************************************
121 bool operator < (const CAttackIDSheet &lhs, const CAttackIDSheet &rhs)
123 if (lhs.Type != rhs.Type) return lhs.Type < rhs.Type;
124 switch(lhs.Type)
126 case CAttackIDSheet::Melee: return false;
127 case CAttackIDSheet::Range: return lhs.RangeWeaponType < rhs.RangeWeaponType;
128 case CAttackIDSheet::Magic: return lhs.SpellInfo < rhs.SpellInfo;
129 case CAttackIDSheet::Creature: return lhs.CreatureAttackIndex < rhs.CreatureAttackIndex;
130 case CAttackIDSheet::DamageShield: return lhs.DamageShieldType < rhs.DamageShieldType;
131 default: return false;
135 // *****************************************************************************************
136 bool operator == (const CAttackIDSheet::CSpellInfo &lhs, const CAttackIDSheet::CSpellInfo &rhs)
138 return lhs.Mode == rhs.Mode && lhs.ID == rhs.ID;
141 // *****************************************************************************************
142 bool operator < (const CAttackIDSheet::CSpellInfo &lhs, const CAttackIDSheet::CSpellInfo &rhs)
144 if (lhs.Mode != rhs.Mode) return lhs.Mode < rhs.Mode;
145 if (lhs.ID != rhs.ID) return lhs.ID < rhs.ID;
146 return false;