git » fp-git.git » commit 4f55c70

fixed several bugs

author ecalot
2006-07-17 04:26:55 UTC
committer ecalot
2006-07-17 04:26:55 UTC
parent 1605b75c7728cc06efaf44ee779cc0af034c9e43

fixed several bugs

PR/src/include/common.h +15 -11
PR/src/lib/actions/import.c +8 -9
PR/src/xml/resources.xml +2 -2

diff --git a/PR/src/include/common.h b/PR/src/include/common.h
index b1dcc31..c712642 100644
--- a/PR/src/include/common.h
+++ b/PR/src/include/common.h
@@ -206,7 +206,11 @@ PARSING_OPTRAW\
 
 #define PR_RESULT_F_BMP_BITRATE_DIFFERS -31
 #define PR_RESULT_F_COMMAND_LINE_SYNTAX -17
+#define PR_RESULT_F_COMPRESS_RESULT_FATAL -26
 #define PR_RESULT_F_EXTRACTION -18
+#define PR_RESULT_F_FD_IMPORT_FROM_MORE_THAN_ONE_DIR -20
+#define PR_RESULT_F_FD_IMPORT_RECURSIVE -21
+#define PR_RESULT_F_FD_NO_FILES_SELECTED -22
 #define PR_RESULT_F_FILE_DAT_NOT_OPEN_NOTFOUND -2
 #define PR_RESULT_F_FILE_DAT_NOT_OPEN_WASDIR -3
 #define PR_RESULT_F_FILE_DAT_NOT_READ_ACCESS -4
@@ -215,19 +219,9 @@ PARSING_OPTRAW\
 #define PR_RESULT_F_FILE_NOT_OPEN_WASDIR -7
 #define PR_RESULT_F_FILE_NOT_READ_ACCESS -8
 #define PR_RESULT_F_FILE_NOT_WRITE_ACCESS -9
+#define PR_RESULT_F_INDEX_NOT_FOUND -23
 #define PR_RESULT_F_INVALID_DAT -10
 #define PR_RESULT_F_MEMORY -11
-#define PR_RESULT_F_WRONG_PRIMITIVE_CALL -19
-#define PR_RESULT_F_XML_ALREADY_OPEN -15
-#define PR_RESULT_F_XML_ATTR -12
-#define PR_RESULT_F_XML_FILE -13
-#define PR_RESULT_F_XML_NOT_OPEN -16
-#define PR_RESULT_F_XML_PARSING -14
-#define PR_RESULT_F_COMPRESS_RESULT_FATAL -26
-#define PR_RESULT_F_FD_IMPORT_FROM_MORE_THAN_ONE_DIR -20
-#define PR_RESULT_F_FD_IMPORT_RECURSIVE -21
-#define PR_RESULT_F_FD_NO_FILES_SELECTED -22
-#define PR_RESULT_F_INDEX_NOT_FOUND -23
 #define PR_RESULT_F_MID_WRONG_FILE_FORMAT -34
 #define PR_RESULT_F_PAL_UNSUPPORTED_SIZE -32
 #define PR_RESULT_F_PLV_WRONG_FILE_FORMAT -33
@@ -235,11 +229,21 @@ PARSING_OPTRAW\
 #define PR_RESULT_F_WAV_UNSUPPORTED_BITRATE -28
 #define PR_RESULT_F_WAV_UNSUPPORTED_SAMPLERATE -29
 #define PR_RESULT_F_WAV_UNSUPPORTED_STEREO -30
+#define PR_RESULT_F_WRONG_PRIMITIVE_CALL -19
+#define PR_RESULT_F_XML_ALREADY_OPEN -15
 #define PR_RESULT_F_XML_AND_DAT_FORMAT_DO_NOT_MATCH -25
+#define PR_RESULT_F_XML_ATTR -12
+#define PR_RESULT_F_XML_FILE -13
+#define PR_RESULT_F_XML_NOT_OPEN -16
+#define PR_RESULT_F_XML_PARSING -14
 #define PR_RESULT_HELP_SHOWN -1
 #define PR_RESULT_SUCCESS 0
 #define PR_RESULT_W_CHECKSUM_ERROR -24
 #define PR_RESULT_W_COMPRESS_RESULT_WARNING -27
 
+#define PR_RESULT_F(code) (code<-1 && code!=PR_RESULT_W_CHECKSUM_ERROR && code!=PR_RESULT_W_COMPRESS_RESULT_WARNING)
+
+/* TODO: change error codes and create PR_RESULT_W and _F using < and > */
+
 #endif
 
diff --git a/PR/src/lib/actions/import.c b/PR/src/lib/actions/import.c
index 6c1a63c..76f9566 100644
--- a/PR/src/lib/actions/import.c
+++ b/PR/src/lib/actions/import.c
@@ -80,34 +80,33 @@ int import_full(const char* vFiledat, const char* vDirExt, tResourceList* r, int
 
 		if (hasFlag(raw_flag)) newRes.type=0; /* compile from raw */
 		getFileName(vFileext,vDirExt,res,vFiledat,vDatFileName,optionflag,backupExtension,NULL);
-		/* TODO: if image read the palette */
+		/* TODO: if image read the palette and check */
 		/* the file is in the archive, so I'll add it to the main DAT body */
 /*		newRes.content=mLoadFileArray(vFileext);*/
 /*		if (newRes.content.size>0) {*/
 			/* TODO: let each format handle the files */
 		o=objectRead(vFileext,&newRes,&result);
-/*			if (!fatal(result)) */
-				if (!result)
+		if (!PR_RESULT_F(result)) { 
 			objectSet(o,&result,&newRes);
 
-/*			if (!fatal(ok)) {
+			if (PR_RESULT_F(result)) { /* TODO: print warnings */ 
 				if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_ERRORS,getFileNameFromPath(vFileext));
 				error++;
 			} else {
 				if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_SUCCESS,getFileNameFromPath(vFileext));
 				ok++;
-			}*/
+			}
 			/*free(newRes.content.data);*/
-/*		} else {
+		} else {
 			if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_NOT_OPEN,getFileNameFromPath(vFileext));
 			error++;
-		}*/
+		}
 
 		list_nextCursor(r);
 	}
 
 	/* Close file. If empty, don't save */
-	mWriteCloseDatFile(ok,optionflag,backupExtension);
+	mWriteCloseDatFile(!ok,optionflag,backupExtension);
 
 	if (hasFlag(verbose_flag)) fprintf(outputStream,PR_TEXT_IMPORT_DONE,ok,error);
 	return error;
@@ -154,7 +153,7 @@ int import_partial(const char* vFiledat, const char* vDirExt, tResourceList* r,
 			getFileName(vFileext,vDirExt,&res,vFiledat,vDatFileName,optionflag,backupExtension,NULL);
 
 			o=objectRead(repairFolders(vFileext),&newRes,&result);
-/*			if (!fatal(ok)) */
+/*			if (!PR_RESULT_F(result)) */
 			if (!ok)
 				objectSet(o,&result,&newRes);
 
diff --git a/PR/src/xml/resources.xml b/PR/src/xml/resources.xml
index 55c717d..60f3a95 100644
--- a/PR/src/xml/resources.xml
+++ b/PR/src/xml/resources.xml
@@ -1597,7 +1597,7 @@ resources.xml: Princed Resources : Resource tree
  <!--
       pop2: kid.dat
   -->
- <folder index="shap" name="prince" type="image" path="kid" file="kid.dat" palette="25001" paletteindex="palc" flags="0x400000">
+ <folder index="shap" name="prince" type="image" path="kid" file="pop2.kid.dat" palette="25001" paletteindex="palc" flags="0x400000">
   <item value="25001" index="palc" path="binary001.bin" type="palette-pop1-4bits" flags="0x0">Unknown binary 1</item>
   <item value="25001" index="pals" path="prince.pal" type="palette-pop1-4bits" flags="0x0">The prince palette</item>
   <item value="24824" index="shap" path="image001.bmp" type="image" flags="0x400000">Unknown image 1</item>
@@ -2418,7 +2418,7 @@ resources.xml: Princed Resources : Resource tree
  <!--
       pop2: prince.dat
   -->
- <folder index="shap" name="prince" path="prince.dat" file="prince.dat" palette="750" paletteindex="palc" flags="0x400000">
+ <folder index="shap" name="prince" path="prince.dat" file="pop2.prince.dat" palette="750" paletteindex="palc" flags="0x400000">
   <item value="25" index="" path="binary001.bin" type="binary" flags="0x0">Unknown binary 1</item>
   <item value="26" index="" path="binary002.bin" type="binary" flags="0x0">Unknown binary 2</item>
   <item value="27" index="" path="binary003.bin" type="binary" flags="0x0">Unknown binary 3</item>