[Scummvm-cvs-logs] SF.net SVN: scummvm:[46369] tools/branches/gsoc2009-gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Dec 13 23:06:45 CET 2009


Revision: 46369
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46369&view=rev
Author:   fingolfin
Date:     2009-12-13 22:06:45 +0000 (Sun, 13 Dec 2009)

Log Message:
-----------
Move util.cpp to common/util.cpp; some cleanup; fix create_sjisfnt.cpp

Modified Paths:
--------------
    tools/branches/gsoc2009-gui/Makefile
    tools/branches/gsoc2009-gui/common/file.cpp
    tools/branches/gsoc2009-gui/common/file.h
    tools/branches/gsoc2009-gui/create_sjisfnt.cpp

Added Paths:
-----------
    tools/branches/gsoc2009-gui/common/util.cpp

Removed Paths:
-------------
    tools/branches/gsoc2009-gui/util.cpp

Modified: tools/branches/gsoc2009-gui/Makefile
===================================================================
--- tools/branches/gsoc2009-gui/Makefile	2009-12-13 21:44:57 UTC (rev 46368)
+++ tools/branches/gsoc2009-gui/Makefile	2009-12-13 22:06:45 UTC (rev 46369)
@@ -78,6 +78,7 @@
 UTILS := \
 	common/file.o \
 	common/md5.o \
+	common/util.o \
 	utils/adpcm.o \
 	utils/audiostream.o \
 	utils/voc.o \
@@ -99,109 +100,32 @@
 	cp $(srcdir)/gui/media/*.* $(bundle_name)/Contents/Resources
 	cp tools_gui$(EXEEXT) $(bundle_name)/Contents/MacOS/
 
-#compress_agos$(EXEEXT): compress_agos.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_gob$(EXEEXT): compress_gob.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#compress_kyra$(EXEEXT): compress_kyra.o kyra_pak.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_queen$(EXEEXT): compress_queen.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_saga$(EXEEXT): compress_saga.o compress.o util.o tool.o $(UTILS)
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_scumm_bun$(EXEEXT): compress_scumm_bun.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_scumm_san$(EXEEXT): compress_scumm_san.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lz -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_scumm_sou$(EXEEXT): compress_scumm_sou.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_sword1$(EXEEXT): compress_sword1.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_sword2$(EXEEXT): compress_sword2.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_tinsel$(EXEEXT): compress_tinsel.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_touche$(EXEEXT): compress_touche.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
-#compress_tucker$(EXEEXT): compress_tucker.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
-
 decine$(EXEEXT): decine.o
 	$(CXX) $(LDFLAGS) -o $@ $+
 
-dekyra$(EXEEXT): dekyra.o dekyra_v1.o util.o $(UTILS)
+dekyra$(EXEEXT): dekyra.o dekyra_v1.o $(UTILS)
 	$(CXX) $(LDFLAGS) -o $@ $+
 
-descumm$(EXEEXT): descumm-tool.o descumm.o descumm6.o descumm-common.o util.o tool.o $(UTILS)
+descumm$(EXEEXT): descumm-tool.o descumm.o descumm6.o descumm-common.o tool.o $(UTILS)
 	$(CXX) $(LDFLAGS) -o $@ $+
 
-desword2$(EXEEXT): desword2.o util.o tool.o $(UTILS)
+desword2$(EXEEXT): desword2.o tool.o $(UTILS)
 	$(CXX) $(LDFLAGS) -o $@ $+
 
 degob$(EXEEXT): degob.o degob_script.o degob_script_v1.o degob_script_v2.o degob_script_v3.o \
 	degob_script_v4.o degob_script_v5.o degob_script_v6.o degob_script_bargon.o \
-	util.o tool.o $(UTILS)
+	tool.o $(UTILS)
 	$(CXX) $(LDFLAGS) -o $@ $+
 
-#encode_dxa$(EXEEXT): encode_dxa.o compress.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+ -lpng -lz -lvorbis -logg -lvorbisenc -lFLAC
+create_sjisfnt$(EXEEXT): create_sjisfnt.o $(UTILS)
+	$(CXX) $(LDFLAGS) `freetype-config --libs` -liconv -o $@ $+
 
-#extract_cine$(EXEEXT): extract_cine.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_agos$(EXEEXT): extract_agos.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_gob_stk$(EXEEXT): extract_gob_stk.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_kyra$(EXEEXT): extract_kyra.o kyra_pak.o kyra_ins.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_loom_tg16$(EXEEXT): extract_loom_tg16.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_mm_apple$(EXEEXT): extract_mm_apple.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_mm_c64$(EXEEXT): extract_mm_c64.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_mm_nes$(EXEEXT): extract_mm_nes.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_parallaction$(EXEEXT): extract_parallaction.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_scumm_mac$(EXEEXT): extract_scumm_mac.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_t7g_mac$(EXEEXT): extract_t7g_mac.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-#extract_zak_c64$(EXEEXT): extract_zak_c64.o util.o tool.o
-#	$(CXX) $(LDFLAGS) -o $@ $+
-
-create_sjisfnt$(EXEEXT): create_sjisfnt.o util.o
-	$(CXX) $(LDFLAGS) `freetype-config --libs` -o $@ $+
 tools_gui$(EXEEXT): gui/main.o gui/pages.o gui/gui_tools.o compress_agos.o compress_gob.o compress_kyra.o \
 	compress_queen.o compress_saga.o compress_scumm_bun.o compress_scumm_san.o compress_scumm_sou.o \
 	compress_sword1.o compress_sword2.o compress_touche.o compress_tucker.o compress_tinsel.o \
 	extract_agos.o extract_cine.o extract_gob_stk.o extract_kyra.o extract_loom_tg16.o extract_mm_apple.o \
 	extract_mm_c64.o extract_mm_nes.o extract_parallaction.o extract_scumm_mac.o extract_t7g_mac.o \
-	encode_dxa.o extract_zak_c64.o kyra_pak.o kyra_ins.o compress.o util.o tool.o tools.o $(UTILS)
+	encode_dxa.o extract_zak_c64.o kyra_pak.o kyra_ins.o compress.o tool.o tools.o $(UTILS)
 	$(CXX) $(LDFLAGS) -o $@ $+ `wx-config --libs` -lpng -lz -lvorbis -logg -lvorbisenc -lFLAC
 
 tools_cli$(EXEEXT): main_cli.o tools_cli.o compress_agos.o compress_gob.o compress_kyra.o \
@@ -209,10 +133,10 @@
 	compress_sword1.o compress_sword2.o compress_touche.o compress_tucker.o compress_tinsel.o \
 	extract_agos.o extract_cine.o extract_gob_stk.o extract_kyra.o extract_loom_tg16.o extract_mm_apple.o \
 	extract_mm_c64.o extract_mm_nes.o extract_parallaction.o extract_scumm_mac.o extract_t7g_mac.o \
-	encode_dxa.o extract_zak_c64.o kyra_pak.o kyra_ins.o compress.o util.o tool.o tools.o $(UTILS)
+	encode_dxa.o extract_zak_c64.o kyra_pak.o kyra_ins.o compress.o tool.o tools.o $(UTILS)
 	$(CXX) $(LDFLAGS) -o $@ $+ -lpng -lz -lvorbis -logg -lvorbisenc -lFLAC
 
-sword2_clue$(EXEEXT): sword2_clue.o util.o
+sword2_clue$(EXEEXT): sword2_clue.o
 	$(CXX) $(LDFLAGS) -o $@ $+ `pkg-config --libs gtk+-2.0`
 
 gui/main.o: gui/main.cpp gui/main.h gui/configuration.h gui/pages.h

Modified: tools/branches/gsoc2009-gui/common/file.cpp
===================================================================
--- tools/branches/gsoc2009-gui/common/file.cpp	2009-12-13 21:44:57 UTC (rev 46368)
+++ tools/branches/gsoc2009-gui/common/file.cpp	2009-12-13 22:06:45 UTC (rev 46369)
@@ -502,6 +502,10 @@
 	return ftell(_file);
 }
 
+int File::err() const {
+	return ferror(_file);
+}
+
 bool File::eos() const {
 	return feof(_file) != 0;
 }

Modified: tools/branches/gsoc2009-gui/common/file.h
===================================================================
--- tools/branches/gsoc2009-gui/common/file.h	2009-12-13 21:44:57 UTC (rev 46368)
+++ tools/branches/gsoc2009-gui/common/file.h	2009-12-13 22:06:45 UTC (rev 46369)
@@ -370,6 +370,8 @@
 	 */
 	int pos() const;
 
+	int err() const;
+
 	/**
 	 * True if there is nothing more to read from this file
 	 */

Copied: tools/branches/gsoc2009-gui/common/util.cpp (from rev 46368, tools/branches/gsoc2009-gui/util.cpp)
===================================================================
--- tools/branches/gsoc2009-gui/common/util.cpp	                        (rev 0)
+++ tools/branches/gsoc2009-gui/common/util.cpp	2009-12-13 22:06:45 UTC (rev 46369)
@@ -0,0 +1,77 @@
+/* ScummVM Tools
+ * Copyright (C) 2002-2009 The ScummVM project
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/util.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef _MSC_VER
+	#define	vsnprintf _vsnprintf
+#endif
+
+void error(const char *s, ...) {
+	char buf[1024];
+	va_list va;
+
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
+
+	fprintf(stderr, "ERROR: %s!\n", buf);
+
+	exit(1);
+}
+
+void warning(const char *s, ...) {
+	char buf[1024];
+	va_list va;
+
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
+
+	fprintf(stderr, "WARNING: %s!\n", buf);
+}
+
+void debug(int /*level*/, const char *s, ...) {
+	char buf[1024];
+	va_list va;
+
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
+
+	fprintf(stderr, "DEBUG: %s!\n", buf);
+}
+
+void notice(const char *s, ...) {
+	char buf[1024];
+	va_list va;
+
+	va_start(va, s);
+	vsnprintf(buf, 1024, s, va);
+	va_end(va);
+
+	fprintf(stdout, "%s\n", buf);
+}

