From: Laszlo T. <ave...@us...> - 2006-08-04 21:42:49
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv10310/plugins/Core Modified Files: Inventory.cpp Inventory.h Spellbook.cpp Spellbook.h Log Message: bg2:spell/innate lists work too Index: Spellbook.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Spellbook.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Spellbook.h 11 Apr 2006 16:32:35 -0000 1.19 --- Spellbook.h 4 Aug 2006 21:42:44 -0000 1.20 *************** *** 109,112 **** --- 109,129 ---- } CRESpellMemorization; + struct SpellExtHeader { + ieDword level; + ieDword count; + ieDword type; //spelltype + ieDword headerindex; + //these come from the header + ieByte SpellForm; + ieResRef MemorisedIcon; + ieByte Target; + ieByte TargetNumber; + ieWord Range; + ieWord Projectile; + ieWord CastingTime; + //other data + ieResRef spellname; + ieDword strref; //the spell's name + }; /** *************** *** 169,172 **** --- 186,193 ---- void ChargeAllSpells(); + /** lists spells of a type */ + bool GetSpellInfo(SpellExtHeader *array, int type, int startindex, int count); + + /** applies the spell on target */ bool CastSpell( ieResRef SpellResRef, Actor* Source, Actor* Target ); Index: Inventory.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Inventory.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** Inventory.cpp 3 Aug 2006 19:58:59 -0000 1.80 --- Inventory.cpp 4 Aug 2006 21:42:44 -0000 1.81 *************** *** 1155,1158 **** --- 1155,1165 ---- continue; } + //skipping if we cannot use the item + int idreq1 = (slot->Flags&IE_INV_ITEM_IDENTIFIED); + int idreq2 = ext_header->IDReq; + if (idreq1!=idreq2) { + continue; + } + actual++; if (actual>startindex) { Index: Spellbook.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Spellbook.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Spellbook.cpp 11 Apr 2006 16:32:35 -0000 1.37 --- Spellbook.cpp 4 Aug 2006 21:42:44 -0000 1.38 *************** *** 504,507 **** --- 504,565 ---- } + /* returns true if there are more item usages not fitting in given array */ + bool Spellbook::GetSpellInfo(SpellExtHeader *array, int type, int startindex, int count) + { + int pos = 0; + int actual = 0; + + memset(array, 0, count * sizeof(SpellExtHeader) ); + for (int i = 0; i < NUM_SPELL_TYPES; i++) { + for (unsigned int j = 0; j < spells[i].size(); j++) { + CRESpellMemorization* sm = spells[i][j]; + + if ( !(type & (1<<sm->Type)) ) { + continue; + } + for (unsigned int k = 0; k < sm->memorized_spells.size(); k++) { + CREMemorizedSpell* slot = sm->memorized_spells[k]; + if (!slot) + continue; + if (!slot->Flags) + continue; + actual++; + if (actual>startindex) { + //store the item, return if we can't store more + if (!count) { + return true; + } + Spell *spl = core->GetSpell(slot->SpellResRef); + ieDword level = 0; + count--; + memcpy(array[pos].spellname, slot->SpellResRef, sizeof(ieResRef) ); + int ehc; + + for(ehc=0;ehc<spl->ExtHeaderCount-1;ehc++) { + if (level<spl->ext_headers[ehc+1].RequiredLevel) { + break; + } + } + SPLExtHeader *ext_header = spl->ext_headers+ehc; + array[pos].headerindex = ehc; + array[pos].SpellForm = ext_header->SpellForm; + memcpy(array[pos].MemorisedIcon, ext_header->MemorisedIcon,sizeof(ieResRef) ); + array[pos].Target = ext_header->Target; + array[pos].TargetNumber = ext_header->TargetNumber; + array[pos].Range = ext_header->Range; + array[pos].Projectile = ext_header->Projectile; + array[pos].CastingTime = ext_header->CastingTime; + array[pos].strref = spl->SpellName; + + pos++; + core->FreeSpell(spl, slot->SpellResRef, false); + } + } + } + } + + return false; + } + bool Spellbook::CastSpell( ieResRef SpellResRef, Actor* Source, Actor* Target ) { Index: Inventory.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Inventory.h,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Inventory.h 29 Jul 2006 18:17:26 -0000 1.49 --- Inventory.h 4 Aug 2006 21:42:44 -0000 1.50 *************** *** 117,120 **** --- 117,125 ---- #define EQUIP_RANGED 2 + //FIXME: + //actually this header shouldn't be THIS large, i was just + //lazy to pick the interesting elements + //it could be possible that some elements need to be added from the + //item header itself struct ItemExtHeader { ieDword slot; |