From 4b7e93de8a52cfcac00d97e000ceeb41c66e335f Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 6 Oct 2022 19:39:18 +1000 Subject: [PATCH] Rename a heap of collision detection functions --- docs/piracychecks.md | 2 +- src/game/body.c | 4 +- src/game/bondbike.c | 28 +- src/game/bondeyespy.c | 48 +- src/game/bondgrab.c | 50 +- src/game/bondgun.c | 2 +- src/game/bondmove.c | 12 +- src/game/bondwalk.c | 57 +- src/game/bot.c | 2 +- src/game/botact.c | 2 +- src/game/chr.c | 56 +- src/game/chraction.c | 265 ++-- src/game/chrai.c | 2 +- src/game/chraicommands.c | 4 +- src/game/explosions.c | 10 +- src/game/lv.c | 1 + src/game/mplayer/scenarios/kingofthehill.inc | 4 +- src/game/padhalllv.c | 10 +- src/game/player.c | 10 +- src/game/playermgr.c | 2 +- src/game/playerreset.c | 2 +- src/game/prop.c | 28 +- src/game/propobj.c | 231 ++-- src/game/setup.c | 2 +- src/game/setupcover.c | 4 +- src/game/setuppads.c | 2 +- src/include/bss.h | 2 +- src/include/commands.h | 6 +- src/include/constants.h | 35 +- src/include/data.h | 2 +- src/include/files/tiles.s | 160 --- src/include/game/chraction.h | 10 +- src/include/game/chraicommands.h | 2 +- src/include/game/prop.h | 2 +- src/include/game/propobj.h | 2 +- src/include/lib/collision.h | 146 +- src/include/types.h | 4 +- src/lib/collision.c | 1309 +++++++++--------- 38 files changed, 1198 insertions(+), 1322 deletions(-) delete mode 100644 src/include/files/tiles.s diff --git a/docs/piracychecks.md b/docs/piracychecks.md index 3f10cb0b4..d03ba85d0 100644 --- a/docs/piracychecks.md +++ b/docs/piracychecks.md @@ -56,7 +56,7 @@ The decomp project wraps all decompiled piracy checks in `#if PIRACYCHECKS` stat **What It Checks:** Checksums `botPickupProp` to make sure it hasn't been modified. -**Payload:** Disables the ability for the player and other characters to go up or down slopes. This is done by nopping the `jr ra` instruction in `cdFindGroundY`, which causes it to flow into the following function, which unconditionally returns false and only exists for this purpose. +**Payload:** Disables the ability for the player and other characters to go up or down slopes. This is done by nopping the `jr ra` instruction in `cdFindGroundInfoAtCyl`, which causes it to flow into the following function, which unconditionally returns false and only exists for this purpose. --- diff --git a/src/game/body.c b/src/game/body.c index 6c0ff6ecb..e72eeaac3 100644 --- a/src/game/body.c +++ b/src/game/body.c @@ -361,7 +361,7 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex) rooms[0] = pad.room; rooms[1] = -1; - if (cdTestVolume(&pad.pos, 20, rooms, CDTYPE_ALL, 1, 200, -200) == CDRESULT_COLLISION + if (cdTestVolume(&pad.pos, 20, rooms, CDTYPE_ALL, CHECKVERTICAL_YES, 200, -200) == CDRESULT_COLLISION && packed->chair == -1 && (packed->spawnflags & SPAWNFLAG_IGNORECOLLISION) == 0) { return; @@ -587,7 +587,7 @@ struct prop *bodyAllocateEyespy(struct pad *pad, s16 room) chr->visionrange = 0; chr->race = bodyGetRace(chr->bodynum); - ground = cdFindGroundY(&pad->pos, 30, rooms, NULL, NULL, NULL, NULL, &inlift, &lift); + ground = cdFindGroundInfoAtCyl(&pad->pos, 30, rooms, NULL, NULL, NULL, NULL, &inlift, &lift); chr->ground = ground; chr->manground = ground; diff --git a/src/game/bondbike.c b/src/game/bondbike.c index fe43d167f..514d19e13 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -137,7 +137,7 @@ void bbikeTryDismountAngle(f32 relativeangle, f32 distance) func0f065e74(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, &pos, rooms); bmoveFindEnteredRoomsByPos(g_Vars.currentplayer, &pos, rooms); - result = cdTestAToB2(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, + result = cdTestCylMove02(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, &pos, rooms, CDTYPE_ALL, true, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); @@ -145,7 +145,7 @@ void bbikeTryDismountAngle(f32 relativeangle, f32 distance) propSetPerimEnabled(g_Vars.currentplayer->hoverbike, true); if (result == CDRESULT_NOCOLLISION) { - result = cdTestVolume(&pos, radius, rooms, CDTYPE_ALL, true, + result = cdTestVolume(&pos, radius, rooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); } @@ -313,7 +313,7 @@ void bbike0f0d2b40(struct defaultobj *bike, struct coord *arg1, f32 arg2, struct struct coord sp60; struct coord sp54; - cd00024e4c(&sp78, &sp6c, 333, "bondbike.c"); + cdGetEdge(&sp78, &sp6c, 333, "bondbike.c"); sp60.x = bike->prop->pos.x; sp60.y = bike->prop->pos.y; @@ -414,21 +414,21 @@ s32 bbikeCalculateNewPosition(struct coord *vel, f32 angledelta) zdiff = dstpos.z - g_Vars.currentplayer->hoverbike->pos.z; if (xdiff > halfradius || zdiff > halfradius || xdiff < -halfradius || zdiff < -halfradius) { - result = cdTestAToB3(&g_Vars.currentplayer->hoverbike->pos, + result = cdExamCylMove06(&g_Vars.currentplayer->hoverbike->pos, g_Vars.currentplayer->hoverbike->rooms, &dstpos, dstrooms, radius, CDTYPE_ALL, 1, ymax - g_Vars.currentplayer->hoverbike->pos.y, ymin - g_Vars.currentplayer->hoverbike->pos.y); if (result == CDRESULT_NOCOLLISION) { - result = cdTestAToB1(&g_Vars.currentplayer->hoverbike->pos, - &dstpos, radius, dstrooms, CDTYPE_ALL, 1, + result = cdExamCylMove02(&g_Vars.currentplayer->hoverbike->pos, + &dstpos, radius, dstrooms, CDTYPE_ALL, true, ymax - g_Vars.currentplayer->hoverbike->pos.y, ymin - g_Vars.currentplayer->hoverbike->pos.y); } } else { - result = cdTestAToB1(&g_Vars.currentplayer->hoverbike->pos, - &dstpos, radius, spa8, CDTYPE_ALL, 1, + result = cdExamCylMove02(&g_Vars.currentplayer->hoverbike->pos, + &dstpos, radius, spa8, CDTYPE_ALL, true, ymax - g_Vars.currentplayer->hoverbike->pos.y, ymin - g_Vars.currentplayer->hoverbike->pos.y); } @@ -473,7 +473,7 @@ s32 bbikeCalculateNewPositionWithPush(struct coord *arg0, f32 arg1) s32 result = bbikeCalculateNewPosition(arg0, arg1); if (result != CDRESULT_NOCOLLISION) { - struct prop *obstacle = cdGetObstacle(); + struct prop *obstacle = cdGetObstacleProp(); if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type == PROPTYPE_CHR) { @@ -563,7 +563,7 @@ void bbikeUpdateVertical(struct coord *pos) g_Vars.currentplayer->prop->pos.y = pos->y; g_Vars.currentplayer->prop->pos.z = pos->z; - ground = cdFindGroundY(&g_Vars.currentplayer->prop->pos, + ground = cdFindGroundInfoAtCyl(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->bond2.radius, g_Vars.currentplayer->prop->rooms, &g_Vars.currentplayer->floorcol, @@ -618,9 +618,9 @@ s32 bbike0f0d3680(struct coord *arg0, struct coord *arg1, struct coord *arg2) if (!result) { #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(arg1, arg2, 659, "bondbike.c"); + cdGetEdge(arg1, arg2, 659, "bondbike.c"); #else - cd00024e4c(arg1, arg2, 656, "bondbike.c"); + cdGetEdge(arg1, arg2, 656, "bondbike.c"); #endif } @@ -646,9 +646,9 @@ s32 bbike0f0d36d4(struct coord *arg0, struct coord *arg1, struct coord *arg2, st if (someint == 0) { #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(arg3, arg4, 685, "bondbike.c"); + cdGetEdge(arg3, arg4, 685, "bondbike.c"); #else - cd00024e4c(arg3, arg4, 682, "bondbike.c"); + cdGetEdge(arg3, arg4, 682, "bondbike.c"); #endif if (arg3->f[0] != arg1->f[0] diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index c4af6a8d0..0fc278df5 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -60,7 +60,7 @@ f32 eyespyFindGround(s16 *floorroom) pos.y = prop->pos.y + yoffset; pos.z = prop->pos.z; - ground = cdFindGroundY(&pos, 26, prop->rooms, NULL, NULL, NULL, floorroom, &inlift, &lift); + ground = cdFindGroundInfoAtCyl(&pos, 26, prop->rooms, NULL, NULL, NULL, floorroom, &inlift, &lift); if (ground < -30000) { ground = -30000; @@ -100,7 +100,7 @@ s32 eyespyTryMoveUpwards(f32 yvel) f0 -= 0.1f; - result = cdTestVolume(&dstpos, 26, dstrooms, types, 1, 15, f0); + result = cdTestVolume(&dstpos, 26, dstrooms, types, CHECKVERTICAL_YES, 15, f0); propSetPerimEnabled(prop, true); if (result == CDRESULT_NOCOLLISION) { @@ -123,12 +123,12 @@ s32 eyespyCalculateNewPosition(struct coord *vel) s16 sp74[24]; s32 types; s32 i; - f32 f18; + f32 ymin; f32 xdiff; f32 zdiff; u32 stack; - f32 limit; - f32 halflimit; + f32 radius; + f32 halfradius; struct prop *prop; s32 playernum; u32 stack2; @@ -146,9 +146,9 @@ s32 eyespyCalculateNewPosition(struct coord *vel) // Allow eyespy to go up steps 30cm or less if (g_Vars.currentplayer->eyespy->oldground <= chr->manground + 30) { - f18 = chr->manground - eyespyprop->pos.y + 30; + ymin = chr->manground - eyespyprop->pos.y + 30; } else { - f18 = g_Vars.currentplayer->eyespy->oldground - eyespyprop->pos.y; + ymin = g_Vars.currentplayer->eyespy->oldground - eyespyprop->pos.y; } // This must be populating dstrooms at least @@ -172,21 +172,21 @@ s32 eyespyCalculateNewPosition(struct coord *vel) xdiff = dstpos.x - eyespyprop->pos.x; zdiff = dstpos.z - eyespyprop->pos.z; - limit = 26; - halflimit = limit * 0.5f; + radius = 26; + halfradius = radius * 0.5f; - if (xdiff > halflimit || zdiff > halflimit || xdiff < -halflimit || zdiff < -halflimit) { - result = cdTestAToB3(&eyespyprop->pos, eyespyprop->rooms, &dstpos, dstrooms, limit, types, 1, 15, f18); + if (xdiff > halfradius || zdiff > halfradius || xdiff < -halfradius || zdiff < -halfradius) { + result = cdExamCylMove06(&eyespyprop->pos, eyespyprop->rooms, &dstpos, dstrooms, radius, types, 1, 15, ymin); if (result == CDRESULT_NOCOLLISION) { - result = cdTestAToB1(&eyespyprop->pos, &dstpos, limit, dstrooms, types, 1, 15, f18); + result = cdExamCylMove02(&eyespyprop->pos, &dstpos, radius, dstrooms, types, true, 15, ymin); } } else { - result = cdTestAToB1(&eyespyprop->pos, &dstpos, limit, sp74, types, 1, 15, f18); + result = cdExamCylMove02(&eyespyprop->pos, &dstpos, radius, sp74, types, true, 15, ymin); } if (result == CDRESULT_COLLISION) { - prop = cdGetObstacle(); + prop = cdGetObstacleProp(); if (prop && prop->type == PROPTYPE_PLAYER) { playernum = g_Vars.currentplayernum; @@ -222,7 +222,7 @@ bool eyespyCalculateNewPositionWithPush(struct coord *vel) if (result != CDRESULT_NOCOLLISION) { g_EyespyHit = EYESPYHIT_BG; - prop = cdGetObstacle(); + prop = cdGetObstacleProp(); if (prop && g_Vars.lvupdate240 > 0) { if (prop->type == PROPTYPE_DOOR) { @@ -235,7 +235,7 @@ bool eyespyCalculateNewPositionWithPush(struct coord *vel) struct coord sp2c; struct coord sp20; - cd00024e4c(&sp2c, &sp20, 286, "bondeyespy.c"); + cdGetEdge(&sp2c, &sp20, 286, "bondeyespy.c"); // Nothing is actually done with these coordinates... // This code was likely copied from bondwalk then the bounce @@ -286,7 +286,7 @@ s32 eyespy0f0cf890(struct coord *arg0, struct coord *arg1, struct coord *arg2, s } if (someint == 0) { - cd00024e4c(arg3, arg4, 350, "bondeyespy.c"); + cdGetEdge(arg3, arg4, 350, "bondeyespy.c"); if (arg3->f[0] != arg1->f[0] || arg3->f[1] != arg1->f[1] @@ -405,7 +405,7 @@ s32 eyespy0f0cfdd0(struct coord *vel, struct coord *arg1, struct coord *arg2) bool result = eyespyCalculateNewPositionWithPush(vel); if (result != CDRESULT_NOCOLLISION) { - cd00024e4c(arg1, arg2, 473, "bondeyespy.c"); + cdGetEdge(arg1, arg2, 473, "bondeyespy.c"); } return result; @@ -635,8 +635,10 @@ bool eyespyTryLaunch(void) playerSetPerimEnabled(g_Vars.currentplayer->prop, false); - if (insafe || !cdTestAToB4(&testfrompos, g_Vars.currentplayer->prop->rooms, - &g_Vars.currentplayer->eyespy->prop->pos, CDTYPE_ALL, 15)) { + if (insafe || !cdExamLos08(&testfrompos, g_Vars.currentplayer->prop->rooms, + &g_Vars.currentplayer->eyespy->prop->pos, + CDTYPE_ALL, + GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT)) { // Launch failed due to not enough physical space, or we're in the G5 safe g_Vars.currentplayer->eyespy->deployed = false; @@ -1142,8 +1144,10 @@ void eyespyProcessInput(bool allowbuttons) g_EyespyPickup = false; } - cdresult = cdHasLineOfSight(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, - &g_Vars.currentplayer->eyespy->prop->pos, g_Vars.currentplayer->eyespy->prop->rooms, 0x22, 0x1c); + cdresult = cdTestLos05(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, + &g_Vars.currentplayer->eyespy->prop->pos, g_Vars.currentplayer->eyespy->prop->rooms, + CDTYPE_DOORS | CDTYPE_BG, + GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); if (cdresult == CDRESULT_COLLISION) { // Something's in the way diff --git a/src/game/bondgrab.c b/src/game/bondgrab.c index 93ed2bb4c..db22ddc2b 100644 --- a/src/game/bondgrab.c +++ b/src/game/bondgrab.c @@ -65,7 +65,7 @@ void bgrabInit(void) if (prop->type == PROPTYPE_OBJ || prop->type == PROPTYPE_DOOR || prop->type == PROPTYPE_WEAPON) { struct defaultobj *obj = prop->obj; struct hov *hov = NULL; - bool withforce; + s32 cdresult; if (obj->hidden & OBJHFLAG_PROJECTILE) { struct projectile *projectile = obj->projectile; @@ -96,18 +96,18 @@ void bgrabInit(void) obj->hidden |= OBJHFLAG_GRABBED; if (obj->flags3 & OBJFLAG3_GEOCYL) { - withforce = cd000276c8(obj->geocyl, + cdresult = cd000276c8Cyl(obj->geocyl, g_Vars.currentplayer->prop->pos.x, g_Vars.currentplayer->prop->pos.z, VERSION >= VERSION_NTSC_1_0 ? 45 : 40, 0, 0); } else { - withforce = cd000274e0(obj->geoblock, + cdresult = cd000274e0Block(obj->geoblock, g_Vars.currentplayer->prop->pos.x, g_Vars.currentplayer->prop->pos.z, VERSION >= VERSION_NTSC_1_0 ? 45 : 40, 0, 0); } - if (withforce) { + if (cdresult != CDRESULT_COLLISION) { g_Vars.currentplayer->grabbedforcez = VERSION >= VERSION_NTSC_1_0 ? 15 : 10; } } @@ -185,9 +185,9 @@ void bgrab0f0ccbf0(struct coord *delta, f32 angle, struct defaultobj *obj) sp98.z = delta->z + g_Vars.currentplayer->prop->pos.z; #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&spb0, &spa4, 201, "bondgrab.c"); + cdGetEdge(&spb0, &spa4, 201, "bondgrab.c"); #else - cd00024e4c(&spb0, &spa4, 200, "bondgrab.c"); + cdGetEdge(&spb0, &spa4, 200, "bondgrab.c"); #endif spc8.x = spa4.z - spb0.z; @@ -217,12 +217,12 @@ void bgrab0f0ccbf0(struct coord *delta, f32 angle, struct defaultobj *obj) struct coord sp44; #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp68, &sp5c, 228, "bondgrab.c"); + cdGetEdge(&sp68, &sp5c, 228, "bondgrab.c"); #else - cd00024e4c(&sp68, &sp5c, 227, "bondgrab.c"); + cdGetEdge(&sp68, &sp5c, 227, "bondgrab.c"); #endif - if (cd00025364(&sp50, &sp44)) { + if (cdGetSavedPos(&sp50, &sp44)) { sp44.x -= sp50.x; sp44.y -= sp50.y; sp44.z -= sp50.z; @@ -300,7 +300,7 @@ bool bgrabTryMoveUpwards(f32 y) ymin -= 0.1f; - result = cdTestVolume(&newpos, radius, rooms, CDTYPE_ALL, 1, + result = cdTestVolume(&newpos, radius, rooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); @@ -369,13 +369,13 @@ s32 bgrabCalculateNewPosition(struct coord *delta, f32 angle, bool arg2) ismoving = true; - cdresult = cd0002d8b8(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, + cdresult = cdExamCylMove05(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, &pos, rooms, CDTYPE_ALL, true, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); if (cdresult == CDRESULT_NOCOLLISION) { - cdresult = cd0002a6fc(&g_Vars.currentplayer->prop->pos, &pos, radius, rooms, CDTYPE_ALL, true, + cdresult = cdExamCylMove01(&g_Vars.currentplayer->prop->pos, &pos, radius, rooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); } @@ -543,7 +543,7 @@ bool bgrabCalculateNewPositiontWithPush(struct coord *delta, f32 angle, bool arg s32 result = bgrabCalculateNewPosition(delta, angle, arg2); if (result != CDRESULT_NOCOLLISION) { - struct prop *obstacle = cdGetObstacle(); + struct prop *obstacle = cdGetObstacleProp(); if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type == PROPTYPE_CHR) { @@ -630,9 +630,9 @@ bool bgrab0f0cdb68(f32 angle) f32 ymin; #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&spa4, &sp98, 678, "bondgrab.c"); + cdGetEdge(&spa4, &sp98, 678, "bondgrab.c"); #else - cd00024e4c(&spa4, &sp98, 674, "bondgrab.c"); + cdGetEdge(&spa4, &sp98, 674, "bondgrab.c"); #endif sp7c = sp98.f[0] - spa4.f[0]; @@ -654,9 +654,9 @@ bool bgrab0f0cdb68(f32 angle) f22 = -f22; } - if (var8005f034) { - for (i = 0; i < var8009a918.header.numvertices; i++) { - f0 = (var8009a918.vertices[i][0] - spa4.f[0]) * f20 + (var8009a918.vertices[i][1] - spa4.f[2]) * f22; + if (g_CdHasSavedBlock) { + for (i = 0; i < g_CdSavedBlock.header.numvertices; i++) { + f0 = (g_CdSavedBlock.vertices[i][0] - spa4.f[0]) * f20 + (g_CdSavedBlock.vertices[i][1] - spa4.f[2]) * f22; if (f0 < 0.0f) { f0 = -f0; @@ -667,7 +667,7 @@ bool bgrab0f0cdb68(f32 angle) } } } else { - if (cd00025364(&sp8c, &sp80)) { + if (cdGetSavedPos(&sp8c, &sp80)) { f32 f0 = (sp8c.f[0] - spa4.f[0]) * f20 + f22 * (sp8c.f[2] - spa4.f[2]); f32 f16 = (sp80.f[0] - spa4.f[0]) * f20 + f22 * (sp80.f[2] - spa4.f[2]); @@ -734,9 +734,9 @@ bool bgrab0f0cdf64(struct coord *delta, struct coord *arg1, struct coord *arg2) if (!result) { #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(arg1, arg2, 815, "bondgrab.c"); + cdGetEdge(arg1, arg2, 815, "bondgrab.c"); #else - cd00024e4c(arg1, arg2, 811, "bondgrab.c"); + cdGetEdge(arg1, arg2, 811, "bondgrab.c"); #endif } @@ -819,7 +819,7 @@ void bgrabUpdateVertical(void) f32 fVar3; f32 f0; - f14 = cdFindGroundY(&g_Vars.currentplayer->prop->pos, + f14 = cdFindGroundInfoAtCyl(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->bond2.radius, g_Vars.currentplayer->prop->rooms, &g_Vars.currentplayer->floorcol, @@ -1218,8 +1218,10 @@ void bgrabTick(void) if (g_Vars.currentplayer->vv_ground <= -30000 || ydiff < -100 || ydiff > 100 || g_Vars.currentplayer->vv_ground < g_Vars.currentplayer->vv_manground - 50 - || !cdHasLineOfSight(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, - &g_Vars.currentplayer->grabbedprop->pos, g_Vars.currentplayer->grabbedprop->rooms, CDTYPE_ALL, 12)) { + || !cdTestLos05(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, + &g_Vars.currentplayer->grabbedprop->pos, g_Vars.currentplayer->grabbedprop->rooms, + CDTYPE_ALL, + GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT)) { bmoveSetMode(MOVEMODE_WALK); } diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 9db092b58..b0028c8ea 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -6110,7 +6110,7 @@ void bgunCreateThrownProjectile(s32 handnum, struct gset *gset) playerSetPerimEnabled(playerprop, false); - if (cd0002deac(&playerprop->pos, playerprop->rooms, &muzzlepos, spawnrooms, CDTYPE_ALL) != CDRESULT_COLLISION) { + if (cdTestLos11(&playerprop->pos, playerprop->rooms, &muzzlepos, spawnrooms, CDTYPE_ALL) != CDRESULT_COLLISION) { spawnpos.x = muzzlepos.x; spawnpos.y = muzzlepos.y; spawnpos.z = muzzlepos.z; diff --git a/src/game/bondmove.c b/src/game/bondmove.c index b3d673cc5..f253f3e57 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -429,16 +429,18 @@ f32 bmoveCalculateLookahead(void) sp150.y = sp100.y * 400 + spf0.y; sp150.z = sp100.z * 400 + spf0.z; - if (cdTestAToB4(&spf0, spe0, &sp150, CDTYPE_BG | CDTYPE_CLOSEDDOORS, 0xf) == CDRESULT_COLLISION) { + if (cdExamLos08(&spf0, spe0, &sp150, + CDTYPE_BG | CDTYPE_CLOSEDDOORS, + GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT) == CDRESULT_COLLISION) { cdGetPos(&sp150, 455, "bondmove.c"); - flags = cdGetTileFlags(); + flags = cdGetGeoFlags(); sp160 = sqrtf((sp150.x - spf0.x) * (sp150.x - spf0.x) + (sp150.y - spf0.y) * (sp150.y - spf0.y) + (sp150.z - spf0.z) * (sp150.z - spf0.z)); } - if (sp160 > 60.0f || (flags & GEOFLAG_0001)) { + if (sp160 > 60.0f || (flags & GEOFLAG_FLOOR1)) { for (i = 0; i < 5; i++) { populated[i] = false; value = (i + 1) * sp160 * 0.2f; @@ -457,9 +459,9 @@ f32 bmoveCalculateLookahead(void) if ( #if VERSION >= VERSION_NTSC_1_0 - cd0002a440(&spbc, sp80, &sp78, NULL, NULL) > 0 + cdFindFloorRoomYColourFlagsAtPos(&spbc, sp80, &sp78, NULL, NULL) > 0 #else - cd0002a440(&spbc, sp80, &sp78, NULL) > 0 + cdFindFloorRoomYColourFlagsAtPos(&spbc, sp80, &sp78, NULL) > 0 #endif && sp78 - ground < 200 && sp78 - ground > -200) { diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index d8a59632e..e9af49ab0 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -148,9 +148,9 @@ void bwalk0f0c3b38(struct coord *reltarget, struct defaultobj *obj) abstarget.z = reltarget->z + g_Vars.currentplayer->prop->pos.z; #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&globalthinga, &globalthingb, 223, "bondwalk.c"); + cdGetEdge(&globalthinga, &globalthingb, 223, "bondwalk.c"); #else - cd00024e4c(&globalthinga, &globalthingb, 221, "bondwalk.c"); + cdGetEdge(&globalthinga, &globalthingb, 221, "bondwalk.c"); #endif vector.x = globalthingb.z - globalthinga.z; @@ -192,7 +192,7 @@ s32 bwalkTryMoveUpwards(f32 amount) f32 ymin; f32 radius; - if (g_Vars.currentplayer->floorflags & GEOFLAG_0100) { + if (g_Vars.currentplayer->floorflags & GEOFLAG_SLOPE) { g_Vars.enableslopes = false; } else { g_Vars.enableslopes = true; @@ -211,7 +211,7 @@ s32 bwalkTryMoveUpwards(f32 amount) ymin -= 0.1f; - result = cdTestVolume(&newpos, radius, rooms, types, 1, + result = cdTestVolume(&newpos, radius, rooms, types, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); @@ -244,7 +244,7 @@ bool bwalkCalculateNewPosition(struct coord *vel, f32 rotateamount, bool apply, f32 zdiff; s32 i; - if (g_Vars.currentplayer->floorflags & GEOFLAG_0100) { + if (g_Vars.currentplayer->floorflags & GEOFLAG_SLOPE) { g_Vars.enableslopes = false; } else { g_Vars.enableslopes = true; @@ -295,21 +295,21 @@ bool bwalkCalculateNewPosition(struct coord *vel, f32 rotateamount, bool apply, halfradius = radius * 0.5f; if (xdiff > halfradius || zdiff > halfradius || xdiff < -halfradius || zdiff < -halfradius) { - result = cdTestAToB3(&g_Vars.currentplayer->prop->pos, + result = cdExamCylMove06(&g_Vars.currentplayer->prop->pos, g_Vars.currentplayer->prop->rooms, &dstpos, dstrooms, radius, types, 1, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); if (result == CDRESULT_NOCOLLISION) { - result = cdTestAToB1(&g_Vars.currentplayer->prop->pos, - &dstpos, radius, dstrooms, types, 1, + result = cdExamCylMove02(&g_Vars.currentplayer->prop->pos, + &dstpos, radius, dstrooms, types, true, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); } } else { - result = cdTestAToB1(&g_Vars.currentplayer->prop->pos, - &dstpos, radius, sp64, types, 1, + result = cdExamCylMove02(&g_Vars.currentplayer->prop->pos, + &dstpos, radius, sp64, types, true, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y); } @@ -354,7 +354,7 @@ bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamount, bo s32 result = bwalkCalculateNewPosition(delta, rotateamount, apply, extrawidth, types); if (result != CDRESULT_NOCOLLISION) { - struct prop *obstacle = cdGetObstacle(); + struct prop *obstacle = cdGetObstacleProp(); if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type == PROPTYPE_DOOR) { @@ -366,9 +366,9 @@ bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamount, bo if (door->doorflags & DOORFLAG_DAMAGEONCONTACT) { if (!g_Vars.currentplayer->isdead) { #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp84, &sp78, 465, "bondwalk.c"); + cdGetEdge(&sp84, &sp78, 465, "bondwalk.c"); #else - cd00024e4c(&sp84, &sp78, 460, "bondwalk.c"); + cdGetEdge(&sp84, &sp78, 460, "bondwalk.c"); #endif sp90.x = sp78.f[2] - sp84.f[2]; @@ -503,9 +503,9 @@ s32 bwalk0f0c4764(struct coord *delta, struct coord *arg1, struct coord *arg2, s if (result == CDRESULT_COLLISION) { #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(arg1, arg2, 607, "bondwalk.c"); + cdGetEdge(arg1, arg2, 607, "bondwalk.c"); #else - cd00024e4c(arg1, arg2, 602, "bondwalk.c"); + cdGetEdge(arg1, arg2, 602, "bondwalk.c"); #endif } @@ -531,9 +531,9 @@ s32 bwalk0f0c47d0(struct coord *a, struct coord *b, struct coord *c, if (result == CDRESULT_COLLISION) { #if VERSION >= VERSION_NTSC_1_0 - cd00024e4c(d, e, 635, "bondwalk.c"); + cdGetEdge(d, e, 635, "bondwalk.c"); #else - cd00024e4c(d, e, 630, "bondwalk.c"); + cdGetEdge(d, e, 630, "bondwalk.c"); #endif if (b->x != d->x @@ -740,7 +740,7 @@ void bwalkUpdateVertical(void) if (g_Vars.antiplayernum >= 0 && g_Vars.currentplayer == g_Vars.anti && g_Vars.currentplayer->bond2.radius != 30 - && cdTestVolume(&g_Vars.currentplayer->prop->pos, 30, g_Vars.currentplayer->prop->rooms, CDTYPE_ALL, 1, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y)) { + && cdTestVolume(&g_Vars.currentplayer->prop->pos, 30, g_Vars.currentplayer->prop->rooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y)) { g_Vars.currentplayer->prop->chr->radius = 30; g_Vars.currentplayer->bond2.radius = 30; radius = 30; @@ -751,10 +751,11 @@ void bwalkUpdateVertical(void) // If this comes up false, a second check is done... maybe checking if the // player is touching a ladder from a room which shares the same coordinate // space? - onladder = cd00029ffc(&g_Vars.currentplayer->prop->pos, + onladder = cdFindLadder(&g_Vars.currentplayer->prop->pos, radius * 1.2f, ymax - g_Vars.currentplayer->prop->pos.y, g_Vars.currentplayer->vv_manground - g_Vars.currentplayer->prop->pos.y + 1, - g_Vars.currentplayer->prop->rooms, 0x8040, &g_Vars.currentplayer->laddernormal); + g_Vars.currentplayer->prop->rooms, GEOFLAG_LADDER | GEOFLAG_LADDER_PLAYERONLY, + &g_Vars.currentplayer->laddernormal); if (!onladder) { testpos.x = g_Vars.currentplayer->prop->pos.x; @@ -762,10 +763,10 @@ void bwalkUpdateVertical(void) testpos.z = g_Vars.currentplayer->prop->pos.z; roomsCopy(g_Vars.currentplayer->prop->rooms, rooms); bmoveFindEnteredRoomsByPos(g_Vars.currentplayer, &testpos, rooms); - onladder2 = cd00029ffc(&g_Vars.currentplayer->prop->pos, + onladder2 = cdFindLadder(&g_Vars.currentplayer->prop->pos, radius * 1.1f, ymax - g_Vars.currentplayer->prop->pos.y, g_Vars.currentplayer->vv_manground - g_Vars.currentplayer->prop->pos.y - 10, - rooms, 0x8040, &g_Vars.currentplayer->laddernormal); + rooms, GEOFLAG_LADDER | GEOFLAG_LADDER_PLAYERONLY, &g_Vars.currentplayer->laddernormal); } testpos.x = g_Vars.currentplayer->prop->pos.x; @@ -778,7 +779,7 @@ void bwalkUpdateVertical(void) roomsCopy(g_Vars.currentplayer->prop->rooms, rooms); bmoveFindEnteredRoomsByPos(g_Vars.currentplayer, &testpos, rooms); - ground = cdFindGroundY(&testpos, g_Vars.currentplayer->bond2.radius, rooms, + ground = cdFindGroundInfoAtCyl(&testpos, g_Vars.currentplayer->bond2.radius, rooms, &g_Vars.currentplayer->floorcol, &g_Vars.currentplayer->floortype, &g_Vars.currentplayer->floorflags, &g_Vars.currentplayer->floorroom, &newinlift, &lift); @@ -888,7 +889,7 @@ void bwalkUpdateVertical(void) #if VERSION >= VERSION_NTSC_1_0 else { // Not enough room above. If on a hoverbike, blow it up - prop = cdGetObstacle(); + prop = cdGetObstacleProp(); if (prop && g_Vars.currentplayer->prop->pos.y < prop->pos.y @@ -963,7 +964,7 @@ void bwalkUpdateVertical(void) && g_Vars.currentplayer->vv_ground < g_Vars.currentplayer->vv_manground - 30) { // Not falling - but still at least 30 units off the ground. // Must be something in the way... - prop = cdGetObstacle(); + prop = cdGetObstacleProp(); if (prop) { if (prop->type == PROPTYPE_CHR) { @@ -1592,12 +1593,10 @@ void bwalk0f0c69b8(void) } else { playerGetBbox(g_Vars.currentplayer->prop, &radius, &ymax, &ymin); - cdresult = cd0002a13c(&g_Vars.currentplayer->prop->pos, + if (!cd0002a13c(&g_Vars.currentplayer->prop->pos, radius * 1.1f, ymax - g_Vars.currentplayer->prop->pos.y, (g_Vars.currentplayer->vv_manground - g_Vars.currentplayer->prop->pos.y) + 1.0f, - g_Vars.currentplayer->prop->rooms, 0x8040); - - if (cdresult == CDRESULT_COLLISION) { + g_Vars.currentplayer->prop->rooms, GEOFLAG_LADDER | GEOFLAG_LADDER_PLAYERONLY)) { g_Vars.currentplayer->ladderupdown = 0.0f; } else { spcc.f[0] += sp74 * g_Vars.currentplayer->laddernormal.f[0]; diff --git a/src/game/bot.c b/src/game/bot.c index 6ba5b51c2..f9e71a795 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -978,7 +978,7 @@ bool botTestPropForPickup(struct prop *prop, struct chrdata *chr) dprint(); if ((obj->flags2 & OBJFLAG2_PICKUPWITHOUTLOS) == 0 - && !cd0002dcd0(&chrprop->pos, chrprop->rooms, &prop->pos, prop->rooms, 0x22)) { + && !cdTestLos06(&chrprop->pos, chrprop->rooms, &prop->pos, prop->rooms, CDTYPE_DOORS | CDTYPE_BG)) { sp3c = false; } } diff --git a/src/game/botact.c b/src/game/botact.c index fe5a81743..4f73ce2cc 100644 --- a/src/game/botact.c +++ b/src/game/botact.c @@ -489,7 +489,7 @@ void botactGetRocketNextStepPos(u16 padnum, struct coord *pos) rooms[1] = -1; pos->x = pad.pos.x; - pos->y = cd0002a36c(&pad.pos, rooms, 0, 0) + 150; + pos->y = cdFindFloorYColourTypeAtPos(&pad.pos, rooms, 0, 0) + 150; pos->z = pad.pos.z; } diff --git a/src/game/chr.c b/src/game/chr.c index 68126e5aa..49b2ebd81 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -260,13 +260,13 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom movez = dstpos->z - prop->pos.z; if (movex > halfradius || movez > halfradius || movex < -halfradius || movez < -halfradius) { - cdresult = cd0002d8b8(&prop->pos, prop->rooms, dstpos, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdExamCylMove05(&prop->pos, prop->rooms, dstpos, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); if (cdresult == CDRESULT_NOCOLLISION) { - cdresult = cd0002a6fc(&prop->pos, dstpos, radius, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdExamCylMove01(&prop->pos, dstpos, radius, dstrooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } } else { - cdresult = cd0002a6fc(&prop->pos, dstpos, radius, sp84, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdExamCylMove01(&prop->pos, dstpos, radius, sp84, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } if (cdresult != CDRESULT_ERROR) { @@ -280,13 +280,13 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom moveok = true; } else { #if VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp78, &sp6c, 453, "chr/chr.c"); + cdGetEdge(&sp78, &sp6c, 453, "chr/chr.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp78, &sp6c, 453, "chr.c"); + cdGetEdge(&sp78, &sp6c, 453, "chr.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp78, &sp6c, 453, "chr/chr.c"); + cdGetEdge(&sp78, &sp6c, 453, "chr/chr.c"); #else - cd00024e4c(&sp78, &sp6c, 451, "chr.c"); + cdGetEdge(&sp78, &sp6c, 451, "chr.c"); #endif // Attempt to find a valid position - method #1 @@ -326,13 +326,13 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom movez = sp44.z - prop->pos.z; if (movex > halfradius || movez > halfradius || movex < -halfradius || movez < -halfradius) { - cdresult = cdTestAToB2(&prop->pos, prop->rooms, &sp44, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestCylMove02(&prop->pos, prop->rooms, &sp44, dstrooms, CDTYPE_ALL, true, ymax - prop->pos.y, ymin - prop->pos.y); if (cdresult == CDRESULT_NOCOLLISION) { - cdresult = cdTestVolume(&sp44, radius, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestVolume(&sp44, radius, dstrooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } } else { - cdresult = cdTestVolume(&sp44, radius, sp84, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestVolume(&sp44, radius, sp84, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } if (cdresult == CDRESULT_NOCOLLISION) { @@ -382,13 +382,13 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom movez = sp44.z - prop->pos.z; if (movex > halfradius || movez > halfradius || movex < -halfradius || movez < -halfradius) { - cdresult = cdTestAToB2(&prop->pos, prop->rooms, &sp44, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestCylMove02(&prop->pos, prop->rooms, &sp44, dstrooms, CDTYPE_ALL, true, ymax - prop->pos.y, ymin - prop->pos.y); if (cdresult == CDRESULT_NOCOLLISION) { - cdresult = cdTestVolume(&sp44, radius, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestVolume(&sp44, radius, dstrooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } } else { - cdresult = cdTestVolume(&sp44, radius, sp84, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestVolume(&sp44, radius, sp84, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } if (cdresult == CDRESULT_NOCOLLISION) { @@ -436,13 +436,13 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom movez = sp44.z - prop->pos.z; if (movex > halfradius || movez > halfradius || movex < -halfradius || movez < -halfradius) { - cdresult = cdTestAToB2(&prop->pos, prop->rooms, &sp44, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestCylMove02(&prop->pos, prop->rooms, &sp44, dstrooms, CDTYPE_ALL, true, ymax - prop->pos.y, ymin - prop->pos.y); if (cdresult == CDRESULT_NOCOLLISION) { - cdresult = cdTestVolume(&sp44, radius, dstrooms, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestVolume(&sp44, radius, dstrooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } } else { - cdresult = cdTestVolume(&sp44, radius, sp84, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y); + cdresult = cdTestVolume(&sp44, radius, sp84, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y); } if (cdresult == CDRESULT_NOCOLLISION) { @@ -494,7 +494,7 @@ bool chr0f01f264(struct chrdata *chr, struct coord *pos, s16 *rooms, f32 arg3) func0f065e74(pos, rooms, &newpos, newrooms); chr0f021fa8(chr, &newpos, newrooms); chrSetPerimEnabled(chr, false); - result = cdTestVolume(&newpos, radius, newrooms, CDTYPE_ALL, 1, + result = cdTestVolume(&newpos, radius, newrooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - chr->prop->pos.y, ymin - chr->prop->pos.y); chrSetPerimEnabled(chr, true); @@ -550,7 +550,7 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 func0f065e74(&prop->pos, prop->rooms, arg2, spfc); } - ground = cdFindGroundY(arg2, chr->radius, spfc, &chr->floorcol, &chr->floortype, &floorflags, &chr->floorroom, &inlift, &lift); + ground = cdFindGroundInfoAtCyl(arg2, chr->radius, spfc, &chr->floorcol, &chr->floortype, &floorflags, &chr->floorroom, &inlift, &lift); if (ground < -1000000) { ground = 0.0f; @@ -603,10 +603,10 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 } if (chr->actiontype == ACT_PATROL || chr->actiontype == ACT_GOPOS) { - chr->onladder = cd00029ffc(&chr->prop->pos, chr->radius * 2.5f, + chr->onladder = cdFindLadder(&chr->prop->pos, chr->radius * 2.5f, chr->manground + chr->height - chr->prop->pos.y, chr->manground + 1.0f - chr->prop->pos.y, - chr->prop->rooms, 0x40, &chr->laddernormal); + chr->prop->rooms, GEOFLAG_LADDER, &chr->laddernormal); } else { chr->onladder = false; } @@ -621,12 +621,12 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 } else if (cd0002a13c(&chr->prop->pos, chr->radius * 1.1f, chr->manground + 185.0f - chr->prop->pos.y, chr->manground - 10.0f - chr->prop->pos.y, - chr->prop->rooms, 0x1000) != CDRESULT_COLLISION) { + chr->prop->rooms, GEOFLAG_AIBOTDUCK)) { chr->height = 135.0f; } else if (cd0002a13c(&chr->prop->pos, chr->radius * 1.1f, chr->manground + 135.0f - chr->prop->pos.y, chr->manground - 10.0f - chr->prop->pos.y, - chr->prop->rooms, 0x800) != CDRESULT_COLLISION) { + chr->prop->rooms, GEOFLAG_AIBOTCROUCH)) { chr->height = 90.0f; } @@ -815,7 +815,7 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 sp94 = spfc; } - ground = cdFindGroundY(sp98, chr->radius, sp94, + ground = cdFindGroundInfoAtCyl(sp98, chr->radius, sp94, &chr->floorcol, &chr->floortype, &floorflags, &chr->floorroom, &inlift, &lift); #if VERSION >= VERSION_NTSC_1_0 @@ -834,7 +834,7 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 lvupdate240freal = 0.0f; - ground = cdFindGroundY(arg2, chr->radius, spfc, &chr->floorcol, &chr->floortype, &floorflags, &chr->floorroom, &inlift, &lift); + ground = cdFindGroundInfoAtCyl(arg2, chr->radius, spfc, &chr->floorcol, &chr->floortype, &floorflags, &chr->floorroom, &inlift, &lift); } #endif @@ -1303,7 +1303,7 @@ struct prop *chr0f020b14(struct prop *prop, struct model *model, testpos.y = pos->y + 100; testpos.z = pos->z; - chr->ground = chr->manground = ground = cdFindGroundY(&testpos, chr->radius, rooms, &chr->floorcol, &chr->floortype, NULL, &chr->floorroom, NULL, NULL); + chr->ground = chr->manground = ground = cdFindGroundInfoAtCyl(&testpos, chr->radius, rooms, &chr->floorcol, &chr->floortype, NULL, &chr->floorroom, NULL, NULL); chr->sumground = ground * (PAL ? 8.4175090789795f : 9.999998f); @@ -2037,7 +2037,7 @@ void chrUncloak(struct chrdata *chr, bool value) } if (checksum != CHECKSUM_PLACEHOLDER) { - ((u32 *)&cd0002a324)[-2] = 0; + ((u32 *)&cdReturnZero)[-2] = 0; } } #endif @@ -5499,9 +5499,9 @@ bool chrUpdateGeometry(struct prop *prop, u8 **start, u8 **end) chr->geo.header.type = GEOTYPE_CYL; if (chr->actiontype == ACT_DIE || chr->actiontype == ACT_DRUGGEDDROP) { - chr->geo.header.flags = GEOFLAG_OPAQUE; + chr->geo.header.flags = GEOFLAG_BLOCK_SHOOT; } else { - chr->geo.header.flags = GEOFLAG_COLLISIONS | GEOFLAG_OPAQUE; + chr->geo.header.flags = GEOFLAG_WALL | GEOFLAG_BLOCK_SHOOT; } chr->geo.ymin = chr->manground; diff --git a/src/game/chraction.c b/src/game/chraction.c index 124c79c22..cc014b878 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -1583,17 +1583,17 @@ void func0f02e4f8(struct coord *arg0, struct coord *arg1, struct coord *dst) struct coord sp20; #if VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp2c, &sp20, 2298, "chr/chraction.c"); + cdGetEdge(&sp2c, &sp20, 2298, "chr/chraction.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp2c, &sp20, 2298, "chraction.c"); + cdGetEdge(&sp2c, &sp20, 2298, "chraction.c"); #else - cd00024e4c(&sp2c, &sp20, 2338, "chraction.c"); + cdGetEdge(&sp2c, &sp20, 2338, "chraction.c"); #endif func0f02e3dc(&sp2c, &sp20, arg0, arg1, dst); } -f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 arg3, f32 ymax, f32 ymin) +f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 cdtypes, f32 ymax, f32 ymin) { struct coord sp5c; struct coord sp50; @@ -1613,7 +1613,7 @@ f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 arg3, f32 ymax, f32 chrSetPerimEnabled(chr, false); - if (cd0002d7c0(&prop->pos, prop->rooms, &sp50, arg3, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { + if (cdExamCylMove03(&prop->pos, prop->rooms, &sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { result = arg2; } else { #if VERSION >= VERSION_PAL_FINAL @@ -5121,8 +5121,8 @@ bool func0f03645c(struct chrdata *chr, struct coord *arg1, s16 *arg2, struct coo chrGetBbox(prop, &radius, &ymax, &ymin); chrSetPerimEnabled(chr, false); - if (cd0002d840(arg1, arg2, arg3, &sp30, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { - if (cd0002d6ac(arg3, &sp30, arg4, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { + if (cdTestCylMove04(arg1, arg2, arg3, &sp30, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { + if (cdTestCylMove01(arg3, &sp30, arg4, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { result = true; } } @@ -5152,8 +5152,8 @@ bool func0f03654c(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coo chrSetPerimEnabled(chr, false); chrGetBbox(prop, &radius, &ymax, &ymin); - if ((rooms2 && cdTestAToB2(pos, rooms, pos2, rooms2, types, 1, ymax - prop->pos.y, ymin - prop->pos.y)) - || (rooms2 == NULL && cd0002d6ac(pos, rooms, pos2, types, 1, ymax - prop->pos.y, ymin - prop->pos.y))) { + if ((rooms2 && cdTestCylMove02(pos, rooms, pos2, rooms2, types, true, ymax - prop->pos.y, ymin - prop->pos.y)) + || (rooms2 == NULL && cdTestCylMove01(pos, rooms, pos2, types, 1, ymax - prop->pos.y, ymin - prop->pos.y))) { if (vector == NULL) { vector = &tmp; @@ -5183,8 +5183,8 @@ bool func0f03654c(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coo sp50.y = pos2->y; sp50.z = pos2->z - a; - if (cd0002d840(pos, rooms, &sp5c, sp40, types, 1, ymax - prop->pos.y, ymin - prop->pos.y) - && cd0002d6ac(&sp5c, sp40, &sp50, types, 1, ymax - prop->pos.y, ymin - prop->pos.y)) { + if (cdTestCylMove04(pos, rooms, &sp5c, sp40, types, 1, ymax - prop->pos.y, ymin - prop->pos.y) + && cdTestCylMove01(&sp5c, sp40, &sp50, types, 1, ymax - prop->pos.y, ymin - prop->pos.y)) { sp5c.x = pos->x - b; sp5c.y = pos->y; sp5c.z = pos->z + a; @@ -5193,8 +5193,8 @@ bool func0f03654c(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coo sp50.y = pos2->y; sp50.z = pos2->z + a; - if (cd0002d840(pos, rooms, &sp5c, sp40, types, 1, ymax - prop->pos.y, ymin - prop->pos.y) - && cd0002d6ac(&sp5c, sp40, &sp50, types, 1, ymax - prop->pos.y, ymin - prop->pos.y)) { + if (cdTestCylMove04(pos, rooms, &sp5c, sp40, types, 1, ymax - prop->pos.y, ymin - prop->pos.y) + && cdTestCylMove01(&sp5c, sp40, &sp50, types, 1, ymax - prop->pos.y, ymin - prop->pos.y)) { result = true; } } @@ -5680,7 +5680,7 @@ void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, st roomsCopy(rooms, sp118); chr0f021fa8(chr, arg3, sp118); - ground = cdFindGroundY(arg3, chr->radius, sp118, &floorcol, &floortype, 0, &floorroom, NULL, NULL); + ground = cdFindGroundInfoAtCyl(arg3, chr->radius, sp118, &floorcol, &floortype, 0, &floorroom, NULL, NULL); spf4.x = arg3->x; spf4.y = prop->pos.y - chr->ground + ground; @@ -5690,7 +5690,7 @@ void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, st chr0f021fa8(chr, &spf4, sp118); chrGetBbox(chr->prop, &radius, &ymax, &ymin); - if (cdTestVolume(&spf4, chr->radius, sp118, CDTYPE_ALL, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { + if (cdTestVolume(&spf4, chr->radius, sp118, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { // Reached end of segment with no collision prop->pos.x = spf4.x; prop->pos.y = spf4.y; @@ -6278,7 +6278,7 @@ void chrStartPatrol(struct chrdata *chr, struct path *path) chrSetPerimEnabled(chr, false); - if (cd0002d840(&prop->pos, prop->rooms, &pad.pos, rooms, CDTYPE_BG, 1, + if (cdTestCylMove04(&prop->pos, prop->rooms, &pad.pos, rooms, CDTYPE_BG, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { nextstep = chr->patrolnextstep; } @@ -6417,12 +6417,12 @@ bool chrCanSeeEntity(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, b func0f065dd8(chrpos, chrrooms, &frompos, fromrooms); - if (cdHasLineOfSight(&frompos, fromrooms, &targetpos, targetrooms, types, 0x10)) { + if (cdTestLos05(&frompos, fromrooms, &targetpos, targetrooms, types, GEOFLAG_BLOCK_SHOOT)) { chrRecordLastVisibleTargetTime(chr); result = true; } } else { - if (cdHasLineOfSight(chrpos, chrrooms, &targetpos, targetrooms, types, 0x10)) { + if (cdTestLos05(chrpos, chrrooms, &targetpos, targetrooms, types, GEOFLAG_BLOCK_SHOOT)) { chrRecordLastVisibleTargetTime(chr); result = true; } @@ -6439,13 +6439,13 @@ bool chrCanSeeEntity(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, b chrSetPerimEnabled(targetchr, false); - if (cdHasLineOfSight(chrpos, chrrooms, &targetpos, targetrooms, types, 0x10)) { + if (cdTestLos05(chrpos, chrrooms, &targetpos, targetrooms, types, GEOFLAG_BLOCK_SHOOT)) { result = true; } chrSetPerimEnabled(targetchr, true); } else if (attackflags & ATTACKFLAG_AIMATPAD) { - if (cdHasLineOfSight(chrpos, chrrooms, &targetpos, targetrooms, types, 0x10)) { + if (cdTestLos05(chrpos, chrrooms, &targetpos, targetrooms, types, GEOFLAG_BLOCK_SHOOT)) { result = true; } } @@ -6489,7 +6489,9 @@ bool chrCanSeeChr(struct chrdata *chr, struct chrdata *target, s16 *room) func0f065e74(&prop->pos, prop->rooms, &pos, rooms); - if (cd0002dcfc(&pos, rooms, &target->prop->pos, target->prop->rooms, sp88, 307, 8)) { + if (cdTestLos07(&pos, rooms, &target->prop->pos, target->prop->rooms, sp88, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, + GEOFLAG_BLOCK_SIGHT)) { cansee = true; } @@ -6532,25 +6534,27 @@ bool chrCanSeeTarget(struct chrdata *chr) return cansee; } -bool chrHasLineOfSightToPos(struct chrdata *viewerchr, struct coord *pos, s16 *rooms) +bool chrHasLineOfSightToPos(struct chrdata *chr, struct coord *pos, s16 *rooms) { - struct prop *viewerprop = viewerchr->prop; + struct prop *prop = chr->prop; bool result = false; - struct coord viewerpos; - s16 viewerrooms[8]; + struct coord eyepos; + s16 chrrooms[8]; - viewerpos.x = viewerprop->pos.x; - viewerpos.y = viewerchr->ground + viewerchr->height - 20; - viewerpos.z = viewerprop->pos.z; + eyepos.x = prop->pos.x; + eyepos.y = chr->ground + chr->height - 20; + eyepos.z = prop->pos.z; - chrSetPerimEnabled(viewerchr, false); - func0f065e74(&viewerprop->pos, viewerprop->rooms, &viewerpos, viewerrooms); + chrSetPerimEnabled(chr, false); + func0f065e74(&prop->pos, prop->rooms, &eyepos, chrrooms); - if (cdHasLineOfSight(&viewerpos, viewerrooms, pos, rooms, 307, 8)) { + if (cdTestLos05(&eyepos, chrrooms, pos, rooms, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, + GEOFLAG_BLOCK_SIGHT)) { result = true; } - chrSetPerimEnabled(viewerchr, true); + chrSetPerimEnabled(chr, true); return result; } @@ -7392,8 +7396,9 @@ bool chrTryRunFromTarget(struct chrdata *chr) propGetBbox(prop, &radius, &ymax, &ymin); // If dst runs into a wall, set it to closest valid spot - if (!cd0002d7c0(&prop->pos, prop->rooms, &dst, 0x33, 1, - ymax - prop->pos.y, ymin - prop->pos.y)) { + if (cdExamCylMove03(&prop->pos, prop->rooms, &dst, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG, + 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { #if VERSION >= VERSION_JPN_FINAL cdGetPos(&dst, 8796, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL @@ -7495,7 +7500,7 @@ bool chrGoToCoverProp(struct chrdata *chr) if (propheight > chrheight * 0.4f && propheight < chrheight * 0.9f) { propSetPerimEnabled(prop, false); - if (cd0002dc18(&chrprop->pos, chrprop->rooms, &prop->pos, CDTYPE_DOORS | CDTYPE_BG)) { + if (cdTestLos04(&chrprop->pos, chrprop->rooms, &prop->pos, CDTYPE_DOORS | CDTYPE_BG)) { propSetPerimEnabled(prop, true); dstpos.x = prop->pos.x - (targetprop->pos.x - prop->pos.x) / targetdist * (propradius * 1.25f + chrradius); @@ -7554,7 +7559,7 @@ bool chrTryStartAlarm(struct chrdata *chr, s32 pad_id) return false; } -s32 chrConsiderGrenadeThrow(struct chrdata *chr, u32 attackflags, u32 entityid) +bool chrConsiderGrenadeThrow(struct chrdata *chr, u32 attackflags, u32 entityid) { bool done = false; @@ -7571,9 +7576,10 @@ s32 chrConsiderGrenadeThrow(struct chrdata *chr, u32 attackflags, u32 entityid) pos.z = target->pos.z; } - if (target && cd0002dc18(&chr->prop->pos, chr->prop->rooms, &pos, 0x33)) { - struct prop *leftprop = chrGetHeldProp(chr, 1); - struct prop *rightprop = chrGetHeldProp(chr, 0); + if (target && cdTestLos04(&chr->prop->pos, chr->prop->rooms, &pos, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG)) { + struct prop *leftprop = chrGetHeldProp(chr, HAND_LEFT); + struct prop *rightprop = chrGetHeldProp(chr, HAND_RIGHT); struct weaponobj *weapon; #if PIRACYCHECKS @@ -7689,7 +7695,8 @@ void chrPunchInflictDamage(struct chrdata *chr, s32 damage, s32 range, u8 revers if (chrIsTargetInFov(chr, 20, reverse) && chrGetDistanceToTarget(chr) < range - && cd0002dc18(&chr->prop->pos, chr->prop->rooms, &targetprop->pos, 0x33)) { + && cdTestLos04(&chr->prop->pos, chr->prop->rooms, &targetprop->pos, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG)) { vector.x = targetprop->pos.x - chr->prop->pos.x; vector.y = 0; vector.z = targetprop->pos.z - chr->prop->pos.z; @@ -9942,9 +9949,9 @@ void chrTickShoot(struct chrdata *chr, s32 handnum) // How nice of the developers to check for this! chrSetPerimEnabled(chr, false); - if (cd0002de34(&chrprop->pos, chrprop->rooms, &gunpos, gunrooms, + if (cdTestLos10(&chrprop->pos, chrprop->rooms, &gunpos, gunrooms, CDTYPE_DOORS | CDTYPE_CHRS | CDTYPE_BG | CDTYPE_DOORSWITHOUTFLAG | extracdtypes, - 0x10) == CDRESULT_COLLISION) { + GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { firingthisframe = false; } @@ -10010,7 +10017,7 @@ void chrTickShoot(struct chrdata *chr, s32 handnum) g_Vars.useperimshoot = true; } - if (cdTestAToB4(&gunpos, gunrooms, &hitpos, cdtypes, 0x10) == CDRESULT_COLLISION) { + if (cdExamLos08(&gunpos, gunrooms, &hitpos, cdtypes, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { hitsomething = true; #if VERSION >= VERSION_JPN_FINAL cdGetPos(&hitpos, 12080, "chr/chraction.c"); @@ -10021,7 +10028,7 @@ void chrTickShoot(struct chrdata *chr, s32 handnum) #else cdGetPos(&hitpos, 12086, "chraction.c"); #endif - hitprop = cdGetObstacle(); + hitprop = cdGetObstacleProp(); } chrSetPerimEnabled(chr, true); @@ -11809,19 +11816,19 @@ bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 *chrroom sp60.y = aimpos->y; sp60.z = (spd4.z * negchrradius) + (aimpos->z - spc8); - if (cd0002da50(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION - || cd0002d7c0(&sp6c, sp50, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { + if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION + || cdExamCylMove03(&sp6c, sp50, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spbc = true; #if VERSION >= VERSION_JPN_FINAL - cd00024e4c(&spac, &spa0, 14154, "chr/chraction.c"); + cdGetEdge(&spac, &spa0, 14154, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL - cd00024e4c(&spac, &spa0, 14151, "chr/chraction.c"); + cdGetEdge(&spac, &spa0, 14151, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&spac, &spa0, 14146, "chraction.c"); + cdGetEdge(&spac, &spa0, 14146, "chraction.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&spac, &spa0, 14145, "chraction.c"); + cdGetEdge(&spac, &spa0, 14145, "chraction.c"); #else - cd00024e4c(&spac, &spa0, 14158, "chraction.c"); + cdGetEdge(&spac, &spa0, 14158, "chraction.c"); #endif func0f044b68(&spac, &spa0, &spd4); } @@ -11834,19 +11841,19 @@ bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 *chrroom sp60.y = aimpos->y; sp60.z = (spd4.z * negchrradius) + (aimpos->z + spc8); - if (cd0002da50(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION - || cd0002d7c0(&sp6c, chrrooms, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { + if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION + || cdExamCylMove03(&sp6c, chrrooms, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spb8 = true; #if VERSION >= VERSION_JPN_FINAL - cd00024e4c(&sp94, &sp88, 14169, "chr/chraction.c"); + cdGetEdge(&sp94, &sp88, 14169, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp94, &sp88, 14166, "chr/chraction.c"); + cdGetEdge(&sp94, &sp88, 14166, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp94, &sp88, 14161, "chraction.c"); + cdGetEdge(&sp94, &sp88, 14161, "chraction.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp94, &sp88, 14160, "chraction.c"); + cdGetEdge(&sp94, &sp88, 14160, "chraction.c"); #else - cd00024e4c(&sp94, &sp88, 14173, "chraction.c"); + cdGetEdge(&sp94, &sp88, 14173, "chraction.c"); #endif func0f044b68(&sp94, &sp88, &spd4); } @@ -11878,20 +11885,20 @@ bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 *chrroom rightpos->x = sp88.x; rightpos->y = sp88.y; rightpos->z = sp88.z; - } else if (cd0002da50(chrpos, chrrooms, aimpos, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION - && (!arg9 || cd0002a6fc(chrpos, aimpos, chrradius, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION)) { + } else if (cdExamCylMove07(chrpos, chrrooms, aimpos, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION + && (!arg9 || cdExamCylMove01(chrpos, aimpos, chrradius, sp40, cdtypes, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION)) { result = true; } else { #if VERSION >= VERSION_JPN_FINAL - cd00024e4c(leftpos, rightpos, 14239, "chr/chraction.c"); + cdGetEdge(leftpos, rightpos, 14239, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL - cd00024e4c(leftpos, rightpos, 14236, "chr/chraction.c"); + cdGetEdge(leftpos, rightpos, 14236, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(leftpos, rightpos, 14231, "chraction.c"); + cdGetEdge(leftpos, rightpos, 14231, "chraction.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(leftpos, rightpos, 14230, "chraction.c"); + cdGetEdge(leftpos, rightpos, 14230, "chraction.c"); #else - cd00024e4c(leftpos, rightpos, 14243, "chraction.c"); + cdGetEdge(leftpos, rightpos, 14243, "chraction.c"); #endif func0f044b68(leftpos, rightpos, &spd4); } @@ -11968,19 +11975,19 @@ bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s16 *chrr sp60.y = aimpos->y; sp60.z = (spd4.z * negchrradius) + (aimpos->z - spc8); - if (cd0002da50(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION - || cd0002d7c0(&sp6c, sp50, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { + if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION + || cdExamCylMove03(&sp6c, sp50, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spbc = true; #if VERSION >= VERSION_JPN_FINAL - cd00024e4c(&spac, &spa0, 14319, "chr/chraction.c"); + cdGetEdge(&spac, &spa0, 14319, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL - cd00024e4c(&spac, &spa0, 14316, "chr/chraction.c"); + cdGetEdge(&spac, &spa0, 14316, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&spac, &spa0, 14311, "chraction.c"); + cdGetEdge(&spac, &spa0, 14311, "chraction.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&spac, &spa0, 14310, "chraction.c"); + cdGetEdge(&spac, &spa0, 14310, "chraction.c"); #else - cd00024e4c(&spac, &spa0, 14323, "chraction.c"); + cdGetEdge(&spac, &spa0, 14323, "chraction.c"); #endif func0f044b68(&spac, &spa0, &spd4); value1 = cd00024e40(); @@ -11994,19 +12001,19 @@ bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s16 *chrr sp60.y = aimpos->y; sp60.z = (spd4.z * negchrradius) + (aimpos->z + spc8); - if (cd0002da50(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION - || cd0002d7c0(&sp6c, chrrooms, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { + if (cdExamCylMove07(chrpos, chrrooms, &sp6c, sp50, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION + || cdExamCylMove03(&sp6c, chrrooms, &sp60, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) == CDRESULT_COLLISION) { spb8 = true; #if VERSION >= VERSION_JPN_FINAL - cd00024e4c(&sp94, &sp88, 14334, "chr/chraction.c"); + cdGetEdge(&sp94, &sp88, 14334, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp94, &sp88, 14331, "chr/chraction.c"); + cdGetEdge(&sp94, &sp88, 14331, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp94, &sp88, 14326, "chraction.c"); + cdGetEdge(&sp94, &sp88, 14326, "chraction.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp94, &sp88, 14325, "chraction.c"); + cdGetEdge(&sp94, &sp88, 14325, "chraction.c"); #else - cd00024e4c(&sp94, &sp88, 14338, "chraction.c"); + cdGetEdge(&sp94, &sp88, 14338, "chraction.c"); #endif func0f044b68(&sp94, &sp88, &spd4); value2 = cd00024e40(); @@ -12046,20 +12053,20 @@ bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s16 *chrr rightpos->x = sp88.x; rightpos->y = sp88.y; rightpos->z = sp88.z; - } else if (cd0002da50(chrpos, chrrooms, aimpos, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION - && (!hasobstacle || cd0002a6fc(chrpos, aimpos, chrradius, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION)) { + } else if (cdExamCylMove07(chrpos, chrrooms, aimpos, sp40, cdtypes, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION + && (!hasobstacle || cdExamCylMove01(chrpos, aimpos, chrradius, sp40, cdtypes, CHECKVERTICAL_YES, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION)) { result = true; } else { #if VERSION >= VERSION_JPN_FINAL - cd00024e4c(leftpos, rightpos, 14404, "chr/chraction.c"); + cdGetEdge(leftpos, rightpos, 14404, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL - cd00024e4c(leftpos, rightpos, 14401, "chr/chraction.c"); + cdGetEdge(leftpos, rightpos, 14401, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(leftpos, rightpos, 14396, "chraction.c"); + cdGetEdge(leftpos, rightpos, 14396, "chraction.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(leftpos, rightpos, 14395, "chraction.c"); + cdGetEdge(leftpos, rightpos, 14395, "chraction.c"); #else - cd00024e4c(leftpos, rightpos, 14408, "chraction.c"); + cdGetEdge(leftpos, rightpos, 14408, "chraction.c"); #endif func0f044b68(leftpos, rightpos, &spd4); } @@ -12170,12 +12177,14 @@ const char var7f1a8cb4[] = "chrdisttopad : %x -> %d : Dist=%f"; * * The chr must be within 200cm of the door unless it's a laser. */ -struct prop *chrOpenDoor(struct chrdata *chr, struct coord *coord) +struct prop *chrOpenDoor(struct chrdata *chr, struct coord *rangepos) { struct prop *doorprop = NULL; - if (cd0002d7c0(&chr->prop->pos, chr->prop->rooms, coord, 0x5020, 1, 0, 0) == CDRESULT_COLLISION) { - doorprop = cdGetObstacle(); + if (cdExamCylMove03(&chr->prop->pos, chr->prop->rooms, rangepos, + CDTYPE_BG | CDTYPE_CLOSEDDOORS | CDTYPE_AJARDOORS, + 1, 0, 0) == CDRESULT_COLLISION) { + doorprop = cdGetObstacleProp(); } if (doorprop) { @@ -12645,7 +12654,7 @@ bool chrGoPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, b rooms[0] = nextpad.room; - nextground = cd0002a36c(&nextpad.pos, rooms, NULL, NULL); + nextground = cdFindFloorYColourTypeAtPos(&nextpad.pos, rooms, NULL, NULL); // Begin exiting lift if lift is 30cm under destination or higher advance = (lifty >= nextground - 30); @@ -13109,8 +13118,9 @@ bool chrStartSkJump(struct chrdata *chr, u8 arg1, u8 arg2, s32 arg3, u8 arg4) chrGetBbox(prop, &radius, &ymax, &ymin); chrSetPerimEnabled(chr, false); propSetPerimEnabled(target, false); - iVar2 = cd0002d6ac(&prop->pos, prop->rooms, &target->pos, 51, 1, - ymax - prop->pos.y, ymin - prop->pos.y); + iVar2 = cdTestCylMove01(&prop->pos, prop->rooms, &target->pos, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG, + 1, ymax - prop->pos.y, ymin - prop->pos.y); chrSetPerimEnabled(chr, true); propSetPerimEnabled(target, true); @@ -13130,7 +13140,7 @@ bool chrStartSkJump(struct chrdata *chr, u8 arg1, u8 arg2, s32 arg3, u8 arg4) chr->act_skjump.hit = false; chr->act_skjump.timer60 = time60; chr->act_skjump.total60 = time60; - chr->act_skjump.ground = cdFindGroundYSimple(&chr->prop->pos, chr->radius, chr->prop->rooms, NULL, NULL); + chr->act_skjump.ground = cdFindGroundAtCyl(&chr->prop->pos, chr->radius, chr->prop->rooms, NULL, NULL); } else { return false; } @@ -14429,7 +14439,9 @@ bool chrCanSeeTargetWithExtraCheck(struct chrdata *chr) if (target->type == PROPTYPE_PLAYER) { if (g_Vars.bondvisible && - (cdHasLineOfSight(&target->pos, target->rooms, &chr->prop->pos, chr->prop->rooms, 51, 8))) { + (cdTestLos05(&target->pos, target->rooms, &chr->prop->pos, chr->prop->rooms, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG, + GEOFLAG_BLOCK_SIGHT))) { struct model *model = chr->model; struct coord sp68; struct coord sp56; @@ -14854,9 +14866,10 @@ void chrSetPadPresetByChrnum(struct chrdata *basechr, s32 chrnum, s32 pad_id) } /** - * Check if chr has line of sight (I think?) to their target. If so, find a - * route to them, then iterate the route backwards (from target to chr). Find - * the first waypoint with line of sight and store it as the chr's pad preset. + * Check if chr has line of sight to their target. If not, find a route + * to them then iterate the route backwards (from target to chr). + * Find the first waypoint in view of both the chr and their target + * and store it as the chr's pad preset. */ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr) { @@ -14870,7 +14883,7 @@ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr) struct pad pad; if (target->type != PROPTYPE_PLAYER || g_Vars.bondvisible) { - if (cd0002dc18(&prop->pos, prop->rooms, &target->pos, CDTYPE_BG)) { + if (cdTestLos04(&prop->pos, prop->rooms, &target->pos, CDTYPE_BG)) { return false; } @@ -14891,8 +14904,8 @@ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr) padUnpack(wp->padnum, PADFIELD_POS, &pad); - if (cd0002dc18(&target->pos, target->rooms, &pad.pos, CDTYPE_BG)) { - if (cd0002dc18(&prop->pos, prop->rooms, &pad.pos, CDTYPE_BG)) { + if (cdTestLos04(&target->pos, target->rooms, &pad.pos, CDTYPE_BG)) { + if (cdTestLos04(&prop->pos, prop->rooms, &pad.pos, CDTYPE_BG)) { chr->padpreset1 = wp->padnum; return true; } @@ -14970,13 +14983,13 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angl // because if the chr was being spawned on top of another chr or object // then the calculated ground value would be raised. ymin = -200; - ground = cdFindGroundYSimple(pos, chrradius, rooms, NULL, NULL); + ground = cdFindGroundAtCyl(pos, chrradius, rooms, NULL, NULL); if (ground > -100000 && ground - pos->y < -200) { ymin = ground - pos->y; } - if (cdTestVolume(pos, chrradius, rooms, types, 1, ymax, ymin) != CDRESULT_COLLISION + if (cdTestVolume(pos, chrradius, rooms, types, CHECKVERTICAL_YES, ymax, ymin) != CDRESULT_COLLISION && (allowonscreen || chrIsPosOffScreen(pos, rooms))) { return true; } @@ -14988,17 +15001,17 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angl testpos.y = pos->y; testpos.z = pos->z + cosf(curangle) * 60; - if ((arg6 && cd0002d840(pos, rooms, &testpos, testrooms, CDTYPE_ALL & ~CDTYPE_PLAYERS, 1, ymax, -200) != CDRESULT_COLLISION) - || (!arg6 && cd0002deac(pos, rooms, &testpos, testrooms, CDTYPE_BG))) { + if ((arg6 && cdTestCylMove04(pos, rooms, &testpos, testrooms, CDTYPE_ALL & ~CDTYPE_PLAYERS, 1, ymax, -200) != CDRESULT_COLLISION) + || (!arg6 && cdTestLos11(pos, rooms, &testpos, testrooms, CDTYPE_BG))) { chr0f021fa8(NULL, &testpos, testrooms); - ground = cdFindGroundYSimple(&testpos, chrradius, testrooms, 0, 0); + ground = cdFindGroundAtCyl(&testpos, chrradius, testrooms, 0, 0); ymin = -200; if (ground > -100000 && ground - pos->y < -200) { ymin = ground - pos->y; } - if (cdTestVolume(&testpos, chrradius, testrooms, CDTYPE_ALL, 1, ymax, ymin) != CDRESULT_COLLISION + if (cdTestVolume(&testpos, chrradius, testrooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax, ymin) != CDRESULT_COLLISION && (allowonscreen || chrIsPosOffScreen(&testpos, testrooms)) && (!arg6 || ground > -100000)) { pos->x = testpos.x; @@ -15038,7 +15051,7 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angl types = CDTYPE_ALL; } - if (cdTestVolume(pos, chrradius, rooms, types, 1, 200, -200) != CDRESULT_COLLISION + if (cdTestVolume(pos, chrradius, rooms, types, CHECKVERTICAL_YES, 200, -200) != CDRESULT_COLLISION && (allowonscreen || chrIsPosOffScreen(pos, rooms))) { return true; } @@ -15048,8 +15061,8 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angl testpos.y = pos->y; testpos.z = cosf(curangle) * 60 + pos->z; - if (cd0002deac(pos, rooms, &testpos, testrooms, CDTYPE_BG) - && cdTestVolume(&testpos, chrradius, testrooms, CDTYPE_ALL, 1, 200, -200.0f) != CDRESULT_COLLISION + if (cdTestLos11(pos, rooms, &testpos, testrooms, CDTYPE_BG) + && cdTestVolume(&testpos, chrradius, testrooms, CDTYPE_ALL, CHECKVERTICAL_YES, 200, -200.0f) != CDRESULT_COLLISION && (allowonscreen || chrIsPosOffScreen(&testpos, testrooms))) { pos->x = testpos.x; pos->y = testpos.y; @@ -15214,7 +15227,7 @@ struct prop *chrSpawnAtChr(struct chrdata *basechr, s32 body, s32 head, u32 chrn return chrSpawnAtCoord(body, head, &chr->prop->pos, chr->prop->rooms, fvalue, ailist, spawnflags); } -bool func0f04b658(struct chrdata *chr) +bool chrIsPropPresetBlockingSightToTarget(struct chrdata *chr) { bool result = false; struct prop *prop = chr->prop; @@ -15224,11 +15237,12 @@ bool func0f04b658(struct chrdata *chr) chrSetPerimEnabled(chr, false); propSetPerimEnabled(target, false); - if (!cd0002dc18(&prop->pos, prop->rooms, &target->pos, 0x33)) { - struct prop *thing = cdGetObstacle(); + if (!cdTestLos04(&prop->pos, prop->rooms, &target->pos, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG)) { + struct prop *obstacle = cdGetObstacleProp(); - if (thing && thing->type == PROPTYPE_OBJ - && chr->proppreset1 == (s16)(thing - g_Vars.props)) { + if (obstacle && obstacle->type == PROPTYPE_OBJ + && chr->proppreset1 == (s16)(obstacle - g_Vars.props)) { result = true; } } @@ -15268,7 +15282,7 @@ bool chrMoveToPos(struct chrdata *chr, struct coord *pos, s16 *rooms, f32 angle, if (chrAdjustPosForSpawn(chr->radius, &pos2, rooms2, angle, (chr->hidden & CHRHFLAG_00100000) != 0, allowonscreen)) #endif { - ground = cdFindGroundY(&pos2, chr->radius, rooms2, &chr->floorcol, + ground = cdFindGroundInfoAtCyl(&pos2, chr->radius, rooms2, &chr->floorcol, &chr->floortype, NULL, &chr->floorroom, NULL, NULL); chr->ground = ground; @@ -15328,9 +15342,12 @@ bool chrCheckCoverOutOfSight(struct chrdata *chr, s32 covernum, bool soft) } if (soft) { - targetcanseecover = cd0002db98(&target->pos, target->rooms, cover.pos, CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_BG, 8); + targetcanseecover = cdTestLos03(&target->pos, target->rooms, cover.pos, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_BG, + GEOFLAG_BLOCK_SIGHT); } else { - targetcanseecover = cd0002f450(&target->pos, target->rooms, cover.pos, 50, 35); + targetcanseecover = cdIsNearlyInSight(&target->pos, target->rooms, cover.pos, 50.0f, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_BG); } if (!targetcanseecover != false) { @@ -15604,7 +15621,7 @@ s16 chrGoToCover(struct chrdata *chr, u8 speed) return -1; } -bool chrRunFromPos(struct chrdata *chr, u32 speed, f32 rundist, struct coord *frompos) +bool chrRunFromPos(struct chrdata *chr, u32 goposflags, f32 rundist, struct coord *frompos) { f32 curdistfrompos; struct coord delta; @@ -15628,7 +15645,7 @@ bool chrRunFromPos(struct chrdata *chr, u32 speed, f32 rundist, struct coord *fr chrSetPerimEnabled(chr, false); - if (cdTestAToB4(&chr->prop->pos, chr->prop->rooms, &delta, CDTYPE_ALL, 4) == CDRESULT_COLLISION) { + if (cdExamLos08(&chr->prop->pos, chr->prop->rooms, &delta, CDTYPE_ALL, GEOFLAG_WALL) == CDRESULT_COLLISION) { #if VERSION >= VERSION_JPN_FINAL cdGetPos(&delta, 18592, "chr/chraction.c"); #elif VERSION >= VERSION_PAL_FINAL @@ -15646,7 +15663,7 @@ bool chrRunFromPos(struct chrdata *chr, u32 speed, f32 rundist, struct coord *fr func0f065e74(&chr->prop->pos, chr->prop->rooms, &delta, rooms); - return chrGoToRoomPos(chr, &delta, rooms, speed); + return chrGoToRoomPos(chr, &delta, rooms, goposflags); } return false; @@ -15693,14 +15710,14 @@ bool chrIsTargetNearlyInSight(struct chrdata *chr, u32 distance) { struct prop *target = chrGetTargetProp(chr); - return cd0002f450(&chr->prop->pos, chr->prop->rooms, &target->pos, distance, 32); + return cdIsNearlyInSight(&chr->prop->pos, chr->prop->rooms, &target->pos, distance, CDTYPE_BG); } bool chrIsNearlyInTargetsSight(struct chrdata *chr, u32 distance) { struct prop *target = chrGetTargetProp(chr); - return cd0002f450(&target->pos, target->rooms, &chr->prop->pos, distance, 32); + return cdIsNearlyInSight(&target->pos, target->rooms, &chr->prop->pos, distance, CDTYPE_BG); } f32 func0f04c784(struct chrdata *chr) @@ -15772,7 +15789,7 @@ bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3, chrGetBbox(chr->prop, &radius, &ymax, &ymin); - result = cd0002d7c0(&chrpos, chr->prop->rooms, pos, + result = cdExamCylMove03(&chrpos, chr->prop->rooms, pos, CDTYPE_BG | CDTYPE_OBJS | CDTYPE_DOORS, 1, ymax - chrpos.f[1], ymin - chrpos.f[1]); @@ -16166,7 +16183,7 @@ void chrAvoid(struct chrdata *chr) zdiff = dstpos.z - chr->prop->pos.z; if (xdiff > halfchrradius || zdiff > halfchrradius || xdiff < -halfchrradius || zdiff < -halfchrradius) { - cdresult = cd0002d8b8(&chr->prop->pos, chr->prop->rooms, &dstpos, dstrooms, CDTYPE_ALL, true, ymax - chr->prop->pos.y, ymin - chr->prop->pos.y); + cdresult = cdExamCylMove05(&chr->prop->pos, chr->prop->rooms, &dstpos, dstrooms, CDTYPE_ALL, true, ymax - chr->prop->pos.y, ymin - chr->prop->pos.y); } if (cdresult == CDRESULT_ERROR) { diff --git a/src/game/chrai.c b/src/game/chrai.c index 24374163e..0828d1ecf 100644 --- a/src/game/chrai.c +++ b/src/game/chrai.c @@ -269,7 +269,7 @@ bool (*g_CommandPointers[])(void) = { /*0x0100*/ aiNoOp0100, /*0x0101*/ aiNoOp0101, /*0x0102*/ aiSetLights, - /*0x0103*/ ai0103, + /*0x0103*/ aiIfPropPresetIsBlockingSightToTarget, /*0x0104*/ aiRemoveObjectAtPropPreset, /*0x0105*/ aiIfPropPresetHeightLessThan, /*0x0106*/ aiSetTarget, diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index d85587d74..2b39fd0fe 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -5844,9 +5844,9 @@ bool aiSetLights(void) /** * @cmd 0103 */ -bool ai0103(void) +bool aiIfPropPresetIsBlockingSightToTarget(void) { - if (func0f04b658(g_Vars.chrdata)) { + if (chrIsPropPresetBlockingSightToTarget(g_Vars.chrdata)) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); } else { diff --git a/src/game/explosions.c b/src/game/explosions.c index b247d9155..beac97e50 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -91,7 +91,7 @@ bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s1 struct coord sp88; struct explosiontype *etype; bool makescorch = true; - s16 ret; + s16 room; f32 y; bool sp68; @@ -100,12 +100,12 @@ bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s1 } if (prop) { - ret = cd0002a564(&prop->pos, prop->rooms, &y, 0, &sp88, &sp68); + room = cdFindFloorRoomYColourNormalPropAtPos(&prop->pos, prop->rooms, &y, 0, &sp88, &sp68); sp100.x = prop->pos.x; sp100.y = y; sp100.z = prop->pos.z; } else { - ret = cd0002a564(pos, rooms, &y, 0, &sp88, &sp68); + room = cdFindFloorRoomYColourNormalPropAtPos(pos, rooms, &y, 0, &sp88, &sp68); sp100.x = pos->x; sp100.y = y; sp100.z = pos->z; @@ -113,12 +113,12 @@ bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s1 etype = &g_ExplosionTypes[type]; - if (sp68 || ret <= 0 + if (sp68 || room <= 0 || !(pos->y - y <= (etype->rangev + etype->changeratev * etype->duration + etype->innersize) * 0.5f || pos->y - y <= 75)) { makescorch = false; } - return explosionCreate(prop, pos, rooms, type, playernum, makescorch, &sp100, ret, &sp88); + return explosionCreate(prop, pos, rooms, type, playernum, makescorch, &sp100, room, &sp88); } f32 explosionGetHorizontalRangeAtFrame(struct explosion *exp, s32 frame) diff --git a/src/game/lv.c b/src/game/lv.c index 11d442b7a..f87ff8f14 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -76,6 +76,7 @@ #include "game/weather.h" #include "lib/anim.h" #include "lib/args.h" +#include "lib/collision.h" #include "lib/joy.h" #include "lib/lib_06440.h" #include "lib/lib_317f0.h" diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index 0613e8609..31b72100e 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -201,7 +201,7 @@ void kohInitProps(void) g_ScenarioData.koh.hillpos.x = pad.pos.x; g_ScenarioData.koh.hillpos.y = pad.pos.y; g_ScenarioData.koh.hillpos.z = pad.pos.z; - g_ScenarioData.koh.hillpos.y = cd0002a36c(&g_ScenarioData.koh.hillpos, &g_ScenarioData.koh.hillrooms[0], 0, 0); + g_ScenarioData.koh.hillpos.y = cdFindFloorYColourTypeAtPos(&g_ScenarioData.koh.hillpos, &g_ScenarioData.koh.hillrooms[0], 0, 0); g_ScenarioData.koh.movehill = false; roomSetLighting(g_ScenarioData.koh.hillrooms[0], LIGHTOP_5, 0, 0, 0); } @@ -292,7 +292,7 @@ void kohTick(void) g_ScenarioData.koh.hillpos.y = pad.pos.y; g_ScenarioData.koh.hillpos.z = pad.pos.z; - g_ScenarioData.koh.hillpos.y = cd0002a36c(&g_ScenarioData.koh.hillpos, g_ScenarioData.koh.hillrooms, NULL, NULL); + g_ScenarioData.koh.hillpos.y = cdFindFloorYColourTypeAtPos(&g_ScenarioData.koh.hillpos, g_ScenarioData.koh.hillrooms, NULL, NULL); roomSetLighting(g_ScenarioData.koh.hillrooms[0], 5, 0, 0, 0); diff --git a/src/game/padhalllv.c b/src/game/padhalllv.c index 076b8bd3f..8ca4b8871 100644 --- a/src/game/padhalllv.c +++ b/src/game/padhalllv.c @@ -121,14 +121,14 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms) padrooms[0] = pad.room; padrooms[1] = -1; - if (cdHasLineOfSight(pos, rooms, &pad.pos, padrooms, CDTYPE_BG, 3) != CDRESULT_COLLISION) { - s32 cdresult = cd0002d8b8(pos, rooms, &pad.pos, padrooms, CDTYPE_BG | CDTYPE_PATHBLOCKER, true, 0.0f, 0.0f); + if (cdTestLos05(pos, rooms, &pad.pos, padrooms, CDTYPE_BG, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2) != CDRESULT_COLLISION) { + s32 cdresult = cdExamCylMove05(pos, rooms, &pad.pos, padrooms, CDTYPE_BG | CDTYPE_PATHBLOCKER, true, 0.0f, 0.0f); if (cdresult == CDRESULT_ERROR) { checkmore[i] = false; } else if (cdresult == CDRESULT_COLLISION) { checkmore[i] = true; - cd00024e4c(&sp250[i], &sp1d8[i], 441, "padhalllv.c"); + cdGetEdge(&sp250[i], &sp1d8[i], 441, "padhalllv.c"); } else { closest = candwaypoints[i]; break; @@ -171,7 +171,7 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms) tmppos.y = pos->y; tmppos.z = sp250[i].f[2] + sp98.f[2]; - if (cd0002d840(pos, rooms, &tmppos, tmprooms, CDTYPE_BG | CDTYPE_PATHBLOCKER, 1, 0.0f, 0.0f) != CDRESULT_COLLISION) { + if (cdTestCylMove04(pos, rooms, &tmppos, tmprooms, CDTYPE_BG | CDTYPE_PATHBLOCKER, 1, 0.0f, 0.0f) != CDRESULT_COLLISION) { closest = candwaypoints[i]; break; } @@ -180,7 +180,7 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms) tmppos.y = pos->y; tmppos.z = sp1d8[i].z - sp98.z; - if (cd0002d840(pos, rooms, &tmppos, tmprooms, CDTYPE_BG | CDTYPE_PATHBLOCKER, 1, 0.0f, 0.0f) != CDRESULT_COLLISION) { + if (cdTestCylMove04(pos, rooms, &tmppos, tmprooms, CDTYPE_BG | CDTYPE_PATHBLOCKER, 1, 0.0f, 0.0f) != CDRESULT_COLLISION) { closest = candwaypoints[i]; break; } diff --git a/src/game/player.c b/src/game/player.c index 457435047..825f43dd0 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -515,7 +515,7 @@ void playerStartNewLife(void) angle = M_BADTAU - scenarioChooseSpawnLocation(30, &pos, rooms, g_Vars.currentplayer->prop); // var7f1ad534 - groundy = cdFindGroundY(&pos, 30, rooms, + groundy = cdFindGroundInfoAtCyl(&pos, 30, rooms, &g_Vars.currentplayer->floorcol, &g_Vars.currentplayer->floortype, &g_Vars.currentplayer->floorflags, @@ -689,7 +689,7 @@ void playerLoadDefaults(void) g_Vars.currentplayer->bondperimenabled = true; g_Vars.currentplayer->periminfo.header.type = GEOTYPE_CYL; - g_Vars.currentplayer->periminfo.header.flags = GEOFLAG_COLLISIONS | GEOFLAG_OPAQUE; + g_Vars.currentplayer->periminfo.header.flags = GEOFLAG_WALL | GEOFLAG_BLOCK_SHOOT; g_Vars.currentplayer->periminfo.ymax = 0; g_Vars.currentplayer->periminfo.ymin = 0; g_Vars.currentplayer->periminfo.x = 0; @@ -5326,7 +5326,7 @@ void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, str bgFindRoomsByPos(pos, inrooms, aboverooms, 20, &bestroom); if (inrooms[0] != -1) { - tmp = room = cdFindRoom(pos, inrooms); + tmp = room = cdFindFloorRoomAtPos(pos, inrooms); if (room > 0) { playerSetCamPropertiesWithRoom(pos, up, look, tmp); @@ -5334,7 +5334,7 @@ void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, str playerSetCamPropertiesWithRoom(pos, up, look, inrooms[0]); } } else if (aboverooms[0] != -1) { - tmp = room = cdFindRoom(pos, aboverooms); + tmp = room = cdFindFloorRoomAtPos(pos, aboverooms); if (room > 0) { playerSetCamPropertiesWithoutRoom(pos, up, look, tmp); @@ -5467,7 +5467,7 @@ bool playerUpdateGeometry(struct prop *prop, u8 **start, u8 **end) void playerUpdatePerimInfo(void) { g_Vars.currentplayer->periminfo.header.type = GEOTYPE_CYL; - g_Vars.currentplayer->periminfo.header.flags = GEOFLAG_COLLISIONS | GEOFLAG_OPAQUE; + g_Vars.currentplayer->periminfo.header.flags = GEOFLAG_WALL | GEOFLAG_BLOCK_SHOOT; g_Vars.currentplayer->periminfo.ymin = g_Vars.currentplayer->vv_manground; g_Vars.currentplayer->periminfo.ymax = g_Vars.currentplayer->vv_manground + g_Vars.currentplayer->vv_headheight; diff --git a/src/game/playermgr.c b/src/game/playermgr.c index 9d3f7752c..a9af88c2e 100644 --- a/src/game/playermgr.c +++ b/src/game/playermgr.c @@ -238,7 +238,7 @@ void playermgrAllocatePlayer(s32 index) g_Vars.players[index]->bondperimenabled = true; g_Vars.players[index]->periminfo.header.type = GEOTYPE_CYL; - g_Vars.players[index]->periminfo.header.flags = GEOFLAG_COLLISIONS | GEOFLAG_OPAQUE; + g_Vars.players[index]->periminfo.header.flags = GEOFLAG_WALL | GEOFLAG_BLOCK_SHOOT; g_Vars.players[index]->periminfo.ymax = 0; g_Vars.players[index]->periminfo.ymin = 0; g_Vars.players[index]->periminfo.x = 0; diff --git a/src/game/playerreset.c b/src/game/playerreset.c index 07470e57d..8ec70b9db 100644 --- a/src/game/playerreset.c +++ b/src/game/playerreset.c @@ -409,7 +409,7 @@ void playerReset(void) } } - groundy = cdFindGroundY(&pos, 30, rooms, + groundy = cdFindGroundInfoAtCyl(&pos, 30, rooms, &g_Vars.currentplayer->floorcol, &g_Vars.currentplayer->floortype, &g_Vars.currentplayer->floorflags, diff --git a/src/game/prop.c b/src/game/prop.c index 8120e900d..94a22ebed 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -1104,7 +1104,7 @@ void func0f061fa8(struct shotdata *shotdata, struct prop *prop, f32 arg2, s32 hi void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2) { - s32 someval; + s32 cdtypes; struct prop **ptr; struct prop *playerprop; bool skipthething; @@ -1190,13 +1190,13 @@ void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2) if (func0f0679ac(model, &distance, &sp110, spfc, spf4) && sp110 <= 0 && distance >= -rangelimit) { - someval = 0x33; + cdtypes = CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG; if (isglass) { - someval = 0; + cdtypes = 0; } - if (cd0002dc18(&playerprop->pos, playerprop->rooms, &prop->pos, someval)) { + if (cdTestLos04(&playerprop->pos, playerprop->rooms, &prop->pos, cdtypes)) { if (isglass) { struct model *model = obj->model; struct coord spd8; @@ -2351,7 +2351,7 @@ void propsTestForPickup(void) } } -f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f32 *arg4, s32 arg5, bool cangangsta, s32 arg7) +f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f32 *arg4, bool throughobjects, bool cangangsta, s32 arg7) { f32 spa0[2]; struct coord sp94; @@ -2371,7 +2371,7 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3 bool sp4c; f32 sp48; struct prop *playerprop; - s32 lVar3; + s32 ok; if (func && bgun0f0a27c8()) { sp50 = true; @@ -2439,13 +2439,17 @@ f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f3 playerSetPerimEnabled(playerprop, false); - if (arg5) { - lVar3 = cd0002db98(&playerprop->pos, playerprop->rooms, &prop->pos, 0x32, 16); + if (throughobjects) { + ok = cdTestLos03(&playerprop->pos, playerprop->rooms, &prop->pos, + CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG, + GEOFLAG_BLOCK_SHOOT); } else { - lVar3 = cd0002db98(&playerprop->pos, playerprop->rooms, &prop->pos, 0x33, 16); + ok = cdTestLos03(&playerprop->pos, playerprop->rooms, &prop->pos, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG, + GEOFLAG_BLOCK_SHOOT); } - if (lVar3) { + if (ok) { f32 value = spa0[1]; if (value < top) { @@ -2682,7 +2686,7 @@ void autoaimTick(void) || (chr->chrflags & CHRCFLAG_FORCEAUTOAIM) || chr->gunprop) && chrCalculateAutoAim(prop, &sp94, sp8c, sp84)) { - f32 thing = func0f06438c(prop, &sp94, sp8c, sp84, sp78, 0, cangangsta, 0); + f32 thing = func0f06438c(prop, &sp94, sp8c, sp84, sp78, false, cangangsta, 0); if (thing > bestthing) { bestthing = thing; @@ -3110,7 +3114,7 @@ void func0f065e98(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *dstroo } if (ptr) { - s32 room = cdFindRoom(pos2, ptr); + s32 room = cdFindFloorRoomAtPos(pos2, ptr); if (room > 0) { dstrooms[0] = room; diff --git a/src/game/propobj.c b/src/game/propobj.c index 6a315fb69..40738fd68 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -994,7 +994,7 @@ struct defaultobj *objFindByPos(struct coord *pos, s16 *rooms) if (prop->type == PROPTYPE_OBJ && arrayIntersects(prop->rooms, rooms) && propUpdateGeometry(prop, &sp38, &sp34) - && func000266a4(pos->x, pos->z, (struct geo *)sp38)) { + && cd000266a4(pos->x, pos->z, (struct geo *)sp38)) { return prop->obj; } @@ -1764,7 +1764,7 @@ void func0f069850(struct defaultobj *obj, struct coord *pos, f32 rot[3][3], stru if (obj->flags3 & OBJFLAG3_GEOCYL) { cyl->header.type = GEOTYPE_CYL; - cyl->header.flags = GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE; + cyl->header.flags = GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT; if (obj->type == OBJTYPE_HOVERBIKE) { hoverbike = (struct hoverbikeobj *)obj; @@ -1818,7 +1818,7 @@ void func0f069b4c(struct defaultobj *obj) rodata = modelGetPartRodata(obj->model->filedata, MODELPART_0065); if (rodata != NULL) { - u32 flags = GEOFLAG_0001 | GEOFLAG_0002; + u32 flags = GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2; if (obj->type == OBJTYPE_ESCASTEP) { flags |= GEOFLAG_LIFTFLOOR; @@ -1832,7 +1832,7 @@ void func0f069b4c(struct defaultobj *obj) rodata = modelGetPartRodata(obj->model->filedata, MODELPART_0066); if (rodata != NULL) { - func0f070ca0(obj, (struct geotilef *)ptr, GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE, NULL, &rodata->type19); + func0f070ca0(obj, (struct geotilef *)ptr, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT, NULL, &rodata->type19); } } } @@ -2177,9 +2177,9 @@ void func0f06a650(struct defaultobj *obj, struct coord *pos, Mtxf *arg2, s16 *ro bbox = modelFindBboxRodata(obj->model); #if VERSION >= VERSION_NTSC_1_0 - room = cd0002a440(pos, rooms, &sp3c, &obj->floorcol, NULL); + room = cdFindFloorRoomYColourFlagsAtPos(pos, rooms, &sp3c, &obj->floorcol, NULL); #else - room = cd0002a440(pos, rooms, &sp3c, &obj->floorcol); + room = cdFindFloorRoomYColourFlagsAtPos(pos, rooms, &sp3c, &obj->floorcol); #endif if (room > 0) { @@ -2289,9 +2289,9 @@ void func0f06a730(struct defaultobj *obj, struct coord *arg1, Mtxf *mtx, s16 *ro func0f065e74(arg1, rooms, &pos2, rooms2); #if VERSION >= VERSION_NTSC_1_0 - if (cd0002a440(&pos2, rooms2, &y, &obj->floorcol, NULL) > 0) + if (cdFindFloorRoomYColourFlagsAtPos(&pos2, rooms2, &y, &obj->floorcol, NULL) > 0) #else - if (cd0002a440(&pos2, rooms2, &y, &obj->floorcol) > 0) + if (cdFindFloorRoomYColourFlagsAtPos(&pos2, rooms2, &y, &obj->floorcol) > 0) #endif { bool updated; @@ -2557,7 +2557,7 @@ void objFreePermanently(struct defaultobj *obj, bool freeprop) objFree(obj, freeprop, false); } -f32 objGetWidth(struct defaultobj *obj) +f32 objGetRadius(struct defaultobj *obj) { if (obj->type == OBJTYPE_KEY) { return 20; @@ -2598,16 +2598,16 @@ bool func0f06b488(struct prop *prop, struct coord *arg1, struct coord *arg2, str if (!cd0002ded8(arg1, arg2, prop)) { #if VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp3c, &sp30, 2910, "prop/propobj.c"); + cdGetEdge(&sp3c, &sp30, 2910, "prop/propobj.c"); cdGetPos(&sp20, 2911, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp3c, &sp30, 2910, "propobj.c"); + cdGetEdge(&sp3c, &sp30, 2910, "propobj.c"); cdGetPos(&sp20, 2911, "propobj.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp3c, &sp30, 2909, "propobj.c"); + cdGetEdge(&sp3c, &sp30, 2909, "propobj.c"); cdGetPos(&sp20, 2910, "propobj.c"); #else - cd00024e4c(&sp3c, &sp30, 2898, "propobj.c"); + cdGetEdge(&sp3c, &sp30, 2898, "propobj.c"); cdGetPos(&sp20, 2899, "propobj.c"); #endif @@ -3287,7 +3287,7 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, spa0[0] = spcc[i]; spa0[1] = -1; - if (cd0002de10(&prop->pos, spa0, &sp1c4, CDTYPE_BG) == CDRESULT_COLLISION) { + if (cdExamLos09(&prop->pos, spa0, &sp1c4, CDTYPE_BG) == CDRESULT_COLLISION) { s0 = true; #if VERSION >= VERSION_PAL_FINAL cdGetPos(&hitthing.unk00, 4258, "prop/propobj.c"); @@ -3298,7 +3298,7 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, #else cdGetPos(&hitthing.unk00, 4246, "propobj.c"); #endif - cd00024ee8(&hitthing.unk0c); + cdGetObstacleNormal(&hitthing.unk0c); } } @@ -3368,7 +3368,7 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coord *arg2, struct coord *arg3) { struct prop *prop = obj->prop; - f32 width = objGetWidth(obj); + f32 radius = objGetRadius(obj); bool result = true; bool sp98 = false; struct coord sp8c; @@ -3388,10 +3388,10 @@ bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 if (prop->pos.x != arg1->x || prop->pos.y != arg1->y || prop->pos.z != arg1->z) { if (obj->hidden & OBJHFLAG_PROJECTILE) { - if (cd0002dac8(&prop->pos, prop->rooms, &sp80, rooms, width, CDTYPE_ALL, false, 0.0f, 0.0f) != CDRESULT_COLLISION) { + if (cdExamCylMove08(&prop->pos, prop->rooms, &sp80, rooms, radius, CDTYPE_ALL, false, 0.0f, 0.0f) != CDRESULT_COLLISION) { setup0f09233c(obj, &sp80, obj->realrot, rooms); - if (cdTestAToB1(&prop->pos, &sp80, width, rooms, CDTYPE_ALL, false, 0.0f, 0.0f) != CDRESULT_COLLISION) { + if (cdExamCylMove02(&prop->pos, &sp80, radius, rooms, CDTYPE_ALL, false, 0.0f, 0.0f) != CDRESULT_COLLISION) { prop->pos.x = sp80.x; prop->pos.y = sp80.y; prop->pos.z = sp80.z; @@ -3407,13 +3407,13 @@ bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 if (!result) { #if VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp64, &sp58, 4386, "prop/propobj.c"); + cdGetEdge(&sp64, &sp58, 4386, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp64, &sp58, 4386, "propobj.c"); + cdGetEdge(&sp64, &sp58, 4386, "propobj.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp64, &sp58, 4385, "propobj.c"); + cdGetEdge(&sp64, &sp58, 4385, "propobj.c"); #else - cd00024e4c(&sp64, &sp58, 4374, "propobj.c"); + cdGetEdge(&sp64, &sp58, 4374, "propobj.c"); #endif arg3->x = sp58.z - sp64.z; @@ -3481,10 +3481,10 @@ bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 sp4c.y = sp80.y; sp4c.z = sp8c.z * f2 + prop->pos.z; - if (cd0002da50(&prop->pos, prop->rooms, &sp4c, rooms, CDTYPE_ALL, false, 0.0f, 0.0f) != CDRESULT_COLLISION) { + if (cdExamCylMove07(&prop->pos, prop->rooms, &sp4c, rooms, CDTYPE_ALL, false, 0.0f, 0.0f) != CDRESULT_COLLISION) { setup0f09233c(obj, &sp4c, obj->realrot, rooms); - if (cdTestVolume(&sp4c, width, rooms, CDTYPE_ALL, false, 0.0f, 0.0f) != CDRESULT_COLLISION) { + if (cdTestVolume(&sp4c, radius, rooms, CDTYPE_ALL, CHECKVERTICAL_NO, 0.0f, 0.0f) != CDRESULT_COLLISION) { prop->pos.x = sp4c.x; prop->pos.y = sp4c.y; prop->pos.z = sp4c.z; @@ -5785,7 +5785,7 @@ f32 liftGetY(struct liftobj *lift) struct geotilef *tile = lift->base.geotilef; if (tile && tile->header.type == GEOTYPE_TILE_F) { - if (tile->header.flags & GEOFLAG_0001) { + if (tile->header.flags & GEOFLAG_FLOOR1) { y = tile->vertices[tile->max[1]].y; } } @@ -5843,9 +5843,9 @@ void liftUpdateTiles(struct liftobj *lift, bool stationary) do { if (i == 0) { #if VERSION >= VERSION_NTSC_1_0 - flags = GEOFLAG_0001 | GEOFLAG_0002 | GEOFLAG_0008 | GEOFLAG_OPAQUE | GEOFLAG_LIFTFLOOR; + flags = GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT | GEOFLAG_LIFTFLOOR; #else - flags = GEOFLAG_0001 | GEOFLAG_0002 | GEOFLAG_LIFTFLOOR; + flags = GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_LIFTFLOOR; #endif // Look for a non-rectangular floor with fallback to rectangular @@ -5861,13 +5861,13 @@ void liftUpdateTiles(struct liftobj *lift, bool stationary) } } } else if (i == 1) { - flags = GEOFLAG_COLLISIONS; + flags = GEOFLAG_WALL; rodata = modelGetPartRodata(lift->base.model->filedata, MODELPART_LIFT_WALL1); } else if (i == 2) { - flags = GEOFLAG_COLLISIONS; + flags = GEOFLAG_WALL; rodata = modelGetPartRodata(lift->base.model->filedata, MODELPART_LIFT_WALL2); } else if (i == 3) { - flags = GEOFLAG_COLLISIONS; + flags = GEOFLAG_WALL; rodata = modelGetPartRodata(lift->base.model->filedata, MODELPART_LIFT_WALL3); } else if (i == 4) { // The doorblock model part exists in the dataDyne tower lifts. @@ -5875,14 +5875,14 @@ void liftUpdateTiles(struct liftobj *lift, bool stationary) // is moving. Without it, the player could exit the lift through // the doorway while it's moving. if (!stationary) { - flags = GEOFLAG_COLLISIONS; + flags = GEOFLAG_WALL; rodata = modelGetPartRodata(lift->base.model->filedata, MODELPART_LIFT_DOORBLOCK); } } else if (i == 5) { #if VERSION >= VERSION_NTSC_1_0 - flags = GEOFLAG_0001 | GEOFLAG_0002 | GEOFLAG_0008 | GEOFLAG_OPAQUE | GEOFLAG_LIFTFLOOR; + flags = GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT | GEOFLAG_LIFTFLOOR; #else - flags = GEOFLAG_0001 | GEOFLAG_0002 | GEOFLAG_LIFTFLOOR; + flags = GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_LIFTFLOOR; #endif rodata = modelGetPartRodata(lift->base.model->filedata, MODELPART_LIFT_FLOORNONRECT2); } else { @@ -6004,7 +6004,7 @@ void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, roomsCopy(rooms, testrooms); setup0f09233c(obj, &testpos, matrix, testrooms); - ground = cdFindGroundYSimple(pos, 5, testrooms, &obj->floorcol, NULL); + ground = cdFindGroundAtCyl(pos, 5, testrooms, &obj->floorcol, NULL); if (ground < -30000) { ground = hov->ground; @@ -6089,11 +6089,11 @@ void hovTick(struct defaultobj *obj, struct hov *hov) func0f065e74(&prop->pos, prop->rooms, &sp1b4, sp198); roomsAppend(sp9c, sp198, ARRAYCOUNT(sp198)); - ground1 = cdFindGroundYSimple(&sp1b4, 5, sp198, &obj->floorcol, NULL); + ground1 = cdFindGroundAtCyl(&sp1b4, 5, sp198, &obj->floorcol, NULL); func0f065e74(&prop->pos, prop->rooms, &sp1a8, sp188); roomsAppend(sp9c, sp188, ARRAYCOUNT(sp188)); - ground2 = cdFindGroundYSimple(&sp1a8, 5, sp188, NULL, NULL); + ground2 = cdFindGroundAtCyl(&sp1a8, 5, sp188, NULL, NULL); if (ground1 >= -30000.0f && ground2 >= -30000.0f) { spb4 = atan2f(ground1 - ground2, sp1cc - sp1d0); @@ -6388,12 +6388,12 @@ s32 func0f072144(struct defaultobj *obj, struct coord *arg1, f32 arg2, bool arg3 pos.y += hov->ground - prevhov.ground; } - cdresult = cd0002d8b8(&prop->pos, prop->rooms, &pos, rooms, CDTYPE_ALL, true, 0.0f, 0.0f); + cdresult = cdExamCylMove05(&prop->pos, prop->rooms, &pos, rooms, CDTYPE_ALL, true, 0.0f, 0.0f); if (cdresult == CDRESULT_ERROR) { // empty } else if (cdresult == CDRESULT_COLLISION) { - cd00025314(&prop->pos, &pos); + cdSetSavedPos(&prop->pos, &pos); } } else { roomsCopy(prop->rooms, rooms); @@ -6404,7 +6404,7 @@ s32 func0f072144(struct defaultobj *obj, struct coord *arg1, f32 arg2, bool arg3 func0f069850(obj, &pos, sp460, &cyl); if (obj->flags3 & OBJFLAG3_GEOCYL) { - cdresult = cd0002a6fc(&prop->pos, &pos, cyl.radius, rooms, CDTYPE_ALL, true, cyl.ymax - pos.y, cyl.ymin - pos.y); + cdresult = cdExamCylMove01(&prop->pos, &pos, cyl.radius, rooms, CDTYPE_ALL, CHECKVERTICAL_YES, cyl.ymax - pos.y, cyl.ymin - pos.y); } else { cdresult = cd0002f02c((struct geoblock *)&cyl, rooms, CDTYPE_ALL); } @@ -6513,7 +6513,7 @@ void hovercarIncrementStep(struct hovercarobj *hovercar) f32 objCollide(struct defaultobj *movingobj, struct coord *movingvel, f32 rotation) { f32 force = 1.0f; - struct prop *obstacle = cdGetObstacle(); + struct prop *obstacle = cdGetObstacleProp(); if (obstacle && g_Vars.lvupdate240 > 0) { if (obstacle->type == PROPTYPE_CHR || obstacle->type == PROPTYPE_PLAYER) { @@ -6538,16 +6538,16 @@ f32 objCollide(struct defaultobj *movingobj, struct coord *movingvel, f32 rotati objApplyMomentum(obstacleobj, &obstaclevel, 0.0f, true, true); #if VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp70, &sp64, 7356, "prop/propobj.c"); + cdGetEdge(&sp70, &sp64, 7356, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp70, &sp64, 7356, "propobj.c"); + cdGetEdge(&sp70, &sp64, 7356, "propobj.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp70, &sp64, 7355, "propobj.c"); + cdGetEdge(&sp70, &sp64, 7355, "propobj.c"); #else - cd00024e4c(&sp70, &sp64, 7308, "propobj.c"); + cdGetEdge(&sp70, &sp64, 7308, "propobj.c"); #endif - if (cd00025364(&sp58, &sp4c)) { + if (cdGetSavedPos(&sp58, &sp4c)) { sp4c.x -= sp58.x; sp4c.y -= sp58.y; sp4c.z -= sp58.z; @@ -8018,7 +8018,7 @@ void platformDisplaceProps2(struct prop *platform, Mtxf *arg1) if (prop->pos.y > platform->pos.y && (obj->hidden & OBJHFLAG_00008000) - && func000266a4(prop->pos.x, prop->pos.z, (struct geo *)sp9c)) { + && cd000266a4(prop->pos.x, prop->pos.z, (struct geo *)sp9c)) { mtx3ToMtx4(obj->realrot, &sp58); mtx4SetTranslation(&prop->pos, &sp58); mtx4MultMtx4InPlace(arg1, &sp58); @@ -8192,7 +8192,9 @@ bool rocketTickFbw(struct weaponobj *rocket) // Check if rocket can fly directly to target if (chrGetTargetProp(ownerchr) == chr->prop && mpPlayerGetIndex(ownerchr) == g_Vars.lvframenum % g_MpNumChrs - && cdHasLineOfSight(&rocketprop->pos, rocketprop->rooms, &chr->prop->pos, chr->prop->rooms, CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, 8)) { + && cdTestLos05(&rocketprop->pos, rocketprop->rooms, &chr->prop->pos, chr->prop->rooms, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, + GEOFLAG_BLOCK_SIGHT)) { projectile->nextsteppos.x = chr->prop->pos.x; projectile->nextsteppos.y = chr->prop->pos.y; projectile->nextsteppos.z = chr->prop->pos.z; @@ -8486,19 +8488,19 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) struct coord sp3ac; f32 f0_2; - if (cd00025364(&sp3d0, &sp3c4)) { + if (cdGetSavedPos(&sp3d0, &sp3c4)) { sp3c4.x -= sp3d0.x; sp3c4.y -= sp3d0.y; sp3c4.z -= sp3d0.z; } else { #if VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp3d0, &sp3c4, 8360, "prop/propobj.c"); + cdGetEdge(&sp3d0, &sp3c4, 8360, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp3d0, &sp3c4, 8360, "propobj.c"); + cdGetEdge(&sp3d0, &sp3c4, 8360, "propobj.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp3d0, &sp3c4, 8339, "propobj.c"); + cdGetEdge(&sp3d0, &sp3c4, 8339, "propobj.c"); #else - cd00024e4c(&sp3d0, &sp3c4, 8289, "propobj.c"); + cdGetEdge(&sp3d0, &sp3c4, 8289, "propobj.c"); #endif sp3d0.x -= sp3c4.x; @@ -8534,13 +8536,13 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) projectile->unk0dc += f0; #if VERSION >= VERSION_PAL_FINAL - cd00024e4c(&sp3e8, &sp3dc, 8398, "prop/propobj.c"); + cdGetEdge(&sp3e8, &sp3dc, 8398, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA - cd00024e4c(&sp3e8, &sp3dc, 8398, "propobj.c"); + cdGetEdge(&sp3e8, &sp3dc, 8398, "propobj.c"); #elif VERSION >= VERSION_NTSC_1_0 - cd00024e4c(&sp3e8, &sp3dc, 8377, "propobj.c"); + cdGetEdge(&sp3e8, &sp3dc, 8377, "propobj.c"); #else - cd00024e4c(&sp3e8, &sp3dc, 8327, "propobj.c"); + cdGetEdge(&sp3e8, &sp3dc, 8327, "propobj.c"); #endif sp3f4.x = sp3dc.z - sp3e8.z; @@ -8700,7 +8702,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) } if (cdresult == CDRESULT_NOCOLLISION) { - ground = cdFindGroundYSimple(&prop->pos, 2, prop->rooms, &obj->floorcol, NULL); + ground = cdFindGroundAtCyl(&prop->pos, 2, prop->rooms, &obj->floorcol, NULL); if (ground > -30000.0f) { prop->pos.y = ground + objGetHov04(obj); @@ -9244,12 +9246,16 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) sp5ac.y = prop->pos.y + sp37c; sp5ac.z = prop->pos.z; - roomnum = cd0002a5e4(&sp5ac, prop->rooms, &sp390, &obj->floorcol, &geoflags, &sp380); + roomnum = cdFindCeilingRoomYColourFlagsNormalAtPos(&sp5ac, prop->rooms, &sp390, &obj->floorcol, &geoflags, &sp380); #if VERSION >= VERSION_NTSC_1_0 - if (roomnum > 0 && prop->pos.y + sp37c < sp390 && !cd0002db98(&sp5c8, sp5b8, &sp5ac, CDTYPE_OBJS | CDTYPE_BG, 3)) + if (roomnum > 0 + && prop->pos.y + sp37c < sp390 + && !cdTestLos03(&sp5c8, sp5b8, &sp5ac, CDTYPE_OBJS | CDTYPE_BG, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2)) #else - if (roomnum > 0 && prop->pos.y + sp37c < sp390 && !cd0002db98(&sp5c8, sp5b8, &sp5ac, CDTYPE_BG, 3)) + if (roomnum > 0 + && prop->pos.y + sp37c < sp390 + && !cdTestLos03(&sp5c8, sp5b8, &sp5ac, CDTYPE_BG, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2)) #endif { sp354 = true; @@ -9269,14 +9275,14 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) obj->hidden |= OBJHFLAG_REAPABLE; } } else { - roomnum = cd0002a564(&prop->pos, prop->rooms, &sp390, &obj->floorcol, &sp380, NULL); + roomnum = cdFindFloorRoomYColourNormalPropAtPos(&prop->pos, prop->rooms, &sp390, &obj->floorcol, &sp380, NULL); #if VERSION >= VERSION_NTSC_1_0 if (roomnum <= 0 && (projectile->flags & PROJECTILEFLAG_STICKY) == 0) { if ((projectile->flags & PROJECTILEFLAG_00010000) == 0) { projectile->flags |= PROJECTILEFLAG_00010000; - if (cdFindRoom(&sp5c8, sp5b8) > 0) { + if (cdFindFloorRoomAtPos(&sp5c8, sp5b8) > 0) { projectile->flags |= PROJECTILEFLAG_INROOM; } } @@ -9289,7 +9295,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) propDeregisterRooms(prop); roomsCopy(sp5b8, prop->rooms); - roomnum = cd0002a440(&prop->pos, prop->rooms, &sp390, &obj->floorcol, NULL); + roomnum = cdFindFloorRoomYColourFlagsAtPos(&prop->pos, prop->rooms, &sp390, &obj->floorcol, NULL); projectile->speed.x = 0.0f; projectile->speed.z = 0.0f; @@ -9546,16 +9552,16 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) sp5ac.z = prop->pos.z; #if VERSION >= VERSION_NTSC_1_0 - roomnum = cd0002a4d0(&sp5ac, prop->rooms, &spa4, &obj->floorcol, &geoflags); + roomnum = cdFindCeilingRoomYColourFlagsAtPos(&sp5ac, prop->rooms, &spa4, &obj->floorcol, &geoflags); - if (roomnum <= 0 || cd0002db98(&sp5c8, sp5b8, &sp5ac, CDTYPE_OBJS | CDTYPE_BG, 3)) { - roomnum = cd0002a440(&prop->pos, prop->rooms, &spa4, &obj->floorcol, &geoflags); + if (roomnum <= 0 || cdTestLos03(&sp5c8, sp5b8, &sp5ac, CDTYPE_OBJS | CDTYPE_BG, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2)) { + roomnum = cdFindFloorRoomYColourFlagsAtPos(&prop->pos, prop->rooms, &spa4, &obj->floorcol, &geoflags); } #else - roomnum = cd0002a4d0(&sp5ac, prop->rooms, &spa4, &obj->floorcol); + roomnum = cdFindCeilingRoomYColourFlagsAtPos(&sp5ac, prop->rooms, &spa4, &obj->floorcol); - if (roomnum <= 0 || cd0002db98(&sp5c8, sp5b8, &sp5ac, CDTYPE_BG, 3)) { - roomnum = cd0002a440(&prop->pos, prop->rooms, &spa4, &obj->floorcol); + if (roomnum <= 0 || cdTestLos03(&sp5c8, sp5b8, &sp5ac, CDTYPE_BG, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2)) { + roomnum = cdFindFloorRoomYColourFlagsAtPos(&prop->pos, prop->rooms, &spa4, &obj->floorcol); } #endif @@ -9567,9 +9573,9 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) roomsCopy(sp5b8, prop->rooms); #if VERSION >= VERSION_NTSC_1_0 - roomnum = cd0002a440(&prop->pos, prop->rooms, &spa4, &obj->floorcol, &geoflags); + roomnum = cdFindFloorRoomYColourFlagsAtPos(&prop->pos, prop->rooms, &spa4, &obj->floorcol, &geoflags); #else - roomnum = cd0002a440(&prop->pos, prop->rooms, &spa4, &obj->floorcol); + roomnum = cdFindFloorRoomYColourFlagsAtPos(&prop->pos, prop->rooms, &spa4, &obj->floorcol); #endif projectile->speed.x = 0.0f; @@ -10208,7 +10214,7 @@ void escastepTick(struct prop *prop) prop->pos.z = newpos.z; if ((obj->flags & OBJFLAG_IGNOREFLOORCOLOUR) == 0) { - cd0002a36c(&prop->pos, prop->rooms, &obj->floorcol, 0); + cdFindFloorYColourTypeAtPos(&prop->pos, prop->rooms, &obj->floorcol, 0); } func0f069c70(obj, true, true); @@ -10326,7 +10332,9 @@ void cctvTick(struct prop *camprop) if (canseeplayer) { playerSetPerimEnabled(playerprop, false); - if (!cdHasLineOfSight(&camprop->pos, camprop->rooms, &playerprop->pos, playerprop->rooms, 315, 8)) { + if (!cdTestLos05(&camprop->pos, camprop->rooms, &playerprop->pos, playerprop->rooms, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_CHRS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, + GEOFLAG_BLOCK_SIGHT)) { canseeplayer = false; } @@ -10815,7 +10823,7 @@ void autogunTick(struct prop *prop) if (relangleh <= autogun->ymaxleft && relangleh >= autogun->ymaxright && track - && cdHasLineOfSight(&prop->pos, prop->rooms, &target->pos, target->rooms, CDTYPE_ALL, 8)) { + && cdTestLos05(&prop->pos, prop->rooms, &target->pos, target->rooms, CDTYPE_ALL, GEOFLAG_BLOCK_SIGHT)) { // Target is in sight obj->flags |= OBJFLAG_AUTOGUN_SEENTARGET; insight = true; @@ -11114,7 +11122,7 @@ void autogunTickShoot(struct prop *autogunprop) mtx00015be4(camGetProjectionMtxF(), sp108, &spc8); mtx4TransformVecInPlace(&spc8, &gunpos); - if (cd0002de34(&autogunprop->pos, autogunprop->rooms, &gunpos, gunrooms, CDTYPE_BG, 0x10) == CDRESULT_COLLISION) { + if (cdTestLos10(&autogunprop->pos, autogunprop->rooms, &gunpos, gunrooms, CDTYPE_BG, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { gunpos.x = autogunprop->pos.x; gunpos.y = autogunprop->pos.y; gunpos.z = autogunprop->pos.z; @@ -11142,7 +11150,7 @@ void autogunTickShoot(struct prop *autogunprop) if (g_Vars.normmplayerisrunning || (targetprop && (targetprop->type == PROPTYPE_CHR)) || (g_Vars.antiplayernum >= 0 && targetprop && targetprop == g_Vars.anti->prop)) { - if (cdTestAToB4(&gunpos, gunrooms, &hitpos, CDTYPE_ALL, 0x10) == CDRESULT_COLLISION) { + if (cdExamLos08(&gunpos, gunrooms, &hitpos, CDTYPE_ALL, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { #if VERSION >= VERSION_PAL_FINAL cdGetPos(&hitpos, 11480, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA @@ -11153,7 +11161,7 @@ void autogunTickShoot(struct prop *autogunprop) cdGetPos(&hitpos, 11296, "propobj.c"); #endif - hitprop = cdGetObstacle(); + hitprop = cdGetObstacleProp(); // SP: If the hit prop is a chr and it's our target // MP: If the hit prop is a chr @@ -11197,7 +11205,9 @@ void autogunTickShoot(struct prop *autogunprop) // Laptop in firing range struct prop *hitprop = NULL; - if (cdTestAToB4(&gunpos, gunrooms, &hitpos, CDTYPE_ALL & ~CDTYPE_PLAYERS, 0x10) == CDRESULT_COLLISION) { + if (cdExamLos08(&gunpos, gunrooms, &hitpos, + CDTYPE_ALL & ~CDTYPE_PLAYERS, + GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { #if VERSION >= VERSION_PAL_FINAL cdGetPos(&hitpos, 11535, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA @@ -11208,7 +11218,7 @@ void autogunTickShoot(struct prop *autogunprop) cdGetPos(&hitpos, 11351, "propobj.c"); #endif - hitprop = cdGetObstacle(); + hitprop = cdGetObstacleProp(); missed = true; } @@ -11233,7 +11243,9 @@ void autogunTickShoot(struct prop *autogunprop) } } else { // Enemy autogun in solo - if (cdTestAToB4(&gunpos, gunrooms, &hitpos, CDTYPE_DOORS | CDTYPE_BG, 0x10) == CDRESULT_COLLISION) { + if (cdExamLos08(&gunpos, gunrooms, &hitpos, + CDTYPE_DOORS | CDTYPE_BG, + GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { #if VERSION >= VERSION_PAL_FINAL cdGetPos(&hitpos, 11561, "prop/propobj.c"); #elif VERSION >= VERSION_PAL_BETA @@ -11511,7 +11523,9 @@ bool chopperCheckTargetInSight(struct chopperobj *obj) struct prop *target = chopperGetTargetProp(chopper); if (target->type != PROPTYPE_PLAYER || g_Vars.bondvisible) { - visible = cdHasLineOfSight(&target->pos, target->rooms, &chopper->base.prop->pos, chopper->base.prop->rooms, 307, 16); + visible = cdTestLos05(&target->pos, target->rooms, &chopper->base.prop->pos, chopper->base.prop->rooms, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, + GEOFLAG_BLOCK_SHOOT); } chopper->targetvisible = visible; @@ -12106,7 +12120,7 @@ void chopperTickFall(struct prop *chopperprop) newpos.y = chopperprop->pos.y + newspeed.f[1] * g_Vars.lvupdate240freal; newpos.z = chopperprop->pos.z + newspeed.f[2] * g_Vars.lvupdate240freal; - if (cd0002de10(&chopperprop->pos, chopperprop->rooms, &newpos, CDTYPE_BG) == CDRESULT_COLLISION) { + if (cdExamLos09(&chopperprop->pos, chopperprop->rooms, &newpos, CDTYPE_BG) == CDRESULT_COLLISION) { struct coord sp74; s16 room; struct coord sp64; @@ -12114,7 +12128,7 @@ void chopperTickFall(struct prop *chopperprop) s16 newrooms[8]; chopperprop->pos.y += 100; - ground = cdFindGroundYSimple(&chopperprop->pos, 5, chopperprop->rooms, NULL, NULL); + ground = cdFindGroundAtCyl(&chopperprop->pos, 5, chopperprop->rooms, NULL, NULL); chopperprop->pos.y -= 100; #if VERSION >= VERSION_PAL_FINAL @@ -12353,7 +12367,7 @@ void chopperTickCombat(struct prop *chopperprop) goalpos.y = sp6c.y; goalpos.z = sp6c.z; } - } else if (cd0002db98(&targetprop->pos, targetprop->rooms, &goalpos, CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, 0x10) == 0) { + } else if (cdTestLos03(&targetprop->pos, targetprop->rooms, &goalpos, CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_PATHBLOCKER | CDTYPE_BG | CDTYPE_AIOPAQUE, GEOFLAG_BLOCK_SHOOT) == 0) { padUnpack(chopper->path->pads[chopper->cw ? (sp8c + 1) % chopper->path->len : sp8c], PADFIELD_POS, &pad); pad.pos.y += -250.0f; @@ -12523,7 +12537,7 @@ void hovercarTick(struct prop *prop) sp210[0] = pad.room; sp210[1] = -1; - sp214.y = cdFindGroundYSimple(&pad.pos, 5, sp210, NULL, NULL) + 35; + sp214.y = cdFindGroundAtCyl(&pad.pos, 5, sp210, NULL, NULL) + 35; } else { sp214.y = pad.pos.y; } @@ -12552,8 +12566,9 @@ void hovercarTick(struct prop *prop) } if (active) { - if (cd0002d7c0(&prop->pos, prop->rooms, &sp214, 0x5000, 0, 0, 0) == 0) { - doorprop = cdGetObstacle(); + if (cdExamCylMove03(&prop->pos, prop->rooms, &sp214, + CDTYPE_CLOSEDDOORS | CDTYPE_AJARDOORS, 0, 0, 0) == CDRESULT_COLLISION) { + doorprop = cdGetObstacleProp(); } if (doorprop) { @@ -12687,7 +12702,7 @@ void hovercarTick(struct prop *prop) func0f065e74(&prop->pos, prop->rooms, &sp150, sp140); if (active) { - sp150.y = cdFindGroundYSimple(&sp150, 5, sp140, NULL, NULL) + 35; + sp150.y = cdFindGroundAtCyl(&sp150, 5, sp140, NULL, NULL) + 35; #if VERSION >= VERSION_NTSC_1_0 if (sp150.y < -100000) { @@ -13136,7 +13151,7 @@ s32 objTickPlayer(struct prop *prop) } if ((obj->flags & OBJFLAG_IGNOREFLOORCOLOUR) == 0) { - cd0002a36c(&prop->pos, prop->rooms, &obj->floorcol, 0); + cdFindFloorYColourTypeAtPos(&prop->pos, prop->rooms, &obj->floorcol, 0); } func0f069c70(obj, true, true); @@ -13229,7 +13244,7 @@ s32 objTickPlayer(struct prop *prop) roomsCopy(sp220, prop->rooms); if (sp148 <= sp144) { - prop->pos.y = cdFindGroundYSimple(&prop->pos, 5, prop->rooms, &obj->floorcol, NULL) + prop->pos.y = cdFindGroundAtCyl(&prop->pos, 5, prop->rooms, &obj->floorcol, NULL) + func0f06a620(obj) + sp112; } @@ -13238,7 +13253,7 @@ s32 objTickPlayer(struct prop *prop) if (objUpdateGeometry(prop, (u8 **)geos, &end) && geos[0]->type == GEOTYPE_BLOCK - && cd0002e4c4((struct geoblock *) geos[0], prop->rooms, 4) == 0) { + && cdTestBlockOverlapsAnyProp((struct geoblock *) geos[0], prop->rooms, CDTYPE_PLAYERS) == CDRESULT_COLLISION) { damage = ((obj->maxdamage - obj->damage) + 1) / 250.0f; obj->flags &= ~OBJFLAG_INVINCIBLE; objDamage(obj, damage, &prop->pos, WEAPON_REMOTEMINE, -1); @@ -15567,15 +15582,15 @@ Gfx *objRenderShadow(struct defaultobj *obj, Gfx *gdl) f32 y; #if VERSION >= VERSION_NTSC_1_0 - s32 value = cd0002a440(&obj->prop->pos, obj->prop->rooms, &y, NULL, NULL); + s32 room = cdFindFloorRoomYColourFlagsAtPos(&obj->prop->pos, obj->prop->rooms, &y, NULL, NULL); #else - s32 value = cd0002a440(&obj->prop->pos, obj->prop->rooms, &y, NULL); + s32 room = cdFindFloorRoomYColourFlagsAtPos(&obj->prop->pos, obj->prop->rooms, &y, NULL); #endif - if (value > 0 && (obj->modelnum == MODEL_HOOVERBOT || obj->modelnum == MODEL_TESTERBOT)) { + if (room > 0 && (obj->modelnum == MODEL_HOOVERBOT || obj->modelnum == MODEL_TESTERBOT)) { angle = hoverpropGetTurnAngle(obj); gdl = gfxRenderRadialShadow(gdl, obj->prop->pos.x, y, obj->prop->pos.z, angle, 20, 0xffffff78); - } else if (value > 0) { + } else if (room > 0) { angle = hoverpropGetTurnAngle(obj); gdl = gfxRenderRadialShadow(gdl, obj->prop->pos.x, y, obj->prop->pos.z, angle, 30, 0xffffff78); } @@ -16573,9 +16588,10 @@ bool objDrop(struct prop *prop, bool lazy) spe4.y = spf0.m[3][1]; spe4.z = spf0.m[3][2]; - if (cd0002de34(&root->pos, root->rooms, &spe4, rooms, CDTYPE_ALL, 7) == CDRESULT_COLLISION + if (cdTestLos10(&root->pos, root->rooms, &spe4, rooms, CDTYPE_ALL, + GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2 | GEOFLAG_WALL) == CDRESULT_COLLISION || (projectile->flags & PROJECTILEFLAG_STICKY) == 0) { - if (cdTestVolume(&spe4, objGetWidth(obj), rooms, CDTYPE_ALL, 0, 0.0f, 0) == CDRESULT_COLLISION) { + if (cdTestVolume(&spe4, objGetRadius(obj), rooms, CDTYPE_ALL, CHECKVERTICAL_NO, 0.0f, 0) == CDRESULT_COLLISION) { spf0.m[3][0] = root->pos.x; spf0.m[3][2] = root->pos.z; } @@ -16720,7 +16736,7 @@ void objDestroySupportedObjects(struct prop *tableprop, s32 playernum) { if (prop->pos.y > tableprop->pos.y && (obj->hidden & OBJHFLAG_00008000) - && func000266a4(prop->pos.x, prop->pos.z, (struct geo *)start)) { + && cd000266a4(prop->pos.x, prop->pos.z, (struct geo *)start)) { objFall(obj, playernum); } } @@ -18026,7 +18042,8 @@ bool objTestForInteract(struct prop *prop) } if (angle <= 0.3926365673542f) { - if ((obj->flags2 & OBJFLAG2_INTERACTCHECKLOS) == 0 || cd0002dcd0(&playerprop->pos, playerprop->rooms, &prop->pos, prop->rooms, 0x20)) { + if ((obj->flags2 & OBJFLAG2_INTERACTCHECKLOS) == 0 + || cdTestLos06(&playerprop->pos, playerprop->rooms, &prop->pos, prop->rooms, CDTYPE_BG)) { g_InteractProp = prop; } } @@ -20534,7 +20551,9 @@ s32 objTestForPickup(struct prop *prop) if (pickup && (obj->flags2 & OBJFLAG2_PICKUPWITHOUTLOS) == 0 && !usebigrange - && cdHasLineOfSight(&playerprop->pos, playerprop->rooms, &prop->pos, prop->rooms, 0x22, 0x1c) == 0) { + && cdTestLos05(&playerprop->pos, playerprop->rooms, &prop->pos, prop->rooms, + CDTYPE_DOORS | CDTYPE_BG, + GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT) == false) { pickup = false; } @@ -23053,13 +23072,13 @@ void doorsCalcFrac(struct doorobj *door) { propSetPerimEnabled(loopprop, false); - cdresult = cd0002e4c4(loopdoor->base.geoblock, loopprop->rooms, + cdresult = cdTestBlockOverlapsAnyProp(loopdoor->base.geoblock, loopprop->rooms, CDTYPE_OBJS | CDTYPE_PLAYERS | CDTYPE_CHRS | CDTYPE_PATHBLOCKER | CDTYPE_OBJSNOTSAFEORHELI); propSetPerimEnabled(loopprop, true); if (cdresult == CDRESULT_COLLISION) { - struct prop *blockerprop = cdGetObstacle(); + struct prop *blockerprop = cdGetObstacleProp(); if (blockerprop && blockerprop->type == PROPTYPE_CHR) { struct chrdata *chr = blockerprop->chr; @@ -23441,7 +23460,7 @@ bool doorTestForInteract(struct prop *prop) if (maybe) { if ((door->base.flags2 & OBJFLAG2_INTERACTCHECKLOS) == 0 - || cd0002dcd0(&playerprop->pos, playerprop->rooms, &prop->pos, prop->rooms, 0x20)) { + || cdTestLos06(&playerprop->pos, playerprop->rooms, &prop->pos, prop->rooms, CDTYPE_BG)) { checkmore = func0f08f968(door, false); if (checkmore && (door->base.flags2 & OBJFLAG2_80000000)) { @@ -24125,7 +24144,9 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct propSetPerimEnabled(fromprop, false); - if (cdTestAToB4(pos, fromprop->rooms, &endpos, CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_CHRS | CDTYPE_PATHBLOCKER| CDTYPE_BG, 0x10) == CDRESULT_COLLISION) { + if (cdExamLos08(pos, fromprop->rooms, &endpos, + CDTYPE_OBJS | CDTYPE_DOORS | CDTYPE_CHRS | CDTYPE_PATHBLOCKER| CDTYPE_BG, + GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { blocked = true; #if VERSION >= VERSION_JPN_FINAL cdGetPos(&endpos, 24883, "prop/propobj.c"); @@ -24138,7 +24159,7 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct #else cdGetPos(&endpos, 24137, "propobj.c"); #endif - obstacle = cdGetObstacle(); + obstacle = cdGetObstacleProp(); } propSetPerimEnabled(fromprop, true); diff --git a/src/game/setup.c b/src/game/setup.c index 6c4e74658..ae1bf9df7 100644 --- a/src/game/setup.c +++ b/src/game/setup.c @@ -1865,7 +1865,7 @@ void setupCreateProps(s32 stagenum) car->nextstep = 0; if (obj->flags & OBJFLAG_CHOPPER_INACTIVE) { - prop->pos.y = cd0002a36c(&prop->pos, prop->rooms, NULL, 0) + 30; + prop->pos.y = cdFindFloorYColourTypeAtPos(&prop->pos, prop->rooms, NULL, 0) + 30; } prop->forcetick = true; diff --git a/src/game/setupcover.c b/src/game/setupcover.c index cd123b352..51d85660f 100644 --- a/src/game/setupcover.c +++ b/src/game/setupcover.c @@ -76,7 +76,7 @@ void setupPrepareCover(void) g_CoverRooms[i] = -1; if (roomsptr != NULL) { - s32 room = cdFindRoom(cover.pos, roomsptr); + s32 room = cdFindFloorRoomAtPos(cover.pos, roomsptr); if (room > 0) { g_CoverRooms[i] = (s16)room; @@ -102,7 +102,7 @@ void setupPrepareCover(void) } if (roomsptr) { - s32 aimroom = cdFindRoom(&aimpos, roomsptr); + s32 aimroom = cdFindFloorRoomAtPos(&aimpos, roomsptr); if (aimroom > 0) { g_CoverFlags[i] |= (g_CoverRooms[i] == (s16)aimroom) ? COVERFLAG_AIMSAMEROOM : COVERFLAG_AIMDIFFROOM; diff --git a/src/game/setuppads.c b/src/game/setuppads.c index 657a61f97..621fa4324 100644 --- a/src/game/setuppads.c +++ b/src/game/setuppads.c @@ -59,7 +59,7 @@ void setupPreparePads(void) } if (roomsptr != NULL) { - roomnum = cdFindRoom(&pad.pos, roomsptr); + roomnum = cdFindFloorRoomAtPos(&pad.pos, roomsptr); if (roomnum > 0) { packedpad->room = roomnum; diff --git a/src/include/bss.h b/src/include/bss.h index 641fecc0b..b05680fe4 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -39,7 +39,7 @@ extern u8 **var8009a888; extern union filedataptr g_TileFileData; extern s32 g_TileNumRooms; extern u32 *g_TileRooms; -extern struct geoblock var8009a918; +extern struct geoblock g_CdSavedBlock; extern u8 g_RdpDramStack[SP_DRAM_STACK_SIZE8]; extern N_ALSndPlayer var8009c2d0; extern struct var8009c340 var8009c340; diff --git a/src/include/commands.h b/src/include/commands.h index 20c11efb7..dec492eae 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -2345,7 +2345,11 @@ 0x00, \ 0x00, -#define cmd0103(label) \ +/** + * Checks if the current chr's proppreset is blocking line of sight from the chr + * to their target. + */ +#define if_proppreset_blocking_sight_to_target(label) \ mkshort(0x0103), \ label, diff --git a/src/include/constants.h b/src/include/constants.h index 7c99d9c61..d74fde60f 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -629,6 +629,9 @@ #define CDTYPE_DOORSLOCKEDTOAI 0x8000 #define CDTYPE_ALL 0x003f +#define CHECKVERTICAL_NO 0 +#define CHECKVERTICAL_YES 1 + #define CHOPPERMODE_PATROL 0 #define CHOPPERMODE_COMBAT 1 #define CHOPPERMODE_FALL 2 @@ -1138,22 +1141,22 @@ #define GBGAME_OTHER 0 #define GBGAME_PD 2 -#define GEOFLAG_0001 0x0001 -#define GEOFLAG_0002 0x0002 -#define GEOFLAG_COLLISIONS 0x0004 -#define GEOFLAG_0008 0x0008 -#define GEOFLAG_OPAQUE 0x0010 // Block AI fire/sight -#define GEOFLAG_LIFTFLOOR 0x0020 -#define GEOFLAG_LADDER 0x0040 -#define GEOFLAG_0080 0x0080 -#define GEOFLAG_0100 0x0100 // Editor: Low wall/edge -#define GEOFLAG_UNDERWATER 0x0200 -#define GEOFLAG_0400 0x0400 // Unused -#define GEOFLAG_AIBOTCROUCH 0x0800 -#define GEOFLAG_AIBOTDUCK 0x1000 -#define GEOFLAG_STEP 0x2000 // Ascend regardless of steepness -#define GEOFLAG_DIE 0x4000 -#define GEOFLAG_CLIMBABLELEDGE 0x8000 // Used for most ledges in Chicago, but not near drain pickup +#define GEOFLAG_FLOOR1 0x0001 +#define GEOFLAG_FLOOR2 0x0002 +#define GEOFLAG_WALL 0x0004 +#define GEOFLAG_BLOCK_SIGHT 0x0008 +#define GEOFLAG_BLOCK_SHOOT 0x0010 +#define GEOFLAG_LIFTFLOOR 0x0020 +#define GEOFLAG_LADDER 0x0040 +#define GEOFLAG_RAMPWALL 0x0080 +#define GEOFLAG_SLOPE 0x0100 +#define GEOFLAG_UNDERWATER 0x0200 +#define GEOFLAG_0400 0x0400 // Unused +#define GEOFLAG_AIBOTCROUCH 0x0800 +#define GEOFLAG_AIBOTDUCK 0x1000 +#define GEOFLAG_STEP 0x2000 // Ascend regardless of steepness +#define GEOFLAG_DIE 0x4000 +#define GEOFLAG_LADDER_PLAYERONLY 0x8000 // Used for most ledges in Chicago, but not near drain pickup #define GEOTYPE_TILE_I 0 // Tiles with integer vertices - used for BG #define GEOTYPE_TILE_F 1 // Tiles with float vertices - used for lifts diff --git a/src/include/data.h b/src/include/data.h index 9fd572a17..0aeebe3ea 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -66,7 +66,7 @@ extern s32 var8005f018; extern s32 var8005f01c; extern bool g_AnimHostEnabled; extern s32 var8005f030; -extern s32 var8005f034; +extern s32 g_CdHasSavedBlock; extern s32 var8005f038; extern u16 *g_RdpOutBufferEnd; extern u16 *g_RdpOutBufferStart; diff --git a/src/include/files/tiles.s b/src/include/files/tiles.s deleted file mode 100644 index f541901a0..000000000 --- a/src/include/files/tiles.s +++ /dev/null @@ -1,160 +0,0 @@ -# Tile files are implemented here using assembly macros because it doesn't -# appear to be possible to do it in C in a sane way. Some rooms have no tiles, -# and you cannot declare an empty array in C. - -.data - -.set FLOORTYPE_DEFAULT, 0 -.set FLOORTYPE_WOOD, 1 -.set FLOORTYPE_STONE, 2 -.set FLOORTYPE_CARPET, 3 -.set FLOORTYPE_METAL, 4 -.set FLOORTYPE_MUD, 5 -.set FLOORTYPE_WATER, 6 -.set FLOORTYPE_DIRT, 7 -.set FLOORTYPE_SNOW, 8 - -.set GEOFLAG_0001, 0x0001 -.set GEOFLAG_0002, 0x0002 -.set GEOFLAG_COLLISIONS, 0x0004 -.set GEOFLAG_0008, 0x0008 -.set GEOFLAG_OPAQUE, 0x0010 -.set GEOFLAG_LIFTFLOOR, 0x0020 -.set GEOFLAG_LADDER, 0x0040 -.set GEOFLAG_0080, 0x0080 -.set GEOFLAG_0100, 0x0100 -.set GEOFLAG_UNDERWATER, 0x0200 -.set GEOFLAG_0400, 0x0400 -.set GEOFLAG_AIBOTCROUCH, 0x0800 -.set GEOFLAG_AIBOTDUCK, 0x1000 -.set GEOFLAG_STEP, 0x2000 -.set GEOFLAG_DIE, 0x4000 -.set GEOFLAG_CLIMBABLELEDGE, 0x8000 - -.set VERSION_NTSC_BETA, 0 -.set VERSION_NTSC_1_0, 1 -.set VERSION_NTSC_FINAL, 2 -.set VERSION_PAL_BETA, 3 -.set VERSION_PAL_FINAL, 4 -.set VERSION_JPN_FINAL, 5 - -.macro tileabstract numverts, flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour - .byte 0 - .byte \numverts - .short \flags - .short \floortype - .byte \xmin - .byte \ymin - .byte \zmin - .byte \xmax - .byte \ymax - .byte \zmax - .short \floorcolour -.endm - -.macro tilevert x, y, z - .short \x - .short \y - .short \z -.endm - -.macro tile3 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3 - tileabstract 3, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 -.endm - -.macro tile4 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4 - tileabstract 4, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 -.endm - -.macro tile5 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5 - tileabstract 5, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 - tilevert \x5, \y5, \z5 -.endm - -.macro tile6 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6 - tileabstract 6, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 - tilevert \x5, \y5, \z5 - tilevert \x6, \y6, \z6 -.endm - -.macro tile7 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7 - tileabstract 7, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 - tilevert \x5, \y5, \z5 - tilevert \x6, \y6, \z6 - tilevert \x7, \y7, \z7 -.endm - -.macro tile8 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7, x8, y8, z8 - tileabstract 8, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 - tilevert \x5, \y5, \z5 - tilevert \x6, \y6, \z6 - tilevert \x7, \y7, \z7 - tilevert \x8, \y8, \z8 -.endm - -.macro tile9 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7, x8, y8, z8, x9, y9, z9 - tileabstract 9, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 - tilevert \x5, \y5, \z5 - tilevert \x6, \y6, \z6 - tilevert \x7, \y7, \z7 - tilevert \x8, \y8, \z8 - tilevert \x9, \y9, \z9 -.endm - -.macro tile11 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7, x8, y8, z8, x9, y9, z9, x10, y10, z10, x11, y11, z11 - tileabstract 11, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 - tilevert \x5, \y5, \z5 - tilevert \x6, \y6, \z6 - tilevert \x7, \y7, \z7 - tilevert \x8, \y8, \z8 - tilevert \x9, \y9, \z9 - tilevert \x10, \y10, \z10 - tilevert \x11, \y11, \z11 -.endm - -.macro tile12 flags, floortype, xmin, ymin, zmin, xmax, ymax, zmax, floorcolour, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5, x6, y6, z6, x7, y7, z7, x8, y8, z8, x9, y9, z9, x10, y10, z10, x11, y11, z11, x12, y12, z12 - tileabstract 12, \flags, \floortype, \xmin, \ymin, \zmin, \xmax, \ymax, \zmax, \floorcolour - tilevert \x1, \y1, \z1 - tilevert \x2, \y2, \z2 - tilevert \x3, \y3, \z3 - tilevert \x4, \y4, \z4 - tilevert \x5, \y5, \z5 - tilevert \x6, \y6, \z6 - tilevert \x7, \y7, \z7 - tilevert \x8, \y8, \z8 - tilevert \x9, \y9, \z9 - tilevert \x10, \y10, \z10 - tilevert \x11, \y11, \z11 - tilevert \x12, \y12, \z12 -.endm diff --git a/src/include/game/chraction.h b/src/include/game/chraction.h index b720736a8..76a395d1c 100644 --- a/src/include/game/chraction.h +++ b/src/include/game/chraction.h @@ -24,7 +24,7 @@ f32 chrGetAttackEntityRelativeAngle(struct chrdata *chr, s32 attackflags, s32 en f32 chrGetAttackEntityDistance(struct chrdata *chr, u32 attackflags, s32 entityid); void func0f02e3dc(struct coord *a, struct coord *b, struct coord *c, struct coord *d, struct coord *dst); void func0f02e4f8(struct coord *arg0, struct coord *arg1, struct coord *dst); -f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 arg3, f32 ymax, f32 ymin); +f32 func0f02e550(struct prop *prop, f32 arg1, f32 arg2, u32 cdtypes, f32 ymax, f32 ymin); f32 func0f02e684(struct prop *prop, f32 arg1, f32 arg2); void chrChooseStandAnimation(struct chrdata *chr, f32 mergetime); void chrStand(struct chrdata *chr); @@ -169,7 +169,7 @@ void func0f044b68(struct coord *arg0, struct coord *arg1, struct coord *arg2); bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coord *aimpos, struct coord *arg4, struct coord *arg5, f32 negchrradius, f32 chrradius, s32 cdtypes, s32 arg9); bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, struct coord *aimpos, struct coord *leftpos, struct coord *rightpos, f32 negchrradius, f32 chrradius, s32 cdtypes, bool hasobstacle); bool chrNavTryObstacle(struct chrdata *chr, struct coord *arg1, bool arg2, struct coord *arg3, f32 radius, bool arg5, struct coord *nextpos, struct waydata *waydata, f32 arg8, s32 cdtypes, s32 arg10); -struct prop *chrOpenDoor(struct chrdata *chr, struct coord *coord); +struct prop *chrOpenDoor(struct chrdata *chr, struct coord *rangepos); void chrNavTickMain(struct chrdata *chr, struct coord *pos, struct waydata *waydata, bool arg3); bool chrGoPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, bool arrivingatlift, s16 curpadnum, s32 nextpadnum); s16 chrGoPosGetNextPadNum(struct chrdata *chr); @@ -212,12 +212,12 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angl #endif struct prop *chrSpawnAtCoord(s32 body, s32 head, struct coord *pos, s16 *room, f32 angle, u8 *ailist, u32 spawnflags); -bool func0f04b658(struct chrdata *chr); +bool chrIsPropPresetBlockingSightToTarget(struct chrdata *chr); bool chrMoveToPos(struct chrdata *chr, struct coord *pos, s16 *room, f32 angle, bool allowonscreen); bool chrCheckCoverOutOfSight(struct chrdata *chr, s32 covernum, bool soft); s32 chrAssignCoverByCriteria(struct chrdata *chr, u16 arg1, s32 arg2); s32 chrAssignCoverAwayFromDanger(struct chrdata *chr, s32 mindist, s32 maxdist); -bool chrRunFromPos(struct chrdata *chr, u32 speed, f32 distance, struct coord *frompos); +bool chrRunFromPos(struct chrdata *chr, u32 goposflags, f32 distance, struct coord *frompos); f32 func0f04c784(struct chrdata *chr); bool chr0f04c874(struct chrdata *chr, u32 angle360, struct coord *pos, u8 arg3, u8 arg4); void rebuildTeams(void); @@ -266,7 +266,7 @@ bool chrTrySurprisedLookAround(struct chrdata *chr); bool chrTryKneel(struct chrdata *chr); bool chrTryStartAnim(struct chrdata *chr, s32 animnum, f32 startframe, f32 endframe, u8 chranimflags, s32 merge, f32 speed); bool chrTryStartAlarm(struct chrdata *chr, s32 pad_id); -s32 chrConsiderGrenadeThrow(struct chrdata *chr, u32 attackflags, u32 entityid); +bool chrConsiderGrenadeThrow(struct chrdata *chr, u32 attackflags, u32 entityid); void chrTickKneel(struct chrdata *chr); void chrFadeCorpse(struct chrdata *chr); void chrFadeCorpseWhenOffScreen(struct chrdata *chr); diff --git a/src/include/game/chraicommands.h b/src/include/game/chraicommands.h index 6c4c58892..4e7268b55 100644 --- a/src/include/game/chraicommands.h +++ b/src/include/game/chraicommands.h @@ -260,7 +260,7 @@ /*0x0100*/ bool aiNoOp0100(void); /*0x0101*/ bool aiNoOp0101(void); /*0x0102*/ bool aiSetLights(void); -/*0x0103*/ bool ai0103(void); +/*0x0103*/ bool aiIfPropPresetIsBlockingSightToTarget(void); /*0x0104*/ bool aiRemoveObjectAtPropPreset(void); /*0x0105*/ bool aiIfPropPresetHeightLessThan(void); /*0x0106*/ bool aiSetTarget(void); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index a0bfc594a..73b2b2250 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -39,7 +39,7 @@ void propsTickPlayer(bool islastplayer); void propsTickPadEffects(void); void propSetPerimEnabled(struct prop *prop, bool enable); void propsTestForPickup(void); -f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f32 *arg4, s32 arg5, bool cangangsta, s32 arg7); +f32 func0f06438c(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3, f32 *arg4, bool throughobjects, bool cangangsta, s32 arg7); void farsightChooseTarget(void); void autoaimTick(void); u32 propDoorGetCdTypes(struct prop *prop); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index 839b243ee..33cd7e004 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -107,7 +107,7 @@ void objFreeProjectile(struct defaultobj *obj); void objFreeEmbedmentOrProjectile(struct prop *prop); void objFree(struct defaultobj *obj, bool freeprop, bool canregen); void objFreePermanently(struct defaultobj *obj, bool freeprop); -f32 objGetWidth(struct defaultobj *obj); +f32 objGetRadius(struct defaultobj *obj); bool func0f06b39c(struct coord *pos, struct coord *dir, struct coord *aimpos, f32 arg3); bool func0f06b488(struct prop *prop, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4, struct coord *arg5, f32 *arg6); bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2, struct coord *arg3, f32 arg4, struct coord *arg5, struct coord *arg6, struct coord *arg7, struct coord *arg8, f32 *arg9); diff --git a/src/include/lib/collision.h b/src/include/lib/collision.h index 468a42500..657659d4a 100644 --- a/src/include/lib/collision.h +++ b/src/include/lib/collision.h @@ -9,119 +9,63 @@ f32 func0f1578c8(struct widthxz *arg0, struct xz *arg1, struct xz *arg2); f32 func0f1579cc(struct widthxz *arg0, struct xz *arg1, struct xz *arg2, struct xz *arg3); f32 cd00024e40(void); -void cd00024e4c(struct coord *arg0, struct coord *arg1, u32 line, char *file); +void cdGetEdge(struct coord *pos1, struct coord *pos2, u32 line, char *file); f32 cd00024e98(void); s32 cd00024ea4(void); -struct prop *cdGetObstacle(void); +struct prop *cdGetObstacleProp(void); void cdGetPos(struct coord *pos, u32 line, char *file); -void cd00024ee8(struct coord *arg0); -u32 cdGetTileFlags(void); -void cd00024f6c(void); -void cd00024fb0(struct coord *arg0, struct coord *arg1, struct prop *prop); -void cd00025038(struct coord *arg0, struct coord *arg1, struct prop *prop, f32 arg3); -void cd000250cc(struct coord *arg0, struct coord *arg1, f32 width); -void cd00025168(struct prop *prop); -void cd000251ac(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct prop *prop); -void cd00025254(struct coord *arg0, struct coord *arg1, struct coord *pos, struct prop *prop, f32 arg4, struct geo *tile); -void cd00025314(struct coord *pos, struct coord *arg1); -bool cd00025364(struct coord *arg0, struct coord *arg1); -void cd000253c4(struct geoblock *block); -s32 cd00025410(f32 arg0, f32 arg1, f32 arg2, f32 arg3); -bool cd000254d8(struct coord *arg0, struct coord *arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, bool *arg6); -f32 cd00025654(f32 x1, f32 z1, f32 x2, f32 z2, f32 x3, f32 z3); -f32 cd00025724(f32 x1, f32 z1, f32 x2, f32 z2); -bool cd00025774(f32 x1, f32 z1, f32 x2, f32 z2, f32 x3, f32 z3); -void cd00025848(f32 tilex, f32 tilez, f32 tilewidth, f32 posx, f32 posz, f32 *x1, f32 *z1, f32 *x2, f32 *z2); -void cd00025928(struct geo *tile, struct coord *arg1); +void cdGetObstacleNormal(struct coord *normal); +u32 cdGetGeoFlags(void); +void cdSetSavedPos(struct coord *pos1, struct coord *pos2); +bool cdGetSavedPos(struct coord *arg0, struct coord *arg1); +void cdGetGeoNormal(struct geo *geo, struct coord *normal); void cdGetFloorCol(struct geo *tile, u16 *floorcol); void cdGetFloorType(struct geo *tile, u8 *floortype); -f32 cdFindGroundInIntTileAtVertex(struct geotilei *tile, f32 x, f32 z, s32 vertexindex); -f32 cdFindGroundInIntTile(struct geotilei *tile, f32 x, f32 z); -f32 cdFindGroundInFltTile(struct geotilef *tile, f32 x, f32 z); -bool cdIs2dPointInIntTile(struct geotilei *tile, f32 x, f32 z); -bool cdIs2dPointInFltTile(struct geotilef *tile, f32 x, f32 z); -bool cdIs2dPointInBlock(struct geoblock *tile, f32 x, f32 z); -bool cdIs2dPointInCyl(struct geocyl *cyl, f32 x, f32 z); -bool func000266a4(f32 x, f32 z, struct geo *tile); +bool cd000266a4(f32 x, f32 z, struct geo *tile); void cdGetPropsOnPlatform(struct prop *platform, s16 *propnums, s32 len); -bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 flags, s32 room, struct geo **tileptr, s32 *roomptr, f32 *groundptr, bool arg8); -void cd00026e7c(struct coord *pos, s16 *rooms, u16 arg2, struct geo **tileptr, s16 *room, f32 *arg5, struct prop **arg6, s32 arg7); -bool cd0002709c(struct geotilei *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collisionthing *thing); -bool cd000272f8(struct geotilef *tile, f32 x, f32 z, f32 radius, struct prop *prop, struct collisionthing *thing); -s32 cd000274e0(struct geoblock *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collisionthing *thing); -bool cd000276c8(struct geocyl *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collisionthing *thing); -void cd00027738(struct coord *pos, f32 width, u8 *start, u8 *end, u16 flags, bool checkvertical, f32 arg6, f32 arg7, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingnum, s32 roomnum); -void cd00027d1c(struct coord *pos, f32 radius, s16 *rooms, u32 types, u16 arg4, u32 arg5, f32 arg6, f32 arg7, struct collisionthing *arg8, s32 arg9); -void cd00027f78(struct geotilei *tile, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex); -s32 cd00028200(struct geotilei *tile, struct coord *pos, f32 width, f32 y1, f32 y2); -void cd0002840c(struct geotilef *tile, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex); -void cd00028638(struct geoblock *block, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex); -void cd0002885c(struct geocyl *cyl, f32 x, f32 z, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex); -void cd00028914(u8 *start, u8 *end, struct coord *pos, f32 radius, u16 flags, bool checkvertical, f32 arg6, f32 arg7, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingnum); -void cd00028df0(struct coord *pos, f32 width, s16 *rooms, u32 types, u16 arg4, u32 arg5, f32 ymax, f32 ymin, struct collisionthing *arg8, s32 arg9); -void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisionthing *arg3); -f32 cd000296a0(struct collisionthing *arg0, struct coord *pos, struct collisionthing **arg2, f32 width); -bool cd00029ffc(struct coord *pos, f32 width, f32 foreheadheight, f32 inversefeettoeyesheight, s16 *rooms, u16 arg5, struct coord *laddernormal); -bool cd0002a13c(struct coord *pos, f32 radius, f32 arg2, f32 arg3, s16 *rooms, u16 arg5); -f32 cdFindGroundY(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype, u16 *floorflags, s16 *floorroom, s32 *inlift, struct prop **lift); -f32 cd0002a324(void); -f32 cdFindGroundYSimple(struct coord *pos, f32 width, s16 *rooms, u16 *floorcol, u8 *floortype); -f32 cd0002a36c(struct coord *coord, s16 *rooms, u16 *floorcol, u8 *floortype); -s32 cdFindRoom(struct coord *pos, s16 *nearrooms); +s32 cd000274e0Block(struct geoblock *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collision *collision); +bool cd000276c8Cyl(struct geocyl *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collision *collision); +bool cdFindLadder(struct coord *pos, f32 width, f32 ymax, f32 ymin, s16 *rooms, u16 geoflags, struct coord *laddernormal); +bool cd0002a13c(struct coord *pos, f32 radius, f32 arg2, f32 arg3, s16 *rooms, u16 geoflags); +f32 cdFindGroundInfoAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype, u16 *floorflags, s16 *floorroom, s32 *inlift, struct prop **lift); +f32 cdReturnZero(void); +f32 cdFindGroundAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype); +f32 cdFindFloorYColourTypeAtPos(struct coord *pos, s16 *rooms, u16 *floorcol, u8 *floortype); +s32 cdFindFloorRoomAtPos(struct coord *pos, s16 *nearrooms); #if VERSION >= VERSION_NTSC_1_0 -s16 cd0002a440(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); -s16 cd0002a4d0(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); +s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); +s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); #else -s16 cd0002a440(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr); -s16 cd0002a4d0(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr); +s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr); +s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr); #endif -s16 cd0002a564(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, struct coord *arg4, struct prop **propptr); -s16 cd0002a5e4(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, u16 *arg4, struct coord *arg5); -s32 cdTestVolume(struct coord *pos, f32 radius, s16 *rooms, s32 types, s32 arg4, f32 ymax, f32 ymin); -s32 cd0002a6fc(struct coord *pos, struct coord *pos2, f32 width, s16 *rooms, s32 types, bool arg5, f32 arg6, f32 arg7); -s32 cdTestAToB1(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 types, s32 arg5, f32 ymax, f32 ymin); -bool cd0002aac0(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilei *tile, struct coord *arg4, struct coord *arg5); -bool cd0002ab98(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilef *tile, struct coord *arg4, struct coord *arg5); -bool cd0002ac70(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilei *tile, struct coord *arg4, struct coord *arg5, struct coord *arg6, s32 arg7, f32 arg8, f32 arg9); -bool cd0002b128(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilef *tile, struct coord *arg4, struct coord *arg5, struct coord *arg6, s32 arg7, f32 arg8, f32 arg9); -bool cd0002b560(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geoblock *block, struct coord *arg4, struct coord *arg5, struct coord *arg6, bool arg7, f32 arg8, f32 arg9); -bool cd0002b954(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geocyl *cyl, struct coord *arg4, struct coord *arg5, struct coord *arg6, bool arg7, f32 arg8, f32 arg9); -bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, struct coord *arg4, u16 arg5, s32 arg6, s32 arg7, f32 arg8, f32 arg9); -void cd0002c328(struct geotilei *tile, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4); -void cd0002c528(struct geotilef *tile, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4); -bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, struct coord *arg4, u16 flags, s32 arg6, s32 arg7, f32 ymax, f32 ymin, f32 *arg10, struct coord *arg11, struct coord *arg12, struct coord *arg13, struct geo **tile, s32 roomnum); -bool cd0002d15c(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, u16 arg4, s32 arg5, s32 arg6, f32 arg7, f32 arg8); -s32 cd0002d3b0(struct coord *arg0, struct coord *arg1, s16 *arg2, s32 types, u16 arg4, s32 arg5, s32 arg6, f32 ymax, f32 ymin); -bool cd0002d6ac(struct coord *pos, s16 *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 arg5, f32 arg6); -s32 cdTestAToB2(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *rooms2, u32 types, s32 arg5, f32 arg6, f32 arg7); -bool cd0002d7c0(struct coord *pos, s16 *rooms, struct coord *arg2, u32 arg3, u32 arg4, f32 ymax, f32 ymin); -s32 cd0002d840(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); -s32 cd0002d8b8(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin); -s32 cdTestAToB3(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 arg4, s32 types, s32 arg6, f32 ymax, f32 ymin); -s32 cd0002da50(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); -s32 cd0002dac8(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin); -bool cd0002db98(struct coord *viewpos, s16 *rooms, struct coord *targetpos, u32 types, u16 arg4); -bool cd0002dc18(struct coord *coord, s16 *rooms, struct coord *coord2, s32 arg3); -bool cdHasLineOfSight(struct coord *coord, s16 *rooms, struct coord *coord2, s16 *rooms2, s32 arg4, u16 arg5); -bool cd0002dcd0(struct coord *arg0, s16 *rooms1, struct coord *arg2, s16 *rooms2, u32 arg4); -bool cd0002dcfc(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s16 *rooms3, u32 types, u16 arg6); -s32 cdTestAToB4(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types, u16 arg4); -s32 cd0002de10(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types); -s32 cd0002de34(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, u16 arg5); -s32 cd0002deac(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types); +s16 cdFindFloorRoomYColourNormalPropAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, struct coord *normal, struct prop **propptr); +s16 cdFindCeilingRoomYColourFlagsNormalAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, u16 *geoflags, struct coord *normal); +s32 cdTestVolume(struct coord *pos, f32 radius, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); +s32 cdExamCylMove01(struct coord *pos, struct coord *pos2, f32 radius, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); +s32 cdExamCylMove02(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); +bool cdTestCylMove01(struct coord *pos, s16 *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 ymax, f32 ymin); +s32 cdTestCylMove02(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *rooms2, u32 types, bool arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove03(struct coord *pos, s16 *rooms, struct coord *arg2, u32 types, u32 arg4, f32 ymax, f32 ymin); +s32 cdTestCylMove04(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove05(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove06(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 arg4, s32 types, s32 arg6, f32 ymax, f32 ymin); +s32 cdExamCylMove07(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove08(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin); +bool cdTestLos03(struct coord *viewpos, s16 *rooms, struct coord *targetpos, u32 types, u16 geoflags); +bool cdTestLos04(struct coord *coord, s16 *rooms, struct coord *coord2, s32 arg3); +bool cdTestLos05(struct coord *coord, s16 *rooms, struct coord *coord2, s16 *rooms2, s32 cdtypes, u16 geoflags); +bool cdTestLos06(struct coord *arg0, s16 *rooms1, struct coord *arg2, s16 *rooms2, u32 types); +bool cdTestLos07(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s16 *rooms3, u32 types, u16 geoflags); +s32 cdExamLos08(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types, u16 geoflags); +s32 cdExamLos09(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types); +s32 cdTestLos10(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, u16 geoflags); +s32 cdTestLos11(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types); bool cd0002ded8(struct coord *arg0, struct coord *arg1, struct prop *prop); -bool cd0002dffc(struct geoblock *arg0, struct geoblock *arg1); -s32 cd0002e278(u8 *start, u8 *end, struct geoblock *ref, u16 flags); -s32 cd0002e4c4(struct geoblock *geo, s16 *rooms, u32 types); -bool cd0002e680(struct geotilei *tile, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block); -bool cd0002e82c(struct geotilef *tile, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block); -bool cd0002e9d8(struct geoblock *block, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block2); -bool cd0002eb84(struct geocyl *cyl, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block); -bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, struct coord *arg4, struct coord *arg5, u16 flags, struct prop *prop); +s32 cdTestBlockOverlapsAnyProp(struct geoblock *geo, s16 *rooms, u32 types); s32 cd0002f02c(struct geoblock *block, s16 *rooms, s32 types); -bool cd0002f308(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 arg4, u16 arg5); -bool cd0002f450(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 arg4); +bool cdIsNearlyInSight(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 arg4); #endif diff --git a/src/include/types.h b/src/include/types.h index a9c09c2f3..768725d7e 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -861,7 +861,7 @@ struct geotilef { union { // The arrays are surely the correct type here, but they create // mismatches in code that has already been matched using individual - // properties (eg. cd00027738). @TODO: Rematch them using the arrays. + // properties (eg. cdCollectGeoForCylFromList). @TODO: Rematch them using the arrays. struct { /*0x06*/ u8 min[3]; // These are indexes into vertices /*0x09*/ u8 max[3]; @@ -5769,7 +5769,7 @@ struct texturepair { s32 texturenum2; }; -struct collisionthing { +struct collision { struct geo *geo; bool intile; s32 vertexindex; diff --git a/src/lib/collision.c b/src/lib/collision.c index cfb2fe8b2..1838cae12 100644 --- a/src/lib/collision.c +++ b/src/lib/collision.c @@ -15,6 +15,9 @@ #include "data.h" #include "types.h" +#define SURFACE_FLOOR 0 +#define SURFACE_CEILING 1 + struct debugtri { s16 vertices[3][3]; u8 unk12; @@ -26,27 +29,27 @@ u32 *g_TileRooms; s32 var8009a8ac; f32 var8009a8b0; s32 var8009a8b4; -struct coord var8009a8b8; +struct coord g_CdEdgeVtx1; s32 var8009a8c4; -struct coord var8009a8c8; -struct prop *g_CdObstacle; +struct coord g_CdEdgeVtx2; +struct prop *g_CdObstacleProp; s32 var8009a8d8; s32 var8009a8dc; -struct coord g_CdPos; +struct coord g_CdObstaclePos; s32 var8009a8ec; f32 var8009a8f0; -bool var8009a8f4; -struct coord var8009a8f8; +bool g_CdHasSavedPos; +struct coord g_CdPos1; s32 var8009a904; -struct coord var8009a908; +struct coord g_CdPos2; s32 var8009a914; -struct geoblock var8009a918; -struct geo *var8009a964; +struct geoblock g_CdSavedBlock; +struct geo *g_CdObstacleGeo; s32 var8009a968; s32 var8009a96c; s32 var8005f030 = 0; -s32 var8005f034 = 0; +bool g_CdHasSavedBlock = false; s32 var8005f038 = 0; f32 cd00024e40(void) @@ -54,15 +57,15 @@ f32 cd00024e40(void) return var8009a8f0; } -void cd00024e4c(struct coord *a, struct coord *b, u32 line, char *file) +void cdGetEdge(struct coord *vtx1, struct coord *vtx2, u32 line, char *file) { - a->x = var8009a8b8.x; - a->y = var8009a8b8.y; - a->z = var8009a8b8.z; + vtx1->x = g_CdEdgeVtx1.x; + vtx1->y = g_CdEdgeVtx1.y; + vtx1->z = g_CdEdgeVtx1.z; - b->x = var8009a8c8.x; - b->y = var8009a8c8.y; - b->z = var8009a8c8.z; + vtx2->x = g_CdEdgeVtx2.x; + vtx2->y = g_CdEdgeVtx2.y; + vtx2->z = g_CdEdgeVtx2.z; } f32 cd00024e98(void) @@ -75,96 +78,96 @@ s32 cd00024ea4(void) return var8009a8ac; } -struct prop *cdGetObstacle(void) +struct prop *cdGetObstacleProp(void) { - return g_CdObstacle; + return g_CdObstacleProp; } void cdGetPos(struct coord *pos, u32 line, char *file) { - pos->x = g_CdPos.x; - pos->y = g_CdPos.y; - pos->z = g_CdPos.z; + pos->x = g_CdObstaclePos.x; + pos->y = g_CdObstaclePos.y; + pos->z = g_CdObstaclePos.z; } -void cd00024ee8(struct coord *arg0) +void cdGetObstacleNormal(struct coord *normal) { - cd00025928(var8009a964, arg0); + cdGetGeoNormal(g_CdObstacleGeo, normal); } -u32 cdGetTileFlags(void) +u32 cdGetGeoFlags(void) { u32 flags = 0; - switch (var8009a964->type) { + switch (g_CdObstacleGeo->type) { case GEOTYPE_TILE_I: - flags = var8009a964->flags; + flags = g_CdObstacleGeo->flags; break; case GEOTYPE_TILE_F: - flags = var8009a964->flags; + flags = g_CdObstacleGeo->flags; break; case GEOTYPE_BLOCK: - flags = GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE; + flags = GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT; break; case GEOTYPE_CYL: - flags = var8009a964->flags; + flags = g_CdObstacleGeo->flags; break; } return flags; } -void cd00024f6c(void) +void cdClearResults(void) { var8009a8b4 = 0; var8009a8ac = 0; - g_CdObstacle = NULL; + g_CdObstacleProp = NULL; var8009a8d8 = 0; var8009a8ec = 0; - var8009a8f4 = false; - var8005f034 = 0; + g_CdHasSavedPos = false; + g_CdHasSavedBlock = false; var8005f038 = 0; } -void cd00024fb0(struct coord *arg0, struct coord *arg1, struct prop *prop) +void cdSetObstacleVtxProp(struct coord *vtx1, struct coord *vtx2, struct prop *prop) { - var8009a8b8.x = arg0->x; - var8009a8b8.y = arg0->y; - var8009a8b8.z = arg0->z; + g_CdEdgeVtx1.x = vtx1->x; + g_CdEdgeVtx1.y = vtx1->y; + g_CdEdgeVtx1.z = vtx1->z; - var8009a8c8.x = arg1->x; - var8009a8c8.y = arg1->y; - var8009a8c8.z = arg1->z; + g_CdEdgeVtx2.x = vtx2->x; + g_CdEdgeVtx2.y = vtx2->y; + g_CdEdgeVtx2.z = vtx2->z; var8009a8b4 = 1; var8009a8ac = 0; - g_CdObstacle = prop; + g_CdObstacleProp = prop; var8009a8d8 = 0; var8009a8ec = 0; - var8009a8f4 = false; - var8005f034 = 0; + g_CdHasSavedPos = false; + g_CdHasSavedBlock = false; var8005f038 = 0; } -void cd00025038(struct coord *arg0, struct coord *arg1, struct prop *prop, f32 arg3) +void cdSetObstacleVtxPropFlt(struct coord *vtx1, struct coord *vtx2, struct prop *prop, f32 arg3) { var8009a8b0 = arg3; - var8009a8b8.x = arg0->x; - var8009a8b8.y = arg0->y; - var8009a8b8.z = arg0->z; + g_CdEdgeVtx1.x = vtx1->x; + g_CdEdgeVtx1.y = vtx1->y; + g_CdEdgeVtx1.z = vtx1->z; - var8009a8c8.x = arg1->x; - var8009a8c8.y = arg1->y; - var8009a8c8.z = arg1->z; + g_CdEdgeVtx2.x = vtx2->x; + g_CdEdgeVtx2.y = vtx2->y; + g_CdEdgeVtx2.z = vtx2->z; var8009a8b4 = 1; var8009a8ac = 1; - g_CdObstacle = prop; + g_CdObstacleProp = prop; var8009a8d8 = 0; var8009a8ec = 0; - var8009a8f4 = 0; - var8005f034 = 0; + g_CdHasSavedPos = false; + g_CdHasSavedBlock = false; var8005f038 = 0; } @@ -182,110 +185,110 @@ void cd000250cc(struct coord *arg0, struct coord *arg1, f32 width) sp1c.x = arg1->x; sp1c.z = arg1->z; - sp2c.x = var8009a8b8.x; - sp2c.z = var8009a8b8.z; + sp2c.x = g_CdEdgeVtx1.x; + sp2c.z = g_CdEdgeVtx1.z; - sp24.x = var8009a8c8.x; - sp24.z = var8009a8c8.z; + sp24.x = g_CdEdgeVtx2.x; + sp24.z = g_CdEdgeVtx2.z; var8009a8b0 = func0f1579cc(&sp34, &sp2c, &sp24, &sp1c); var8009a8ac = 1; } -void cd00025168(struct prop *prop) +void cdSetObstacleProp(struct prop *prop) { var8009a8b4 = 0; var8009a8ac = 0; - g_CdObstacle = prop; + g_CdObstacleProp = prop; var8009a8d8 = 0; var8009a8ec = 0; - var8009a8f4 = false; - var8005f034 = 0; + g_CdHasSavedPos = false; + g_CdHasSavedBlock = false; var8005f038 = 0; } -void cd000251ac(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct prop *prop) +void cdSetObstacleVtxColProp(struct coord *vtxpos1, struct coord *vtxpos2, struct coord *collisionpos, struct prop *prop) { - var8009a8b8.x = arg0->x; - var8009a8b8.y = arg0->y; - var8009a8b8.z = arg0->z; + g_CdEdgeVtx1.x = vtxpos1->x; + g_CdEdgeVtx1.y = vtxpos1->y; + g_CdEdgeVtx1.z = vtxpos1->z; - var8009a8c8.x = arg1->x; - var8009a8c8.y = arg1->y; - var8009a8c8.z = arg1->z; + g_CdEdgeVtx2.x = vtxpos2->x; + g_CdEdgeVtx2.y = vtxpos2->y; + g_CdEdgeVtx2.z = vtxpos2->z; - g_CdPos.x = arg2->x; - g_CdPos.y = arg2->y; - g_CdPos.z = arg2->z; + g_CdObstaclePos.x = collisionpos->x; + g_CdObstaclePos.y = collisionpos->y; + g_CdObstaclePos.z = collisionpos->z; var8009a8b4 = 1; var8009a8ac = 0; - g_CdObstacle = prop; + g_CdObstacleProp = prop; var8009a8d8 = 1; var8009a8ec = 0; - var8009a8f4 = 0; - var8005f034 = 0; + g_CdHasSavedPos = false; + g_CdHasSavedBlock = false; var8005f038 = 0; } -void cd00025254(struct coord *arg0, struct coord *arg1, struct coord *pos, struct prop *prop, f32 arg4, struct geo *geo) +void cdSetObstacleVtxColPropFltGeo(struct coord *vtxpos1, struct coord *vtxpos2, struct coord *collisionpos, struct prop *prop, f32 arg4, struct geo *geo) { - var8009a8b8.x = arg0->x; - var8009a8b8.y = arg0->y; - var8009a8b8.z = arg0->z; + g_CdEdgeVtx1.x = vtxpos1->x; + g_CdEdgeVtx1.y = vtxpos1->y; + g_CdEdgeVtx1.z = vtxpos1->z; - var8009a8c8.x = arg1->x; - var8009a8c8.y = arg1->y; - var8009a8c8.z = arg1->z; + g_CdEdgeVtx2.x = vtxpos2->x; + g_CdEdgeVtx2.y = vtxpos2->y; + g_CdEdgeVtx2.z = vtxpos2->z; - g_CdPos.x = pos->x; - g_CdPos.y = pos->y; - g_CdPos.z = pos->z; + g_CdObstaclePos.x = collisionpos->x; + g_CdObstaclePos.y = collisionpos->y; + g_CdObstaclePos.z = collisionpos->z; var8009a8b4 = 1; var8009a8ac = 0; - g_CdObstacle = prop; + g_CdObstacleProp = prop; var8009a8d8 = 1; var8009a8f0 = arg4; var8009a8ec = 1; - var8009a8f4 = false; - var8005f034 = 0; - var8009a964 = geo; + g_CdHasSavedPos = false; + g_CdHasSavedBlock = false; + g_CdObstacleGeo = geo; var8005f038 = 1; } -void cd00025314(struct coord *arg0, struct coord *arg1) +void cdSetSavedPos(struct coord *pos1, struct coord *pos2) { - var8009a8f8.x = arg0->x; - var8009a8f8.y = arg0->y; - var8009a8f8.z = arg0->z; + g_CdPos1.x = pos1->x; + g_CdPos1.y = pos1->y; + g_CdPos1.z = pos1->z; - var8009a908.x = arg1->x; - var8009a908.y = arg1->y; - var8009a908.z = arg1->z; + g_CdPos2.x = pos2->x; + g_CdPos2.y = pos2->y; + g_CdPos2.z = pos2->z; - var8009a8f4 = true; + g_CdHasSavedPos = true; } -bool cd00025364(struct coord *arg0, struct coord *arg1) +bool cdGetSavedPos(struct coord *pos1, struct coord *pos2) { - if (var8009a8f4) { - arg0->x = var8009a8f8.x; - arg0->y = var8009a8f8.y; - arg0->z = var8009a8f8.z; + if (g_CdHasSavedPos) { + pos1->x = g_CdPos1.x; + pos1->y = g_CdPos1.y; + pos1->z = g_CdPos1.z; - arg1->x = var8009a908.x; - arg1->y = var8009a908.y; - arg1->z = var8009a908.z; + pos2->x = g_CdPos2.x; + pos2->y = g_CdPos2.y; + pos2->z = g_CdPos2.z; } - return var8009a8f4; + return g_CdHasSavedPos; } -void cd000253c4(struct geoblock *block) +void cdSetSavedBlock(struct geoblock *block) { - var8009a918 = *block; - var8005f034 = true; + g_CdSavedBlock = *block; + g_CdHasSavedBlock = true; } s32 cd00025410(f32 arg0, f32 arg1, f32 arg2, f32 arg3) @@ -415,53 +418,53 @@ void cd00025848(f32 tilex, f32 tilez, f32 tilewidth, f32 posx, f32 posz, f32 *x1 *z2 = tilez + posz + posx; } -void cd00025928(struct geo *geo, struct coord *arg1) +void cdGetGeoNormal(struct geo *geo, struct coord *normal) { if (geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile0 = (struct geotilei *) geo; + struct geotilei *tile = (struct geotilei *) geo; s32 sp38[3]; s32 sp2c[3]; s32 sp20[3]; - sp38[0] = tile0->vertices[1][0] - tile0->vertices[0][0]; - sp38[1] = tile0->vertices[1][1] - tile0->vertices[0][1]; - sp38[2] = tile0->vertices[1][2] - tile0->vertices[0][2]; + sp38[0] = tile->vertices[1][0] - tile->vertices[0][0]; + sp38[1] = tile->vertices[1][1] - tile->vertices[0][1]; + sp38[2] = tile->vertices[1][2] - tile->vertices[0][2]; - sp2c[0] = tile0->vertices[2][0] - tile0->vertices[0][0]; - sp2c[1] = tile0->vertices[2][1] - tile0->vertices[0][1]; - sp2c[2] = tile0->vertices[2][2] - tile0->vertices[0][2]; + sp2c[0] = tile->vertices[2][0] - tile->vertices[0][0]; + sp2c[1] = tile->vertices[2][1] - tile->vertices[0][1]; + sp2c[2] = tile->vertices[2][2] - tile->vertices[0][2]; sp20[0] = sp38[1] * sp2c[2] - sp38[2] * sp2c[1]; sp20[1] = sp38[2] * sp2c[0] - sp38[0] * sp2c[2]; sp20[2] = sp38[0] * sp2c[1] - sp38[1] * sp2c[0]; - arg1->x = sp20[0]; - arg1->y = sp20[1]; - arg1->z = sp20[2]; + normal->x = sp20[0]; + normal->y = sp20[1]; + normal->z = sp20[2]; } else if (geo->type == GEOTYPE_TILE_F) { - struct geotilef *tile1 = (struct geotilef *) geo; + struct geotilef *tile = (struct geotilef *) geo; f32 sp10[3]; f32 sp04[3]; - sp10[0] = tile1->vertices[1].x - tile1->vertices[0].x; - sp10[1] = tile1->vertices[1].y - tile1->vertices[0].y; - sp10[2] = tile1->vertices[1].z - tile1->vertices[0].z; + sp10[0] = tile->vertices[1].x - tile->vertices[0].x; + sp10[1] = tile->vertices[1].y - tile->vertices[0].y; + sp10[2] = tile->vertices[1].z - tile->vertices[0].z; - sp04[0] = tile1->vertices[2].x - tile1->vertices[0].x; - sp04[1] = tile1->vertices[2].y - tile1->vertices[0].y; - sp04[2] = tile1->vertices[2].z - tile1->vertices[0].z; + sp04[0] = tile->vertices[2].x - tile->vertices[0].x; + sp04[1] = tile->vertices[2].y - tile->vertices[0].y; + sp04[2] = tile->vertices[2].z - tile->vertices[0].z; - arg1->x = sp10[1] * sp04[2] - sp10[2] * sp04[1]; - arg1->y = sp10[2] * sp04[0] - sp10[0] * sp04[2]; - arg1->z = sp10[0] * sp04[1] - sp10[1] * sp04[0]; + normal->x = sp10[1] * sp04[2] - sp10[2] * sp04[1]; + normal->y = sp10[2] * sp04[0] - sp10[0] * sp04[2]; + normal->z = sp10[0] * sp04[1] - sp10[1] * sp04[0]; } else if (geo->type == GEOTYPE_BLOCK) { - arg1->x = 0; - arg1->y = 1; - arg1->z = 0; + normal->x = 0; + normal->y = 1; + normal->z = 0; } else if (geo->type == GEOTYPE_CYL) { - arg1->x = 0; - arg1->y = 1; - arg1->z = 0; + normal->x = 0; + normal->y = 1; + normal->z = 0; } } @@ -473,14 +476,14 @@ void cdGetFloorCol(struct geo *geo, u16 *floorcol) } if (geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile0 = (struct geotilei *) geo; - *floorcol = tile0->floorcol; + struct geotilei *tile = (struct geotilei *) geo; + *floorcol = tile->floorcol; return; } if (geo->type == GEOTYPE_TILE_F) { - struct geotilef *tile1 = (struct geotilef *) geo; - *floorcol = tile1->floorcol; + struct geotilef *tile = (struct geotilef *) geo; + *floorcol = tile->floorcol; return; } @@ -775,7 +778,7 @@ bool cdIs2dPointInCyl(struct geocyl *cyl, f32 x, f32 z) return xdiff * xdiff + zdiff * zdiff <= cyl->radius * cyl->radius; } -bool func000266a4(f32 x, f32 z, struct geo *geo) +bool cd000266a4(f32 x, f32 z, struct geo *geo) { if (geo == NULL) { return false; @@ -820,21 +823,21 @@ void cdGetPropsOnPlatform(struct prop *platform, s16 *propnums, s32 maxlen) struct geotilei *tile = (struct geotilei *) geo; geo = (struct geo *)((u32)geo + sizeof(struct geotilei) + sizeof(tile->vertices[0]) * (tile->header.numvertices - ARRAYCOUNT(tile->vertices))); } else if (geo->type == GEOTYPE_TILE_F) { - struct geotilef *type1 = (struct geotilef *) geo; + struct geotilef *tile = (struct geotilef *) geo; struct coord *pos = &prop->pos; - if ((geo->flags & (GEOFLAG_0001 | GEOFLAG_0002)) - && pos->x >= type1->vertices[type1->xmin].x - && pos->x <= type1->vertices[type1->xmax].x - && pos->z >= type1->vertices[type1->zmin].z - && pos->z <= type1->vertices[type1->zmax].z - && pos->y >= type1->vertices[type1->ymin].y - && cdIs2dPointInFltTile(type1, pos->x, pos->z) - && pos->y >= cdFindGroundInFltTile(type1, pos->x, pos->z)) { + if ((geo->flags & (GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2)) + && pos->x >= tile->vertices[tile->xmin].x + && pos->x <= tile->vertices[tile->xmax].x + && pos->z >= tile->vertices[tile->zmin].z + && pos->z <= tile->vertices[tile->zmax].z + && pos->y >= tile->vertices[tile->ymin].y + && cdIs2dPointInFltTile(tile, pos->x, pos->z) + && pos->y >= cdFindGroundInFltTile(tile, pos->x, pos->z)) { break; } - geo = (struct geo *)((u32)geo + sizeof(struct geotilef) + sizeof(struct coord) * (type1->header.numvertices - ARRAYCOUNT(type1->vertices))); + geo = (struct geo *)((u32)geo + sizeof(struct geotilef) + sizeof(struct coord) * (tile->header.numvertices - ARRAYCOUNT(tile->vertices))); } else if (geo->type == GEOTYPE_BLOCK) { geo = (struct geo *)((u32)geo + sizeof(struct geoblock)); } else if (geo->type == GEOTYPE_CYL) { @@ -873,8 +876,8 @@ void cdSetPropYBounds(struct prop *prop, f32 ymax, f32 ymin) struct geotilei *tile = (struct geotilei *) geo; geo = (struct geo *)((u32)geo + sizeof(struct geotilei) + sizeof(tile->vertices[0]) * (tile->header.numvertices - ARRAYCOUNT(tile->vertices))); } else if (geo->type == GEOTYPE_TILE_F) { - struct geotilef *type1 = (struct geotilef *) geo; - geo = (struct geo *)((u32)geo + sizeof(struct geotilef) + sizeof(struct coord) * (type1->header.numvertices - ARRAYCOUNT(type1->vertices))); + struct geotilef *tile = (struct geotilef *) geo; + geo = (struct geo *)((u32)geo + sizeof(struct geotilef) + sizeof(struct coord) * (tile->header.numvertices - ARRAYCOUNT(tile->vertices))); } else if (geo->type == GEOTYPE_BLOCK) { struct geoblock *block = (struct geoblock *) geo; block->ymax = ymax; @@ -891,7 +894,7 @@ void cdSetPropYBounds(struct prop *prop, f32 ymax, f32 ymin) } #endif -bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 flags, s32 room, struct geo **tileptr, s32 *roomptr, f32 *groundptr, bool arg8) +bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 geoflags, s32 room, struct geo **tileptr, s32 *roomptr, f32 *groundptr, bool ceiling) { bool result = false; struct geo *geo = (struct geo *) start; @@ -902,18 +905,18 @@ bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 flags, s32 room, stru if (geo->type == GEOTYPE_TILE_I) { struct geotilei *tile = (struct geotilei *) geo; - if ((geo->flags & flags) + if ((geo->flags & geoflags) && pos->x >= *(s16 *)(tile->xmin + (u32)tile) && pos->x <= *(s16 *)(tile->xmax + (u32)tile) && pos->z >= *(s16 *)(tile->zmin + (u32)tile) && pos->z <= *(s16 *)(tile->zmax + (u32)tile)) { - if ((!arg8 && pos->y >= *(s16 *)(tile->ymin + (u32)tile)) - || (arg8 && pos->y <= *(s16 *)(tile->ymax + (u32)tile))) { + if ((!ceiling && pos->y >= *(s16 *)(tile->ymin + (u32)tile)) + || (ceiling && pos->y <= *(s16 *)(tile->ymax + (u32)tile))) { if (cdIs2dPointInIntTile(tile, pos->x, pos->z)) { f32 ground = cdFindGroundInIntTile(tile, pos->x, pos->z); - if ((!arg8 && ground <= pos->y && ground > *groundptr) - || (arg8 && ground >= pos->y && ground < *groundptr)) { + if ((!ceiling && ground <= pos->y && ground > *groundptr) + || (ceiling && ground >= pos->y && ground < *groundptr)) { *groundptr = ground; *tileptr = geo; *roomptr = room; @@ -925,20 +928,20 @@ bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 flags, s32 room, stru geo = (struct geo *)((u32)geo + sizeof(struct geotilei) + sizeof(tile->vertices[0]) * (tile->header.numvertices - ARRAYCOUNT(tile->vertices))); } else if (geo->type == GEOTYPE_TILE_F) { - struct geotilef *type1 = (struct geotilef *) geo; + struct geotilef *tile = (struct geotilef *) geo; - if ((geo->flags & flags) - && pos->x >= type1->vertices[type1->xmin].x - && pos->x <= type1->vertices[type1->xmax].x - && pos->z >= type1->vertices[type1->zmin].z - && pos->z <= type1->vertices[type1->zmax].z) { - if ((!arg8 && pos->y >= type1->vertices[type1->ymin].y) - || (arg8 && pos->y <= type1->vertices[type1->ymax].y)) { - if (cdIs2dPointInFltTile(type1, pos->x, pos->z)) { - f32 ground = cdFindGroundInFltTile(type1, pos->x, pos->z); + if ((geo->flags & geoflags) + && pos->x >= tile->vertices[tile->xmin].x + && pos->x <= tile->vertices[tile->xmax].x + && pos->z >= tile->vertices[tile->zmin].z + && pos->z <= tile->vertices[tile->zmax].z) { + if ((!ceiling && pos->y >= tile->vertices[tile->ymin].y) + || (ceiling && pos->y <= tile->vertices[tile->ymax].y)) { + if (cdIs2dPointInFltTile(tile, pos->x, pos->z)) { + f32 ground = cdFindGroundInFltTile(tile, pos->x, pos->z); - if ((!arg8 && pos->y >= ground && ground > *groundptr) - || (arg8 && pos->y <= ground && ground < *groundptr)) { + if ((!ceiling && pos->y >= ground && ground > *groundptr) + || (ceiling && pos->y <= ground && ground < *groundptr)) { *groundptr = ground; *tileptr = geo; *roomptr = room; @@ -948,7 +951,7 @@ bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 flags, s32 room, stru } } - geo = (struct geo *)((u32)geo + sizeof(struct geotilef) + sizeof(struct coord) * (type1->header.numvertices - ARRAYCOUNT(type1->vertices))); + geo = (struct geo *)((u32)geo + sizeof(struct geotilef) + sizeof(struct coord) * (tile->header.numvertices - ARRAYCOUNT(tile->vertices))); } else if (geo->type == GEOTYPE_BLOCK) { geo = (struct geo *)((u32)geo + sizeof(struct geoblock)); } else if (geo->type == GEOTYPE_CYL) { @@ -959,26 +962,26 @@ bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 flags, s32 room, stru return result; } -void cd00026e7c(struct coord *pos, s16 *rooms, u16 arg2, struct geo **tileptr, s16 *arg4, f32 *arg5, struct prop **arg6, s32 arg7) +void cdFindClosestVertical(struct coord *pos, s16 *rooms, u16 geoflags, struct geo **geoptr, s16 *roomptr, f32 *groundptr, struct prop **propptr, bool ceiling) { - s16 *roomptr; + s16 *roomptr2; s32 roomnum; u8 *start; u8 *end; - f32 sp274; - struct geo *sp270 = NULL; - s32 sp26c = 0; - struct prop *sp268 = NULL; + f32 closesty; + struct geo *geo = NULL; + s32 room = 0; + struct prop *bestprop = NULL; s16 *propnumptr; s16 propnums[256]; - if (arg7) { - sp274 = 4294967296; + if (ceiling) { + closesty = 4294967296; } else { - sp274 = -4294967296; + closesty = -4294967296; } - roomptr = rooms; + roomptr2 = rooms; roomnum = rooms[0]; while (roomnum != -1) { @@ -986,11 +989,11 @@ void cd00026e7c(struct coord *pos, s16 *rooms, u16 arg2, struct geo **tileptr, s start = g_TileFileData.u8 + g_TileRooms[roomnum]; end = g_TileFileData.u8 + g_TileRooms[roomnum + 1]; - cd00026a04(pos, start, end, arg2, roomnum, &sp270, &sp26c, &sp274, arg7); + cd00026a04(pos, start, end, geoflags, roomnum, &geo, &room, &closesty, ceiling); } - roomptr++; - roomnum = *roomptr; + roomptr2++; + roomnum = *roomptr2; } roomGetProps(rooms, propnums, 256); @@ -1000,30 +1003,30 @@ void cd00026e7c(struct coord *pos, s16 *rooms, u16 arg2, struct geo **tileptr, s struct prop *prop = &g_Vars.props[*propnumptr]; if (propUpdateGeometry(prop, &start, &end) - && cd00026a04(pos, start, end, arg2, prop->rooms[0], &sp270, &sp26c, &sp274, arg7)) { - sp268 = prop; + && cd00026a04(pos, start, end, geoflags, prop->rooms[0], &geo, &room, &closesty, ceiling)) { + bestprop = prop; } propnumptr++; } - *tileptr = sp270; - *arg4 = sp26c; - *arg5 = sp274; + *geoptr = geo; + *roomptr = room; + *groundptr = closesty; - if (arg6 != NULL) { - *arg6 = sp268; + if (propptr != NULL) { + *propptr = bestprop; } } -bool cd0002709c(struct geotilei *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collisionthing *thing) +bool cd0002709cIntTile(struct geotilei *tile, f32 x, f32 z, f32 radius, struct prop *prop, struct collision *collision) { bool result = false; if (cdIs2dPointInIntTile(tile, x, z)) { - thing->geo = &tile->header; - thing->vertexindex = 0; - thing->prop = prop; + collision->geo = &tile->header; + collision->vertexindex = 0; + collision->prop = prop; result = true; } else { s32 numvertices = tile->header.numvertices; @@ -1037,13 +1040,13 @@ bool cd0002709c(struct geotilei *tile, f32 x, f32 z, f32 width, struct prop *pro value = -value; } - if (value <= width - && (cd00025724(tile->vertices[i][0], tile->vertices[i][2], x, z) <= width - || cd00025724(tile->vertices[next][0], tile->vertices[next][2], x, z) <= width + if (value <= radius + && (cd00025724(tile->vertices[i][0], tile->vertices[i][2], x, z) <= radius + || cd00025724(tile->vertices[next][0], tile->vertices[next][2], x, z) <= radius || cd00025774(tile->vertices[i][0], tile->vertices[i][2], tile->vertices[next][0], tile->vertices[next][2], x, z))) { - thing->geo = &tile->header; - thing->vertexindex = i; - thing->prop = prop; + collision->geo = &tile->header; + collision->vertexindex = i; + collision->prop = prop; result = true; break; } @@ -1053,14 +1056,14 @@ bool cd0002709c(struct geotilei *tile, f32 x, f32 z, f32 width, struct prop *pro return result; } -bool cd000272f8(struct geotilef *tile, f32 x, f32 z, f32 radius, struct prop *prop, struct collisionthing *thing) +bool cd000272f8FltTile(struct geotilef *tile, f32 x, f32 z, f32 radius, struct prop *prop, struct collision *collision) { bool result = false; if (cdIs2dPointInFltTile(tile, x, z)) { - thing->geo = &tile->header; - thing->vertexindex = 0; - thing->prop = prop; + collision->geo = &tile->header; + collision->vertexindex = 0; + collision->prop = prop; result = true; } else { s32 numvertices = tile->header.numvertices; @@ -1078,9 +1081,9 @@ bool cd000272f8(struct geotilef *tile, f32 x, f32 z, f32 radius, struct prop *pr && (cd00025724(tile->vertices[i].x, tile->vertices[i].z, x, z) <= radius || cd00025724(tile->vertices[next].x, tile->vertices[next].z, x, z) <= radius || cd00025774(tile->vertices[i].x, tile->vertices[i].z, tile->vertices[next].x, tile->vertices[next].z, x, z))) { - thing->geo = &tile->header; - thing->vertexindex = i; - thing->prop = prop; + collision->geo = &tile->header; + collision->vertexindex = i; + collision->prop = prop; result = true; break; } @@ -1090,15 +1093,15 @@ bool cd000272f8(struct geotilef *tile, f32 x, f32 z, f32 radius, struct prop *pr return result; } -s32 cd000274e0(struct geoblock *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collisionthing *thing) +s32 cd000274e0Block(struct geoblock *tile, f32 x, f32 z, f32 radius, struct prop *prop, struct collision *collision) { bool result = false; if (cdIs2dPointInBlock(tile, x, z)) { - if (thing) { - thing->geo = &tile->header; - thing->vertexindex = 0; - thing->prop = prop; + if (collision) { + collision->geo = &tile->header; + collision->vertexindex = 0; + collision->prop = prop; } result = true; @@ -1116,14 +1119,14 @@ s32 cd000274e0(struct geoblock *tile, f32 x, f32 z, f32 width, struct prop *prop value = -value; } - if (value <= width - && (cd00025724(tile->vertices[i][0], tile->vertices[i][1], x, z) <= width - || cd00025724(tile->vertices[next][0], tile->vertices[next][1], x, z) <= width + if (value <= radius + && (cd00025724(tile->vertices[i][0], tile->vertices[i][1], x, z) <= radius + || cd00025724(tile->vertices[next][0], tile->vertices[next][1], x, z) <= radius || cd00025774(tile->vertices[i][0], tile->vertices[i][1], tile->vertices[next][0], tile->vertices[next][1], x, z))) { - if (thing) { - thing->geo = &tile->header; - thing->vertexindex = i; - thing->prop = prop; + if (collision) { + collision->geo = &tile->header; + collision->vertexindex = i; + collision->prop = prop; } result = true; @@ -1135,30 +1138,32 @@ s32 cd000274e0(struct geoblock *tile, f32 x, f32 z, f32 width, struct prop *prop return result; } -bool cd000276c8(struct geocyl *cyl, f32 x, f32 z, f32 width, struct prop *prop, struct collisionthing *thing) +bool cd000276c8Cyl(struct geocyl *cyl, f32 x, f32 z, f32 radius, struct prop *prop, struct collision *collision) { bool result = false; f32 sumx = x - cyl->x; f32 sumz = z - cyl->z; - f32 sumwidth = cyl->radius + width; + f32 sumwidth = cyl->radius + radius; if (sumx * sumx + sumz * sumz <= sumwidth * sumwidth) { result = true; - if (thing) { - thing->geo = &cyl->header; - thing->vertexindex = 0; - thing->prop = prop; + if (collision) { + collision->geo = &cyl->header; + collision->vertexindex = 0; + collision->prop = prop; } } return result; } -void cd00027738(struct coord *pos, f32 radius, u8 *start, u8 *end, u16 flags, +s32 cdTestRampWall(struct geotilei *tile, struct coord *pos, f32 width, f32 y1, f32 y2); + +void cdCollectGeoForCylFromList(struct coord *pos, f32 radius, u8 *start, u8 *end, u16 geoflags, bool checkvertical, f32 arg6, f32 arg7, struct prop *prop, - struct collisionthing *things, s32 maxthings, s32 *thingnum, s32 roomnum) + struct collision *collisions, s32 maxcollisions, s32 *numcollisions, s32 roomnum) { struct geo *geo = (struct geo *) start; s32 result; @@ -1167,25 +1172,25 @@ void cd00027738(struct coord *pos, f32 radius, u8 *start, u8 *end, u16 flags, if (geo->type == GEOTYPE_TILE_I) { struct geotilei *tile = (struct geotilei *) geo; - if ((geo->flags & flags) + if ((geo->flags & geoflags) && pos->x >= *(s16 *)(tile->xmin + (u32)tile) - radius && pos->x <= *(s16 *)(tile->xmax + (u32)tile) + radius && pos->z >= *(s16 *)(tile->zmin + (u32)tile) - radius && pos->z <= *(s16 *)(tile->zmax + (u32)tile) + radius && (!checkvertical || (pos->y + arg6 >= *(s16 *)(tile->ymin + (u32)tile) && pos->y + arg7 <= *(s16 *)(tile->ymax + (u32)tile)))) { - if (geo->flags & GEOFLAG_0080) { - result = cd00028200(tile, pos, radius, pos->y + arg7, pos->y + arg6); + if (geo->flags & GEOFLAG_RAMPWALL) { + result = cdTestRampWall(tile, pos, radius, pos->y + arg7, pos->y + arg6); } else { result = 1; } if (result != 0) { - if (cd0002709c(tile, pos->x, pos->z, radius, prop, &things[*thingnum])) { - things[*thingnum].room = roomnum; - *thingnum = *thingnum + 1; + if (cd0002709cIntTile(tile, pos->x, pos->z, radius, prop, &collisions[*numcollisions])) { + collisions[*numcollisions].room = roomnum; + *numcollisions = *numcollisions + 1; - if (*thingnum >= maxthings) { + if (*numcollisions >= maxcollisions) { break; } } @@ -1197,20 +1202,20 @@ void cd00027738(struct coord *pos, f32 radius, u8 *start, u8 *end, u16 flags, struct geotilef *tile = (struct geotilef *) geo; s32 tmp = 0x40; - if ((geo->flags & flags) + if ((geo->flags & geoflags) && pos->x >= *(f32 *)((u32)tile + tile->xmin * 0xc + 0x10) - radius && pos->x <= *(f32 *)((u32)tile + tile->xmax * 0xc + 0x10) + radius && pos->z >= *(f32 *)((u32)tile + tile->zmin * 0xc + 0x18) - radius && pos->z <= *(f32 *)((u32)tile + tile->zmax * 0xc + 0x18) + radius && (!checkvertical || (pos->y + arg6 >= *(f32*)((u32)tile + tile->ymin * 0xc + 0x14) && pos->y + arg7 <= *(f32 *)((u32)tile + tile->ymax * 0xc + 0x14)))) { - result = cd000272f8(tile, pos->x, pos->z, radius, prop, &things[*thingnum]); + result = cd000272f8FltTile(tile, pos->x, pos->z, radius, prop, &collisions[*numcollisions]); if (result != 0) { - things[*thingnum].room = roomnum; - *thingnum = *thingnum + 1; + collisions[*numcollisions].room = roomnum; + *numcollisions = *numcollisions + 1; - if (*thingnum >= maxthings) { + if (*numcollisions >= maxcollisions) { break; } } @@ -1220,15 +1225,15 @@ void cd00027738(struct coord *pos, f32 radius, u8 *start, u8 *end, u16 flags, } else if (geo->type == GEOTYPE_BLOCK) { struct geoblock *block = (struct geoblock *) geo; - if ((flags & (GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE)) + if ((geoflags & (GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT)) && (!checkvertical || (pos->y + arg6 >= block->ymin && pos->y + arg7 <= block->ymax))) { - result = cd000274e0(block, pos->x, pos->z, radius, prop, &things[*thingnum]); + result = cd000274e0Block(block, pos->x, pos->z, radius, prop, &collisions[*numcollisions]); if (result) { - things[*thingnum].room = roomnum; - *thingnum = *thingnum + 1; + collisions[*numcollisions].room = roomnum; + *numcollisions = *numcollisions + 1; - if (*thingnum >= maxthings) { + if (*numcollisions >= maxcollisions) { break; } } @@ -1238,15 +1243,15 @@ void cd00027738(struct coord *pos, f32 radius, u8 *start, u8 *end, u16 flags, } else if (geo->type == GEOTYPE_CYL) { struct geocyl *cyl = (struct geocyl *) geo; - if ((flags & geo->flags) + if ((geoflags & geo->flags) && (!checkvertical || (pos->y + arg6 >= cyl->ymin && pos->y + arg7 <= cyl->ymax))) { - result = cd000276c8(cyl, pos->x, pos->z, radius, prop, &things[*thingnum]); + result = cd000276c8Cyl(cyl, pos->x, pos->z, radius, prop, &collisions[*numcollisions]); if (result) { - things[*thingnum].room = roomnum; - *thingnum = *thingnum + 1; + collisions[*numcollisions].room = roomnum; + *numcollisions = *numcollisions + 1; - if (*thingnum >= maxthings) { + if (*numcollisions >= maxcollisions) { break; } } @@ -1257,13 +1262,13 @@ void cd00027738(struct coord *pos, f32 radius, u8 *start, u8 *end, u16 flags, } } -void cd00027d1c(struct coord *pos, f32 radius, s16 *rooms, u32 types, u16 arg4, u32 arg5, f32 arg6, f32 arg7, struct collisionthing *arg8, s32 arg9) +void cdCollectGeoForCyl(struct coord *pos, f32 radius, s16 *rooms, u32 types, u16 geoflags, bool checkvertical, f32 ymax, f32 ymin, struct collision *collisions, s32 maxcollisions) { s16 *roomptr; s32 roomnum; u8 *start; u8 *end; - s32 sp294 = 0; + s32 numcollisions = 0; s16 *propnumptr; s16 propnums[256]; @@ -1277,9 +1282,9 @@ void cd00027d1c(struct coord *pos, f32 radius, s16 *rooms, u32 types, u16 arg4, start = g_TileFileData.u8 + g_TileRooms[roomnum]; end = g_TileFileData.u8 + g_TileRooms[roomnum + 1]; - cd00027738(pos, radius, start, end, arg4, arg5, arg6, arg7, NULL, arg8, arg9, &sp294, roomnum); + cdCollectGeoForCylFromList(pos, radius, start, end, geoflags, checkvertical, ymax, ymin, NULL, collisions, maxcollisions, &numcollisions, roomnum); - if (sp294 >= arg9) { + if (numcollisions >= maxcollisions) { goto end; } } @@ -1297,9 +1302,9 @@ void cd00027d1c(struct coord *pos, f32 radius, s16 *rooms, u32 types, u16 arg4, struct prop *prop = &g_Vars.props[*propnumptr]; if (propIsOfCdType(prop, types) && propUpdateGeometry(prop, &start, &end)) { - cd00027738(pos, radius, start, end, arg4, arg5, arg6, arg7, prop, arg8, arg9, &sp294, prop->rooms[0]); + cdCollectGeoForCylFromList(pos, radius, start, end, geoflags, checkvertical, ymax, ymin, prop, collisions, maxcollisions, &numcollisions, prop->rooms[0]); - if (sp294 >= arg9) { + if (numcollisions >= maxcollisions) { break; } } @@ -1308,10 +1313,10 @@ void cd00027d1c(struct coord *pos, f32 radius, s16 *rooms, u32 types, u16 arg4, } end: - arg8[sp294].geo = NULL; + collisions[numcollisions].geo = NULL; } -void cd00027f78(struct geotilei *tile, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex) +void cd00027f78(struct geotilei *tile, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collision *collisions, s32 maxcollisions, s32 *numcollisions) { s32 i; s32 numvertices = tile->header.numvertices; @@ -1330,11 +1335,11 @@ void cd00027f78(struct geotilei *tile, f32 arg1, f32 arg2, f32 arg3, struct prop && (cd00025724(tile->vertices[i][0], tile->vertices[i][2], arg1, arg2) <= arg3 || cd00025724(tile->vertices[next][0], tile->vertices[next][2], arg1, arg2) <= arg3 || cd00025774(tile->vertices[i][0], tile->vertices[i][2], tile->vertices[next][0], tile->vertices[next][2], arg1, arg2))) { - if (*thingindex < maxthings) { - things[*thingindex].geo = &tile->header; - things[*thingindex].vertexindex = i; - things[*thingindex].prop = prop; - *thingindex += 1; + if (*numcollisions < maxcollisions) { + collisions[*numcollisions].geo = &tile->header; + collisions[*numcollisions].vertexindex = i; + collisions[*numcollisions].prop = prop; + *numcollisions += 1; } else { break; } @@ -1343,7 +1348,17 @@ void cd00027f78(struct geotilei *tile, f32 arg1, f32 arg2, f32 arg3, struct prop } } -s32 cd00028200(struct geotilei *tile, struct coord *pos, f32 width, f32 y1, f32 y2) +/** + * Triangular wall tiles are generally implemented with just a bounding box check, + * but this means if the player gets on top of one they can walk across it. + * This is a problem for ramps that the player can jump off at any height + * such as the Air Base staircase near the baggage terminal. + * + * To handle this, the ramp wall tiles are flagged with GEOFLAG_RAMPWALL. + * When collision checks are being done, tiles with this flag are passed to + * this function which does a more extensive check. + */ +s32 cdTestRampWall(struct geotilei *tile, struct coord *pos, f32 width, f32 y1, f32 y2) { s32 count; s32 i; @@ -1351,7 +1366,7 @@ s32 cd00028200(struct geotilei *tile, struct coord *pos, f32 width, f32 y1, f32 s32 y2count; s32 numverts; - if (!g_Vars.enableslopes && (tile->header.flags & GEOFLAG_0100)) { + if (!g_Vars.enableslopes && (tile->header.flags & GEOFLAG_SLOPE)) { return 0; } @@ -1427,7 +1442,7 @@ s32 cd00028200(struct geotilei *tile, struct coord *pos, f32 width, f32 y1, f32 return count; } -void cd0002840c(struct geotilef *tile, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex) +void cd0002840c(struct geotilef *tile, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collision *collisions, s32 maxcollisions, s32 *numcollisions) { s32 i; s32 numvertices = tile->header.numvertices; @@ -1446,11 +1461,11 @@ void cd0002840c(struct geotilef *tile, f32 arg1, f32 arg2, f32 arg3, struct prop && (cd00025724(tile->vertices[i].x, tile->vertices[i].z, arg1, arg2) <= arg3 || cd00025724(tile->vertices[next].x, tile->vertices[next].z, arg1, arg2) <= arg3 || cd00025774(tile->vertices[i].x, tile->vertices[i].z, tile->vertices[next].x, tile->vertices[next].z, arg1, arg2))) { - if (*thingindex < maxthings) { - things[*thingindex].geo = &tile->header; - things[*thingindex].vertexindex = i; - things[*thingindex].prop = prop; - *thingindex += 1; + if (*numcollisions < maxcollisions) { + collisions[*numcollisions].geo = &tile->header; + collisions[*numcollisions].vertexindex = i; + collisions[*numcollisions].prop = prop; + *numcollisions += 1; } else { break; } @@ -1459,7 +1474,7 @@ void cd0002840c(struct geotilef *tile, f32 arg1, f32 arg2, f32 arg3, struct prop } } -void cd00028638(struct geoblock *block, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex) +void cd00028638(struct geoblock *block, f32 arg1, f32 arg2, f32 arg3, struct prop *prop, struct collision *collisions, s32 maxcollisions, s32 *numcollisions) { s32 i; s32 numvertices = block->header.numvertices; @@ -1478,11 +1493,11 @@ void cd00028638(struct geoblock *block, f32 arg1, f32 arg2, f32 arg3, struct pro && (cd00025724(block->vertices[i][0], block->vertices[i][1], arg1, arg2) <= arg3 || cd00025724(block->vertices[next][0], block->vertices[next][1], arg1, arg2) <= arg3 || cd00025774(block->vertices[i][0], block->vertices[i][1], block->vertices[next][0], block->vertices[next][1], arg1, arg2))) { - if (*thingindex < maxthings) { - things[*thingindex].geo = &block->header; - things[*thingindex].vertexindex = i; - things[*thingindex].prop = prop; - *thingindex += 1; + if (*numcollisions < maxcollisions) { + collisions[*numcollisions].geo = &block->header; + collisions[*numcollisions].vertexindex = i; + collisions[*numcollisions].prop = prop; + *numcollisions += 1; } else { break; } @@ -1491,25 +1506,25 @@ void cd00028638(struct geoblock *block, f32 arg1, f32 arg2, f32 arg3, struct pro } } -void cd0002885c(struct geocyl *cyl, f32 x, f32 z, f32 arg3, struct prop *prop, struct collisionthing *things, s32 maxthings, s32 *thingindex) +void cd0002885c(struct geocyl *cyl, f32 x, f32 z, f32 arg3, struct prop *prop, struct collision *collisions, s32 maxcollisions, s32 *numcollisions) { f32 xdiff = x - cyl->x; f32 zdiff = z - cyl->z; f32 f16 = arg3 + cyl->radius; if (xdiff * xdiff + zdiff * zdiff <= f16 * f16) { - if (*thingindex < maxthings) { - things[*thingindex].geo = &cyl->header; - things[*thingindex].vertexindex = 0; - things[*thingindex].prop = prop; - *thingindex += 1; + if (*numcollisions < maxcollisions) { + collisions[*numcollisions].geo = &cyl->header; + collisions[*numcollisions].vertexindex = 0; + collisions[*numcollisions].prop = prop; + *numcollisions += 1; } } } -void cd00028914(u8 *start, u8 *end, struct coord *pos, f32 radius, u16 flags, +void cdCollectGeoForCylMoveFromList(u8 *start, u8 *end, struct coord *pos, f32 radius, u16 geoflags, bool checkvertical, f32 arg6, f32 arg7, struct prop *prop, - struct collisionthing *things, s32 maxthings, s32 *thingindex) + struct collision *collisions, s32 maxcollisions, s32 *numcollisions) { struct geo *geo = (struct geo *) start; @@ -1517,7 +1532,7 @@ void cd00028914(u8 *start, u8 *end, struct coord *pos, f32 radius, u16 flags, if (geo->type == GEOTYPE_TILE_I) { struct geotilei *tile = (struct geotilei *) geo; - if (geo->flags & flags) { + if (geo->flags & geoflags) { if (pos->x >= *(s16 *)(tile->xmin + (u32)tile) - radius && pos->x <= *(s16 *)(tile->xmax + (u32)tile) + radius && pos->z >= *(s16 *)(tile->zmin + (u32)tile) - radius @@ -1526,14 +1541,14 @@ void cd00028914(u8 *start, u8 *end, struct coord *pos, f32 radius, u16 flags, && pos->y + arg7 <= *(s16 *)(tile->ymax + (u32)tile)))) { bool pass; - if (geo->flags & GEOFLAG_0080) { - pass = cd00028200(tile, pos, radius, pos->y + arg7, pos->y + arg6); + if (geo->flags & GEOFLAG_RAMPWALL) { + pass = cdTestRampWall(tile, pos, radius, pos->y + arg7, pos->y + arg6); } else { pass = true; } if (pass) { - cd00027f78(tile, pos->x, pos->z, radius, prop, things, maxthings, thingindex); + cd00027f78(tile, pos->x, pos->z, radius, prop, collisions, maxcollisions, numcollisions); } } } @@ -1542,32 +1557,32 @@ void cd00028914(u8 *start, u8 *end, struct coord *pos, f32 radius, u16 flags, } else if (geo->type == GEOTYPE_TILE_F) { struct geotilef *tile = (struct geotilef *) geo; - if ((geo->flags & flags) + if ((geo->flags & geoflags) && pos->x >= tile->vertices[tile->xmin].x - radius && pos->x <= tile->vertices[tile->xmax].x + radius && pos->z >= tile->vertices[tile->zmin].z - radius && pos->z <= tile->vertices[tile->zmax].z + radius && (!checkvertical || (pos->y + arg6 >= tile->vertices[tile->ymin].y && pos->y + arg7 <= tile->vertices[tile->ymax].y))) { - cd0002840c(tile, pos->x, pos->z, radius, prop, things, maxthings, thingindex); + cd0002840c(tile, pos->x, pos->z, radius, prop, collisions, maxcollisions, numcollisions); } geo = (struct geo *)((u32)geo + (u32)(tile->header.numvertices - 0x40) * 0xc + 0x310); } else if (geo->type == GEOTYPE_BLOCK) { struct geoblock *block = (struct geoblock *) geo; - if ((flags & (GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE)) + if ((geoflags & (GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT)) && (!checkvertical || (pos->y + arg6 >= block->ymin && pos->y + arg7 <= block->ymax))) { - cd00028638(block, pos->x, pos->z, radius, prop, things, maxthings, thingindex); + cd00028638(block, pos->x, pos->z, radius, prop, collisions, maxcollisions, numcollisions); } geo = (struct geo *)((u32)geo + sizeof(struct geoblock)); } else if (geo->type == GEOTYPE_CYL) { struct geocyl *cyl = (struct geocyl *) geo; - if ((flags & geo->flags) + if ((geoflags & geo->flags) && (!checkvertical || (pos->y + arg6 >= cyl->ymin && pos->y + arg7 <= cyl->ymax))) { - cd0002885c(cyl, pos->x, pos->z, radius, prop, things, maxthings, thingindex); + cd0002885c(cyl, pos->x, pos->z, radius, prop, collisions, maxcollisions, numcollisions); } geo = (struct geo *)((u32)geo + sizeof(struct geocyl)); @@ -1575,13 +1590,13 @@ void cd00028914(u8 *start, u8 *end, struct coord *pos, f32 radius, u16 flags, } } -void cd00028df0(struct coord *pos, f32 width, s16 *rooms, u32 types, u16 arg4, u32 arg5, f32 ymax, f32 ymin, struct collisionthing *arg8, s32 arg9) +void cdCollectGeoForCylMove(struct coord *pos, f32 width, s16 *rooms, u32 types, u16 geoflags, bool checkvertical, f32 ymax, f32 ymin, struct collision *collisions, s32 maxcollisions) { s16 *roomptr; s32 roomnum; u8 *start; u8 *end; - s32 sp294 = 0; + s32 numcollisions = 0; s16 *propnumptr; s16 propnums[256]; @@ -1595,7 +1610,7 @@ void cd00028df0(struct coord *pos, f32 width, s16 *rooms, u32 types, u16 arg4, u start = g_TileFileData.u8 + g_TileRooms[roomnum]; end = g_TileFileData.u8 + g_TileRooms[roomnum + 1]; - cd00028914(start, end, pos, width, arg4, arg5, ymax, ymin, NULL, arg8, arg9, &sp294); + cdCollectGeoForCylMoveFromList(start, end, pos, width, geoflags, checkvertical, ymax, ymin, NULL, collisions, maxcollisions, &numcollisions); } roomptr++; @@ -1611,16 +1626,16 @@ void cd00028df0(struct coord *pos, f32 width, s16 *rooms, u32 types, u16 arg4, u struct prop *prop = &g_Vars.props[*propnumptr]; if (propIsOfCdType(prop, types) && propUpdateGeometry(prop, &start, &end)) { - cd00028914(start, end, pos, width, arg4, arg5, ymax, ymin, prop, arg8, arg9, &sp294); + cdCollectGeoForCylMoveFromList(start, end, pos, width, geoflags, checkvertical, ymax, ymin, prop, collisions, maxcollisions, &numcollisions); } propnumptr++; } - arg8[sp294].geo = NULL; + collisions[numcollisions].geo = NULL; } -void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisionthing *things) +void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collision *collisions) { s32 i; struct widthxz spf8; @@ -1629,7 +1644,7 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi struct xz spe0; f32 bestvalue = 0.0f; s32 bestindex = -1; - struct collisionthing *bestthing; + u32 stack; f32 value; s32 curr; s32 next; @@ -1637,7 +1652,7 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi struct coord vtx2; struct geo *geo; - for (i = 0; (geo = things[i].geo) != NULL; i++) { + for (i = 0; (geo = collisions[i].geo) != NULL; i++) { if (1); if (geo->type == GEOTYPE_TILE_I) { struct geotilei *tile = (struct geotilei *) geo; @@ -1649,7 +1664,7 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi spe0.x = dist->x; spe0.z = dist->z; - curr = things[i].vertexindex; + curr = collisions[i].vertexindex; next = (curr + 1) % tile->header.numvertices; spf0.x = tile->vertices[curr][0]; @@ -1674,7 +1689,7 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi spe0.x = dist->x; spe0.z = dist->z; - curr = things[i].vertexindex; + curr = collisions[i].vertexindex; next = (curr + 1) % tile->header.numvertices; spf0.x = tile->vertices[curr].x; @@ -1699,7 +1714,7 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi spe0.x = dist->x; spe0.z = dist->z; - curr = things[i].vertexindex; + curr = collisions[i].vertexindex; next = (curr + 1) % block->header.numvertices; spf0.x = block->vertices[curr][0]; @@ -1739,9 +1754,9 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi } } - if (things[bestindex].geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile = (struct geotilei *) things[bestindex].geo; - s32 curr = things[bestindex].vertexindex; + if (collisions[bestindex].geo->type == GEOTYPE_TILE_I) { + struct geotilei *tile = (struct geotilei *) collisions[bestindex].geo; + s32 curr = collisions[bestindex].vertexindex; s32 next = (curr + 1) % tile->header.numvertices; vtx1.x = tile->vertices[curr][0]; @@ -1751,9 +1766,9 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi vtx2.x = tile->vertices[next][0]; vtx2.y = tile->vertices[next][1]; vtx2.z = tile->vertices[next][2]; - } else if (things[bestindex].geo->type == GEOTYPE_TILE_F) { - struct geotilef *tile = (struct geotilef *) things[bestindex].geo; - s32 curr = things[bestindex].vertexindex; + } else if (collisions[bestindex].geo->type == GEOTYPE_TILE_F) { + struct geotilef *tile = (struct geotilef *) collisions[bestindex].geo; + s32 curr = collisions[bestindex].vertexindex; s32 next = (curr + 1) % tile->header.numvertices; vtx1.x = tile->vertices[curr].x; @@ -1763,9 +1778,9 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi vtx2.x = tile->vertices[next].x; vtx2.y = tile->vertices[next].y; vtx2.z = tile->vertices[next].z; - } else if (things[bestindex].geo->type == GEOTYPE_BLOCK) { - struct geoblock *block = (struct geoblock *) things[bestindex].geo; - s32 curr = things[bestindex].vertexindex; + } else if (collisions[bestindex].geo->type == GEOTYPE_BLOCK) { + struct geoblock *block = (struct geoblock *) collisions[bestindex].geo; + s32 curr = collisions[bestindex].vertexindex; s32 next = (curr + 1) % block->header.numvertices; vtx1.x = block->vertices[curr][0]; @@ -1775,8 +1790,8 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi vtx2.x = block->vertices[next][0]; vtx2.y = pos->y; vtx2.z = block->vertices[next][1]; - } else if (things[bestindex].geo->type == GEOTYPE_CYL) { - struct geocyl *cyl = (struct geocyl *) things[bestindex].geo; + } else if (collisions[bestindex].geo->type == GEOTYPE_CYL) { + struct geocyl *cyl = (struct geocyl *) collisions[bestindex].geo; cd00025848(cyl->x, cyl->z, cyl->radius, pos->x, pos->z, &vtx1.x, &vtx1.z, &vtx2.x, &vtx2.z); @@ -1784,15 +1799,15 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi vtx2.y = pos->y; } - cd00025038(&vtx1, &vtx2, things[bestindex].prop, bestvalue); + cdSetObstacleVtxPropFlt(&vtx1, &vtx2, collisions[bestindex].prop, bestvalue); } #if VERSION >= VERSION_NTSC_1_0 // NTSC beta mismatches due to swapped s5/s6 registers -// thing should be s6; next should be s5 -f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisionthing **thingptr, f32 width) +// collision should be s6; next should be s5 +f32 cdFindGroundFromList(struct collision *collisions, struct coord *pos, struct collision **collisionptr, f32 width) { - struct collisionthing *thing; + struct collision *collision; s32 i; f32 curground = -4294967296; bool hasground = false; @@ -1834,76 +1849,76 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio f32 thisx; f32 thisz; - *thingptr = NULL; + *collisionptr = NULL; - for (thing = things; thing->geo != NULL; thing++) { - if (thing->geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile = (struct geotilei *) thing->geo; + for (collision = collisions; collision->geo != NULL; collision++) { + if (collision->geo->type == GEOTYPE_TILE_I) { + struct geotilei *tile = (struct geotilei *) collision->geo; if (tile->header.flags & GEOFLAG_DIE) { - thing->intile = false; + collision->intile = false; } else { - if (tile->header.flags & GEOFLAG_0100) { + if (tile->header.flags & GEOFLAG_SLOPE) { hasflag0100 = true; } - thing->intile = cdIs2dPointInIntTile(tile, pos->x, pos->z); + collision->intile = cdIs2dPointInIntTile(tile, pos->x, pos->z); - if (thing->intile) { + if (collision->intile) { anyintile = true; } } - } else if (thing->geo->type == GEOTYPE_TILE_F) { - struct geotilef *tile = (struct geotilef *) thing->geo; + } else if (collision->geo->type == GEOTYPE_TILE_F) { + struct geotilef *tile = (struct geotilef *) collision->geo; - thing->intile = cdIs2dPointInFltTile(tile, pos->x, pos->z); + collision->intile = cdIs2dPointInFltTile(tile, pos->x, pos->z); - if (thing->intile) { + if (collision->intile) { anyintile = true; } } } if (anyintile) { - for (thing = things; thing->geo != NULL; thing++) { - if (thing->intile) { - if (thing->geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile = (struct geotilei *) thing->geo; + for (collision = collisions; collision->geo != NULL; collision++) { + if (collision->intile) { + if (collision->geo->type == GEOTYPE_TILE_I) { + struct geotilei *tile = (struct geotilei *) collision->geo; if ((tile->header.flags & GEOFLAG_STEP) == 0) { - ground = cdFindGroundInIntTile((void *)thing->geo, pos->x, pos->z); + ground = cdFindGroundInIntTile((void *)collision->geo, pos->x, pos->z); if (ground >= curground && ground < pos->y) { curground = ground; - *thingptr = thing; + *collisionptr = collision; hasground = true; } } - } else if (thing->geo->type == GEOTYPE_TILE_F) { - struct geotilef *tile = (struct geotilef *) thing->geo; + } else if (collision->geo->type == GEOTYPE_TILE_F) { + struct geotilef *tile = (struct geotilef *) collision->geo; - ground = cdFindGroundInFltTile((void *)thing->geo, pos->x, pos->z); + ground = cdFindGroundInFltTile((void *)collision->geo, pos->x, pos->z); if (ground >= curground && ground < pos->y) { curground = ground; - *thingptr = thing; + *collisionptr = collision; hasground = true; } } } } - for (thing = things; thing->geo != NULL; thing++) { - if (thing->intile) { - if (thing->geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile = (struct geotilei *) thing->geo; + for (collision = collisions; collision->geo != NULL; collision++) { + if (collision->intile) { + if (collision->geo->type == GEOTYPE_TILE_I) { + struct geotilei *tile = (struct geotilei *) collision->geo; if (tile->header.flags & GEOFLAG_STEP) { - ground = cdFindGroundInIntTile((void *)thing->geo, pos->x, pos->z); + ground = cdFindGroundInIntTile((void *)collision->geo, pos->x, pos->z); if (ground >= curground && (ground < pos->y || !hasground)) { curground = ground; - *thingptr = thing; + *collisionptr = collision; hasground = true; } } @@ -1919,17 +1934,17 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio if (!hasground || hasflag0100) { spe4 = 4294967296.0f; - for (thing = things; thing->geo != NULL; thing++) { + for (collision = collisions; collision->geo != NULL; collision++) { #if VERSION >= VERSION_NTSC_1_0 - if (thing->intile == false - && (!hasgroundfromearlier || (thing->geo->type == GEOTYPE_TILE_I && (thing->geo->flags & GEOFLAG_0100)))) + if (collision->intile == false + && (!hasgroundfromearlier || (collision->geo->type == GEOTYPE_TILE_I && (collision->geo->flags & GEOFLAG_SLOPE)))) #else - if (thing->intile == false - && (!hasground || (thing->geo->type == GEOTYPE_TILE_I && (thing->geo->flags & GEOFLAG_0100)))) + if (collision->intile == false + && (!hasground || (collision->geo->type == GEOTYPE_TILE_I && (collision->geo->flags & GEOFLAG_SLOPE)))) #endif { - if (thing->geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile = (struct geotilei *) thing->geo; + if (collision->geo->type == GEOTYPE_TILE_I) { + struct geotilei *tile = (struct geotilei *) collision->geo; numvertices = tile->header.numvertices; #if VERSION >= VERSION_NTSC_1_0 isdie = (tile->header.flags & GEOFLAG_DIE) != 0; @@ -1970,9 +1985,9 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio ground = cdFindGroundInIntTileAtVertex(tile, x, z, i); - if (ground < pos->y || (thing->geo->flags & GEOFLAG_STEP)) { + if (ground < pos->y || (collision->geo->flags & GEOFLAG_STEP)) { curground = ground; - *thingptr = thing; + *collisionptr = collision; spe4 = f30; #if VERSION >= VERSION_NTSC_1_0 hasground = true; @@ -1994,9 +2009,9 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio z = tile->vertices[i][2]; ground = cdFindGroundInIntTileAtVertex(tile, x, z, i); - if (ground < pos->y || (thing->geo->flags & GEOFLAG_STEP)) { + if (ground < pos->y || (collision->geo->flags & GEOFLAG_STEP)) { curground = ground; - *thingptr = thing; + *collisionptr = collision; spe4 = thisvalue; #if VERSION >= VERSION_NTSC_1_0 hasground = true; @@ -2015,9 +2030,9 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio z = tile->vertices[next][2]; ground = cdFindGroundInIntTileAtVertex(tile, x, z, i); - if (ground < pos->y || (thing->geo->flags & GEOFLAG_STEP)) { + if (ground < pos->y || (collision->geo->flags & GEOFLAG_STEP)) { curground = ground; - *thingptr = thing; + *collisionptr = collision; spe4 = nextvalue; #if VERSION >= VERSION_NTSC_1_0 hasground = true; @@ -2030,8 +2045,8 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio } } } - } else if (thing->geo->type == GEOTYPE_TILE_F) { - struct geotilef *tile = (struct geotilef *) thing->geo; + } else if (collision->geo->type == GEOTYPE_TILE_F) { + struct geotilef *tile = (struct geotilef *) collision->geo; s32 numvertices = tile->header.numvertices; s32 i; @@ -2063,7 +2078,7 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio if (ground < pos->y) { curground = ground; - *thingptr = thing; + *collisionptr = collision; spe4 = f30; #if VERSION >= VERSION_NTSC_1_0 hasground = true; @@ -2082,7 +2097,7 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio if (ground < pos->y) { curground = ground; - *thingptr = thing; + *collisionptr = collision; spe4 = thisvalue; #if VERSION >= VERSION_NTSC_1_0 hasground = true; @@ -2098,7 +2113,7 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio if (ground < pos->y) { curground = ground; - *thingptr = thing; + *collisionptr = collision; spe4 = nextvalue; #if VERSION >= VERSION_NTSC_1_0 hasground = true; @@ -2119,7 +2134,7 @@ f32 cd000296a0(struct collisionthing *things, struct coord *pos, struct collisio } #else GLOBAL_ASM( -glabel cd000296a0 +glabel cdFindGroundFromList /* 2ab9c: 27bdfef8 */ addiu $sp,$sp,-264 /* 2aba0: 3c01cf80 */ lui $at,0xcf80 /* 2aba4: 44812000 */ mtc1 $at,$f4 @@ -2719,20 +2734,24 @@ glabel cd000296a0 ); #endif -bool cd00029ffc(struct coord *pos, f32 width, f32 foreheadheight, f32 inversefeettoeyesheight, s16 *rooms, u16 arg5, struct coord *laddernormal) +/** + * Test if the given cylindar is intersecting a tile with the given geoflags. + * If so, populate the laddernormal argument and return true. + * + * There is nothing specific to ladders in this function, but it's only used + * for finding ladders. + */ +bool cdFindLadder(struct coord *pos, f32 width, f32 ymax, f32 ymin, s16 *rooms, u16 geoflags, struct coord *laddernormal) { - u32 stack[5]; - struct collisionthing thing; + struct collision collisions[2]; - cd00027d1c(pos, width, rooms, CDTYPE_BG, - arg5, 1, foreheadheight, inversefeettoeyesheight, - &thing, 1); + cdCollectGeoForCyl(pos, width, rooms, CDTYPE_BG, geoflags, CHECKVERTICAL_YES, ymax, ymin, collisions, 1); - if (thing.geo) { - struct geotilei *tile = (struct geotilei *) thing.geo; + if (collisions[0].geo) { + struct geotilei *tile = (struct geotilei *) collisions[0].geo; struct coord dist; - cd00025928(thing.geo, laddernormal); + cdGetGeoNormal(collisions[0].geo, laddernormal); dist.x = pos->x - tile->vertices[0][0]; dist.y = pos->y - tile->vertices[0][1]; @@ -2750,30 +2769,29 @@ bool cd00029ffc(struct coord *pos, f32 width, f32 foreheadheight, f32 inversefee return false; } -bool cd0002a13c(struct coord *pos, f32 radius, f32 arg2, f32 arg3, s16 *rooms, u16 arg5) +bool cd0002a13c(struct coord *pos, f32 radius, f32 ymax, f32 ymin, s16 *rooms, u16 geoflags) { - u32 stack[5]; - struct collisionthing thing; + struct collision collisions[2]; - cd00027d1c(pos, radius, rooms, CDTYPE_BG, arg5, 1, arg2, arg3, &thing, 1); + cdCollectGeoForCyl(pos, radius, rooms, CDTYPE_BG, geoflags, CHECKVERTICAL_YES, ymax, ymin, collisions, 1); - if (thing.geo) { + if (collisions[0].geo) { return true; } return false; } -f32 cdFindGroundY(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, +f32 cdFindGroundInfoAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype, u16 *floorflags, s16 *floorroom, s32 *inlift, struct prop **lift) { - struct collisionthing cdthings[21]; - struct collisionthing *sp72 = NULL; + struct collision collisions[21]; + struct collision *sp72 = NULL; f32 ground; struct geo *geo = NULL; - cd00027d1c(pos, radius, rooms, CDTYPE_ALL, 3, 0, 0, 0, cdthings, 20); - ground = cd000296a0(cdthings, pos, &sp72, radius); + cdCollectGeoForCyl(pos, radius, rooms, CDTYPE_ALL, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, CHECKVERTICAL_NO, 0, 0, collisions, 20); + ground = cdFindGroundFromList(collisions, pos, &sp72, radius); if (sp72) { geo = sp72->geo; @@ -2817,30 +2835,30 @@ f32 cdFindGroundY(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, } /** - * This function must come immediately after cdFindGroundY. + * This function must come immediately after cdFindGroundInfoAtCyl. * * A piracy check looks for this function, then backtracks two instructions to - * nop the jr ra at the end of cdFindGroundY, causing it to flow into this + * nop the jr ra at the end of cdFindGroundInfoAtCyl, causing it to flow into this * function and return 0. */ -f32 cd0002a324(void) +f32 cdReturnZero(void) { return 0; } -f32 cdFindGroundYSimple(struct coord *pos, f32 width, s16 *rooms, u16 *floorcol, u8 *floortype) +f32 cdFindGroundAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype) { - return cdFindGroundY(pos, width, rooms, floorcol, floortype, NULL, NULL, NULL, NULL); + return cdFindGroundInfoAtCyl(pos, radius, rooms, floorcol, floortype, NULL, NULL, NULL, NULL); } -f32 cd0002a36c(struct coord *coord, s16 *rooms, u16 *floorcol, u8 *floortype) +f32 cdFindFloorYColourTypeAtPos(struct coord *pos, s16 *rooms, u16 *floorcol, u8 *floortype) { struct geo *geo; s16 sp30[2]; f32 sp2c; f32 result = -4294967296; - cd00026e7c(coord, rooms, 3, &geo, &sp30[1], &sp2c, NULL, 0); + cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &sp30[1], &sp2c, NULL, SURFACE_FLOOR); if (geo) { result = sp2c; @@ -2857,28 +2875,28 @@ f32 cd0002a36c(struct coord *coord, s16 *rooms, u16 *floorcol, u8 *floortype) return result; } -s32 cdFindRoom(struct coord *pos, s16 *nearrooms) +s32 cdFindFloorRoomAtPos(struct coord *pos, s16 *nearrooms) { struct geo *geo; s16 room; f32 sp2c; - cd00026e7c(pos, nearrooms, 3, &geo, &room, &sp2c, 0, 0); + cdFindClosestVertical(pos, nearrooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &room, &sp2c, 0, SURFACE_FLOOR); return room; } #if VERSION >= VERSION_NTSC_1_0 -s16 cd0002a440(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) +s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) #else -s16 cd0002a440(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) +s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) #endif { struct geo *geo; s16 room; f32 sp2c; - cd00026e7c(pos, rooms, 3, &geo, &room, &sp2c, NULL, 0); + cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &room, &sp2c, NULL, SURFACE_FLOOR); if (geo != NULL) { *arg2 = sp2c; @@ -2898,16 +2916,16 @@ s16 cd0002a440(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) } #if VERSION >= VERSION_NTSC_1_0 -s16 cd0002a4d0(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) +s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) #else -s16 cd0002a4d0(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) +s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) #endif { struct geo *geo; s16 sp32; f32 sp2c; - cd00026e7c(pos, rooms, 3, &geo, &sp32, &sp2c, NULL, 1); + cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &sp32, &sp2c, NULL, SURFACE_CEILING); if (geo != NULL) { *arg2 = sp2c; @@ -2926,37 +2944,37 @@ s16 cd0002a4d0(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) return sp32; } -s16 cd0002a564(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, struct coord *arg4, struct prop **propptr) +s16 cdFindFloorRoomYColourNormalPropAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, struct coord *normal, struct prop **propptr) { struct geo *geo; - s16 sp32; + s16 room; f32 sp2c; - cd00026e7c(pos, rooms, 3, &geo, &sp32, &sp2c, propptr, 0); + cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &room, &sp2c, propptr, SURFACE_FLOOR); if (geo) { *arg2 = sp2c; - cd00025928(geo, arg4); + cdGetGeoNormal(geo, normal); } if (floorcol) { cdGetFloorCol(geo, floorcol); } - return sp32; + return room; } -s16 cd0002a5e4(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, u16 *flagsptr, struct coord *arg5) +s16 cdFindCeilingRoomYColourFlagsNormalAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, u16 *flagsptr, struct coord *normal) { struct geo *geo; s16 sp32; f32 sp2c; - cd00026e7c(pos, rooms, 3, &geo, &sp32, &sp2c, NULL, 1); + cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &sp32, &sp2c, NULL, SURFACE_CEILING); if (geo) { *arg2 = sp2c; - cd00025928(geo, arg5); + cdGetGeoNormal(geo, normal); } if (floorcol) { @@ -2973,16 +2991,16 @@ s16 cd0002a5e4(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, u16 *fla /** * Tests if a cylinder volume fits in the given position. */ -s32 cdTestVolume(struct coord *pos, f32 width, s16 *rooms, s32 types, s32 arg4, f32 ymax, f32 ymin) +s32 cdTestVolume(struct coord *pos, f32 width, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) { - struct collisionthing cdthings[2]; + struct collision collisions[2]; bool result = true; - cd00027d1c(pos, width, rooms, types, 4, arg4, ymax, ymin, cdthings, 1); + cdCollectGeoForCyl(pos, width, rooms, types, GEOFLAG_WALL, checkvertical, ymax, ymin, collisions, 1); - if (cdthings[0].geo) { + if (collisions[0].geo) { result = false; - cd00025168(cdthings[0].prop); + cdSetObstacleProp(collisions[0].prop); } return result; @@ -2990,7 +3008,7 @@ s32 cdTestVolume(struct coord *pos, f32 width, s16 *rooms, s32 types, s32 arg4, #if MATCHING GLOBAL_ASM( -glabel cd0002a6fc +glabel cdExamCylMove01 /* 2a6fc: 27bdff58 */ addiu $sp,$sp,-168 /* 2a700: 44866000 */ mtc1 $a2,$f12 /* 2a704: afb00030 */ sw $s0,0x30($sp) @@ -3015,7 +3033,7 @@ glabel cd0002a6fc /* 2a750: 8fa700b8 */ lw $a3,0xb8($sp) /* 2a754: afb80014 */ sw $t8,0x14($sp) /* 2a758: e7a40018 */ swc1 $f4,0x18($sp) -/* 2a75c: 0c009f47 */ jal cd00027d1c +/* 2a75c: 0c009f47 */ jal cdCollectGeoForCyl /* 2a760: e7a6001c */ swc1 $f6,0x1c($sp) /* 2a764: 8fa90080 */ lw $t1,0x80($sp) /* 2a768: 5120009d */ beqzl $t1,.L0002a9e0 @@ -3183,7 +3201,7 @@ glabel cd0002a6fc .L0002a9cc: /* 2a9cc: 27a40070 */ addiu $a0,$sp,0x70 /* 2a9d0: 27a50064 */ addiu $a1,$sp,0x64 -/* 2a9d4: 0c0093ec */ jal cd00024fb0 +/* 2a9d4: 0c0093ec */ jal cdSetObstacleVtxProp /* 2a9d8: 8fa6008c */ lw $a2,0x8c($sp) /* 2a9dc: 8fbf0034 */ lw $ra,0x34($sp) .L0002a9e0: @@ -3194,27 +3212,26 @@ glabel cd0002a6fc ); #else // Mismatch: Goal copies geo from t1 to v0 in the type 0 block -s32 cd0002a6fc(struct coord *pos, struct coord *pos2, f32 width, s16 *rooms, s32 types, bool arg5, f32 arg6, f32 arg7) +s32 cdExamCylMove01(struct coord *pos, struct coord *pos2, f32 radius, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) { - u32 stack[5]; - struct collisionthing thing; // 80 + struct collision collisions[2]; // 80 s32 cdresult; struct coord sp70; struct coord sp64; cdresult = CDRESULT_NOCOLLISION; - cd00027d1c(pos2, width, rooms, types, 4, arg5, arg6, arg7, &thing, 1); + cdCollectGeoForCyl(pos2, radius, rooms, types, GEOFLAG_WALL, checkvertical, ymax, ymin, collisions, 1); // 768 - if (thing.geo != NULL) { + if (collisions[0].geo != NULL) { cdresult = CDRESULT_COLLISION; // 778 - if (thing.geo->type == GEOTYPE_TILE_I) { - struct geotilei *tile = (struct geotilei *) thing.geo; - s32 this = thing.vertexindex; - s32 next = (this + 1) % thing.geo->numvertices; + if (collisions[0].geo->type == GEOTYPE_TILE_I) { + struct geotilei *tile = (struct geotilei *) collisions[0].geo; + s32 this = collisions[0].vertexindex; + s32 next = (this + 1) % collisions[0].geo->numvertices; sp70.x = tile->vertices[this][0]; sp70.y = tile->vertices[this][1]; @@ -3223,22 +3240,22 @@ s32 cd0002a6fc(struct coord *pos, struct coord *pos2, f32 width, s16 *rooms, s32 sp64.x = tile->vertices[next][0]; sp64.y = tile->vertices[next][1]; sp64.z = tile->vertices[next][2]; - } else /*854*/ if (thing.geo->type == GEOTYPE_TILE_F) { - struct geotilef *type1 = (struct geotilef *) thing.geo; - s32 this = thing.vertexindex; - s32 next = (this + 1) % thing.geo->numvertices; + } else /*854*/ if (collisions[0].geo->type == GEOTYPE_TILE_F) { + struct geotilef *tile = (struct geotilef *) collisions[0].geo; + s32 this = collisions[0].vertexindex; + s32 next = (this + 1) % collisions[0].geo->numvertices; - sp70.x = type1->vertices[this].x; - sp70.y = type1->vertices[this].y; - sp70.z = type1->vertices[this].z; + sp70.x = tile->vertices[this].x; + sp70.y = tile->vertices[this].y; + sp70.z = tile->vertices[this].z; - sp64.x = type1->vertices[next].x; - sp64.y = type1->vertices[next].y; - sp64.z = type1->vertices[next].z; - } else if (thing.geo->type == GEOTYPE_BLOCK) { - struct geoblock *block = (struct geoblock *) thing.geo; - s32 this = thing.vertexindex; - s32 next = (this + 1) % thing.geo->numvertices; + sp64.x = tile->vertices[next].x; + sp64.y = tile->vertices[next].y; + sp64.z = tile->vertices[next].z; + } else if (collisions[0].geo->type == GEOTYPE_BLOCK) { + struct geoblock *block = (struct geoblock *) collisions[0].geo; + s32 this = collisions[0].vertexindex; + s32 next = (this + 1) % collisions[0].geo->numvertices; sp70.x = block->vertices[this][0]; sp70.y = pos->y; @@ -3247,8 +3264,8 @@ s32 cd0002a6fc(struct coord *pos, struct coord *pos2, f32 width, s16 *rooms, s32 sp64.x = block->vertices[next][0]; sp64.y = pos->y; sp64.z = block->vertices[next][1]; - } else if (thing.geo->type == GEOTYPE_CYL) { - struct geocyl *cyl = (struct geocyl *) thing.geo; + } else if (collisions[0].geo->type == GEOTYPE_CYL) { + struct geocyl *cyl = (struct geocyl *) collisions[0].geo; if (1); @@ -3258,35 +3275,35 @@ s32 cd0002a6fc(struct coord *pos, struct coord *pos2, f32 width, s16 *rooms, s32 sp64.y = pos->y; } - cd00024fb0(&sp70, &sp64, thing.prop); + cdSetObstacleVtxProp(&sp70, &sp64, collisions[0].prop); } return cdresult; } #endif -s32 cdTestAToB1(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 types, s32 arg5, f32 ymax, f32 ymin) +s32 cdExamCylMove02(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) { - struct collisionthing things[21]; + struct collision collisions[21]; struct coord dist; s32 result = CDRESULT_NOCOLLISION; - cd00028df0(dstpos, width, dstrooms, types, 4, arg5, ymax, ymin, things, 20); + cdCollectGeoForCylMove(dstpos, width, dstrooms, types, GEOFLAG_WALL, checkvertical, ymax, ymin, collisions, 20); - if (things[0].geo) { + if (collisions[0].geo) { result = CDRESULT_COLLISION; dist.x = dstpos->x - origpos->x; dist.y = dstpos->y - origpos->y; dist.z = dstpos->z - origpos->z; - cd0002901c(origpos, &dist, width, things); + cd0002901c(origpos, &dist, width, collisions); } return result; } -bool cd0002aac0(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilei *tile, struct coord *arg4, struct coord *arg5) +bool cd0002aac0IntTile(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilei *tile, struct coord *arg4, struct coord *arg5) { s32 i; u8 numvertices = tile->header.numvertices; @@ -3303,7 +3320,7 @@ bool cd0002aac0(struct coord *arg0, struct coord *arg1, struct coord *arg2, stru return false; } -bool cd0002ab98(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilef *tile, struct coord *arg4, struct coord *arg5) +bool cd0002ab98FltTile(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilef *tile, struct coord *arg4, struct coord *arg5) { s32 i; u8 numvertices = tile->header.numvertices; @@ -3318,7 +3335,7 @@ bool cd0002ab98(struct coord *arg0, struct coord *arg1, struct coord *arg2, stru return false; } -bool cd0002ac70(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilei *tile, +bool cd0002ac70IntTile(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilei *tile, struct coord *arg4, struct coord *arg5, struct coord *arg6, bool arg7, f32 arg8, f32 arg9) { bool result = false; @@ -3408,7 +3425,7 @@ bool cd0002ac70(struct coord *arg0, struct coord *arg1, struct coord *arg2, stru return result; } -bool cd0002b128(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilef *tile, +bool cd0002b128FltTile(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geotilef *tile, struct coord *arg4, struct coord *arg5, struct coord *arg6, bool arg7, f32 arg8, f32 arg9) { bool result = false; @@ -3498,7 +3515,7 @@ bool cd0002b128(struct coord *arg0, struct coord *arg1, struct coord *arg2, stru return result; } -bool cd0002b560(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geoblock *block, +bool cd0002b560Block(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geoblock *block, struct coord *arg4, struct coord *arg5, struct coord *arg6, bool arg7, f32 arg8, f32 arg9) { bool result = false; @@ -3586,7 +3603,7 @@ bool cd0002b560(struct coord *arg0, struct coord *arg1, struct coord *arg2, stru return result; } -bool cd0002b954(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geocyl *cyl, +bool cd0002b954Cyl(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct geocyl *cyl, struct coord *arg4, struct coord *arg5, struct coord *arg6, bool arg7, f32 arg8, f32 arg9) { bool result = false; @@ -3665,7 +3682,7 @@ bool cd0002b954(struct coord *arg0, struct coord *arg1, struct coord *arg2, stru return result; } -bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, struct coord *arg4, u16 flags, bool arg6, s32 arg7, f32 arg8, f32 arg9) +bool cdTestAToBGeolist(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, struct coord *arg4, u16 geoflags, bool checkvertical, s32 arg7, f32 arg8, f32 arg9) { struct geo *geo = (struct geo *) start; @@ -3677,7 +3694,7 @@ bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord spc4; struct coord spb8; - if (tile->header.flags & flags) { + if (tile->header.flags & geoflags) { min.x = *(s16 *)(tile->xmin + (u32)tile); if ((!(arg2->x < min.x)) || !(arg3->x < min.x)) { @@ -3691,17 +3708,17 @@ bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru if ((!(arg2->z > max.z)) || !(arg3->z > max.z)) { if (1); - if (arg6) { + if (checkvertical) { min.y = *(s16 *)(tile->ymin + (u32)tile); max.y = *(s16 *)(tile->ymax + (u32)tile); if ((!(arg2->y < min.y) || !(arg3->y < min.y)) && (!(arg2->y > max.y) || !(arg3->y > max.y)) && bgTestLineIntersectsBbox(arg2, arg4, &min, &max) - && cd0002aac0(arg2, arg3, arg4, tile, &spc4, &spb8)) { + && cd0002aac0IntTile(arg2, arg3, arg4, tile, &spc4, &spb8)) { return false; } - } else if (cd0002ac70(arg2, arg3, arg4, tile, &spc4, 0, 0, arg7, arg8, arg9)) { + } else if (cd0002ac70IntTile(arg2, arg3, arg4, tile, &spc4, 0, 0, arg7, arg8, arg9)) { return false; } } @@ -3718,7 +3735,7 @@ bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord sp90; struct coord sp84; - if (tile->header.flags & flags) { + if (tile->header.flags & geoflags) { min.x = tile->vertices[tile->xmin].x; max.x = tile->vertices[tile->xmax].x; min.z = tile->vertices[tile->zmin].z; @@ -3728,17 +3745,17 @@ bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru && (!(arg2->x > max.x) || !(arg3->x > max.x)) && ((!(arg2->z < min.z)) || !(arg3->z < min.z)) && (!(arg2->z > max.z) || !(arg3->z > max.z))) { - if (arg6) { + if (checkvertical) { min.y = tile->vertices[tile->ymin].y; max.y = tile->vertices[tile->ymax].y; if ((!(arg2->y < min.y) || !(arg3->y < min.y)) && (!(arg2->y > max.y) || !(arg3->y > max.y)) && bgTestLineIntersectsBbox(arg2, arg4, &min, &max) - && cd0002ab98(arg2, arg3, arg4, tile, &sp90, &sp84)) { + && cd0002ab98FltTile(arg2, arg3, arg4, tile, &sp90, &sp84)) { return false; } - } else if (cd0002b128(arg2, arg3, arg4, tile, &sp90, 0, 0, arg7, arg8, arg9)) { + } else if (cd0002b128FltTile(arg2, arg3, arg4, tile, &sp90, 0, 0, arg7, arg8, arg9)) { return false; } } @@ -3749,8 +3766,8 @@ bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord sp78; struct geoblock *block = (struct geoblock *) geo; - if ((flags & (GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE)) - && cd0002b560(arg2, arg3, arg4, block, &sp78, 0, 0, arg7, arg8, arg9)) { + if ((geoflags & (GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT)) + && cd0002b560Block(arg2, arg3, arg4, block, &sp78, 0, 0, arg7, arg8, arg9)) { return false; } @@ -3759,8 +3776,8 @@ bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord sp68; struct geocyl *cyl = (struct geocyl *) geo; - if ((flags & cyl->header.flags) - && cd0002b954(arg2, arg3, arg4, cyl, &sp68, 0, 0, arg7, arg8, arg9)) { + if ((geoflags & cyl->header.flags) + && cd0002b954Cyl(arg2, arg3, arg4, cyl, &sp68, 0, 0, arg7, arg8, arg9)) { return false; } @@ -3771,7 +3788,7 @@ bool cd0002bd04(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru return true; } -void cd0002c328(struct geotilei *tile, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4) +void cd0002c328IntTile(struct geotilei *tile, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4) { struct coord sp3c; u32 stack[2]; @@ -3825,7 +3842,7 @@ void cd0002c328(struct geotilei *tile, struct coord *arg1, struct coord *arg2, s arg4->z = arg1->z + sp3c.f[2] * min; } -void cd0002c528(struct geotilef *tile, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4) +void cd0002c528FltTile(struct geotilef *tile, struct coord *arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4) { struct coord sp3c; u32 stack[2]; @@ -3879,8 +3896,8 @@ void cd0002c528(struct geotilef *tile, struct coord *arg1, struct coord *arg2, s arg4->z = arg1->z + sp3c.f[2] * min; } -bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, struct coord *arg4, - u16 flags, bool arg6, s32 arg7, f32 ymax, f32 ymin, f32 *arg10, struct coord *arg11, +bool cdExamAToBGeolist(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, struct coord *arg4, + u16 geoflags, bool checkvertical, s32 arg7, f32 ymax, f32 ymin, f32 *arg10, struct coord *arg11, struct coord *arg12, struct coord *arg13, struct geo **geoptr, s32 roomnum) { struct geo *geo; @@ -3903,13 +3920,13 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord sp114; struct coord sp108; - if (geo->flags & GEOFLAG_0080) { - ok = cd00028200(tile, arg2, 0, arg2->y + ymin, arg2->y + ymax); + if (geo->flags & GEOFLAG_RAMPWALL) { + ok = cdTestRampWall(tile, arg2, 0, arg2->y + ymin, arg2->y + ymax); } else { ok = true; } - if (ok && (geo->flags & flags)) { + if (ok && (geo->flags & geoflags)) { min.x = *(s16 *)(tile->xmin + (u32)tile); if (!(arg2->x < min.x) || !(arg3->x < min.x)) { @@ -3922,14 +3939,14 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru max.z = *(s16 *)(tile->zmax + (u32)tile); if (!(arg2->z > max.z) || !(arg3->z > max.z)) { - if (arg6) { + if (checkvertical) { min.y = *(s16 *)(tile->ymin + (u32)tile); max.y = *(s16 *)(tile->ymax + (u32)tile); if ((!(arg2->y < min.y) || !(arg3->y < min.y)) && (!(arg2->y > max.y) || !(arg3->y > max.y)) && bgTestLineIntersectsBbox(arg2, arg4, &min, &max) - && cd0002aac0(arg2, arg3, arg4, tile, &sp12c, &sp120)) { + && cd0002aac0IntTile(arg2, arg3, arg4, tile, &sp12c, &sp120)) { x = sp12c.x - arg2->x; y = sp12c.y - arg2->y; z = sp12c.z - arg2->z; @@ -3944,12 +3961,12 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru arg11->y = sp12c.y; arg11->z = sp12c.z; - cd0002c328(tile, &sp12c, &sp120, arg12, arg13); + cd0002c328IntTile(tile, &sp12c, &sp120, arg12, arg13); *geoptr = geo; } } - } else if (cd0002ac70(arg2, arg3, arg4, tile, &sp12c, &sp114, &sp108, arg7, ymax, ymin)) { + } else if (cd0002ac70IntTile(arg2, arg3, arg4, tile, &sp12c, &sp114, &sp108, arg7, ymax, ymin)) { x = sp12c.x - arg2->x; y = sp12c.y - arg2->y; z = sp12c.z - arg2->z; @@ -3991,7 +4008,7 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord spc8; struct coord spbc; - if (geo->flags & flags) { + if (geo->flags & geoflags) { min.x = tile->vertices[tile->xmin].x; max.x = tile->vertices[tile->xmax].x; min.z = tile->vertices[tile->zmin].z; @@ -4001,14 +4018,14 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru && (!(arg2->x > max.x) || !(arg3->x > max.x)) && (!(arg2->z < min.z) || !(arg3->z < min.z)) && (!(arg2->z > max.z) || !(arg3->z > max.z))) { - if (arg6) { + if (checkvertical) { min.y = tile->vertices[tile->ymin].y; max.y = tile->vertices[tile->ymax].y; if ((!(arg2->y < min.y) || !(arg3->y < min.y)) && (!(arg2->y > max.y) || !(arg3->y > max.y)) && bgTestLineIntersectsBbox(arg2, arg4, &min, &max) - && cd0002ab98(arg2, arg3, arg4, tile, &spe0, &spd4)) { + && cd0002ab98FltTile(arg2, arg3, arg4, tile, &spe0, &spd4)) { x = spe0.x - arg2->x; y = spe0.y - arg2->y; z = spe0.z - arg2->z; @@ -4023,12 +4040,12 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru arg11->y = spe0.y; arg11->z = spe0.z; - cd0002c528(tile, &spe0, &spd4, arg12, arg13); + cd0002c528FltTile(tile, &spe0, &spd4, arg12, arg13); *geoptr = geo; } } - } else if (cd0002b128(arg2, arg3, arg4, tile, &spe0, &spc8, &spbc, arg7, ymax, ymin)) { + } else if (cd0002b128FltTile(arg2, arg3, arg4, tile, &spe0, &spc8, &spbc, arg7, ymax, ymin)) { x = spe0.x - arg2->x; y = spe0.y - arg2->y; z = spe0.z - arg2->z; @@ -4063,8 +4080,8 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord spa4; struct coord sp98; - if ((flags & (GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE)) - && (cd0002b560(arg2, arg3, arg4, (struct geoblock *)geo, &spb0, &spa4, &sp98, arg7, ymax, ymin))) { + if ((geoflags & (GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT)) + && (cd0002b560Block(arg2, arg3, arg4, (struct geoblock *)geo, &spb0, &spa4, &sp98, arg7, ymax, ymin))) { x = spb0.x - arg2->x; y = spb0.y - arg2->y; z = spb0.z - arg2->z; @@ -4098,8 +4115,8 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru struct coord sp7c; struct coord sp70; - if ((flags & geo->flags) - && cd0002b954(arg2, arg3, arg4, cyl, &sp88, &sp7c, &sp70, arg7, ymax, ymin)) { + if ((geoflags & geo->flags) + && cd0002b954Cyl(arg2, arg3, arg4, cyl, &sp88, &sp7c, &sp70, arg7, ymax, ymin)) { x = sp88.x - arg2->x; y = sp88.y - arg2->y; z = sp88.z - arg2->z; @@ -4133,7 +4150,7 @@ bool cd0002c714(u8 *start, u8 *end, struct coord *arg2, struct coord *arg3, stru return !result; } -bool cd0002d15c(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, u16 arg4, s32 arg5, s32 arg6, f32 arg7, f32 ymax) +bool cdTestAToB(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, u16 geoflags, bool checkvertical, s32 arg6, f32 ymax, f32 ymin) { s32 roomnum; s16 *roomptr; @@ -4156,8 +4173,8 @@ bool cd0002d15c(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, start = g_TileFileData.u8 + g_TileRooms[roomnum]; end = g_TileFileData.u8 + g_TileRooms[roomnum + 1]; - if (cd0002bd04(start, end, pos, coord2, &sp27c, arg4, arg5, arg6, arg7, ymax) == 0) { - cd00025168(NULL); + if (cdTestAToBGeolist(start, end, pos, coord2, &sp27c, geoflags, checkvertical, arg6, ymax, ymin) == 0) { + cdSetObstacleProp(NULL); return false; } } @@ -4176,8 +4193,8 @@ bool cd0002d15c(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, if (propIsOfCdType(prop, types) && propUpdateGeometry(prop, &start, &end) - && cd0002bd04(start, end, pos, coord2, &sp27c, arg4, arg5, arg6, arg7, ymax) == 0) { - cd00025168(prop); + && cdTestAToBGeolist(start, end, pos, coord2, &sp27c, geoflags, checkvertical, arg6, ymax, ymin) == 0) { + cdSetObstacleProp(prop); return false; } @@ -4187,9 +4204,11 @@ bool cd0002d15c(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, return true; } +s32 cdExamAToB(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u16 geoflags, bool checkvertical, s32 arg6, f32 ymax, f32 ymin); + #if MATCHING GLOBAL_ASM( -glabel cd0002d3b0 +glabel cdExamAToB /* 2d3b0: 27bdfd20 */ addiu $sp,$sp,-736 /* 2d3b4: 3c014f80 */ lui $at,0x4f80 /* 2d3b8: 44812000 */ mtc1 $at,$f4 @@ -4274,7 +4293,7 @@ glabel cd0002d3b0 /* 2d4f0: 8fa702e4 */ lw $a3,0x2e4($sp) /* 2d4f4: afb90014 */ sw $t9,0x14($sp) /* 2d4f8: afaa001c */ sw $t2,0x1c($sp) -/* 2d4fc: 0c00b1c5 */ jal cd0002c714 +/* 2d4fc: 0c00b1c5 */ jal cdExamAToBGeolist /* 2d500: afa90018 */ sw $t1,0x18($sp) /* 2d504: 1440000b */ bnez $v0,.L0002d534 /* 2d508: 240d0001 */ addiu $t5,$zero,0x1 @@ -4286,7 +4305,7 @@ glabel cd0002d3b0 /* 2d520: 02403025 */ or $a2,$s2,$zero /* 2d524: 00003825 */ or $a3,$zero,$zero /* 2d528: e7b00010 */ swc1 $f16,0x10($sp) -/* 2d52c: 0c009495 */ jal cd00025254 +/* 2d52c: 0c009495 */ jal cdSetObstacleVtxColPropFltGeo /* 2d530: afae0014 */ sw $t6,0x14($sp) .L0002d534: /* 2d534: 86080002 */ lh $t0,0x2($s0) @@ -4351,7 +4370,7 @@ glabel cd0002d3b0 /* 2d614: afb40034 */ sw $s4,0x34($sp) /* 2d618: afab0014 */ sw $t3,0x14($sp) /* 2d61c: afac0018 */ sw $t4,0x18($sp) -/* 2d620: 0c00b1c5 */ jal cd0002c714 +/* 2d620: 0c00b1c5 */ jal cdExamAToBGeolist /* 2d624: afad001c */ sw $t5,0x1c($sp) /* 2d628: 1440000b */ bnez $v0,.L0002d658 /* 2d62c: 24190001 */ addiu $t9,$zero,0x1 @@ -4363,7 +4382,7 @@ glabel cd0002d3b0 /* 2d644: 02403025 */ or $a2,$s2,$zero /* 2d648: 02003825 */ or $a3,$s0,$zero /* 2d64c: e7b20010 */ swc1 $f18,0x10($sp) -/* 2d650: 0c009495 */ jal cd00025254 +/* 2d650: 0c009495 */ jal cdSetObstacleVtxColPropFltGeo /* 2d654: afa90014 */ sw $t1,0x14($sp) .L0002d658: /* 2d658: 86220002 */ lh $v0,0x2($s1) @@ -4393,7 +4412,7 @@ glabel cd0002d3b0 // Mismatch: Calculation of g_TileRooms[roomnum] is different // Other functions and the below use t3 as the offset, t2 as the base, then t2 + t3 // But goal for this function uses t2 as the offset, t3 as the base, then t2 + t3 -s32 cd0002d3b0(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u16 arg4, s32 arg5, s32 arg6, f32 ymax, f32 ymin) +s32 cdExamAToB(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u16 geoflags, bool checkvertical, s32 arg6, f32 ymax, f32 ymin) { s32 roomnum; s16 *roomptr; @@ -4422,9 +4441,9 @@ s32 cd0002d3b0(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u1 start = g_TileFileData.u8 + g_TileRooms[roomnum]; end = g_TileFileData.u8 + g_TileRooms[roomnum + 1]; - if (!cd0002c714(start, end, arg0, arg1, &sp2c4, arg4, arg5, arg6, ymax, ymin, &sp298, &sp2b4, &sp2a8, &sp29c, &sp294, roomnum)) { + if (!cdExamAToBGeolist(start, end, arg0, arg1, &sp2c4, geoflags, checkvertical, arg6, ymax, ymin, &sp298, &sp2b4, &sp2a8, &sp29c, &sp294, roomnum)) { sp2c0 = true; - cd00025254(&sp2a8, &sp29c, &sp2b4, NULL, sp298, sp294); + cdSetObstacleVtxColPropFltGeo(&sp2a8, &sp29c, &sp2b4, NULL, sp298, sp294); } } @@ -4441,9 +4460,9 @@ s32 cd0002d3b0(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u1 if (propIsOfCdType(prop, types) && propUpdateGeometry(prop, &start, &end) - && !cd0002c714(start, end, arg0, arg1, &sp2c4, arg4, arg5, arg6, ymax, ymin, &sp298, &sp2b4, &sp2a8, &sp29c, &sp294, -999)) { + && !cdExamAToBGeolist(start, end, arg0, arg1, &sp2c4, geoflags, checkvertical, arg6, ymax, ymin, &sp298, &sp2b4, &sp2a8, &sp29c, &sp294, -999)) { sp2c0 = true; - cd00025254(&sp2a8, &sp29c, &sp2b4, prop, sp298, sp294); + cdSetObstacleVtxColPropFltGeo(&sp2a8, &sp29c, &sp2b4, prop, sp298, sp294); } propnumptr++; @@ -4453,17 +4472,17 @@ s32 cd0002d3b0(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u1 } #endif -bool cd0002d6ac(struct coord *pos, s16 *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 arg5, f32 arg6) +bool cdTestCylMove01(struct coord *pos, s16 *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 ymax, f32 ymin) { s16 sp44[21]; s16 sp34[8]; portal00018148(pos, targetpos, rooms, sp34, sp44, 20); - return cd0002d15c(pos, targetpos, sp44, types, 4, 0, arg4, arg5, arg6); + return cdTestAToB(pos, targetpos, sp44, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg4, ymax, ymin); } -s32 cdTestAToB2(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *rooms2, u32 types, s32 arg5, f32 arg6, f32 arg7) +s32 cdTestCylMove02(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *rooms2, u32 types, s32 arg5, f32 ymax, f32 ymin) { s32 result; s16 sp44[20]; @@ -4472,34 +4491,34 @@ s32 cdTestAToB2(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *rooms2 func0f065d1c(pos, rooms, coord2, sp34, sp44, 20); if (arrayIntersects(sp34, rooms2)) { - result = cd0002d15c(pos, coord2, sp44, types, 4, 0, arg5, arg6, arg7); + result = cdTestAToB(pos, coord2, sp44, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg5, ymax, ymin); } else { - result = 0; + result = CDRESULT_COLLISION; } return result; } -bool cd0002d7c0(struct coord *pos, s16 *rooms, struct coord *arg2, u32 arg3, u32 arg4, f32 ymax, f32 ymin) +s32 cdExamCylMove03(struct coord *pos, s16 *rooms, struct coord *arg2, u32 types, u32 arg4, f32 ymax, f32 ymin) { s16 sp44[21]; s16 sp34[8]; portal00018148(pos, arg2, rooms, sp34, sp44, 20); - return cd0002d3b0(pos, arg2, sp44, arg3, 4, 0, arg4, ymax, ymin); + return cdExamAToB(pos, arg2, sp44, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg4, ymax, ymin); } -s32 cd0002d840(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) +s32 cdTestCylMove04(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) { s16 rooms[21]; portal00018148(arg0, arg2, arg1, arg3, rooms, 20); - return cd0002d15c(arg0, arg2, rooms, types, 4, 0, arg5, ymax, ymin); + return cdTestAToB(arg0, arg2, rooms, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg5, ymax, ymin); } -s32 cd0002d8b8(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin) +s32 cdExamCylMove05(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin) { s16 sp44[21]; s16 sp34[8]; @@ -4507,27 +4526,26 @@ s32 cd0002d8b8(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s func0f065d1c(pos, rooms, pos2, sp34, sp44, 20); - result = cd0002d3b0(pos, pos2, sp44, types, 4, 0, arg5, ymax, ymin); + result = cdExamAToB(pos, pos2, sp44, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg5, ymax, ymin); if (result != CDRESULT_COLLISION && !arrayIntersects(sp34, rooms2)) { - cd00024f6c(); + cdClearResults(); result = CDRESULT_ERROR; } return result; } -s32 cdTestAToB3(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, s32 types, s32 arg6, f32 ymax, f32 ymin) +s32 cdExamCylMove06(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, s32 types, s32 arg6, f32 ymax, f32 ymin) { - u32 stack[7]; - s16 sp5c[8]; + s16 sp5c[21]; s16 sp4c[8]; struct coord sp40; s32 result; func0f065d1c(arg0, arg1, arg2, sp4c, sp5c, 20); - result = cd0002d3b0(arg0, arg2, sp5c, types, 4, 0, arg6, ymax, ymin); + result = cdExamAToB(arg0, arg2, sp5c, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg6, ymax, ymin); if (result == CDRESULT_COLLISION) { sp40.x = arg2->x - arg0->x; @@ -4536,23 +4554,23 @@ s32 cdTestAToB3(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f3 cd000250cc(arg0, &sp40, width); } else if (!arrayIntersects(sp4c, arg3)) { - cd00024f6c(); - result = -1; + cdClearResults(); + result = CDRESULT_ERROR; } return result; } -s32 cd0002da50(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) +s32 cdExamCylMove07(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) { s16 rooms[21]; portal00018148(arg0, arg2, arg1, arg3, rooms, 20); - return cd0002d3b0(arg0, arg2, rooms, types, 4, 0, arg5, ymax, ymin); + return cdExamAToB(arg0, arg2, rooms, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg5, ymax, ymin); } -s32 cd0002dac8(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin) +s32 cdExamCylMove08(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin) { s16 rooms[21]; struct coord sp40; @@ -4560,9 +4578,9 @@ s32 cd0002dac8(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 portal00018148(arg0, arg2, arg1, arg3, rooms, 20); - result = cd0002d3b0(arg0, arg2, rooms, types, 4, 0, arg6, ymax, ymin); + result = cdExamAToB(arg0, arg2, rooms, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg6, ymax, ymin); - if (result == 0) { + if (result == CDRESULT_COLLISION) { sp40.x = arg2->x - arg0->x; sp40.y = arg2->y - arg0->y; sp40.z = arg2->z - arg0->z; @@ -4573,22 +4591,22 @@ s32 cd0002dac8(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 return result; } -bool cd0002db98(struct coord *viewpos, s16 *rooms, struct coord *targetpos, u32 types, u16 arg4) +bool cdTestLos03(struct coord *viewpos, s16 *rooms, struct coord *targetpos, u32 types, u16 geoflags) { s16 sp44[21]; s16 sp34[8]; portal00018148(viewpos, targetpos, rooms, sp34, sp44, 20); - return cd0002d15c(viewpos, targetpos, sp44, types, arg4, 1, 1, 0, 0); + return cdTestAToB(viewpos, targetpos, sp44, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } -bool cd0002dc18(struct coord *coord, s16 *rooms, struct coord *coord2, s32 arg3) +bool cdTestLos04(struct coord *frompos, s16 *fromrooms, struct coord *topos, s32 types) { - return cd0002db98(coord, rooms, coord2, arg3, 0x1c); + return cdTestLos03(frompos, fromrooms, topos, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } -bool cdHasLineOfSight(struct coord *coord, s16 *rooms, struct coord *coord2, s16 *rooms2, s32 arg4, u16 arg5) +bool cdTestLos05(struct coord *coord, s16 *rooms, struct coord *coord2, s16 *rooms2, s32 types, u16 geoflags) { bool result; s16 sp44[20]; @@ -4597,7 +4615,7 @@ bool cdHasLineOfSight(struct coord *coord, s16 *rooms, struct coord *coord2, s16 func0f065d1c(coord, rooms, coord2, sp34, sp44, 20); if (arrayIntersects(sp34, rooms2)) { - result = cd0002d15c(coord, coord2, sp44, arg4, arg5, 1, 1, 0, 0); + result = cdTestAToB(coord, coord2, sp44, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } else { result = false; } @@ -4605,12 +4623,12 @@ bool cdHasLineOfSight(struct coord *coord, s16 *rooms, struct coord *coord2, s16 return result; } -bool cd0002dcd0(struct coord *arg0, s16 *rooms1, struct coord *arg2, s16 *rooms2, u32 arg4) +bool cdTestLos06(struct coord *arg0, s16 *rooms1, struct coord *arg2, s16 *rooms2, u32 types) { - return cdHasLineOfSight(arg0, rooms1, arg2, rooms2, arg4, 0x1c); + return cdTestLos05(arg0, rooms1, arg2, rooms2, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } -bool cd0002dcfc(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s16 *rooms3, u32 types, u16 arg6) +bool cdTestLos07(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s16 *rooms3, u32 types, u16 geoflags) { bool result; s16 sp34[20]; @@ -4618,7 +4636,7 @@ bool cd0002dcfc(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, func0f065d1c(pos, rooms, pos2, rooms3, sp34, 20); if (arrayIntersects(rooms3, rooms2)) { - result = cd0002d15c(pos, pos2, sp34, types, arg6, 1, 1, 0, 0); + result = cdTestAToB(pos, pos2, sp34, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } else { result = false; } @@ -4626,33 +4644,33 @@ bool cd0002dcfc(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, return result; } -s32 cdTestAToB4(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types, u16 arg4) +s32 cdExamLos08(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types, u16 geoflags) { s16 sp44[21]; s16 sp34[8]; portal00018148(pos, pos2, rooms, sp34, sp44, 20); - return cd0002d3b0(pos, pos2, sp44, types, arg4, 1, 1, 0, 0); + return cdExamAToB(pos, pos2, sp44, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } -s32 cd0002de10(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types) +s32 cdExamLos09(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types) { - return cdTestAToB4(pos, rooms, pos2, types, 0x1c); + return cdExamLos08(pos, rooms, pos2, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } -s32 cd0002de34(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, u16 arg5) +s32 cdTestLos10(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, u16 geoflags) { s16 rooms[21]; portal00018148(arg0, arg2, arg1, arg3, rooms, 20); - return cd0002d15c(arg0, arg2, rooms, types, arg5, 1, 1, 0, 0); + return cdTestAToB(arg0, arg2, rooms, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } -s32 cd0002deac(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types) +s32 cdTestLos11(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types) { - return cd0002de34(arg0, arg1, arg2, arg3, types, 0x1c); + return cdTestLos10(arg0, arg1, arg2, arg3, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } bool cd0002ded8(struct coord *arg0, struct coord *arg1, struct prop *prop) @@ -4672,21 +4690,26 @@ bool cd0002ded8(struct coord *arg0, struct coord *arg1, struct prop *prop) sp7c.z = arg1->z - arg0->z; if (propUpdateGeometry(prop, &start, &end)) { - if (!cd0002c714(start, end, arg0, arg1, &sp7c, 0x1c, 1, 1, 0, 0, &sp50, &sp6c, &sp60, &sp54, &geo, -999)) { + if (!cdExamAToBGeolist(start, end, arg0, arg1, &sp7c, + GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT, + CHECKVERTICAL_YES, 1, 0, 0, &sp50, &sp6c, &sp60, &sp54, &geo, -999)) { result = true; - cd00025254(&sp60, &sp54, &sp6c, prop, sp50, geo); + cdSetObstacleVtxColPropFltGeo(&sp60, &sp54, &sp6c, prop, sp50, geo); } } return !result; } -bool cd0002dffc(struct geoblock *arg0, struct geoblock *arg1) +/** + * Return true if both blocks are not intersecting on the X/Z plane. + */ +bool cdBlockExcludesBlockLaterally(struct geoblock *block1, struct geoblock *block2) { u32 stack[4]; f32 zero = 0.0f; - s32 numvertices0 = arg0->header.numvertices; - s32 numvertices1 = arg1->header.numvertices; + s32 numvertices0 = block1->header.numvertices; + s32 numvertices1 = block2->header.numvertices; s32 i; for (i = 0; i < numvertices0; i++) { @@ -4694,21 +4717,21 @@ bool cd0002dffc(struct geoblock *arg0, struct geoblock *arg1) f64 diff1; f64 diff2; - diff1 = arg0->vertices[next][1] - (f64)arg0->vertices[i][1]; - diff2 = arg0->vertices[i][0] - (f64)arg0->vertices[next][0]; + diff1 = block1->vertices[next][1] - (f64)block1->vertices[i][1]; + diff2 = block1->vertices[i][0] - (f64)block1->vertices[next][0]; if (diff1 == zero && diff2 == zero) { - if (cdIs2dPointInBlock(arg1, arg0->vertices[i][0], arg0->vertices[i][1])) { + if (cdIs2dPointInBlock(block2, block1->vertices[i][0], block1->vertices[i][1])) { return false; } } else { - f64 sum1 = arg0->vertices[i][0] * diff1 + arg0->vertices[i][1] * diff2; + f64 sum1 = block1->vertices[i][0] * diff1 + block1->vertices[i][1] * diff2; f64 sum2; s32 j = (next + 1) % numvertices0; s32 k; while (j != i) { - sum2 = arg0->vertices[j][0] * diff1 + arg0->vertices[j][1] * diff2; + sum2 = block1->vertices[j][0] * diff1 + block1->vertices[j][1] * diff2; if (1); if (1); @@ -4722,7 +4745,7 @@ bool cd0002dffc(struct geoblock *arg0, struct geoblock *arg1) } for (k = 0; k < numvertices1; k++) { - f64 sum3 = arg1->vertices[k][0] * diff1 + arg1->vertices[k][1] * diff2; + f64 sum3 = block2->vertices[k][0] * diff1 + block2->vertices[k][1] * diff2; if (sum2 == sum1) { sum2 = sum1 - sum3 + sum1; @@ -4742,7 +4765,7 @@ bool cd0002dffc(struct geoblock *arg0, struct geoblock *arg1) return false; } -s32 cd0002e278(u8 *start, u8 *end, struct geoblock *ref, u16 flags) +s32 cdTestBlockOverlapsGeolist(u8 *start, u8 *end, struct geoblock *block, u16 geoflags) { struct geo *geo = (struct geo *) start; @@ -4751,31 +4774,33 @@ s32 cd0002e278(u8 *start, u8 *end, struct geoblock *ref, u16 flags) struct geotilei *tile = (struct geotilei *) geo; geo = (struct geo *)((u32)geo + tile->header.numvertices * 6 + 0xe); } else if (geo->type == GEOTYPE_TILE_F) { - struct geotilef *type1 = (struct geotilef *) geo; - geo = (struct geo *)((u32)geo + type1->header.numvertices * 0xc + 0x10); + struct geotilef *tile = (struct geotilef *) geo; + geo = (struct geo *)((u32)geo + tile->header.numvertices * 0xc + 0x10); } else if (geo->type == GEOTYPE_BLOCK) { - struct geoblock *tile2 = (struct geoblock *) geo; + struct geoblock *thisblock = (struct geoblock *) geo; - if ((flags & (GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE)) - && tile2->ymax >= ref->ymin - && tile2->ymin <= ref->ymax) { + if ((geoflags & (GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT)) + && thisblock->ymax >= block->ymin + && thisblock->ymin <= block->ymax) { // Tiles are overlapping vertically s32 i; - for (i = 0; i < ref->header.numvertices; i++) { - if (cdIs2dPointInBlock(tile2, ref->vertices[i][0], ref->vertices[i][1])) { - return false; + for (i = 0; i < block->header.numvertices; i++) { + if (cdIs2dPointInBlock(thisblock, block->vertices[i][0], block->vertices[i][1])) { + return CDRESULT_COLLISION; } } - for (i = 0; i < tile2->header.numvertices; i++) { - if (cdIs2dPointInBlock(ref, tile2->vertices[i][0], tile2->vertices[i][1])) { - return false; + for (i = 0; i < thisblock->header.numvertices; i++) { + if (cdIs2dPointInBlock(block, thisblock->vertices[i][0], thisblock->vertices[i][1])) { + return CDRESULT_COLLISION; } } - if (!cd0002dffc(ref, tile2) && !cd0002dffc(tile2, ref)) { - return false; + // This is a bit wasteful... + // If A excludes B, there's no point checking if B excludes A. + if (!cdBlockExcludesBlockLaterally(block, thisblock) && !cdBlockExcludesBlockLaterally(thisblock, block)) { + return CDRESULT_COLLISION; } } @@ -4783,21 +4808,31 @@ s32 cd0002e278(u8 *start, u8 *end, struct geoblock *ref, u16 flags) } else if (geo->type == GEOTYPE_CYL) { struct geocyl *cyl = (struct geocyl *) geo; - if ((flags & geo->flags) - && cyl->ymax >= ref->ymin - && cyl->ymin <= ref->ymax - && cd000274e0(ref, cyl->x, cyl->z, cyl->radius, NULL, NULL)) { - return false; + if ((geoflags & geo->flags) + && cyl->ymax >= block->ymin + && cyl->ymin <= block->ymax + && cd000274e0Block(block, cyl->x, cyl->z, cyl->radius, NULL, NULL)) { + return CDRESULT_COLLISION; } geo = (struct geo *)((u32)geo + 0x18); } } - return true; + return CDRESULT_NOCOLLISION; } -s32 cd0002e4c4(struct geoblock *geo, s16 *rooms, u32 types) +/** + * Test if the given block overlaps any prop. Set the saved obstacle prop if so. + * + * The BG tests are pointless and not used, as cdTestBlockOverlapsGeolist only + * tests blocks and cylinders. + * + * The function is used to check if a door is being blocked by another prop, + * and is also used in a sanity check to make sure a moved object hasn't moved + * into the player's position. + */ +s32 cdTestBlockOverlapsAnyProp(struct geoblock *geo, s16 *rooms, u32 types) { s32 result = CDRESULT_NOCOLLISION; s32 roomnum; @@ -4817,10 +4852,10 @@ s32 cd0002e4c4(struct geoblock *geo, s16 *rooms, u32 types) start = g_TileFileData.u8 + g_TileRooms[roomnum]; end = g_TileFileData.u8 + g_TileRooms[roomnum + 1]; - result = cd0002e278(start, end, geo, GEOFLAG_COLLISIONS); + result = cdTestBlockOverlapsGeolist(start, end, geo, GEOFLAG_WALL); if (result == CDRESULT_COLLISION) { - cd00025168(NULL); + cdSetObstacleProp(NULL); break; } } @@ -4839,10 +4874,10 @@ s32 cd0002e4c4(struct geoblock *geo, s16 *rooms, u32 types) struct prop *prop = &g_Vars.props[*propnumptr]; if (propIsOfCdType(prop, types) && propUpdateGeometry(prop, &start, &end)) { - result = cd0002e278(start, end, geo, GEOFLAG_COLLISIONS); + result = cdTestBlockOverlapsGeolist(start, end, geo, GEOFLAG_WALL); if (result == CDRESULT_COLLISION) { - cd00025168(prop); + cdSetObstacleProp(prop); break; } } @@ -4854,7 +4889,7 @@ s32 cd0002e4c4(struct geoblock *geo, s16 *rooms, u32 types) return result; } -bool cd0002e680(struct geotilei *tile, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block) +bool cd0002e680IntTile(struct geotilei *tile, s32 numvertices, struct coord *verts, struct coord *diffs, struct prop *prop, struct geoblock *block) { bool result = false; s32 i; @@ -4874,13 +4909,13 @@ bool cd0002e680(struct geotilei *tile, s32 numvertices, struct coord *arg2, stru curr = i; } - if (cd0002ac70((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), - (struct coord *)((u32)arg2 + next * sizeof(struct coord)), - (struct coord *)((u32)arg3 + curr * sizeof(struct coord)), + if (cd0002ac70IntTile((struct coord *)((u32)verts + curr * sizeof(struct coord)), + (struct coord *)((u32)verts + next * sizeof(struct coord)), + (struct coord *)((u32)diffs + curr * sizeof(struct coord)), tile, &sp6c, &sp84, &sp78, 0, 0.0f, 0.0f)) { - cd000251ac(&sp84, &sp78, &sp6c, prop); - cd00025314((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), (struct coord *)((u32)arg2 + next * sizeof(struct coord))); - cd000253c4(block); + cdSetObstacleVtxColProp(&sp84, &sp78, &sp6c, prop); + cdSetSavedPos((struct coord *)((u32)verts + curr * sizeof(struct coord)), (struct coord *)((u32)verts + next * sizeof(struct coord))); + cdSetSavedBlock(block); result = true; break; } @@ -4889,7 +4924,7 @@ bool cd0002e680(struct geotilei *tile, s32 numvertices, struct coord *arg2, stru return result; } -bool cd0002e82c(struct geotilef *tile, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block) +bool cd0002e82cIntTile(struct geotilef *tile, s32 numvertices, struct coord *verts, struct coord *diffs, struct prop *prop, struct geoblock *block) { bool result = false; s32 i; @@ -4909,13 +4944,13 @@ bool cd0002e82c(struct geotilef *tile, s32 numvertices, struct coord *arg2, stru curr = i; } - if (cd0002b128((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), - (struct coord *)((u32)arg2 + next * sizeof(struct coord)), - (struct coord *)((u32)arg3 + curr * sizeof(struct coord)), + if (cd0002b128FltTile((struct coord *)((u32)verts + curr * sizeof(struct coord)), + (struct coord *)((u32)verts + next * sizeof(struct coord)), + (struct coord *)((u32)diffs + curr * sizeof(struct coord)), tile, &sp6c, &sp84, &sp78, 0, 0.0f, 0.0f)) { - cd000251ac(&sp84, &sp78, &sp6c, prop); - cd00025314((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), (struct coord *)((u32)arg2 + next * sizeof(struct coord))); - cd000253c4(block); + cdSetObstacleVtxColProp(&sp84, &sp78, &sp6c, prop); + cdSetSavedPos((struct coord *)((u32)verts + curr * sizeof(struct coord)), (struct coord *)((u32)verts + next * sizeof(struct coord))); + cdSetSavedBlock(block); result = true; break; } @@ -4924,7 +4959,7 @@ bool cd0002e82c(struct geotilef *tile, s32 numvertices, struct coord *arg2, stru return result; } -bool cd0002e9d8(struct geoblock *thisblock, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block) +bool cd0002e9d8Block(struct geoblock *thisblock, s32 numvertices, struct coord *verts, struct coord *diffs, struct prop *prop, struct geoblock *block) { bool result = false; s32 i; @@ -4944,13 +4979,13 @@ bool cd0002e9d8(struct geoblock *thisblock, s32 numvertices, struct coord *arg2, curr = i; } - if (cd0002b560((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), - (struct coord *)((u32)arg2 + next * sizeof(struct coord)), - (struct coord *)((u32)arg3 + curr * sizeof(struct coord)), + if (cd0002b560Block((struct coord *)((u32)verts + curr * sizeof(struct coord)), + (struct coord *)((u32)verts + next * sizeof(struct coord)), + (struct coord *)((u32)diffs + curr * sizeof(struct coord)), thisblock, &sp6c, &sp84, &sp78, 0, 0.0f, 0.0f)) { - cd000251ac(&sp84, &sp78, &sp6c, prop); - cd00025314((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), (struct coord *)((u32)arg2 + next * sizeof(struct coord))); - cd000253c4(block); + cdSetObstacleVtxColProp(&sp84, &sp78, &sp6c, prop); + cdSetSavedPos((struct coord *)((u32)verts + curr * sizeof(struct coord)), (struct coord *)((u32)verts + next * sizeof(struct coord))); + cdSetSavedBlock(block); result = true; break; } @@ -4959,7 +4994,7 @@ bool cd0002e9d8(struct geoblock *thisblock, s32 numvertices, struct coord *arg2, return result; } -bool cd0002eb84(struct geocyl *cyl, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block) +bool cd0002eb84Cyl(struct geocyl *cyl, s32 numvertices, struct coord *arg2, struct coord *arg3, struct prop *prop, struct geoblock *block) { bool result = false; s32 i; @@ -4979,13 +5014,13 @@ bool cd0002eb84(struct geocyl *cyl, s32 numvertices, struct coord *arg2, struct curr = i; } - if (cd0002b954((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), + if (cd0002b954Cyl((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), (struct coord *)((u32)arg2 + next * sizeof(struct coord)), (struct coord *)((u32)arg3 + curr * sizeof(struct coord)), cyl, &sp6c, &sp84, &sp78, 0, 0.0f, 0.0f)) { - cd000251ac(&sp84, &sp78, &sp6c, prop); - cd00025314((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), (struct coord *)((u32)arg2 + next * sizeof(struct coord))); - cd000253c4(block); + cdSetObstacleVtxColProp(&sp84, &sp78, &sp6c, prop); + cdSetSavedPos((struct coord *)((u32)arg2 + curr * sizeof(struct coord)), (struct coord *)((u32)arg2 + next * sizeof(struct coord))); + cdSetSavedBlock(block); result = true; break; } @@ -4994,7 +5029,7 @@ bool cd0002eb84(struct geocyl *cyl, s32 numvertices, struct coord *arg2, struct return result; } -bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, struct coord *arg4, struct coord *arg5, u16 flags, struct prop *prop) +bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, struct coord *verts, struct coord *diffs, u16 geoflags, struct prop *prop) { struct geo *geo = (struct geo *) start; @@ -5004,10 +5039,10 @@ bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, str if (geo->type == GEOTYPE_TILE_I) { struct geotilei *tile = (struct geotilei *)geo; - if ((flags & geo->flags) + if ((geoflags & geo->flags) && *(s16 *)(tile->ymax + (u32)tile) >= block->ymin && *(s16 *)(tile->ymin + (u32)tile) <= block->ymax - && cd0002e680(tile, numvertices, arg4, arg5, prop, block)) { + && cd0002e680IntTile(tile, numvertices, verts, diffs, prop, block)) { return false; } @@ -5015,10 +5050,10 @@ bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, str } else if (geo->type == GEOTYPE_TILE_F) { struct geotilef *tile = (struct geotilef *)geo; - if ((flags & geo->flags) + if ((geoflags & geo->flags) && tile->vertices[tile->ymax].y >= block->ymin && tile->vertices[tile->ymin].y <= block->ymax - && cd0002e82c(tile, numvertices, arg4, arg5, prop, block)) { + && cd0002e82cIntTile(tile, numvertices, verts, diffs, prop, block)) { return false; } @@ -5026,10 +5061,10 @@ bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, str } else if (geo->type == GEOTYPE_BLOCK) { struct geoblock *block2 = (struct geoblock *)geo; - if ((flags & (GEOFLAG_COLLISIONS | GEOFLAG_0008 | GEOFLAG_OPAQUE)) + if ((geoflags & (GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT)) && block2->ymax >= block->ymin && block2->ymin <= block->ymax - && cd0002e9d8(block2, numvertices, arg4, arg5, prop, block)) { + && cd0002e9d8Block(block2, numvertices, verts, diffs, prop, block)) { return false; } @@ -5037,10 +5072,10 @@ bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, str } else if (geo->type == GEOTYPE_CYL) { struct geocyl *cyl = (struct geocyl *)geo; - if ((flags & geo->flags) + if ((geoflags & geo->flags) && cyl->ymax >= block->ymin && cyl->ymin <= block->ymax - && cd0002eb84(cyl, numvertices, arg4, arg5, prop, block)) { + && cd0002eb84Cyl(cyl, numvertices, verts, diffs, prop, block)) { return false; } @@ -5061,21 +5096,21 @@ bool cd0002f02c(struct geoblock *block, s16 *rooms, s32 types) s16 propnums[256]; s16 *propnumptr; bool result = true; - struct coord spcc[8]; - struct coord sp6c[8]; + struct coord verts[8]; + struct coord diffs[8]; for (i = 0; i < numvertices; i++) { - spcc[i].x = block->vertices[i][0]; - spcc[i].y = block->ymax; - spcc[i].z = block->vertices[i][1]; + verts[i].x = block->vertices[i][0]; + verts[i].y = block->ymax; + verts[i].z = block->vertices[i][1]; } for (i = 0; i < numvertices; i++) { next = (i + 1) % numvertices; - sp6c[i].x = spcc[next].x - spcc[i].x; - sp6c[i].y = spcc[next].y - spcc[i].y; - sp6c[i].z = spcc[next].z - spcc[i].z; + diffs[i].x = verts[next].x - verts[i].x; + diffs[i].y = verts[next].y - verts[i].y; + diffs[i].z = verts[next].z - verts[i].z; } if (types & CDTYPE_BG) { @@ -5087,7 +5122,7 @@ bool cd0002f02c(struct geoblock *block, s16 *rooms, s32 types) start = g_TileFileData.u8 + g_TileRooms[roomnum]; end = g_TileFileData.u8 + g_TileRooms[roomnum + 1]; - result = cd0002ed30(start, end, block, numvertices, spcc, sp6c, 4, NULL); + result = cd0002ed30(start, end, block, numvertices, verts, diffs, GEOFLAG_WALL, NULL); if (!result) { break; @@ -5109,7 +5144,7 @@ bool cd0002f02c(struct geoblock *block, s16 *rooms, s32 types) if (propIsOfCdType(prop, types)) { if (propUpdateGeometry(prop, &start, &end)) { - result = cd0002ed30(start, end, block, numvertices, spcc, sp6c, 4, prop); + result = cd0002ed30(start, end, block, numvertices, verts, diffs, GEOFLAG_WALL, prop); if (!result) { break; @@ -5127,7 +5162,7 @@ bool cd0002f02c(struct geoblock *block, s16 *rooms, s32 types) #if VERSION < VERSION_NTSC_1_0 struct debugtri *cdReadIntTileVertices(struct debugtri *ptr, s32 *remaining, struct geotilei *tile) { - if (tile->header.flags & (GEOFLAG_0001 | GEOFLAG_COLLISIONS)) { + if (tile->header.flags & (GEOFLAG_FLOOR1 | GEOFLAG_WALL)) { s32 i; s32 numvertices = tile->header.numvertices; s16 vertices[16][3]; @@ -5169,7 +5204,7 @@ struct debugtri *cdReadIntTileVertices(struct debugtri *ptr, s32 *remaining, str #if VERSION < VERSION_NTSC_1_0 struct debugtri *cdReadFltTileVertices(struct debugtri *ptr, s32 *remaining, struct geotilef *tile) { - if (tile->header.flags & (GEOFLAG_0001 | GEOFLAG_COLLISIONS)) { + if (tile->header.flags & (GEOFLAG_FLOOR1 | GEOFLAG_WALL)) { s32 i; s32 numvertices = tile->header.numvertices; s16 vertices[16][3]; @@ -5208,24 +5243,24 @@ struct debugtri *cdReadFltTileVertices(struct debugtri *ptr, s32 *remaining, str } #endif -Gfx *cd0002f2e8(Gfx *gdl, u32 arg1, u32 arg2, u32 arg3) +Gfx *cdRender(Gfx *gdl, u32 arg1, u32 arg2, u32 arg3) { return gdl; } -void func0002f2fc(u32 arg0, u32 arg1) +void cd0002f2fc(u32 arg0, u32 arg1) { // empty } -bool cd0002f308(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 arg4, u16 arg5) +bool cdIsNearlyInSightWithFlags(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 types, u16 geoflags) { struct coord diff; f32 x; f32 z; struct coord vector; - if (cd0002db98(viewpos, rooms, targetpos, arg4, arg5)) { + if (cdTestLos03(viewpos, rooms, targetpos, types, geoflags)) { return true; } @@ -5242,7 +5277,7 @@ bool cd0002f308(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 diff.y = targetpos->y; diff.z = targetpos->z + x; - if (cd0002db98(viewpos, rooms, &diff, arg4, arg5)) { + if (cdTestLos03(viewpos, rooms, &diff, types, geoflags)) { return true; } @@ -5250,14 +5285,14 @@ bool cd0002f308(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 diff.y = targetpos->y; diff.z = targetpos->z - x; - if (cd0002db98(viewpos, rooms, &diff, arg4, arg5)) { + if (cdTestLos03(viewpos, rooms, &diff, types, geoflags)) { return true; } return false; } -bool cd0002f450(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 arg4) +bool cdIsNearlyInSight(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 types) { - return cd0002f308(viewpos, rooms, targetpos, distance, arg4, 8); + return cdIsNearlyInSightWithFlags(viewpos, rooms, targetpos, distance, types, GEOFLAG_BLOCK_SIGHT); }