From: Alyssa M. <fu...@us...> - 2010-08-30 08:57:32
|
gemrb: Infinity Engine emulator The branch master has been updated via caf8a6af6bf632477060f735a0df3ce53372c777 (commit) Summary of changes: gemrb/core/Spellbook.h | 8 +++++--- gemrb/plugins/CREImporter/CREImporter.cpp | 26 +++++++++++++------------- gemrb/plugins/CREImporter/CREImporter.h | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) from 1549a0cbc545ed36dfd9985be483be6cd9bf7bf8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=caf8a6af6bf632477060f735a0df3ce53372c777 commit caf8a6af6bf632477060f735a0df3ce53372c777 Author: Alyssa Milburn <fu...@fu...> Date: Mon Aug 30 10:55:23 2010 +0200 try fixing the spellbook memorization API diff --git a/gemrb/core/Spellbook.h b/gemrb/core/Spellbook.h index 6315610..78ae688 100644 --- a/gemrb/core/Spellbook.h +++ b/gemrb/core/Spellbook.h @@ -148,8 +148,9 @@ private: void RemoveMemorization(CRESpellMemorization* sm, const ieResRef ResRef); /** adds a spell to the book, internal */ bool AddKnownSpell(CREKnownSpell *spl, int memo); - /** returns a CRESpellMemorization pointer */ - CRESpellMemorization *GetSpellMemorization(unsigned int type, unsigned int level); + /** Adds a new CRESpellMemorization, to the *end* only */ + bool AddSpellMemorization(CRESpellMemorization* sm); + public: Spellbook(); ~Spellbook(); @@ -164,7 +165,8 @@ public: bool KnowSpell(const char *resref); bool KnowSpell(int spellid); - bool AddSpellMemorization(CRESpellMemorization* sm); + /** returns a CRESpellMemorization pointer */ + CRESpellMemorization *GetSpellMemorization(unsigned int type, unsigned int level); int GetTypes() const; bool IsIWDSpellBook() const; unsigned int GetSpellLevelCount(int type) const; diff --git a/gemrb/plugins/CREImporter/CREImporter.cpp b/gemrb/plugins/CREImporter/CREImporter.cpp index 84ad587..2b0fa96 100644 --- a/gemrb/plugins/CREImporter/CREImporter.cpp +++ b/gemrb/plugins/CREImporter/CREImporter.cpp @@ -633,17 +633,22 @@ void CREImporter::ReadScript(Actor *act, int ScriptLevel) act->SetScript( aScript, ScriptLevel, act->InParty!=0); } -CRESpellMemorization* CREImporter::GetSpellMemorization() +CRESpellMemorization* CREImporter::GetSpellMemorization(Actor *act) { - CRESpellMemorization* spl = new CRESpellMemorization(); + ieWord Level, Type, Number, Number2; - str->ReadWord( &spl->Level ); - str->ReadWord( &spl->Number ); - str->ReadWord( &spl->Number2 ); - str->ReadWord( &spl->Type ); + str->ReadWord( &Level ); + str->ReadWord( &Number ); + str->ReadWord( &Number2 ); + str->ReadWord( &Type ); str->ReadDword( &MemorizedIndex ); str->ReadDword( &MemorizedCount ); + CRESpellMemorization* spl = act->spellbook.GetSpellMemorization(Level, Type); + assert(spl->Number == 0 && spl->Number2 == 0); // unused + spl->Number = Number; + spl->Number2 = Number; + return spl; } @@ -1119,7 +1124,7 @@ void CREImporter::ReadInventory(Actor *act, unsigned int Inventory_Size) str->Seek( SpellMemorizationOffset+CREOffset, GEM_STREAM_START ); for (i = 0; i < SpellMemorizationCount; i++) { - CRESpellMemorization* sm = GetSpellMemorization(); + CRESpellMemorization* sm = GetSpellMemorization(act); j=KnownSpellsCount; while(j--) { @@ -1143,7 +1148,6 @@ void CREImporter::ReadInventory(Actor *act, unsigned int Inventory_Size) } printf("[CREImporter]: Duplicate memorized spell (%d) in creature!\n", k); } - act->spellbook.AddSpellMemorization( sm ); } i=KnownSpellsCount; @@ -1460,9 +1464,7 @@ void CREImporter::GetIWD2Spellpage(Actor *act, ieIWD2SpellType type, int level, ieDword tmpDword; int check = 0; - CRESpellMemorization *sm = new CRESpellMemorization; - sm->Level = level; - sm->Type = type; + CRESpellMemorization* sm = act->spellbook.GetSpellMemorization(level, type); while(count--) { str->ReadDword(&spellindex); str->ReadDword(&totalcount); @@ -1504,8 +1506,6 @@ void CREImporter::GetIWD2Spellpage(Actor *act, ieIWD2SpellType type, int level, sm->Number = (ieWord) tmpDword; str->ReadDword(&tmpDword); sm->Number2 = (ieWord) tmpDword; - - act->spellbook.AddSpellMemorization(sm); } void CREImporter::GetActorIWD2(Actor *act) diff --git a/gemrb/plugins/CREImporter/CREImporter.h b/gemrb/plugins/CREImporter/CREImporter.h index 38e2568..a0417e1 100644 --- a/gemrb/plugins/CREImporter/CREImporter.h +++ b/gemrb/plugins/CREImporter/CREImporter.h @@ -89,7 +89,7 @@ private: void ReadScript(Actor *actor, int ScriptLevel); void ReadDialog(Actor *actor); CREKnownSpell* GetKnownSpell(); - CRESpellMemorization* GetSpellMemorization(); + CRESpellMemorization* GetSpellMemorization(Actor *act); CREMemorizedSpell* GetMemorizedSpell(); CREItem* GetItem(); void SetupColor(ieDword&); ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |