Skip to content

Commit

Permalink
Implement parts of W3DView
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwil committed Dec 30, 2023
1 parent f865b75 commit f07b628
Show file tree
Hide file tree
Showing 10 changed files with 1,050 additions and 103 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if(MSVC)

# Set warning level 3
# disable C4244: conversion from 'double' to 'float', possible loss of data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4244 /w14456 /w15038")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4244 /w14456 /w15038 /w14552")

if (MSVC_VERSION LESS 1920)
# MSVC lower than 19
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ set(GAMEENGINE_SRC
game/client/messagestream/selectionxlat.cpp
game/client/optionpreferences.cpp
game/client/parabolicease.cpp
game/client/selectioninfo.cpp
game/client/shader/bwfilter.cpp
game/client/shader/cloudshader.cpp
game/client/shader/crossfadefilter.cpp
Expand Down
3 changes: 2 additions & 1 deletion src/game/client/ingameui.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class InGameUI : public SubsystemInterface, public SnapShot
bool Get_Unk7() const { return m_unk7; }
void Set_Unk6(bool b) { m_unk6 = b; }
void Clear_Attack_Move_To_Mode() { m_attackMoveToMode = false; }
bool Is_In_Force_To_Attack_Mode() { return m_forceToAttackMode; }

protected:
struct MoveHintStruct
Expand Down Expand Up @@ -344,7 +345,7 @@ class InGameUI : public SubsystemInterface, public SnapShot
PopupMessageData *m_popupMessageData;
int m_popupMessageColor;
bool m_waypointMode;
bool m_unk2; // not 100% identified yet
bool m_forceToAttackMode; // not 100% identified yet
bool m_unk3; // not 100% identified yet
bool m_attackMoveToMode; // not 100% identified yet
bool m_unk5; // not 100% identified yet
Expand Down
27 changes: 27 additions & 0 deletions src/game/client/selectioninfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file
*
* @author Jonathan Wilson
*
* @brief Selection Info
*
* @copyright Thyme is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version
* 2 of the License, or (at your option) any later version.
* A full copy of the GNU General Public License can be found in
* LICENSE
*/
#include "selectioninfo.h"
#ifdef GAME_DLL
#include "hooker.h"
#endif

PickType Get_Pick_Types_For_Context(bool force_to_attack)
{
#ifdef GAME_DLL
return Call_Function<PickType, bool>(PICK_ADDRESS(0x00723550, 0x0086D346), force_to_attack);
#else
return PICKTYPE_UNK;
#endif
}
19 changes: 19 additions & 0 deletions src/game/client/selectioninfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @file
*
* @author Jonathan Wilson
*
* @brief Selection Info
*
* @copyright Thyme is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version
* 2 of the License, or (at your option) any later version.
* A full copy of the GNU General Public License can be found in
* LICENSE
*/
#pragma once
#include "always.h"
#include "view.h"

PickType Get_Pick_Types_For_Context(bool force_to_attack);
50 changes: 25 additions & 25 deletions src/game/client/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,41 +171,41 @@ void View::Scroll_By(Coord2D *pos)
m_pos.y += pos->y;
}

void View::Move_Camera_To(const Coord3D *o, int i1, int i2, bool b, float f1, float f2)
void View::Move_Camera_To(const Coord3D *o, int frames, int shutter, bool orient, float in, float out)
{
Look_At(o);
}

void View::Move_Camera_Along_Waypoint_Path(Waypoint *w, int i1, int i2, bool b, float f1, float f2) {}
void View::Move_Camera_Along_Waypoint_Path(Waypoint *way, int frames, int stutter, bool orient, float in, float out) {}

bool View::Is_Camera_Movement_Finished()
{
return true;
}

void View::Camera_Mod_Final_Zoom(float f1, float f2, float f3) {}
void View::Camera_Mod_Final_Zoom(float final_zoom, float in, float out) {}

void View::Camera_Mod_Rolling_Average(int i) {}
void View::Camera_Mod_Rolling_Average(int frames_to_average) {}

