From: Jarda B. <edh...@us...> - 2004-03-30 00:04:02
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/CREImporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23247/plugins/CREImporter Modified Files: CREImp.cpp CREImp.h Log Message: Added wip versions of Spellbook and Inventory Index: CREImp.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/CREImporter/CREImp.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CREImp.h 24 Feb 2004 22:20:42 -0000 1.5 --- CREImp.h 29 Mar 2004 23:52:29 -0000 1.6 *************** *** 45,48 **** --- 45,52 ---- delete this; } + CREKnownSpell* GetKnownSpell(); + CRESpellMemorization* GetSpellMemorization(); + CREMemorizedSpell* GetMemorizedSpell(); + CREItem* GetItem(); }; Index: CREImp.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/CREImporter/CREImp.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** CREImp.cpp 24 Feb 2004 22:20:42 -0000 1.24 --- CREImp.cpp 29 Mar 2004 23:52:29 -0000 1.25 *************** *** 307,311 **** str->Seek( 4, GEM_CURRENT_POS ); str->Read( act->scriptName, 32 ); ! str->Seek( 44, GEM_CURRENT_POS ); str->Read( act->Dialog, 8 ); act->BaseStats[IE_ARMOR_TYPE] = 0; --- 307,323 ---- str->Seek( 4, GEM_CURRENT_POS ); str->Read( act->scriptName, 32 ); ! ! str->Read( &act->KnownSpellsOffset, 4 ); ! str->Read( &act->KnownSpellsCount, 4 ); ! str->Read( &act->SpellMemorizationOffset, 4 ); ! str->Read( &act->SpellMemorizationCount, 4 ); ! str->Read( &act->MemorizedSpellsOffset, 4 ); ! str->Read( &act->MemorizedSpellsCount, 4 ); ! str->Read( &act->ItemSlotsOffset, 4 ); ! str->Read( &act->ItemsOffset, 4 ); ! str->Read( &act->ItemsCount, 4 ); ! ! str->Seek( 8, GEM_CURRENT_POS ); ! str->Read( act->Dialog, 8 ); act->BaseStats[IE_ARMOR_TYPE] = 0; *************** *** 314,318 **** --- 326,421 ---- act->anims->DrawCircle = false;*/ + // Reading inventory + act->inventory = new Inventory(); + + std::vector<CREItem*> items; + str->Seek( act->ItemsOffset, GEM_STREAM_START ); + for (int i = 0; i < act->ItemsCount; i++) { + items.push_back( GetItem() ); + } + + str->Seek( act->ItemSlotsOffset, GEM_STREAM_START ); + for (int i = 0; i < INVENTORY_SIZE; i++) { + ieWord index; + str->Read( &index, 2 ); + + if (index != 0xFFFF) + act->inventory->SetSlotItem( items[index], i ); + } + act->inventory->dump(); + + + // Reading spellbook + act->spellbook = new Spellbook(); + + str->Seek( act->KnownSpellsOffset, GEM_STREAM_START ); + for (int i = 0; i < act->KnownSpellsCount; i++) { + act->spellbook->AddKnownSpell( GetKnownSpell() ); + } + + str->Seek( act->MemorizedSpellsOffset, GEM_STREAM_START ); + for (int i = 0; i < act->MemorizedSpellsCount; i++) { + act->spellbook->AddMemorizedSpell( GetMemorizedSpell() ); + } + + str->Seek( act->SpellMemorizationOffset, GEM_STREAM_START ); + for (int i = 0; i < act->SpellMemorizationCount; i++) { + act->spellbook->AddSpellMemorization( GetSpellMemorization() ); + } + + act->spellbook->dump(); + + + act->Init(); //applies effects, updates Modified return act; } + + CREKnownSpell* CREImp::GetKnownSpell() + { + CREKnownSpell* spl = new CREKnownSpell(); + + str->Read( &spl->SpellResRef, 8 ); + str->Read( &spl->Level, 2 ); + str->Read( &spl->Type, 2 ); + + return spl; + } + + CRESpellMemorization* CREImp::GetSpellMemorization() + { + CRESpellMemorization* spl = new CRESpellMemorization(); + + str->Read( &spl->Level, 2 ); + str->Read( &spl->Number, 2 ); + str->Read( &spl->Number2, 2 ); + str->Read( &spl->Type, 2 ); + str->Read( &spl->MemorizedIndex, 4 ); + str->Read( &spl->MemorizedCount, 4 ); + + return spl; + } + + CREMemorizedSpell* CREImp::GetMemorizedSpell() + { + CREMemorizedSpell* spl = new CREMemorizedSpell(); + + str->Read( &spl->SpellResRef, 8 ); + str->Read( &spl->Flags, 4 ); + + return spl; + } + + CREItem* CREImp::GetItem() + { + CREItem *itm = new CREItem(); + + str->Read( itm->ItemResRef, 8 ); + str->Read( &itm->Unknown08, 2 ); + str->Read( &itm->Usages[0], 2 ); + str->Read( &itm->Usages[1], 2 ); + str->Read( &itm->Usages[2], 2 ); + str->Read( &itm->Flags, 4 ); + + return itm; + } |