git » fp-git.git » commit a163f18

o Some optimizations

author ecalot
2003-10-23 22:48:36 UTC
committer ecalot
2003-10-23 22:48:36 UTC
parent 6959098dd3bbad9a928ad88a9edacddfb7d20644

o Some optimizations

PR/src/lib/actions/export.c +3 -12
PR/src/lib/compression/rle_compress.c +5 -4
PR/src/lib/compression/rle_decompress.c +5 -4
PR/src/lib/compression/rlev_decompress.c +5 -4
PR/src/lib/object/image/image16.c +5 -4
PR/src/lib/object/image/image2.c +5 -4
PR/src/lib/object/image/image256.c +5 -4
PR/src/lib/object/image/image_common.c +5 -4

diff --git a/PR/src/lib/actions/export.c b/PR/src/lib/actions/export.c
index acc737d..81d476b 100644
--- a/PR/src/lib/actions/export.c
+++ b/PR/src/lib/actions/export.c
@@ -44,8 +44,8 @@ extract.c: Princed Resources : DAT Extractor
 \***************************************************************/
 
 char writeData(unsigned char* data, int ignoreChars, char* vFileext, int size) {
-	FILE*              target;
-	char ok;
+	FILE* target;
+	char  ok;
 
 	ok=((target=fopen(vFileext,"wb"))!=NULL);
 	ok=ok&&fwrite(data+ignoreChars,size-ignoreChars,1,target);
@@ -86,13 +86,11 @@ int extract(char* vFiledat,char* vDirExt, tResource* r[], char task) {
 		unsigned short int id;
 		unsigned long int  size,offset;
 		unsigned char*     data;
-//		FILE*              target;
 		char               type=0;
 		char               recordSize;
 		char               aux[260];
 		tImage             image; //this is used to make a persistent palette
 		char               isntImageSet=1;
-	////printf("kkkkkkkkkkk: %x\n",task);
 
 		//verify dat format
 		ok    = fread(&indexOffset,4,1,fp);
@@ -104,7 +102,6 @@ int extract(char* vFiledat,char* vDirExt, tResource* r[], char task) {
 		if (!pop1) { //verify if pop2
 			ofk=numberOfItems*6+2+(numberOfItems-2)*13;
 			numberOfItems=((indexSize-6-(numberOfItems*6)-((numberOfItems-2)*13))/11);
-////printf("verificando pop2: numberOfItems=%d, indexSize=%d\r\n",numberOfItems,indexSize);
 		}
 		recordSize=pop1?8:11;
 		if (!ok) {
@@ -127,16 +124,11 @@ int extract(char* vFiledat,char* vDirExt, tResource* r[], char task) {
 			offset=index[ofk+k*recordSize+2]+256*index[ofk+k*recordSize+3]+256*256*index[ofk+k*recordSize+4]+256*256*256*index[ofk+k*recordSize+5];
 			size=index[ofk+k*recordSize+6]+256*index[ofk+k*recordSize+7]+1;
 			if (!pop1) {
-				//printf("jajaA %d\r\n",ok);
 				ok=ok&&(index[ofk+k*recordSize+8]==0x40)&&(!index[ofk+k*recordSize+9])&&(!index[ofk+k*recordSize+10]);
-				//printf("jajaB %d\r\n",ok);
 			}
 			ok=ok&&((data=getMemory(size))!=NULL);
-				//printf("jajaC %d offset=%d\r\n",ok,offset);
 			ok=ok&&(!fseek(fp,offset,SEEK_SET));
-				//printf("jajaD %d\r\n",ok);
 			ok=ok&&fread(data,size,1,fp);
-				//printf("jajaEd %d\r\n",ok);
 			if (!ok) return -3;
 
 			//For the moment rebuilt option will be mandatory:
@@ -147,6 +139,7 @@ int extract(char* vFiledat,char* vDirExt, tResource* r[], char task) {
 				if ((*(r[id])).coms!=NULL) free ((*(r[id])).coms);
 				if ((*(r[id])).desc!=NULL) free ((*(r[id])).desc);
 				free(r[id]);
+				r[id]=NULL;
 			}
 
 			//set resource information on this index entry
@@ -192,10 +185,8 @@ int extract(char* vFiledat,char* vDirExt, tResource* r[], char task) {
 				}
 			}
 			if (data!=NULL) free(data);
-			//printf("libere data que no era nula\n");
 		}
 		fclose(fp);
-		//printf("termine A %d\n",ok);
 		return ok;
 	} else {
 		return -1; //file could not be open
diff --git a/PR/src/lib/compression/rle_compress.c b/PR/src/lib/compression/rle_compress.c
index b0b2f83..54c519e 100644
--- a/PR/src/lib/compression/rle_compress.c
+++ b/PR/src/lib/compression/rle_compress.c
@@ -101,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++; //TODO idem
+			*(cursorData)=*(cursorPix);
 			(*counter)++;
-			*(cursorData)=       *(cursorPix-1);
+			cursorPix++;
 			cursorData++;
 		}
 
@@ -113,8 +113,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				cursorPix++;
 				(*counter)--;
 			}
-			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=     *(cursorPix-1); //Print repeated char
+			
+			*(cursorData)=*(cursorPix); //Print repeated char
+			cursorPix++;
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/compression/rle_decompress.c b/PR/src/lib/compression/rle_decompress.c
index b0b2f83..54c519e 100644
--- a/PR/src/lib/compression/rle_decompress.c
+++ b/PR/src/lib/compression/rle_decompress.c
@@ -101,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++; //TODO idem
+			*(cursorData)=*(cursorPix);
 			(*counter)++;
-			*(cursorData)=       *(cursorPix-1);
+			cursorPix++;
 			cursorData++;
 		}
 
