diff options
| author | Strangerke | 2012-12-31 01:09:06 +0100 | 
|---|---|---|
| committer | Strangerke | 2012-12-31 01:09:06 +0100 | 
| commit | a57e859d14de78bc06e9b47804d9c2b59acb830c (patch) | |
| tree | c5ee8540bef212a3f63c1102de1597d72d28de76 | |
| parent | f59f7dafc3f6a5bc9210acf87a9355fadba6510a (diff) | |
| download | scummvm-rg350-a57e859d14de78bc06e9b47804d9c2b59acb830c.tar.gz scummvm-rg350-a57e859d14de78bc06e9b47804d9c2b59acb830c.tar.bz2 scummvm-rg350-a57e859d14de78bc06e9b47804d9c2b59acb830c.zip | |
HOPKINS: Some more refactoring
| -rw-r--r-- | engines/hopkins/lines.cpp | 124 | ||||
| -rw-r--r-- | engines/hopkins/lines.h | 1 | ||||
| -rw-r--r-- | engines/hopkins/objects.cpp | 167 | ||||
| -rw-r--r-- | engines/hopkins/objects.h | 2 | ||||
| -rw-r--r-- | engines/hopkins/script.cpp | 4 | 
5 files changed, 94 insertions, 204 deletions
| diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp index 4d10fbea6d..29657d9505 100644 --- a/engines/hopkins/lines.cpp +++ b/engines/hopkins/lines.cpp @@ -425,108 +425,8 @@ LABEL_28:  	return true;  } -int LinesManager::Scolision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6) { -	int16 *v7; -	int16 *v13; -	int result; - -	int v24 = a5; -	int v6 = a5; - -	if (a5 >= a6 + 1) { -LABEL_47: -		result = 0; -	} else { -		int v22 = a1 + 10; -		int v21 = a1 - 10; -		int v20 = a2 + 10; -		int v19 = a2 - 10; -		int v11, v18; -		for (;;) { -			v7 = Ligne[v6].lineData; - -			if (v7 != (int16 *)g_PTRNUL) { -				int v23 = 1; -				int v8 = 2 * Ligne[v6].field0; -				int v9 = v7[0]; -				int v15 = v7[1]; -				int v10 = v7[v8 - 2]; -				int v17 = v7[v8 - 1]; -				if (v7[0] >= v10) -					goto LABEL_50; -				if (v22 < v9 || v21 > v10) -					v23 = 0; -				if (v9 >= v10) { -LABEL_50: -					if (v21 > v9 || v22 < v10) -						v23 = 0; -				} -				if (v15 >= v17) -					goto LABEL_51; -				if (v20 < v15 || v19 > v17) -					v23 = 0; -				if (v15 >= v17) { -LABEL_51: -					if (v19 > v15 || v20 < v17) -						v23 = 0; -				} -				if (v23 == 1) { -					v11 = 0; -					v18 = Ligne[v24].field0; -					if (v18 > 0) -						break; -				} -			} -LABEL_46: -			++v24; -			v6 = v24; -			if (v24 >= a6 + 1) -				goto LABEL_47; -		} -		for (;;) { -			int v12 = v7[0]; -			v13 = v7 + 1; -			int v16 = v13[0]; -			v7 = v13 + 1; -			if (a1 == v12 -			        || v12 == a1 + 1 -			        || v12 == a1 + 2 -			        || v12 == a1 + 3 -			        || v12 == a1 + 4 -			        || v12 == a1 + 5 -			        || v12 == a1 + 6 -			        || v12 == a1 + 7 -			        || v12 == a1 + 8 -			        || v12 == a1 + 9 -			        || a1 + 10 == v12) { -				if (v16 == a2 -				        || v16 == a2 + 1 -				        || v16 == a2 + 2 -				        || v16 == a2 + 3 -				        || v16 == a2 + 4 -				        || v16 == a2 + 5 -				        || v16 == a2 + 6 -				        || v16 == a2 + 7 -				        || v16 == a2 + 8 -				        || v16 == a2 + 9 -				        || a2 + 10 == v16) -					break; -			} -			++v11; -			if (v18 <= v11) -				goto LABEL_46; -		} -		*a3 = v11; -		*a4 = v24; -		result = 1; -	} -	return result; -} -  // Init route  void LinesManager::INIPARCOURS() { -	int v0; -	int v1;  	int v2;  	int16 *v3;  	int v4; @@ -536,14 +436,12 @@ void LinesManager::INIPARCOURS() {  	int v11;  	int v12;  	int v13; -	int v14; -	int v15; -	v15 = Ligne[0].lineData[0]; -	v14 = Ligne[0].lineData[1]; +	int v15 = Ligne[0].lineData[0]; +	int v14 = Ligne[0].lineData[1]; -	v0 = 1; -	v1 = 0; +	int v0 = 1; +	bool v1 = false;  	do {  		v2 = Ligne[v0].field0;  		v3 = Ligne[v0].lineData; @@ -552,20 +450,18 @@ void LinesManager::INIPARCOURS() {  		v5 = v3[2 * v2 - 1];  		if (_vm->_graphicsManager.max_x == v4 || _vm->_graphicsManager.max_y == v5 || _vm->_graphicsManager.min_x == v4  				|| _vm->_graphicsManager.min_y == v5) -			v1 = 1; +			v1 = true;  		if (v15 == v4 && v14 == v5) -			v1 = 1; -		if (v0 == 400) { -//			v6 = v1; +			v1 = true; +		if (v0 == 400)  			error("ERROR - LAST LINE NOT FOUND"); -//			v1 = v6; -		} +  		v7 = Ligne[v0 + 1].lineData;  		if (v7[0] != v4 && v7[1] != v5) -			v1 = 1; +			v1 = true;  		if (!v1)  			++v0; -	} while (v1 != 1); +	} while (!v1);  	_vm->_objectsManager.DERLIGNE = v0;  	v13 = _vm->_globals.Max_Ligne_Long; diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h index 92b465fd96..ab32a28f8a 100644 --- a/engines/hopkins/lines.h +++ b/engines/hopkins/lines.h @@ -79,7 +79,6 @@ public:  	void RETIRE_LIGNE(int idx);  	void AJOUTE_LIGNE(int idx, int a2, int a3, int a4, int a5, int a6, int a7);  	bool colision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6); -	int Scolision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6);  	void INIPARCOURS();  	int CONTOURNE1(int a1, int a2, int a3, int a4, int a5, int16 *a6, int a7, int a8, int a9);  	int CONTOURNE(int a1, int a2, int a3, int a4, int a5, int16 *a6, int a7); diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 85e5784dc5..5c2a27788b 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -75,7 +75,7 @@ ObjectsManager::ObjectsManager() {  	A_DEPA = 0;  	MAX_DEPA = 0;  	MAX_DEPA1 = 0; -	CH_TETE = 0; +	CH_TETE = false;  	T_RECTIF = 0;  	_disableFl = false;  	_twoCharactersFl = false; @@ -109,9 +109,7 @@ void ObjectsManager::changeObject(int objIndex) {  }  byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) { -	byte *dataP; - -	dataP = NULL; +	byte *dataP = NULL;  	int val1 = _vm->_globals.ObjetW[objIndex].field0;  	int val2 = _vm->_globals.ObjetW[objIndex]._idx; @@ -2186,10 +2184,8 @@ void ObjectsManager::CHARGE_OBSTACLE(const Common::String &file) {   * Load Zone   */  void ObjectsManager::loadZone(const Common::String &file) { -	int v3; +	int bobZoneIdx;  	int v4; -	int v5; -	int v6;  	byte *v9;  	int v10;  	byte *v13; @@ -2197,22 +2193,22 @@ void ObjectsManager::loadZone(const Common::String &file) {  	int16 v18;  	byte *ptr; -	for (int v1 = 1; v1 <= 100; v1++) { -		_vm->_globals.ZONEP[v1]._destX = 0; -		_vm->_globals.ZONEP[v1]._destY = 0; -		_vm->_globals.ZONEP[v1].field4 = 0; -		_vm->_globals.ZONEP[v1].field6 = 0; -		_vm->_globals.ZONEP[v1].field7 = 0; -		_vm->_globals.ZONEP[v1].field8 = 0; -		_vm->_globals.ZONEP[v1].field9 = 0; -		_vm->_globals.ZONEP[v1].fieldA = 0; -		_vm->_globals.ZONEP[v1].fieldB = 0; -		_vm->_globals.ZONEP[v1].fieldC = 0; -		_vm->_globals.ZONEP[v1].fieldD = 0; -		_vm->_globals.ZONEP[v1].fieldE = 0; -		_vm->_globals.ZONEP[v1].fieldF = 0; -		_vm->_globals.ZONEP[v1].field12 = 0; -		_vm->_globals.ZONEP[v1].field10 = 0; +	for (int i = 1; i <= 100; i++) { +		_vm->_globals.ZONEP[i]._destX = 0; +		_vm->_globals.ZONEP[i]._destY = 0; +		_vm->_globals.ZONEP[i].field4 = 0; +		_vm->_globals.ZONEP[i].field6 = 0; +		_vm->_globals.ZONEP[i].field7 = 0; +		_vm->_globals.ZONEP[i].field8 = 0; +		_vm->_globals.ZONEP[i].field9 = 0; +		_vm->_globals.ZONEP[i].fieldA = 0; +		_vm->_globals.ZONEP[i].fieldB = 0; +		_vm->_globals.ZONEP[i].fieldC = 0; +		_vm->_globals.ZONEP[i].fieldD = 0; +		_vm->_globals.ZONEP[i].fieldE = 0; +		_vm->_globals.ZONEP[i].fieldF = 0; +		_vm->_globals.ZONEP[i].field12 = 0; +		_vm->_globals.ZONEP[i].field10 = 0;  	}  	_vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, file); @@ -2226,46 +2222,43 @@ void ObjectsManager::loadZone(const Common::String &file) {  	v18 = 0;  	v17 = 0;  	do { -		v3 = (int16)READ_LE_UINT16((uint16 *)ptr + v4); -		if (v3 != -1) { -			v5 = v3; -			v6 = v3; +		bobZoneIdx = (int16)READ_LE_UINT16((uint16 *)ptr + v4); +		if (bobZoneIdx != -1) {  			_vm->_linesManager.addZoneLine(  			    v18, -			    READ_LE_UINT16((uint16 *)ptr + v4 + 1), +			    READ_LE_UINT16((uint16 *)ptr + v4 + 1), // CHECKME: Shouldn't it be a byte?  			    READ_LE_UINT16((uint16 *)ptr + v4 + 2),  			    READ_LE_UINT16((uint16 *)ptr + v4 + 3),  			    READ_LE_UINT16((uint16 *)ptr + v4 + 4), -			    v3); -			_vm->_globals.ZONEP[v5].field10 = 1; -			v3 = v6; +			    bobZoneIdx); +			_vm->_globals.ZONEP[bobZoneIdx].field10 = 1;  		}  		v4 += 5;  		++v18;  		++v17; -	} while (v3 != -1); +	} while (bobZoneIdx != -1); -	for (int v7 = 1; v7 <= 100; v7++) { -		// CHECKME: Shouldn't it be READ_LE_UINT8? -		_vm->_globals.ZONEP[v7]._destX = (int16)READ_LE_UINT16((uint16 *)ptr + v4); -		_vm->_globals.ZONEP[v7]._destY = (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 1); -		_vm->_globals.ZONEP[v7].field4 = (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 2); +	for (int i = 1; i <= 100; i++) { +		 // CHECKME: Shouldn't it be a byte? +		_vm->_globals.ZONEP[i]._destX = (int16)READ_LE_UINT16((uint16 *)ptr + v4); +		_vm->_globals.ZONEP[i]._destY = (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 1); +		_vm->_globals.ZONEP[i].field4 = (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 2);  		v4 += 3;  	}  	v9 = (ptr + 10 * v17 + 606);  	v10 = 0; -	for (int v11 = 1; v11 <= 100; v11++) { -		_vm->_globals.ZONEP[v11].field6 = v9[v10]; -		_vm->_globals.ZONEP[v11].field7 = v9[v10 + 1]; -		_vm->_globals.ZONEP[v11].field8 = v9[v10 + 2]; -		_vm->_globals.ZONEP[v11].field9 = v9[v10 + 3]; -		_vm->_globals.ZONEP[v11].fieldA = v9[v10 + 4]; -		_vm->_globals.ZONEP[v11].fieldB = v9[v10 + 5]; -		_vm->_globals.ZONEP[v11].fieldC = v9[v10 + 6]; -		_vm->_globals.ZONEP[v11].fieldD = v9[v10 + 7]; -		_vm->_globals.ZONEP[v11].fieldE = v9[v10 + 8]; -		_vm->_globals.ZONEP[v11].fieldF = v9[v10 + 9]; +	for (int i = 1; i <= 100; i++) { +		_vm->_globals.ZONEP[i].field6 = v9[v10]; +		_vm->_globals.ZONEP[i].field7 = v9[v10 + 1]; +		_vm->_globals.ZONEP[i].field8 = v9[v10 + 2]; +		_vm->_globals.ZONEP[i].field9 = v9[v10 + 3]; +		_vm->_globals.ZONEP[i].fieldA = v9[v10 + 4]; +		_vm->_globals.ZONEP[i].fieldB = v9[v10 + 5]; +		_vm->_globals.ZONEP[i].fieldC = v9[v10 + 6]; +		_vm->_globals.ZONEP[i].fieldD = v9[v10 + 7]; +		_vm->_globals.ZONEP[i].fieldE = v9[v10 + 8]; +		_vm->_globals.ZONEP[i].fieldF = v9[v10 + 9];  		v10 += 10;  	} @@ -2814,7 +2807,7 @@ void ObjectsManager::CLEAR_ECRAN() {  void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCharacter newCharacter) {  	CharacterLocation *loc; -	CH_TETE = 1; +	CH_TETE = true;  	_vm->_graphicsManager.SCOPY(_vm->_graphicsManager._vesaScreen, 532, 25, 65, 40, _vm->_graphicsManager._vesaBuffer, 532, 25);  	_vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 597, 65);  	_vm->_globals.NOT_VERIF = 1; @@ -2822,7 +2815,7 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha  	if (oldCharacter == CHARACTER_SAMANTHA && newCharacter == CHARACTER_HOPKINS  		&& _vm->_globals._saveData->_realHopkins._location == _vm->_globals._screenId) { -		CH_TETE = 0; +		CH_TETE = false;  		loc = &_vm->_globals._saveData->_samantha;  		loc->_pos.x = getSpriteX(0);  		loc->_pos.y = getSpriteY(0); @@ -2849,7 +2842,7 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha  		_vm->_globals.loadCharacterData();  	} else if (oldCharacter == CHARACTER_HOPKINS && newCharacter == CHARACTER_SAMANTHA  			&& _vm->_globals._saveData->_samantha._location == _vm->_globals._screenId) { -		CH_TETE = 0; +		CH_TETE = false;  		loc = &_vm->_globals._saveData->_realHopkins;  		loc->_pos.x = getSpriteX(0);  		loc->_pos.y = getSpriteY(0); @@ -3847,36 +3840,37 @@ void ObjectsManager::OPTI_OBJET() {  	Common::String file;  	int v0 = 1;  	int v5; -	int v7;  	file = "OBJET1.ini";  	data = _vm->_fileManager.searchCat(file, 1);  	if (data == g_PTRNUL) {  		_vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, file);  		data = _vm->_fileManager.loadFile(_vm->_globals._curFilename); +		if (data == g_PTRNUL) +			error("INI file %s not found", file.c_str());  	} -	if ((data == g_PTRNUL) || *data != 'I' || *(data + 1) != 'N' || *(data + 2) != 'I') { -		error("Not an INI file"); -	} else { -		v7 = 0; -		do { -			v5 = _vm->_scriptManager.handleOpcode(data + 20 * v0); -			if (_vm->shouldQuit()) -				return; +	if (data[0] != 'I' || data[1] != 'N' || data[2] != 'I') +		error("File %s is not an INI file"); + +	bool v7 = false; +	do { +		v5 = _vm->_scriptManager.handleOpcode(data + 20 * v0); +		if (_vm->shouldQuit()) +			return; + +		if (v5 == 2) +			v0 = _vm->_scriptManager.handleGoto(data + 20 * v0); +		if (v5 == 3) +			v0 = _vm->_scriptManager.handleIf(data, v0); +		if (v0 == -1) +			error("defective IFF function"); +		if (v5 == 1 || v5 == 4) +			++v0; +		if (!v5 || v5 == 5) +			v7 = true; +	} while (!v7); -			if (v5 == 2) -				v0 = _vm->_scriptManager.handleGoto(data + 20 * v0); -			if (v5 == 3) -				v0 = _vm->_scriptManager.handleIf(data, v0); -			if (v0 == -1) -				error("defective IFF function"); -			if (v5 == 1 || v5 == 4) -				++v0; -			if (!v5 || v5 == 5) -				v7 = 1; -		} while (v7 != 1); -	}  	_vm->_globals.freeMemory(data);  } @@ -3959,7 +3953,7 @@ void ObjectsManager::SPECIAL_JEU() {  					v2 = v2 + 614396;  					*v2 = *v3;  					v2 = v2 + 2; -					*v2 = *(v3 + 2); +					*v2 = v3[2];  					_vm->_graphicsManager.no_scroll = 0;  					_vm->_graphicsManager.DD_VBL(); @@ -4010,15 +4004,15 @@ void ObjectsManager::BOB_VIVANT(int idx) {  	int v3;  	int v4; -	v1 = 5 * idx; -	v2 = (int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + 2 * v1); -	v3 = (int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + 2 * v1 + 2); -	v4 = *(_vm->_talkManager._characterAnim + 2 * v1 + 8); -	if ((int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + 2 * v1 + 4)) { +	v1 = 10 * idx; +	v2 = (int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + v1); +	v3 = (int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + v1 + 2); +	v4 = _vm->_talkManager._characterAnim[v1 + 8]; +	if ((int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + v1 + 4)) {  		if (!_vm->_globals.NO_OFFSET)  			_vm->_graphicsManager.fastDisplay(_vm->_talkManager._characterSprite,  				_vm->_graphicsManager.ofscroll + v2, v3, -				*(_vm->_talkManager._characterAnim + 2 * v1 + 8)); +				_vm->_talkManager._characterAnim[v1 + 8]);  		if (_vm->_globals.NO_OFFSET)  			_vm->_graphicsManager.fastDisplay(_vm->_talkManager._characterSprite, v2, v3, v4);  	} @@ -4286,13 +4280,14 @@ int ObjectsManager::BOBPOSI(int idx) {   * Set Hopkins animation   */  void ObjectsManager::setBobAnimation(int idx) { -	if (_vm->_globals._bob[idx]._disabledAnimationFl) { -		_vm->_globals._bob[idx]._disabledAnimationFl = false; -		_vm->_globals._bob[idx].field10 = 5; -		_vm->_globals._bob[idx]._frameIndex = 250; -		_vm->_globals._bob[idx].field12 = 0; -		_vm->_globals._bob[idx].field14 = 0; -	} +	if (!_vm->_globals._bob[idx]._disabledAnimationFl) +		return; + +	_vm->_globals._bob[idx]._disabledAnimationFl = false; +	_vm->_globals._bob[idx].field10 = 5; +	_vm->_globals._bob[idx]._frameIndex = 250; +	_vm->_globals._bob[idx].field12 = 0; +	_vm->_globals._bob[idx].field14 = 0;  }  /** diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h index 9fbaaced76..5f31b3a72a 100644 --- a/engines/hopkins/objects.h +++ b/engines/hopkins/objects.h @@ -100,7 +100,7 @@ public:  	int A_DEPA;  	int MAX_DEPA;  	int MAX_DEPA1; -	int CH_TETE; +	bool CH_TETE;  	int T_RECTIF;  	bool _disableFl;  	bool _twoCharactersFl; diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index 217f1f15f2..43b65d006e 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -203,7 +203,7 @@ LABEL_1141:  				_vm->_objectsManager._characterPos.x = (int16)READ_LE_UINT16(dataP + 6);  				_vm->_objectsManager._characterPos.y = v6;  				_vm->_objectsManager.PERI = v5; -				if (_vm->_objectsManager.CH_TETE == 1) { +				if (_vm->_objectsManager.CH_TETE) {  					if (_vm->_globals._saveData->data[svField354] == 1  							&& _vm->_globals._saveData->_cloneHopkins._pos.x && _vm->_globals._saveData->_cloneHopkins._pos.y  							&& _vm->_globals._saveData->_cloneHopkins.field2 && _vm->_globals._saveData->_cloneHopkins._location) { @@ -255,7 +255,7 @@ LABEL_1141:  				}  			}  			opcodeType = 1; -			_vm->_objectsManager.CH_TETE = 0; +			_vm->_objectsManager.CH_TETE = false;  	} else if (dataP[2] == 'S' && dataP[3] == 'T' && dataP[4] == 'E') {  		if (!_vm->_objectsManager._disableFl) {  			int v7 = *(dataP + 5); | 
