[Scummvm-git-logs] scummvm master -> 05853de65c50172b9f4379476b999b6b3f952d53
mduggan
mgithub at guarana.org
Fri Jan 1 06:12:26 UTC 2021
This automated email contains information about 16 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
96c62ee08b NUVIE: Small cleanup in use of array functions
cb8228e69e CONFIGURE: Correct typo in message
05e1d42702 CREATE-PROJECT: Better defaults for xcode
f64c621a20 ULTIMA8: Update Crusader camera on teleport
a41ceb29bd ULTIMA8: Fix save/load of Crusader gumps and processes
e3a4ee8dc3 ULTIMA8: Add extra sanity assertions on loading/saving
cdff1c5021 ULTIMA8: Use default ScummVM save/load dialogs for Crusader
5e4bdbb0b8 ULTIMA8: Small pathfinding optimizations
a70153fdd0 ULTIMA8: Add smooth Crusader turning.
259dd1031d ULTIMA8: Name keys correctly for Crusader
7d7cd0ee0b ULTIMA8: Fix parameter type and bitmask for AAF_ROTATED flag
686a11c721 ULTIMA8: Support Crusader combat slides and rolls
835803e269 ULTIMA8: Put crusader crosshair in correct position
d3000bc458 ULTIMA8: Correct ini file setting names set by debugger
74630555f0 ULTIMA8: Split kernel cycles from frame rate in a more consistent way
05853de65c ULTIMA8: Improve const correctness of rendering functions
Commit: 96c62ee08bba50546d7913271c8bf62a801cb929
https://github.com/scummvm/scummvm/commit/96c62ee08bba50546d7913271c8bf62a801cb929
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
NUVIE: Small cleanup in use of array functions
Changed paths:
engines/ultima/nuvie/pathfinder/seek_path.cpp
diff --git a/engines/ultima/nuvie/pathfinder/seek_path.cpp b/engines/ultima/nuvie/pathfinder/seek_path.cpp
index e9aa9c450e..2bf2c0a48f 100644
--- a/engines/ultima/nuvie/pathfinder/seek_path.cpp
+++ b/engines/ultima/nuvie/pathfinder/seek_path.cpp
@@ -29,7 +29,7 @@ namespace Nuvie {
using Std::vector;
-SeekPath::SeekPath() : A_scan(0), B_scan(0) {
+SeekPath::SeekPath() {
}
@@ -188,8 +188,8 @@ bool SeekPath::path_search(MapCoord &start, MapCoord &goal) {
}
void SeekPath::delete_nodes() {
- A_scan.resize(0);
- B_scan.resize(0);
+ A_scan.clear();
+ B_scan.clear();
}
} // End of namespace Nuvie
Commit: cb8228e69e18575e31b23fdd794945c2a8c1eb84
https://github.com/scummvm/scummvm/commit/cb8228e69e18575e31b23fdd794945c2a8c1eb84
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
CONFIGURE: Correct typo in message
Changed paths:
configure
diff --git a/configure b/configure
index 3ab8182c19..13901c4719 100755
--- a/configure
+++ b/configure
@@ -2905,7 +2905,7 @@ case $_host_os in
# Building with SDK 10.14+ causes blurry display on Retina screens.
# A workaround is to set the LC_VERSION_MIN_MACOSX load command's sdk value
# to n/a (i.e. 0.0). See bug #11430 for details.
- echocheck "macOS deployement target"
+ echocheck "macOS deployment target"
cat > $TMPC << EOF
#include "AvailabilityMacros.h"
Commit: 05e1d42702498138f09c3138ebcc7602d7f96901
https://github.com/scummvm/scummvm/commit/05e1d42702498138f09c3138ebcc7602d7f96901
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
CREATE-PROJECT: Better defaults for xcode
* Add DEBUG define to debug builds
* Set optimization -O3 on release builds
Changed paths:
devtools/create_project/xcode.cpp
diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index d924a82810..a175b1eb24 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -995,6 +995,7 @@ void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) {
REMOVE_DEFINE(scummvm_defines, "IPHONE_IOS7");
REMOVE_DEFINE(scummvm_defines, "IPHONE_SANDBOXED");
REMOVE_DEFINE(scummvm_defines, "SDL_BACKEND");
+ ADD_DEFINE(scummvm_defines, "DEBUG");
ADD_SETTING_LIST(scummvm_Debug, "GCC_PREPROCESSOR_DEFINITIONS", scummvm_defines, kSettingsNoQuote | kSettingsAsList, 5);
ADD_SETTING(scummvm_Debug, "GCC_WARN_ABOUT_RETURN_TYPE", "YES");
ADD_SETTING(scummvm_Debug, "GCC_WARN_UNUSED_VARIABLE", "YES");
@@ -1022,6 +1023,7 @@ void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) {
REMOVE_SETTING(scummvm_Release, "ENABLE_TESTABILITY");
REMOVE_SETTING(scummvm_Release, "GCC_PREPROCESSOR_DEFINITIONS");
ValueList scummvm_Release_defines(scummvm_defines);
+ REMOVE_DEFINE(scummvm_defines, "DEBUG");
ADD_DEFINE(scummvm_Release_defines, "RELEASE_BUILD");
ADD_SETTING_LIST(scummvm_Release, "GCC_PREPROCESSOR_DEFINITIONS", scummvm_Release_defines, kSettingsNoQuote | kSettingsAsList, 5);
@@ -1183,6 +1185,7 @@ void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) {
ADD_SETTING(scummvmOSX_Release, "COPY_PHASE_STRIP", "YES");
REMOVE_SETTING(scummvmOSX_Release, "GCC_DYNAMIC_NO_PIC");
REMOVE_SETTING(scummvmOSX_Release, "GCC_OPTIMIZATION_LEVEL");
+ ADD_SETTING(scummvmOSX_Release, "GCC_OPTIMIZATION_LEVEL", "3");
ADD_SETTING(scummvmOSX_Release, "WRAPPER_EXTENSION", "app");
REMOVE_SETTING(scummvmOSX_Release, "DEBUG_INFORMATION_FORMAT");
ADD_SETTING_QUOTE(scummvmOSX_Release, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym");
Commit: f64c621a20d3254358780102921645a3be562ba9
https://github.com/scummvm/scummvm/commit/f64c621a20d3254358780102921645a3be562ba9
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Update Crusader camera on teleport
Changed paths:
engines/ultima/ultima8/world/actors/main_actor.cpp
diff --git a/engines/ultima/ultima8/world/actors/main_actor.cpp b/engines/ultima/ultima8/world/actors/main_actor.cpp
index 8c2ec89785..c70f44522d 100644
--- a/engines/ultima/ultima8/world/actors/main_actor.cpp
+++ b/engines/ultima/ultima8/world/actors/main_actor.cpp
@@ -332,6 +332,12 @@ void MainActor::teleport(int mapNum, int32 x, int32 y, int32 z) {
}
Actor::teleport(mapNum, x, y, z);
+
+ if (GAME_IS_CRUSADER) {
+ // Keep the camera on the avatar (the snap process will update on next move)
+ CameraProcess::SetCameraProcess(new CameraProcess(x, y, z));
+ }
+
_justTeleported = true;
}
@@ -373,6 +379,12 @@ void MainActor::teleport(int mapNum, int teleport_id) {
egg->dumpInfo();
Actor::teleport(mapNum, xv, yv, zv);
+
+ if (GAME_IS_CRUSADER) {
+ // Keep the camera on the avatar (the snap process will update on next move)
+ CameraProcess::SetCameraProcess(new CameraProcess(xv, yv, zv));
+ }
+
_justTeleported = true;
}
Commit: a41ceb29bd73d97c27e91be11feeedd006073545
https://github.com/scummvm/scummvm/commit/a41ceb29bd73d97c27e91be11feeedd006073545
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Fix save/load of Crusader gumps and processes
Changed paths:
engines/ultima/ultima8/games/start_crusader_process.cpp
engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
engines/ultima/ultima8/gumps/cru_energy_gump.cpp
engines/ultima/ultima8/gumps/cru_health_gump.cpp
engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
engines/ultima/ultima8/gumps/cru_pickup_area_gump.cpp
engines/ultima/ultima8/gumps/cru_pickup_area_gump.h
engines/ultima/ultima8/gumps/cru_status_gump.cpp
engines/ultima/ultima8/gumps/cru_status_gump.h
engines/ultima/ultima8/gumps/cru_weapon_gump.cpp
engines/ultima/ultima8/gumps/cru_weapon_gump.h
engines/ultima/ultima8/gumps/translucent_gump.cpp
engines/ultima/ultima8/gumps/translucent_gump.h
engines/ultima/ultima8/kernel/object_manager.cpp
engines/ultima/ultima8/world/actors/attack_process.cpp
diff --git a/engines/ultima/ultima8/games/start_crusader_process.cpp b/engines/ultima/ultima8/games/start_crusader_process.cpp
index 1225babc01..7168e17077 100644
--- a/engines/ultima/ultima8/games/start_crusader_process.cpp
+++ b/engines/ultima/ultima8/games/start_crusader_process.cpp
@@ -74,10 +74,10 @@ void StartCrusaderProcess::run() {
}
}
- Gump *statusGump = new CruStatusGump();
+ Gump *statusGump = new CruStatusGump(true);
statusGump->InitGump(nullptr, false);
- Gump *cruPickupAreaGump = new CruPickupAreaGump();
+ Gump *cruPickupAreaGump = new CruPickupAreaGump(true);
cruPickupAreaGump->InitGump(nullptr, false);
// Try to load the save game, if succeeded this pointer will no longer be valid
diff --git a/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp b/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
index 998e971421..9afad1e54c 100644
--- a/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_ammo_gump.cpp
@@ -113,11 +113,11 @@ void CruAmmoGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
}
void CruAmmoGump::saveData(Common::WriteStream *ws) {
- Gump::saveData(ws);
+ CruStatGump::saveData(ws);
}
bool CruAmmoGump::loadData(Common::ReadStream *rs, uint32 version) {
- return Gump::loadData(rs, version);
+ return CruStatGump::loadData(rs, version);
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/gumps/cru_energy_gump.cpp b/engines/ultima/ultima8/gumps/cru_energy_gump.cpp
index 342486bd8c..8f0cbf5e2e 100644
--- a/engines/ultima/ultima8/gumps/cru_energy_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_energy_gump.cpp
@@ -70,11 +70,11 @@ void CruEnergyGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
}
void CruEnergyGump::saveData(Common::WriteStream *ws) {
- Gump::saveData(ws);
+ CruStatGump::saveData(ws);
}
bool CruEnergyGump::loadData(Common::ReadStream *rs, uint32 version) {
- return Gump::loadData(rs, version);
+ return CruStatGump::loadData(rs, version);
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/gumps/cru_health_gump.cpp b/engines/ultima/ultima8/gumps/cru_health_gump.cpp
index 1a457a5221..c2b1f30b6e 100644
--- a/engines/ultima/ultima8/gumps/cru_health_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_health_gump.cpp
@@ -72,11 +72,11 @@ void CruHealthGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
}
void CruHealthGump::saveData(Common::WriteStream *ws) {
- Gump::saveData(ws);
+ CruStatGump::saveData(ws);
}
bool CruHealthGump::loadData(Common::ReadStream *rs, uint32 version) {
- return Gump::loadData(rs, version);
+ return CruStatGump::loadData(rs, version);
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp b/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
index ce626f8951..a120c499b8 100644
--- a/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_inventory_gump.cpp
@@ -154,11 +154,11 @@ void CruInventoryGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool sc
}
void CruInventoryGump::saveData(Common::WriteStream *ws) {
- Gump::saveData(ws);
+ CruStatGump::saveData(ws);
}
bool CruInventoryGump::loadData(Common::ReadStream *rs, uint32 version) {
- return Gump::loadData(rs, version);
+ return CruStatGump::loadData(rs, version);
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/gumps/cru_pickup_area_gump.cpp b/engines/ultima/ultima8/gumps/cru_pickup_area_gump.cpp
index 0d607c1fb4..202df47ca8 100644
--- a/engines/ultima/ultima8/gumps/cru_pickup_area_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_pickup_area_gump.cpp
@@ -34,12 +34,23 @@ namespace Ultima8 {
static const int PICKUP_GUMP_GAP = 5;
static const int PICKUP_GUMP_HEIGHT = 30;
-CruPickupAreaGump *CruPickupAreaGump::_instance;
+CruPickupAreaGump *CruPickupAreaGump::_instance = nullptr;
DEFINE_RUNTIME_CLASSTYPE_CODE(CruPickupAreaGump)
-CruPickupAreaGump::CruPickupAreaGump() : Gump(PICKUP_GUMP_GAP, PICKUP_GUMP_GAP, 200, 500, 0) {
- _instance = this;
+CruPickupAreaGump::CruPickupAreaGump() : Gump() { }
+
+CruPickupAreaGump::CruPickupAreaGump(bool unused) : Gump(PICKUP_GUMP_GAP, PICKUP_GUMP_GAP, 200, 500, 0, 0, LAYER_ABOVE_NORMAL) {
+}
+
+CruPickupAreaGump::~CruPickupAreaGump() {
+ _instance = nullptr;
+}
+
+void CruPickupAreaGump::InitGump(Gump *newparent, bool take_focus) {
+ Gump::InitGump(newparent, take_focus);
+ assert(!_instance || _instance == this);
+ _instance = this;
}
void CruPickupAreaGump::addPickup(const Item *item) {
@@ -70,6 +81,21 @@ void CruPickupAreaGump::addPickup(const Item *item) {
}
}
+void CruPickupAreaGump::saveData(Common::WriteStream *ws) {
+ Gump::saveData(ws);
+}
+
+bool CruPickupAreaGump::loadData(Common::ReadStream *rs, uint32 version) {
+ if (!Gump::loadData(rs, version))
+ return false;
+
+ if (_instance && _instance != this)
+ delete _instance;
+ _instance = this;
+ return true;
+}
+
+
CruPickupAreaGump *CruPickupAreaGump::get_instance() {
return _instance;
}
diff --git a/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h b/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h
index 2138cbb334..bc5fbcb2c6 100644
--- a/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h
+++ b/engines/ultima/ultima8/gumps/cru_pickup_area_gump.h
@@ -39,8 +39,18 @@ class CruPickupAreaGump : public Gump {
public:
ENABLE_RUNTIME_CLASSTYPE()
+ // default constructor only for use when loading savegame
CruPickupAreaGump();
+ // Normal constructor
+ CruPickupAreaGump(bool unused);
+ ~CruPickupAreaGump();
+
+ void InitGump(Gump *newparent, bool take_focus = false) override;
+
+ bool loadData(Common::ReadStream *rs, uint32 version);
+ void saveData(Common::WriteStream *ws) override;
+
void addPickup(const Item *item);
static CruPickupAreaGump *get_instance();
diff --git a/engines/ultima/ultima8/gumps/cru_status_gump.cpp b/engines/ultima/ultima8/gumps/cru_status_gump.cpp
index 16ca66c029..a33c46b170 100644
--- a/engines/ultima/ultima8/gumps/cru_status_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_status_gump.cpp
@@ -49,17 +49,27 @@ static const int FRAME_GUMP_SHAPE = 1;
CruStatusGump *CruStatusGump::_instance = nullptr;
-CruStatusGump::CruStatusGump() : Gump() {
+CruStatusGump::CruStatusGump() : Gump() { }
+
+// Start with an approximate width/height which we will adjust later..
+CruStatusGump::CruStatusGump(bool unused) : Gump(PX_FROM_LEFT, PX_FROM_BOTTOM, 500, 100, 0, 0, LAYER_ABOVE_NORMAL) {
assert(!_instance);
_instance = this;
}
CruStatusGump::~CruStatusGump() {
+ assert(_instance == this);
+ _instance = nullptr;
}
void CruStatusGump::InitGump(Gump *newparent, bool take_focus) {
Gump::InitGump(newparent, take_focus);
+ createStatusItems();
+}
+
+void CruStatusGump::createStatusItems() {
+ assert(_children.size() == 0);
GumpShapeArchive *gumpshapes = GameData::get_instance()->getGumps();
if (!gumpshapes) {
warning("failed to init stats gump: no gump shape archive");
@@ -103,7 +113,12 @@ void CruStatusGump::saveData(Common::WriteStream *ws) {
}
bool CruStatusGump::loadData(Common::ReadStream *rs, uint32 version) {
- return Gump::loadData(rs, version);
+ if (Gump::loadData(rs, version)) {
+ createStatusItems();
+ return true;
+ } else {
+ return false;
+ }
}
uint32 CruStatusGump::I_hideStatusGump(const uint8 * /*args*/,
diff --git a/engines/ultima/ultima8/gumps/cru_status_gump.h b/engines/ultima/ultima8/gumps/cru_status_gump.h
index 02bde8049f..40003f5510 100644
--- a/engines/ultima/ultima8/gumps/cru_status_gump.h
+++ b/engines/ultima/ultima8/gumps/cru_status_gump.h
@@ -38,7 +38,12 @@ class CruStatusGump : public Gump {
public:
ENABLE_RUNTIME_CLASSTYPE()
+ // default constructor for save game loading
CruStatusGump();
+
+ // need a parameter to differentiate the non-default constructor..
+ CruStatusGump(bool unused);
+
~CruStatusGump() override;
// Init the gump, call after construction
@@ -50,6 +55,8 @@ public:
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;
+ void createStatusItems();
+
static CruStatusGump *get_instance() {
return _instance;
}
diff --git a/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp b/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp
index 36002447e1..bded985dea 100644
--- a/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp
+++ b/engines/ultima/ultima8/gumps/cru_weapon_gump.cpp
@@ -38,21 +38,12 @@ static const int WEAPON_GUMP_SHAPE = 3;
DEFINE_RUNTIME_CLASSTYPE_CODE(CruWeaponGump)
-CruWeaponGump::CruWeaponGump() : CruStatGump(), _weaponShape(nullptr),
- _weaponGump(nullptr) {
-
+CruWeaponGump::CruWeaponGump() : CruStatGump(), _weaponShape(nullptr) {
}
CruWeaponGump::CruWeaponGump(Shape *shape, int x)
- : CruStatGump(shape, x), _weaponShape(nullptr), _weaponGump(nullptr) {
+ : CruStatGump(shape, x), _weaponShape(nullptr) {
_frameNum = 0;
-}
-
-CruWeaponGump::~CruWeaponGump() {
-}
-
-void CruWeaponGump::InitGump(Gump *newparent, bool take_focus) {
- CruStatGump::InitGump(newparent, take_focus);
GumpShapeArchive *gumpshapes = GameData::get_instance()->getGumps();
if (!gumpshapes) {
@@ -65,11 +56,18 @@ void CruWeaponGump::InitGump(Gump *newparent, bool take_focus) {
warning("failed to init stat gump: no weapon shape");
return;
}
+}
- _weaponGump = new Gump();
- // We will fill out the shape to paint for this later.
- _weaponGump->InitGump(this, false);
+CruWeaponGump::~CruWeaponGump() {
+}
+void CruWeaponGump::InitGump(Gump *newparent, bool take_focus) {
+ CruStatGump::InitGump(newparent, take_focus);
+
+ // We will fill out the shape to paint for this later.
+ Gump *weaponGump = new Gump();
+ weaponGump->InitGump(this, false);
+ weaponGump->SetIndex(1);
}
void CruWeaponGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled) {
@@ -79,13 +77,15 @@ void CruWeaponGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
return;
}
+ Gump *weaponGump = _children.front();
+ assert(weaponGump);
uint16 active = a->getActiveWeapon();
if (!active) {
- _weaponGump->SetShape(0, 0);
+ weaponGump->SetShape(0, 0);
} else {
Item *item = getItem(active);
if (!item) {
- _weaponGump->SetShape(0, 0);
+ weaponGump->SetShape(0, 0);
} else {
WeaponInfo *weaponinfo = item->getShapeInfo()->_weaponInfo;
uint16 frameno = 0;
@@ -94,9 +94,9 @@ void CruWeaponGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
assert(WEAPON_GUMP_SHAPE == weaponinfo->_displayGumpShape);
frameno = weaponinfo->_displayGumpFrame;
}
- _weaponGump->SetShape(_weaponShape, frameno);
- _weaponGump->UpdateDimsFromShape();
- _weaponGump->setRelativePosition(CENTER);
+ weaponGump->SetShape(_weaponShape, frameno);
+ weaponGump->UpdateDimsFromShape();
+ weaponGump->setRelativePosition(CENTER);
}
}
diff --git a/engines/ultima/ultima8/gumps/cru_weapon_gump.h b/engines/ultima/ultima8/gumps/cru_weapon_gump.h
index eeb1db6090..414632608c 100644
--- a/engines/ultima/ultima8/gumps/cru_weapon_gump.h
+++ b/engines/ultima/ultima8/gumps/cru_weapon_gump.h
@@ -51,7 +51,6 @@ public:
private:
Shape *_weaponShape;
- Gump *_weaponGump;
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/gumps/translucent_gump.cpp b/engines/ultima/ultima8/gumps/translucent_gump.cpp
index c916ca328f..b359998e75 100644
--- a/engines/ultima/ultima8/gumps/translucent_gump.cpp
+++ b/engines/ultima/ultima8/gumps/translucent_gump.cpp
@@ -45,5 +45,13 @@ void TranslucentGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool sca
}
}
+void TranslucentGump::saveData(Common::WriteStream *ws) {
+ Gump::saveData(ws);
+}
+
+bool TranslucentGump::loadData(Common::ReadStream *rs, uint32 version) {
+ return Gump::loadData(rs, version);
+}
+
} // End of namespace Ultima8
} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/gumps/translucent_gump.h b/engines/ultima/ultima8/gumps/translucent_gump.h
index 748788ebe7..492673d089 100644
--- a/engines/ultima/ultima8/gumps/translucent_gump.h
+++ b/engines/ultima/ultima8/gumps/translucent_gump.h
@@ -43,6 +43,9 @@ public:
// Paint this Gump
void PaintThis(RenderSurface *, int32 lerp_factor, bool scaled) override;
+
+ bool loadData(Common::ReadStream *rs, uint32 version);
+ void saveData(Common::WriteStream *ws) override;
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/kernel/object_manager.cpp b/engines/ultima/ultima8/kernel/object_manager.cpp
index e753af4c73..6569a9736d 100644
--- a/engines/ultima/ultima8/kernel/object_manager.cpp
+++ b/engines/ultima/ultima8/kernel/object_manager.cpp
@@ -46,8 +46,10 @@
#include "ultima/ultima8/gumps/widgets/sliding_widget.h"
#include "ultima/ultima8/gumps/mini_stats_gump.h"
#include "ultima/ultima8/gumps/minimap_gump.h"
+#include "ultima/ultima8/gumps/cru_status_gump.h"
#include "ultima/ultima8/gumps/cru_pickup_gump.h"
#include "ultima/ultima8/gumps/cru_pickup_area_gump.h"
+#include "ultima/ultima8/gumps/translucent_gump.h"
namespace Ultima {
namespace Ultima8 {
@@ -100,7 +102,7 @@ void ObjectManager::reset() {
unsigned int i;
for (i = 0; i < _objects.size(); ++i) {
- if (_objects[i] == 0) continue;
+ if (_objects[i] == nullptr) continue;
#if 0
Item *item = dynamic_cast<Item *>(_objects[i]);
if (item && item->getParent()) continue; // will be deleted by parent
@@ -111,7 +113,7 @@ void ObjectManager::reset() {
}
for (i = 0; i < _objects.size(); ++i) {
- assert(_objects[i] == 0);
+ assert(_objects[i] == nullptr);
}
@@ -164,7 +166,7 @@ uint16 ObjectManager::assignObjId(Object *obj, ObjId new_objid) {
// failure???
if (new_objid != 0) {
- assert(_objects[new_objid] == 0);
+ assert(_objects[new_objid] == nullptr);
_objects[new_objid] = obj;
}
return new_objid;
@@ -257,6 +259,7 @@ bool ObjectManager::load(Common::ReadStream *rs, uint32 version) {
// top level gumps have to be added to the correct core gump
Gump *gump = dynamic_cast<Gump *>(obj);
if (gump) {
+ assert(gump->GetParent() == nullptr);
Ultima8Engine::get_instance()->addGump(gump);
}
@@ -280,13 +283,14 @@ bool ObjectManager::load(Common::ReadStream *rs, uint32 version) {
}
unsigned int count = 0;
for (unsigned int i = 1024; i < _objects.size(); i++) {
- if (_objects[i] == 0 && _objIDs->isIDUsed(i)) {
+ if (_objects[i] == nullptr && _objIDs->isIDUsed(i)) {
_objIDs->clearID(i);
count++;
}
}
pout << "Reclaimed " << count << " _objIDs on load." << Std::endl;
+ objectTypes();
return true;
}
@@ -371,8 +375,10 @@ void ObjectManager::setupLoaders() {
addObjectLoader("SlidingWidget", ObjectLoader<SlidingWidget>::load);
addObjectLoader("MiniStatsGump", ObjectLoader<MiniStatsGump>::load);
addObjectLoader("MiniMapGump", ObjectLoader<MiniMapGump>::load);
+ addObjectLoader("CruStatusGump", ObjectLoader<CruStatusGump>::load);
addObjectLoader("CruPickupAreaGump", ObjectLoader<CruPickupAreaGump>::load);
addObjectLoader("CruPickupGump", ObjectLoader<CruPickupGump>::load);
+ addObjectLoader("TranslucentGump", ObjectLoader<TranslucentGump>::load);
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/world/actors/attack_process.cpp b/engines/ultima/ultima8/world/actors/attack_process.cpp
index 645d051d35..5ca18a1728 100644
--- a/engines/ultima/ultima8/world/actors/attack_process.cpp
+++ b/engines/ultima/ultima8/world/actors/attack_process.cpp
@@ -977,6 +977,7 @@ bool AttackProcess::loadData(Common::ReadStream *rs, uint32 version) {
_target = rs->readUint16LE();
setTacticNo(rs->readUint16LE());
setBlockNo(rs->readUint16LE());
+ _tacticDatStartOffset = rs->readUint16LE();
_soundNo = rs->readUint16LE();
_playedStartSound = rs->readByte();
Commit: e3a4ee8dc3daf4b23516327bcb9f67dabcc1804e
https://github.com/scummvm/scummvm/commit/e3a4ee8dc3daf4b23516327bcb9f67dabcc1804e
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Add extra sanity assertions on loading/saving
Changed paths:
engines/ultima/ultima8/kernel/kernel.cpp
engines/ultima/ultima8/kernel/object.cpp
diff --git a/engines/ultima/ultima8/kernel/kernel.cpp b/engines/ultima/ultima8/kernel/kernel.cpp
index ef95bb10e0..9b12e55c92 100644
--- a/engines/ultima/ultima8/kernel/kernel.cpp
+++ b/engines/ultima/ultima8/kernel/kernel.cpp
@@ -325,6 +325,7 @@ void Kernel::save(Common::WriteStream *ws) {
ws->writeUint32LE(_processes.size());
for (ProcessIterator it = _processes.begin(); it != _processes.end(); ++it) {
const Std::string & classname = (*it)->GetClassType()._className; // virtual
+ assert(classname.size());
Std::map<Common::String, ProcessLoadFunc>::iterator iter;
iter = _processLoaders.find(classname);
@@ -357,6 +358,7 @@ bool Kernel::load(Common::ReadStream *rs, uint32 version) {
Process *Kernel::loadProcess(Common::ReadStream *rs, uint32 version) {
const uint16 classlen = rs->readUint16LE();
+ assert(classlen > 0);
char *buf = new char[classlen + 1];
rs->read(buf, classlen);
buf[classlen] = 0;
@@ -372,7 +374,6 @@ Process *Kernel::loadProcess(Common::ReadStream *rs, uint32 version) {
return nullptr;
}
-
_loading = true;
Process *p = (*(iter->_value))(rs, version);
diff --git a/engines/ultima/ultima8/kernel/object.cpp b/engines/ultima/ultima8/kernel/object.cpp
index 214f247b57..caea06046a 100644
--- a/engines/ultima/ultima8/kernel/object.cpp
+++ b/engines/ultima/ultima8/kernel/object.cpp
@@ -73,6 +73,13 @@ void Object::saveData(Common::WriteStream *ws) {
}
bool Object::loadData(Common::ReadStream *rs, uint32 version) {
+ // If we are loading into an object that already got an ID defined, then
+ // there is a problem - default constructors should not allocate object
+ // IDs, otherwise we can end up with the wrong IDs during load, because
+ // we blindly reload the old object IDs and then assign the kernel pointer
+ // table using those.
+ assert(_objId == 0xFFFF);
+
_objId = rs->readUint16LE();
return true;
Commit: cdff1c50219a7a936dbfa8cd167d6419db455b95
https://github.com/scummvm/scummvm/commit/cdff1c50219a7a936dbfa8cd167d6419db455b95
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Use default ScummVM save/load dialogs for Crusader
Changed paths:
engines/ultima/ultima8/gumps/remorse_menu_gump.cpp
engines/ultima/ultima8/kernel/object_manager.cpp
diff --git a/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp b/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp
index 91fe8f8a63..0a8ed310d4 100644
--- a/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp
+++ b/engines/ultima/ultima8/gumps/remorse_menu_gump.cpp
@@ -39,6 +39,10 @@
#include "ultima/ultima8/meta_engine.h"
#include "engines/dialogs.h"
+#include "engines/dialogs.h"
+#include "common/translation.h"
+#include "gui/saveload.h"
+
namespace Ultima {
namespace Ultima8 {
@@ -190,6 +194,37 @@ void RemorseMenuGump::ChildNotify(Gump *child, uint32 message) {
}
}
+static void _openScummVmSaveLoad(bool isSave) {
+ GUI::SaveLoadChooser *dialog;
+ Common::String desc;
+ int slot;
+
+ if (isSave) {
+ dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+
+ slot = dialog->runModalWithCurrentTarget();
+ desc = dialog->getResultString();
+
+ if (desc.empty()) {
+ // create our own description for the saved game, the user didnt enter it
+ desc = dialog->createDefaultSaveDescription(slot);
+ }
+
+ if (desc.size() > 28)
+ desc = Common::String(desc.c_str(), 28);
+ } else {
+ dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+ slot = dialog->runModalWithCurrentTarget();
+ }
+
+ delete dialog;
+
+ if (isSave)
+ Ultima8Engine::get_instance()->saveGame(slot, desc, true);
+ else
+ Ultima8Engine::get_instance()->loadGameState(slot);
+}
+
void RemorseMenuGump::selectEntry(int entry) {
switch (entry) {
case 1: // New Game
@@ -197,8 +232,7 @@ void RemorseMenuGump::selectEntry(int entry) {
break;
case 2:
case 3: // Load/Save Game
- // FIXME: Need a different save/load gump for crusader
- U8SaveGump::showLoadSaveGump(this, entry == 3);
+ _openScummVmSaveLoad(entry == 3);
break;
case 4: {
// Options - show the ScummVM options dialog
diff --git a/engines/ultima/ultima8/kernel/object_manager.cpp b/engines/ultima/ultima8/kernel/object_manager.cpp
index 6569a9736d..87503616af 100644
--- a/engines/ultima/ultima8/kernel/object_manager.cpp
+++ b/engines/ultima/ultima8/kernel/object_manager.cpp
@@ -290,7 +290,6 @@ bool ObjectManager::load(Common::ReadStream *rs, uint32 version) {
}
pout << "Reclaimed " << count << " _objIDs on load." << Std::endl;
- objectTypes();
return true;
}
Commit: 5e4bdbb0b8397af74b9927634e578e89d2f3a355
https://github.com/scummvm/scummvm/commit/5e4bdbb0b8397af74b9927634e578e89d2f3a355
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Small pathfinding optimizations
This doesn't make much difference to the average case, but for the "failure"
case it brings down the run time, making the game smoother on slower hardware
or in debugging mode.
Changed paths:
engines/ultima/shared/std/containers.h
engines/ultima/ultima8/world/actors/pathfinder.cpp
engines/ultima/ultima8/world/actors/pathfinder.h
diff --git a/engines/ultima/shared/std/containers.h b/engines/ultima/shared/std/containers.h
index e0b5e13a07..d89e212029 100644
--- a/engines/ultima/shared/std/containers.h
+++ b/engines/ultima/shared/std/containers.h
@@ -356,7 +356,7 @@ public:
}
typename _Container::const_reference top() const {
- return c.front();
+ return c.back();
}
void push(const typename _Container::value_type &_Val) {
@@ -365,7 +365,7 @@ public:
}
void pop() {
- c.pop_front();
+ c.pop_back();
}
void swap(priority_queue &_Right) {
diff --git a/engines/ultima/ultima8/world/actors/pathfinder.cpp b/engines/ultima/ultima8/world/actors/pathfinder.cpp
index 547ee9828d..a7800fb700 100644
--- a/engines/ultima/ultima8/world/actors/pathfinder.cpp
+++ b/engines/ultima/ultima8/world/actors/pathfinder.cpp
@@ -34,6 +34,7 @@
namespace Ultima {
namespace Ultima8 {
+
#ifdef DEBUG
ObjId Pathfinder::_visualDebugActor = 0xFFFF;
#endif
@@ -60,9 +61,9 @@ void PathfindingState::load(const Actor *_actor) {
}
bool PathfindingState::checkPoint(int32 x, int32 y, int32 z,
- int range) const {
+ int sqr_range) const {
int distance = (_x - x) * (_x - x) + (_y - y) * (_y - y) + (_z - z) * (_z - z);
- return distance < range * range;
+ return distance < sqr_range;
}
bool PathfindingState::checkItem(const Item *item, int xyRange, int zRange) const {
@@ -113,18 +114,18 @@ bool PathfindingState::checkHit(const Actor *_actor, const Actor *target) const
}
bool PathNodeCmp::operator()(const PathNode *n1, const PathNode *n2) const {
- return (n1->heuristicTotalCost < n2->heuristicTotalCost);
+ return (n1->heuristicTotalCost > n2->heuristicTotalCost);
}
Pathfinder::Pathfinder() : _actor(nullptr), _targetItem(nullptr),
_hitMode(false), _expandTime(0), _targetX(0), _targetY(0),
_targetZ(0), _actorXd(0), _actorYd(0), _actorZd(0) {
expandednodes = 0;
- _visited.reserve(1800);
+ _visited.reserve(1500);
}
Pathfinder::~Pathfinder() {
-#if 0
+#if 1
pout << "~Pathfinder: " << _cleanupNodes.size() << " nodes to clean up, visited "
<< _visited.size() << " and "
<< expandednodes << " expanded nodes in " << _expandTime << "ms." << Std::endl;
@@ -180,12 +181,19 @@ bool Pathfinder::canReach() {
}
bool Pathfinder::alreadyVisited(int32 x, int32 y, int32 z) const {
- //! this may need optimization
-
- Std::vector<PathfindingState>::const_iterator iter;
- for (iter = _visited.begin(); iter != _visited.end(); ++iter)
- if (iter->checkPoint(x, y, z, 8))
+ //
+ // There are more efficient search structures we could use for
+ // this, but for the number of points we end up having even on
+ // pathfind failure (~1200) the fancy structures don't justify
+ // their extra overhead.
+ //
+ // Linear search of an array is just as fast, or slightly faster.
+ //
+ Common::Array<PathfindingState>::const_iterator iter;
+ for (iter = _visited.begin(); iter != _visited.end(); iter++) {
+ if (iter->checkPoint(x, y, z, 8*8))
return true;
+ }
return false;
}
@@ -201,7 +209,7 @@ bool Pathfinder::checkTarget(const PathNode *node) const {
return node->state.checkItem(_targetItem, 32, 8);
}
} else {
- return node->state.checkPoint(_targetX, _targetY, _targetZ, 48);
+ return node->state.checkPoint(_targetX, _targetY, _targetZ, 48*48);
}
}
@@ -236,7 +244,7 @@ unsigned int Pathfinder::costHeuristic(PathNode *node) const {
#else
// Weigh remaining distance more than already travelled distance,
- // to try to explore more _nodes closer to the target.
+ // to try to explore more nodes closer to the target.
node->heuristicTotalCost = 2 * cost + 3 * dist;
#endif
@@ -246,9 +254,6 @@ unsigned int Pathfinder::costHeuristic(PathNode *node) const {
#ifdef DEBUG
-// FIXME: these functions assume that we're using a 2x scaler...
-// (and the whole system is generally a very big hack...)
-
static void drawbox(const Item *item) {
RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
int32 cx, cy, cz;
@@ -270,17 +275,17 @@ static void drawbox(const Item *item) {
int32 x0, y0, x1, y1, x2, y2, x3, y3;
- x0 = (d.width() / 2) + (ix - iy) / 2;
- y0 = (d.height() / 2) + (ix + iy) / 4 - iz * 2;
+ x0 = (d.width() / 2) + (ix - iy) / 4;
+ y0 = (d.height() / 2) + (ix + iy) / 8 - iz;
- x1 = (d.width() / 2) + (ix - iy) / 2;
- y1 = (d.height() / 2) + (ix + iy) / 4 - (iz + zd) * 2;
+ x1 = (d.width() / 2) + (ix - iy) / 4;
+ y1 = (d.height() / 2) + (ix + iy) / 8 - (iz + zd);
- x2 = (d.width() / 2) + (ix - xd - iy) / 2;
- y2 = (d.height() / 2) + (ix - xd + iy) / 4 - iz * 2;
+ x2 = (d.width() / 2) + (ix - xd - iy) / 4;
+ y2 = (d.height() / 2) + (ix - xd + iy) / 8 - iz;
- x3 = (d.width() / 2) + (ix - iy + yd) / 2;
- y3 = (d.height() / 2) + (ix + iy - yd) / 4 - iz * 2;
+ x3 = (d.width() / 2) + (ix - iy + yd) / 4;
+ y3 = (d.height() / 2) + (ix + iy - yd) / 8 - iz;
screen->Fill32(0xFF0000FF, x0 - 1, y0 - 1, 3, 3);
@@ -301,8 +306,8 @@ static void drawdot(int32 x, int32 y, int32 Z, int size, uint32 rgb) {
y -= cy;
Z -= cz;
int32 x0, y0;
- x0 = (d.width() / 2) + (x - y) / 2;
- y0 = (d.height() / 2) + (x + y) / 4 - Z * 2;
+ x0 = (d.width() / 2) + (x - y) / 4;
+ y0 = (d.height() / 2) + (x + y) / 8 - Z;
screen->Fill32(rgb, x0 - size, y0 - size, 2 * size + 1, 2 * size + 1);
}
@@ -321,8 +326,8 @@ static void drawedge(const PathNode *from, const PathNode *to, uint32 rgb) {
cy = from->state._y - cy;
cz = from->state._z - cz;
- x0 = (d.width() / 2) + (cx - cy) / 2;
- y0 = (d.height() / 2) + (cx + cy) / 4 - cz * 2;
+ x0 = (d.width() / 2) + (cx - cy) / 4;
+ y0 = (d.height() / 2) + (cx + cy) / 8 - cz;
Ultima8Engine::get_instance()->getGameMapGump()->GetCameraLocation(cx, cy, cz);
@@ -330,8 +335,8 @@ static void drawedge(const PathNode *from, const PathNode *to, uint32 rgb) {
cy = to->state._y - cy;
cz = to->state._z - cz;
- x1 = (d.width() / 2) + (cx - cy) / 2;
- y1 = (d.height() / 2) + (cx + cy) / 4 - cz * 2;
+ x1 = (d.width() / 2) + (cx - cy) / 4;
+ y1 = (d.height() / 2) + (cx + cy) / 8 - cz;
screen->DrawLine32(rgb, x0, y0, x1, y1);
}
@@ -413,7 +418,7 @@ void Pathfinder::newNode(PathNode *oldnode, PathfindingState &state,
screen->BeginPainting();
drawpath(newnode, 0xFFFFFF00, done);
screen->EndPainting();
- g_system->delayMillis(250);
+ g_system->delayMillis(50);
if (!done) {
screen->BeginPainting();
drawpath(newnode, 0xFFB0B000, done);
diff --git a/engines/ultima/ultima8/world/actors/pathfinder.h b/engines/ultima/ultima8/world/actors/pathfinder.h
index 689f2a6e9f..9ea44caae9 100644
--- a/engines/ultima/ultima8/world/actors/pathfinder.h
+++ b/engines/ultima/ultima8/world/actors/pathfinder.h
@@ -93,7 +93,7 @@ protected:
int32 _actorXd, _actorYd, _actorZd;
- Std::vector<PathfindingState> _visited;
+ Common::Array<PathfindingState> _visited;
Std::priority_queue<PathNode *, Std::vector<PathNode *>, PathNodeCmp> _nodes;
/** List of nodes for garbage collection later and order is not important */
Commit: a70153fdd04bfc3becba7114e68db67ac58136ff
https://github.com/scummvm/scummvm/commit/a70153fdd04bfc3becba7114e68db67ac58136ff
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Add smooth Crusader turning.
Changed paths:
engines/ultima/ultima8/misc/direction_util.h
engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
engines/ultima/ultima8/world/actors/avatar_mover_process.h
engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
engines/ultima/ultima8/world/crosshair_process.cpp
test/engines/ultima/ultima8/misc/direction_util.h
diff --git a/engines/ultima/ultima8/misc/direction_util.h b/engines/ultima/ultima8/misc/direction_util.h
index 1bc3a70202..387079d756 100644
--- a/engines/ultima/ultima8/misc/direction_util.h
+++ b/engines/ultima/ultima8/misc/direction_util.h
@@ -59,6 +59,17 @@ inline int Direction_YFactor(Direction dir) {
return _y_fact16[(int)dir];
}
+//! Convert a direction to hundreths of degrees (rotated by 90 degrees)
+inline int32 Direction_ToCentidegrees(Direction dir) {
+ return static_cast<int>(dir) * 2250;
+}
+
+//! Convert from centidegrees to a direction.
+inline Direction Direction_FromCentidegrees(int32 cds) {
+ return static_cast<Direction>(((cds + 1125) / 2250) % 16);
+}
+
+
/**
* Return the direction for a given slope (0-7).
* NOTE: Assumes cartesian coords, NOT screen coords. (which have y
diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
index a49ee53ff8..6c8017349e 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.cpp
@@ -41,8 +41,7 @@ namespace Ultima {
namespace Ultima8 {
AvatarMoverProcess::AvatarMoverProcess() : Process(),
- _lastFrame(0), _lastAttack(0), _idleTime(0),
- _movementFlags(0) {
+ _lastAttack(0), _idleTime(0), _movementFlags(0) {
_type = 1; // CONSTANT! (type 1 = persistent)
}
@@ -52,12 +51,6 @@ AvatarMoverProcess::~AvatarMoverProcess() {
void AvatarMoverProcess::run() {
Kernel *kernel = Kernel::get_instance();
- uint32 framenum = kernel->getFrameNum();
-
- // only run once per frame
- if (framenum == _lastFrame)
- return;
- _lastFrame = framenum;
// busy, so don't move
if (kernel->getNumProcesses(1, ActorAnimProcess::ACTOR_ANIM_PROC_TYPE) > 0) {
@@ -66,6 +59,7 @@ void AvatarMoverProcess::run() {
}
MainActor *avatar = getMainActor();
+ assert(avatar);
if (avatar->getLastAnim() == Animation::hang) {
handleHangingMode();
diff --git a/engines/ultima/ultima8/world/actors/avatar_mover_process.h b/engines/ultima/ultima8/world/actors/avatar_mover_process.h
index cb523d30e9..4c245655f2 100644
--- a/engines/ultima/ultima8/world/actors/avatar_mover_process.h
+++ b/engines/ultima/ultima8/world/actors/avatar_mover_process.h
@@ -66,8 +66,8 @@ public:
enum MovementFlags {
MOVE_MOUSE_DIRECTION = 0x001,
MOVE_RUN = 0x002,
- MOVE_STEP = 0x0004,
- MOVE_JUMP = 0x0008,
+ MOVE_STEP = 0x0004, // also side-steps in crusader
+ MOVE_JUMP = 0x0008, // used for roll in crusader (when combined with left/right), and crouch (when combined with back)
// Tank controls
MOVE_TURN_LEFT = 0x0010,
@@ -110,8 +110,6 @@ protected:
// Adjust the direction based on the current turn flags
Direction getTurnDirForTurnFlags(Direction direction, DirectionMode dirmode);
- uint32 _lastFrame;
-
// attack speed limiting
uint32 _lastAttack;
diff --git a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
index 799fa9786b..328288eb34 100644
--- a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
@@ -41,7 +41,7 @@ namespace Ultima8 {
// p_dynamic_cast stuff
DEFINE_RUNTIME_CLASSTYPE_CODE(CruAvatarMoverProcess)
-CruAvatarMoverProcess::CruAvatarMoverProcess() : AvatarMoverProcess() {
+CruAvatarMoverProcess::CruAvatarMoverProcess() : AvatarMoverProcess(), _avatarAngle(0) {
}
@@ -49,6 +49,40 @@ CruAvatarMoverProcess::~CruAvatarMoverProcess() {
}
+void CruAvatarMoverProcess::run() {
+
+ // Even when we are not doing anything (because we're waiting for an anim)
+ // we check if the combat angle needs updating - this keeps it smooth.
+
+ MainActor *avatar = getMainActor();
+ assert(avatar);
+
+ if (avatar->isInCombat() && !hasMovementFlags(MOVE_FORWARD | MOVE_BACK)) {
+ // See comment on _avatarAngle in header about these constants
+ if (hasMovementFlags(MOVE_TURN_LEFT)) {
+ if (hasMovementFlags(MOVE_RUN))
+ _avatarAngle -= 375;
+ else
+ _avatarAngle -= 150;
+
+ if (_avatarAngle < 0)
+ _avatarAngle += 36000;
+ }
+ if (hasMovementFlags(MOVE_TURN_RIGHT)) {
+ if (hasMovementFlags(MOVE_RUN))
+ _avatarAngle += 375;
+ else
+ _avatarAngle += 150;
+
+ _avatarAngle = _avatarAngle % 36000;
+ }
+ }
+
+ // Now do the regular process
+ AvatarMoverProcess::run();
+}
+
+
void CruAvatarMoverProcess::handleHangingMode() {
// No hanging in crusader, this shouldn't happen?
assert(false);
@@ -57,7 +91,8 @@ void CruAvatarMoverProcess::handleHangingMode() {
void CruAvatarMoverProcess::handleCombatMode() {
MainActor *avatar = getMainActor();
const Animation::Sequence lastanim = avatar->getLastAnim();
- Direction direction = avatar->getDir();
+ Direction direction = Direction_FromCentidegrees(_avatarAngle);
+ const Direction curdir = avatar->getDir();
const bool stasis = Ultima8Engine::get_instance()->isAvatarInStasis();
// never idle when in combat
@@ -71,13 +106,6 @@ void CruAvatarMoverProcess::handleCombatMode() {
if (stasis)
return;
- bool moving = (lastanim == Animation::advance || lastanim == Animation::retreat);
-
- // if we are trying to move, allow change direction only after move occurs to avoid spinning
- if (moving || !hasMovementFlags(MOVE_FORWARD | MOVE_BACK)) {
- direction = getTurnDirForTurnFlags(direction, avatar->animDirMode(Animation::combatStand));
- }
-
if (hasMovementFlags(MOVE_FORWARD)) {
Animation::Sequence nextanim;
if (hasMovementFlags(MOVE_STEP)) {
@@ -107,9 +135,8 @@ void CruAvatarMoverProcess::handleCombatMode() {
int x, y;
getMovementFlagAxes(x, y);
-
if (x != 0 || y != 0) {
- Direction nextdir = Direction_Get(y, x, dirmode_8dirs);
+ Direction nextdir = Direction_FromCentidegrees(_avatarAngle);
if (checkTurn(nextdir, true))
return;
@@ -135,8 +162,13 @@ void CruAvatarMoverProcess::handleCombatMode() {
return;
}
- if (checkTurn(direction, false))
+ if (curdir != direction) {
+ // Slight hack: don't "wait" for this - we want to keep turning smooth,
+ // and the process will not do anything else if an anim is active, so
+ // it's safe.
+ avatar->doAnim(Animation::combatStand, direction);
return;
+ }
// not doing anything in particular? stand
if (lastanim != Animation::combatStand) {
@@ -161,6 +193,9 @@ void CruAvatarMoverProcess::handleNormalMode() {
avatar->toggleInCombat();
}
+ // In normal mode the internal angle is set based on the avatar direction
+ _avatarAngle = Direction_ToCentidegrees(direction);
+
// If Avatar has fallen down and not dead, get up!
if (standUpIfNeeded(direction))
return;
diff --git a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
index c10fa99cd4..01970c267d 100644
--- a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
+++ b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
@@ -43,12 +43,27 @@ public:
// p_dynamic_cast stuff
ENABLE_RUNTIME_CLASSTYPE()
+ void run() override;
+
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;
void tryAttack() override;
+ double getAvatarAngleDegrees() const {
+ return static_cast<double>(_avatarAngle) / 100.0;
+ }
+
private:
+
+ /**
+ * Angle of avatar in centidegrees (1/100deg). The original game runs the keyboard
+ * process 45 times per second and rotates the crosshair by 2 (regular) or
+ * 5 ('run') degrees each time. This process runs 60 times per second, so we choose a
+ * multiplier that can use integers - rotating 3.75 or 1.5 degrees each time.
+ */
+ int32 _avatarAngle;
+
void handleHangingMode() override;
void handleCombatMode() override;
void handleNormalMode() override;
diff --git a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
index 6c330a8a1b..6aa9da22a9 100644
--- a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
@@ -161,7 +161,7 @@ void U8AvatarMoverProcess::handleCombatMode() {
return;
waitFor(avatar->doAnim(Animation::attack, mousedir));
- _lastAttack = _lastFrame;
+ _lastAttack = Kernel::get_instance()->getFrameNum();
// attacking gives str/dex
avatar->accumulateStr(1 + (getRandom() % 2));
@@ -193,7 +193,7 @@ void U8AvatarMoverProcess::handleCombatMode() {
return;
waitFor(avatar->doAnim(Animation::kick, mousedir));
- _lastAttack = _lastFrame;
+ _lastAttack = Kernel::get_instance()->getFrameNum();
// kicking gives str/dex
avatar->accumulateStr(1 + (getRandom() % 2));
@@ -750,7 +750,7 @@ void U8AvatarMoverProcess::jump(Animation::Sequence action, Direction direction)
bool U8AvatarMoverProcess::canAttack() {
MainActor *avatar = getMainActor();
- return (_lastFrame > _lastAttack + (25 - avatar->getDex()));
+ return (Kernel::get_instance()->getFrameNum() > _lastAttack + (25 - avatar->getDex()));
}
void U8AvatarMoverProcess::tryAttack() {
diff --git a/engines/ultima/ultima8/world/crosshair_process.cpp b/engines/ultima/ultima8/world/crosshair_process.cpp
index 00af5317aa..56cfa7e7da 100644
--- a/engines/ultima/ultima8/world/crosshair_process.cpp
+++ b/engines/ultima/ultima8/world/crosshair_process.cpp
@@ -24,11 +24,15 @@
#include "ultima/ultima8/kernel/kernel.h"
#include "ultima/ultima8/world/actors/main_actor.h"
+#include "ultima/ultima8/world/actors/cru_avatar_mover_process.h"
#include "ultima/ultima8/world/crosshair_process.h"
#include "ultima/ultima8/world/item.h"
#include "ultima/ultima8/world/world.h"
#include "ultima/ultima8/world/item_factory.h"
#include "ultima/ultima8/world/get_object.h"
+#include "ultima/ultima8/ultima8.h"
+
+#include "common/math.h"
namespace Ultima {
namespace Ultima8 {
@@ -57,12 +61,18 @@ void CrosshairProcess::run() {
// TODO: Make a fine adjustment for avatar height (eg, when crouching)
// for now just put it at 3/4 avatar height which is about right.
cz += az / 4;
+
+ const CruAvatarMoverProcess *mover = dynamic_cast<CruAvatarMoverProcess *>(Ultima8Engine::get_instance()->getAvatarMoverProcess());
+ if (!mover) {
+ warning("lost CruAvatarMoverProcess!");
+ return;
+ }
// TODO: Get the fine angle of the avatar once that is implemented.
- uint16 dir = (mainactor->getDir() + 4) % 16;
- // Dir is 0~15, convert to 0~15/8*pi
- float angle = (3.14 * dir / 8.0);
- float xoff = CROSSHAIR_DIST * cos(angle);
- float yoff = CROSSHAIR_DIST * sin(angle);
+ double angle = mover->getAvatarAngleDegrees() + 90.0;
+ // Convert angle to 0~2pi
+ double rads = Common::deg2rad(angle);
+ float xoff = CROSSHAIR_DIST * cos(rads);
+ float yoff = CROSSHAIR_DIST * sin(rads);
cx -= static_cast<int32>(xoff);
cy -= static_cast<int32>(yoff);
diff --git a/test/engines/ultima/ultima8/misc/direction_util.h b/test/engines/ultima/ultima8/misc/direction_util.h
index ea639445d0..4aebd6249e 100644
--- a/test/engines/ultima/ultima8/misc/direction_util.h
+++ b/test/engines/ultima/ultima8/misc/direction_util.h
@@ -48,4 +48,16 @@ class U8DirectionTestSuite : public CxxTest::TestSuite {
_test_direction_get_worlddir(dirmode16);
}
+ void test_direction_conversions() {
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_ToCentidegrees(Ultima::Ultima8::dir_north), 0);
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_ToCentidegrees(Ultima::Ultima8::dir_nne), 2250);
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_ToCentidegrees(Ultima::Ultima8::dir_east), 9000);
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_ToCentidegrees(Ultima::Ultima8::dir_west), 27000);
+
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_FromCentidegrees(2250), Ultima::Ultima8::dir_nne);
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_FromCentidegrees(2249), Ultima::Ultima8::dir_nne);
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_FromCentidegrees(2251), Ultima::Ultima8::dir_nne);
+ TS_ASSERT_EQUALS(Ultima::Ultima8::Direction_FromCentidegrees(4500), Ultima::Ultima8::dir_northeast);
+ }
+
};
Commit: 259dd1031d252d5bfd52196d92e868642997a977
https://github.com/scummvm/scummvm/commit/259dd1031d252d5bfd52196d92e868642997a977
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Name keys correctly for Crusader
Changed paths:
engines/ultima/ultima8/meta_engine.cpp
diff --git a/engines/ultima/ultima8/meta_engine.cpp b/engines/ultima/ultima8/meta_engine.cpp
index 431167db99..3184764e4e 100644
--- a/engines/ultima/ultima8/meta_engine.cpp
+++ b/engines/ultima/ultima8/meta_engine.cpp
@@ -63,7 +63,6 @@ static const KeybindingRecord COMMON_KEYS[] = {
{ ACTION_MOVE_LEFT, "MOVE_LEFT", "Move Left", "AvatarMoverProcess::startMoveLeft", "AvatarMoverProcess::stopMoveLeft", nullptr, "JOY_LEFT", FLAG_MENU_ENABLED },
{ ACTION_MOVE_RIGHT, "MOVE_RIGHT", "Move Right", "AvatarMoverProcess::startMoveRight", "AvatarMoverProcess::stopMoveRight", nullptr, "JOY_RIGHT", FLAG_MENU_ENABLED },
{ ACTION_MOVE_RUN, "MOVE_RUN", "Run", "AvatarMoverProcess::startMoveRun", "AvatarMoverProcess::stopMoveRun", "LSHIFT", "JOY_RIGHT_TRIGGER", FLAG_MENU_ENABLED },
- { ACTION_MOVE_STEP, "MOVE_STEP", "Step", "AvatarMoverProcess::startMoveStep", "AvatarMoverProcess::stopMoveStep", "LCTRL", "JOY_RIGHT_SHOULDER", FLAG_MENU_ENABLED },
{ ACTION_NONE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
@@ -77,6 +76,8 @@ static const KeybindingRecord U8_KEYS[] = {
{ ACTION_INVENTORY, "INVENTORY", "Inventory", "MainActor::useInventory", nullptr, "z", "JOY_LEFT_SHOULDER", 0 },
{ ACTION_CLOSE_GUMPS, "CLOSE_GUMPS", "Close Gumps", "GUIApp::closeItemGumps", nullptr, "BACKSPACE", nullptr, 0 },
{ ACTION_JUMP, "JUMP", "Jump (fake both-button-click)", "AvatarMoverProcess::startJump", "AvatarMoverProcess::stopJump", "SPACE", nullptr, FLAG_MENU_ENABLED },
+ { ACTION_MOVE_STEP, "MOVE_STEP", "Step", "AvatarMoverProcess::startMoveStep", "AvatarMoverProcess::stopMoveStep", "LCTRL", "JOY_RIGHT_SHOULDER", FLAG_MENU_ENABLED },
+
{ ACTION_NONE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
@@ -90,6 +91,8 @@ static const KeybindingRecord CRUSADER_KEYS[] = {
{ ACTION_USE_SELECTION, "USE_SELECTION", "Use Selection", "ItemSelectionProcess::useSelectedItem", nullptr, "RETURN", nullptr, 0 },
{ ACTION_ATTACK, "ATTACK", "Attack", "AvatarMoverProcess::tryAttack", nullptr, "SPACE", nullptr, 0 },
{ ACTION_CAMERA_AVATAR, "CAMERA_AVATAR", "Focus Camera on Silencer", "CameraProcess::moveToAvatar", nullptr, "z", nullptr, 0 },
+ { ACTION_JUMP, "JUMP", "Jump / Roll / Crouch", "AvatarMoverProcess::startJump", "AvatarMoverProcess::stopJump", "LCTRL", nullptr, FLAG_MENU_ENABLED },
+ { ACTION_MOVE_STEP, "MOVE_STEP", "Side Step / Advance / Retreat", "AvatarMoverProcess::startMoveStep", "AvatarMoverProcess::stopMoveStep", "LALT", "JOY_RIGHT_SHOULDER", FLAG_MENU_ENABLED },
{ ACTION_NONE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
Commit: 7d7cd0ee0b3fe6bec735348b403588be7091a6c0
https://github.com/scummvm/scummvm/commit/7d7cd0ee0b3fe6bec735348b403588be7091a6c0
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Fix parameter type and bitmask for AAF_ROTATED flag
Changed paths:
engines/ultima/ultima8/world/actors/anim_action.cpp
engines/ultima/ultima8/world/actors/anim_action.h
diff --git a/engines/ultima/ultima8/world/actors/anim_action.cpp b/engines/ultima/ultima8/world/actors/anim_action.cpp
index b2a00486ee..43008c64f8 100644
--- a/engines/ultima/ultima8/world/actors/anim_action.cpp
+++ b/engines/ultima/ultima8/world/actors/anim_action.cpp
@@ -87,7 +87,7 @@ const AnimFrame &AnimAction::getFrame(Direction dir, unsigned int frameno) const
having to check against game type each time they are used
*/
/*static*/
-AnimAction::AnimActionFlags AnimAction::loadAnimActionFlags(uint16 rawflags) {
+AnimAction::AnimActionFlags AnimAction::loadAnimActionFlags(uint32 rawflags) {
uint32 ret = AAF_NONE;
ret |= (rawflags & AAF_COMMONFLAGS);
if (GAME_IS_U8) {
diff --git a/engines/ultima/ultima8/world/actors/anim_action.h b/engines/ultima/ultima8/world/actors/anim_action.h
index 490163030d..e284fa5c6c 100644
--- a/engines/ultima/ultima8/world/actors/anim_action.h
+++ b/engines/ultima/ultima8/world/actors/anim_action.h
@@ -151,7 +151,7 @@ public:
enum AnimActionFlags {
AAF_NONE = 0x0000,
AAF_TWOSTEP = 0x0001,
- AAF_ATTACK = 0x0002, // U8 only
+ AAF_ATTACK = 0x0002, // U8 only? also present in crusader, but ignored.
AAF_LOOPING = 0x0004,
AAF_UNSTOPPABLE = 0x0008,
AAF_LOOPING2_U8 = 0x0010,
@@ -160,13 +160,13 @@ public:
AAF_HANGING = 0x0080,
AAF_16DIRS = 0x4000, // Cru only
AAF_DESTROYACTOR = 0x8000, // destroy actor after animation finishes
- AAF_ROTATED = 0x100000, // Cru only
+ AAF_ROTATED = 0x10000, // Cru only
AAF_COMMONFLAGS = (AAF_TWOSTEP | AAF_LOOPING | AAF_UNSTOPPABLE | AAF_HANGING | AAF_DESTROYACTOR)
};
private:
- static AnimActionFlags loadAnimActionFlags(uint16 rawflags);
+ static AnimActionFlags loadAnimActionFlags(uint32 rawflags);
uint32 _shapeNum;
uint32 _action;
Commit: 686a11c721787cbef77ced64d05334061233a7eb
https://github.com/scummvm/scummvm/commit/686a11c721787cbef77ced64d05334061233a7eb
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Support Crusader combat slides and rolls
Changed paths:
engines/ultima/ultima8/world/actors/animation.cpp
engines/ultima/ultima8/world/actors/animation.h
engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
diff --git a/engines/ultima/ultima8/world/actors/animation.cpp b/engines/ultima/ultima8/world/actors/animation.cpp
index 20e4575009..bb26236237 100644
--- a/engines/ultima/ultima8/world/actors/animation.cpp
+++ b/engines/ultima/ultima8/world/actors/animation.cpp
@@ -22,12 +22,20 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/world/actors/animation.h"
+#include "ultima/ultima8/kernel/core_app.h"
namespace Ultima {
namespace Ultima8 {
namespace Animation {
bool isCombatAnim(const Sequence anim) {
+ if (GAME_IS_U8)
+ return isCombatAnimU8(anim);
+ else
+ return isCombatAnimCru(anim);
+}
+
+bool isCombatAnimU8(const Sequence anim) {
switch (anim) {
case combatStand:
case readyWeapon:
@@ -37,7 +45,27 @@ bool isCombatAnim(const Sequence anim) {
case kick:
case startBlock:
case stopBlock:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool isCombatAnimCru(const Sequence anim) {
+ switch (anim) {
+ case combatStand:
+ case readyWeapon:
+ case advance:
+ case retreat:
+ case attack:
+ case kick:
+ case kneel:
+ case kneelStart:
case fire2:
+ case combatRollLeft:
+ case combatRollRight:
+ case slideLeft:
+ case slideRight:
return true;
default:
return false;
@@ -48,7 +76,7 @@ bool isCombatAnim(const Sequence anim) {
Sequence checkWeapon(const Sequence nextanim,
const Sequence lastanim) {
Sequence anim = nextanim;
- if (isCombatAnim(nextanim) && ! isCombatAnim(lastanim)) {
+ if (isCombatAnim(nextanim) && !isCombatAnim(lastanim)) {
anim = readyWeapon;
} else if (!isCombatAnim(nextanim) && isCombatAnim(lastanim)) {
anim = unreadyWeapon;
diff --git a/engines/ultima/ultima8/world/actors/animation.h b/engines/ultima/ultima8/world/actors/animation.h
index 3469287b73..84c6d3ab36 100644
--- a/engines/ultima/ultima8/world/actors/animation.h
+++ b/engines/ultima/ultima8/world/actors/animation.h
@@ -149,6 +149,8 @@ enum Result {
};
bool isCombatAnim(const Sequence anim);
+bool isCombatAnimU8(const Sequence anim);
+bool isCombatAnimCru(const Sequence anim);
Sequence checkWeapon(const Sequence nextanim, const Sequence lastanim);
} // End of namespace Animation
diff --git a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
index 328288eb34..a9c8aecaa2 100644
--- a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp
@@ -54,10 +54,10 @@ void CruAvatarMoverProcess::run() {
// Even when we are not doing anything (because we're waiting for an anim)
// we check if the combat angle needs updating - this keeps it smooth.
- MainActor *avatar = getMainActor();
+ const MainActor *avatar = getMainActor();
assert(avatar);
- if (avatar->isInCombat() && !hasMovementFlags(MOVE_FORWARD | MOVE_BACK)) {
+ if (avatar->isInCombat() && !hasMovementFlags(MOVE_FORWARD | MOVE_BACK | MOVE_JUMP | MOVE_STEP)) {
// See comment on _avatarAngle in header about these constants
if (hasMovementFlags(MOVE_TURN_LEFT)) {
if (hasMovementFlags(MOVE_RUN))
@@ -99,17 +99,15 @@ void CruAvatarMoverProcess::handleCombatMode() {
_idleTime = 0;
// If Avatar has fallen down, stand up
- if (standUpIfNeeded(direction))
+ if (standUpIfNeeded(direction)) {
return;
-
- // can't do any new actions if in stasis
- if (stasis)
+ } else if (stasis) {
return;
-
- if (hasMovementFlags(MOVE_FORWARD)) {
+ } else if (hasMovementFlags(MOVE_FORWARD)) {
Animation::Sequence nextanim;
if (hasMovementFlags(MOVE_STEP)) {
- nextanim = Animation::advance;
+ nextanim = avatar->hasActorFlags(Actor::ACT_KNEELING) ?
+ Animation::kneelingAdvance : Animation::advance;
} else if (hasMovementFlags(MOVE_RUN)) {
// Take a step before running
avatar->toggleInCombat();
@@ -117,6 +115,12 @@ void CruAvatarMoverProcess::handleCombatMode() {
nextanim = Animation::startRun;
else
nextanim = Animation::run;
+ } else if (hasMovementFlags(MOVE_JUMP)) {
+ avatar->toggleInCombat();
+ nextanim = Animation::jumpForward;
+ } else if (avatar->hasActorFlags(Actor::ACT_KNEELING)) {
+ nextanim = Animation::stopKneeling;
+ avatar->clearActorFlag(Actor::ACT_KNEELING);
} else {
// moving from combat stows weapon
nextanim = Animation::walk;
@@ -126,11 +130,35 @@ void CruAvatarMoverProcess::handleCombatMode() {
nextanim = Animation::checkWeapon(nextanim, lastanim);
step(nextanim, direction);
return;
- }
-
- if (hasMovementFlags(MOVE_BACK)) {
- waitFor(avatar->doAnim(Animation::retreat, direction));
+ } else if (hasMovementFlags(MOVE_BACK)) {
+ Animation::Sequence nextanim;
+ if (hasMovementFlags(MOVE_JUMP)) {
+ nextanim = Animation::startKneeling;
+ avatar->setActorFlag(Actor::ACT_KNEELING);
+ } else {
+ nextanim = avatar->hasActorFlags(Actor::ACT_KNEELING) ?
+ Animation::kneelingRetreat : Animation::retreat;
+ }
+ waitFor(avatar->doAnim(nextanim, direction));
return;
+ } else if (hasMovementFlags(MOVE_STEP)) {
+ if (hasMovementFlags(MOVE_TURN_LEFT)) {
+ avatar->doAnim(Animation::slideLeft, direction);
+ return;
+ } else if (hasMovementFlags(MOVE_TURN_RIGHT)) {
+ avatar->doAnim(Animation::slideRight, direction);
+ return;
+ }
+ } else if (hasMovementFlags(MOVE_JUMP)) {
+ if (hasMovementFlags(MOVE_TURN_LEFT)) {
+ //direction = Direction_TurnByDelta(direction, 4, dirmode_16dirs);
+ avatar->doAnim(Animation::combatRollLeft, direction);
+ return;
+ } else if (hasMovementFlags(MOVE_TURN_RIGHT)) {
+ //direction = Direction_TurnByDelta(direction, -4, dirmode_16dirs);
+ avatar->doAnim(Animation::combatRollRight, direction);
+ return;
+ }
}
int x, y;
@@ -162,17 +190,20 @@ void CruAvatarMoverProcess::handleCombatMode() {
return;
}
+ Animation::Sequence idleanim = avatar->hasActorFlags(Actor::ACT_KNEELING) ?
+ Animation::kneel : Animation::combatStand;
+
if (curdir != direction) {
// Slight hack: don't "wait" for this - we want to keep turning smooth,
// and the process will not do anything else if an anim is active, so
// it's safe.
- avatar->doAnim(Animation::combatStand, direction);
+ avatar->doAnim(idleanim, direction);
return;
}
// not doing anything in particular? stand
- if (lastanim != Animation::combatStand) {
- Animation::Sequence nextanim = Animation::checkWeapon(Animation::combatStand, lastanim);
+ if (lastanim != idleanim) {
+ Animation::Sequence nextanim = Animation::checkWeapon(idleanim, lastanim);
waitFor(avatar->doAnim(nextanim, direction));
}
}
@@ -201,7 +232,7 @@ void CruAvatarMoverProcess::handleNormalMode() {
return;
// If still in combat stance, sheathe weapon
- if (!stasis && Animation::isCombatAnim(lastanim)) {
+ if (!stasis && Animation::isCombatAnimU8(lastanim)) {
putAwayWeapon(direction);
return;
}
@@ -217,37 +248,13 @@ void CruAvatarMoverProcess::handleNormalMode() {
if (stasis)
return;
- if (hasMovementFlags(MOVE_JUMP) && hasMovementFlags(MOVE_ANY_DIRECTION)) {
- clearMovementFlag(MOVE_JUMP);
-
+ if (hasMovementFlags(MOVE_JUMP) && hasMovementFlags(MOVE_FORWARD)) {
Animation::Sequence nextanim = Animation::jump;
- // check if we need to do a running jump
- if (lastanim == Animation::run || lastanim == Animation::runningJump) {
- nextanim = Animation::runningJump;
- }
- else if (avatar->hasActorFlags(Actor::ACT_AIRWALK)) {
- nextanim = Animation::airwalkJump;
- }
-
nextanim = Animation::checkWeapon(nextanim, lastanim);
waitFor(avatar->doAnim(nextanim, direction));
return;
}
- if (hasMovementFlags(MOVE_JUMP)) {
- clearMovementFlag(MOVE_JUMP);
-
- Animation::Sequence nextanim = Animation::jumpUp;
-
- if (nextanim == Animation::jump) {
- jump(Animation::jump, direction);
- } else {
- nextanim = Animation::checkWeapon(nextanim, lastanim);
- waitFor(avatar->doAnim(nextanim, direction));
- }
- return;
- }
-
bool moving = (lastanim == Animation::step || lastanim == Animation::run || lastanim == Animation::walk);
DirectionMode dirmode = avatar->animDirMode(Animation::step);
@@ -375,25 +382,6 @@ void CruAvatarMoverProcess::step(Animation::Sequence action, Direction direction
waitFor(avatar->doAnim(action, direction));
}
-void CruAvatarMoverProcess::jump(Animation::Sequence action, Direction direction) {
- MainActor *avatar = getMainActor();
-
- // running jump
- if (action == Animation::runningJump) {
- waitFor(avatar->doAnim(action, direction));
- return;
- }
-
- // airwalk
- if (avatar->hasActorFlags(Actor::ACT_AIRWALK) &&
- action == Animation::jump) {
- waitFor(avatar->doAnim(Animation::airwalkJump, direction));
- return;
- }
-
- waitFor(avatar->doAnim(Animation::jump, direction));
-}
-
bool CruAvatarMoverProcess::canAttack() {
MainActor *avatar = getMainActor();
return avatar->isInCombat();
diff --git a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
index 01970c267d..e99ce27628 100644
--- a/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
+++ b/engines/ultima/ultima8/world/actors/cru_avatar_mover_process.h
@@ -70,7 +70,6 @@ private:
bool canAttack() override;
void step(Animation::Sequence action, Direction direction, bool adjusted = false);
- void jump(Animation::Sequence action, Direction direction);
};
diff --git a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
index 6aa9da22a9..bc771ee72f 100644
--- a/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
+++ b/engines/ultima/ultima8/world/actors/u8_avatar_mover_process.cpp
@@ -348,7 +348,7 @@ void U8AvatarMoverProcess::handleNormalMode() {
return;
// If still in combat stance, sheathe weapon
- if (!stasis && Animation::isCombatAnim(lastanim)) {
+ if (!stasis && Animation::isCombatAnimU8(lastanim)) {
putAwayWeapon(direction);
return;
}
Commit: 835803e269d156ec4cc241210c03df016b27175b
https://github.com/scummvm/scummvm/commit/835803e269d156ec4cc241210c03df016b27175b
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Put crusader crosshair in correct position
Changed paths:
engines/ultima/ultima8/world/actors/main_actor.cpp
engines/ultima/ultima8/world/actors/main_actor.h
engines/ultima/ultima8/world/crosshair_process.cpp
diff --git a/engines/ultima/ultima8/world/actors/main_actor.cpp b/engines/ultima/ultima8/world/actors/main_actor.cpp
index c70f44522d..d97a3adc16 100644
--- a/engines/ultima/ultima8/world/actors/main_actor.cpp
+++ b/engines/ultima/ultima8/world/actors/main_actor.cpp
@@ -39,6 +39,7 @@
#include "ultima/ultima8/graphics/anim_dat.h"
#include "ultima/ultima8/graphics/wpn_ovlay_dat.h"
#include "ultima/ultima8/graphics/shape_info.h"
+#include "ultima/ultima8/graphics/main_shape_archive.h"
#include "ultima/ultima8/gumps/cru_pickup_area_gump.h"
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/world/world.h"
@@ -50,6 +51,7 @@
#include "ultima/ultima8/world/sprite_process.h"
#include "ultima/ultima8/world/actors/avatar_gravity_process.h"
#include "ultima/ultima8/audio/music_process.h"
+#include "ultima/ultima8/world/actors/anim_action.h"
namespace Ultima {
namespace Ultima8 {
@@ -685,6 +687,24 @@ void MainActor::nextInvItem() {
_activeInvItem = getIdOfNextItemInList(items, _activeInvItem);
}
+void MainActor::addFireAnimOffsets(int32 &x, int32 &y, int32 &z) {
+ assert(GAME_IS_CRUSADER);
+ Animation::Sequence fireanim = (hasActorFlags(ACT_KNEELING) ? Animation::kneelAndFire : Animation::attack);
+ uint32 actionno = AnimDat::getActionNumberForSequence(fireanim, this);
+ Direction dir = getDir();
+
+ const AnimAction *animaction = GameData::get_instance()->getMainShapes()->getAnim(getShape(), actionno);
+ for (unsigned int i = 0; i < animaction->getSize(); i++) {
+ const AnimFrame &frame = animaction->getFrame(dir, i);
+ if (frame.is_cruattack()) {
+ x += frame.cru_attackx();
+ y += frame.cru_attacky();
+ z += frame.cru_attackz();
+ return;
+ }
+ }
+}
+
void MainActor::saveData(Common::WriteStream *ws) {
Actor::saveData(ws);
diff --git a/engines/ultima/ultima8/world/actors/main_actor.h b/engines/ultima/ultima8/world/actors/main_actor.h
index 76f3b50ead..bf47b02ac9 100644
--- a/engines/ultima/ultima8/world/actors/main_actor.h
+++ b/engines/ultima/ultima8/world/actors/main_actor.h
@@ -142,6 +142,9 @@ public:
//! Detonate used bomb
void detonateBomb();
+ //! Add the x/y/z fire offsets given the current state of the actor
+ void addFireAnimOffsets(int32 &x, int32 &y, int32 &z);
+
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;
diff --git a/engines/ultima/ultima8/world/crosshair_process.cpp b/engines/ultima/ultima8/world/crosshair_process.cpp
index 56cfa7e7da..132c42b356 100644
--- a/engines/ultima/ultima8/world/crosshair_process.cpp
+++ b/engines/ultima/ultima8/world/crosshair_process.cpp
@@ -55,26 +55,22 @@ void CrosshairProcess::run() {
if (mainactor->isInCombat()) {
Kernel *kernel = Kernel::get_instance();
assert(kernel);
- int32 cx, cy, cz, ax, ay, az;
- mainactor->getCentre(cx, cy, cz);
- mainactor->getFootpadWorld(ax, ay, az);
- // TODO: Make a fine adjustment for avatar height (eg, when crouching)
- // for now just put it at 3/4 avatar height which is about right.
- cz += az / 4;
+ int32 ax, ay, az;
+ mainactor->getLocation(ax, ay, az);
+ mainactor->addFireAnimOffsets(ax, ay, az);
const CruAvatarMoverProcess *mover = dynamic_cast<CruAvatarMoverProcess *>(Ultima8Engine::get_instance()->getAvatarMoverProcess());
if (!mover) {
warning("lost CruAvatarMoverProcess!");
return;
}
- // TODO: Get the fine angle of the avatar once that is implemented.
double angle = mover->getAvatarAngleDegrees() + 90.0;
// Convert angle to 0~2pi
double rads = Common::deg2rad(angle);
float xoff = CROSSHAIR_DIST * cos(rads);
float yoff = CROSSHAIR_DIST * sin(rads);
- cx -= static_cast<int32>(xoff);
- cy -= static_cast<int32>(yoff);
+ ax -= static_cast<int32>(xoff);
+ ay -= static_cast<int32>(yoff);
Item *item;
if (_itemNum) {
@@ -86,7 +82,7 @@ void CrosshairProcess::run() {
setItemNum(item->getObjId());
}
assert(item);
- item->move(cx, cy, cz);
+ item->move(ax, ay, az);
} else {
if (_itemNum) {
Item *item = getItem(_itemNum);
Commit: d3000bc45832e5dc2256cbf322d13c0e01fbb053
https://github.com/scummvm/scummvm/commit/d3000bc45832e5dc2256cbf322d13c0e01fbb053
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Correct ini file setting names set by debugger
Changed paths:
engines/ultima/ultima8/misc/debugger.cpp
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index dda3bf0442..bf5480e7d0 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -370,13 +370,13 @@ bool Debugger::cmdMemberVar(int argc, const char **argv) {
if (!scumm_stricmp(argv[1], "_frameLimit")) {
b = &g->_frameLimit;
- ini = "_frameLimit";
+ ini = "frameLimit";
} else if (!scumm_stricmp(argv[1], "_frameSkip")) {
b = &g->_frameSkip;
- ini = "_frameSkip";
+ ini = "frameSkip";
} else if (!scumm_stricmp(argv[1], "_interpolate")) {
b = &g->_interpolate;
- ini = "_interpolate";
+ ini = "interpolate";
} else {
debugPrintf("Unknown member: %s\n", argv[1]);
return true;
Commit: 74630555f04fce17cfd19f26630999634aae7e0a
https://github.com/scummvm/scummvm/commit/74630555f04fce17cfd19f26630999634aae7e0a
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Split kernel cycles from frame rate in a more consistent way
The original U8/Crusader Kernel runs different processes at different cycles
per second. For all the game processes we care about, they run at either 1 or
2 times per frame - until now that's been done by hacks and constants here and
there. This change makes the way it works far more consistent and removes a
lot of magic numbers.
Changed paths:
engines/ultima/ultima8/gumps/container_gump.cpp
engines/ultima/ultima8/gumps/game_map_gump.cpp
engines/ultima/ultima8/kernel/kernel.cpp
engines/ultima/ultima8/kernel/kernel.h
engines/ultima/ultima8/kernel/process.cpp
engines/ultima/ultima8/kernel/process.h
engines/ultima/ultima8/ultima8.cpp
engines/ultima/ultima8/ultima8.h
engines/ultima/ultima8/world/actors/actor.cpp
engines/ultima/ultima8/world/actors/attack_process.cpp
engines/ultima/ultima8/world/target_reticle_process.cpp
diff --git a/engines/ultima/ultima8/gumps/container_gump.cpp b/engines/ultima/ultima8/gumps/container_gump.cpp
index 136a8fbf35..aa79cbef9e 100644
--- a/engines/ultima/ultima8/gumps/container_gump.cpp
+++ b/engines/ultima/ultima8/gumps/container_gump.cpp
@@ -117,7 +117,7 @@ void ContainerGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
}
Std::list<Item *> &contents = c->_contents;
- int32 gametick = Kernel::get_instance()->getFrameNum();
+ int32 gameframeno = Kernel::get_instance()->getFrameNum();
//!! TODO: check these painting commands (flipped? translucent?)
bool paintEditorItems = Ultima8Engine::get_instance()->isPaintEditorItems();
@@ -125,7 +125,7 @@ void ContainerGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scale
Std::list<Item *>::iterator iter;
for (iter = contents.begin(); iter != contents.end(); ++iter) {
Item *item = *iter;
- item->setupLerp(gametick);
+ item->setupLerp(gameframeno);
if (!paintEditorItems && item->getShapeInfo()->is_editor())
continue;
diff --git a/engines/ultima/ultima8/gumps/game_map_gump.cpp b/engines/ultima/ultima8/gumps/game_map_gump.cpp
index 29ef2cb382..ded60fbcd2 100644
--- a/engines/ultima/ultima8/gumps/game_map_gump.cpp
+++ b/engines/ultima/ultima8/gumps/game_map_gump.cpp
@@ -125,8 +125,6 @@ void GameMapGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool scaled)
_displayList->BeginDisplayList(surf, lx, ly, lz);
uint32 gametick = Kernel::get_instance()->getFrameNum();
- if (GAME_IS_CRUSADER)
- gametick /= 2;
bool paintEditorItems = Ultima8Engine::get_instance()->isPaintEditorItems();
diff --git a/engines/ultima/ultima8/kernel/kernel.cpp b/engines/ultima/ultima8/kernel/kernel.cpp
index 9b12e55c92..a8630714c9 100644
--- a/engines/ultima/ultima8/kernel/kernel.cpp
+++ b/engines/ultima/ultima8/kernel/kernel.cpp
@@ -32,13 +32,18 @@ namespace Ultima8 {
Kernel *Kernel::_kernel = nullptr;
+const uint32 Kernel::TICKS_PER_FRAME = 2;
+const uint32 Kernel::TICKS_PER_SECOND = 60;
+const uint32 Kernel::FRAMES_PER_SECOND = Kernel::TICKS_PER_SECOND / Kernel::TICKS_PER_FRAME;
+
+
Kernel::Kernel() : _loading(false) {
debugN(MM_INFO, "Creating Kernel...\n");
_kernel = this;
_pIDs = new idMan(1, 32766, 128);
current_process = _processes.end();
- _frameNum = 0;
+ _tickNum = 0;
_paused = 0;
_runningProcess = nullptr;
_frameByFrame = false;
@@ -155,7 +160,7 @@ void Kernel::removeProcess(Process *proc) {
void Kernel::runProcesses() {
if (!_paused)
- _frameNum++;
+ _tickNum++;
if (_processes.size() == 0) {
return;
@@ -176,7 +181,8 @@ void Kernel::runProcesses() {
p->terminate();
}
if (!(p->is_terminated() || p->is_suspended()) &&
- (!_paused || (p->_flags & Process::PROC_RUNPAUSED))) {
+ (!_paused || (p->_flags & Process::PROC_RUNPAUSED)) &&
+ (_tickNum % p->getTicksPerRun() == 0)) {
_runningProcess = p;
p->run();
@@ -320,7 +326,7 @@ void Kernel::killProcessesNotOfType(ObjId objid, uint16 processtype, bool fail)
}
void Kernel::save(Common::WriteStream *ws) {
- ws->writeUint32LE(_frameNum);
+ ws->writeUint32LE(_tickNum);
_pIDs->save(ws);
ws->writeUint32LE(_processes.size());
for (ProcessIterator it = _processes.begin(); it != _processes.end(); ++it) {
@@ -341,7 +347,7 @@ void Kernel::save(Common::WriteStream *ws) {
}
bool Kernel::load(Common::ReadStream *rs, uint32 version) {
- _frameNum = rs->readUint32LE();
+ _tickNum = rs->readUint32LE();
if (!_pIDs->load(rs, version)) return false;
diff --git a/engines/ultima/ultima8/kernel/kernel.h b/engines/ultima/ultima8/kernel/kernel.h
index cd70851938..d039a3e1e6 100644
--- a/engines/ultima/ultima8/kernel/kernel.h
+++ b/engines/ultima/ultima8/kernel/kernel.h
@@ -122,8 +122,15 @@ public:
}
uint32 getFrameNum() const {
- return _frameNum;
+ return _tickNum / TICKS_PER_FRAME;
};
+ uint32 getTickNum() const {
+ return _tickNum;
+ };
+
+ static const uint32 TICKS_PER_FRAME;
+ static const uint32 TICKS_PER_SECOND;
+ static const uint32 FRAMES_PER_SECOND;
INTRINSIC(I_getNumProcesses);
INTRINSIC(I_resetRef);
@@ -139,7 +146,7 @@ private:
bool _loading;
- uint32 _frameNum;
+ uint32 _tickNum;
unsigned int _paused;
bool _frameByFrame;
diff --git a/engines/ultima/ultima8/kernel/process.cpp b/engines/ultima/ultima8/kernel/process.cpp
index 94d44cf666..c15a7e20f8 100644
--- a/engines/ultima/ultima8/kernel/process.cpp
+++ b/engines/ultima/ultima8/kernel/process.cpp
@@ -23,6 +23,7 @@
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/kernel/process.h"
#include "ultima/ultima8/kernel/kernel.h"
+#include "ultima/ultima8/kernel/core_app.h"
namespace Ultima {
namespace Ultima8 {
@@ -31,8 +32,12 @@ namespace Ultima8 {
DEFINE_RUNTIME_CLASSTYPE_CODE(Process)
Process::Process(ObjId it, uint16 ty)
- : _pid(0xFFFF), _flags(0), _itemNum(it), _type(ty), _result(0) {
+ : _pid(0xFFFF), _flags(0), _itemNum(it), _type(ty), _result(0), _ticksPerRun(2) {
Kernel::get_instance()->assignPID(this);
+ if (GAME_IS_CRUSADER) {
+ // Default kernel ticks per run of processes in Crusader
+ _ticksPerRun = 1;
+ }
}
void Process::fail() {
diff --git a/engines/ultima/ultima8/kernel/process.h b/engines/ultima/ultima8/kernel/process.h
index f8ece170d1..887acc0a5f 100644
--- a/engines/ultima/ultima8/kernel/process.h
+++ b/engines/ultima/ultima8/kernel/process.h
@@ -95,6 +95,9 @@ public:
void setType(uint16 ty) {
_type = ty;
}
+ void setTicksPerRun(uint32 val) {
+ _ticksPerRun = val;
+ }
ProcId getPid() const {
return _pid;
@@ -105,6 +108,9 @@ public:
uint16 getType() const {
return _type;
}
+ uint32 getTicksPerRun() const {
+ return _ticksPerRun;
+ }
//! dump some info about this process to pout
virtual void dumpInfo() const;
@@ -121,6 +127,10 @@ protected:
uint32 _flags;
+ //! how many kernel ticks between when this process should be run.
+ //! not saved because it's fixed by process type and game.
+ uint32 _ticksPerRun;
+
//! item we are assigned to
ObjId _itemNum;
uint16 _type;
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 0805181c96..bc524eea30 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -505,33 +505,40 @@ void Ultima8Engine::menuInitMinimal(istring gamename) {
pout << "-- Finished loading minimal--" << Std::endl << Std::endl;
}
+//
+// To time the frames, we use "fast" ticks which come 3000 times a second.
+//
+static uint32 _fastTicksNow() {
+ return g_system->getMillis() * 3;
+}
+
bool Ultima8Engine::runGame() {
_isRunning = true;
- int32 next_ticks = g_system->getMillis() * 3; // Next time is right now!
+ int32 next_ticks = _fastTicksNow(); // Next time is right now!
Common::Event event;
while (_isRunning) {
_inBetweenFrame = true; // Will get set false if it's not an _inBetweenFrame
if (!_frameLimit) {
- _kernel->runProcesses();
- if (GAME_IS_CRUSADER)
+ for (unsigned int tick = 0; tick < Kernel::TICKS_PER_FRAME; tick++) {
_kernel->runProcesses();
- _desktopGump->run();
+ _desktopGump->run();
+ }
_inBetweenFrame = false;
- next_ticks = _animationRate + g_system->getMillis() * 3;
+ next_ticks = _animationRate + _fastTicksNow();
_lerpFactor = 256;
} else {
- int32 ticks = g_system->getMillis() * 3;
+ int32 ticks = _fastTicksNow();
int32 diff = next_ticks - ticks;
while (diff < 0) {
next_ticks += _animationRate;
- _kernel->runProcesses();
- if (GAME_IS_CRUSADER)
+ for (unsigned int tick = 0; tick < Kernel::TICKS_PER_FRAME; tick++) {
_kernel->runProcesses();
- _desktopGump->run();
+ _desktopGump->run();
+ }
#if 0
perr << "--------------------------------------" << Std::endl;
perr << "NEW FRAME" << Std::endl;
@@ -539,7 +546,7 @@ bool Ultima8Engine::runGame() {
#endif
_inBetweenFrame = false;
- ticks = g_system->getMillis() * 3;
+ ticks = _fastTicksNow();
// If frame skipping is off, we will only recalc next
// ticks IF the frames are taking up 'way' too much time.
@@ -1390,7 +1397,7 @@ void Ultima8Engine::addGump(Gump *gump) {
uint32 Ultima8Engine::getGameTimeInSeconds() {
// 1 second per every 30 frames
- return (Kernel::get_instance()->getFrameNum() + _timeOffset) / 30; // constant!
+ return (Kernel::get_instance()->getFrameNum() + _timeOffset) / Kernel::FRAMES_PER_SECOND; // constant!
}
void Ultima8Engine::moveKeyEvent() {
@@ -1399,7 +1406,7 @@ void Ultima8Engine::moveKeyEvent() {
bool Ultima8Engine::moveKeyDownRecently() {
uint32 nowframe = Kernel::get_instance()->getFrameNum();
- return (nowframe - _moveKeyFrame) < 60;
+ return (nowframe - _moveKeyFrame) < 2 * Kernel::FRAMES_PER_SECOND;
}
void Ultima8Engine::save(Common::WriteStream *ws) {
@@ -1470,7 +1477,7 @@ uint32 Ultima8Engine::I_makeAvatarACheater(const uint8 * /*args*/,
uint32 Ultima8Engine::I_getCurrentTimerTick(const uint8 * /*args*/,
unsigned int /*argsize*/) {
// number of ticks of a 60Hz timer, with the default animrate of 30Hz
- return Kernel::get_instance()->getFrameNum() * 2;
+ return Kernel::get_instance()->getTickNum();
}
uint32 Ultima8Engine::I_setAvatarInStasis(const uint8 *args, unsigned int argsize) {
@@ -1536,7 +1543,7 @@ uint32 Ultima8Engine::I_setTimeInGameHours(const uint8 *args,
ARG_UINT16(newhour);
// 1 _game hour per every 27000 frames
- int32 absolute = newhour * 27000;
+ int32 absolute = newhour * 27000;
get_instance()->_timeOffset = absolute - Kernel::get_instance()->getFrameNum();
return 0;
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 1bdb7d29cb..4cdd197249 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -108,7 +108,7 @@ private:
bool _frameSkip; //!< Set to true to enable frame skipping (default false)
bool _frameLimit; //!< Set to true to enable frame limiting (default true)
bool _interpolate; //!< Set to true to enable interpolation (default true)
- int32 _animationRate; //!< The animation rate. Affects all processes! (default 100)
+ int32 _animationRate; //!< The animation rate, frames per second in "fast" ticks (3000 per second). Affects all processes! (default 100 = 30 fps)
// Sort of Camera Related Stuff, move somewhere else
diff --git a/engines/ultima/ultima8/world/actors/actor.cpp b/engines/ultima/ultima8/world/actors/actor.cpp
index 098c3cbb2c..33025ed4b3 100644
--- a/engines/ultima/ultima8/world/actors/actor.cpp
+++ b/engines/ultima/ultima8/world/actors/actor.cpp
@@ -831,7 +831,7 @@ void Actor::receiveHitCru(uint16 other, Direction dir, int damage, uint16 damage
if (isDead())
return;
- _lastTimeWasHit = Kernel::get_instance()->getFrameNum() * 2;
+ _lastTimeWasHit = Kernel::get_instance()->getTickNum();
if (shape != 1 && this != getControlledActor()) {
Actor *controlled = getControlledActor();
diff --git a/engines/ultima/ultima8/world/actors/attack_process.cpp b/engines/ultima/ultima8/world/actors/attack_process.cpp
index 5ca18a1728..9a26a4aae1 100644
--- a/engines/ultima/ultima8/world/actors/attack_process.cpp
+++ b/engines/ultima/ultima8/world/actors/attack_process.cpp
@@ -535,7 +535,7 @@ void AttackProcess::genericAttack() {
AudioProcess *audio = AudioProcess::get_instance();
const Direction curdir = a->getDir();
- const int32 now = Kernel::get_instance()->getFrameNum() * 2;
+ const int32 now = Kernel::get_instance()->getTickNum();
int wpnField8 = wpn ? wpn->getShapeInfo()->_weaponInfo->_field8 : 1;
const uint16 controlledNPC = World::get_instance()->getControlledNPCNum();
Direction targetdir = dir_invalid;
@@ -880,7 +880,7 @@ void AttackProcess::timeNowToTimerVal2(int now) {
}
void AttackProcess::setTimer3() {
- const int32 now = Kernel::get_instance()->getFrameNum() * 2;
+ const int32 now = Kernel::get_instance()->getTickNum();
_timer3set = true;
_timer3 = randomOf(10) * 60 + now;
return;
diff --git a/engines/ultima/ultima8/world/target_reticle_process.cpp b/engines/ultima/ultima8/world/target_reticle_process.cpp
index e516c06660..3a686a0436 100644
--- a/engines/ultima/ultima8/world/target_reticle_process.cpp
+++ b/engines/ultima/ultima8/world/target_reticle_process.cpp
@@ -64,7 +64,7 @@ void TargetReticleProcess::run() {
return;
}
- if (frameno - _lastUpdate < 60) {
+ if (frameno - _lastUpdate < 2 * Kernel::FRAMES_PER_SECOND) {
return;
}
Commit: 05853de65c50172b9f4379476b999b6b3f952d53
https://github.com/scummvm/scummvm/commit/05853de65c50172b9f4379476b999b6b3f952d53
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2021-01-01T15:07:37+09:00
Commit Message:
ULTIMA8: Improve const correctness of rendering functions
Changed paths:
engines/ultima/ultima8/graphics/point_scaler.cpp
engines/ultima/ultima8/graphics/render_surface.h
engines/ultima/ultima8/graphics/scaler.h
engines/ultima/ultima8/graphics/soft_render_surface.cpp
engines/ultima/ultima8/graphics/soft_render_surface.h
diff --git a/engines/ultima/ultima8/graphics/point_scaler.cpp b/engines/ultima/ultima8/graphics/point_scaler.cpp
index 568e13f7c4..99e3fb4c44 100644
--- a/engines/ultima/ultima8/graphics/point_scaler.cpp
+++ b/engines/ultima/ultima8/graphics/point_scaler.cpp
@@ -30,13 +30,13 @@ namespace Ultima8 {
// Very very simple point scaler
template<class uintX, class Manip, class uintS = uintX> class PointScalerInternal {
public:
- static bool Scale(Texture *tex , int32 sx, int32 sy, int32 sw, int32 sh,
+ static bool Scale(const Texture *tex , int32 sx, int32 sy, int32 sw, int32 sh,
uint8 *pixel, int32 dw, int32 dh, int32 pitch, bool clamp_src) {
// Source buffer pointers
- uintS *texel = reinterpret_cast<uintS *>(tex->getPixels()) + (sy * tex->w + sx);
+ const uintS *texel = reinterpret_cast<const uintS *>(tex->getPixels()) + (sy * tex->w + sx);
int tpitch = tex->w;
- uintS *tline_end = texel + sw;
- uintS *tex_end = texel + sh * tex->w;
+ const uintS *tline_end = texel + sw;
+ const uintS *tex_end = texel + sh * tex->w;
int tex_diff = tex->w - sw;
diff --git a/engines/ultima/ultima8/graphics/render_surface.h b/engines/ultima/ultima8/graphics/render_surface.h
index badd99bb4e..1b77be1f5e 100644
--- a/engines/ultima/ultima8/graphics/render_surface.h
+++ b/engines/ultima/ultima8/graphics/render_surface.h
@@ -180,31 +180,31 @@ public:
//! Paint a Shape
// TODO: virtual void Paint(CachedShape* s, uint32 frame, int32 x, int32 y) = 0;
- virtual void Paint(Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
+ virtual void Paint(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
//! Paint a Shape without clipping
// TODO: virtual void PaintNoClip(CachedShape*s, uint32 frame, int32 x, int32 y) = 0;
- virtual void PaintNoClip(Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
+ virtual void PaintNoClip(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
//! Paint a Translucent Shape.
// TODO: virtual void PaintTranslucent(CachedShape* s, uint32 frame, int32 x, int32 y) = 0;
- virtual void PaintTranslucent(Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
+ virtual void PaintTranslucent(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) = 0;
//! Paint a Mirrored Shape
// TODO: virtual void PaintMirrored(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans = false) = 0;
- virtual void PaintMirrored(Shape *s, uint32 frame, int32 x, int32 y, bool trans = false, bool untformed_pal = false) = 0;
+ virtual void PaintMirrored(const Shape *s, uint32 frame, int32 x, int32 y, bool trans = false, bool untformed_pal = false) = 0;
//! Paint an Invisible Shape
// TODO: virtual void PaintInvisible(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored) = 0;
- virtual void PaintInvisible(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal = false) = 0;
+ virtual void PaintInvisible(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal = false) = 0;
//! Paint a Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
// TODO: virtual void PaintHighlight(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
- virtual void PaintHighlight(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
+ virtual void PaintHighlight(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
//! Paint a Invisible Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
// TODO: virtual void PaintHighlightInvis(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
- virtual void PaintHighlightInvis(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
+ virtual void PaintHighlightInvis(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
//
// Basic Line Drawing
@@ -221,10 +221,10 @@ public:
// Basic Font Drawing
//
//! Draw FixedWidthFont
- virtual void PrintTextFixed(FixedWidthFont *, const char *text, int x, int y) = 0;
+ virtual void PrintTextFixed(const FixedWidthFont *, const char *text, int x, int y) = 0;
//! Draw a fixed width character from a FixedWidthFont
- virtual void PrintCharFixed(FixedWidthFont *, int character, int x, int y) = 0;
+ virtual void PrintCharFixed(const FixedWidthFont *, int character, int x, int y) = 0;
//
@@ -232,24 +232,20 @@ public:
//
//! Blit a region from a Texture (Alpha == 0 -> skipped)
- virtual void Blit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) = 0;
+ virtual void Blit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) = 0;
//! Blit a region from a Texture with a Colour blend (AlphaTex == 0 -> skipped. AlphaCol32 -> Blend Factors)
- virtual void FadedBlit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
+ virtual void FadedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
//! Blit a region from a Texture with a Colour blend masked based on DestAlpha (AlphaTex == 0 || AlphaDest == 0 -> skipped. AlphaCol32 -> Blend Factors)
- virtual void MaskedBlit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
+ virtual void MaskedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) = 0;
//! Blit a stretched region from a Texture (Alpha == 0 -> skipped???)
- virtual void StretchBlit(Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, bool clampedges = false) = 0;
+ virtual void StretchBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, bool clampedges = false) = 0;
//! Blit a region from a Texture using a scaler
- virtual bool ScalerBlit(Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *, bool clampedges = false) = 0;
+ virtual bool ScalerBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *, bool clampedges = false) = 0;
-
- ////////////////////////////////////////
- // TODO: Add in Abstract 3d code Here //
- ////////////////////////////////////////
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/graphics/scaler.h b/engines/ultima/ultima8/graphics/scaler.h
index 1d3eb1726a..f76f819f00 100644
--- a/engines/ultima/ultima8/graphics/scaler.h
+++ b/engines/ultima/ultima8/graphics/scaler.h
@@ -34,7 +34,7 @@ class Scaler {
friend class hqScaler;
protected:
// Basic scaler function template
- typedef bool (*ScalerFunc)(Texture *tex, int32 sx, int32 sy, int32 sw, int32 sh,
+ typedef bool (*ScalerFunc)(const Texture *tex, int32 sx, int32 sy, int32 sw, int32 sh,
uint8 *pixel, int32 dw, int32 dh, int32 pitch, bool clamp_src);
//
@@ -63,7 +63,7 @@ public:
// virtual bool SetDisplayFormat(const RenderSurface::Format &format);
// Call this to scale a section of the screen
- inline bool Scale(Texture *texture, int32 sx, int32 sy, int32 sw, int32 sh,
+ inline bool Scale(const Texture *texture, int32 sx, int32 sy, int32 sw, int32 sh,
uint8 *pixel, int32 dw, int32 dh, int32 pitch, bool clamp_src) const {
// Check to see if we are doing valid integer scalings
if (!ScaleArbitrary()) {
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.cpp b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
index 75296d63a1..39de776740 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.cpp
@@ -364,7 +364,7 @@ template<class uintX> void SoftRenderSurface<uintX>::DrawLine32(uint32 rgb, int3
//
// Desc: Blit a region from a Texture (Alpha == 0 -> skipped)
//
-template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend) {
+template<class uintX> void SoftRenderSurface<uintX>::Blit(const Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend) {
// Clamp or wrap or return?
if (sx + w > static_cast<int32>(_tex->w))
return;
@@ -425,7 +425,7 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
texel += tex_diff;
}
} else if (_tex->_format == TEX_FMT_NATIVE) {
- uintX *texel = reinterpret_cast<uintX *>(_tex->getBasePtr(sx, sy));
+ const uintX *texel = reinterpret_cast<const uintX *>(_tex->getBasePtr(sx, sy));
int tex_diff = _tex->w - w;
while (pixel != end) {
@@ -453,7 +453,7 @@ template<class uintX> void SoftRenderSurface<uintX>::Blit(Texture *_tex, int32 s
//
// Desc: Blit a region from a Texture (Alpha == 0 -> skipped)
//
-template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
+template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(const Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
// Clamp or wrap or return?
if (w > static_cast<int32>(_tex->w))
return;
@@ -542,7 +542,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, in
texel += tex_diff;
}
} else if (_tex->_format == TEX_FMT_NATIVE) {
- uintX *texel = reinterpret_cast<uintX *>(_tex->getBasePtr(sx, sy));
+ const uintX *texel = reinterpret_cast<const uintX *>(_tex->getBasePtr(sx, sy));
int tex_diff = _tex->w - w;
while (pixel != end) {
@@ -570,7 +570,7 @@ template<class uintX> void SoftRenderSurface<uintX>::FadedBlit(Texture *_tex, in
// Desc Blit a region from a Texture with a Colour blend masked based on DestAlpha (AlphaTex == 0 || AlphaDest == 0 -> skipped. AlphaCol32 -> Blend Factors)
//
//
-template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
+template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(const Texture *_tex, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend) {
// Clamp or wrap or return?
if (w > static_cast<int32>(_tex->w))
return;
@@ -669,7 +669,7 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, i
texel += tex_diff;
}
} else if (_tex->_format == TEX_FMT_NATIVE) {
- uintX *texel = reinterpret_cast<uintX *>(_tex->getBasePtr(sx, sy));
+ const uintX *texel = reinterpret_cast<const uintX *>(_tex->getBasePtr(sx, sy));
int tex_diff = _tex->w - w;
while (pixel != end) {
@@ -700,7 +700,7 @@ template<class uintX> void SoftRenderSurface<uintX>::MaskedBlit(Texture *_tex, i
// Desc: Blit a region from a Texture, and arbitrarily stretch it to fit the dest region
//
//
-template<class uintX> void SoftRenderSurface<uintX>::StretchBlit(Texture *texture,
+template<class uintX> void SoftRenderSurface<uintX>::StretchBlit(const Texture *texture,
int32 sx, int32 sy, int32 sw, int32 sh,
int32 dx, int32 dy, int32 dw, int32 dh,
bool clampedges) {
@@ -723,7 +723,7 @@ template<class uintX> void SoftRenderSurface<uintX>::StretchBlit(Texture *textur
// Desc: Blit a region from a Texture using a scaler
//
//
-template<class uintX> bool SoftRenderSurface<uintX>::ScalerBlit(Texture *texture, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *scaler, bool clampedges) {
+template<class uintX> bool SoftRenderSurface<uintX>::ScalerBlit(const Texture *texture, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *scaler, bool clampedges) {
// Nothing we can do
if ((sh <= 0) || (dh <= 0) || (sw <= 0) || (dw <= 0)) return false;
@@ -743,7 +743,7 @@ template<class uintX> bool SoftRenderSurface<uintX>::ScalerBlit(Texture *texture
//
// Desc: Draw a fixed width character from a Texture buffer
//
-template<class uintX> void SoftRenderSurface<uintX>::PrintCharFixed(FixedWidthFont *font, int character, int x, int y) {
+template<class uintX> void SoftRenderSurface<uintX>::PrintCharFixed(const FixedWidthFont *font, int character, int x, int y) {
if (character == ' ') return; // Don't paint spaces
int align_x = font->_alignX;
@@ -767,7 +767,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PrintCharFixed(FixedWidthFo
//
// Desc: Draw fixed width from a Texture buffer (16x16 characters fixed width and height)
//
-template<class uintX> void SoftRenderSurface<uintX>::PrintTextFixed(FixedWidthFont *font, const char *text, int x, int y) {
+template<class uintX> void SoftRenderSurface<uintX>::PrintTextFixed(const FixedWidthFont *font, const char *text, int x, int y) {
int align_x = font->_alignX;
int align_y = font->_alignY;
int char_width = font->_width;
@@ -798,7 +798,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PrintTextFixed(FixedWidthFo
//
// Desc: Standard shape drawing functions. Clips but doesn't do anything else
//
-template<class uintX> void SoftRenderSurface<uintX>::Paint(Shape *s, uint32 framenum, int32 x, int32 y, bool untformed_pal) {
+template<class uintX> void SoftRenderSurface<uintX>::Paint(const Shape *s, uint32 framenum, int32 x, int32 y, bool untformed_pal) {
#include "ultima/ultima8/graphics/soft_render_surface.inl"
}
@@ -808,7 +808,7 @@ template<class uintX> void SoftRenderSurface<uintX>::Paint(Shape *s, uint32 fram
//
// Desc: Standard shape drawing functions. Doesn't clip
//
-template<class uintX> void SoftRenderSurface<uintX>::PaintNoClip(Shape *s, uint32 framenum, int32 x, int32 y, bool untformed_pal) {
+template<class uintX> void SoftRenderSurface<uintX>::PaintNoClip(const Shape *s, uint32 framenum, int32 x, int32 y, bool untformed_pal) {
#define NO_CLIPPING
#include "ultima/ultima8/graphics/soft_render_surface.inl"
#undef NO_CLIPPING
@@ -820,7 +820,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintNoClip(Shape *s, uint3
//
// Desc: Standard shape drawing functions. Clips and XForms
//
-template<class uintX> void SoftRenderSurface<uintX>::PaintTranslucent(Shape *s, uint32 framenum, int32 x, int32 y, bool untformed_pal) {
+template<class uintX> void SoftRenderSurface<uintX>::PaintTranslucent(const Shape *s, uint32 framenum, int32 x, int32 y, bool untformed_pal) {
#define XFORM_SHAPES
#include "ultima/ultima8/graphics/soft_render_surface.inl"
#undef XFORM_SHAPES
@@ -832,7 +832,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintTranslucent(Shape *s,
//
// Desc: Standard shape drawing functions. Clips, Flips and conditionally XForms
//
-template<class uintX> void SoftRenderSurface<uintX>::PaintMirrored(Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool untformed_pal) {
+template<class uintX> void SoftRenderSurface<uintX>::PaintMirrored(const Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool untformed_pal) {
#define FLIP_SHAPES
#define XFORM_SHAPES
#define XFORM_CONDITIONAL trans
@@ -851,7 +851,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintMirrored(Shape *s, uin
// Desc: Standard shape drawing functions. Invisible, Clips, and conditionally Flips and Xforms
//
-template<class uintX> void SoftRenderSurface<uintX>::PaintInvisible(Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal) {
+template<class uintX> void SoftRenderSurface<uintX>::PaintInvisible(const Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal) {
#define FLIP_SHAPES
#define FLIP_CONDITIONAL mirrored
#define XFORM_SHAPES
@@ -874,7 +874,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintInvisible(Shape *s, ui
// Desc: Standard shape drawing functions. Highlights, Clips, and conditionally Flips and Xforms
//
-template<class uintX> void SoftRenderSurface<uintX>::PaintHighlight(Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal) {
+template<class uintX> void SoftRenderSurface<uintX>::PaintHighlight(const Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal) {
#define FLIP_SHAPES
#define FLIP_CONDITIONAL mirrored
#define XFORM_SHAPES
@@ -901,7 +901,7 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintHighlight(Shape *s, ui
// Desc: Standard shape drawing functions. Highlights, Clips, and conditionally Flips and Xforms. 50% translucent
//
-template<class uintX> void SoftRenderSurface<uintX>::PaintHighlightInvis(Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal) {
+template<class uintX> void SoftRenderSurface<uintX>::PaintHighlightInvis(const Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal) {
#define FLIP_SHAPES
#define FLIP_CONDITIONAL mirrored
#define XFORM_SHAPES
diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.h b/engines/ultima/ultima8/graphics/soft_render_surface.h
index 7ef1b5ab08..15e05a4f39 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.h
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.h
@@ -80,31 +80,31 @@ public:
// Paint a Shape
// TODO: virtual void Paint(CachedShape* s, uint32 frame, int32 x, int32 y);
- void Paint(Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
+ void Paint(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
// Paint an Shape without clipping
// TODO: virtual void PaintNoClip(CachedShape*s, uint32 frame, int32 x, int32 y);
- void PaintNoClip(Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
+ void PaintNoClip(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
// Paint a Translucent Shape.
// TODO: virtual void PaintTranslucent(CachedShape* s, uint32 frame, int32 x, int32 y);
- void PaintTranslucent(Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
+ void PaintTranslucent(const Shape *s, uint32 frame, int32 x, int32 y, bool untformed_pal = false) override;
// Paint a Mirrored Shape
// TODO: virtual void PaintMirrored(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans = false);
- void PaintMirrored(Shape *s, uint32 frame, int32 x, int32 y, bool trans = false, bool untformed_pal = false) override;
+ void PaintMirrored(const Shape *s, uint32 frame, int32 x, int32 y, bool trans = false, bool untformed_pal = false) override;
// Paint a Invisible Shape
// TODO: virtual void PaintInvisible(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored);
- void PaintInvisible(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal = false) override;
+ void PaintInvisible(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, bool untformed_pal = false) override;
// Paint a Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
// TODO: virtual void PaintHighlight(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
- void PaintHighlight(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) override;
+ void PaintHighlight(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) override;
// Paint a Invisible Highlighted Shape of using the 32 Bit Colour col32 (0xAARRGGBB Alpha is blend level)
// TODO: virtual void PaintHighlightInvis(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
- void PaintHighlightInvis(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) override;
+ void PaintHighlightInvis(const Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) override;
//
// Basic Line Drawing
@@ -121,10 +121,10 @@ public:
// Basic Font Drawing
//
// Draw FixedWidthFont
- void PrintTextFixed(FixedWidthFont *, const char *text, int x, int y) override;
+ void PrintTextFixed(const FixedWidthFont *, const char *text, int x, int y) override;
// Draw a fixed width character from a FixedWidthFont
- void PrintCharFixed(FixedWidthFont *, int character, int x, int y) override;
+ void PrintCharFixed(const FixedWidthFont *, int character, int x, int y) override;
//
@@ -132,23 +132,19 @@ public:
//
// Blit a region from a Texture (Alpha == 0 -> skipped)
- void Blit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) override;
+ void Blit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, bool alpha_blend = false) override;
// Blit a region from a Texture with a Colour blend (AlphaTex == 0 -> skipped. AlphaCol32 -> Blend Factors)
- void FadedBlit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
+ void FadedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
// Blit a region from a Texture with a Colour blend masked based on DestAlpha (AlphaTex == 0 || AlphaDest == 0 -> skipped. AlphaCol32 -> Blend Factors)
- void MaskedBlit(Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
+ void MaskedBlit(const Texture *, int32 sx, int32 sy, int32 w, int32 h, int32 dx, int32 dy, uint32 col32, bool alpha_blend = false) override;
// Blit a stretched region from a Texture (Alpha == 0 -> skipped)
- void StretchBlit(Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, bool clampedges = false) override;
+ void StretchBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, bool clampedges = false) override;
// Blit a region from a Texture using a scaler
- bool ScalerBlit(Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *, bool clampedges = false) override;
-
- ////////////////////////////////////////
- // TODO: Add in Abstract 3d code Here //
- ////////////////////////////////////////
+ bool ScalerBlit(const Texture *, int32 sx, int32 sy, int32 sw, int32 sh, int32 dx, int32 dy, int32 dw, int32 dh, const Scaler *, bool clampedges = false) override;
};
} // End of namespace Ultima8
More information about the Scummvm-git-logs
mailing list