From 6727138e64801426d89afaa5834077c641dc0b56 Mon Sep 17 00:00:00 2001
From: Lwmte
Date: Thu, 19 Aug 2021 18:43:52 +0300
Subject: [PATCH 1/9] Add RefreshFloorGlobals hack to temporarily fix issues
with monkeyswing and possibly other states
---
TR5Main/Game/Lara/lara.cpp | 4 ++++
TR5Main/Game/collide.cpp | 7 +++++++
TR5Main/Game/collide.h | 1 +
3 files changed, 12 insertions(+)
diff --git a/TR5Main/Game/Lara/lara.cpp b/TR5Main/Game/Lara/lara.cpp
index 8e27fd4cf..67db07aa2 100644
--- a/TR5Main/Game/Lara/lara.cpp
+++ b/TR5Main/Game/Lara/lara.cpp
@@ -920,6 +920,10 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll) //hmmmm
// Check for collision with items
LaraBaddieCollision(item, coll);
+ // FIXME: refresh floor globals because sometimes they are messed by calling GetFloorHeight
+ // all over the place. Needed for monkeyswing. Remove when block flags decoupled from floordata. -- Lwmte 19.08.21
+ RefreshFloorGlobals(item);
+
// Handle Lara collision
if (Lara.Vehicle == NO_ITEM)
lara_collision_routines[item->currentAnimState](item, coll);
diff --git a/TR5Main/Game/collide.cpp b/TR5Main/Game/collide.cpp
index 4d6056ffd..74c78be87 100644
--- a/TR5Main/Game/collide.cpp
+++ b/TR5Main/Game/collide.cpp
@@ -1258,6 +1258,13 @@ void DoFloorThings(FLOOR_INFO* floor, int x, int y, int z)
}
}
+void RefreshFloorGlobals(ITEM_INFO* item)
+{
+ auto room = item->roomNumber;
+ auto floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &room);
+ DoFloorThings(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
+}
+
void GetCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight)
{
int resetRoom;
diff --git a/TR5Main/Game/collide.h b/TR5Main/Game/collide.h
index 390367a3e..1b35220e2 100644
--- a/TR5Main/Game/collide.h
+++ b/TR5Main/Game/collide.h
@@ -127,6 +127,7 @@ int Move3DPosTo3DPos(PHD_3DPOS* src, PHD_3DPOS* dest, int velocity, short angAdd
int MoveLaraPosition(PHD_VECTOR* pos, ITEM_INFO* item, ITEM_INFO* l);
int TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* l, int radius);
void CreatureCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
+void RefreshFloorGlobals(ITEM_INFO* item);
void GetCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight);
void GetObjectCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight);
void LaraBaddieCollision(ITEM_INFO* item, COLL_INFO* coll);
From e74fa376d14e8614cfde71bba51452bf91ff033a Mon Sep 17 00:00:00 2001
From: hispidence
Date: Fri, 20 Aug 2021 01:37:49 +0100
Subject: [PATCH 2/9] Move index_error_maker into new file (ScriptUtil.h). Add
newindex_error_maker. Make them call ScriptAssert instead of just throwing an
exception so it won't terminate the application on WARN or SILENT error
modes.
---
TR5Main/Scripting/GameScriptNamedBase.h | 7 -------
TR5Main/Scripting/ScriptUtil.h | 13 +++++++++++++
TR5Main/TR5Main.vcxproj | 1 +
TR5Main/TR5Main.vcxproj.filters | 3 +++
4 files changed, 17 insertions(+), 7 deletions(-)
create mode 100644 TR5Main/Scripting/ScriptUtil.h
diff --git a/TR5Main/Scripting/GameScriptNamedBase.h b/TR5Main/Scripting/GameScriptNamedBase.h
index 3c1ee3b63..7469928e9 100644
--- a/TR5Main/Scripting/GameScriptNamedBase.h
+++ b/TR5Main/Scripting/GameScriptNamedBase.h
@@ -3,13 +3,6 @@
#include
#include
-
-#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
-{ \
- std::string err = "Attempted to read non-existant var \"" + key.as() + "\" from " + LUA_CLASS_NAME; \
- throw TENScriptException(err); \
-}
-
template using callbackSetName = std::function;
using callbackRemoveName = std::function;
diff --git a/TR5Main/Scripting/ScriptUtil.h b/TR5Main/Scripting/ScriptUtil.h
new file mode 100644
index 000000000..e9690389d
--- /dev/null
+++ b/TR5Main/Scripting/ScriptUtil.h
@@ -0,0 +1,13 @@
+#pragma once
+#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
+{ \
+ std::string err = "Attempted to read non-existant var \"" + key.as() + "\" from " + LUA_CLASS_NAME; \
+ ScriptAssert(false, err);\
+}
+
+#define newindex_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
+{ \
+ std::string err = "Attempted to set non-existant var \"" + key.as() + "\" of " + LUA_CLASS_NAME; \
+ ScriptAssert(false, err);\
+}
+
diff --git a/TR5Main/TR5Main.vcxproj b/TR5Main/TR5Main.vcxproj
index 55db006c4..963ed4372 100644
--- a/TR5Main/TR5Main.vcxproj
+++ b/TR5Main/TR5Main.vcxproj
@@ -410,6 +410,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"
+
diff --git a/TR5Main/TR5Main.vcxproj.filters b/TR5Main/TR5Main.vcxproj.filters
index 3af423eec..db350d76d 100644
--- a/TR5Main/TR5Main.vcxproj.filters
+++ b/TR5Main/TR5Main.vcxproj.filters
@@ -1050,6 +1050,9 @@
File di intestazione
+
+ File di intestazione
+
From 12d896776a4d95258f4020cddb8af719194607b0 Mon Sep 17 00:00:00 2001
From: hispidence
Date: Fri, 20 Aug 2021 01:41:14 +0100
Subject: [PATCH 3/9] Give newindex errors to script classes which already have
index errors.
---
TR5Main/Scripting/GameScriptAIObject.cpp | 3 +++
TR5Main/Scripting/GameScriptCameraInfo.cpp | 3 +++
TR5Main/Scripting/GameScriptItemInfo.cpp | 3 +++
TR5Main/Scripting/GameScriptMeshInfo.cpp | 3 +++
TR5Main/Scripting/GameScriptSinkInfo.cpp | 3 +++
5 files changed, 15 insertions(+)
diff --git a/TR5Main/Scripting/GameScriptAIObject.cpp b/TR5Main/Scripting/GameScriptAIObject.cpp
index 347b95978..bc8aed2a0 100644
--- a/TR5Main/Scripting/GameScriptAIObject.cpp
+++ b/TR5Main/Scripting/GameScriptAIObject.cpp
@@ -3,6 +3,7 @@
#include "GameScriptAIObject.h"
#include "ScriptAssert.h"
#include "GameScriptPosition.h"
+#include "ScriptUtil.h"
#include
/***
AI object
@@ -15,6 +16,7 @@ AI object
constexpr auto LUA_CLASS_NAME{ "AIObject" };
static auto index_error = index_error_maker(GameScriptAIObject, LUA_CLASS_NAME);
+static auto newindex_error = newindex_error_maker(GameScriptAIObject, LUA_CLASS_NAME);
GameScriptAIObject::GameScriptAIObject(AI_OBJECT & ref, bool temp) : m_aiObject{ref}, m_temporary{ temp }
{};
@@ -30,6 +32,7 @@ void GameScriptAIObject::Register(sol::state* state)
{
state->new_usertype(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
+ sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos
diff --git a/TR5Main/Scripting/GameScriptCameraInfo.cpp b/TR5Main/Scripting/GameScriptCameraInfo.cpp
index 33c676bfa..2d1af133b 100644
--- a/TR5Main/Scripting/GameScriptCameraInfo.cpp
+++ b/TR5Main/Scripting/GameScriptCameraInfo.cpp
@@ -2,6 +2,7 @@
#include "ScriptAssert.h"
#include "GameScriptCameraInfo.h"
#include "GameScriptPosition.h"
+#include "ScriptUtil.h"
/***
Camera info
@@ -12,6 +13,7 @@ Camera info
static constexpr auto LUA_CLASS_NAME{ "CameraInfo" };
static auto index_error = index_error_maker(GameScriptCameraInfo, LUA_CLASS_NAME);
+static auto newindex_error = newindex_error_maker(GameScriptCameraInfo, LUA_CLASS_NAME);
GameScriptCameraInfo::GameScriptCameraInfo(LEVEL_CAMERA_INFO & ref, bool temp) : m_camera{ref}, m_temporary{ temp }
{};
@@ -27,6 +29,7 @@ void GameScriptCameraInfo::Register(sol::state* state)
{
state->new_usertype(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
+ sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos
diff --git a/TR5Main/Scripting/GameScriptItemInfo.cpp b/TR5Main/Scripting/GameScriptItemInfo.cpp
index bea9444ac..8d94cbb98 100644
--- a/TR5Main/Scripting/GameScriptItemInfo.cpp
+++ b/TR5Main/Scripting/GameScriptItemInfo.cpp
@@ -1,6 +1,7 @@
#include "framework.h"
#include "ScriptAssert.h"
#include "GameScriptItemInfo.h"
+#include "ScriptUtil.h"
#include "items.h"
#include "objectslist.h"
#include "level.h"
@@ -23,6 +24,7 @@ pickups, and Lara herself.
constexpr auto LUA_CLASS_NAME{ "ItemInfo" };
static auto index_error = index_error_maker(GameScriptItemInfo, LUA_CLASS_NAME);
+static auto newindex_error = newindex_error_maker(GameScriptItemInfo, LUA_CLASS_NAME);
GameScriptItemInfo::GameScriptItemInfo(short num, bool temp) : m_item{ &g_Level.Items[num] }, m_num{ num }, m_initialised{ false }, m_temporary{ temp }
{};
@@ -167,6 +169,7 @@ void GameScriptItemInfo::Register(sol::state* state)
"newItem", sol::overload(Create, CreateEmpty),
"newItemTemporary", sol::overload(Create, CreateEmpty),
sol::meta_function::index, index_error,
+ sol::meta_function::new_index, newindex_error,
/// Initialise an item.
//Use this if you called new with no arguments
diff --git a/TR5Main/Scripting/GameScriptMeshInfo.cpp b/TR5Main/Scripting/GameScriptMeshInfo.cpp
index 16b45127a..13f3bd0c1 100644
--- a/TR5Main/Scripting/GameScriptMeshInfo.cpp
+++ b/TR5Main/Scripting/GameScriptMeshInfo.cpp
@@ -4,6 +4,7 @@
#include "GameScriptMeshInfo.h"
#include "GameScriptPosition.h"
#include "GameScriptColor.h"
+#include "ScriptUtil.h"
#include
/***
Mesh info
@@ -15,6 +16,7 @@ Mesh info
constexpr auto LUA_CLASS_NAME{ "MeshInfo" };
static auto index_error = index_error_maker(GameScriptMeshInfo, LUA_CLASS_NAME);
+static auto newindex_error = newindex_error_maker(GameScriptMeshInfo, LUA_CLASS_NAME);
GameScriptMeshInfo::GameScriptMeshInfo(MESH_INFO & ref, bool temp) : m_mesh{ref}, m_temporary{ temp }
{};
@@ -30,6 +32,7 @@ void GameScriptMeshInfo::Register(sol::state* state)
{
state->new_usertype(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
+ sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos
diff --git a/TR5Main/Scripting/GameScriptSinkInfo.cpp b/TR5Main/Scripting/GameScriptSinkInfo.cpp
index 94167f366..907e02cbf 100644
--- a/TR5Main/Scripting/GameScriptSinkInfo.cpp
+++ b/TR5Main/Scripting/GameScriptSinkInfo.cpp
@@ -3,6 +3,7 @@
#include "ScriptAssert.h"
#include "GameScriptSinkInfo.h"
#include "GameScriptPosition.h"
+#include "ScriptUtil.h"
#include
/***
Sink info
@@ -14,6 +15,7 @@ Sink info
constexpr auto LUA_CLASS_NAME{ "SinkInfo" };
static auto index_error = index_error_maker(GameScriptSinkInfo, LUA_CLASS_NAME);
+static auto newindex_error = newindex_error_maker(GameScriptSinkInfo, LUA_CLASS_NAME);
GameScriptSinkInfo::GameScriptSinkInfo(SINK_INFO & ref, bool temp) : m_sink{ref}, m_temporary{ temp }
{};
@@ -29,6 +31,7 @@ void GameScriptSinkInfo::Register(sol::state* state)
{
state->new_usertype(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
+ sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos
From 7af11a9bf4d73016440e1d4f115e52ad8f07563d Mon Sep 17 00:00:00 2001
From: hispidence
Date: Fri, 20 Aug 2021 01:48:06 +0100
Subject: [PATCH 4/9] Add unlimitedAir documentation comment.
---
TR5Main/Scripting/GameScriptLevel.cpp | 9 +++++-
doc/classes/Level.html | 42 +++++++++++++++++++++------
2 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/TR5Main/Scripting/GameScriptLevel.cpp b/TR5Main/Scripting/GameScriptLevel.cpp
index d977c3519..f68fdffd9 100644
--- a/TR5Main/Scripting/GameScriptLevel.cpp
+++ b/TR5Main/Scripting/GameScriptLevel.cpp
@@ -128,8 +128,15 @@ This is equivalent to TRNG's LevelFarView variable.
__(not yet implemented)__
@mem farView
*/
-
"farView", sol::property(&GameScriptLevel::SetLevelFarView),
+
+/*** (bool) If true, the player will have an unlimited oxygen supply when in water.
+
+ __(not yet implemented)__
+@mem unlimitedAir
+*/
+ "unlimitedAir", &GameScriptLevel::UnlimitedAir,
+
/// (table of @{InventoryObject}s) table of inventory object overrides
//@mem objects
"objects", &GameScriptLevel::InventoryObjects
diff --git a/doc/classes/Level.html b/doc/classes/Level.html
index e153e7358..9c0abc189 100644
--- a/doc/classes/Level.html
+++ b/doc/classes/Level.html
@@ -147,6 +147,10 @@ level file itself.
(byte) The maximum draw distance, in sectors (blocks), of this particular level. |
+ Level.unlimitedAir |
+ (bool) If true, the player will have an unlimited oxygen supply when in water. |
+
+
Level.objects |
(table of InventoryObjects) table of inventory object overrides |
@@ -270,8 +274,9 @@ level file itself.
(Color) distance fog RGB color (as seen in TR4's Desert Railroad).
- If not provided, distance fog will be black.
- (not yet implemented)
+ If not provided, distance fog will be black.
+
+ (not yet implemented)
@@ -300,8 +305,9 @@ level file itself.
(bool) if true, the horizon graphic will transition smoothly to the sky layer.
- If set to false, there will be a black band between the two.
- (not yet implemented)
+ If set to false, there will be a black band between the two.
+
+ (not yet implemented)
@@ -316,8 +322,9 @@ level file itself.
(bool) equivalent to classic TRLE's LIGHTNING setting.
- If true, there will be a flickering lightning in the skylayer, as in the TRC Ireland levels.
- (thunder sounds not yet implemented)
+ If true, there will be a flickering lightning in the skylayer, as in the TRC Ireland levels.
+
+ (thunder sounds not yet implemented)
@@ -331,8 +338,9 @@ level file itself.
Level.weather
- (WeatherType) Must be one of the values WeatherType.NORMAL, WeatherType.RAIN, or WeatherType.SNOW.
- (not yet implemented)
+ (WeatherType) Must be one of the values WeatherType.NORMAL, WeatherType.RAIN, or WeatherType.SNOW.
+
+ (not yet implemented)
@@ -442,6 +450,22 @@ number, the faster the scroll will be.
+
+
+
+ Level.unlimitedAir
+
+
+ (bool) If true, the player will have an unlimited oxygen supply when in water.
+
+ (not yet implemented)
+
+
+
+
+
+
+
@@ -487,7 +511,7 @@ number, the faster the scroll will be.
generated by LDoc 1.4.6
-
Last updated 2021-08-17 03:39:52
+
Last updated 2021-08-20 01:47:29