[Scummvm-cvs-logs] SF.net SVN: scummvm: [29073] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Mon Sep 24 00:17:58 CEST 2007


Revision: 29073
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29073&view=rev
Author:   dreammaster
Date:     2007-09-23 15:17:57 -0700 (Sun, 23 Sep 2007)

Log Message:
-----------
Converted fields in data that were originally offsets (such as tick proc offsets) to use indexes, allowing for more generic handling of different language versions

Modified Paths:
--------------
    scummvm/trunk/engines/lure/debugger.cpp
    scummvm/trunk/engines/lure/hotspots.cpp
    scummvm/trunk/engines/lure/hotspots.h
    scummvm/trunk/engines/lure/lure.cpp
    scummvm/trunk/engines/lure/luredefs.h
    scummvm/trunk/engines/lure/res.cpp
    scummvm/trunk/engines/lure/res_struct.cpp
    scummvm/trunk/engines/lure/res_struct.h
    scummvm/trunk/engines/lure/scripts.cpp

Modified: scummvm/trunk/engines/lure/debugger.cpp
===================================================================
--- scummvm/trunk/engines/lure/debugger.cpp	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/debugger.cpp	2007-09-23 22:17:57 UTC (rev 29073)
@@ -311,7 +311,7 @@
 		DebugPrintf("Animation Id = %xh, Colour offset = %d\n", hs->animRecordId, hs->colourOffset);
 		DebugPrintf("Talk Script offset = %xh, Tick Script offset = %xh\n",
 			hs->talkScriptOffset, hs->tickScriptOffset);
