author | ecalot
<ecalot> 2005-07-06 19:15:08 UTC |
committer | ecalot
<ecalot> 2005-07-06 19:15:08 UTC |
parent | 638e93a7ad4b4ca4ac6326c7277585a1cd2416fa |
PR/src/Makefile | +2 | -2 |
PR/src/include/reslist.h | +1 | -1 |
PR/src/include/types.h | +1 | -1 |
PR/src/lib/layers/dat.c | +21 | -15 |
PR/src/lib/layers/disk.c | +1 | -1 |
PR/src/lib/layers/reslist.c | +7 | -3 |
PR/src/xml/resources.xml | +1 | -1 |
diff --git a/PR/src/Makefile b/PR/src/Makefile index 620f01d..20b732d 100644 --- a/PR/src/Makefile +++ b/PR/src/Makefile @@ -69,14 +69,14 @@ ADDONS = .python.o #Use this to temporary remove an option OPTIONS = $(INCLUDE) $(DEFINES) $(RELEASE) -LINKEROPTIONS = $(LINKERRELEASE) +LINKEROPTIONS = $(LINKERRELEASE) $(LIBS) #main file $(EXEFILE): $(EXEOBJ) $(XMLFILE) $(INFO) Linking files... $(MAKEDIR) bin - $(CC) $(OPTIONS) -o $(EXEFILE) $(EXEOBJ) -o $@ + $(CC) $(OPTIONS) -o $(EXEFILE) $(EXEOBJ) $(INFO) Program successfully compiled $(INFO) $(INFO) Please read readme.txt for syntax information diff --git a/PR/src/include/reslist.h b/PR/src/include/reslist.h index f72a53c..6b7af2b 100644 --- a/PR/src/include/reslist.h +++ b/PR/src/include/reslist.h @@ -81,7 +81,7 @@ int resIdCmp(tResourceId a,tResourceId b); const tResource* resourceListGetElement(tResourceList* r); tResourceList resourceListCreate(int isCopy); void resourceListAddInfo(tResourceList* r,tResource* res); -void resourceListAdd(tResourceList* r,const tResource* res); +void resourceListAdd(tResourceList* r,tResource* res); /* only increases order */ void resourceListDebugPrint(tResourceList* r); #endif diff --git a/PR/src/include/types.h b/PR/src/include/types.h index f72a53c..6b7af2b 100644 --- a/PR/src/include/types.h +++ b/PR/src/include/types.h @@ -81,7 +81,7 @@ int resIdCmp(tResourceId a,tResourceId b); const tResource* resourceListGetElement(tResourceList* r); tResourceList resourceListCreate(int isCopy); void resourceListAddInfo(tResourceList* r,tResource* res); -void resourceListAdd(tResourceList* r,const tResource* res); +void resourceListAdd(tResourceList* r,tResource* res); /* only increases order */ void resourceListDebugPrint(tResourceList* r); #endif diff --git a/PR/src/lib/layers/dat.c b/PR/src/lib/layers/dat.c index 26b5483..9a20b93 100644 --- a/PR/src/lib/layers/dat.c +++ b/PR/src/lib/layers/dat.c @@ -79,7 +79,7 @@ int checkSum(const unsigned char* data,int size) { /* todo: move to datindex.c */ #define toLower(a) (('A'<=(a)&&(a)<='Z')?(a)|0x40:(a)) /* TODO: move to memory.c and improve str5lowercpy */ -#define toUpper(a) (('a'<=(a)&&(a)<='b')?(a)&0xDF:(a)) +#define toUpper(a) (('a'<=(a)&&(a)<='z')?(a)&0xDF:(a)) /* the cursor get functions */ @@ -102,6 +102,19 @@ void rememberIndex(char* to, const char* from) { *to=0; } +void saveIndex(char* to, const char* from) { + int i=4; + int k=0; + from+=3; + while (i--) { + to[k]=toUpper(*from); + from--; + if (!to[k]) continue; + k++; + } + for (;k<4;k++) to[k]=0; +} + /* the cursor move functions */ int dat_cursorNextIndex(tIndexCursor* r) { @@ -363,6 +376,7 @@ void dat_readRes(tResource* res) { /* for each archived file the index is read */ res->id.value= dat_readCursorGetId (readIndexCursor); strncpy(res->id.index,dat_readCursorGetIndexName (readIndexCursor),5); + res->id.order=0; res->offset= dat_readCursorGetOffset (readIndexCursor); res->size= dat_readCursorGetSize (readIndexCursor); res->flags= dat_readCursorGetFlags (readIndexCursor); @@ -483,7 +497,7 @@ void mWriteCloseDatFile(int dontSave,int optionflag, const char* backupExtension resourceListStartIteration(&resIndex); res=resourceListGetElement(&resIndex); if (res) { - if (!strncmp(res->id.index,"POP1",4)) { /* POP1 */ + if (!strncmp(res->id.index,"pop1",4)) { /* POP1 */ do { totalItems++; printf("Adding item id (%s,%d)\n",res->id.index,res->id.value); @@ -497,25 +511,17 @@ void mWriteCloseDatFile(int dontSave,int optionflag, const char* backupExtension unsigned long int flags=res->flags; int numberOfSlaveItems=0; int slaveCountPos=size1; /* first value is a junked place */ + int c; unsigned char v; + char aux[4]; /* first step: read the list to create the master index */ strcpy(index,"X"); do { if (strncmp(res->id.index,index,4)) { - fseek(writeDatFile,3,SEEK_CUR); - v=toUpper(res->id.index[0]); - fwritechar(&v,writeDatFile); - fseek(writeDatFile,-1,SEEK_CUR); - v=v?toUpper(res->id.index[1]):0; - fwritechar(&v,writeDatFile); - v=v?toUpper(res->id.index[2]):0; - fseek(writeDatFile,-1,SEEK_CUR); - fwritechar(&v,writeDatFile); - v=v?toUpper(res->id.index[3]):0; - fseek(writeDatFile,-1,SEEK_CUR); - fwritechar(&v,writeDatFile); - fseek(writeDatFile,4,SEEK_CUR); + saveIndex(aux,res->id.index); + for (c=0;c<4;c++) + fwritechar((unsigned char*)(aux+c),writeDatFile); fwriteshort(&totalItems,writeDatFile); /* Junk (I) */ strncpy(index,res->id.index,5); diff --git a/PR/src/lib/layers/disk.c b/PR/src/lib/layers/disk.c index 58bfe6f..5fba858 100644 --- a/PR/src/lib/layers/disk.c +++ b/PR/src/lib/layers/disk.c @@ -122,7 +122,7 @@ int makebase(const char* p) { /* Declare variables */ static char old[MAX_FILENAME_SIZE]; - int i,a,equal=1; + int i,a=0,equal=1; int size; char* aux; diff --git a/PR/src/lib/layers/reslist.c b/PR/src/lib/layers/reslist.c index 0b7bbcb..f7f73b9 100644 --- a/PR/src/lib/layers/reslist.c +++ b/PR/src/lib/layers/reslist.c @@ -79,10 +79,14 @@ tResourceList resourceListCreate(int isCopy) { return list_create(sizeof(tResource),resCmp,isCopy?resFreeDummy:resFree); } -void resourceListAdd(tResourceList* r,const tResource* res) { +void resourceListAdd(tResourceList* r,tResource* res) { /* first try to detect if the resource exists */ - /*if (!list_moveCursor(r,res))*/ - list_insert(r,res); /* insert repeated resources */ +/* res->id.order=0; + while (list_moveCursor(r,res)) { + printf("id=(%d,%s,%d)\n",res->id.value,res->id.index,res->id.order); + res->id.order++; * increase order until the id is unique * + }*/ + list_insert(r,res); } void printr(const tResource* record) { diff --git a/PR/src/xml/resources.xml b/PR/src/xml/resources.xml index 9575428..3f407cc 100644 --- a/PR/src/xml/resources.xml +++ b/PR/src/xml/resources.xml @@ -1387,7 +1387,7 @@ resources.xml: Princed Resources : Resource tree <item value="750" path="palette2.pal" type="palette">Unknown Resource number 750</item> </folder> - <folder index="pop1" name="binary" file="ilevels.dat" type="level" path="levels"> + <folder index="pop1" name="binary" file="levels.dat" type="level" path="levels"> <item value="2000" number="0" path="demo.plv">Demo level</item> <item value="2001" number="1" path="level1.plv">Level 1</item> <item value="2002" number="2" path="level2.plv">Level 2</item>