[Scummvm-cvs-logs] SF.net SVN: scummvm: [29556] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Nov 18 14:22:38 CET 2007


Revision: 29556
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29556&view=rev
Author:   peres001
Date:     2007-11-18 05:22:38 -0800 (Sun, 18 Nov 2007)

Log Message:
-----------
Cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/disk_br.cpp
    scummvm/trunk/engines/parallaction/disk_ns.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/font.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/objects.cpp
    scummvm/trunk/engines/parallaction/objects.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/parser_ns.cpp
    scummvm/trunk/engines/parallaction/walk.h

Modified: scummvm/trunk/engines/parallaction/disk_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_br.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/disk_br.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -42,8 +42,7 @@
 	}
 
 	~Sprite() {
-		if (packedData)
-			free(packedData);
+		free(packedData);
 	}
 };
 

Modified: scummvm/trunk/engines/parallaction/disk_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_ns.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/disk_ns.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -933,8 +933,7 @@
 		}
 	}
 
-	if (tempBuffer)
-		free(tempBuffer);
+	free(tempBuffer);
 
 }
 

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -241,9 +241,7 @@
 
 DECLARE_COMMAND_OPCODE(get) {
 	_cmdRunCtxt.cmd->u._zone->_flags &= ~kFlagsFixed;
-	if (!runZone(_cmdRunCtxt.cmd->u._zone)) {
-		runCommands(_cmdRunCtxt.cmd->u._zone->_commands);
-	}
+	runZone(_cmdRunCtxt.cmd->u._zone);
 }
 
 
@@ -443,6 +441,9 @@
 
 
 void Parallaction::runCommands(CommandList& list, Zone *z) {
+	if (list.size() == 0)
+		return;
+
 	debugC(3, kDebugExec, "runCommands");
 
 	CommandList::iterator it = list.begin();
@@ -598,6 +599,8 @@
 
 	debugC(3, kDebugExec, "runZone completed");
 
+	runCommands(z->_commands, z);
+
 	return 0;
 }
 

Modified: scummvm/trunk/engines/parallaction/font.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/font.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/font.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -202,8 +202,7 @@
 	}
 
 	~DosFont() {
-		if (_data)
-			delete _data;
+		delete _data;
 	}
 
 	void setData() {
@@ -455,8 +454,7 @@
 }
 
 AmigaFont::~AmigaFont() {
-	if (_data)
-		free(_data);
+	free(_data);
 }
 
 uint16 AmigaFont::getSpacing(byte c) {

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/graphics.h	2007-11-18 13:22:38 UTC (rev 29556)
@@ -102,7 +102,6 @@
 	}
 
 	~Cnv() {
-		if (_count == 0 || _data == NULL) return;
 		free(_data);
 	}
 
@@ -159,8 +158,7 @@
 	}
 
 	void free() {
-		if (data)
-			::free(data);
+		::free(data);
 		data = 0;
 		w = 0;
 		h = 0;

Modified: scummvm/trunk/engines/parallaction/objects.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/objects.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/objects.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -51,14 +51,9 @@
 }
 
 Animation::~Animation() {
-	if (_program)
-		delete _program;
-
-	if (_scriptName)
-		free(_scriptName);
-
-	if (_cnv)
-		delete _cnv;
+	delete _program;
+	free(_scriptName);
+	delete _cnv;
 }
 
 uint16 Animation::width() const {
@@ -142,8 +137,7 @@
 	case kZoneDoor:
 		free(u.door->_location);
 		free(u.door->_background);
-		if (u.door->_cnv)
-			delete u.door->_cnv;
+		delete u.door->_cnv;
 		delete u.door;
 		break;
 
@@ -207,8 +201,7 @@
 
 void Label::free() {
 	_cnv.free();
-	if (_text)
-		::free(_text);
+	::free(_text);
 	_text = 0;
 
 	resetPosition();
@@ -241,8 +234,7 @@
 }
 
 Answer::~Answer() {
-	if (_text)
-		free(_text);
+	free(_text);
 }
 
 Question::Question() {
@@ -256,8 +248,9 @@
 
 Question::~Question() {
 
-	for (uint32 i = 0; i < NUM_ANSWERS; i++)
-		if (_answers[i]) delete _answers[i];
+	for (uint32 i = 0; i < NUM_ANSWERS; i++) {
+		delete _answers[i];
+	}
 
 	free(_text);
 }
@@ -267,10 +260,8 @@
 }
 
 Instruction::~Instruction() {
-	if (_text)
-		free(_text);
-	if (_text2)
-		free(_text2);
+	free(_text);
+	free(_text2);
 }
 
 int16 ScriptVar::getRValue() {

Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/objects.h	2007-11-18 13:22:38 UTC (rev 29556)
@@ -119,10 +119,8 @@
 	}
 
 	~CommandData() {
-		if (_string)
-			free(_string);
-		if (_string2)
-			free(_string2);
+		free(_string);
+		free(_string2);
 	}
 };
 

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -278,8 +278,7 @@
 		if (_activeZone) {
 			Zone *z = _activeZone;	// speak Zone or sound
 			_activeZone = NULL;
-			if (runZone( z ) == 0)
-				runCommands( z->_commands, z );
+			runZone(z);
 		}
 
 		if (_engineFlags & kEngineChangeLocation) {
@@ -332,7 +331,6 @@
 
 
 void Parallaction::processInput(InputData *data) {
-	Zone *z;
 
 	switch (data->_event) {
 	case kEvEnterZone:
@@ -350,10 +348,7 @@
 		_procCurrentHoverItem = -1;
 		_hoverZone = NULL;
 		pauseJobs();
-		z = data->_zone;
-		if (runZone(z) == 0) {
-			runCommands( z->_commands, z );
-		}
+		runZone(data->_zone);
 		resumeJobs();
 		break;
 
@@ -421,7 +416,7 @@
 
 void Parallaction::updateInput() {
 
-	_keyDown = readInput();
+	int16 keyDown = readInput();
 
 	debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
 		!_mouseHidden,
@@ -438,13 +433,13 @@
 		return;
 	}
 
-	if (_keyDown == kEvQuitGame) {
+	if (keyDown == kEvQuitGame) {
 		_input._event = kEvQuitGame;
 	} else
-	if (_keyDown == kEvSaveGame) {
+	if (keyDown == kEvSaveGame) {
 		_input._event = kEvSaveGame;
 	} else
-	if (_keyDown == kEvLoadGame) {
+	if (keyDown == kEvLoadGame) {
 		_input._event = kEvLoadGame;
 	} else {
 		_input._mousePos = _mousePos;
@@ -618,9 +613,8 @@
 void Parallaction::freeCharacter() {
 	debugC(1, kDebugExec, "freeCharacter()");
 
-	if (_objectsNames)
-		delete _objectsNames;
-	_objectsNames = NULL;
+	delete _objectsNames;
+	_objectsNames = 0;
 
 	_char.free();
 
@@ -803,10 +797,8 @@
 	freeZones();
 	freeAnimations();
 
-	if (_location._comment) {
-		free(_location._comment);
-	}
-	_location._comment = NULL;
+	free(_location._comment);
+	_location._comment = 0;
 
 	_location._commands.clear();
 	_location._aCommands.clear();
@@ -881,6 +873,10 @@
 void Parallaction::doLocationEnterTransition() {
 	debugC(2, kDebugExec, "doLocationEnterTransition");
 
+	if (!_location._comment) {
+		return;
+	}
+
     if (_localFlags[_currentLocationIndex] & kFlagsVisited) {
         debugC(2, kDebugExec, "skipping location transition");
         return; // visited
@@ -996,14 +992,10 @@
 
 void Character::free() {
 
-	if (_ani._cnv)
-		delete _ani._cnv;
-	if (_talk)
-		delete _talk;
-	if (_head)
-		delete _head;
-	if (_objs)
-		delete _objs;
+	delete _ani._cnv;
+	delete _talk;
+	delete _head;
+	delete _objs;
 
 	_ani._cnv = NULL;
 	_talk = NULL;

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-11-18 13:22:38 UTC (rev 29556)
@@ -513,8 +513,6 @@
 	uint32		_baseTime;
 	char		_characterName1[50]; 	// only used in changeCharacter
 
-	int16 _keyDown;
-
 	JobList		_jobs;
 
 	Common::String      _saveFileName;

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -331,6 +331,9 @@
 	delete _objectsNames;
 	delete _countersNames;
 
+	_globalTable = 0;
+	_objectsNames = 0;
+	_countersNames = 0;
 }
 
 void Parallaction_br::startPart() {

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -46,8 +46,7 @@
 }
 
 LocationName::~LocationName() {
-	if (_buf)
-		free(_buf);
+	free(_buf);
 }
 
 
@@ -70,8 +69,7 @@
 */
 void LocationName::bind(const char *s) {
 
-	if (_buf)
-		free(_buf);
+	free(_buf);
 
 	_buf = strdup(s);
 	_hasSlide = false;
@@ -165,7 +163,6 @@
 	delete _labelFont;
 	delete _menuFont;
 
-	return;
 }
 
 void Parallaction_ns::renderLabel(Graphics::Surface *cnv, char *text) {
@@ -387,17 +384,13 @@
 		_gfx->swapBuffers();
 	}
 
-	if (_location._comment) {
-		doLocationEnterTransition();
-	}
+	doLocationEnterTransition();
 
 	runJobs();
 	_gfx->swapBuffers();
 
 	_gfx->setPalette(_gfx->_palette);
-	if (_location._aCommands.size() > 0) {
-		runCommands(_location._aCommands);
-	}
+	runCommands(_location._aCommands);
 
 	if (_hasLocationSound)
 		_soundMan->playSfx(_locationSound, 0, true);

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2007-11-18 13:22:38 UTC (rev 29556)
@@ -529,8 +529,7 @@
 
 	createCommand(_lookup);
 
-	_locParseCtxt.cmd->u._string = (char*)malloc(strlen(_tokens[_locParseCtxt.nextToken])+1);
-	strcpy(_locParseCtxt.cmd->u._string, _tokens[_locParseCtxt.nextToken]);
+	_locParseCtxt.cmd->u._string = strdup(_tokens[_locParseCtxt.nextToken]);
 	_locParseCtxt.nextToken++;
 
 	parseCommandFlags();
@@ -777,6 +776,7 @@
 
 			int16 index = forwards.lookup(answer->_following._name);
 			free(answer->_following._name);
+			answer->_following._name = 0;
 
 			if (index == Table::notFound)
 				answer->_following._question = 0;

Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h	2007-11-18 10:08:43 UTC (rev 29555)
+++ scummvm/trunk/engines/parallaction/walk.h	2007-11-18 13:22:38 UTC (rev 29556)
@@ -72,8 +72,7 @@
 	}
 
 	void free() {
-		if (data)
-			::free(data);
+		::free(data);
 		data = 0;
 		w = 0;
 		h = 0;


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