-		DebugPrintf("Tick Proc offset = %xh\n", hs->tickProcOffset);
+		DebugPrintf("Tick Proc offset = %xh\n", hs->tickProcId);
 		DebugPrintf("Tick timeout = %d\n", hs->tickTimeout);
 		DebugPrintf("NPC Shcedule = %xh\n", hs->npcSchedule);
 		DebugPrintf("Character mode = %d, delay ctr = %d, pause ctr = %d\n",

Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/hotspots.cpp	2007-09-23 22:17:57 UTC (rev 29073)
@@ -36,6 +36,7 @@
 #include "lure/game.h"
 #include "lure/fights.h"
 #include "lure/sound.h"
+#include "lure/lure.h"
 #include "common/endian.h"
 
 namespace Lure {
@@ -74,7 +75,7 @@
 
 	_override = resources.getHotspotOverride(res->hotspotId);
 	setAnimation(_data->animRecordId);
-	_tickHandler = HotspotTickHandlers::getHandler(_data->tickProcOffset);
+	_tickHandler = HotspotTickHandlers::getHandler(_data->tickProcId);
 	_nameBuffer[0] = '\0';
 
 	if (_hotspotId < FIRST_NONCHARACTER_ID) {
@@ -103,6 +104,11 @@
 
 Hotspot::Hotspot(Hotspot *character, uint16 objType): _pathFinder(this) {
 	assert(character);
+
+	Common::Language language = LureEngine::getReference().getLanguage();
+	uint16 animId = 0x5810;
+	if (language == IT_ITA) animId = 0x58D0;
+
 	_originalId = objType;
 	_data = NULL;
 	_anim = NULL;
@@ -120,7 +126,7 @@
 	_skipFlag = false;
 
 	switch (objType) {
-	case VOICE_ANIM_ID:
+	case VOICE_ANIM_INDEX:
 		_roomNumber = character->roomNumber();
 		_destHotspotId = character->hotspotId();
 		_startX = character->x() + character->talkX() + 12;
@@ -138,11 +144,11 @@
 		_voiceCtr = 40;
 
 		_tickHandler = HotspotTickHandlers::getHandler(VOICE_TICK_PROC_ID);
-		setAnimation(VOICE_ANIM_ID);
+		setAnimation(animId);
 		break;
 
-	case PUZZLED_ANIM_ID:
-	case EXCLAMATION_ANIM_ID:
+	case PUZZLED_ANIM_INDEX:
+	case EXCLAMATION_ANIM_INDEX:
 		_roomNumber = character->roomNumber();
 		_hotspotId = 0xfffe;
 		_startX = character->x() + character->talkX() + 12;
@@ -158,8 +164,8 @@
 
 		_destHotspotId = character->hotspotId();
 		_tickHandler = HotspotTickHandlers::getHandler(PUZZLED_TICK_PROC_ID);
-		setAnimation(VOICE_ANIM_ID);
-		setFrameNumber(objType == PUZZLED_ANIM_ID ? 1 : 2);
+		setAnimation(animId);
+		setFrameNumber(objType == PUZZLED_ANIM_INDEX ? 1 : 2);
 		
 		character->setFrameCtr(_voiceCtr);
 		break;
@@ -467,7 +473,8 @@
 
 void Hotspot::setTickProc(uint16 newVal) {
 	if (_data)
-		_data->tickProcOffset = newVal;
+		_data->tickProcId = newVal;
+
 	_tickHandler = HotspotTickHandlers::getHandler(newVal);	
 }
 
@@ -763,12 +770,12 @@
 
 	if (idVal == 0x76) {
 		// Special code id for showing the puzzled talk bubble
-		hotspot = new Hotspot(this, PUZZLED_ANIM_ID);
+		hotspot = new Hotspot(this, PUZZLED_ANIM_INDEX);
 		res.addHotspot(hotspot);
 
 	} else if (idVal == 0x120) {
 		// Special code id for showing the exclamation talk bubble
-		hotspot = new Hotspot(this, EXCLAMATION_ANIM_ID);
+		hotspot = new Hotspot(this, EXCLAMATION_ANIM_INDEX);
 		res.addHotspot(hotspot);
 
 	} else if (idVal >= 0x8000) {
@@ -2170,83 +2177,81 @@
 
 /*------------------------------------------------------------------------*/
 
-HandlerMethodPtr HotspotTickHandlers::getHandler(uint16 procOffset) {
-	switch (procOffset) {
-	case 0:
-	case 0x41BD:
+HandlerMethodPtr HotspotTickHandlers::getHandler(uint16 procIndex) {
+	switch (procIndex) {
+	case 1:
 		return defaultHandler;
 	case STANDARD_CHARACTER_TICK_PROC:
 		return standardCharacterAnimHandler;
+	case PLAYER_TICK_PROC_ID:
+		return playerAnimHandler;
 	case VOICE_TICK_PROC_ID:
 		return voiceBubbleAnimHandler;
 	case PUZZLED_TICK_PROC_ID:
 		return puzzledAnimHandler;
-	case 0x7207:
+	case 6:
 		return roomExitAnimHandler;
-	case PLAYER_TICK_PROC_ID:
-		return playerAnimHandler;
-	case 0x7C14:
+	case 7:
 	case FOLLOWER_TICK_PROC_2:
 		return followerAnimHandler;
 	case JAILOR_TICK_PROC_ID:
-	case 0x7F02:
+	case 10:
 		return jailorAnimHandler;
 	case STANDARD_ANIM_2_TICK_PROC:
 		return standardAnimHandler2;
 	case STANDARD_ANIM_TICK_PROC:
 		return standardAnimHandler;
-	case 0x7F54:
+	case 13:
 		return sonicRatAnimHandler;
-	case 0x7F69:
+	case 14:
 		return droppingTorchAnimHandler;
-	case 0x7FA1:
+	case 15:
 		return playerSewerExitAnimHandler;
-	case 0x8009:
+	case 16:
 		return fireAnimHandler;
-	case 0x80C6:
+	case 17:
 		return sparkleAnimHandler;
-	case 0x813F:
+	case 18:
 		return teaAnimHandler;
-	case 0x8180:
+	case 19:
 		return goewinCaptiveAnimHandler;
-	case 0x81B3:
+	case 20:
 		return prisonerAnimHandler;
-	case 0x81F3:
+	case 21:
 		return catrionaAnimHandler;
-	case 0x820E:
+	case 22:
 		return morkusAnimHandler;
-	case 0x8241:
+	case 23:
 		return grubAnimHandler;
-	case 0x82A0:
+	case 24:
 		return barmanAnimHandler;
-	case 0x85ce:
+	case 25:
 		return skorlAnimHandler;
-	case 0x862D:
+	case 26:
 		return gargoyleAnimHandler;
 	case GOEWIN_SHOP_TICK_PROC:
 		return goewinShopAnimHandler;
-	case 0x86FA:
-	case 0x86FF:
-	case 0x871E:
-	case 0x873D:
-	case 0x8742:
-	case 0x8747:
+	case 28:
+	case 29:
+	case 30:
+	case 31:
+	case 32:
+	case 33:
 		return skullAnimHandler;
-	case 0x87B3:
+	case 34:
 		return dragonFireAnimHandler;
-	case 0x87EC:
+	case 35:
 		return castleSkorlAnimHandler;
-	case 0x882A:
+	case 36:
 		return rackSerfAnimHandler;
 	case TALK_TICK_PROC_ID:
 		return talkAnimHandler;
-	case 0x982D:
+	case 38:
 		return fighterAnimHandler;
 	case PLAYER_FIGHT_TICK_PROC_ID:
 		return playerFightAnimHandler;
 	default:
-		error("Unknown tick proc %xh for hotspot", procOffset);
-//		return defaultHandler;
+		error("Unknown tick proc Id %xh for hotspot", procIndex);
 	}
 }
 
@@ -2888,7 +2893,7 @@
 	ValueTableData &fields = res.fieldList();
 	Hotspot *player = res.getActiveHotspot(PLAYER_ID);
 
-	if ((h.resource()->tickProcOffset == FOLLOWER_TICK_PROC_2) || (fields.getField(37) == 0)) {
+	if ((h.resource()->tickProcId == FOLLOWER_TICK_PROC_2) || (fields.getField(37) == 0)) {
 		if (h.currentActions().isEmpty() && (h.roomNumber() != player->roomNumber())) {
 			// Character in different room than player
 			if (h.hotspotId() == GOEWIN_ID) 

Modified: scummvm/trunk/engines/lure/hotspots.h
===================================================================
--- scummvm/trunk/engines/lure/hotspots.h	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/hotspots.h	2007-09-23 22:17:57 UTC (rev 29073)
@@ -91,7 +91,7 @@
 	static void fighterAnimHandler(Hotspot &h);
 	static void playerFightAnimHandler(Hotspot &h);
 public:
-	static HandlerMethodPtr getHandler(uint16 procOffset);
+	static HandlerMethodPtr getHandler(uint16 procIndex);
 };
 
 enum CurrentAction {NO_ACTION, START_WALKING, DISPATCH_ACTION, EXEC_HOTSPOT_SCRIPT, 

Modified: scummvm/trunk/engines/lure/lure.cpp
===================================================================
--- scummvm/trunk/engines/lure/lure.cpp	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/lure.cpp	2007-09-23 22:17:57 UTC (rev 29073)
@@ -62,6 +62,8 @@
 }
 
 int LureEngine::init() {
+	int_engine = this;
+
 	_system->beginGFXTransaction();
 		initCommonGFX(false);
 		_system->initSize(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT);
@@ -78,7 +80,6 @@
 	Surface::initialise();
 	_room = new Room();
 	_fights = new FightsManager();
-	int_engine = this;
 	return 0;
 }
 
@@ -104,6 +105,18 @@
 }
 
 int LureEngine::go() {
+
+	if (ConfMan.getBool("copy_protection")) {
+		CopyProtectionDialog *dialog = new CopyProtectionDialog();
+		bool result = dialog->show();
+		delete dialog;
+		if (_events->quitFlag)
+			return 0;
+
+		if (!result)
+			error("Sorry - copy protection failed");
+	}
+
 	if (ConfMan.getInt("boot_param") == 0) {
 		// Show the introduction
 		Sound.loadSection(INTRO_SOUND_RESOURCE_ID);

Modified: scummvm/trunk/engines/lure/luredefs.h
===================================================================
--- scummvm/trunk/engines/lure/luredefs.h	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/luredefs.h	2007-09-23 22:17:57 UTC (rev 29073)
@@ -34,7 +34,7 @@
 
 #define SUPPORT_FILENAME "lure.dat"
 #define LURE_DAT_MAJOR 1
-#define LURE_DAT_MINOR 21
+#define LURE_DAT_MINOR 22
 
 #define LURE_DEBUG 1
 
@@ -133,6 +133,10 @@
 // Endgame animation constants
 #define ENDGAME_PALETTE_ID 0xFF00
 #define ENDGAME_ANIM_ID 0xFF01
+// Miscellaneous resources
+#define COPY_PROTECTION_RESOURCE_ID 0x4139
+#define CREDITS_RESOURCE_ID 0x7800
+#define RESTART_RESOURCE_ID 0x7900
 
 // Specifies the maximum buffer sized allocated for decoding animation data
 #define MAX_ANIM_DECODER_BUFFER_SIZE 300000
@@ -158,7 +162,6 @@
 
 // Font details
 #define FONT_RESOURCE_ID 4
-#define NUM_CHARS_IN_FONT 122
 #define FONT_WIDTH 8
 #define FONT_HEIGHT 8
 
@@ -224,6 +227,7 @@
 #define FIGHT_DATA_RESOURCE_ID 0x3f16
 #define STRING_LIST_RESOURCE_ID 0x3f17
 #define SOUND_DESC_RESOURCE_ID 0x3f18
+#define STRING_DECODER_RESOURCE_ID 0x3f19
 
 // Script constants
 #define STARTUP_SCRIPT 0x23FC
@@ -256,25 +260,24 @@
 #define BRICKS_ID 0x2714
 #define BOOK_ID 0x2723
 #define START_NONVISUAL_HOTSPOT_ID 0x7530
-#define CREDITS_RESOURCE_ID 0x7800
-#define RESTART_RESOURCE_ID 0x7900
 
 // Milliseconds delay between game frames
 #define GAME_FRAME_DELAY 80
 #define GAME_TICK_DELAY 20
 
 // Tick proc constants
-#define STANDARD_CHARACTER_TICK_PROC 0x4f82
-#define PLAYER_TICK_PROC_ID 0x5E44
-#define VOICE_TICK_PROC_ID 0x625E
-#define PUZZLED_TICK_PROC_ID 0x6571
-#define FOLLOWER_TICK_PROC_2 0x7C24
-#define JAILOR_TICK_PROC_ID 0x7efa
-#define STANDARD_ANIM_2_TICK_PROC 0x7F37
-#define STANDARD_ANIM_TICK_PROC 0x7f3a
-#define GOEWIN_SHOP_TICK_PROC 0x865A
-#define TALK_TICK_PROC_ID 0x8ABD
-#define PLAYER_FIGHT_TICK_PROC_ID 0x98B6
+#define NULL_TICK_PROC_ID 1
+#define STANDARD_CHARACTER_TICK_PROC 2
+#define PLAYER_TICK_PROC_ID 3
+#define VOICE_TICK_PROC_ID 4
+#define PUZZLED_TICK_PROC_ID 5
+#define FOLLOWER_TICK_PROC_2 8
+#define JAILOR_TICK_PROC_ID 9
+#define STANDARD_ANIM_2_TICK_PROC 11
+#define STANDARD_ANIM_TICK_PROC 12
+#define GOEWIN_SHOP_TICK_PROC 27
+#define TALK_TICK_PROC_ID 37
+#define PLAYER_FIGHT_TICK_PROC_ID 39
 
 // String constants
 #define STRANGER_ID 0x17A
@@ -284,9 +287,9 @@
 // Misc constants
 #define GENERAL_MAGIC_ID 42
 #define PLAYER_FIGHT_ANIM_ID 0x55F6
-#define VOICE_ANIM_ID 0x5810
-#define PUZZLED_ANIM_ID 0x8001
-#define EXCLAMATION_ANIM_ID 0x8002
+#define VOICE_ANIM_INDEX 1
+#define PUZZLED_ANIM_INDEX 2
+#define EXCLAMATION_ANIM_INDEX 3
 #define SERF_ANIM_ID 0x58A0
 #define BLACKSMITH_STANDARD 0x8a12
 #define BLACKSMITH_HAMMERING_ANIM_ID 0x9c11

Modified: scummvm/trunk/engines/lure/res.cpp
===================================================================
--- scummvm/trunk/engines/lure/res.cpp	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/res.cpp	2007-09-23 22:17:57 UTC (rev 29073)
@@ -480,10 +480,11 @@
 		assert(character);
 
 		// Add the special "voice" animation above the character
-		Hotspot *hotspot = new Hotspot(character, VOICE_ANIM_ID);
+		Hotspot *hotspot = new Hotspot(character, VOICE_ANIM_INDEX);
 		addHotspot(hotspot);
 	}
 }
+uint16 englishLoadOffsets[] = {0x3afe, 0x41BD, 0x7167, 0x7172, 0x8617, 0x88ac, 0};
 
 Hotspot *Resources::activateHotspot(uint16 hotspotId) {
 	HotspotData *res = getHotspot(hotspotId);
@@ -508,24 +509,23 @@
 		uint16 talkIndex;
 
 		switch (res->loadOffset) {
-		case 0x3afe:
-			// Copy protection check - since the game is freeware now,
-			// don't bother with it
+		case 1:
+			// Copy protection check - since the game is freeware now, ignore it
 			loadFlag = false;
 			break;
 
-		case 0x41BD:
+		case 2:
 			// Empty handler used to prevent loading hotspots that
 			// are yet to be active (such as the straw fire)
 			loadFlag = false;
 			break;
 
-		case 0x7172:
-		case 0x7167:
+		case 3:
+		case 4:
 			// Standard animation load
 			break;
 
-		case 0x8617:
+		case 5:
 			// Custom loader used by the notice hotspot 42ah in room #20
 			talkIndex = _fieldList.getField(TALK_INDEX);
 			if ((talkIndex < 8) || (talkIndex >= 14))
@@ -536,14 +536,14 @@
 				res->startY = 85;    
 			break;
 
-		case 0x88ac:
+		case 6:
 			// Torch in room #1
 			loadFlag = _fieldList.getField(TORCH_HIDE) == 0;
 			break;
 
 		default:
 			// All others simply activate the hotspot
-			warning("Hotspot %d uses unknown load offset proc %d",
+			warning("Hotspot %d uses unknown load offset index %d",
 				res->hotspotId, res->loadOffset);
 		}
 
@@ -552,8 +552,8 @@
 			assert(hotspot);
 
 			// Special post-load handling
-			if (res->loadOffset == 0x7167) hotspot->setPersistant(true);
-			if (res->loadOffset == 0x8617) hotspot->handleTalkDialog();
+			if (res->loadOffset == 3) hotspot->setPersistant(true);
+			if (res->loadOffset == 5) hotspot->handleTalkDialog();
 			
 			// TODO: Figure out why there's a room set in the animation decode for a range of characters,
 			// particularly since it doesn't seem to match what happens in-game

Modified: scummvm/trunk/engines/lure/res_struct.cpp
===================================================================
--- scummvm/trunk/engines/lure/res_struct.cpp	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/res_struct.cpp	2007-09-23 22:17:57 UTC (rev 29073)
@@ -410,7 +410,7 @@
 	animRecordId = FROM_LE_16(rec->animRecordId);
 	hotspotScriptOffset = FROM_LE_16(rec->hotspotScriptOffset);
 	talkScriptOffset = FROM_LE_16(rec->talkScriptOffset);
-	tickProcOffset = FROM_LE_16(rec->tickProcOffset);
+	tickProcId = FROM_LE_16(rec->tickProcId);
 	tickTimeout = FROM_LE_16(rec->tickTimeout);
 	tickScriptOffset = FROM_LE_16(rec->tickScriptOffset);
 	npcSchedule = FROM_LE_16(rec->npcSchedule);
@@ -454,7 +454,7 @@
 	stream->writeUint16LE(heightCopy);
 	stream->writeUint16LE(yCorrection);
 	stream->writeUint16LE(hotspotScriptOffset);
-	stream->writeUint16LE(tickProcOffset);
+	stream->writeUint16LE(tickProcId);
 	stream->writeUint16LE(tickTimeout);
 	stream->writeUint16LE(tickScriptOffset);
 	stream->writeUint16LE(characterMode);
@@ -495,7 +495,7 @@
 	heightCopy = stream->readUint16LE();
 	yCorrection = stream->readUint16LE();
 	hotspotScriptOffset = stream->readUint16LE();
-	tickProcOffset = stream->readUint16LE();
+	tickProcId = stream->readUint16LE();
 	tickTimeout = stream->readUint16LE();
 	tickScriptOffset = stream->readUint16LE();
 	characterMode = (CharacterMode) stream->readUint16LE();

Modified: scummvm/trunk/engines/lure/res_struct.h
===================================================================
--- scummvm/trunk/engines/lure/res_struct.h	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/res_struct.h	2007-09-23 22:17:57 UTC (rev 29073)
@@ -83,7 +83,7 @@
 	uint16 animRecordId;
 	uint16 hotspotScriptOffset;
 	uint16 talkScriptOffset;
-	uint16 tickProcOffset;
+	uint16 tickProcId;
 	uint16 tickTimeout;
 	uint16 tickScriptOffset;
 	uint16 npcSchedule;
@@ -277,6 +277,13 @@
 
 		return last;
 	}
+
+	T operator[](int index) {
+		typename Common_List::iterator i = Common_List::begin();
+		while (index-- > 0) 
+			++i;
+		return *i;
+	}
 };
 
 /** Enumeration used for direction facings */
@@ -452,7 +459,7 @@
 	uint16 animRecordId;
 	uint16 hotspotScriptOffset;
 	uint16 talkScriptOffset;
-	uint16 tickProcOffset;
+	uint16 tickProcId;
 	uint16 tickTimeout;
 	uint16 tickScriptOffset;
 	uint16 npcSchedule;
@@ -772,8 +779,8 @@
 
 enum StringEnum {S_CREDITS = 25, S_RESTART_GAME = 26, S_SAVE_GAME = 27, S_RESTORE_GAME = 28, 
 	S_QUIT = 29, S_FAST_TEXT = 30, S_SLOW_TEXT = 31, S_SOUND_ON = 32, S_SOUND_OFF = 33, 
-	S_NOTHING = 34, S_FOR = 35, S_TO = 36, S_ON = 37, S_AND_THEN = 38,
-	S_FINISH = 39};
+	S_NOTHING = 34, S_FOR = 35, S_TO = 36, S_ON = 37, S_AND_THEN = 38, S_FINISH = 39, 
+	S_CONFIRM_YN = 40, S_ARTICLE_LIST = 41};
 
 class StringList {
 private:

Modified: scummvm/trunk/engines/lure/scripts.cpp
===================================================================
--- scummvm/trunk/engines/lure/scripts.cpp	2007-09-23 22:16:46 UTC (rev 29072)
+++ scummvm/trunk/engines/lure/scripts.cpp	2007-09-23 22:17:57 UTC (rev 29073)
@@ -235,7 +235,7 @@
 void Script::remoteRoomViewSetup(uint16 v1, uint16 v2, uint16 v3) {
 	Hotspot *player = Resources::getReference().getActiveHotspot(PLAYER_ID);
 
-	player->setTickProc(0); // disable player actions
+	player->setTickProc(NULL_TICK_PROC_ID);
 	Resources::getReference().fieldList().setField(OLD_ROOM_NUMBER,
 		player->roomNumber());
 }


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