diff options
author | Andrew Kurushin | 2004-12-18 16:08:59 +0000 |
---|---|---|
committer | Andrew Kurushin | 2004-12-18 16:08:59 +0000 |
commit | 1724d009628f169ccb9bbfc94bd72e5301169fc8 (patch) | |
tree | 7da64f4c668df500a3f26fb663d5376149440cb2 /saga | |
parent | c195ae0e74fee2d7e22b8df68eae20073abd139b (diff) | |
download | scummvm-rg350-1724d009628f169ccb9bbfc94bd72e5301169fc8.tar.gz scummvm-rg350-1724d009628f169ccb9bbfc94bd72e5301169fc8.tar.bz2 scummvm-rg350-1724d009628f169ccb9bbfc94bd72e5301169fc8.zip |
sprite loading fix in win demo
svn-id: r16119
Diffstat (limited to 'saga')
-rw-r--r-- | saga/actor.cpp | 56 | ||||
-rw-r--r-- | saga/actor.h | 12 | ||||
-rw-r--r-- | saga/game.cpp | 10 | ||||
-rw-r--r-- | saga/interface.cpp | 4 | ||||
-rw-r--r-- | saga/ite_introproc.cpp | 5 | ||||
-rw-r--r-- | saga/resnames.h | 2 | ||||
-rw-r--r-- | saga/scene.cpp | 2 | ||||
-rw-r--r-- | saga/sprite.cpp | 13 |
8 files changed, 60 insertions, 44 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index da02e3b9c6..56319a483c 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -70,13 +70,13 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { for (i = 0; i < ACTORCOUNT; i++) { actor = &_actors[i]; - actor->actorId = ACTOR_INDEX_TO_ID(i); - actor->index = i; - debug(0, "init actorId=0x%X index=0x%X", actor->actorId, actor->index); + actor->_actorId = ACTOR_INDEX_TO_ID(i); + actor->_index = i; + debug(0, "init actorId=0x%X index=0x%X", actor->_actorId, actor->_index); actor->spriteListResourceId = ActorTable[i].spriteListResourceId; actor->frameListResourceId = ActorTable[i].frameListResourceId; actor->flags = ActorTable[i].flags; - actor->speechColor = ActorTable[actor->index].speechColor; + actor->speechColor = ActorTable[i].speechColor; actor->orient = ACTOR_DEFAULT_ORIENT; actor->def_action = 0; actor->def_action_flags = 0; @@ -84,9 +84,13 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { actor->action_flags = 0; actor->action_time = 0; actor->action_frame = 0; - if (loadActorResources(actor) != SUCCESS) - error("Error while loading actors resource actorId=0x%X index=0x%X", actor->actorId, actor->index); - _orderList.push_back(actor); + actor->_disabled = !loadActorResources(actor); + if (actor->_disabled) { + warning("Disabling actorId=0x%X index=0x%X", actor->_actorId, actor->_index); + } else { + _orderList.push_back(actor); + } + } } @@ -103,7 +107,7 @@ Actor::~Actor() { } } -int Actor::loadActorResources(ActorData * actor) { +bool Actor::loadActorResources(ActorData * actor) { byte *resourcePointer; size_t resourceLength; int frameCount; @@ -112,20 +116,19 @@ int Actor::loadActorResources(ActorData * actor) { int i, orient; int result; + debug(0, "Loading frame resource id 0x%X", actor->frameListResourceId); result = RSC_LoadResource(_actorContext, actor->frameListResourceId, &resourcePointer, &resourceLength); if (result != SUCCESS) { warning("Couldn't load sprite action index resource"); - return FAILURE; + return false; } frameCount = resourceLength / 16; - debug(0, "Sprite resource contains %d frames", frameCount); + debug(0, "Frame resource contains %d frames", frameCount); framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * frameCount); if (framesPointer == NULL) { - warning("Couldn't allocate memory for sprite frames"); - RSC_FreeResource(resourcePointer); - return MEM; + error("Couldn't allocate memory for sprite frames"); } MemoryReadStreamEndian readS(resourcePointer, resourceLength, IS_BIG_ENDIAN); @@ -149,27 +152,37 @@ int Actor::loadActorResources(ActorData * actor) { actor->frameCount = frameCount; + debug(0, "Loading sprite resource id 0x%X", actor->spriteListResourceId); if (_vm->_sprite->loadList(actor->spriteListResourceId, &actor->spriteList) != SUCCESS) { warning("Unable to load sprite list"); - return FAILURE; + return false; } - if (lastFrame >= _vm->_sprite->getListLen(actor->spriteList)) { + i = _vm->_sprite->getListLen(actor->spriteList); + + if ( (lastFrame >= i)) { debug(0, "Appending to sprite list 0x%X", actor->spriteListResourceId); if (_vm->_sprite->appendList(actor->spriteListResourceId + 1, actor->spriteList) != SUCCESS) { warning("Unable append sprite list"); - return FAILURE; + return false; } } - return SUCCESS; + return true; } ActorData *Actor::getActor(uint16 actorId) { - if(!IS_VALID_ACTOR_ID(actorId)) + ActorData *actor; + + if (!IS_VALID_ACTOR_ID(actorId)) error("Actor::getActor Wrong actorId 0x%X", actorId); - return &_actors[ACTOR_ID_TO_INDEX(actorId)]; + actor = &_actors[ACTOR_ID_TO_INDEX(actorId)]; + + if (actor->_disabled) + error("Actor::getActor disabled actorId 0x%X", actorId); + + return actor; } ActorOrderList::iterator Actor::getActorOrderIterator(const ActorData *actor) { @@ -297,9 +310,12 @@ int Actor::drawList() { for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) { actor = actorOrderIterator.operator*(); + if(actor->frameCount == 0) continue; + o_idx = ActorOrientationLUT[actor->orient]; sprite_num = actor->frames[actor->action].dir[o_idx].frameIndex; sprite_num += actor->action_frame; + if(actor->spriteList->sprite_count <= sprite_num) continue; _vm->_sprite->drawOccluded(back_buf, actor->spriteList, sprite_num, actor->s_pt.x, actor->s_pt.y); // If actor's current intent is to speak, oblige him by @@ -604,7 +620,7 @@ int Actor::handleWalkIntent(ActorData *actor, WALKINTENT *a_walkint, int *comple // Initialize walk intent if (!a_walkint->wi_init) { setPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem); - setDefaultAction(actor->actorId, ACTION_IDLE, ACTION_NONE); + setDefaultAction(actor->_actorId, ACTION_IDLE, ACTION_NONE); a_walkint->wi_init = 1; } diff --git a/saga/actor.h b/saga/actor.h index 3c06d47aca..922fecdd17 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -177,8 +177,9 @@ struct ACTORINTENT { typedef Common::List<ACTORINTENT> ActorIntentList; struct ActorData { - int index; // Actor index - uint16 actorId; // Actor id + bool _disabled; + int _index; // Actor index + uint16 _actorId; // Actor id int name_i; // Actor's index in actor name string list uint16 flags; @@ -219,8 +220,9 @@ struct ActorData { ActorData() { - index = 0; - actorId = 0; + _disabled = false; + _index = 0; + _actorId = 0; name_i = 0; flags = 0; frames = NULL; @@ -288,7 +290,7 @@ private: ActorData *getActor(uint16 actorId); - int loadActorResources(ActorData * actor); + bool loadActorResources(ActorData * actor); ActorOrderList::iterator getActorOrderIterator(const ActorData *actor); void reorderActorUp(ActorData *actor); diff --git a/saga/game.cpp b/saga/game.cpp index 9f24f651a8..189a9502b3 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -112,12 +112,6 @@ GAME_RESOURCEDESC ITE_Resources = { ITE_DIALOGUE_PANEL }; -GAME_RESOURCEDESC ITEMACDEMO_Resources = { - ITEMACDEMO_SCENE_LUT, // Scene lookup table RN - ITE_SCRIPT_LUT, // Script lookup table RN - ITE_COMMAND_PANEL, - ITE_DIALOGUE_PANEL -}; GAME_SOUNDINFO ITE_GameSound = { GAME_SOUND_VOC, 0, 0, 0 @@ -218,7 +212,7 @@ GAMEDESC GameDescs[] = { 320, 200, 137, ITE_DEFAULT_SCENE, - &ITEMACDEMO_Resources, + &ITE_Resources, ARRAYSIZE(ITEMACDEMO_GameFiles), ITEMACDEMO_GameFiles, ARRAYSIZE(ITEMACDEMO_GameFonts), @@ -593,7 +587,7 @@ int GAME_GetSceneInfo(GAME_SCENEDESC *gs_desc) { assert(gs_desc != NULL); gs_desc->first_scene = GameModule.gamedesc->gd_startscene; - gs_desc->scene_lut_rn = GameModule.gamedesc->gd_resource_desc->scene_lut_rn; + gs_desc->scene_lut_rn = RSC_ConvertID(GameModule.gamedesc->gd_resource_desc->scene_lut_rn); return SUCCESS; } diff --git a/saga/interface.cpp b/saga/interface.cpp index 1cd90593aa..8bcede1578 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -574,7 +574,7 @@ int Interface::handlePlayfieldClick(SURFACE *ds, const Point& imousePt) { if (objectNum == -1) { // Player clicked on empty spot - walk here regardless of verb _vm->_actor->StoA(iactor_pt, imousePt); - _vm->_actor->walkTo(0, &iactor_pt, 0, NULL); + _vm->_actor->walkTo(1, &iactor_pt, 0, NULL); return SUCCESS; } @@ -593,7 +593,7 @@ int Interface::handlePlayfieldClick(SURFACE *ds, const Point& imousePt) { } else { // Not a normal scene object - walk to it as if it weren't there _vm->_actor->StoA(iactor_pt, imousePt); - _vm->_actor->walkTo(0, &iactor_pt, 0, NULL); + _vm->_actor->walkTo(1, &iactor_pt, 0, NULL); } return SUCCESS; diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index bb48ffe54c..5caa7286ea 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -126,12 +126,15 @@ int Scene::ITEStartProc() { size_t i; SCENE_QUEUE first_scene; + SCENE_QUEUE tempScene; GAME_SCENEDESC gs_desc; n_introscenes = ARRAYSIZE(ITE_IntroList); for (i = 0; i < n_introscenes; i++) { - _vm->_scene->queueScene(&ITE_IntroList[i]); + tempScene = ITE_IntroList[i]; + tempScene.scene_n = RSC_ConvertID(tempScene.scene_n); + _vm->_scene->queueScene(&tempScene); } GAME_GetSceneInfo(&gs_desc); diff --git a/saga/resnames.h b/saga/resnames.h index ea9f0f07e4..fb4bc0f3d3 100644 --- a/saga/resnames.h +++ b/saga/resnames.h @@ -29,7 +29,6 @@ namespace Saga { // Lookup tables -#define ITEMACDEMO_SCENE_LUT 1804 #define ITE_SCENE_LUT 1806 #define ITE_SCRIPT_LUT 216 @@ -58,7 +57,6 @@ namespace Saga { #define ITE_DEFAULT_PORTRAITS 125 // ITE Scene resource numbers -#define ITEMACDEMO_INTRO_ANIM_SCENE 1536 #define ITE_INTRO_ANIM_SCENE 1538 #define ITE_CAVE_SCENE_1 1542 #define ITE_CAVE_SCENE_2 1545 diff --git a/saga/scene.cpp b/saga/scene.cpp index 6b81fa16fe..53362bcc79 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -232,7 +232,7 @@ int Scene::nextScene() { scene_qdat = queueIterator.operator->(); assert(scene_qdat != NULL); - loadScene(RSC_ConvertID(scene_qdat->scene_n), scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType); + loadScene(scene_qdat->scene_n, scene_qdat->load_flag, scene_qdat->scene_proc, scene_qdat->scene_desc, scene_qdat->fadeType); return SUCCESS; } diff --git a/saga/sprite.cpp b/saga/sprite.cpp index 0e0645d2dc..a95e61aaea 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -73,19 +73,22 @@ int Sprite::loadList(int resource_num, SPRITELIST **sprite_list_p) { uint16 sprite_count; uint16 i; - new_slist = (SPRITELIST *)malloc(sizeof *new_slist); - if (new_slist == NULL) { - return MEM; - } - if (RSC_LoadResource(_spriteContext, resource_num, &spritelist_data, &spritelist_len) != SUCCESS) { return FAILURE; } + if (spritelist_len == 0) + return FAILURE; + MemoryReadStreamEndian readS(spritelist_data, spritelist_len, IS_BIG_ENDIAN); sprite_count = readS.readUint16(); + new_slist = (SPRITELIST *)malloc(sizeof *new_slist); + if (new_slist == NULL) { + return MEM; + } + new_slist->sprite_count = sprite_count; new_slist->offset_list = (SPRITELIST_OFFSET *)malloc(sprite_count * sizeof *new_slist->offset_list); |