1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
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
;
34 // currently no additionnal infos for melee
38 std::string rangeWeaponType
;
39 if (item
.getValueByName(rangeWeaponType
, (prefix
+ "RangeWeaponType").c_str()))
41 RangeWeaponType
= RANGE_WEAPON_TYPE::stringToRangeWeaponType(rangeWeaponType
);
46 SpellInfo
.build(item
, prefix
);
49 item
.getValueByName(CreatureAttackIndex
, (prefix
+ "CreatureAttackIndex").c_str());
52 item
.getValueByName(DamageShieldType
, (prefix
+ "DamageShieldType").c_str());
55 nlwarning("Bad attack type");
60 // *****************************************************************************************
61 void CAttackIDSheet::serial(NLMISC::IStream
&f
)
67 // currently no additionnal infos for melee
70 f
.serialEnum(RangeWeaponType
);
76 f
.serial(CreatureAttackIndex
);
79 f
.serial(DamageShieldType
);
82 nlwarning("Bad attack type");
87 // *****************************************************************************************
88 void CAttackIDSheet::CSpellInfo::build(const NLGEORGES::UFormElm
&item
, const std::string
&prefix
)
91 item
.getValueByName(spellID
, (prefix
+ ".SpellID").c_str());
92 ID
= (MAGICFX::TMagicFx
) spellID
;
94 item
.getValueByName(spellMode
, (prefix
+ ".SpellMode").c_str());
95 Mode
= (MAGICFX::TSpellMode
) spellMode
;
98 // *****************************************************************************************
99 void CAttackIDSheet::CSpellInfo::serial(NLMISC::IStream
&f
)
105 // *****************************************************************************************
106 bool operator == (const CAttackIDSheet
&lhs
, const CAttackIDSheet
&rhs
)
108 if (lhs
.Type
!= rhs
.Type
) return false;
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
;
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
;