git » fp-git.git » commit 67c43cc

new modules

author ecalot
2005-12-16 16:49:03 UTC
committer ecalot
2005-12-16 16:49:03 UTC
parent 826f284dff90c0e400e4c3aeba2170d346a1ac0c

new modules

PR/src/Makefile +8 -0
PR/src/include/translate.h +49 -0
PR/src/lib/layers/stringformat.c +1 -0
PR/src/lib/xml/translate.c +47 -0

diff --git a/PR/src/Makefile b/PR/src/Makefile
index 20b732d..f8a062d 100644
--- a/PR/src/Makefile
+++ b/PR/src/Makefile
@@ -197,6 +197,14 @@ $(XMLFILE): xml/resources.xml
 	$(INFO) Compiling XML search features...
 	$(CC) $(OPTIONS) -c lib/xml/search.c -o $@
 
+.translate.o: lib/xml/translate.c include/common.h
+	$(INFO) Compiling array tranlation features...
+	$(CC) $(OPTIONS) -c lib/xml/translate.c -o $@
+
+.stringformat.o: lib/layers/stringformat.c include/common.h
+	$(INFO) Compiling unknown string format parsing feature...
+	$(CC) $(OPTIONS) -c lib/layers/stringformat.c -o $@
+
 .bmp.o: lib/formats/bmp.c include/bmp.h include/common.h include/dat.h include/disk.h include/memory.h
 	$(INFO) Compiling bitmap files support \(bmp\)...
 	$(CC) $(OPTIONS) -c lib/formats/bmp.c -o $@
diff --git a/PR/src/include/translate.h b/PR/src/include/translate.h
new file mode 100644
index 0000000..48e89f5
--- /dev/null
+++ b/PR/src/include/translate.h
@@ -0,0 +1,49 @@
+/*  Princed V3 - Prince of Persia Level Editor for PC Version
+    Copyright (C) 2003 Princed Development Team
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    The authors of this program may be contacted at http://forum.princed.com.ar
+*/
+
+/*
+translate.c: Princed Resources : array translating resources
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2005 Princed Development Team
+  Created: 16 Dec 2005
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2005-Dec-16)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
+
+#ifndef _TRANSLATE_H_
+#define _TRANSLATE_H_
+
+#define TRANS_ARRAY_INDEX_INT {"pop1", "shap", "fram", "shpl",         "palt"       }
+#define TRANS_ARRAY_INDEX_EXT {"pop 1","shape","frame","shape palette","palette tga"}
+
+extern const char* _indexInt[];
+extern const char* _indexExt[];
+
+const char* translate (const char* input, const char** s1, const char** s2,int sizeOfArray);
+
+#define translateInt2Ext(a) translate (a, _indexInt, _indexExt, sizeof(_indexInt)/sizeof(char*))
+#define translateExt2Int(a) translate (a, _indexExt, _indexInt, sizeof(_indexInt)/sizeof(char*))
+
+#endif
+
diff --git a/PR/src/lib/layers/stringformat.c b/PR/src/lib/layers/stringformat.c
index 97c9815..bd96296 100644
--- a/PR/src/lib/layers/stringformat.c
+++ b/PR/src/lib/layers/stringformat.c
@@ -31,6 +31,7 @@ dfsdfs.c: Princed Resources : dfsgsdgsdfgdfgs
   DO NOT remove this copyright notice
 */
 
+#include <stdlib.h> /* NULL */
 
 static int i;
 static char buffer[200];
diff --git a/PR/src/lib/xml/translate.c b/PR/src/lib/xml/translate.c
new file mode 100644
index 0000000..450a18e
--- /dev/null
+++ b/PR/src/lib/xml/translate.c
@@ -0,0 +1,47 @@
+/*  Princed V3 - Prince of Persia Level Editor for PC Version
+    Copyright (C) 2003 Princed Development Team
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    The authors of this program may be contacted at http://forum.princed.com.ar
+*/
+
+/*
+translate.c: Princed Resources : array translating resources
+\xaf\xaf\xaf\xaf\xaf\xaf\xaf
+ Copyright 2005 Princed Development Team
+  Created: 16 Dec 2005
+
+  Author: Enrique Calot <ecalot.cod@princed.com.ar>
+  Version: 1.01 (2005-Dec-16)
+
+ Note:
+  DO NOT remove this copyright notice
+*/
+
+#include <string.h> /* strcmp */
+
+const char* _indexInt[]=TRANS_ARRAY_INDEX_INT;
+const char* _indexExt[]=TRANS_ARRAY_INDEX_EXT};
+
+const char* translate (const char* input, const char** s1, const char** s2,int sizeOfArray) {
+	while (sizeOfArray--) {
+		if (!strcmp(input,s1[sizeOfArray])) {
+			return s2[sizeOfArray];
+		}
+	}
+	return input;
+}
+