diff --git a/docs/progress.svg b/docs/progress.svg index baf3c50..df77531 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -45.89% (559) · 51.64% (629) · 0% (0) · 2.46% (30) +45.98% (560) · 51.56% (628) · 0% (0) · 2.46% (30) - - + + @@ -233,7 +233,7 @@ void __cdecl Lara_BaddieCollision(ITEM_INFO *lara_item, COLL_INFO *coll); void __cdecl Lara_TakeHit(ITEM_INFO *lara_item, COLL_INFO *coll); void __cdecl Creature_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); -void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); +void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); void __cdecl Door_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); void __cdecl Object_CollisionTrap(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); void __cdecl Lara_Push(ITEM_INFO *item, ITEM_INFO *lara_item, COLL_INFO *coll, int32_t spaz_on, int32_t big_push); @@ -1298,10 +1298,10 @@ Tomb2.exe progress according to the function sizes: -42.81% · 56.86% · 0% · 0.33% +42.84% · 56.84% · 0% · 0.33% - - + + @@ -2074,7 +2074,7 @@ void __thiscall SE_ChangeBitmapPalette(BITMAP_RESOURCE *bmpRsrc, HWND hWnd); void __cdecl ReqItemRightalign(REQUEST_INFO *req, TEXTSTRING *txt); void __cdecl Room_GetNewRoom(int32_t x, int32_t y, int32_t z, int16_t room_num); -void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); +void __cdecl Object_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll); int32_t __cdecl Item_IsTriggerActive(ITEM_INFO *item); BOOL __cdecl LoadAnimatedTextures(HANDLE handle); void __cdecl Shell_Cleanup(void); diff --git a/docs/progress.txt b/docs/progress.txt index d11ff67..52d93b1 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -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); diff --git a/meson.build b/meson.build index 7fb7cf5..b5fa3d9 100644 --- a/meson.build +++ b/meson.build @@ -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', diff --git a/src/game/creature.c b/src/game/creature.c index b5743f9..dbffd1d 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -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); } } diff --git a/src/game/objects/common.c b/src/game/objects/common.c new file mode 100644 index 0000000..45c0fd6 --- /dev/null +++ b/src/game/objects/common.c @@ -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); + } +} diff --git a/src/game/objects/common.h b/src/game/objects/common.h new file mode 100644 index 0000000..ab47200 --- /dev/null +++ b/src/game/objects/common.h @@ -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); diff --git a/src/game/objects/vehicles/boat.c b/src/game/objects/vehicles/boat.c index f9bb954..02c1578 100644 --- a/src/game/objects/vehicles/boat.c +++ b/src/game/objects/vehicles/boat.c @@ -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" diff --git a/src/global/funcs.h b/src/global/funcs.h index a9b18d6..e7cd009 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -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) diff --git a/src/inject_exec.c b/src/inject_exec.c index d126939..8f56921 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -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)