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

Remere at users.sourceforge.net Remere at users.sourceforge.net
Fri Aug 7 08:43:12 CEST 2009


Revision: 43092
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43092&view=rev
Author:   Remere
Date:     2009-08-07 06:43:12 +0000 (Fri, 07 Aug 2009)

Log Message:
-----------
*Compression is now the default choice (instead of extraction)
*Fixed issue in compress_agos which would make it crash if you selected an invalid input file.

Modified Paths:
--------------
    tools/branches/gsoc2009-gui/compress_agos.cpp
    tools/branches/gsoc2009-gui/compress_agos.h
    tools/branches/gsoc2009-gui/gui/configuration.h
    tools/branches/gsoc2009-gui/gui/pages.cpp

Modified: tools/branches/gsoc2009-gui/compress_agos.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_agos.cpp	2009-08-07 01:17:57 UTC (rev 43091)
+++ tools/branches/gsoc2009-gui/compress_agos.cpp	2009-08-07 06:43:12 UTC (rev 43092)
@@ -67,11 +67,9 @@
 }
 
 
-int CompressAgos::get_offsets(uint32 filenums[], uint32 offsets[]) {
-	int i;
-	char buf[8];
-
-	for (i = 0;; i++) {
+int CompressAgos::get_offsets(size_t maxcount, uint32 filenums[], uint32 offsets[]) {
+	for (size_t i = 0; i < maxcount; i++) {
+		char buf[8];
 		_input.read(buf, 1, 8);
 		if (!memcmp(buf, "Creative", 8) || !memcmp(buf, "RIFF", 4)) {
 			return i;
@@ -80,18 +78,22 @@
 
 		offsets[i] = _input.readUint32LE();
 	}
+
+	// We exceeded size of array
+	throw ToolException("Too many indexes read, file does not appear to be of the correct format.");
 }
 
-int CompressAgos::get_offsets_mac(uint32 filenums[], uint32 offsets[]) {
-	int i, size;
-	size = _input.size();
+int CompressAgos::get_offsets_mac(size_t maxcount, uint32 filenums[], uint32 offsets[]) {
+	int size = _input.size();
 
-	for (i = 1; i <= size / 6; i++) {
+	for (int i = 1; i <= size / 6; i++) {
+		if ((size_t)i >= maxcount)
+			throw ToolException("Too many indexes read, file does not appear to be of the correct format.");
 		filenums[i] = _input.readUint16BE();
 		offsets[i] = _input.readUint32BE();
 	}
 
-	return(size/6);
+	return (size/6);
 }
 
 
@@ -140,7 +142,7 @@
 
 	_output_snd.open(TEMP_DAT, "wb");
 
-	num = get_offsets(filenums, offsets);
+	num = get_offsets(32768, filenums, offsets);
 	if (!num) {
 		error("This does not seem to be a valid file");
 	}
@@ -176,7 +178,7 @@
 
 	_output_snd.open(TEMP_DAT, "wb");
 
-	num = get_offsets_mac(filenums, offsets);
+	num = get_offsets_mac(32768, filenums, offsets);
 	if (!num) {
 		error("This does not seem to be a valid file");
 	}

Modified: tools/branches/gsoc2009-gui/compress_agos.h
===================================================================
--- tools/branches/gsoc2009-gui/compress_agos.h	2009-08-07 01:17:57 UTC (rev 43091)
+++ tools/branches/gsoc2009-gui/compress_agos.h	2009-08-07 06:43:12 UTC (rev 43092)
@@ -39,8 +39,8 @@
 	File _input, _output_idx, _output_snd;
 
 	void end();
-	int get_offsets(uint32 filenums[], uint32 offsets[]);
-	int get_offsets_mac(uint32 filenums[], uint32 offsets[]);
+	int get_offsets(size_t maxcount, uint32 filenums[], uint32 offsets[]);
+	int get_offsets_mac(size_t maxcount, uint32 filenums[], uint32 offsets[]);
 	uint32 get_sound(uint32 offset);
 	void convert_pc(Filename* inputPath);
 	void convert_mac(Filename *inputPath);

Modified: tools/branches/gsoc2009-gui/gui/configuration.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/configuration.h	2009-08-07 01:17:57 UTC (rev 43091)
+++ tools/branches/gsoc2009-gui/gui/configuration.h	2009-08-07 06:43:12 UTC (rev 43092)
@@ -94,7 +94,7 @@
 	// Default values for all the settings
 
 	advanced = false;
-	compressing = false;
+	compressing = true;
 
 	selectedTool = NULL;
 

Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp	2009-08-07 01:17:57 UTC (rev 43091)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp	2009-08-07 06:43:12 UTC (rev 43092)
@@ -112,8 +112,8 @@
 		wxT("Welcome to the ScummVM extraction and compression utility.")));
 	
 	wxString choices[] = {
+		wxT("Compress audio files"),
 		wxT("Extract from game data files"),
-		wxT("Compress audio files"),
 		wxT("Choose tool to use (advanced)")
 	};
 
@@ -130,9 +130,9 @@
 	if (config.advanced)
 		options->SetSelection(2);
 	else if (config.compressing)
+		options->SetSelection(0);
+	else
 		options->SetSelection(1);
-	else
-		options->SetSelection(0);
 
 	return panel;
 }


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