Modified: tools/branches/gsoc2009-gui/create_sjisfnt.cpp
===================================================================
--- tools/branches/gsoc2009-gui/create_sjisfnt.cpp	2009-12-13 21:44:57 UTC (rev 46368)
+++ tools/branches/gsoc2009-gui/create_sjisfnt.cpp	2009-12-13 22:06:45 UTC (rev 46369)
@@ -23,16 +23,19 @@
  *
  */
 
+
+#include "common/endian.h"
+#include "common/file.h"
+#include "common/util.h"
+
 #include <iconv.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <vector>
 
 #include <ft2build.h>
 #include FT_FREETYPE_H
 
-#include "util.h"
-#include <cstdio>
-#include <cstdlib>
-
 namespace {
 
 int mapSJIStoChunk(uint8 fB, uint8 sB);
@@ -62,7 +65,7 @@
 
 int main(int argc, char *argv[]) {
 	if (argc < 2 || argc > 3) {
-		std::printf("Usage:\n\t%s <input ttf font> [outfile]\n", argv[0]);
+		printf("Usage:\n\t%s <input ttf font> [outfile]\n", argv[0]);
 		return -1;
 	}
 
@@ -194,28 +197,24 @@
 		delete[] i->plainData;
 	glyphs.clear();
 
-	FILE *sjisFont = std::fopen(out, "wb");
-	if (sjisFont) {
+	File sjisFont(out, "wb");
+	if (sjisFont.isOpen()) {
 		// Write our magic bytes
-		writeUint32BE(sjisFont, MKID_BE('SCVM'));
-		writeUint32BE(sjisFont, MKID_BE('SJIS'));
+		sjisFont.writeUint32BE(MKID_BE('SCVM'));
+		sjisFont.writeUint32BE(MKID_BE('SJIS'));
 
 		// Write version
-		writeUint32BE(sjisFont, 0x00000001);
+		sjisFont.writeUint32BE(0x00000001);
 
 		// Write character count
-		writeUint16BE(sjisFont, chars);
+		sjisFont.writeUint16BE(chars);
 
-		std::fwrite(sjisFontData, 1, sjisDataSize, sjisFont);
-		std::fflush(sjisFont);
+		sjisFont.write(sjisFontData, 1, sjisDataSize);
 
-		if (std::ferror(sjisFont)) {
+		if (sjisFont.err()) {
 			delete[] sjisFontData;
-			std::fclose(sjisFont);
 			error("Error while writing to font file: '%s'", out);
 		}
-
-		std::fclose(sjisFont);
 	} else {
 		delete[] sjisFontData;
 		error("Could not open file '%s' for writing", out);

Deleted: tools/branches/gsoc2009-gui/util.cpp
===================================================================
--- tools/branches/gsoc2009-gui/util.cpp	2009-12-13 21:44:57 UTC (rev 46368)
+++ tools/branches/gsoc2009-gui/util.cpp	2009-12-13 22:06:45 UTC (rev 46369)
@@ -1,75 +0,0 @@
-/* Scumm Tools
- * Copyright (C) 2003-2006  The ScummVM 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "stdio.h"
-#include "util.h"
-#include <stdarg.h>
-
-#ifdef _MSC_VER
-	#define	vsnprintf _vsnprintf
-#endif
-
-void error(const char *s, ...) {
-	char buf[1024];
-	va_list va;
-
-	va_start(va, s);
-	vsnprintf(buf, 1024, s, va);
-	va_end(va);
-
-	fprintf(stderr, "ERROR: %s!\n", buf);
-
-	exit(1);
-}
-
-void warning(const char *s, ...) {
-	char buf[1024];
-	va_list va;
-
-	va_start(va, s);
-	vsnprintf(buf, 1024, s, va);
-	va_end(va);
-
-	fprintf(stderr, "WARNING: %s!\n", buf);
-}
-
-void debug(int /*level*/, const char *s, ...) {
-	char buf[1024];
-	va_list va;
-
-	va_start(va, s);
-	vsnprintf(buf, 1024, s, va);
-	va_end(va);
-
-	fprintf(stderr, "DEBUG: %s!\n", buf);
-}
-
-void notice(const char *s, ...) {
-	char buf[1024];
-	va_list va;
-
-	va_start(va, s);
-	vsnprintf(buf, 1024, s, va);
-	va_end(va);
-
-	fprintf(stdout, "%s\n", buf);
-}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list