git » fp-git.git » commit 8459b96

fixed checksum bugs in plv support

author ecalot
2006-07-16 22:29:33 UTC
committer ecalot
2006-07-16 22:29:33 UTC
parent 007dd257a4f76b1b7a40979ec3adf8a7251ac2a6

fixed checksum bugs in plv support

PR/src/lib/formats/plv.c +3 -1
PR/src/lib/layers/autodetect.c +1 -1
PR/src/xml/resources.xml +1 -1

diff --git a/PR/src/lib/formats/plv.c b/PR/src/lib/formats/plv.c
index b1552c2..720d9c0 100644
--- a/PR/src/lib/formats/plv.c
+++ b/PR/src/lib/formats/plv.c
@@ -105,6 +105,7 @@ int writePlv(const char* file, tBinary content, int popversion, const char* datf
 	unsigned char sizeOfNow;
 	unsigned char version=popversion;
 	unsigned long int block2size;
+	long contentSizeWithChecksum=content.size+1;
 
 	/* Get current time */
 	now=getDate();
@@ -128,7 +129,7 @@ int writePlv(const char* file, tBinary content, int popversion, const char* datf
 	ok=ok&&fwritechar(&version,target); /* PLV version */
 	ok=ok&&fwritechar(&level,target);
 	ok=ok&&fwritelong(&numberOfFieldPairs,target);
-	ok=ok&&fwritelong(&content.size,target);
+	ok=ok&&fwritelong(&contentSizeWithChecksum,target);
 
 	/* Write block 1: checksum and raw data */
 	checksum=getChecksum(content);
@@ -212,6 +213,7 @@ int readPlv(const char* file, tBinary* content, int *number, char** datfile, cha
 	ok=ok&&freadlong(&fieldPair,fd);
 	ok=ok&&freadlong(&block1Size,fd);
 	ok=ok&&freadchar(&checksum,fd);
+	block1Size--; /* drop the ckecksum */
 
 	/* TODO: validate checksum */
 
diff --git a/PR/src/lib/layers/autodetect.c b/PR/src/lib/layers/autodetect.c
index 7887506..8eeb9ef 100644
--- a/PR/src/lib/layers/autodetect.c
+++ b/PR/src/lib/layers/autodetect.c
@@ -43,7 +43,7 @@ autodetect.c: Princed Resources : Automatic detection resource types
 \***************************************************************/
 
 int verifyPop1LevelHeader(tBinary c) {
-	return (((c.size==2306)||(c.size==2305))&&!(c.data[1697]&0x0F)&&!(c.data[1699]&0x0F)&&!(c.data[1701]&0x0F));
+	return (((c.size==2305)||(c.size==2304)));/* &&!(c.data[1697]&0x0F)&&!(c.data[1699]&0x0F)&&!(c.data[1701]&0x0F));*/
 }
 
 int verifyPop2LevelHeader(tBinary c) {
diff --git a/PR/src/xml/resources.xml b/PR/src/xml/resources.xml
index 2a67055..55c717d 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-pop1-4bits">Unknown Resource number 750</item>
  </folder>
 
- <folder index="pop1" name="binary" file="levels.dat" type="level" path="levels">
+ <folder index="pop1" name="binary" file="levels.dat" type="pop1level" 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>