@@ -113,8 +113,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				cursorPix++;
 				(*counter)--;
 			}
-			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=     *(cursorPix-1); //Print repeated char
+			
+			*(cursorData)=*(cursorPix); //Print repeated char
+			cursorPix++;
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/compression/rlev_decompress.c b/PR/src/lib/compression/rlev_decompress.c
index b0b2f83..54c519e 100644
--- a/PR/src/lib/compression/rlev_decompress.c
+++ b/PR/src/lib/compression/rlev_decompress.c
@@ -101,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++; //TODO idem
+			*(cursorData)=*(cursorPix);
 			(*counter)++;
-			*(cursorData)=       *(cursorPix-1);
+			cursorPix++;
 			cursorData++;
 		}
 
@@ -113,8 +113,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				cursorPix++;
 				(*counter)--;
 			}
-			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=     *(cursorPix-1); //Print repeated char
+			
+			*(cursorData)=*(cursorPix); //Print repeated char
+			cursorPix++;
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image16.c b/PR/src/lib/object/image/image16.c
index b0b2f83..54c519e 100644
--- a/PR/src/lib/object/image/image16.c
+++ b/PR/src/lib/object/image/image16.c
@@ -101,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++; //TODO idem
+			*(cursorData)=*(cursorPix);
 			(*counter)++;
-			*(cursorData)=       *(cursorPix-1);
+			cursorPix++;
 			cursorData++;
 		}
 
@@ -113,8 +113,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				cursorPix++;
 				(*counter)--;
 			}
-			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=     *(cursorPix-1); //Print repeated char
+			
+			*(cursorData)=*(cursorPix); //Print repeated char
+			cursorPix++;
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image2.c b/PR/src/lib/object/image/image2.c
index b0b2f83..54c519e 100644
--- a/PR/src/lib/object/image/image2.c
+++ b/PR/src/lib/object/image/image2.c
@@ -101,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++; //TODO idem
+			*(cursorData)=*(cursorPix);
 			(*counter)++;
-			*(cursorData)=       *(cursorPix-1);
+			cursorPix++;
 			cursorData++;
 		}
 
@@ -113,8 +113,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				cursorPix++;
 				(*counter)--;
 			}
-			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=     *(cursorPix-1); //Print repeated char
+			
+			*(cursorData)=*(cursorPix); //Print repeated char
+			cursorPix++;
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image256.c b/PR/src/lib/object/image/image256.c
index b0b2f83..54c519e 100644
--- a/PR/src/lib/object/image/image256.c
+++ b/PR/src/lib/object/image/image256.c
@@ -101,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++; //TODO idem
+			*(cursorData)=*(cursorPix);
 			(*counter)++;
-			*(cursorData)=       *(cursorPix-1);
+			cursorPix++;
 			cursorData++;
 		}
 
@@ -113,8 +113,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				cursorPix++;
 				(*counter)--;
 			}
-			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=     *(cursorPix-1); //Print repeated char
+			
+			*(cursorData)=*(cursorPix); //Print repeated char
+			cursorPix++;
 			cursorData++;
 		}
 	}
diff --git a/PR/src/lib/object/image/image_common.c b/PR/src/lib/object/image/image_common.c
index b0b2f83..54c519e 100644
--- a/PR/src/lib/object/image/image_common.c
+++ b/PR/src/lib/object/image/image_common.c
@@ -101,9 +101,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 
 		//Step 2: Look and copy the string until a repeated byte is found
 		while ((cursorPix<imgEnd)&&(*cursorPix!=*(cursorPix+1))&&((*counter)!=127)) {
-			cursorPix++; //TODO idem
+			*(cursorData)=*(cursorPix);
 			(*counter)++;
-			*(cursorData)=       *(cursorPix-1);
+			cursorPix++;
 			cursorData++;
 		}
 
@@ -113,8 +113,9 @@ void compressRle(unsigned char* data,tImage* img,int *dataSize) {
 				cursorPix++;
 				(*counter)--;
 			}
-			cursorPix++; //TODO poner esta linea abajo
-			*(cursorData)=     *(cursorPix-1); //Print repeated char
+			
+			*(cursorData)=*(cursorPix); //Print repeated char
+			cursorPix++;
 			cursorData++;
 		}
 	}