port Object_Collision

This commit is contained in:
Marcin Kurczewski 2024-07-18 13:17:03 +02:00
parent 03f04c2595
commit e90bb700e8
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
9 changed files with 42 additions and 11 deletions

View File

@ -69,10 +69,10 @@
</g>
<g transform="translate(0 116)">
<text x="0" y="7.50">Tomb2.exe progress according to the physical function order:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">45.89% (559)</tspan> · <tspan class="known">51.64% (629)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">45.98% (560)</tspan> · <tspan class="known">51.56% (628)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="342.83" height="6" x="0" y="0" class="decompiled"/>
<rect width="385.77" height="6" x="342.83" y="0" class="known"/>
<rect width="343.45" height="6" x="0" y="0" class="decompiled"/>
<rect width="385.15" height="6" x="343.45" y="0" class="known"/>
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -233,7 +233,7 @@
<rect width="12" height="12" x="60" y="45" class="decompiled"><title>void __cdecl Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="75" y="45" class="decompiled"><title>void __cdecl Lara_TakeHit(ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="90" y="45" class="decompiled"><title>void __cdecl Creature_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="105" y="45" class="known"><title>void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="105" y="45" class="decompiled"><title>void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="120" y="45" class="known"><title>void __cdecl Door_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="135" y="45" class="known"><title>void __cdecl Object_CollisionTrap(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="12" height="12" x="150" y="45" class="known"><title>void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);</title></rect>
@ -1298,10 +1298,10 @@
</g>
<g transform="translate(0 546)">
<text x="0" y="7.50">Tomb2.exe progress according to the function sizes:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">42.81%</tspan> · <tspan class="known">56.86%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">42.84%</tspan> · <tspan class="known">56.84%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="319.81" height="6" x="0" y="0" class="decompiled"/>
<rect width="424.75" height="6" x="319.81" y="0" class="known"/>
<rect width="320" height="6" x="0" y="0" class="decompiled"/>
<rect width="424.56" height="6" x="320" y="0" class="known"/>
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -2074,7 +2074,7 @@
<rect width="5.24" height="5.77" x="741.76" y="244.61" class="known"><title>void __thiscall SE_ChangeBitmapPalette(BITMAP_RESOURCE *bmpRsrc, HWND hWnd);</title></rect>
<rect width="5.39" height="5.51" x="616.62" y="253.38" class="known"><title>void __cdecl ReqItemRightalign(REQUEST_INFO *req, TEXTSTRING *txt);</title></rect>
<rect width="5.39" height="5.41" x="616.62" y="261.89" class="decompiled"><title>void __cdecl Room_GetNewRoom(int32_t x, int32_t y, int32_t z, int16_t room_num);</title></rect>
<rect width="5.39" height="5.41" x="616.62" y="270.30" class="known"><title>void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="5.39" height="5.41" x="616.62" y="270.30" class="decompiled"><title>void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="5.39" height="5.41" x="616.62" y="278.72" class="known"><title>int32_t __cdecl Item_IsTriggerActive(ITEM_INFO *item);</title></rect>
<rect width="5.39" height="5.41" x="616.62" y="287.13" class="known"><title>BOOL __cdecl LoadAnimatedTextures(HANDLE handle);</title></rect>
<rect width="5.39" height="5.41" x="616.62" y="295.54" class="decompiled"><title>void __cdecl Shell_Cleanup(void);</title></rect>

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 361 KiB

View File

@ -2748,7 +2748,7 @@ typedef struct __unaligned {
0x00413640 0x0195 + void __cdecl Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll);
0x004137E0 0x0079 + void __cdecl Lara_TakeHit(ITEM_INFO *lara_item, COLL_INFO *coll);
0x00413860 0x0078 + void __cdecl Creature_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
0x004138E0 0x0055 - void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
0x004138E0 0x0055 + void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
0x00413940 0x0077 - void __cdecl Door_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
0x004139C0 0x0067 - void __cdecl Object_CollisionTrap(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);
0x00413A30 0x0306 - void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push);

View File

@ -95,6 +95,7 @@ dll_sources = [
'src/game/music/music_backend_cdaudio.c',
'src/game/music/music_backend_files.c',
'src/game/music/music_main.c',
'src/game/objects/common.c',
'src/game/objects/creatures/bird.c',
'src/game/objects/vehicles/boat.c',
'src/game/output.c',

View File

@ -880,6 +880,6 @@ void __cdecl Creature_Collision(
if (coll->enable_baddie_push && g_Lara.water_status != LWS_UNDERWATER
&& g_Lara.water_status != LWS_SURFACE) {
Lara_Push(item, lara_item, coll, coll->enable_spaz, 0);
Lara_Push(item, lara_item, coll, coll->enable_spaz, false);
}
}

22
src/game/objects/common.c Normal file
View File

@ -0,0 +1,22 @@
#include "game/objects/common.h"
#include "global/funcs.h"
#include "global/vars.h"
void __cdecl Object_Collision(
const int16_t item_num, ITEM_INFO *const lara_item, COLL_INFO *const coll)
{
ITEM_INFO *const item = &g_Items[item_num];
if (!Item_TestBoundsCollide(item, lara_item, coll->radius)) {
return;
}
if (!Collide_TestCollision(item, lara_item)) {
return;
}
if (coll->enable_baddie_push) {
Lara_Push(item, lara_item, coll, false, true);
}
}

View File

@ -0,0 +1,6 @@
#pragma once
#include "global/types.h"
void __cdecl Object_Collision(
int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);

View File

@ -4,6 +4,7 @@
#include "game/items.h"
#include "game/lara/lara_look.h"
#include "game/math.h"
#include "game/objects/common.h"
#include "game/random.h"
#include "game/sound.h"
#include "global/funcs.h"

View File

@ -6,7 +6,6 @@
// clang-format off
#define Output_InsertInventoryBackground ((void __cdecl (*)(const int16_t *obj_ptr))0x00401D50)
#define Object_Collision ((void __cdecl (*)(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll))0x004138E0)
#define Door_Collision ((void __cdecl (*)(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll))0x00413940)
#define Object_CollisionTrap ((void __cdecl (*)(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll))0x004139C0)
#define Lara_Push ((void __cdecl (*)(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push))0x00413A30)

View File

@ -21,6 +21,7 @@
#include "game/math_misc.h"
#include "game/matrix.h"
#include "game/music.h"
#include "game/objects/common.h"
#include "game/objects/creatures/bird.h"
#include "game/objects/vehicles/boat.h"
#include "game/output.h"
@ -696,6 +697,7 @@ static void Inject_Objects(const bool enable)
INJECT(enable, 0x0040D950, Boat_Animation);
INJECT(enable, 0x0040DAC0, Boat_Control);
INJECT(enable, 0x0040E0F0, Gondola_Control);
INJECT(enable, 0x004138E0, Object_Collision);
}
static void Inject_S_Audio_Sample(const bool enable)