NANCY: Add ActionRecord and Scene debug channels

Added debug channels for action records and scenes, and added proper output to their respective loading functions.
This commit is contained in:
fracturehill 2021-03-02 01:48:02 +02:00 committed by Eugene Sandulenko
parent 74b045bd52
commit 145d5fd735
17 changed files with 222 additions and 23 deletions

View file

@ -147,6 +147,80 @@ bool ActionManager::addNewActionRecord(Common::SeekableReadStream &inputData) {
}
_records.push_back(newRecord);
debugC(1, kDebugActionRecord, "Loaded action record %i, type %s, typeID %i, description \"%s\", execType == %s",
_records.size() - 1,
newRecord->getRecordTypeName().c_str(),
newRecord->type,
newRecord->description.c_str(),
newRecord->execType == ActionRecord::kRepeating ? "kRepeating" : "kOneShot");
for (uint i = 0; i < newRecord->dependencies.size(); ++i) {
debugCN(1, kDebugActionRecord, "\tDependency %i: type ", i);
switch (newRecord->dependencies[i].type) {
case kNone :debugCN(1, kDebugActionRecord, "kNone"); break;
case kInventory :
debugCN(1, kDebugActionRecord, "kInventory, item ID %i %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "is in possession" : "is not in possession");
break;
case kEventFlag :
debugCN(1, kDebugActionRecord, "kEventFlag, flag ID %i == %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "true" : "false");
break;
case kLogicCondition :
debugCN(1, kDebugActionRecord, "kLogicCondition, logic condition ID %i == %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "true" : "false");
break;
case kTotalTime :
debugCN(1, kDebugActionRecord, "kTotalTime, %i hours, %i minutes, %i seconds, %i milliseconds",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].minutes,
newRecord->dependencies[i].seconds,
newRecord->dependencies[i].milliseconds);
break;
case kSceneTime :
debugCN(1, kDebugActionRecord, "kSceneTime, %i hours, %i minutes, %i seconds, %i milliseconds",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].minutes,
newRecord->dependencies[i].seconds,
newRecord->dependencies[i].milliseconds);
break;
case kPlayerTime :
debugCN(1, kDebugActionRecord, "kPlayerTime, %i days, %i hours, %i minutes, %i seconds",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].minutes,
newRecord->dependencies[i].seconds,
newRecord->dependencies[i].milliseconds);
break;
case kSceneCount :
debugCN(1, kDebugActionRecord, "kSceneCount, scene ID %i, hit count %s %i",
newRecord->dependencies[i].hours,
newRecord->dependencies[i].milliseconds == 1 ? ">" : newRecord->dependencies[i].milliseconds == 2 ? "<" : "==",
newRecord->dependencies[i].seconds);
break;
case kResetOnNewDay : debugCN(1, kDebugActionRecord, "kResetOnNewDay"); break;
case kUseItem :
debugCN(1, kDebugActionRecord, "kUseItem, item ID %i %s",
newRecord->dependencies[i].label,
newRecord->dependencies[i].condition == kTrue ? "is held" : "is not held");
break;
case kTimeOfDay :
debugCN(1, kDebugActionRecord, "kTimeOfDay, %s",
newRecord->dependencies[i].label == 0 ? "day" : newRecord->dependencies[i].label == 1 ? "night" : "dusk/dawn");
break;
case kTimerNotDone : debugCN(1, kDebugActionRecord, "kTimerNotDone"); break;
case kTimerDone : debugCN(1, kDebugActionRecord, "kTimerDone"); break;
case kDifficultyLevel :
debugCN(1, kDebugActionRecord, "kDifficultyLevel, level %i", newRecord->dependencies[i].condition);
break;
default: debugCN(1, kDebugActionRecord, "unknown"); break;
}
debugC(1, kDebugActionRecord, ", orFlag == %s", newRecord->dependencies[i].orFlag == true ? "true" : "false");
}
return true;
}

View file

@ -128,6 +128,9 @@ protected:
}
}
// Used for debugging
virtual Common::String getRecordTypeName() const =0;
public:
Common::String description; // 0x00
byte type; // 0x30

View file

@ -63,9 +63,9 @@ ActionRecord *ActionManager::createActionRecord(uint16 type) {
case 0x28:
return new PlayPrimaryVideoChan0(_engine->scene->getViewport());
case 0x29:
return new PlaySecondaryVideo(_engine->scene->getViewport());
return new PlaySecondaryVideo('0', _engine->scene->getViewport());
case 0x2A:
return new PlaySecondaryVideo(_engine->scene->getViewport());
return new PlaySecondaryVideo('1', _engine->scene->getViewport());
case 0x2B:
return new PlaySecondaryMovie(_engine->scene->getViewport());
case 0x2C:

View file

@ -69,6 +69,8 @@ public:
SolveState solveState = kNotSolved;
protected:
virtual Common::String getRecordTypeName() const override { return "LeverPuzzle"; }
virtual uint16 getZOrder() const override { return 7; }
virtual BlitType getBlitType() const override { return kTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -70,6 +70,8 @@ public:
Time solveSoundPlayTime;
protected:
virtual Common::String getRecordTypeName() const override { return "OrderingPuzzle"; }
virtual uint16 getZOrder() const override { return 7; }
virtual BlitType getBlitType() const override { return kTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -76,6 +76,8 @@ public:
SolveState solveState;
protected:
virtual Common::String getRecordTypeName() const override { return "PasswordPuzzle"; }
virtual uint16 getZOrder() const override { return 7; }
virtual BlitType getBlitType() const override { return kTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -114,6 +114,8 @@ public:
static PlayPrimaryVideoChan0 *activePrimaryVideo;
protected:
virtual Common::String getRecordTypeName() const override { return "PlayPrimaryVideoChan0"; }
virtual uint16 getZOrder() const override { return 8; }
virtual BlitType getBlitType() const override { return kNoTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -45,6 +45,9 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
SceneChangeDescription sceneChange;
protected:
virtual Common::String getRecordTypeName() const override { return "SceneChange"; }
};
class HotMultiframeSceneChange : public SceneChange {
@ -53,6 +56,9 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
Common::Array<HotspotDescription> hotspots;
protected:
virtual Common::String getRecordTypeName() const override { return "HotMultiframeSceneChange"; }
};
class Hot1FrSceneChange : public SceneChange {
@ -61,20 +67,32 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
HotspotDescription hotspotDesc;
protected:
virtual Common::String getRecordTypeName() const override { return "Hot1FrSceneChange"; }
};
class Hot1FrExitSceneChange : public Hot1FrSceneChange {
virtual CursorManager::CursorType getHoverCursor() const override { return CursorManager::kExitArrow; }
protected:
virtual Common::String getRecordTypeName() const override { return "Hot1FrExitSceneChange"; }
};
class HotMultiframeMultisceneChange : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "HotMultiframeMultisceneChange"; }
};
class StartFrameNextScene : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "StartFrameNextScene"; }
};
class StartStopPlayerScrolling : public ActionRecord {
@ -83,6 +101,9 @@ public:
// TODO add a Start and Stop subclass
byte type = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "StartStopPlayerScrolling"; }
};
class MapCall : public ActionRecord {
@ -91,6 +112,9 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
virtual CursorManager::CursorType getHoverCursor() const override { return CursorManager::kExitArrow; }
protected:
virtual Common::String getRecordTypeName() const override { return "MapCall"; }
};
class MapCallHot1Fr : public MapCall {
@ -99,6 +123,9 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
HotspotDescription hotspotDesc;
protected:
virtual Common::String getRecordTypeName() const override { return "MapCallHot1Fr"; }
};
class MapCallHotMultiframe : public MapCall {
@ -107,21 +134,33 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
Common::Array<HotspotDescription> hotspots;
protected:
virtual Common::String getRecordTypeName() const override { return "MapCallHotMultiframe"; }
};
class MapLocationAccess : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "MapLocationAccess"; }
};
class MapSound : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "MapSound"; }
};
class MapAviOverride : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "MapAviOverride"; }
};
class MapAviOverrideOff : public ActionRecord {
@ -129,11 +168,17 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte overrideOffData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "MapAviOverrideOff"; }
};
class TextBoxWrite : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "TextBoxWrite"; }
};
class TextBoxClear : public ActionRecord {
@ -141,11 +186,17 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte clearData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "TextBoxClear"; }
};
class BumpPlayerClock : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "BumpPlayerClock"; }
};
class SaveContinueGame : public ActionRecord {
@ -153,6 +204,9 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte saveContinueData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "SaveContinueGame"; }
};
class TurnOffMainRendering : public ActionRecord {
@ -160,6 +214,9 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte turnOffData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "TurnOffMainRendering"; }
};
class TurnOnMainRendering : public ActionRecord {
@ -167,18 +224,27 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte turnOnData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "TurnOnMainRendering"; }
};
class ResetAndStartTimer : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
virtual void execute(Nancy::NancyEngine *engine) override;
protected:
virtual Common::String getRecordTypeName() const override { return "ResetAndStartTimer"; }
};
class StopTimer : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
virtual void execute(Nancy::NancyEngine *engine) override;
protected:
virtual Common::String getRecordTypeName() const override { return "StopTimer"; }
};
class EventFlags : public ActionRecord {
@ -187,6 +253,9 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
MultiEventFlagDescription flags;
protected:
virtual Common::String getRecordTypeName() const override { return "EventFlags"; }
};
class EventFlagsMultiHS : public EventFlags {
@ -195,6 +264,9 @@ public:
virtual void execute(Nancy::NancyEngine *engine) override;
Common::Array<HotspotDescription> hotspots;
protected:
virtual Common::String getRecordTypeName() const override { return "EventFlagsMultiHS"; }
};
class LoseGame : public ActionRecord {
@ -202,6 +274,9 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte loseData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "LoseGame"; }
};
class PushScene : public ActionRecord {
@ -209,6 +284,9 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte pushData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "PushScene"; }
};
class PopScene : public ActionRecord {
@ -216,6 +294,9 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte popData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "PopScene"; }
};
class WinGame : public ActionRecord {
@ -223,16 +304,25 @@ public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
byte winData = 0;
protected:
virtual Common::String getRecordTypeName() const override { return "WinGame"; }
};
class AddInventoryNoHS : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "AddInventoryNoHS"; }
};
class RemoveInventoryNoHS : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "RemoveInventoryNoHS"; }
};
class DifficultyLevel : public ActionRecord {
@ -242,6 +332,9 @@ public:
uint16 difficulty = 0;
EventFlagDescription flag;
protected:
virtual Common::String getRecordTypeName() const override { return "DifficultyLevel"; }
};
class ShowInventoryItem : public ActionRecord, public RenderObject {
@ -262,6 +355,8 @@ public:
Graphics::ManagedSurface _fullSurface;
protected:
virtual Common::String getRecordTypeName() const override { return "ShowInventoryItem"; }
virtual uint16 getZOrder() const override { return 9; }
virtual BlitType getBlitType() const override { return kNoTrans; }
virtual bool isViewportRelative() const override { return true; }
@ -276,11 +371,17 @@ public:
SoundDescription sound;
SceneChangeDescription sceneChange;
EventFlagDescription flagOnTrigger;
protected:
virtual Common::String getRecordTypeName() const override { return "PlayDigiSoundAndDie"; }
};
class PlaySoundPanFrameAnchorAndDie : public ActionRecord {
public:
virtual uint16 readData(Common::SeekableReadStream &stream) override;
protected:
virtual Common::String getRecordTypeName() const override { return "PlaySoundPanFrameAnchorAndDie"; }
};
class PlaySoundMultiHS : public ActionRecord {
@ -292,6 +393,9 @@ public:
SceneChangeDescription sceneChange; // 0x22
EventFlagDescription flag; // 0x2A
Common::Array<HotspotDescription> hotspots; // 0x31
protected:
virtual Common::String getRecordTypeName() const override { return "PlaySoundMultiHS"; }
};
class HintSystem : public ActionRecord {
@ -309,6 +413,9 @@ public:
void selectHint(Nancy::NancyEngine *engine);
void getHint(uint hint, uint difficulty);
protected:
virtual Common::String getRecordTypeName() const override { return "HintSystem"; }
};
} // End of namespace Action

View file

@ -71,6 +71,8 @@ public:
protected:
virtual Common::String getRecordTypeName() const override { return "RotatingLockPuzzle"; }
virtual uint16 getZOrder() const override { return 7; }
virtual BlitType getBlitType() const override { return kTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -50,7 +50,7 @@ class PlaySecondaryVideo : public ActionRecord, public RenderObject {
public:
enum HoverState { kNoHover, kHover, kEndHover };
PlaySecondaryVideo(RenderObject &redrawFrom) : RenderObject(redrawFrom) {}
PlaySecondaryVideo(char chan, RenderObject &redrawFrom) : RenderObject(redrawFrom), channel(chan) {}
virtual ~PlaySecondaryVideo() { _decoder.close(); }
virtual void init() override;
@ -74,6 +74,8 @@ public:
Common::Array<SecondaryVideoDesc> videoDescs; // 0x35
protected:
virtual Common::String getRecordTypeName() const override { return Common::String("PlaySecondaryVideoChan" + channel); }
virtual uint16 getZOrder() const override { return 8; }
virtual BlitType getBlitType() const override { return kTrans; }
virtual bool isViewportRelative() const override { return true; }
@ -83,6 +85,8 @@ protected:
int _currentViewportFrame = -1;
bool _isPlaying = false;
bool _isHovered = false;
char channel;
};
class PlaySecondaryMovie : public ActionRecord, public RenderObject {
@ -113,6 +117,8 @@ public:
Common::Array<SecondaryVideoDesc> videoDescs; // 0xD4
protected:
virtual Common::String getRecordTypeName() const override { return "PlaySecondaryMovie"; }
virtual uint16 getZOrder() const override { return 8; }
virtual BlitType getBlitType() const override { return kNoTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -70,6 +70,8 @@ public:
static bool playerHasTriedPuzzle;
protected:
virtual Common::String getRecordTypeName() const override { return "SliderPuzzle"; }
virtual uint16 getZOrder() const override { return 7; }
virtual BlitType getBlitType() const override { return kTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -77,6 +77,8 @@ public:
bool isInterruptible;
protected:
virtual Common::String getRecordTypeName() const override { return isInterruptible ? "PlayIntStaticBitmapAnimation" : "PlayStaticBitmapAnimation"; }
virtual uint16 getZOrder() const override { return zOrder; }
virtual BlitType getBlitType() const override { return isTransparent == kTrue ? kTrans : kNoTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -88,6 +88,8 @@ public:
uint selected;
protected:
virtual Common::String getRecordTypeName() const override { return "Telephone"; }
virtual uint16 getZOrder() const override { return 7; }
virtual BlitType getBlitType() const override { return kTrans; }
virtual bool isViewportRelative() const override { return true; }

View file

@ -61,16 +61,9 @@ NancyEngine::NancyEngine(OSystem *syst, const NancyGameDescription *gd) :
{
_system = syst;
DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level");
DebugMan.addDebugChannel(kDebugEngine, "Engine", "Engine debug level");
DebugMan.addDebugChannel(kDebugDisplay, "Display", "Display debug level");
DebugMan.addDebugChannel(kDebugMouse, "Mouse", "Mouse debug level");
DebugMan.addDebugChannel(kDebugParser, "Parser", "Parser debug level");
DebugMan.addDebugChannel(kDebugFile, "File", "File IO debug level");
DebugMan.addDebugChannel(kDebugRoute, "Route", "Route debug level");
DebugMan.addDebugChannel(kDebugInventory, "Inventory", "Inventory debug level");
DebugMan.addDebugChannel(kDebugObject, "Object", "Object debug level");
DebugMan.addDebugChannel(kDebugMusic, "Music", "Music debug level");
DebugMan.addDebugChannel(kDebugActionRecord, "ActionRecord", "Action Record debug level");
DebugMan.addDebugChannel(kDebugScene, "Scene", "Scene debug level");
_console = new NancyConsole(this);
_rnd = new Common::RandomSource("Nancy");

View file

@ -49,16 +49,9 @@ namespace Nancy {
static const int kSavegameVersion = 1;
enum NancyDebugChannels {
kDebugSchedule = 1 << 0,
kDebugEngine = 1 << 1,
kDebugDisplay = 1 << 2,
kDebugMouse = 1 << 3,
kDebugParser = 1 << 4,
kDebugFile = 1 << 5,
kDebugRoute = 1 << 6,
kDebugInventory = 1 << 7,
kDebugObject = 1 << 8,
kDebugMusic = 1 << 9
kDebugEngine = 1 << 0,
kDebugActionRecord = 1 << 1,
kDebugScene = 1 << 2
};
struct NancyGameDescription;

View file

@ -194,6 +194,13 @@ void Scene::load() {
readSceneSummary(*sceneSummaryChunk);
debugC(0, kDebugScene, "Loading new scene %i: description \"%s\", frame %i, vertical scroll %i, doNotStartSound == %s",
_sceneState.nextScene.sceneID,
_sceneState.summary.description.c_str(),
_sceneState.nextScene.frameID,
_sceneState.nextScene.verticalOffset,
_sceneState._doNotStartSound == true ? "true" : "false");
// Search for Action Records, maximum for a scene is 30
Common::SeekableReadStream *actionRecordChunk = nullptr;

View file

@ -189,7 +189,7 @@ protected:
};
struct Timers {
enum TimeOfDay { kDay, kNight, kDuskDawn };
enum TimeOfDay { kDay = 0, kNight = 1, kDuskDawn = 2 };
Time tickCount;
Time pushedPlayTime;