Skip to content

Commit

Permalink
update return type of get_player_unit_data
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeulater committed Nov 4, 2023
1 parent ea1b192 commit 4ec7e0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions xlive/Blam/Engine/game/players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,20 @@ datum s_player::get_unit_index(datum player_index)
return get(player_index)->unit_index;
}

uint8* s_player::get_player_unit_data(datum player_index)
unit_datum* s_player::get_player_unit_data(datum player_index)
{
datum unit_datum = s_player::get_unit_index(player_index);
if (DATUM_IS_NONE(unit_datum))
datum unit_index = s_player::get_unit_index(player_index);
if (DATUM_IS_NONE(unit_index))
return nullptr;

return (uint8*)object_get_fast_unsafe(unit_datum);
return (unit_datum*)object_get_fast_unsafe(unit_index);
}

real_vector3d* s_player::get_unit_coords(datum player_index)
{
uint8* player_unit = get_player_unit_data(player_index);
unit_datum* player_unit = get_player_unit_data(player_index);
if (player_unit != nullptr)
return reinterpret_cast<real_point3d*>(player_unit + 0x64);
return &player_unit->object.position;

return nullptr;
}
Expand Down
4 changes: 3 additions & 1 deletion xlive/Blam/Engine/game/players.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include "Blam/Engine/memory/data.h"
#include "Blam/Engine/objects/damage_reporting.h"
#include "Blam/Engine/objects/emblems.h"
#include "Blam/Engine/objects/objects.h"
#include "Blam/Engine/units/units.h"
#include "Blam/Engine/Simulation/MachineID.h"

#define k_maximum_players 16
Expand Down Expand Up @@ -171,7 +173,7 @@ struct s_player
static void set_unit_speed(datum player_index, float speed);
static const wchar_t* get_name(datum player_index);
static datum get_unit_index(datum player_index);
static uint8* get_player_unit_data(datum player_index);
static unit_datum* get_player_unit_data(datum player_index);
static real_vector3d* get_unit_coords(datum player_index);
static uint64 get_id(datum player_index);
};
Expand Down

0 comments on commit 4ec7e0e

Please sign in to comment.