void View::Camera_Mod_Final_Time_Multiplier(int i) {}
void View::Camera_Mod_Final_Time_Multiplier(int final_multiplier) {}

void View::Camera_Mod_Final_Pitch(float f1, float f2, float f3) {}
void View::Camera_Mod_Final_Pitch(float final_pitch, float in, float out) {}

void View::Camera_Mod_Freeze_Time() {}

void View::Camera_Mod_Freeze_Angle() {}

void View::Camera_Mod_Look_Toward(Coord3D *o) {}
void View::Camera_Mod_Look_Toward(Coord3D *p_loc) {}

void View::Camera_Mod_Final_Look_Toward(Coord3D *o) {}
void View::Camera_Mod_Final_Look_Toward(Coord3D *p_loc) {}

void View::Camera_Mod_Final_Move_To(Coord3D *o) {}
void View::Camera_Mod_Final_Move_To(Coord3D *p_loc) {}

void View::Camera_Enable_Slave_Mode(const Utf8String &s1, const Utf8String &s2) {}
void View::Camera_Enable_Slave_Mode(const Utf8String &thing, const Utf8String &bone) {}

void View::Camera_Disable_Slave_Mode() {}

void View::Add_Camera_Shake(const Coord3D &o, float f1, float f2, float f3) {}
void View::Add_Camera_Shake(const Coord3D &position, float radius, float duration, float amplitude) {}

FilterModes View::Get_View_Filter_Mode()
{
Expand All @@ -229,17 +229,17 @@ bool View::Set_View_Filter(FilterTypes filter)
return false;
}

void View::Set_Fade_Parameters(int i1, int i2) {}
void View::Set_Fade_Parameters(int fade_frames, int direction) {}

void View::Set_3D_Wireframe_Mode(bool on) {}

void View::Reset_Camera(const Coord3D *o, int i, float f1, float f2) {}
void View::Reset_Camera(const Coord3D *location, int frames, float in, float out) {}

void View::Rotate_Camera(float f1, int i, float f2, float f3) {}
void View::Rotate_Camera(float rotations, int frames, float in, float out) {}

void View::Rotate_Camera_Toward_Object(ObjectID id, int i1, int i2, float f1, float f2) {}
void View::Rotate_Camera_Toward_Object(ObjectID id, int milliseconds, int hold_milliseconds, float in, float out) {}

void View::Rotate_Camera_Toward_Position(const Coord3D *o, int i, float f1, float f2, bool b) {}
void View::Rotate_Camera_Toward_Position(const Coord3D *p_loc, int milliseconds, float in, float out, bool b) {}

bool View::Is_Time_Frozen()
{
Expand All @@ -251,13 +251,13 @@ int View::Get_Time_Multiplier()
return 1;
}

void View::Set_Time_Multiplier(int multiplier) {}
void View::Set_Time_Multiplier(int multiple) {}

void View::Set_Default_View(float f1, float f2, float f3) {}
void View::Set_Default_View(float pitch, float angle, float max_height) {}

void View::Zoom_Camera(float f1, int i, float f2, float f3) {}
void View::Zoom_Camera(float final_zoom, int milliseconds, float in, float out) {}

void View::Pitch_Camera(float f1, int i, float f2, float f3) {}
void View::Pitch_Camera(float final_pitch, int milliseconds, float in, float out) {}

void View::Set_Angle(float angle)
{
Expand All @@ -269,9 +269,9 @@ float View::Get_Angle()
return m_angle;
}

void View::Set_Pitch(float pitch)
void View::Set_Pitch(float angle)
{
m_pitchAngle = std::clamp(pitch, DEG_TO_RADF(-36.f), DEG_TO_RADF(36.f));
m_pitchAngle = std::clamp(angle, DEG_TO_RADF(-36.f), DEG_TO_RADF(36.f));
}

float View::Get_Pitch()
Expand All @@ -295,16 +295,16 @@ float View::Get_Zoom()
return m_zoom;
}

void View::Set_Zoom(float zoom) {}
void View::Set_Zoom(float z) {}

