From: Laszlo T. <ave...@us...> - 2005-06-22 21:21:29
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/CREImporter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19265/plugins/CREImporter Modified Files: CREImp.cpp CREImp.h Log Message: fixed creature saving (spells, items) fixed .gam saving (bestiary, familiars) implemented shrinking of portrait icons for savegames (when needed) Index: CREImp.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/CREImporter/CREImp.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CREImp.h 19 Jun 2005 22:59:33 -0000 1.13 --- CREImp.h 22 Jun 2005 21:21:13 -0000 1.14 *************** *** 1,3 **** - /* GemRB - Infinity Engine Emulator * Copyright (C) 2003 The GemRB Project --- 1,2 ---- *************** *** 31,38 **** #define IE_CRE_V2_2 22 #define IE_CRE_V9_0 90 ! ! //local variables in creatures are stored in fake opcodes ! #define FAKE_VARIABLE_OPCODE 187 ! #define FAKE_VARIABLE_MARKER 1 class CREImp : public ActorMgr { --- 30,37 ---- #define IE_CRE_V2_2 22 #define IE_CRE_V9_0 90 ! ! //local variables in creatures are stored in fake opcodes ! #define FAKE_VARIABLE_OPCODE 187 ! #define FAKE_VARIABLE_MARKER 1 class CREImp : public ActorMgr { *************** *** 47,56 **** ieDword MemorizedSpellsOffset; ieDword MemorizedSpellsCount; ieDword ItemSlotsOffset; ieDword ItemsOffset; ieDword ItemsCount; ! ieDword EffectsOffset; ! ieDword EffectsCount; ! ieByte TotSCEFF; public: --- 46,57 ---- ieDword MemorizedSpellsOffset; ieDword MemorizedSpellsCount; + ieDword MemorizedIndex; + ieDword MemorizedCount; ieDword ItemSlotsOffset; ieDword ItemsOffset; ieDword ItemsCount; ! ieDword EffectsOffset; ! ieDword EffectsCount; ! ieByte TotSCEFF; public: *************** *** 87,96 **** int PutActorBG(DataStream *stream, Actor *actor); int PutActorIWD1(DataStream *stream, Actor *actor); ! int PutActorIWD2(DataStream *stream, Actor *actor); ! int PutKnownSpells(DataStream *stream, Actor *actor); ! int PutSpellPages(DataStream *stream, Actor *actor); ! int PutMemorizedSpells(DataStream *stream, Actor *actor); ! int PutEffects(DataStream *stream, Actor *actor); ! int PutVariables(DataStream *stream, Actor *actor); int PutInventory(DataStream *stream, Actor *actor, unsigned int size); int PutHeader(DataStream *stream, Actor *actor); --- 88,97 ---- int PutActorBG(DataStream *stream, Actor *actor); int PutActorIWD1(DataStream *stream, Actor *actor); ! int PutActorIWD2(DataStream *stream, Actor *actor); ! int PutKnownSpells(DataStream *stream, Actor *actor); ! int PutSpellPages(DataStream *stream, Actor *actor); ! int PutMemorizedSpells(DataStream *stream, Actor *actor); ! int PutEffects(DataStream *stream, Actor *actor); ! int PutVariables(DataStream *stream, Actor *actor); int PutInventory(DataStream *stream, Actor *actor, unsigned int size); int PutHeader(DataStream *stream, Actor *actor); Index: CREImp.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/CREImporter/CREImp.cpp,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** CREImp.cpp 20 Jun 2005 17:15:24 -0000 1.76 --- CREImp.cpp 22 Jun 2005 21:21:13 -0000 1.77 *************** *** 154,159 **** str->ReadWord( &spl->Number2 ); str->ReadWord( &spl->Type ); ! str->ReadDword( &spl->MemorizedIndex ); ! str->ReadDword( &spl->MemorizedCount ); return spl; --- 154,159 ---- str->ReadWord( &spl->Number2 ); str->ReadWord( &spl->Type ); ! str->ReadDword( &MemorizedIndex ); ! str->ReadDword( &MemorizedCount ); return spl; *************** *** 199,203 **** } } ! for(i=(int) stat+1;i<RandColor;i++) { if (randcolors[i][0]==stat) { stat=randcolors[i][ rand()%RandRows + 1]; --- 199,203 ---- } } ! for (i=(int) stat+1;i<RandColor;i++) { if (randcolors[i][0]==stat) { stat=randcolors[i][ rand()%RandRows + 1]; *************** *** 244,248 **** ieByte tmp2[7]; str->Read( tmp2, 7); ! for(int i=0;i<7;i++) { act->BaseStats[IE_METAL_COLOR+i]=tmp2[i]; SetupColor(act->BaseStats[IE_METAL_COLOR+i]); --- 244,248 ---- ieByte tmp2[7]; str->Read( tmp2, 7); ! for (int i=0;i<7;i++) { act->BaseStats[IE_METAL_COLOR+i]=tmp2[i]; SetupColor(act->BaseStats[IE_METAL_COLOR+i]); *************** *** 374,378 **** str->Read( &tmpByte, 1 ); act->BaseStats[IE_LUCK]=tmpByte; ! for(i=0;i<21;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_PROFICIENCYBASTARDSWORD+i]=tmpByte; --- 374,378 ---- str->Read( &tmpByte, 1 ); act->BaseStats[IE_LUCK]=tmpByte; ! for (i=0;i<21;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_PROFICIENCYBASTARDSWORD+i]=tmpByte; *************** *** 381,385 **** act->BaseStats[IE_TRACKING]=tmpByte; str->Seek( 32, GEM_CURRENT_POS ); ! for(i=0;i<100;i++) { str->ReadDword( &act->StrRefs[i] ); } --- 381,385 ---- act->BaseStats[IE_TRACKING]=tmpByte; str->Seek( 32, GEM_CURRENT_POS ); ! for (i=0;i<100;i++) { str->ReadDword( &act->StrRefs[i] ); } *************** *** 426,430 **** str->ReadDword( &act->BaseStats[IE_XP_MAGE] ); // Exp for secondary class str->ReadDword( &act->BaseStats[IE_XP_THIEF] ); // Exp for tertiary class ! for(i = 0; i<10; i++) { str->ReadWord( &tmpWord ); act->BaseStats[IE_INTERNAL_0+i]=tmpWord; --- 426,430 ---- str->ReadDword( &act->BaseStats[IE_XP_MAGE] ); // Exp for secondary class str->ReadDword( &act->BaseStats[IE_XP_THIEF] ); // Exp for tertiary class ! for (i = 0; i<10; i++) { str->ReadWord( &tmpWord ); act->BaseStats[IE_INTERNAL_0+i]=tmpWord; *************** *** 573,578 **** } } ! for (j = 0; j < sm->MemorizedCount; j++) { ! k = sm->MemorizedIndex+j; if (memorized_spells[k]) { sm->memorized_spells.push_back( memorized_spells[k]); --- 573,578 ---- } } ! for (j = 0; j < MemorizedCount; j++) { ! k = MemorizedIndex+j; if (memorized_spells[k]) { sm->memorized_spells.push_back( memorized_spells[k]); *************** *** 686,690 **** str->Read( &tmpByte, 1 ); act->BaseStats[IE_LUCK]=tmpByte; ! for(i=0;i<21;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_PROFICIENCYBASTARDSWORD+i]=tmpByte; --- 686,690 ---- str->Read( &tmpByte, 1 ); act->BaseStats[IE_LUCK]=tmpByte; ! for (i=0;i<21;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_PROFICIENCYBASTARDSWORD+i]=tmpByte; *************** *** 694,698 **** act->BaseStats[IE_TRACKING]=tmpByte; str->Seek( 32, GEM_CURRENT_POS ); ! for(i=0;i<100;i++) { str->ReadDword( &act->StrRefs[i] ); } --- 694,698 ---- act->BaseStats[IE_TRACKING]=tmpByte; str->Seek( 32, GEM_CURRENT_POS ); ! for (i=0;i<100;i++) { str->ReadDword( &act->StrRefs[i] ); } *************** *** 861,865 **** act->BaseStats[IE_LEVELSORCEROR]=tmpByte; str->Seek( 22, GEM_CURRENT_POS ); //levels for classes ! for(i=0;i<64;i++) { str->ReadDword( &act->StrRefs[i] ); } --- 861,865 ---- act->BaseStats[IE_LEVELSORCEROR]=tmpByte; str->Seek( 22, GEM_CURRENT_POS ); //levels for classes ! for (i=0;i<64;i++) { str->ReadDword( &act->StrRefs[i] ); } *************** *** 873,877 **** act->BaseStats[IE_HATEDRACE]=tmpByte; //we got 7 more hated races ! for(i=0;i<7;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_HATEDRACE2+i]=tmpByte; --- 873,877 ---- act->BaseStats[IE_HATEDRACE]=tmpByte; //we got 7 more hated races ! for (i=0;i<7;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_HATEDRACE2+i]=tmpByte; *************** *** 1029,1033 **** str->Read( &tmpByte, 1 ); act->BaseStats[IE_LUCK]=tmpByte; ! for(i=0;i<21;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_PROFICIENCYBASTARDSWORD+i]=tmpByte; --- 1029,1033 ---- str->Read( &tmpByte, 1 ); act->BaseStats[IE_LUCK]=tmpByte; ! for (i=0;i<21;i++) { str->Read( &tmpByte, 1 ); act->BaseStats[IE_PROFICIENCYBASTARDSWORD+i]=tmpByte; *************** *** 1036,1040 **** act->BaseStats[IE_TRACKING]=tmpByte; str->Seek( 32, GEM_CURRENT_POS ); ! for(i=0;i<100;i++) { str->ReadDword( &act->StrRefs[i] ); } --- 1036,1040 ---- act->BaseStats[IE_TRACKING]=tmpByte; str->Seek( 32, GEM_CURRENT_POS ); ! for (i=0;i<100;i++) { str->ReadDword( &act->StrRefs[i] ); } *************** *** 1147,1151 **** //adding known spells KnownSpellsCount = actor->spellbook.GetTotalKnownSpellsCount(); ! headersize += KnownSpellsCount * 16; SpellMemorizationOffset = headersize; --- 1147,1151 ---- //adding known spells KnownSpellsCount = actor->spellbook.GetTotalKnownSpellsCount(); ! headersize += KnownSpellsCount * 12; SpellMemorizationOffset = headersize; *************** *** 1162,1168 **** EffectsCount = actor->locals->GetCount(); if (TotSCEFF) { ! headersize += EffectsCount * 0x10; } else { ! headersize += EffectsCount * 0x20; } ItemsOffset = headersize; --- 1162,1168 ---- EffectsCount = actor->locals->GetCount(); if (TotSCEFF) { ! headersize += EffectsCount * 264; } else { ! headersize += EffectsCount * 48; } ItemsOffset = headersize; *************** *** 1170,1174 **** //counting items (calculating item storage) ItemsCount = 0; ! for(i=0;i<Inventory_Size;i++) { CREItem *it = actor->inventory.GetSlotItem(i); if (it) { --- 1170,1174 ---- //counting items (calculating item storage) ItemsCount = 0; ! for (i=0;i<Inventory_Size;i++) { CREItem *it = actor->inventory.GetSlotItem(i); if (it) { *************** *** 1179,1184 **** ItemSlotsOffset = headersize; ! //adding in itemslot table ! return headersize + (Inventory_Size+1)*sizeof(ieWord); } --- 1179,1184 ---- ItemSlotsOffset = headersize; ! //adding itemslot table size and equipped slot field ! return headersize + (Inventory_Size)*sizeof(ieWord)+sizeof(ieDword); } *************** *** 1190,1197 **** ieWord *indices =(ieWord *) malloc(size*sizeof(ieWord) ); ! for(i=0;i<size;i++) { indices[i]=(ieWord) -1; } ! for(i=0;i<size;i++) { CREItem *it = actor->inventory.GetSlotItem(i); if (!it) { --- 1190,1197 ---- ieWord *indices =(ieWord *) malloc(size*sizeof(ieWord) ); ! for (i=0;i<size;i++) { indices[i]=(ieWord) -1; } ! for (i=0;i<size;i++) { CREItem *it = actor->inventory.GetSlotItem(i); if (!it) { *************** *** 1206,1210 **** indices[i] = ItemCount++; } ! for(i=0;i<size;i++) { stream->WriteWord( indices+i); } --- 1206,1210 ---- indices[i] = ItemCount++; } ! for (i=0;i<size;i++) { stream->WriteWord( indices+i); } *************** *** 1238,1242 **** stream->WriteWord( &tmpWord); stream->WriteDword( &actor->BaseStats[IE_ANIMATION_ID]); ! for(i=0;i<7;i++) { Signature[i] = (char) actor->BaseStats[IE_METAL_COLOR+i]; } --- 1238,1242 ---- stream->WriteWord( &tmpWord); stream->WriteDword( &actor->BaseStats[IE_ANIMATION_ID]); ! for (i=0;i<7;i++) { Signature[i] = (char) actor->BaseStats[IE_METAL_COLOR+i]; } *************** *** 1506,1510 **** stream->WriteDword( &actor->BaseStats[IE_XP_MAGE]); stream->WriteDword( &actor->BaseStats[IE_XP_THIEF]); ! for(i = 0; i<10; i++) { tmpWord = actor->BaseStats[IE_INTERNAL_0]; stream->WriteWord( &tmpWord ); --- 1506,1510 ---- stream->WriteDword( &actor->BaseStats[IE_XP_MAGE]); stream->WriteDword( &actor->BaseStats[IE_XP_THIEF]); ! for (i = 0; i<10; i++) { tmpWord = actor->BaseStats[IE_INTERNAL_0]; stream->WriteWord( &tmpWord ); *************** *** 1517,1521 **** stream->WriteWord( &actor->AppearanceFlags1); stream->WriteWord( &actor->AppearanceFlags2); ! for(i=0;i<7;i++) { tmpWord = actor->BaseStats[IE_COLORS+i]; stream->WriteWord( &tmpWord); --- 1517,1521 ---- stream->WriteWord( &actor->AppearanceFlags1); stream->WriteWord( &actor->AppearanceFlags2); ! for (i=0;i<7;i++) { tmpWord = actor->BaseStats[IE_COLORS+i]; stream->WriteWord( &tmpWord); *************** *** 1610,1627 **** { int type=actor->spellbook.GetTypes(); ! for(int i=0;i<type;i++) { unsigned int level = actor->spellbook.GetSpellLevelCount(i); ! for(unsigned int j=0;j<level;j++) { unsigned int count = actor->spellbook.GetKnownSpellsCount(i, j); ! for(unsigned int k=0;k<count;k++) { CREKnownSpell *ck = actor->spellbook.GetKnownSpell(i, j, k); stream->WriteResRef(ck->SpellResRef); ! ! ieDword tmpDword; ! ! tmpDword = ck->Level; ! stream->WriteDword( &tmpDword); ! tmpDword = ck->Type; ! stream->WriteDword( &tmpDword); } } --- 1610,1622 ---- { int type=actor->spellbook.GetTypes(); ! for (int i=0;i<type;i++) { unsigned int level = actor->spellbook.GetSpellLevelCount(i); ! for (unsigned int j=0;j<level;j++) { unsigned int count = actor->spellbook.GetKnownSpellsCount(i, j); ! for (unsigned int k=0;k<count;k++) { CREKnownSpell *ck = actor->spellbook.GetKnownSpell(i, j, k); stream->WriteResRef(ck->SpellResRef); ! stream->WriteWord( &ck->Level); ! stream->WriteWord( &ck->Type); } } *************** *** 1637,1643 **** int type=actor->spellbook.GetTypes(); ! for(int i=0;i<type;i++) { unsigned int level = actor->spellbook.GetSpellLevelCount(i); ! for(unsigned int j=0;j<level;j++) { tmpWord = j+1; stream->WriteWord( &tmpWord); --- 1632,1638 ---- int type=actor->spellbook.GetTypes(); ! for (int i=0;i<type;i++) { unsigned int level = actor->spellbook.GetSpellLevelCount(i); ! for (unsigned int j=0;j<level;j++) { tmpWord = j+1; stream->WriteWord( &tmpWord); *************** *** 1660,1668 **** { int type=actor->spellbook.GetTypes(); ! for(int i=0;i<type;i++) { unsigned int level = actor->spellbook.GetSpellLevelCount(i); ! for(unsigned int j=0;j<level;j++) { unsigned int count = actor->spellbook.GetMemorizedSpellsCount(i,j); ! for(unsigned int k=0;k<count;k++) { CREMemorizedSpell *cm = actor->spellbook.GetMemorizedSpell(i,j,k); --- 1655,1663 ---- { int type=actor->spellbook.GetTypes(); ! for (int i=0;i<type;i++) { unsigned int level = actor->spellbook.GetSpellLevelCount(i); ! for (unsigned int j=0;j<level;j++) { unsigned int count = actor->spellbook.GetMemorizedSpellsCount(i,j); ! for (unsigned int k=0;k<count;k++) { CREMemorizedSpell *cm = actor->spellbook.GetMemorizedSpell(i,j,k); *************** *** 1674,1677 **** --- 1669,1687 ---- return 0; } + int CREImp::PutEffects( DataStream *stream, Actor *actor) + { + char filling[0x268]; + + memset(filling,0,sizeof(filling) ); + for(unsigned int i=0;i<EffectsCount-actor->locals->GetCount();i++) { + if (TotSCEFF) { + stream->Write( filling, 264); + } else { + stream->Write( filling, 48); + } + } + return 0; + } + //add as effect! int CREImp::PutVariables( DataStream *stream, Actor *actor) *************** *** 1781,1784 **** --- 1791,1798 ---- return ret; } + ret = PutEffects(stream, actor); + if (ret) { + return ret; + } //effects and variables ret = PutVariables(stream, actor); |