Skip to content

Commit

Permalink
Merge branch 'master' into collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
pskelton authored Oct 27, 2024
2 parents 8aa8ac9 + 78756c5 commit c59b83f
Show file tree
Hide file tree
Showing 20 changed files with 289 additions and 302 deletions.
12 changes: 12 additions & 0 deletions src/Application/GameConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ class GameConfig : public Config {
using String = ConfigEntry<std::string>;
using Key = ConfigEntry<PlatformKey>;

class Audio : public ConfigSection {
public:
explicit Audio(GameConfig *config) : ConfigSection(config, "audio") {}

Bool DisableHRTF = {this, "disable_hrtf", true, "Disable HRTF for headphones."};
};

Audio audio{ this };

class Debug : public ConfigSection {
public:
explicit Debug(GameConfig *config) : ConfigSection(config, "debug") {}
Expand Down Expand Up @@ -71,6 +80,7 @@ class GameConfig : public Config {

Bool NoLogo = {this, "no_logo", false, "Skip 3do logo on startup."};

// TODO(captainurist): Move to [audio]?
Bool NoSound = {this, "no_sound", false, "Don't play any sounds. Currently in-house movies are not affected."};

Bool NoVideo = {this, "no_video", false, "Don't play any movies."};
Expand Down Expand Up @@ -545,6 +555,7 @@ class GameConfig : public Config {

Bool ShowHits = {this, "show_hits", true, "Show HP status in status bar."};

// TODO(captainurist): move to [audio]?
Int MusicLevel = {this, "music_level", 3, &ValidateLevel, "Music volume level."};

Int SoundLevel = {this, "sound_level", 4, &ValidateLevel, "Sound volume level."};
Expand All @@ -559,6 +570,7 @@ class GameConfig : public Config {

Int VerticalTurnSpeed = {this, "vertical_turn_speed", 25, &ValidateVerticalTurnSpeed, "Discrete vertical turn speed."};

// TODO(captainurist): move to [audio]?
Bool WalkSound = {this, "walk_sound", true, "Enable footsteps sound when walking."};

private:
Expand Down
99 changes: 51 additions & 48 deletions src/Engine/Data/TileEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
enum class TILE_DESC_FLAG {
TILE_DESC_NULL = 0,
TILE_DESC_BURN = 0x1,
TILE_DESC_WATER = 0x2,
TILE_DESC_WATER = 0x2, // Literally water.
TILE_DESC_BLOCK = 0x4,
TILE_DESC_REPULSE = 0x8,
TILE_DESC_FLAT = 0x10,
TILE_DESC_WAVY = 0x20,
TILE_DESC_DONT_DRAW = 0x40,
TILE_DESC_WATER_2 = 0x100,
TILE_DESC_TRANSITION = 0x200,
TILE_DESC_WATER_2 = 0x100, // Shore tile that's drawn on top of the water.
TILE_DESC_TRANSITION = 0x200, // Transition tile, e.g. dirt-sand, dirt-water, grass-dirt, etc. All road tiles have this set.
TILE_DESC_SCROLL_DOWN = 0x400,
TILE_DESC_SCROLL_UP = 0x800,
TILE_DESC_SCROLL_LEFT = 0x1000,
Expand All @@ -30,29 +30,29 @@ MM_DECLARE_OPERATORS_FOR_FLAGS(TILE_DESC_FLAGS)
enum class TILE_SECT {
TILE_SECT_NULL = -1,
TILE_SECT_Start = -2,
TILE_SECT_Base1 = 0,
TILE_SECT_Base2_NS = 1,
TILE_SECT_Base3_EW = 2,
TILE_SECT_Base4_N_E = 3,
TILE_SECT_Special1_N_W = 4,
TILE_SECT_Special2_S_E = 5,
TILE_SECT_Special3_S_W = 6,
TILE_SECT_Special4_NS_E = 7,
TILE_SECT_Special5_NS_W = 8,
TILE_SECT_Special6_EW_N = 9,
TILE_SECT_Special7_EW_S = 0xA,
TILE_SECT_Special8_NCAP = 0xB,
TILE_SECT_NE1_SE1_ECAP = 0xC,
TILE_SECT_SCAP = 0xD,
TILE_SECT_NW1_SW1_WCAP = 0xE,
TILE_SECT_DN = 0xF,
TILE_SECT_E1_DS = 0x10,
TILE_SECT_W1_DW = 0x11,
TILE_SECT_N1_DE = 0x12,
TILE_SECT_S1_DSW = 0x13,
TILE_SECT_XNE1_XSE1_DNE = 0x14,
TILE_SECT_DSE = 0x15,
TILE_SECT_XNW1_XSW1_DNW = 0x16,
TILE_SECT_Base1 = 0, // Base tile. For roads - crossing.
TILE_SECT_Base2_NS = 1, // Base variation (swamp has one). For roads - NS.
TILE_SECT_Base3_EW = 2, // Base variation (swamp has one). For roads - EW.
TILE_SECT_Base4_N_E = 3, // Base variation (not sure if this is used). For roads - NE turn.
TILE_SECT_Special1_N_W = 4, // For roads - NW turn.
TILE_SECT_Special2_S_E = 5, // For roads - SE turn.
TILE_SECT_Special3_S_W = 6, // For roads - SW turn.
TILE_SECT_Special4_NS_E = 7, // For roads - T intersection, NS/E.
TILE_SECT_Special5_NS_W = 8, // For roads - T intersection, NS/W.
TILE_SECT_Special6_EW_N = 9, // For roads - T intersection, EW/N.
TILE_SECT_Special7_EW_S = 0xA, // For roads - T intersection, EW/S.
TILE_SECT_Special8_NCAP = 0xB, // For roads - N road end.
TILE_SECT_NE1_SE1_ECAP = 0xC, // NE/SE transition to 3 x dirt. For roads - E road end.
TILE_SECT_SCAP = 0xD, // For roads - S road end.
TILE_SECT_NW1_SW1_WCAP = 0xE, // NW/SW transition to 3 x dirt. For roads - W road end.
TILE_SECT_DN = 0xF, // For roads - Y intersection, N.
TILE_SECT_E1_DS = 0x10, // E transition to dirt. For roads - Y intersection, S.
TILE_SECT_W1_DW = 0x11, // W transition to dirt. For roads - Y intersection, W.
TILE_SECT_N1_DE = 0x12, // N transition to dirt. For roads - Y intersection, E.
TILE_SECT_S1_DSW = 0x13, // S transition to dirt. For roads - diagonal road, SW.
TILE_SECT_XNE1_XSE1_DNE = 0x14, // NE/SE transition to 1 x dirt. For roads - diagonal road, NE.
TILE_SECT_DSE = 0x15, // For roads - diagonal road, SE.
TILE_SECT_XNW1_XSW1_DNW = 0x16, // NW/SW transition to 1 x dirt. For roads - diagonal road, NW.

TILE_SECT_FIRST_SPECIAL = TILE_SECT_Special1_N_W,
TILE_SECT_LAST_SPECIAL = TILE_SECT_Special8_NCAP,
Expand All @@ -64,34 +64,37 @@ inline Segment<TILE_SECT> allSpecialTileSects() {
}

// TODO(captainurist): #enum rename
// TODO(captainurist): rename enum values properly, City is Sand.
// Most of these tilesets don't exist in mm7 data, see comments. Everything's mapped to dirt.
#pragma warning(push)
#pragma warning(disable : 4341)
enum class Tileset : int16_t {
// Tile 0 has Tileset = 255.
Tileset_Grass = 0,
Tileset_Snow = 1,
Tileset_Desert = 2,
Tileset_CooledLava = 3,
Tileset_Dirt = 4,
Tileset_Water = 5,
Tileset_Badlands = 6,
Tileset_Desert = 2, // Sand.
Tileset_CooledLava = 3, // Somehow this tileset is all dirt in the data files.
Tileset_Dirt = 4, // This one has only 3 tiles.
Tileset_Water = 5, // Water tile & shoreline tiles.
Tileset_Badlands = 6, // Looks like Deyja.
Tileset_Swamp = 7,
Tileset_Tropical = 8,
Tileset_City = 9,
Tileset_RoadGrassCobble = 10,
Tileset_RoadGrassDirt = 11,
Tileset_RoadSnowCobble = 12,
Tileset_RoadSnowDirt = 13,
Tileset_RoadSandCobble = 14,
Tileset_RoadSandDirt = 15,
Tileset_RoadVolcanoCobble = 16,
Tileset_RoadVolcanoDirt = 17,
Tileset_RoadCrackedCobble = 22,
Tileset_RoadCrackedDirt = 23,
Tileset_RoadSwampCobble = 24,
Tileset_RoadSwampDir = 25,
Tileset_RoadTropicalCobble = 26,
Tileset_RoadTropicalDirt = 27,
Tileset_RoadCityStone = 28,
Tileset_Tropical = 8, // This is all dirt.
Tileset_City = 9, // This is sand too, lol.
Tileset_RoadGrassCobble = 10, // Cobble road on dirt actually.
Tileset_RoadGrassDirt = 11, // This is all dirt.
Tileset_RoadSnowCobble = 12, // This is all dirt.
Tileset_RoadSnowDirt = 13, // This is all dirt.
Tileset_RoadSandCobble = 14, // This doesn't exist in mm7 tiles at all.
Tileset_RoadSandDirt = 15, // This doesn't exist in mm7 tiles at all.
Tileset_RoadVolcanoCobble = 16, // This is all dirt.
Tileset_RoadVolcanoDirt = 17, // This is all dirt.
Tileset_RoadCrackedCobble = 22, // This is all dirt.
Tileset_RoadCrackedDirt = 23, // This is all dirt.
Tileset_RoadSwampCobble = 24, // This is all dirt.
Tileset_RoadSwampDir = 25, // This is all dirt.
Tileset_RoadTropicalCobble = 26, // This is all dirt.
Tileset_RoadTropicalDirt = 27, // This is all dirt.
Tileset_RoadCityStone = 28, // This is all dirt.
Tileset_NULL = -1,
Tileset_Start = -2
};
Expand Down
2 changes: 0 additions & 2 deletions src/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ Engine::Engine(std::shared_ptr<GameConfig> config, OverlaySystem &overlaySystem)
uNumStationaryLights_in_pStationaryLightsStack = 0;

pCamera3D = new Camera3D;
pStru10Instance = new stru10;

keyboardInputHandler = ::keyboardInputHandler;
keyboardActionMapping = ::keyboardActionMapping;
Expand All @@ -442,7 +441,6 @@ Engine::~Engine() {
mouse->Deactivate();

delete pEventTimer;
delete pStru10Instance;
delete pCamera3D;
pAudioPlayer.reset();
}
Expand Down
2 changes: 0 additions & 2 deletions src/Engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ struct SpellFxRenderer;
class Vis;
class ParticleEngine;
struct ClippingFunctions;
struct stru10;
class GUIMessageQueue;
class GameResourceManager;
class StatusBar;
Expand Down Expand Up @@ -113,7 +112,6 @@ class Engine {
std::shared_ptr<GameConfig> config;
int uNumStationaryLights_in_pStationaryLightsStack;
float fSaturation;
stru10 *pStru10Instance;
BloodsplatContainer *bloodsplat_container = nullptr;
DecalBuilder *decal_builder = nullptr;
SpellFxRenderer *spell_fx_renedrer = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Graphics/BspRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void BspRenderer::AddFaceToRenderList_d3d(int node_id, int uFaceID) {
nodes[num_nodes].uFaceID = uFaceID;

// calculates the portal bounding and frustum
bool bFrustumbuilt = engine->pStru10Instance->CalcPortalShapePoly(
bool bFrustumbuilt = CalcPortalShapePoly(
pFace, static_subAddFaceToRenderList_d3d_stru_F79E08,
&pNewNumVertices, nodes[num_nodes].ViewportNodeFrustum.data(),
nodes[num_nodes].pPortalBounding.data());
Expand Down
16 changes: 8 additions & 8 deletions src/Engine/Graphics/Collisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ void CollideIndoorWithDecorations() {
CollideWithDecoration(sector->pDecorationIDs[i]);
}

void CollideOutdoorWithDecorations(int grid_x, int grid_y) {
if (grid_x < 0 || grid_x > 127 || grid_y < 0 || grid_y > 127)
void CollideOutdoorWithDecorations(Vec2i gridPos) {
if (gridPos.x < 0 || gridPos.x > 127 || gridPos.y < 0 || gridPos.y > 127)
return;

int grid_index = grid_x + (grid_y << 7);
int grid_index = gridPos.x + (gridPos.y << 7);
int list_index = pOutdoor->pOMAP[grid_index];

for(int i = list_index; i < pOutdoor->pFaceIDLIST.size(); i++) {
Expand Down Expand Up @@ -744,7 +744,7 @@ void ProcessActorCollisionsODM(Actor &actor, bool isFlying) {
break;

CollideOutdoorWithModels(true);
CollideOutdoorWithDecorations(WorldPosToGridCellX(actor.pos.x), WorldPosToGridCellY(actor.pos.y));
CollideOutdoorWithDecorations(WorldPosToGrid(actor.pos));
CollideWithParty(false);
_46ED8A_collide_against_sprite_objects(Pid(OBJECT_Actor, actor.id));

Expand Down Expand Up @@ -1021,7 +1021,7 @@ void ProcessPartyCollisionsODM(Vec3f *partyNewPos, Vec3f *partyInputSpeed, bool
}

CollideOutdoorWithModels(true);
CollideOutdoorWithDecorations(WorldPosToGridCellX(pParty->pos.x), WorldPosToGridCellY(pParty->pos.y));
CollideOutdoorWithDecorations(WorldPosToGrid(pParty->pos));
_46ED8A_collide_against_sprite_objects(Pid::character(0));
if (!engine->config->gameplay.NoPartyActorCollisions.value()) {
for (size_t actor_id = 0; actor_id < pActors.size(); ++actor_id)
Expand All @@ -1046,8 +1046,8 @@ void ProcessPartyCollisionsODM(Vec3f *partyNewPos, Vec3f *partyInputSpeed, bool
float x_advance_floor = ODM_GetFloorLevel(Vec3f(newPosLow.x, partyNewPos->y, newPosLow.z), pParty->height, partyIsOnWater, &party_y_pid, 0);
int party_x_pid;
float y_advance_floor = ODM_GetFloorLevel(Vec3f(partyNewPos->x, newPosLow.y, newPosLow.z), pParty->height, partyIsOnWater, &party_x_pid, 0);
bool terr_slope_advance_x = IsTerrainSlopeTooHigh(newPosLow.x, partyNewPos->y);
bool terr_slope_advance_y = IsTerrainSlopeTooHigh(partyNewPos->x, newPosLow.y);
bool terr_slope_advance_x = IsTerrainSlopeTooHigh(Vec3f(newPosLow.x, partyNewPos->y, 0.0f));
bool terr_slope_advance_y = IsTerrainSlopeTooHigh(Vec3f(partyNewPos->x, newPosLow.y, 0.0f));

*partyNotOnModel = false;
if (!party_y_pid && !party_x_pid && !*floorFaceId) *partyNotOnModel = true;
Expand All @@ -1067,7 +1067,7 @@ void ProcessPartyCollisionsODM(Vec3f *partyNewPos, Vec3f *partyInputSpeed, bool
} else if (move_in_y) {
partyNewPos->y = newPosLow.y;
} else {
if (IsTerrainSlopeTooHigh(newPosLow.x, newPosLow.y) && allnewfloor <= partyNewPos->z) {
if (IsTerrainSlopeTooHigh(newPosLow) && allnewfloor <= partyNewPos->z) {
// move down the hill is allowed
partyNewPos->x = newPosLow.x;
partyNewPos->y = newPosLow.y;
Expand Down
5 changes: 2 additions & 3 deletions src/Engine/Graphics/Collisions.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ void CollideIndoorWithDecorations();
/**
* @offset 0x0046E26D.
*
* @param grid_x Grid x coordinate.
* @param grid_y Grid y coordinate.
* @param gridPos Grid coordinates.
*/
void CollideOutdoorWithDecorations(int grid_x, int grid_y);
void CollideOutdoorWithDecorations(Vec2i gridPos);

/**
* @offset 0x0046F04E.
Expand Down
Loading

0 comments on commit c59b83f

Please sign in to comment.