Created
March 25, 2011 21:39
-
-
Save tomprince/887689 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gemrb/core/EffectQueue.cpp b/gemrb/core/EffectQueue.cpp | |
index ca980d6..624b7ea 100644 | |
--- a/gemrb/core/EffectQueue.cpp | |
+++ b/gemrb/core/EffectQueue.cpp | |
@@ -423,10 +423,9 @@ Effect *EffectQueue::CreateUnsummonEffect(Effect *fx) | |
return newfx; | |
} | |
-void EffectQueue::AddEffect(Effect* fx, bool insert) | |
+void EffectQueue::AddEffect(Effect const& fx, bool insert) | |
{ | |
- Effect* new_fx = new Effect; | |
- memcpy( new_fx, fx, sizeof( Effect ) ); | |
+ Effect* new_fx = new Effect(fx); | |
if( insert) { | |
effects.insert( effects.begin(), new_fx ); | |
} else { | |
@@ -434,6 +433,11 @@ void EffectQueue::AddEffect(Effect* fx, bool insert) | |
} | |
} | |
+void EffectQueue::AddEffect(Effect const* fx, bool insert) | |
+{ | |
+ AddEffect(*fx, insert); | |
+} | |
+ | |
//This method can remove an effect described by a pointer to it, or | |
//an exact matching effect | |
bool EffectQueue::RemoveEffect(Effect* fx) | |
@@ -1752,7 +1756,7 @@ Effect *EffectQueue::GetEffect(ieDword idx) const | |
*/ | |
//returns true if the effect supports simplified duration | |
-bool EffectQueue::HasDuration(Effect *fx) | |
+bool EffectQueue::HasDuration(Effect const* fx) | |
{ | |
switch(fx->TimingMode) { | |
case FX_DURATION_INSTANT_LIMITED: //simple duration | |
diff --git a/gemrb/core/EffectQueue.h b/gemrb/core/EffectQueue.h | |
index 1380c39..ee8a3ad 100644 | |
--- a/gemrb/core/EffectQueue.h | |
+++ b/gemrb/core/EffectQueue.h | |
@@ -196,7 +196,9 @@ public: | |
/** adds an effect to the queue, it could also insert it if flagged so | |
* fx should be freed by the caller | |
*/ | |
- void AddEffect(Effect* fx, bool insert=false); | |
+ void AddEffect(Effect const* fx, bool insert=false); | |
+ /** adds an effect to the queue */ | |
+ void AddEffect(Effect const& fx, bool insert=false); | |
/** Adds an Effect to the queue, subject to level and other checks. | |
* Returns FX_ABORT is unsuccessful. fx is just a reference, AddEffect() | |
* will malloc its own copy */ | |
@@ -235,7 +237,7 @@ public: | |
void RemoveLevelEffects(ieResRef &Removed, ieDword level, ieDword flags, ieDword match) const; | |
/* returns true if the timing method supports simplified duration */ | |
- static bool HasDuration(Effect *fx); | |
+ static bool HasDuration(Effect const* fx); | |
/* returns true if the effect should be saved */ | |
static bool Persistent(Effect* fx); | |
/* returns next saved effect, increases index */ | |
diff --git a/gemrb/core/Interface.cpp b/gemrb/core/Interface.cpp | |
index c4db5c9..d3bd5c9 100644 | |
--- a/gemrb/core/Interface.cpp | |
+++ b/gemrb/core/Interface.cpp | |
@@ -4682,11 +4682,6 @@ ITMExtHeader *Interface::GetITMExt(int count) | |
return new ITMExtHeader[count]; | |
} | |
-SPLExtHeader *Interface::GetSPLExt(int count) | |
-{ | |
- return new SPLExtHeader[count]; | |
-} | |
- | |
Effect *Interface::GetEffect(ieDword opcode) | |
{ | |
if (opcode==0xffffffff) { | |
diff --git a/gemrb/core/Interface.h b/gemrb/core/Interface.h | |
index af2c42a..e68ac85 100644 | |
--- a/gemrb/core/Interface.h | |
+++ b/gemrb/core/Interface.h | |
@@ -602,7 +602,6 @@ public: | |
// FIXME: due to Win32 we have to allocate/release all common | |
// memory from Interface. Yes, it is ugly. | |
ITMExtHeader *GetITMExt(int count); | |
- SPLExtHeader *GetSPLExt(int count); | |
//creates a standalone effect with opcode | |
Effect *GetEffect(ieDword opcode); | |
Effect *GetFeatures(int count); | |
diff --git a/gemrb/core/Scriptable/Scriptable.cpp b/gemrb/core/Scriptable/Scriptable.cpp | |
index 625cea8..391d9c3 100644 | |
--- a/gemrb/core/Scriptable/Scriptable.cpp | |
+++ b/gemrb/core/Scriptable/Scriptable.cpp | |
@@ -652,14 +652,15 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l | |
if (caster) { | |
// check for target (type) change | |
- int count, i; | |
+ int count; | |
+ size_t i; | |
Actor *newact = NULL; | |
SPLExtHeader *seh = NULL; | |
Effect *fx = NULL; | |
switch (caster->wildSurgeMods.target_change_type) { | |
case WSTC_SETTYPE: | |
seh = &spl->ext_headers[SpellHeader]; | |
- for (i=0; i < seh->FeatureCount; i++) { | |
+ for (i=0; i < seh->features.size(); i++) { | |
seh->features[i].Target = caster->wildSurgeMods.target_type; | |
} | |
// we need to fetch the projectile, so the effect queue is created | |
@@ -671,12 +672,12 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l | |
// TODO: unhardcode to allow for mixing all the target types | |
// caster gets selftargetting fx when the projectile is fetched above | |
seh = &spl->ext_headers[SpellHeader]; | |
- for (i=0; i < seh->FeatureCount; i++) { | |
+ for (i=0; i < seh->features.size(); i++) { | |
if (seh->features[i].Target == FX_TARGET_SELF) { | |
seh->features[i].Target = caster->wildSurgeMods.target_type; | |
} else { | |
// also apply to the caster | |
- fx = seh->features+i; | |
+ fx = &seh->features[i]; | |
core->ApplyEffect(fx, caster, caster); | |
} | |
} | |
@@ -703,7 +704,7 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l | |
// make it also work for self-targetting spells: | |
// change the payload or this was all in vain | |
seh = &spl->ext_headers[SpellHeader]; | |
- for (i=0; i < seh->FeatureCount; i++) { | |
+ for (i=0; i < seh->features.size(); i++) { | |
if (seh->features[i].Target == FX_TARGET_SELF) { | |
seh->features[i].Target = FX_TARGET_PRESET; | |
} | |
@@ -720,7 +721,7 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l | |
// apply the saving throw mod | |
if (caster->wildSurgeMods.saving_throw_mod) { | |
seh = &spl->ext_headers[SpellHeader]; | |
- for (i=0; i < seh->FeatureCount; i++) { | |
+ for (i=0; i < seh->features.size(); i++) { | |
seh->features[i].SavingThrowBonus += caster->wildSurgeMods.saving_throw_mod; | |
} | |
} | |
@@ -731,7 +732,7 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l | |
// make it also work for self-targetting spells: | |
// change the payload or this was all in vain | |
seh = &spl->ext_headers[SpellHeader]; | |
- for (i=0; i < seh->FeatureCount; i++) { | |
+ for (i=0; i < seh->features.size(); i++) { | |
if (seh->features[i].Target == FX_TARGET_SELF) { | |
seh->features[i].Target = FX_TARGET_PRESET; | |
} | |
@@ -791,7 +792,7 @@ void Scriptable::CreateProjectile(const ieResRef SpellResRef, ieDword tgt, int l | |
//can't check GetEffectBlock, since it doesn't construct the queue for selftargetting spells | |
bool invis = false; | |
unsigned int opcode = EffectQueue::ResolveEffect(fx_set_invisible_state_ref); | |
- for (unsigned int i=0; i < spl->ext_headers[SpellHeader].FeatureCount; i++) { | |
+ for (unsigned int i=0; i < spl->ext_headers[SpellHeader].features.size(); i++) { | |
if (spl->GetExtHeader(SpellHeader)->features[i].Opcode == opcode) { | |
invis = true; | |
break; | |
@@ -1064,7 +1065,7 @@ int Scriptable::SpellCast(bool instant) | |
SpellHeader = 0; | |
} | |
- SPLExtHeader *header = spl->GetExtHeader(SpellHeader); | |
+ SPLExtHeader const* header = spl->GetExtHeader(SpellHeader); | |
int casting_time = (int)header->CastingTime; | |
// how does this work for non-actors exactly? | |
if (actor) { | |
diff --git a/gemrb/core/Spell.cpp b/gemrb/core/Spell.cpp | |
index 06512eb..d0da2c7 100644 | |
--- a/gemrb/core/Spell.cpp | |
+++ b/gemrb/core/Spell.cpp | |
@@ -33,26 +33,18 @@ | |
SPLExtHeader::SPLExtHeader(void) | |
{ | |
- features = NULL; | |
} | |
SPLExtHeader::~SPLExtHeader(void) | |
{ | |
- delete [] features; | |
} | |
Spell::Spell(void) | |
{ | |
- ext_headers = NULL; | |
- casting_features = NULL; | |
} | |
Spell::~Spell(void) | |
{ | |
- //Spell is in the core, so this is not needed, i guess (Avenger) | |
- //core->FreeSPLExt(ext_headers, casting_features); | |
- delete [] ext_headers; | |
- delete [] casting_features; | |
} | |
int Spell::GetHeaderIndexFromLevel(int level) const | |
@@ -61,13 +53,13 @@ int Spell::GetHeaderIndexFromLevel(int level) const | |
if (Flags & SF_SIMPLIFIED_DURATION) { | |
return level; | |
} | |
- int block_index; | |
- for(block_index=0;block_index<ExtHeaderCount-1;block_index++) { | |
+ size_t block_index; | |
+ for(block_index=0;block_index<ext_headers.size()-1;block_index++) { | |
if (ext_headers[block_index+1].RequiredLevel>level) { | |
return block_index; | |
} | |
} | |
- return ExtHeaderCount-1; | |
+ return ext_headers.size()-1; | |
} | |
//-1 will return cfb | |
@@ -120,61 +112,61 @@ void Spell::AddCastingGlow(EffectQueue *fxqueue, ieDword duration, int gender) | |
EffectQueue *Spell::GetEffectBlock(Scriptable *self, const Point &pos, int block_index, int level, ieDword pro) const | |
{ | |
- Effect *features; | |
+ Effect const* features; | |
int count; | |
//iwd2 has this hack | |
if (block_index>=0) { | |
if (Flags & SF_SIMPLIFIED_DURATION) { | |
- features = ext_headers[0].features; | |
- count = ext_headers[0].FeatureCount; | |
+ features = &ext_headers[0].features[0]; | |
+ count = ext_headers[0].features.size(); | |
} else { | |
- features = ext_headers[block_index].features; | |
- count = ext_headers[block_index].FeatureCount; | |
+ features = &ext_headers[block_index].features[0]; | |
+ count = ext_headers[block_index].features.size(); | |
} | |
} else { | |
- features = casting_features; | |
- count = CastingFeatureCount; | |
+ features = &casting_features[0]; | |
+ count = casting_features.size(); | |
} | |
EffectQueue *fxqueue = new EffectQueue(); | |
EffectQueue *selfqueue = NULL; | |
for (int i=0;i<count;i++) { | |
- Effect *fx = features+i; | |
+ Effect fx = features[i]; | |
if ((Flags & SF_SIMPLIFIED_DURATION) && (block_index>=0)) { | |
//hack the effect according to Level | |
//fxqueue->AddEffect will copy the effect, | |
//so we don't risk any overwriting | |
if (EffectQueue::HasDuration(features+i)) { | |
- fx->Duration = (TimePerLevel*block_index+TimeConstant)*core->Time.round_sec; | |
+ fx.Duration = (TimePerLevel*block_index+TimeConstant)*core->Time.round_sec; | |
} | |
} | |
//fill these for completeness, inventoryslot is a good way | |
//to discern a spell from an item effect | |
- fx->InventorySlot = 0xffff; | |
+ fx.InventorySlot = 0xffff; | |
//the hostile flag is used to determine if this was an attack | |
- fx->SourceFlags = Flags; | |
- fx->CasterLevel = level; | |
+ fx.SourceFlags = Flags; | |
+ fx.CasterLevel = level; | |
// apply the stat-based spell duration modifier | |
if (self->Type == ST_ACTOR) { | |
Actor *caster = (Actor *) self; | |
if (caster->Modified[IE_SPELLDURATIONMODMAGE] && SpellType == IE_SPL_WIZARD) { | |
- fx->Duration = (fx->Duration * caster->Modified[IE_SPELLDURATIONMODMAGE]) / 100; | |
+ fx.Duration = (fx.Duration * caster->Modified[IE_SPELLDURATIONMODMAGE]) / 100; | |
} else if (caster->Modified[IE_SPELLDURATIONMODPRIEST] && SpellType == IE_SPL_PRIEST) { | |
- fx->Duration = (fx->Duration * caster->Modified[IE_SPELLDURATIONMODPRIEST]) / 100; | |
+ fx.Duration = (fx.Duration * caster->Modified[IE_SPELLDURATIONMODPRIEST]) / 100; | |
} | |
} | |
- if (fx->Target != FX_TARGET_SELF) { | |
- fx->Projectile = pro; | |
+ if (fx.Target != FX_TARGET_SELF) { | |
+ fx.Projectile = pro; | |
fxqueue->AddEffect( fx ); | |
} else { | |
- fx->Projectile = 0; | |
- fx->PosX=pos.x; | |
- fx->PosY=pos.y; | |
+ fx.Projectile = 0; | |
+ fx.PosX=pos.x; | |
+ fx.PosY=pos.y; | |
if (!selfqueue) { | |
selfqueue = new EffectQueue(); | |
} | |
@@ -194,14 +186,14 @@ EffectQueue *Spell::GetEffectBlock(Scriptable *self, const Point &pos, int block | |
Projectile *Spell::GetProjectile(Scriptable *self, int header, const Point &target) const | |
{ | |
- SPLExtHeader *seh = GetExtHeader(header); | |
+ SPLExtHeader const* seh = GetExtHeader(header); | |
if (!seh) { | |
printMessage("Spell", "Cannot retrieve spell header!!! ",RED); | |
- printf("required header: %d, maximum: %d\n", header, (int) ExtHeaderCount); | |
+ printf("required header: %d, maximum: %d\n", header, (int) ext_headers.size()); | |
return NULL; | |
} | |
Projectile *pro = core->GetProjectileServer()->GetProjectileByIndex(seh->ProjectileAnimation); | |
- if (seh->FeatureCount) { | |
+ if (seh->features.size()) { | |
pro->SetEffects(GetEffectBlock(self, target, header, seh->ProjectileAnimation)); | |
} | |
return pro; | |
@@ -223,10 +215,10 @@ unsigned int Spell::GetCastingDistance(Scriptable *Sender) const | |
level = 1; | |
} | |
int idx = GetHeaderIndexFromLevel(level); | |
- SPLExtHeader *seh = GetExtHeader(idx); | |
+ SPLExtHeader const* seh = GetExtHeader(idx); | |
if (!seh) { | |
printMessage("Spell", "Cannot retrieve spell header!!! ",RED); | |
- printf("required header: %d, maximum: %d\n", idx, (int) ExtHeaderCount); | |
+ printf("required header: %d, maximum: %d\n", idx, (int) ext_headers.size()); | |
return 0; | |
} | |
diff --git a/gemrb/core/Spell.h b/gemrb/core/Spell.h | |
index 810cb41..f495ee2 100644 | |
--- a/gemrb/core/Spell.h | |
+++ b/gemrb/core/Spell.h | |
@@ -33,6 +33,8 @@ | |
#include "EffectQueue.h" | |
+#include <vector> | |
+ | |
class Projectile; | |
//values for Spell usability Flags | |
@@ -84,12 +86,10 @@ public: | |
ieWord DiceThrown; | |
ieWord DamageBonus; | |
ieWord DamageType; | |
- ieWord FeatureCount; | |
- ieWord FeatureOffset; | |
ieWord Charges; | |
ieWord ChargeDepletion; | |
ieWord ProjectileAnimation; | |
- Effect* features; | |
+ std::vector<Effect> features; | |
}; | |
/** | |
@@ -103,8 +103,8 @@ public: | |
Spell(); | |
~Spell(); | |
- SPLExtHeader *ext_headers; | |
- Effect* casting_features; | |
+ std::vector<SPLExtHeader> ext_headers; | |
+ std::vector<Effect> casting_features; | |
/** Resref of the spell itself */ | |
ieResRef Name; | |
@@ -134,11 +134,6 @@ public: | |
ieDword unknown10; | |
ieDword unknown11; | |
ieDword unknown12; | |
- ieDword ExtHeaderOffset; | |
- ieWord ExtHeaderCount; | |
- ieDword FeatureBlockOffset; | |
- ieWord CastingFeatureOffset; | |
- ieWord CastingFeatureCount; | |
// IWD2 only | |
ieDword TimePerLevel; | |
@@ -149,16 +144,16 @@ public: | |
public: | |
//returns the requested extended header | |
- inline SPLExtHeader *GetExtHeader(unsigned int which) const | |
+ inline SPLExtHeader const* GetExtHeader(unsigned int which) const | |
{ | |
if (Flags & SF_SIMPLIFIED_DURATION) { | |
which = 0; | |
} | |
- if(ExtHeaderCount<=which) { | |
+ if(ext_headers.size()<=which) { | |
return NULL; | |
} | |
- return ext_headers+which; | |
+ return &ext_headers[which]; | |
} | |
//converts a wanted level to block index count | |
int GetHeaderIndexFromLevel(int level) const; | |
diff --git a/gemrb/core/Spellbook.cpp b/gemrb/core/Spellbook.cpp | |
index b910faf..2704a62 100644 | |
--- a/gemrb/core/Spellbook.cpp | |
+++ b/gemrb/core/Spellbook.cpp | |
@@ -896,7 +896,7 @@ void Spellbook::AddSpellInfo(unsigned int sm_level, unsigned int sm_type, const | |
Spell *spl = gamedata->GetSpell(spellname); | |
if (!spl) | |
return; | |
- if (spl->ExtHeaderCount<1) | |
+ if (spl->ext_headers.size()<1) | |
return; | |
ieDword level = 0; | |
@@ -910,15 +910,15 @@ void Spellbook::AddSpellInfo(unsigned int sm_level, unsigned int sm_type, const | |
spellinfo.push_back( seh ); | |
memcpy(seh->spellname, spellname, sizeof(ieResRef) ); | |
- int ehc; | |
+ size_t ehc; | |
- for (ehc = 0; ehc < spl->ExtHeaderCount-1; ehc++) { | |
+ for (ehc = 0; ehc < spl->ext_headers.size()-1; ehc++) { | |
if (level<spl->ext_headers[ehc+1].RequiredLevel) { | |
break; | |
} | |
} | |
- SPLExtHeader *ext_header = spl->ext_headers+ehc; | |
+ SPLExtHeader *ext_header = &spl->ext_headers[ehc]; | |
seh->headerindex = ehc; | |
seh->level = sm_level; | |
seh->type = sm_type; | |
diff --git a/gemrb/plugins/SPLImporter/SPLImporter.cpp b/gemrb/plugins/SPLImporter/SPLImporter.cpp | |
index c8c9bfe..3c9db42 100644 | |
--- a/gemrb/plugins/SPLImporter/SPLImporter.cpp | |
+++ b/gemrb/plugins/SPLImporter/SPLImporter.cpp | |
@@ -150,11 +150,14 @@ Spell* SPLImporter::GetSpell(Spell *s, bool /*silent*/) | |
str->ReadDword( &s->unknown10 ); | |
str->ReadDword( &s->unknown11 ); | |
str->ReadDword( &s->unknown12 ); | |
- str->ReadDword( &s->ExtHeaderOffset ); | |
- str->ReadWord( &s->ExtHeaderCount ); | |
- str->ReadDword( &s->FeatureBlockOffset ); | |
- str->ReadWord( &s->CastingFeatureOffset ); | |
- str->ReadWord( &s->CastingFeatureCount ); | |
+ ieDword ExtHeaderOffset; | |
+ ieWord ExtHeaderCount; | |
+ str->ReadDword( &ExtHeaderOffset ); | |
+ str->ReadWord( &ExtHeaderCount ); | |
+ ieWord CastingFeatureOffset, CastingFeatureCount; | |
+ str->ReadDword( &FeatureBlockOffset ); | |
+ str->ReadWord( &CastingFeatureOffset ); | |
+ str->ReadWord( &CastingFeatureCount ); | |
memset( s->unknown13, 0, 8 ); | |
if (version == 20) { | |
@@ -178,77 +181,78 @@ Spell* SPLImporter::GetSpell(Spell *s, bool /*silent*/) | |
} | |
} | |
- s->ext_headers = core->GetSPLExt(s->ExtHeaderCount); | |
+ s->ext_headers.resize(ExtHeaderCount); | |
- for (i = 0; i < s->ExtHeaderCount; i++) { | |
- str->Seek( s->ExtHeaderOffset + i * 40, GEM_STREAM_START ); | |
- GetExtHeader( s, s->ext_headers+i ); | |
+ for (i = 0; i < ExtHeaderCount; i++) { | |
+ str->Seek( ExtHeaderOffset + i * 40, GEM_STREAM_START ); | |
+ GetExtHeader( s, s->ext_headers[i] ); | |
} | |
- s->casting_features = core->GetFeatures(s->CastingFeatureCount); | |
- str->Seek( s->FeatureBlockOffset + 48*s->CastingFeatureOffset, | |
+ s->casting_features.resize(CastingFeatureCount); | |
+ str->Seek( FeatureBlockOffset + 48*CastingFeatureOffset, | |
GEM_STREAM_START ); | |
- for (i = 0; i < s->CastingFeatureCount; i++) { | |
- GetFeature(s, s->casting_features+i); | |
+ for (i = 0; i < CastingFeatureCount; i++) { | |
+ GetFeature(s, s->casting_features[i]); | |
} | |
return s; | |
} | |
-void SPLImporter::GetExtHeader(Spell *s, SPLExtHeader* eh) | |
+void SPLImporter::GetExtHeader(Spell *s, SPLExtHeader& eh) | |
{ | |
ieByte tmpByte; | |
- str->Read( &eh->SpellForm, 1 ); | |
- str->Read( &eh->unknown1, 1 ); | |
- str->Read( &eh->Location, 1 ); | |
- str->Read( &eh->unknown2, 1 ); | |
- str->ReadResRef( eh->MemorisedIcon ); | |
- str->Read( &eh->Target, 1 ); | |
+ str->Read( &eh.SpellForm, 1 ); | |
+ str->Read( &eh.unknown1, 1 ); | |
+ str->Read( &eh.Location, 1 ); | |
+ str->Read( &eh.unknown2, 1 ); | |
+ str->ReadResRef( eh.MemorisedIcon ); | |
+ str->Read( &eh.Target, 1 ); | |
//this hack is to let gemrb target dead actors by some spells | |
- if (eh->Target == 1) { | |
+ if (eh.Target == 1) { | |
if (core->GetSpecialSpell(s->Name)&SPEC_DEAD) { | |
- eh->Target = 3; | |
+ eh.Target = 3; | |
} | |
} | |
str->Read( &tmpByte,1 ); | |
if (!tmpByte) { | |
tmpByte = 1; | |
} | |
- eh->TargetNumber = tmpByte; | |
- str->ReadWord( &eh->Range ); | |
- str->ReadWord( &eh->RequiredLevel ); | |
- str->ReadDword( &eh->CastingTime ); | |
- str->ReadWord( &eh->DiceSides ); | |
- str->ReadWord( &eh->DiceThrown ); | |
- str->ReadWord( &eh->DamageBonus ); | |
- str->ReadWord( &eh->DamageType ); | |
- str->ReadWord( &eh->FeatureCount ); | |
- str->ReadWord( &eh->FeatureOffset ); | |
- str->ReadWord( &eh->Charges ); | |
- str->ReadWord( &eh->ChargeDepletion ); | |
- str->ReadWord( &eh->ProjectileAnimation ); | |
+ eh.TargetNumber = tmpByte; | |
+ str->ReadWord( &eh.Range ); | |
+ str->ReadWord( &eh.RequiredLevel ); | |
+ str->ReadDword( &eh.CastingTime ); | |
+ str->ReadWord( &eh.DiceSides ); | |
+ str->ReadWord( &eh.DiceThrown ); | |
+ str->ReadWord( &eh.DamageBonus ); | |
+ str->ReadWord( &eh.DamageType ); | |
+ ieWord FeatureCount, FeatureOffset; | |
+ str->ReadWord( &FeatureCount ); | |
+ str->ReadWord( &FeatureOffset ); | |
+ str->ReadWord( &eh.Charges ); | |
+ str->ReadWord( &eh.ChargeDepletion ); | |
+ str->ReadWord( &eh.ProjectileAnimation ); | |
//for some odd reasons 0 and 1 are the same | |
- if (eh->ProjectileAnimation) { | |
- eh->ProjectileAnimation--; | |
+ if (eh.ProjectileAnimation) { | |
+ eh.ProjectileAnimation--; | |
} | |
- eh->features = core->GetFeatures( eh->FeatureCount ); | |
- str->Seek( s->FeatureBlockOffset + 48*eh->FeatureOffset, GEM_STREAM_START ); | |
- for (unsigned int i = 0; i < eh->FeatureCount; i++) { | |
- GetFeature(s, eh->features+i); | |
+ eh.features.resize(FeatureCount); | |
+ str->Seek( FeatureBlockOffset + 48*FeatureOffset, GEM_STREAM_START ); | |
+ for (unsigned int i = 0; i < FeatureCount; i++) { | |
+ GetFeature(s, eh.features[i]); | |
} | |
} | |
-void SPLImporter::GetFeature(Spell *s, Effect *fx) | |
+void SPLImporter::GetFeature(Spell *s, Effect& fx) | |
{ | |
PluginHolder<EffectMgr> eM(IE_EFF_CLASS_ID); | |
eM->Open( str, false ); | |
- eM->GetEffect( fx ); | |
- memcpy(fx->Source, s->Name, 9); | |
- fx->PrimaryType = s->PrimaryType; | |
- fx->SecondaryType = s->SecondaryType; | |
+ eM->GetEffect( &fx ); | |
+ memcpy(fx.Source, s->Name, 9); | |
+ fx.PrimaryType = s->PrimaryType; | |
+ fx.SecondaryType = s->SecondaryType; | |
} | |
#include "plugindef.h" | |
diff --git a/gemrb/plugins/SPLImporter/SPLImporter.h b/gemrb/plugins/SPLImporter/SPLImporter.h | |
index 2b355bb..c7b0c56 100644 | |
--- a/gemrb/plugins/SPLImporter/SPLImporter.h | |
+++ b/gemrb/plugins/SPLImporter/SPLImporter.h | |
@@ -34,14 +34,15 @@ private: | |
bool autoFree; | |
int version; | |
+ ieDword FeatureBlockOffset; | |
public: | |
SPLImporter(void); | |
~SPLImporter(void); | |
bool Open(DataStream* stream, bool autoFree = true); | |
Spell* GetSpell(Spell *spl, bool silent=false); | |
private: | |
- void GetExtHeader(Spell *s, SPLExtHeader* eh); | |
- void GetFeature(Spell *s, Effect *f); | |
+ void GetExtHeader(Spell *s, SPLExtHeader& eh); | |
+ void GetFeature(Spell *s, Effect& f); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment