Created
April 25, 2019 14:57
-
-
Save camden-smallwood-zz/a847c6ae98d6751d2587a8e5584fadf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datum_handle __cdecl object_new(s_object_placement_data *placement_data) | |
{ | |
s_object_placement_data *_data; // edi | |
string_id v2; // ST3C_4 | |
s_object_type_definition *object_type; // eax | |
__int32 model_tag_index; // ecx | |
s_object_type_definition *_object_type; // esi | |
datum_handle object_index; // ebx | |
s_tls_data *tls; // eax | |
s_object_definition *_definition; // ecx | |
s_object_header *object_headers; // eax | |
int header_index; // edx | |
s_object_data *object_data; // esi | |
s_object_placement_data *_placement_data; // edi | |
__int16 object_source; // ax | |
bool v14; // al | |
long_flags v15; // edx | |
unsigned int v16; // edx | |
s_model_definition *model1; // eax | |
s_object_data *v18; // edx | |
s_object_data *v19; // ecx | |
dword v20; // eax | |
__int32 v21; // ecx | |
signed __int16 v22; // ax | |
__int32 v23; // eax | |
s_object_definition *v24; // esi | |
signed int v25; // eax | |
bool v26; // zf | |
char v27; // al | |
__int16 v28; // ax | |
__int16 v29; // si | |
__int16 v30; // si | |
int v31; // eax | |
bool v32; // cl | |
__int16 v33; // ax | |
char v34; // cl | |
char *v35; // eax | |
s_object_data *v36; // esi | |
char *v37; // esi | |
char *v38; // esi | |
_BYTE *v39; // edi | |
bool v40; // al | |
bool v41; // cl | |
int v42; // eax | |
int datum_handle; // eax | |
char v44; // al | |
char v45; // al | |
_BYTE *v46; // ecx | |
bool v47; // al | |
s_location *location; // eax | |
__int32 creation_effect_tag_index; // ecx | |
datum_handle parent_object_index; // eax | |
ulong v51; // eax | |
signed __int16 v53; // [esp+20h] [ebp-38h] | |
unsigned __int32 v54; // [esp+20h] [ebp-38h] | |
s_object_type_definition *__object_type; // [esp+24h] [ebp-34h] | |
signed __int16 v56; // [esp+28h] [ebp-30h] | |
signed __int16 v57; // [esp+2Ch] [ebp-2Ch] | |
int v58; // [esp+30h] [ebp-28h] | |
s_object_header *_object_headers; // [esp+34h] [ebp-24h] | |
bool disable_physics; // [esp+38h] [ebp-20h] | |
s_model_definition *model2; // [esp+3Ch] [ebp-1Ch] | |
int v62; // [esp+40h] [ebp-18h] | |
bool v63; // [esp+44h] [ebp-14h] | |
#368 *v64; // [esp+44h] [ebp-14h] | |
s_tls_data *v65; // [esp+48h] [ebp-10h] | |
s_object_definition *definition; // [esp+4Ch] [ebp-Ch] | |
char v67; // [esp+50h] [ebp-8h] | |
char v68; // [esp+50h] [ebp-8h] | |
char v69; // [esp+51h] [ebp-7h] | |
bool has_multiplayer_properties; // [esp+52h] [ebp-6h] | |
char v71; // [esp+53h] [ebp-5h] | |
char v72; // [esp+54h] [ebp-4h] | |
_data = placement_data; | |
v69 = 0; | |
if ( !(placement_data->placement_flags & 0x10) && placement_data->definition_index != NONE ) | |
object_place(placement_data); | |
if ( _data->definition_index == NONE || (v2 = _data->variant_name, sub_B58FF0(_data->definition_index)) ) | |
{ | |
if ( _data->definition_index != NONE ) | |
{ | |
definition = (s_object_definition *)tag_get('obje', _data->definition_index); | |
model2 = 0; | |
object_type = (s_object_type_definition *)object_type_get_definition(definition->type); | |
model_tag_index = definition->model.tag_index; | |
_object_type = object_type; | |
__object_type = object_type; | |
if ( model_tag_index != NONE ) | |
model2 = (s_model_definition *)tag_get('hlmt', model_tag_index); | |
if ( object_physics_predicate_sub_5C8200(0xFFFFFFFF, _data->definition_index) ) | |
havok_sub_75CF50(); | |
object_index = object_header_new(_object_type->datum_size); | |
if ( object_index == NONE ) | |
return object_index; | |
v67 = 0; | |
tls = *(s_tls_data **)(__readfsdword(0x2Cu) + 4 * g_tls_index); | |
_definition = definition; | |
v65 = tls; | |
object_headers = (s_object_header *)tls->object_header->base_address; | |
header_index = (unsigned __int16)object_index; | |
object_data = (s_object_data *)object_headers[header_index].data; | |
_object_headers = object_headers; | |
has_multiplayer_properties = definition->multiplayer_properties.count > 0; | |
object_headers[header_index].flags |= 8u; | |
object_headers[header_index].type = definition->type; | |
object_data->object_flags |= 4u; | |
_placement_data = placement_data; | |
v62 = 16 * (unsigned __int16)object_index; | |
object_data->definition_index = placement_data->definition_index; | |
object_data->map_variant_index = NONE; | |
object_data->next_recycling_object_index = NONE; | |
object_data->recycling_time = NONE; | |
object_data->parent_recycling_group = NONE; | |
object_data->next_recycling_group_member = NONE; | |
object_data->air_probe_index2 = NONE; | |
object_data->air_probe_index = NONE; | |
v71 = 0; | |
disable_physics = false; | |
if ( _placement_data->object_identifier.source == NONE ) | |
{ | |
sub_B282E0(definition->type); | |
_definition = definition; | |
object_source = NONE; | |
} | |
else | |
{ | |
object_data->object_identifier.unique_id = _placement_data->object_identifier.unique_id; | |
*(_DWORD *)&object_data->object_identifier.origin_bsp_index = *(_DWORD *)&_placement_data->object_identifier.origin_bsp_index; | |
object_source = _placement_data->map_variant_index; | |
} | |
object_data->scenario_datum_index = object_source; | |
_mm_storel_epi64( | |
(__m128i *)&object_data->relative_position, | |
_mm_loadl_epi64((const __m128i *)&_placement_data->relative_position)); | |
object_data->relative_position.z = _placement_data->relative_position.z; | |
_mm_storel_epi64((__m128i *)&object_data->forward, _mm_loadl_epi64((const __m128i *)&_placement_data->forward)); | |
object_data->forward.k = _placement_data->forward.k; | |
_mm_storel_epi64((__m128i *)&object_data->up, _mm_loadl_epi64((const __m128i *)&_placement_data->up)); | |
object_data->up.k = _placement_data->up.k; | |
_mm_storel_epi64( | |
(__m128i *)&object_data->transitional_velocity, | |
_mm_loadl_epi64((const __m128i *)&_placement_data->translational_velocity)); | |
object_data->transitional_velocity.k = _placement_data->translational_velocity.k; | |
_mm_storel_epi64( | |
(__m128i *)&object_data->angular_velocity, | |
_mm_loadl_epi64((const __m128i *)&_placement_data->angular_velocity)); | |
object_data->angular_velocity.k = _placement_data->angular_velocity.k; | |
object_data->scale = _placement_data->scale; | |
if ( _placement_data->placement_flags & 1 ) | |
object_data->object_flags |= 0x400u; | |
else | |
object_data->object_flags &= 0xFFFFFBFF; | |
v14 = model2 && model2->collision_model.tag_index != NONE; | |
if ( v14 ) | |
object_data->object_flags |= 0x200u; | |
else | |
object_data->object_flags &= 0xFFFFFDFF; | |
object_data->object_flags &= 0x7FFFFFFFu; | |
v15 = object_data->object_flags; | |
if ( object_data->object_identifier.source == 5 ) | |
v16 = (unsigned int)&unk_4000000 | v15; | |
else | |
v16 = v15 & 0xFBFFFFFF; | |
object_data->object_flags = v16; | |
if ( _definition->model.tag_index != NONE ) | |
{ | |
model1 = (s_model_definition *)tag_get('hlmt', _definition->model.tag_index); | |
if ( (unsigned __int8)sub_14EA540(model1->render_model.tag_index) ) | |
object_data->object_flags |= 0x800u; | |
else | |
object_data->object_flags &= 0xFFFFF7FF; | |
} | |
LOWORD(_object_headers[v62 / 0x10u].unknown) = NONE; | |
object_data->location = (s_location)-1; | |
object_data->first_cluster_reference_index = NONE; | |
object_data->clusters_touched_on_connection = 0; | |
object_data->bsp_placement_policy = _placement_data->bsp_placement_policy; | |
object_data->parent_object_index = NONE; | |
object_data->next_object_index = NONE; | |
object_data->first_child_object_index = NONE; | |
object_data->first_widget_index = NONE; | |
object_data->name_index = NONE; | |
*(_WORD *)&object_data->damaged_explosion_timer = NONE; | |
object_data->shield_impact_decay_timer = NONE; | |
v18 = *(s_object_data **)&v65->object_header->base_address[v62 + 12]; | |
if ( v18->object_flags & 1 ) | |
{ | |
v18->object_flags &= ~1u; | |
if ( v65->object_header->base_address[16 * (unsigned __int16)object_get_root_object_handle(object_index) + 2] & 0x40 ) | |
sub_B2C7B0(object_index, 0, 1, 0, 0); | |
object_sub_B347F0(object_index); | |
} | |
v19 = *(s_object_data **)&v65->object_header->base_address[v62 + 12]; | |
_mm_storel_epi64((__m128i *)&v19->damage_owner, _mm_loadl_epi64((const __m128i *)&_placement_data->damage_owner2)); | |
*(_DWORD *)&v19->damage_owner.team = *(_DWORD *)&_placement_data->damage_owner2.team; | |
object_data->bsp2E4_datum_index = NONE; | |
object_data->havok_component_index = NONE; | |
object_data->physics_flags = 0; | |
object_data->variant_index = NONE; | |
v20 = 0; | |
if ( (definition->flags >> 14) & 1 ) | |
v20 = 0x200000; | |
object_data->physics_flags = v20; | |
if ( definition->_bfca & 1 ) | |
object_data->physics_flags |= 0x400000u; | |
else | |
object_data->physics_flags &= 0xFFBFFFFF; | |
if ( (_placement_data->placement_flags >> 3) & 1 ) | |
object_data->physics_flags |= 0x200u; | |
else | |
object_data->physics_flags &= 0xFFFFFDFF; | |
object_data->in_water_ticks = -32768; | |
object_data->created_at_rest = (LOWORD(_placement_data->placement_flags) >> 8) & 1; | |
object_data->simulation_object_glue_index = NONE; | |
object_data->simulation_unknown_team_index = NONE; | |
*(_WORD *)&object_data->simulation_flags = -256; | |
object_data->destroyed_constraints = _placement_data->valid_damage_constraints1; | |
object_data->loosened_constraints = _placement_data->valid_damage_constraints2; | |
sub_B2AAC0(object_index); | |
if ( *((_BYTE *)_placement_data + 330) ) | |
object_data->simulation_flags |= 2u; | |
else | |
object_data->simulation_flags &= 0xFDu; | |
LOWORD(v21) = 1; | |
v22 = 0; | |
if ( ((unsigned __int32)object_data->object_flags >> 11) & 1 ) | |
v22 = 32; | |
object_data->unknown_simulation_ticks = NONE; | |
v57 = 1; | |
v56 = 1; | |
v53 = v22; | |
LOWORD(v58) = 0; | |
v63 = 0; | |
if ( model2 ) | |
{ | |
if ( model2->nodes.count >= 1 ) | |
v21 = model2->nodes.count; | |
v57 = v21; | |
LOWORD(v21) = 1; | |
if ( model2->collision_regions.count >= 1 ) | |
v21 = model2->collision_regions.count; | |
v56 = v21; | |
if ( model2->new_damage_info.count > 0 ) | |
v58 = *((_DWORD *)model2->new_damage_info.address + 49); | |
v23 = model2->animation.tag_index; | |
v24 = definition; | |
if ( v23 != NONE && (sub_6DF6E0(v23, definition->model.tag_index) || definition->model.tag_index == NONE) ) | |
{ | |
v25 = 1 << LOBYTE(definition->type); | |
v71 = 1; | |
v63 = (v25 & 0x47F0) == 0; | |
if ( v25 & 0x330 ) | |
{ | |
v26 = (*(_BYTE *)(tag_get('devi', _placement_data->definition_index) + 0x120) & AllowInterpolation) == 0; | |
v27 = v63; | |
if ( !v26 ) | |
v27 = 1; | |
v63 = v27; | |
} | |
} | |
} | |
else | |
{ | |
v24 = definition; | |
} | |
if ( !(unsigned __int8)object_header_block_allocate(object_index, 346, 8 * LOWORD(v24->attachments.count), 2) | |
|| !(unsigned __int8)object_header_block_allocate(object_index, 350, 12 * v58, 1) | |
|| !(unsigned __int8)object_header_block_allocate(object_index, 354, 24 * LOWORD(v24->change_colors.count), 2) | |
|| !(unsigned __int8)object_header_block_allocate(object_index, 338, 52 * v57, 2) | |
|| !(unsigned __int8)object_header_block_allocate(object_index, 342, v53 + 10 * v56, 2) | |
|| (!v63 ? (v28 = 0) : (v28 = 32 * v57), | |
!(unsigned __int8)object_header_block_allocate(object_index, 334, v28, 4) | |
|| (!v63 ? (v29 = 0) : (v29 = 32 * v57), | |
v72 = 1, | |
!(unsigned __int8)object_header_block_allocate(object_index, 330, v29, 4))) ) | |
{ | |
v72 = 0; | |
} | |
v30 = 0; | |
if ( v71 ) | |
{ | |
v30 = 192; | |
if ( __object_type->unknown14 != NONE ) | |
{ | |
v31 = mixing_board_get_definition(__object_type->unknown14); | |
if ( v31 ) | |
v30 = *(unsigned int *)(v31 + 4) + 0xC0; | |
} | |
} | |
v32 = v72 && (unsigned __int8)object_header_block_allocate(object_index, 358, v30, 3); | |
v33 = 0; | |
if ( has_multiplayer_properties ) | |
v33 = 0x4C; | |
if ( v32 && (unsigned __int8)object_header_block_allocate(object_index, 362, v33, 2) ) | |
{ | |
v34 = sub_5C4560(_placement_data->definition_index); | |
v72 = v34; | |
if ( v34 ) | |
{ | |
LABEL_94: | |
v35 = v65->object_header->base_address; | |
v36 = *(s_object_data **)&v35[v62 + 12]; | |
v64 = *(#368 **)&v35[v62 + 12]; | |
if ( v34 ) | |
{ | |
if ( v71 ) | |
{ | |
v37 = (char *)v64 + v36->animation.offset; | |
sub_6DC960(v37, object_index, __object_type->unknown14); | |
sub_6DDD20(v37, model2->animation.tag_index, definition->model.tag_index, 1); | |
} | |
if ( has_multiplayer_properties ) | |
{ | |
v38 = definition->multiplayer_properties.address; | |
v39 = (char *)v64 + *((signed __int16 *)v64 + 182); | |
v68 = sub_42E130(); | |
sub_BA06E0(placement_data->definition_index, v38, &placement_data->multiplayer_properties); | |
if ( *v39 & 1 && !v68 ) | |
{ | |
v40 = game_is_forge(); | |
v41 = false; | |
if ( !v40 ) | |
v41 = true; | |
disable_physics = v41; | |
} | |
_placement_data = placement_data; | |
} | |
if ( definition->attachments.count > 0 ) | |
memset((char *)v64 + *((signed __int16 *)v64 + 174), NONE, *((signed __int16 *)v64 + 173) & 0xFFFFFFF8); | |
v72 = sub_B73C60(object_index, _placement_data, &v69); | |
v67 = 1; | |
v36 = *(s_object_data **)&v65->object_header->base_address[v62 + 12]; | |
} | |
v42 = _placement_data->damage_owner1.object_index; | |
if ( v42 != NONE ) | |
{ | |
datum_handle = object_get_root_object_handle(v42); | |
sub_B98FB0(datum_handle, object_index); | |
} | |
v44 = v72; | |
if ( v72 ) | |
{ | |
v54 = ((unsigned __int32)v36->object_flags >> 17) & 0xFFFFFF01; | |
if ( _placement_data->placement_flags & 6 ) | |
v36->object_flags &= 0xFFFDFFFF; | |
object_early_mover_new(object_index); | |
object_register_scenario_object(object_index); | |
object_choose_variant(object_index, _placement_data->variant_name); | |
object_choose_initial_permutation( | |
object_index, | |
_placement_data->field_138, | |
(int)_placement_data->ordnance_drop_points, | |
_placement_data->ordnance_drop_point_count); | |
object_set_initial_change_colors( | |
object_index, | |
_placement_data->valid_change_colors, | |
_placement_data->change_colors); | |
object_set_initial_variation_values(object_index, 0, 0); | |
object_compute_change_colors(object_index); | |
object_has_animation_manager(object_index); | |
if ( v45 ) | |
object_reset_interpolation(object_index); | |
object_wake(object_index); | |
HIBYTE(placement_data) = object_load_scenario_placement_matrices(object_index); | |
if ( !HIBYTE(placement_data) ) | |
object_compute_node_matrices(object_index); | |
v46 = (_BYTE *)v65->object_globals; | |
if ( v46 && *v46 ) | |
{ | |
if ( *((_BYTE *)_placement_data + 326) | |
|| (v47 = object_find_initial_location(object_index, &_placement_data->location), | |
(*((_BYTE *)_placement_data + 326) = v47) != 0) ) | |
{ | |
location = &_placement_data->location; | |
} | |
else | |
{ | |
location = 0; | |
} | |
object_reconnect_to_map(object_index, true, location); | |
} | |
havok_component_acquire(object_index); | |
if ( !HIBYTE(placement_data) ) | |
sub_B31770(object_index); | |
if ( (_placement_data->placement_flags >> 5) & 1 ) | |
v36->physics_flags |= 2u; | |
else | |
v36->physics_flags &= 0xFFFFFFFD; | |
object_reconnect_to_physics(object_index); | |
object_create_attachments(object_index); | |
object_type_create_children(object_index); | |
creation_effect_tag_index = definition->creation_effect.tag_index; | |
if ( creation_effect_tag_index != NONE ) | |
{ | |
placement_data = 0; | |
effect_new_from_object( | |
creation_effect_tag_index, | |
(const __m128i *)&_placement_data->damage_owner2, | |
(campaign_metagame_globals *)&placement_data, | |
object_index, | |
0.0, | |
0i64, | |
0, | |
1); | |
} | |
object_build_damage_report(object_index); | |
if ( (_BYTE)v54 ) | |
v36->object_flags |= 0x20000u; | |
else | |
v36->object_flags &= 0xFFFDFFFF; | |
parent_object_index = _placement_data->parent_object_index; | |
if ( parent_object_index != NONE ) | |
object_attach_to_marker( | |
parent_object_index, | |
(StringIds)_placement_data->child_name, | |
object_index, | |
(StringIds)_placement_data->child_marker_name); | |
if ( disable_physics ) | |
object_disable_physics(object_index, 1); | |
if ( ((unsigned __int32)v36->object_flags >> 17) & 1 ) | |
{ | |
if ( !(_object_headers[v62 / 0x10u].flags & 1) && sub_B35260() ) | |
{ | |
v51 = _placement_data->placement_flags; | |
if ( !(v51 & 2) && (!(v51 & 4) || v36->location.cluster_reference.bsp_index != NONE) ) | |
hs_object_destroy(object_index); | |
} | |
} | |
v44 = v72; | |
} | |
v36->object_flags &= 0xFFFFFFFB; | |
if ( !v44 ) | |
{ | |
if ( v67 ) | |
object_type_delete(object_index); | |
object_header_delete(object_index); | |
object_index = NONE; | |
} | |
sub_B36F50(object_index); | |
return object_index; | |
} | |
} | |
else | |
{ | |
v34 = 0; | |
v72 = 0; | |
} | |
v69 = 1; | |
goto LABEL_94; | |
} | |
} | |
return NONE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment