git » fp-git.git » commit 2a11f92

created attribute order in xms and resId to make sure the id is unique

author ecalot
2005-06-30 16:49:44 UTC
committer ecalot
2005-06-30 16:49:44 UTC
parent 34902cff59f773e6f4c8b89612f8bd3430a76b37

created attribute order in xms and resId to make sure the id is unique

PR/src/include/pr.h +1 -0
PR/src/include/reslist.h +1 -0
PR/src/include/types.h +1 -0
PR/src/lib/layers/reslist.c +5 -1
PR/src/lib/xml/parse.c +4 -0
PR/src/lib/xml/search.c +15 -0

diff --git a/PR/src/include/pr.h b/PR/src/include/pr.h
index 335f47e..c13bc65 100644
--- a/PR/src/include/pr.h
+++ b/PR/src/include/pr.h
@@ -56,6 +56,7 @@ typedef struct tTag {
 	char* paletteindex;
 	char* value;
 	char* index;
+	char* order;
 	char* version;
 	char* number;
 	char* flags;
diff --git a/PR/src/include/reslist.h b/PR/src/include/reslist.h
index 07f3a0b..f72a53c 100644
--- a/PR/src/include/reslist.h
+++ b/PR/src/include/reslist.h
@@ -54,6 +54,7 @@ typedef enum {
 typedef struct {
 	unsigned short int value;
 	char               index[5];
+	unsigned short     order;
 }tResourceId;
 
 typedef struct {
diff --git a/PR/src/include/types.h b/PR/src/include/types.h
index 07f3a0b..f72a53c 100644
--- a/PR/src/include/types.h
+++ b/PR/src/include/types.h
@@ -54,6 +54,7 @@ typedef enum {
 typedef struct {
 	unsigned short int value;
 	char               index[5];
+	unsigned short     order;
 }tResourceId;
 
 typedef struct {
diff --git a/PR/src/lib/layers/reslist.c b/PR/src/lib/layers/reslist.c
index 23bb271..0b7bbcb 100644
--- a/PR/src/lib/layers/reslist.c
+++ b/PR/src/lib/layers/reslist.c
@@ -48,6 +48,10 @@ int resIdCmp(tResourceId a,tResourceId b) {
 	/* at this point, the indexes are the same, so let's compare the number */
 	if (a.value>b.value) return GT;
 	if (a.value<b.value) return LT;
+	
+	/* at this point, indexes and values are the same, but this is not enough, we'll use order to be sure it's unique */
+	if (a.order>b.order) return GT;
+	if (a.order<b.order) return LT;
 	return EQ;
 }
 
@@ -82,7 +86,7 @@ void resourceListAdd(tResourceList* r,const tResource* res) {
 }
 
 void printr(const tResource* record) {
-		printf("id=(%d,%s)\n",record->id.value,record->id.index);
+		printf("id=(%d,%s,%d)\n",record->id.value,record->id.index,record->id.order);
 		printf("palette=(%d,%s)\n",record->palette.value,record->palette.index);
 		printf("size=%ld offset=%lu\n",record->size,record->offset);
 		printf("number=%d type=%d\n",record->number,record->type);
diff --git a/PR/src/lib/xml/parse.c b/PR/src/lib/xml/parse.c
index 5f99568..1b0df0b 100644
--- a/PR/src/lib/xml/parse.c
+++ b/PR/src/lib/xml/parse.c
@@ -98,6 +98,7 @@ tTag* getTagStructure() {
 	t->palette=NULL;
 	t->value=NULL;
 	t->index=NULL;
+	t->order=NULL;
 	t->paletteindex=NULL;
 	t->version=NULL;
 	t->number=NULL;
@@ -119,6 +120,7 @@ void freeTagStructure(tTag* t) {
 	freeAllocation(t->palette);
 	freeAllocation(t->value);
 	freeAllocation(t->index);
+	freeAllocation(t->order);
 	freeAllocation(t->paletteindex);
 	freeAllocation(t->version);
 	freeAllocation(t->number);
@@ -148,6 +150,7 @@ int attribFill(char* attr,char* val, tTag* t) {
 	FillAttr(t->palette,"palette");
 	FillAttr(t->value,"value");
 	FillAttr(t->index,"index");
+	FillAttr(t->order,"order");
 	FillAttr(t->paletteindex,"paletteindex");
 	FillAttr(t->version,"version");
 	FillAttr(t->number,"levelnumber"); /* levelnumber is a number alias */
@@ -373,6 +376,7 @@ tTag* makeTree(char** p,char* name, int* error,tTag* father) {
 		TotalInheritance(type);
 		TotalInheritance(file);
 		TotalInheritance(index);
+		TotalInheritance(order);
 		TotalInheritance(flags);
 		/* PartialConcatInheritance(tag->path,father->path,tag->value); */
 		if ((tag->value==NULL)||(tag->path!=NULL)) {
diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c
index 0158bca..027946e 100644
--- a/PR/src/lib/xml/search.c
+++ b/PR/src/lib/xml/search.c
@@ -89,6 +89,21 @@ void workTag(const tTag* t,void* pass) {
 	}
 #endif
 
+	/* Get the order */
+	if (t->order) {
+		if (equalsIgnoreCase(t->order,"first")) {
+			res.id.order=0;
+		} else if (equalsIgnoreCase(t->order,"second")) {
+			res.id.order=1;
+		} else if (equalsIgnoreCase(t->order,"last")) {
+			res.id.order=65535;
+		} else {
+			res.id.order=atoi(t->order);
+		}
+	} else {
+		res.id.order=0;
+	}
+	
 	/* Copy id and palette id */	
 	keepIdAttributes(id,value,index);
 	keepIdAttributesElse(palette,palette,paletteindex,index);