float View::Get_Height_Above_Ground()
{
return m_heightAboveGround;
}

void View::Set_Height_Above_Ground(float height)
void View::Set_Height_Above_Ground(float z)
{
m_heightAboveGround = height;
m_heightAboveGround = z;
}

void View::Zoom_In()
Expand Down
79 changes: 40 additions & 39 deletions src/game/client/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ class View : public SnapShot
virtual void Init();
virtual void Reset() { m_zoomLimited = true; };
virtual uint32_t Get_ID();
virtual void Set_Zoom_Limited(bool b);
virtual void Set_Zoom_Limited(bool limit);
virtual bool Is_Zoom_Limited();
virtual Drawable *Pick_Drawable(const ICoord2D *o, bool b, PickType type) = 0;
virtual int Iterate_Drawables_In_Region(IRegion2D *r, bool (*func)(Drawable *, void *), void *) = 0;
virtual Drawable *Pick_Drawable(const ICoord2D *screen, bool force_attack, PickType type) = 0;
virtual int Iterate_Drawables_In_Region(
IRegion2D *screen_region, bool (*callback)(Drawable *, void *), void *user_data) = 0;
virtual void Get_Screen_Corner_World_Points_At_Z(
Coord3D *top_left, Coord3D *top_right, Coord3D *bottom_left, Coord3D *bottom_right, float z);
virtual void Set_Width(int32_t width) { m_width = width; }
Expand All @@ -128,38 +129,38 @@ class View : public SnapShot
virtual void Look_At(const Coord3D *pos);
virtual void Init_Height_For_Map();
virtual void Scroll_By(Coord2D *pos);
virtual void Move_Camera_To(const Coord3D *o, int i1, int i2, bool b, float f1, float f2);
virtual void Move_Camera_Along_Waypoint_Path(Waypoint *w, int i1, int i2, bool b, float f1, float f2);
virtual void Move_Camera_To(const Coord3D *o, int frames, int shutter, bool orient, float in, float out);
virtual void Move_Camera_Along_Waypoint_Path(Waypoint *way, int frames, int stutter, bool orient, float in, float out);
virtual bool Is_Camera_Movement_Finished();
virtual void Camera_Mod_Final_Zoom(float f1, float f2, float f3);
virtual void Camera_Mod_Rolling_Average(int i);
virtual void Camera_Mod_Final_Time_Multiplier(int i);
virtual void Camera_Mod_Final_Pitch(float f1, float f2, float f3);
virtual void Camera_Mod_Final_Zoom(float final_zoom, float in, float out);
virtual void Camera_Mod_Rolling_Average(int frames_to_average);
virtual void Camera_Mod_Final_Time_Multiplier(int final_multiplier);
virtual void Camera_Mod_Final_Pitch(float final_pitch, float in, float out);
virtual void Camera_Mod_Freeze_Time();
virtual void Camera_Mod_Freeze_Angle();
virtual void Camera_Mod_Look_Toward(Coord3D *o);
virtual void Camera_Mod_Final_Look_Toward(Coord3D *o);
virtual void Camera_Mod_Final_Move_To(Coord3D *o);
virtual void Camera_Enable_Slave_Mode(const Utf8String &s1, const Utf8String &s2);
virtual void Camera_Mod_Look_Toward(Coord3D *p_loc);
virtual void Camera_Mod_Final_Look_Toward(Coord3D *p_loc);
virtual void Camera_Mod_Final_Move_To(Coord3D *p_loc);
virtual void Camera_Enable_Slave_Mode(const Utf8String &thing, const Utf8String &bone);
virtual void Camera_Disable_Slave_Mode();
virtual void Add_Camera_Shake(const Coord3D &o, float f1, float f2, float f3);
virtual void Add_Camera_Shake(const Coord3D &position, float radius, float duration, float amplitude);
virtual FilterModes Get_View_Filter_Mode();
virtual FilterTypes Get_View_Filter_Type();
virtual bool Set_View_Filter_Mode(FilterModes mode);
virtual void Set_View_Filter_Pos(const Coord3D *pos);
virtual bool Set_View_Filter(FilterTypes filter);
virtual void Set_Fade_Parameters(int frames, int direction);
virtual void Set_Fade_Parameters(int fade_frames, int direction);
virtual void Set_3D_Wireframe_Mode(bool on);
virtual void Reset_Camera(const Coord3D *o, int i, float f1, float f2);
virtual void Rotate_Camera(float f1, int i, float f2, float f3);
virtual void Rotate_Camera_Toward_Object(ObjectID id, int i1, int i2, float f1, float f2);
virtual void Rotate_Camera_Toward_Position(const Coord3D *o, int i, float f1, float f2, bool b);
virtual void Reset_Camera(const Coord3D *location, int frames, float in, float out);
virtual void Rotate_Camera(float rotations, int frames, float in, float out);
virtual void Rotate_Camera_Toward_Object(ObjectID id, int milliseconds, int hold_milliseconds, float in, float out);
virtual void Rotate_Camera_Toward_Position(const Coord3D *p_loc, int milliseconds, float in, float out, bool b);
virtual bool Is_Time_Frozen();
virtual int Get_Time_Multiplier();
virtual void Set_Time_Multiplier(int multiplier);
virtual void Set_Default_View(float f1, float f2, float f3);
virtual void Zoom_Camera(float f1, int i, float f2, float f3);
virtual void Pitch_Camera(float f1, int i, float f2, float f3);
virtual void Set_Time_Multiplier(int multiple);
virtual void Set_Default_View(float pitch, float angle, float max_height);
virtual void Zoom_Camera(float final_zoom, int milliseconds, float in, float out);
virtual void Pitch_Camera(float final_pitch, int milliseconds, float in, float out);
virtual void Set_Angle(float angle);
virtual float Get_Angle();
virtual void Set_Pitch(float pitch);
Expand All @@ -168,24 +169,24 @@ class View : public SnapShot
virtual void Get_Position(Coord3D *pos);
virtual const Coord3D &Get_3D_Camera_Position() = 0;
virtual float Get_Zoom();
virtual void Set_Zoom(float zoom);
virtual void Set_Zoom(float z);
virtual float Get_Height_Above_Ground();
virtual void Set_Height_Above_Ground(float height);
virtual void Set_Height_Above_Ground(float z);
virtual void Zoom_In();
virtual void Zoom_Out();
virtual void Set_Zoom_To_Default() {}
virtual float Get_Max_Zoom() { return m_maxZoom; }
virtual void Set_Ok_To_Adjust_Height(bool ok) { m_okToAdjustHeight = ok; }
virtual void Set_Ok_To_Adjust_Height(bool val) { m_okToAdjustHeight = val; }
virtual float Get_Terrain_Height_Under_Camera() { return m_terrainHeightUnderCamera; }
virtual void Set_Terrain_Height_Under_Camera(float height) { m_terrainHeightUnderCamera = height; }
virtual float Get_Current_Height_Above_Ground() { return m_currentHeightAboveGround; }
virtual void Set_Current_Height_Above_Ground(float height) { m_currentHeightAboveGround = height; }
virtual void Set_Field_Of_View(float fov) { m_FOV = fov; }
virtual void Set_Field_Of_View(float angle) { m_FOV = angle; }
virtual float Get_Field_Of_View() { return m_FOV; }
virtual int World_To_Screen_Tri_Return(const Coord3D *o1, ICoord2D *o2) = 0;
virtual void Screen_To_World(const ICoord2D *o1, Coord3D *o2) = 0;
virtual void Screen_To_Terrain(const ICoord2D *o1, Coord3D *o2) = 0;
virtual void Screen_To_World_At_Z(const ICoord2D *o1, Coord3D *o2, float f) = 0;
virtual int World_To_Screen_Tri_Return(const Coord3D *w, ICoord2D *s) = 0;
virtual void Screen_To_World(const ICoord2D *s, Coord3D *w) = 0;
virtual void Screen_To_Terrain(const ICoord2D *screen, Coord3D *world) = 0;
virtual void Screen_To_World_At_Z(const ICoord2D *s, Coord3D *w, float z) = 0;
virtual void Get_Location(ViewLocation *location);
virtual void Set_Location(const ViewLocation *location);
virtual void Draw_View() = 0;
Expand All @@ -198,10 +199,10 @@ class View : public SnapShot
m_lockType = LOCK_FOLLOW;
};
virtual void Snap_To_Camera_Lock() { m_snapImmediate = true; }
virtual void Set_Snap_Mode(CameraLockType type, float dist)
virtual void Set_Snap_Mode(CameraLockType lock_type, float lock_dist)
{
m_lockType = type;
m_lockDist = dist;
m_lockType = lock_type;
m_lockDist = lock_dist;
};
virtual Drawable *Get_Camera_Lock_Drawable() { return m_cameraLockDrawable; }
virtual void Set_Camera_Lock_Drawable(Drawable *drawable)
Expand All @@ -211,19 +212,19 @@ class View : public SnapShot
}
virtual void Set_Mouse_Lock(bool locked) { m_mouseLocked = locked; }
virtual bool Is_Mouse_Locked() { return m_mouseLocked; }
virtual void Shake(const Coord3D *o, CameraShakeType type) {}
virtual void Shake(const Coord3D *epicenter, CameraShakeType shake_type) {}
virtual float Get_FX_Pitch() { return 1.0f; }
virtual void Force_Camera_Constraint_Recalc() {}
virtual void Set_Guard_Band_Bias(Coord2D *) = 0;
virtual View *Prepend_View_To_List(View *view)
virtual void Set_Guard_Band_Bias(Coord2D *bias) = 0;
virtual View *Prepend_View_To_List(View *list)
{
m_next = view;
m_next = list;
return this;
};
virtual View *Get_Next_View() { return m_next; }
Coord3D &Get_Position() { return m_pos; }
void Set_Position(const Coord3D *pos) { m_pos = *pos; }
bool World_To_Screen_Tri(const Coord3D *o1, ICoord2D *o2) { return World_To_Screen_Tri_Return(o1, o2) == 0; }
bool World_To_Screen_Tri(const Coord3D *w, ICoord2D *s) { return World_To_Screen_Tri_Return(w, s) == 0; }

