ihnm actors list WIP
svn-id: r18623
This commit is contained in:
parent
c950bd8231
commit
5956747e2e
7 changed files with 122 additions and 31 deletions
|
@ -206,13 +206,14 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
|
|||
_pathRect.top = _vm->getDisplayInfo().pathStartY;
|
||||
_pathRect.bottom = _vm->getSceneHeight();
|
||||
|
||||
if (_vm->getGameType() == GType_ITE) {
|
||||
// Get actor resource file context
|
||||
_actorContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
|
||||
if (_actorContext == NULL) {
|
||||
error("Actor::Actor() resource context not found");
|
||||
}
|
||||
|
||||
if (_vm->getGameType() == GType_ITE) {
|
||||
|
||||
_vm->_resource->loadResource(_actorContext, _vm->getResourceDescription()->actorsStringsResourceId, stringsPointer, stringsLength);
|
||||
|
||||
_vm->loadStrings(_actorsStrings, stringsPointer, stringsLength);
|
||||
|
@ -281,7 +282,6 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) {
|
|||
|
||||
Actor::~Actor() {
|
||||
int i;
|
||||
ActorData *actor;
|
||||
ObjectData *obj;
|
||||
|
||||
debug(9, "Actor::~Actor()");
|
||||
|
@ -296,11 +296,8 @@ Actor::~Actor() {
|
|||
free(_pathCell);
|
||||
_actorsStrings.freeMem();
|
||||
//release resources
|
||||
for (i = 0; i < _actorsCount; i++) {
|
||||
actor = _actors[i];
|
||||
delete actor;
|
||||
}
|
||||
free(_actors);
|
||||
freeList();
|
||||
|
||||
for (i = 0; i < _objsCount; i++) {
|
||||
obj = _objs[i];
|
||||
delete obj;
|
||||
|
@ -372,8 +369,89 @@ bool Actor::loadActorResources(ActorData *actor) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Actor::loadList(int actorsEntrance, int actorCount, int actorsResourceID,
|
||||
int protagStatesCount, int protagStatesResourceID) {
|
||||
void Actor::freeList() {
|
||||
int i;
|
||||
ActorData *actor;
|
||||
for (i = 0; i < _actorsCount; i++) {
|
||||
actor = _actors[i];
|
||||
delete actor;
|
||||
}
|
||||
free(_actors);
|
||||
_actors = NULL;
|
||||
_actorsCount = 0;
|
||||
}
|
||||
|
||||
void Actor::loadList(int actorsEntrance, int actorCount, int actorsResourceID, int protagStatesCount, int protagStatesResourceID) {
|
||||
int i;
|
||||
ActorData *actor;
|
||||
byte* actorListData;
|
||||
size_t actorListLength;
|
||||
freeList();
|
||||
|
||||
_vm->_resource->loadResource(_actorContext, actorsResourceID, actorListData, actorListLength);
|
||||
|
||||
MemoryReadStream actorS(actorListData, actorListLength);
|
||||
_actorsCount = actorListLength / ACTOR_INHM_SIZE;
|
||||
|
||||
_actors = (ActorData **)malloc(_actorsCount * sizeof(*_actors));
|
||||
for (i = 0; i < _actorsCount; i++) {
|
||||
actor = _actors[i] = new ActorData();
|
||||
actor->id = actorIndexToId(i);
|
||||
actor->index = i;
|
||||
debug(9, "init actor id=%d index=%d", actor->id, actor->index);
|
||||
actorS.readUint32LE(); //next displayed
|
||||
actorS.readByte(); //type
|
||||
actor->flags = actorS.readByte();
|
||||
actor->nameIndex = actorS.readUint16LE();
|
||||
actor->sceneNumber = actorS.readUint32LE();
|
||||
actor->location.fromStream(actorS);
|
||||
actor->screenPosition.x = actorS.readUint16LE();
|
||||
actor->screenPosition.y = actorS.readUint16LE();
|
||||
actor->screenScale = actorS.readUint16LE();
|
||||
actor->screenDepth = actorS.readUint16LE();
|
||||
actor->frameListResourceId = actorS.readUint32LE();
|
||||
actor->spriteListResourceId = actorS.readUint32LE();
|
||||
actor->scriptEntrypointNumber = actorS.readUint32LE();
|
||||
actorS.readByte();
|
||||
actorS.readByte();
|
||||
actorS.readByte();
|
||||
actorS.readByte();
|
||||
actorS.readUint16LE(); //LEFT
|
||||
actorS.readUint16LE(); //RIGHT
|
||||
actorS.readUint16LE(); //TOP
|
||||
actorS.readUint16LE(); //BOTTOM
|
||||
actor->speechColor = actorS.readByte();
|
||||
actor->currentAction = actorS.readByte();
|
||||
actor->facingDirection = actorS.readByte();
|
||||
actor->actionDirection = actorS.readByte();
|
||||
actor->actionCycle = actorS.readUint16LE();
|
||||
actor->frameNumber = actorS.readUint16LE();
|
||||
actor->finalTarget.fromStream(actorS);
|
||||
actor->partialTarget.fromStream(actorS);
|
||||
actorS.readUint16LE(); //movement speed
|
||||
actorS.seek(128, SEEK_CUR);
|
||||
actorS.readByte();//walkStepIndex
|
||||
actorS.readByte();//walkStepCount
|
||||
actorS.readUint32LE(); //sprites
|
||||
actorS.readUint32LE(); //frames
|
||||
actorS.readUint32LE(); //last zone
|
||||
actor->targetObject = actorS.readUint16LE();
|
||||
actor->actorFlags = actorS.readUint16LE();
|
||||
actorS.readUint32LE(); //next in scene
|
||||
actorS.seek(6, SEEK_CUR); //action vars
|
||||
}
|
||||
free(actorListData);
|
||||
|
||||
for (i = 0; i < _actorsCount; i++) {
|
||||
actor = _actors[i];
|
||||
if (actor->flags & kExtended) {
|
||||
actor->disabled = !loadActorResources(actor);
|
||||
if (actor->disabled) {
|
||||
warning("Disabling actor Id=%d index=%d", actor->id, actor->index);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: protagonist stuff
|
||||
}
|
||||
|
||||
void Actor::takeExit(uint16 actorId, const HitZone *hitZone) {
|
||||
|
|
|
@ -72,6 +72,8 @@ class HitZone;
|
|||
|
||||
#define PATH_NODE_EMPTY -1
|
||||
|
||||
#define ACTOR_INHM_SIZE 228
|
||||
|
||||
enum ActorActions {
|
||||
kActionWait = 0,
|
||||
kActionWalkToPoint = 1,
|
||||
|
@ -227,6 +229,11 @@ struct Location {
|
|||
screenPoint.x = x / ACTOR_LMULT;
|
||||
screenPoint.y = y / ACTOR_LMULT - z;
|
||||
}
|
||||
void fromStream(Common::MemoryReadStream &stream) {
|
||||
x = stream.readUint16LE();
|
||||
y = stream.readUint16LE();
|
||||
z = stream.readUint16LE();
|
||||
}
|
||||
};
|
||||
|
||||
class CommonObjectData {
|
||||
|
@ -572,6 +579,7 @@ public:
|
|||
void setProtagState(int state);
|
||||
int getProtagState() { return _protagState; }
|
||||
|
||||
void freeList();
|
||||
void loadList(int actorsEntrance, int actorCount, int actorsResourceID,
|
||||
int protagStatesCount, int protagStatesResourceID);
|
||||
|
||||
|
|
|
@ -80,10 +80,10 @@ SceneDescription IHNM_IntroMovie4Desc = {
|
|||
};
|
||||
|
||||
LoadSceneParams IHNM_IntroList[] = {
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, -1},
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc2, false, kTransitionNoFade, 0, -1},
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie3Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, -1},
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie4Desc, Scene::SC_IHNMHateProc, false, kTransitionNoFade, 0, -1}
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc2, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie3Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{0, kLoadByDescription, &IHNM_IntroMovie4Desc, Scene::SC_IHNMHateProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}
|
||||
};
|
||||
|
||||
int Scene::IHNMStartProc() {
|
||||
|
@ -105,7 +105,7 @@ int Scene::IHNMStartProc() {
|
|||
firstScene.sceneProc = NULL;
|
||||
firstScene.transitionType = kTransitionFade;
|
||||
firstScene.actorsEntrance = 0;
|
||||
firstScene.chapter = 0;
|
||||
firstScene.chapter = -1;
|
||||
|
||||
_vm->_scene->queueScene(&firstScene);
|
||||
|
||||
|
|
|
@ -45,15 +45,15 @@ using Common::EN_USA;
|
|||
using Common::DE_DEU;
|
||||
|
||||
LoadSceneParams ITE_IntroList[] = {
|
||||
{RID_ITE_INTRO_ANIM_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroAnimProc, false, kTransitionNoFade, 0, -1},
|
||||
{RID_ITE_CAVE_SCENE_1, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave1Proc, false, kTransitionFade, 0, -1},
|
||||
{RID_ITE_CAVE_SCENE_2, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave2Proc, false, kTransitionNoFade, 0, -1},
|
||||
{RID_ITE_CAVE_SCENE_3, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave3Proc, false, kTransitionNoFade, 0, -1},
|
||||
{RID_ITE_CAVE_SCENE_4, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave4Proc, false, kTransitionNoFade, 0, -1},
|
||||
{RID_ITE_VALLEY_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroValleyProc, false, kTransitionFade, 0, -1},
|
||||
{RID_ITE_TREEHOUSE_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroTreeHouseProc, false, kTransitionNoFade, 0, -1},
|
||||
{RID_ITE_FAIREPATH_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFairePathProc, false, kTransitionNoFade, 0, -1},
|
||||
{RID_ITE_FAIRETENT_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFaireTentProc, false, kTransitionNoFade, 0, -1}
|
||||
{RID_ITE_INTRO_ANIM_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroAnimProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_CAVE_SCENE_1, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave1Proc, false, kTransitionFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_CAVE_SCENE_2, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave2Proc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_CAVE_SCENE_3, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave3Proc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_CAVE_SCENE_4, kLoadByResourceId, NULL, Scene::SC_ITEIntroCave4Proc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_VALLEY_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroValleyProc, false, kTransitionFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_TREEHOUSE_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroTreeHouseProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_FAIREPATH_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFairePathProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE},
|
||||
{RID_ITE_FAIRETENT_SCENE, kLoadByResourceId, NULL, Scene::SC_ITEIntroFaireTentProc, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}
|
||||
};
|
||||
|
||||
int Scene::ITEStartProc() {
|
||||
|
|
|
@ -447,6 +447,9 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) {
|
|||
_vm->_resource->loadResource(resourceContext, metaResourceTable[chapter],
|
||||
resourcePointer, resourceLength);
|
||||
|
||||
if (resourceLength == 0) {
|
||||
error("Resource::loadGlobalResources wrong resource");
|
||||
}
|
||||
MemoryReadStream metaS(resourcePointer, resourceLength);
|
||||
|
||||
_metaResource.sceneIndex = metaS.readSint16LE();
|
||||
|
|
|
@ -597,7 +597,7 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) {
|
|||
EVENT *q_event;
|
||||
static PalEntry current_pal[PAL_ENTRIES];
|
||||
|
||||
if (loadSceneParams->chapter != -1) {
|
||||
if ((_vm->getGameType() == GType_IHNM) && (loadSceneParams->chapter != NO_CHAPTER_CHANGE)) {
|
||||
if (loadSceneParams->loadFlag != kLoadBySceneNumber) {
|
||||
error("loadScene wrong usage");
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace Saga {
|
|||
|
||||
#define SCENE_DOORS_MAX 16
|
||||
|
||||
#define NO_CHAPTER_CHANGE -2
|
||||
|
||||
class ObjectMap;
|
||||
|
||||
struct EVENT;
|
||||
|
@ -248,7 +250,7 @@ class Scene {
|
|||
void clearSceneQueue(void) {
|
||||
_sceneQueue.clear();
|
||||
}
|
||||
void changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter = -1);
|
||||
void changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionType transitionType, int chapter = NO_CHAPTER_CHANGE);
|
||||
void freeCutawayList();
|
||||
|
||||
bool isSceneLoaded() const { return _sceneLoaded; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue