[Scummvm-git-logs] scummvm branch-2-3 -> 14786606c7658701e59982edaabda3e1a3463fc3
dreammaster
dreammaster at scummvm.org
Wed Sep 29 03:18:28 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
14786606c7 AGS: SetObjectFrame fallback to dummy frame in an empty loop
Commit: 14786606c7658701e59982edaabda3e1a3463fc3
https://github.com/scummvm/scummvm/commit/14786606c7658701e59982edaabda3e1a3463fc3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-09-28T20:18:15-07:00
Commit Message:
AGS: SetObjectFrame fallback to dummy frame in an empty loop
>From upstream 1496f7f6419d192bd4060956492e8897678035c9
Changed paths:
engines/ags/engine/ac/global_object.cpp
engines/ags/engine/ac/object.cpp
diff --git a/engines/ags/engine/ac/global_object.cpp b/engines/ags/engine/ac/global_object.cpp
index 39e424ef3d..0f80853e35 100644
--- a/engines/ags/engine/ac/global_object.cpp
+++ b/engines/ags/engine/ac/global_object.cpp
@@ -155,14 +155,14 @@ void SetObjectFrame(int obn, int viw, int lop, int fra) {
viw--;
if (viw < 0 || viw >= _GP(game).numviews) quitprintf("!SetObjectFrame: invalid view number used (%d, range is 0 - %d)", viw, _GP(game).numviews - 1);
if (lop < 0 || lop >= _G(views)[viw].numLoops) quitprintf("!SetObjectFrame: invalid loop number used (%d, range is 0 - %d)", lop, _G(views)[viw].numLoops - 1);
- // AGS < 3.6.0 let user to pass literally any positive invalid frame value by silently reassigning it to zero...
- if (_GP(game).options[OPT_BASESCRIPTAPI] < kScriptAPI_v360) {
- if (fra >= _G(views)[viw].loops[lop].numFrames) {
+ // historically AGS let user to pass literally any positive invalid frame value by silently reassigning it to zero...
+ if (fra < 0 || fra >= _G(views)[viw].loops[lop].numFrames) {
+ if (_G(views)[viw].loops[lop].numFrames == 0) // NOTE: we have a dummy frame allocated for this case
+ debug_script_warn("SetObjectFrame: specified loop %d has no frames, will fallback to dummy frame", lop);
+ else
debug_script_warn("SetObjectFrame: frame index out of range (%d, must be 0 - %d), set to 0", fra, _G(views)[viw].loops[lop].numFrames - 1);
- fra = 0;
- }
+ fra = 0;
}
- if (fra < 0 || fra >= _G(views)[viw].loops[lop].numFrames) quitprintf("!SetObjectFrame: invalid frame number used (%d, range is 0 - %d)", fra, _G(views)[viw].loops[lop].numFrames - 1);
if (viw > UINT16_MAX || lop > UINT16_MAX || fra > UINT16_MAX) {
debug_script_warn("Warning: object's (id %d) view/loop/frame (%d/%d/%d) is outside of internal range (%d/%d/%d), reset to no view",
obn, viw + 1, lop, fra, UINT16_MAX + 1, UINT16_MAX, UINT16_MAX);
@@ -175,12 +175,7 @@ void SetObjectFrame(int obn, int viw, int lop, int fra) {
_G(objs)[obn].loop = (uint16_t)lop;
if (fra >= 0)
_G(objs)[obn].frame = (uint16_t)fra;
- // AGS >= 3.2.0 do not let assign an empty loop
- // NOTE: pre-3.2.0 games are converting views from ViewStruct272 struct, always has at least 1 frame
- if (_G(loaded_game_file_version) >= kGameVersion_320) {
- if (_G(views)[viw].loops[lop].numFrames == 0)
- quit("!SetObjectFrame: specified loop has no frames");
- }
+
_G(objs)[obn].view = viw;
_G(objs)[obn].loop = lop;
_G(objs)[obn].frame = fra;
diff --git a/engines/ags/engine/ac/object.cpp b/engines/ags/engine/ac/object.cpp
index 90b9cf0de8..938d40298b 100644
--- a/engines/ags/engine/ac/object.cpp
+++ b/engines/ags/engine/ac/object.cpp
@@ -94,8 +94,8 @@ void Object_SetView(ScriptObject *objj, int view, int loop, int frame) {
if (frame < 0) frame = obj.frame;
const int vidx = view - 1;
if (vidx < 0 || vidx >= _GP(game).numviews) quit("!Object_SetView: invalid view number used");
- loop = CLIP(loop, 0, (int)_G(views)[vidx].numLoops - 1);
- frame = CLIP(frame, 0, (int)_G(views)[vidx].loops[loop].numFrames - 1);
+ loop = Math::Clamp(loop, 0, (int)_G(views)[vidx].numLoops - 1);
+ frame = Math::Clamp(frame, 0, (int)_G(views)[vidx].loops[loop].numFrames - 1);
}
SetObjectFrame(objj->id, view, loop, frame);
More information about the Scummvm-git-logs
mailing list