protected:
View *m_next;
Expand Down
16 changes: 16 additions & 0 deletions src/hooker/setuphooks_zh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,22 @@ void Setup_Hooks()
// w3dview.h
Hook_Any(0x0076E2F0, W3DView::Set_Fade_Parameters);
Hook_Any(0x0076E330, W3DView::Set_View_Filter_Pos);
Hook_Any(0x0076D420, W3DView::Init);
Hook_Any(0x0076D600, W3DView::Reset);
Hook_Any(0x0076D200, W3DView::Set_Camera_Transform);
Hook_Any(0x0076CF10, W3DView::Calc_Camera_Constraints);
Hook_Any(0x0076D0C0, W3DView::Get_Pick_Ray);
Hook_Any(0x0076C780, W3DView::Build_Camera_Transform);
Hook_Any(0x0076F5D0, W3DView::Pick_Drawable);
Hook_Any(0x0076F3B0, W3DView::Iterate_Drawables_In_Region);
Hook_Any(0x0076C5B0, W3DView::Set_Width);
Hook_Any(0x0076C4F0, W3DView::Set_Height);
Hook_Any(0x0076C6B0, W3DView::Set_Origin);
Hook_Any(0x0076D680, W3DView::Update_Camera_Movements);
Hook_Any(0x00771B60, W3DView::Zoom_Camera_One_Frame);
Hook_Any(0x007716E0, W3DView::Rotate_Camera_One_Frame);
Hook_Any(0x00771C00, W3DView::Pitch_Camera_One_Frame);
Hook_Any(0x00771CA0, W3DView::Move_Along_Waypoint_Path);

// scene.h
Hook_Any(0x00832550, SceneClass::Render);
Expand Down
Loading

0 comments on commit f07b628

Please sign in to comment.