Skip to content

Commit

Permalink
Updated camera, director and user index
Browse files Browse the repository at this point in the history
And partially network session
  • Loading branch information
twist84 committed Nov 25, 2024
1 parent 0932b18 commit bb4066d
Show file tree
Hide file tree
Showing 88 changed files with 886 additions and 928 deletions.
2 changes: 1 addition & 1 deletion game/source/ai/ai_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void __cdecl ai_debug_render()

void ai_debug_drawstack_setup(real_point3d const* position)
{
e_output_user_index user_index = player_mapping_first_active_output_user();
long user_index = player_mapping_first_active_output_user();
s_observer_result const* camera = observer_try_and_get_camera(user_index);

global_ai_debug_drawstack_last_position = *position;
Expand Down
4 changes: 2 additions & 2 deletions game/source/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ e_camera_mode camera_mode_from_string(char const* str)

void c_camera::set_next_move_instantly()
{
__unknownC = 5;
SET_BIT(m_flags, _next_move_instantly_bit, true);
m_move_instant_ticks = 5;
m_flags.set(_move_instantly, true);
}

25 changes: 13 additions & 12 deletions game/source/camera/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,36 @@ enum e_camera_mode
};

enum e_director_perspective;
enum e_output_user_index;

struct s_observer_command;

struct c_camera
{
virtual e_camera_mode get_type() const;
virtual e_director_perspective get_perspective() const;
virtual void update(e_output_user_index output_user_index, real a2, s_observer_command* result);
virtual void update(long user_index, real dt, s_observer_command* result);
virtual long get_target() const;
virtual void set_target(long target_index);
virtual void set_target(long object_index);
virtual void set_position(real_point3d const* position);
virtual void set_forward(vector3d const* forward);
virtual void set_roll(real roll);
virtual void enable_orientation(bool orientation_enable);
virtual void enable_movement(bool movement_enable);
virtual void enable_roll(bool roll_enable);
virtual void handle_deleted_player(long player);
virtual void enable_orientation(bool enabled);
virtual void enable_movement(bool enabled);
virtual void enable_roll(bool enabled);
virtual void handle_deleted_player(long player_index);
virtual void handle_deleted_object(long object_index);
virtual real get_unknown(); // c_flying_camera, c_static_camera, c_scripted_camera

enum e_flags
enum e_base_camera_flags
{
_next_move_instantly_bit = 0
_move_instantly = 0,

k_number_of_base_camera_flags
};

long m_object_index;
dword_flags m_flags;
dword __unknownC;
long m_target_object_index;
c_flags<e_base_camera_flags, long, k_number_of_base_camera_flags> m_flags;
long m_move_instant_ticks;

void set_next_move_instantly();
};
Expand Down
24 changes: 13 additions & 11 deletions game/source/camera/dead_camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
struct c_dead_camera :
public c_camera
{
real_point3d m_position;
public:
void constructor(long user_index)
{
DECLFUNC(0x00729E60, void, __thiscall, c_camera*, long)(this, user_index);
}

//protected:
real_point3d m_falling_camera_position;
euler_angles2d m_orientation;
real m_focus_distance;
real m_distance;
real m_field_of_view;
real __unknown2C;
long m_target_player_index;
long m_target_object_index;
bool __unknown38;
real m_timer;
long m_player_index;
long m_killer_object_index;
bool m_unit_fell_to_death;
byte m_user_index;

byte pad[0x2];
byte unused[0x10];

void constructor(long user_index)
{
DECLFUNC(0x00729E60, void, __thiscall, c_camera*, long)(this, user_index);
}
};
static_assert(sizeof(c_dead_camera) == 0x4C);

32 changes: 16 additions & 16 deletions game/source/camera/debug_director.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ HOOK_DECLARE_CLASS_MEMBER(0x007262F0, c_debug_director, _update);
byte const cycle_camera_key_code_bytes[] = { _key_code_backspace };
DATA_PATCH_DECLARE(0x007262F6 + 1, cycle_camera_key_code, cycle_camera_key_code_bytes);

//REFERENCE_DECLARE_ARRAY(0x018ECEC4, e_camera_mode, k_debug_camera_modes, 2);
e_camera_mode k_debug_camera_modes[] = { _camera_mode_flying, _camera_mode_following };
//REFERENCE_DECLARE_ARRAY(0x018ECEC4, e_camera_mode, debug_camera_modes, 2);
e_camera_mode debug_camera_modes[] = { _camera_mode_flying, _camera_mode_following };

void __thiscall c_debug_director::_update(real a1)
void __thiscall c_debug_director::_update(real dt)
{
if (input_key_frames_down(_key_code_backspace, _input_type_ui) == 1)
cycle_camera();

mouse_state* state = input_get_mouse_state(_input_type_ui);
if (k_debug_camera_modes[m_camera_mode_index] == _camera_mode_flying && state)
if (debug_camera_modes[m_current_camera_mode_index] == _camera_mode_flying && state)
{
if (state->frames_down[_mouse_button_middle_click] == 1)
{
m_biped_control_mode = !m_biped_control_mode;
console_printf(m_biped_control_mode ? "Biped control mode" : "Flying camera control mode");
m_flying_camera_biped_control = !m_flying_camera_biped_control;
console_printf(m_flying_camera_biped_control ? "Biped control mode" : "Flying camera control mode");
}

if (g_editor_director_mouse_wheel_speed_enabled && !state->frames_down[_mouse_button_middle_click])
Expand All @@ -44,20 +44,20 @@ void __thiscall c_debug_director::_update(real a1)
// g_director_camera_speed_scale = int_pin(g_director_camera_speed_scale * 1.03f, 0.0009765625f, 256.0f);
}

if (m_biped_control_mode || !editor_input_inhibited())
if (m_flying_camera_biped_control || !editor_input_inhibited())
{
m_collision_disabled = false;
m_input_inhibited = false;
set_camera_mode(_camera_mode_static, 0.0f);
}
else
{
m_collision_disabled = true;
m_input_inhibited = true;
set_camera_mode(_camera_mode_flying, 0.0f);
static_cast<c_flying_camera*>(get_camera())->set_collision(false);
}
}

INVOKE_CLASS_MEMBER(0x00593540, c_director, update, a1);
INVOKE_CLASS_MEMBER(0x00593540, c_director, update, dt);
}

void c_debug_director::constructor(long user_index)
Expand All @@ -68,28 +68,28 @@ void c_debug_director::constructor(long user_index)

void c_debug_director::changed_camera()
{
set_camera_mode(k_debug_camera_modes[m_camera_mode_index], 0.0f);
console_printf("%s camera", global_camera_mode_names[k_debug_camera_modes[m_camera_mode_index]]);
set_camera_mode(debug_camera_modes[m_current_camera_mode_index], 0.0f);
console_printf("%s camera", global_camera_mode_names[debug_camera_modes[m_current_camera_mode_index]]);
c_camera* camera = get_camera();
if (camera->get_type() == _camera_mode_flying)
{
m_collision_disabled = true;
m_input_inhibited = true;
static_cast<c_flying_camera*>(get_camera())->set_collision(false);
}
else
{
m_collision_disabled = false;
m_input_inhibited = false;
}
}

void c_debug_director::cycle_camera()
{
m_camera_mode_index = (m_camera_mode_index - 1) % NUMBEROF(k_debug_camera_modes);
m_current_camera_mode_index = (m_current_camera_mode_index - 1) % NUMBEROF(debug_camera_modes);
changed_camera();
}

bool c_debug_director::finished_cycle()
{
return m_camera_mode_index == NUMBEROF(k_debug_camera_modes) - 1;
return m_current_camera_mode_index == NUMBEROF(debug_camera_modes) - 1;
}

23 changes: 7 additions & 16 deletions game/source/camera/debug_director.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,20 @@
struct c_debug_director :
public c_director
{
void __thiscall _update(real a1);
public:
void __thiscall _update(real dt);

void constructor(long user_index);
void changed_camera();
void cycle_camera();
bool finished_cycle();

// camera mode cycle - Backspace (Previously F12)
// control mode toggle - middle-mouse click
//protected:
long m_current_camera_mode_index;
bool m_input_inhibited;
bool m_flying_camera_biped_control;

// 0: _camera_mode_flying
// 1: _camera_mode_following
long m_camera_mode_index;

// k_debug_camera_modes[m_camera_mode_index] == _camera_mode_flying
// = !m_biped_control_mode && editor_input_inhibited()
bool m_collision_disabled;

// 0: _camera_mode_flying
// 1: _camera_mode_static
bool m_biped_control_mode;

byte pad[2];
byte pad[0x2];
byte unused[0xC];
};
static_assert(sizeof(c_debug_director) == 0x160);
Expand Down
Loading

0 comments on commit bb4066d

Please sign in to comment.