Read pad data directly rather than copying it to the stack
This commit is contained in:
parent
0b87a5af75
commit
66f99b50d6
|
|
@ -345,7 +345,7 @@ s32 bodyChooseHead(s32 bodynum)
|
|||
*/
|
||||
void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex)
|
||||
{
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
s16 rooms[2];
|
||||
struct chrdata *chr;
|
||||
struct modelfiledata *headfiledata;
|
||||
|
|
@ -356,12 +356,12 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex)
|
|||
f32 angle;
|
||||
s32 index;
|
||||
|
||||
padUnpack(packed->padnum, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[packed->padnum];
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
if (cdTestVolume(&pad.pos, 20, rooms, CDTYPE_ALL, CHECKVERTICAL_YES, 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;
|
||||
|
|
@ -411,8 +411,8 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex)
|
|||
}
|
||||
|
||||
if (model != NULL) {
|
||||
angle = atan2f(pad.look.x, pad.look.z);
|
||||
prop = chrAllocate(model, &pad.pos, rooms, angle, ailistFindById(packed->ailistnum));
|
||||
angle = atan2f(pad->look.x, pad->look.z);
|
||||
prop = chrAllocate(model, &pad->pos, rooms, angle, ailistFindById(packed->ailistnum));
|
||||
|
||||
if (prop != NULL) {
|
||||
propActivate(prop);
|
||||
|
|
|
|||
|
|
@ -2949,14 +2949,12 @@ void botTickUnpaused(struct chrdata *chr)
|
|||
} else if (g_MpSetup.scenario == MPSCENARIO_CAPTURETHECASE) {
|
||||
// If the bot is holding an opponent's token, take it home
|
||||
if (botShouldReturnCtcToken(chr)) {
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
s32 teamindex = g_ScenarioData.ctc.teamindexes[radarGetTeamIndex(chr->team)];
|
||||
newaction = MA_AIBOTGOTOPOS;
|
||||
padUnpack(g_ScenarioData.ctc.spawnpadsperteam[teamindex].homepad, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
aibot->gotopos.x = pad.pos.x;
|
||||
aibot->gotopos.y = pad.pos.y;
|
||||
aibot->gotopos.z = pad.pos.z;
|
||||
aibot->gotorooms[0] = pad.room;
|
||||
pad = &g_Pads[g_ScenarioData.ctc.spawnpadsperteam[teamindex].homepad];
|
||||
aibot->gotopos = pad->pos;
|
||||
aibot->gotorooms[0] = pad->room;
|
||||
aibot->gotorooms[1] = -1;
|
||||
aibot->unk04c_00 = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -480,17 +480,14 @@ bool botactFindRocketRoute(struct chrdata *chr, struct coord *frompos, struct co
|
|||
*/
|
||||
void botactGetRocketNextStepPos(u16 padnum, struct coord *pos)
|
||||
{
|
||||
struct pad pad;
|
||||
s16 rooms[2];
|
||||
|
||||
padUnpack(padnum, PADFIELD_ROOM | PADFIELD_POS, &pad);
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = g_Pads[padnum].room;
|
||||
rooms[1] = -1;
|
||||
|
||||
pos->x = pad.pos.x;
|
||||
pos->y = cdFindFloorYColourTypeAtPos(&pad.pos, rooms, 0, 0) + 150;
|
||||
pos->z = pad.pos.z;
|
||||
pos->x = g_Pads[padnum].pos.x;
|
||||
pos->y = cdFindFloorYColourTypeAtPos(&g_Pads[padnum].pos, rooms, 0, 0) + 150;
|
||||
pos->z = g_Pads[padnum].pos.z;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ bool botroomFindPos(s16 room, struct coord *pos, f32 *angleptr, s32 *padnumptr,
|
|||
s32 padnums[40]; // written to stack
|
||||
s32 padcount;
|
||||
s32 totalcount;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
bool sp54;
|
||||
bool sp50;
|
||||
s32 count;
|
||||
|
|
@ -105,14 +105,12 @@ bool botroomFindPos(s16 room, struct coord *pos, f32 *angleptr, s32 *padnumptr,
|
|||
waypointnum = g_Vars.waypointnums[g_Rooms[room].firstwaypoint + i];
|
||||
waypoint = &g_StageSetup.waypoints[waypointnum];
|
||||
|
||||
padUnpack(waypoint->padnum, PADFIELD_FLAGS, &pad);
|
||||
|
||||
if (sp50 && (pad.flags & PADFLAG_20000)) {
|
||||
if (sp50 && (g_Pads[waypoint->padnum].flags & PADFLAG_20000)) {
|
||||
padUnsetFlag(waypoint->padnum, PADFLAG_20000);
|
||||
padnums[padcount] = waypoint->padnum;
|
||||
padcount++;
|
||||
totalcount++;
|
||||
} else if ((pad.flags & PADFLAG_20000) == 0) {
|
||||
} else if ((g_Pads[waypoint->padnum].flags & PADFLAG_20000) == 0) {
|
||||
padnums[padcount] = waypoint->padnum;
|
||||
padcount++;
|
||||
totalcount++;
|
||||
|
|
@ -149,13 +147,14 @@ bool botroomFindPos(s16 room, struct coord *pos, f32 *angleptr, s32 *padnumptr,
|
|||
*covernumptr = covernums[i];
|
||||
} else {
|
||||
i -= covercount;
|
||||
padUnpack(padnums[i], PADFIELD_POS | PADFIELD_LOOK, &pad);
|
||||
|
||||
pos->x = pad.pos.x;
|
||||
pos->y = pad.pos.y;
|
||||
pos->z = pad.pos.z;
|
||||
pad = &g_Pads[padnums[i]];
|
||||
|
||||
*angleptr = atan2f(pad.look.z, pad.look.x);
|
||||
pos->x = pad->pos.x;
|
||||
pos->y = pad->pos.y;
|
||||
pos->z = pad->pos.z;
|
||||
|
||||
*angleptr = atan2f(pad->look.z, pad->look.x);
|
||||
*padnumptr = padnums[i];
|
||||
*covernumptr = -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5366,20 +5366,20 @@ void chrGoPosInitMagic(struct chrdata *chr, struct waydata *waydata, struct coor
|
|||
void chrGoPosGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 *flags)
|
||||
{
|
||||
struct waypoint *waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex];
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
if (waypoint) {
|
||||
padUnpack(waypoint->padnum, PADFIELD_POS | PADFIELD_ROOM | PADFIELD_FLAGS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
pos->x = pad.pos.x;
|
||||
pos->y = pad.pos.y;
|
||||
pos->z = pad.pos.z;
|
||||
pos->x = pad->pos.x;
|
||||
pos->y = pad->pos.y;
|
||||
pos->z = pad->pos.z;
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
if (flags) {
|
||||
*flags = pad.flags;
|
||||
*flags = pad->flags;
|
||||
}
|
||||
} else {
|
||||
pos->x = chr->act_gopos.endpos.x;
|
||||
|
|
@ -5605,19 +5605,19 @@ s16 chrPatrolCalculatePadNum(struct chrdata *chr, s32 numsteps)
|
|||
void chrPatrolGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 *flags)
|
||||
{
|
||||
s32 padnum = chrPatrolCalculatePadNum(chr, 0);
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_ROOM | PADFIELD_FLAGS, &pad);
|
||||
pad = &g_Pads[padnum];
|
||||
|
||||
pos->x = pad.pos.x;
|
||||
pos->y = pad.pos.y;
|
||||
pos->z = pad.pos.z;
|
||||
pos->x = pad->pos.x;
|
||||
pos->y = pad->pos.y;
|
||||
pos->z = pad->pos.z;
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
if (flags) {
|
||||
*flags = pad.flags;
|
||||
*flags = pad->flags;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5664,7 +5664,6 @@ void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, st
|
|||
struct coord spdc;
|
||||
s16 spcc[8];
|
||||
u32 stack[4];
|
||||
struct pad pad;
|
||||
struct coord sp5c;
|
||||
s16 sp4c[8];
|
||||
|
||||
|
|
@ -5726,8 +5725,7 @@ void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, st
|
|||
} else {
|
||||
if (chr->act_gopos.curindex >= 2) {
|
||||
waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex - 2];
|
||||
padUnpack(waypoint->padnum, PADFIELD_POS, &pad);
|
||||
chrSetLookAngle(chr, atan2f(prop->pos.x - pad.pos.x, prop->pos.z - pad.pos.z));
|
||||
chrSetLookAngle(chr, atan2f(prop->pos.x - g_Pads[waypoint->padnum].pos.x, prop->pos.z - g_Pads[waypoint->padnum].pos.z));
|
||||
}
|
||||
|
||||
if (CHRRACE(chr) == RACE_HUMAN || CHRRACE(chr) == RACE_SKEDAR) {
|
||||
|
|
@ -6251,7 +6249,7 @@ void chrStartPatrol(struct chrdata *chr, struct path *path)
|
|||
f32 xdiff;
|
||||
f32 zdiff;
|
||||
s32 *padnumptr;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
struct coord nextpos;
|
||||
s16 nextrooms[8];
|
||||
s16 rooms[8];
|
||||
|
|
@ -6268,16 +6266,16 @@ void chrStartPatrol(struct chrdata *chr, struct path *path)
|
|||
// maybe a line of sight check?
|
||||
if (chr->patrolnextstep >= 0 && chr->patrolnextstep < path->len) {
|
||||
padnumptr = &path->pads[chr->patrolnextstep];
|
||||
padUnpack(*padnumptr, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[*padnumptr];
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
chrGetBbox(prop, &radius, &ymax, &ymin);
|
||||
|
||||
chrSetPerimEnabled(chr, false);
|
||||
|
||||
if (cdTestCylMove04(&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;
|
||||
}
|
||||
|
|
@ -6290,10 +6288,10 @@ void chrStartPatrol(struct chrdata *chr, struct path *path)
|
|||
if (nextstep < 0) {
|
||||
for (i = 0; path->pads[i] >= 0; i++) {
|
||||
padnumptr = &path->pads[i];
|
||||
padUnpack(*padnumptr, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[*padnumptr];
|
||||
|
||||
xdiff = pad.pos.x - prop->pos.x;
|
||||
zdiff = pad.pos.z - prop->pos.z;
|
||||
xdiff = pad->pos.x - prop->pos.x;
|
||||
zdiff = pad->pos.z - prop->pos.z;
|
||||
dist = xdiff * xdiff + zdiff * zdiff;
|
||||
|
||||
if (nextstep < 0 || dist < bestdistance) {
|
||||
|
|
@ -6304,14 +6302,14 @@ void chrStartPatrol(struct chrdata *chr, struct path *path)
|
|||
}
|
||||
|
||||
padnumptr = &path->pads[nextstep];
|
||||
padUnpack(*padnumptr, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[*padnumptr];
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
// If chr has line of sight to the pad then begin the patrol,
|
||||
// otherwise use gopos to get to the starting pad
|
||||
if (func0f03654c(chr, &prop->pos, prop->rooms, &pad.pos, rooms, NULL,
|
||||
if (func0f03654c(chr, &prop->pos, prop->rooms, &pad->pos, rooms, NULL,
|
||||
chr->radius * 1.2f, CDTYPE_PATHBLOCKER | CDTYPE_BG) != CDRESULT_COLLISION) {
|
||||
chrStopFiring(chr);
|
||||
|
||||
|
|
@ -6352,10 +6350,10 @@ void chrStartPatrol(struct chrdata *chr, struct path *path)
|
|||
chr->hidden &= ~CHRHFLAG_NEEDANIM;
|
||||
}
|
||||
} else {
|
||||
sp60[0] = pad.room;
|
||||
sp60[0] = pad->room;
|
||||
sp60[1] = -1;
|
||||
|
||||
chrGoToRoomPos(chr, &pad.pos, sp60, GOPOSFLAG_FORPATHSTART);
|
||||
chrGoToRoomPos(chr, &pad->pos, sp60, GOPOSFLAG_FORPATHSTART);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7119,14 +7117,11 @@ bool chrGoToPad(struct chrdata *chr, s32 padnum, u32 goposflags)
|
|||
#endif
|
||||
{
|
||||
s16 rooms[2];
|
||||
struct pad pad;
|
||||
|
||||
padUnpack(padnum, PADFIELD_ROOM | PADFIELD_POS, &pad);
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = g_Pads[padnum].room;
|
||||
rooms[1] = -1;
|
||||
|
||||
if (chrGoToRoomPos(chr, &pad.pos, rooms, goposflags)) {
|
||||
if (chrGoToRoomPos(chr, &g_Pads[padnum].pos, rooms, goposflags)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -12571,7 +12566,7 @@ void chrNavTickMain(struct chrdata *chr, struct coord *nextpos, struct waydata *
|
|||
bool chrGoPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, bool arrivingatlift, s16 curpadnum, s32 nextpadnum)
|
||||
{
|
||||
bool advance = false;
|
||||
struct pad nextpad;
|
||||
struct pad *nextpad;
|
||||
u32 nextpadflags = 0;
|
||||
f32 nextground;
|
||||
f32 lifty;
|
||||
|
|
@ -12588,8 +12583,7 @@ bool chrGoPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, b
|
|||
lifty = liftGetY(lift);
|
||||
|
||||
if (nextpadnum >= 0) {
|
||||
padUnpack(nextpadnum, PADFIELD_POS | PADFIELD_ROOM | PADFIELD_FLAGS, &nextpad);
|
||||
nextpadflags = nextpad.flags;
|
||||
nextpadflags = nextpad->flags;
|
||||
}
|
||||
|
||||
if (curpadflags & PADFLAG_AIWAITLIFT) {
|
||||
|
|
@ -12621,7 +12615,7 @@ bool chrGoPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, b
|
|||
|
||||
if (nextpadnum >= 0) {
|
||||
// Call the lift
|
||||
chrOpenDoor(chr, &nextpad.pos);
|
||||
chrOpenDoor(chr, &nextpad->pos);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -12652,9 +12646,9 @@ bool chrGoPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, b
|
|||
s16 rooms[] = {0, -1};
|
||||
u32 stack2;
|
||||
|
||||
rooms[0] = nextpad.room;
|
||||
rooms[0] = nextpad->room;
|
||||
|
||||
nextground = cdFindFloorYColourTypeAtPos(&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);
|
||||
|
|
@ -12723,7 +12717,7 @@ void chrTickGoPos(struct chrdata *chr)
|
|||
s16 nextrooms[8];
|
||||
struct prop *prop = chr->prop;
|
||||
bool enteringmagic = false;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
bool sp240 = true;
|
||||
struct coord curwppos;
|
||||
s16 curwprooms[8];
|
||||
|
|
@ -12829,28 +12823,28 @@ void chrTickGoPos(struct chrdata *chr)
|
|||
f32 sp160;
|
||||
f32 sp156;
|
||||
struct waypoint *next;
|
||||
struct pad pad2;
|
||||
struct pad *pad2;
|
||||
|
||||
waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex];
|
||||
|
||||
if (waypoint) {
|
||||
padUnpack(waypoint->padnum, PADFIELD_FLAGS | PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
// Both of these functions are calculating something with the coords
|
||||
// and are returning a boolean. There are no write operations.
|
||||
sp188 = posIsArrivingAtPos(&chr->prevpos, &prop->pos, &pad.pos, 30);
|
||||
sp184 = posIsArrivingLaterallyAtPos(&chr->prevpos, &prop->pos, &pad.pos, 30);
|
||||
sp188 = posIsArrivingAtPos(&chr->prevpos, &prop->pos, &pad->pos, 30);
|
||||
sp184 = posIsArrivingLaterallyAtPos(&chr->prevpos, &prop->pos, &pad->pos, 30);
|
||||
|
||||
if (pad.flags & PADFLAG_AIDUCK) {
|
||||
if (pad->flags & PADFLAG_AIDUCK) {
|
||||
chr->act_gopos.flags |= GOPOSFLAG_DUCK;
|
||||
} else if (pad.flags & PADFLAG_10000) {
|
||||
} else if (pad->flags & PADFLAG_10000) {
|
||||
chr->act_gopos.flags |= GOPOSFLAG_WALKDIRECT;
|
||||
}
|
||||
|
||||
if ((pad.flags & PADFLAG_AIWAITLIFT) || (pad.flags & PADFLAG_AIONLIFT)) {
|
||||
advance = chrGoPosUpdateLiftAction(chr, pad.flags, sp184, sp188, waypoint->padnum, chrGoPosGetNextPadNum(chr));
|
||||
if ((pad->flags & PADFLAG_AIWAITLIFT) || (pad->flags & PADFLAG_AIONLIFT)) {
|
||||
advance = chrGoPosUpdateLiftAction(chr, pad->flags, sp184, sp188, waypoint->padnum, chrGoPosGetNextPadNum(chr));
|
||||
} else {
|
||||
if (sp188 || (sp184 && (chr->inlift || (pad.flags & PADFLAG_8000)))) {
|
||||
if (sp188 || (sp184 && (chr->inlift || (pad->flags & PADFLAG_8000)))) {
|
||||
advance = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -12880,9 +12874,9 @@ void chrTickGoPos(struct chrdata *chr)
|
|||
waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex];
|
||||
|
||||
if (waypoint) {
|
||||
padUnpack(waypoint->padnum, PADFIELD_FLAGS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
if ((pad.flags & PADFLAG_AIWALKDIRECT) == 0) {
|
||||
if ((pad->flags & PADFLAG_AIWALKDIRECT) == 0) {
|
||||
// The waypoint the chr is running to doesn't have
|
||||
// PADFLAG_AIWALKDIRECT, so the chr is able to ignore it and run
|
||||
// towards the next one if it's in sight.
|
||||
|
|
@ -12891,21 +12885,21 @@ void chrTickGoPos(struct chrdata *chr)
|
|||
waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex + 1];
|
||||
|
||||
if (waypoint) {
|
||||
padUnpack(waypoint->padnum, PADFIELD_FLAGS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
if ((pad.flags & PADFLAG_AIWALKDIRECT) == 0) {
|
||||
if ((pad->flags & PADFLAG_AIWALKDIRECT) == 0) {
|
||||
// And this one doesn't have PADFLAG_AIWALKDIRECT either,
|
||||
// so the chr can consider skipping this one too.
|
||||
waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex + 2];
|
||||
|
||||
if (waypoint) {
|
||||
padUnpack(waypoint->padnum, PADFIELD_ROOM | PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
nextpos.x = pad.pos.x;
|
||||
nextpos.y = pad.pos.y;
|
||||
nextpos.z = pad.pos.z;
|
||||
nextpos.x = pad->pos.x;
|
||||
nextpos.y = pad->pos.y;
|
||||
nextpos.z = pad->pos.z;
|
||||
|
||||
nextrooms[0] = pad.room;
|
||||
nextrooms[0] = pad->room;
|
||||
nextrooms[1] = -1;
|
||||
} else {
|
||||
nextpos.x = chr->act_gopos.endpos.x;
|
||||
|
|
@ -12931,26 +12925,26 @@ void chrTickGoPos(struct chrdata *chr)
|
|||
|
||||
if (waypoint) {
|
||||
candosomething = (chr->act_gopos.flags & GOPOSFLAG_INIT) != 0;
|
||||
padUnpack(waypoint->padnum, PADFIELD_FLAGS | PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
next = chr->act_gopos.waypoints[chr->act_gopos.curindex + 1];
|
||||
|
||||
if (next) {
|
||||
padUnpack(next->padnum, PADFIELD_ROOM | PADFIELD_POS, &pad2);
|
||||
pad2 = &g_Pads[next->padnum];
|
||||
|
||||
if ((pad.flags & (PADFLAG_AIWAITLIFT | PADFLAG_AIONLIFT))
|
||||
&& (pad2.flags & (PADFLAG_AIWAITLIFT | PADFLAG_AIONLIFT))) {
|
||||
if ((pad->flags & (PADFLAG_AIWAITLIFT | PADFLAG_AIONLIFT))
|
||||
&& (pad2->flags & (PADFLAG_AIWAITLIFT | PADFLAG_AIONLIFT))) {
|
||||
candosomething = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pad.flags & PADFLAG_AIWALKDIRECT) == 0 || candosomething) {
|
||||
if ((pad->flags & PADFLAG_AIWALKDIRECT) == 0 || candosomething) {
|
||||
if (next) {
|
||||
nextpos.x = pad2.pos.x;
|
||||
nextpos.y = pad2.pos.y;
|
||||
nextpos.z = pad2.pos.z;
|
||||
nextpos.x = pad2->pos.x;
|
||||
nextpos.y = pad2->pos.y;
|
||||
nextpos.z = pad2->pos.z;
|
||||
|
||||
nextrooms[0] = pad2.room;
|
||||
nextrooms[0] = pad2->room;
|
||||
nextrooms[1] = -1;
|
||||
} else {
|
||||
nextpos.x = chr->act_gopos.endpos.x;
|
||||
|
|
@ -12961,12 +12955,12 @@ void chrTickGoPos(struct chrdata *chr)
|
|||
}
|
||||
|
||||
// I suspect this is making the chr turn to face the next pad
|
||||
if ((pad.flags & PADFLAG_AIWALKDIRECT) && candosomething) {
|
||||
if ((pad->flags & PADFLAG_AIWALKDIRECT) && candosomething) {
|
||||
if (true) {
|
||||
sp180 = prop->pos.x - pad.pos.x;
|
||||
sp176 = prop->pos.z - pad.pos.z;
|
||||
sp172 = nextpos.x - pad.pos.x;
|
||||
sp168 = nextpos.z - pad.pos.z;
|
||||
sp180 = prop->pos.x - pad->pos.x;
|
||||
sp176 = prop->pos.z - pad->pos.z;
|
||||
sp172 = nextpos.x - pad->pos.x;
|
||||
sp168 = nextpos.z - pad->pos.z;
|
||||
}
|
||||
|
||||
sp156 = sqrtf((sp180 * sp180 + sp176 * sp176) * (sp172 * sp172 + sp168 * sp168));
|
||||
|
|
@ -12995,11 +12989,9 @@ void chrTickGoPos(struct chrdata *chr)
|
|||
waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex];
|
||||
|
||||
if (waypoint) {
|
||||
padUnpack(waypoint->padnum, PADFIELD_POS, &pad);
|
||||
|
||||
nextpos.x = pad.pos.x;
|
||||
nextpos.y = pad.pos.y;
|
||||
nextpos.z = pad.pos.z;
|
||||
nextpos.x = g_Pads[waypoint->padnum].pos.x;
|
||||
nextpos.y = g_Pads[waypoint->padnum].pos.y;
|
||||
nextpos.z = g_Pads[waypoint->padnum].pos.z;
|
||||
} else {
|
||||
nextpos.x = chr->act_gopos.endpos.x;
|
||||
nextpos.y = chr->act_gopos.endpos.y;
|
||||
|
|
@ -13741,7 +13733,6 @@ void chrGetAttackEntityPos(struct chrdata *chr, u32 attackflags, s32 entityid, s
|
|||
{
|
||||
struct prop *targetprop;
|
||||
struct chrdata *targetchr;
|
||||
struct pad pad;
|
||||
|
||||
if (attackflags & ATTACKFLAG_AIMATCHR) {
|
||||
// Aiming at a chr by chrnum
|
||||
|
|
@ -13767,13 +13758,12 @@ void chrGetAttackEntityPos(struct chrdata *chr, u32 attackflags, s32 entityid, s
|
|||
} else if (attackflags & ATTACKFLAG_AIMATPAD) {
|
||||
// Aiming at a pad by padnum
|
||||
s32 padnum = chrResolvePadId(chr, entityid);
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
|
||||
pos->x = pad.pos.x;
|
||||
pos->y = pad.pos.y;
|
||||
pos->z = pad.pos.z;
|
||||
pos->x = g_Pads[padnum].pos.x;
|
||||
pos->y = g_Pads[padnum].pos.y;
|
||||
pos->z = g_Pads[padnum].pos.z;
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = g_Pads[padnum].room;
|
||||
rooms[1] = -1;
|
||||
} else {
|
||||
// Aiming at the chr's preconfigured target
|
||||
|
|
@ -13962,17 +13952,12 @@ f32 chrGetDistanceToPad(struct chrdata *chr, s32 pad_id)
|
|||
struct prop *prop = chr->prop;
|
||||
f32 xdiff, ydiff, zdiff;
|
||||
f32 distance = 0;
|
||||
struct pad pad;
|
||||
pad_id = chrResolvePadId(chr, pad_id);
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (pad_id >= 0)
|
||||
#endif
|
||||
{
|
||||
padUnpack(pad_id, PADFIELD_POS, &pad);
|
||||
xdiff = pad.pos.x - prop->pos.x;
|
||||
ydiff = pad.pos.y - prop->pos.y;
|
||||
zdiff = pad.pos.z - prop->pos.z;
|
||||
if (pad_id >= 0) {
|
||||
xdiff = g_Pads[pad_id].pos.x - prop->pos.x;
|
||||
ydiff = g_Pads[pad_id].pos.y - prop->pos.y;
|
||||
zdiff = g_Pads[pad_id].pos.z - prop->pos.z;
|
||||
distance = sqrtf(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
|
||||
}
|
||||
|
||||
|
|
@ -13984,14 +13969,13 @@ f32 chrGetSameFloorDistanceToPad(struct chrdata *chr, s32 pad_id)
|
|||
{
|
||||
struct prop *prop = chr->prop;
|
||||
f32 xdiff, ydiff, zdiff, ydiff_absolute;
|
||||
struct pad pad;
|
||||
f32 ret;
|
||||
|
||||
pad_id = chrResolvePadId(chr, pad_id);
|
||||
padUnpack(pad_id, PADFIELD_POS, &pad);
|
||||
xdiff = pad.pos.x - prop->pos.x;
|
||||
ydiff = pad.pos.y - prop->pos.y;
|
||||
zdiff = pad.pos.z - prop->pos.z;
|
||||
|
||||
xdiff = g_Pads[pad_id].pos.x - prop->pos.x;
|
||||
ydiff = g_Pads[pad_id].pos.y - prop->pos.y;
|
||||
zdiff = g_Pads[pad_id].pos.z - prop->pos.z;
|
||||
|
||||
if (ydiff > 0) {
|
||||
ydiff_absolute = ydiff;
|
||||
|
|
@ -14030,28 +14014,17 @@ f32 chrGetLateralDistanceToPad(struct chrdata *chr, s32 pad_id)
|
|||
{
|
||||
struct prop *prop = chr->prop;
|
||||
f32 xdiff, zdiff;
|
||||
struct pad pad;
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
f32 distance = 0;
|
||||
|
||||
pad_id = chrResolvePadId(chr, pad_id);
|
||||
|
||||
if (pad_id >= 0) {
|
||||
padUnpack(pad_id, PADFIELD_POS, &pad);
|
||||
xdiff = pad.pos.x - prop->pos.x;
|
||||
zdiff = pad.pos.z - prop->pos.z;
|
||||
xdiff = g_Pads[pad_id].pos.x - prop->pos.x;
|
||||
zdiff = g_Pads[pad_id].pos.z - prop->pos.z;
|
||||
distance = sqrtf(xdiff * xdiff + zdiff * zdiff);
|
||||
}
|
||||
|
||||
return distance;
|
||||
#else
|
||||
pad_id = chrResolvePadId(chr, pad_id);
|
||||
padUnpack(pad_id, PADFIELD_POS, &pad);
|
||||
xdiff = pad.pos.x - prop->pos.x;
|
||||
zdiff = pad.pos.z - prop->pos.z;
|
||||
return sqrtf(xdiff * xdiff + zdiff * zdiff);
|
||||
#endif
|
||||
}
|
||||
|
||||
f32 chrGetSquaredDistanceToCoord(struct chrdata *chr, struct coord *pos)
|
||||
|
|
@ -14076,17 +14049,12 @@ s32 chrGetPadRoom(struct chrdata *chr, s32 pad_id)
|
|||
{
|
||||
s32 ret = -1;
|
||||
s32 pad_id_backup = pad_id;
|
||||
struct pad pad;
|
||||
|
||||
if (pad_id >= 10000) {
|
||||
s32 resolved_pad_id = chrResolvePadId(chr, pad_id - 10000);
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (resolved_pad_id >= 0)
|
||||
#endif
|
||||
{
|
||||
padUnpack(resolved_pad_id, PADFIELD_ROOM, &pad);
|
||||
ret = pad.room;
|
||||
if (resolved_pad_id >= 0) {
|
||||
ret = g_Pads[resolved_pad_id].room;
|
||||
}
|
||||
} else {
|
||||
ret = pad_id;
|
||||
|
|
@ -14319,18 +14287,13 @@ f32 chrGetDistanceFromTargetToPad(struct chrdata *chr, s32 pad_id)
|
|||
{
|
||||
struct prop *prop = chrGetTargetProp(chr);
|
||||
f32 xdiff, ydiff, zdiff;
|
||||
struct pad pad;
|
||||
f32 distance = 0;
|
||||
pad_id = chrResolvePadId(chr, pad_id);
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (pad_id >= 0)
|
||||
#endif
|
||||
{
|
||||
padUnpack(pad_id, PADFIELD_POS, &pad);
|
||||
xdiff = pad.pos.x - prop->pos.x;
|
||||
ydiff = pad.pos.y - prop->pos.y;
|
||||
zdiff = pad.pos.z - prop->pos.z;
|
||||
if (pad_id >= 0) {
|
||||
xdiff = g_Pads[pad_id].pos.x - prop->pos.x;
|
||||
ydiff = g_Pads[pad_id].pos.y - prop->pos.y;
|
||||
zdiff = g_Pads[pad_id].pos.z - prop->pos.z;
|
||||
distance = sqrtf(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
|
||||
}
|
||||
|
||||
|
|
@ -14550,11 +14513,11 @@ bool waypointIsWithin90DegreesOfPosAngle(struct waypoint *waypoint, struct coord
|
|||
{
|
||||
u32 stack[3];
|
||||
f32 diffangle;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
padUnpack(waypoint->padnum, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
diffangle = angle - atan2f(pad.pos.x - pos->x, pad.pos.z - pos->z);
|
||||
diffangle = angle - atan2f(pad->pos.x - pos->x, pad->pos.z - pos->z);
|
||||
|
||||
if (diffangle < 0) {
|
||||
diffangle += M_BADTAU;
|
||||
|
|
@ -14719,16 +14682,14 @@ bool chrSetChrPresetToChrNearSelf(u8 checktype, struct chrdata *chr, f32 distanc
|
|||
|
||||
bool chrSetChrPresetToChrNearPad(u32 checktype, struct chrdata *chr, f32 distance, s32 padnum)
|
||||
{
|
||||
struct pad pad;
|
||||
s16 rooms[2];
|
||||
|
||||
padnum = chrResolvePadId(chr, padnum);
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = g_Pads[padnum].room;
|
||||
rooms[1] = -1;
|
||||
|
||||
return chrSetChrPresetToChrNearPos(checktype, chr, distance, &pad.pos, rooms);
|
||||
return chrSetChrPresetToChrNearPos(checktype, chr, distance, &g_Pads[padnum].pos, rooms);
|
||||
}
|
||||
|
||||
bool chrSetChrPresetToChrNearPos(u8 checktype, struct chrdata *chr, f32 distance, struct coord *pos, s16 *rooms)
|
||||
|
|
@ -14880,7 +14841,7 @@ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr)
|
|||
struct waypoint *waypoints[5];
|
||||
s32 numwaypoints;
|
||||
s32 i;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
if (target->type != PROPTYPE_PLAYER || g_Vars.bondvisible) {
|
||||
if (cdTestLos04(&prop->pos, prop->rooms, &target->pos, CDTYPE_BG)) {
|
||||
|
|
@ -14902,10 +14863,10 @@ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr)
|
|||
for (i = 0; waypoints[i] != NULL; i++) {
|
||||
struct waypoint *wp = waypoints[i];
|
||||
|
||||
padUnpack(wp->padnum, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[wp->padnum];
|
||||
|
||||
if (cdTestLos04(&target->pos, target->rooms, &pad.pos, CDTYPE_BG)) {
|
||||
if (cdTestLos04(&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;
|
||||
}
|
||||
|
|
@ -15204,15 +15165,18 @@ struct prop *chrSpawnAtCoord(s32 bodynum, s32 headnum, struct coord *pos, s16 *r
|
|||
struct prop *chrSpawnAtPad(struct chrdata *basechr, s32 body, s32 head, s32 pad_id, u8 *ailist, u32 spawnflags)
|
||||
{
|
||||
s32 resolved_pad_id = chrResolvePadId(basechr, pad_id);
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
s16 room[2];
|
||||
f32 fvalue;
|
||||
padUnpack(resolved_pad_id, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad);
|
||||
fvalue = atan2f(pad.look.x, pad.look.z);
|
||||
room[0] = pad.room;
|
||||
|
||||
pad = &g_Pads[resolved_pad_id];
|
||||
|
||||
fvalue = atan2f(pad->look.x, pad->look.z);
|
||||
|
||||
room[0] = pad->room;
|
||||
room[1] = -1;
|
||||
|
||||
return chrSpawnAtCoord(body, head, &pad.pos, &room[0], fvalue, ailist, spawnflags);
|
||||
return chrSpawnAtCoord(body, head, &pad->pos, &room[0], fvalue, ailist, spawnflags);
|
||||
}
|
||||
|
||||
struct prop *chrSpawnAtChr(struct chrdata *basechr, s32 body, s32 head, u32 chrnum, u8 *ailist, u32 spawnflags)
|
||||
|
|
|
|||
|
|
@ -2235,23 +2235,23 @@ u8 *aiObjectMoveToPad(u8 *cmd)
|
|||
struct defaultobj *obj = objFindByTagId(cmd[2]);
|
||||
u16 padnum = cmd[4] | (cmd[3] << 8);
|
||||
Mtxf matrix;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
s16 rooms[2];
|
||||
|
||||
if (obj && obj->prop) {
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[padnum];
|
||||
mtx00016d58(&matrix,
|
||||
0, 0, 0,
|
||||
-pad.look.x, -pad.look.y, -pad.look.z,
|
||||
pad.up.x, pad.up.y, pad.up.z);
|
||||
-pad->look.x, -pad->look.y, -pad->look.z,
|
||||
pad->up.x, pad->up.y, pad->up.z);
|
||||
|
||||
if (obj->model) {
|
||||
mtx00015f04(obj->model->scale, &matrix);
|
||||
}
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
func0f06a730(obj, &pad.pos, &matrix, rooms, &pad.pos);
|
||||
func0f06a730(obj, &pad->pos, &matrix, rooms, &pad->pos);
|
||||
}
|
||||
|
||||
cmd += 5;
|
||||
|
|
@ -4885,12 +4885,11 @@ u8 *aiChrMoveToPad(u8 *cmd)
|
|||
struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]);
|
||||
bool pass = false;
|
||||
f32 theta;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
s16 rooms[2];
|
||||
struct chrdata *chr2;
|
||||
|
||||
if (chr && chr->prop) {
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (cmd[5] == 88) {
|
||||
chr2 = chrFindById(g_Vars.chrdata, cmd[4]);
|
||||
|
||||
|
|
@ -4903,24 +4902,14 @@ u8 *aiChrMoveToPad(u8 *cmd)
|
|||
padnum = chrResolvePadId(chr, padnum);
|
||||
|
||||
if (padnum >= 0) {
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad);
|
||||
theta = atan2f(pad.look.x, pad.look.z);
|
||||
pad = &g_Pads[padnum];
|
||||
theta = atan2f(pad->look.x, pad->look.z);
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
pass = chrMoveToPos(chr, &pad.pos, rooms, theta, cmd[5]);
|
||||
pass = chrMoveToPos(chr, &pad->pos, rooms, theta, cmd[5]);
|
||||
}
|
||||
}
|
||||
#else
|
||||
padnum = chrResolvePadId(chr, padnum);
|
||||
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad);
|
||||
theta = atan2f(pad.look.x, pad.look.z);
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[1] = -1;
|
||||
pass = chrMoveToPos(chr, &pad.pos, rooms, theta, cmd[5]);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pass) {
|
||||
|
|
@ -10771,14 +10760,10 @@ u8 *aiIfObjectDistanceToPadLessThan(u8 *cmd)
|
|||
if (obj && obj->prop) {
|
||||
pad_id = chrResolvePadId(g_Vars.chrdata, pad_id);
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (pad_id >= 0)
|
||||
#endif
|
||||
{
|
||||
padUnpack(pad_id, PADFIELD_POS, &pad);
|
||||
xdiff = obj->prop->pos.x - pad.pos.x;
|
||||
ydiff = obj->prop->pos.y - pad.pos.y;
|
||||
zdiff = obj->prop->pos.z - pad.pos.z;
|
||||
if (pad_id >= 0) {
|
||||
xdiff = obj->prop->pos.x - g_Pads[pad_id].pos.x;
|
||||
ydiff = obj->prop->pos.y - g_Pads[pad_id].pos.y;
|
||||
zdiff = obj->prop->pos.z - g_Pads[pad_id].pos.z;
|
||||
|
||||
if (ydiff < 200 && ydiff > -200 &&
|
||||
xdiff < distance && xdiff > -distance &&
|
||||
|
|
|
|||
|
|
@ -1349,7 +1349,7 @@ void scenarioHandleDroppedToken(struct chrdata *chr, struct prop *prop)
|
|||
s32 i;
|
||||
struct weaponobj *weapon = prop->weapon;
|
||||
struct defaultobj *obj;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
Mtxf mtx;
|
||||
s16 rooms[2];
|
||||
|
||||
|
|
@ -1362,18 +1362,18 @@ void scenarioHandleDroppedToken(struct chrdata *chr, struct prop *prop)
|
|||
weapon->team = i;
|
||||
obj = prop->obj;
|
||||
|
||||
padUnpack(g_ScenarioData.ctc.spawnpadsperteam[g_ScenarioData.ctc.teamindexes[i]].homepad,
|
||||
PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_ROOM, &pad);
|
||||
mtx00016d58(&mtx, 0, 0, 0, -pad.look.x, -pad.look.y, -pad.look.z, pad.up.x, pad.up.y, pad.up.z);
|
||||
pad = &g_Pads[g_ScenarioData.ctc.spawnpadsperteam[g_ScenarioData.ctc.teamindexes[i]].homepad];
|
||||
|
||||
mtx00016d58(&mtx, 0, 0, 0, -pad->look.x, -pad->look.y, -pad->look.z, pad->up.x, pad->up.y, pad->up.z);
|
||||
|
||||
if (obj->model) {
|
||||
mtx00015f04(obj->model->scale, &mtx);
|
||||
}
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
func0f06a730(obj, &pad.pos, &mtx, rooms, &pad.pos);
|
||||
func0f06a730(obj, &pad->pos, &mtx, rooms, &pad->pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ void kohInit(void)
|
|||
void kohInitProps(void)
|
||||
{
|
||||
s16 pad_id = 0;
|
||||
struct pad pad;
|
||||
|
||||
if (g_ScenarioData.koh.hillcount > 1) {
|
||||
g_ScenarioData.koh.hillindex = random() % g_ScenarioData.koh.hillcount;
|
||||
|
|
@ -195,12 +194,11 @@ void kohInitProps(void)
|
|||
g_ScenarioData.koh.hillindex = 0;
|
||||
}
|
||||
|
||||
padUnpack(pad_id, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
g_ScenarioData.koh.hillrooms[0] = pad.room;
|
||||
g_ScenarioData.koh.hillrooms[0] = g_Pads[pad_id].room;
|
||||
g_ScenarioData.koh.hillrooms[1] = -1;
|
||||
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.x = g_Pads[pad_id].pos.x;
|
||||
g_ScenarioData.koh.hillpos.y = g_Pads[pad_id].pos.y;
|
||||
g_ScenarioData.koh.hillpos.z = g_Pads[pad_id].pos.z;
|
||||
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);
|
||||
|
|
@ -283,14 +281,12 @@ void kohTick(void)
|
|||
g_ScenarioData.koh.hillindex = 0;
|
||||
}
|
||||
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
|
||||
g_ScenarioData.koh.hillrooms[0] = pad.room;
|
||||
g_ScenarioData.koh.hillrooms[0] = g_Pads[padnum].room;
|
||||
g_ScenarioData.koh.hillrooms[1] = -1;
|
||||
|
||||
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.x = g_Pads[padnum].pos.x;
|
||||
g_ScenarioData.koh.hillpos.y = g_Pads[padnum].pos.y;
|
||||
g_ScenarioData.koh.hillpos.z = g_Pads[padnum].pos.z;
|
||||
|
||||
g_ScenarioData.koh.hillpos.y = cdFindFloorYColourTypeAtPos(&g_ScenarioData.koh.hillpos, g_ScenarioData.koh.hillrooms, NULL, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,24 +27,22 @@ bool padHasBboxData(s32 padnum)
|
|||
|
||||
void padGetCentre(s32 padnum, struct coord *coord)
|
||||
{
|
||||
struct pad pad;
|
||||
struct pad *pad = &g_Pads[padnum];
|
||||
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_NORMAL | PADFIELD_BBOX, &pad);
|
||||
coord->x = pad->pos.f[0] + (
|
||||
(pad->bbox.xmin + pad->bbox.xmax) * pad->normal.f[0] +
|
||||
(pad->bbox.ymin + pad->bbox.ymax) * pad->up.f[0] +
|
||||
(pad->bbox.zmin + pad->bbox.zmax) * pad->look.f[0]) * 0.5f;
|
||||
|
||||
coord->x = pad.pos.f[0] + (
|
||||
(pad.bbox.xmin + pad.bbox.xmax) * pad.normal.f[0] +
|
||||
(pad.bbox.ymin + pad.bbox.ymax) * pad.up.f[0] +
|
||||
(pad.bbox.zmin + pad.bbox.zmax) * pad.look.f[0]) * 0.5f;
|
||||
coord->y = pad->pos.f[1] + (
|
||||
(pad->bbox.xmin + pad->bbox.xmax) * pad->normal.f[1] +
|
||||
(pad->bbox.ymin + pad->bbox.ymax) * pad->up.f[1] +
|
||||
(pad->bbox.zmin + pad->bbox.zmax) * pad->look.f[1]) * 0.5f;
|
||||
|
||||
coord->y = pad.pos.f[1] + (
|
||||
(pad.bbox.xmin + pad.bbox.xmax) * pad.normal.f[1] +
|
||||
(pad.bbox.ymin + pad.bbox.ymax) * pad.up.f[1] +
|
||||
(pad.bbox.zmin + pad.bbox.zmax) * pad.look.f[1]) * 0.5f;
|
||||
|
||||
coord->z = pad.pos.f[2] + (
|
||||
(pad.bbox.xmin + pad.bbox.xmax) * pad.normal.f[2] +
|
||||
(pad.bbox.ymin + pad.bbox.ymax) * pad.up.f[2] +
|
||||
(pad.bbox.zmin + pad.bbox.zmax) * pad.look.f[2]) * 0.5f;
|
||||
coord->z = pad->pos.f[2] + (
|
||||
(pad->bbox.xmin + pad->bbox.xmax) * pad->normal.f[2] +
|
||||
(pad->bbox.ymin + pad->bbox.ymax) * pad->up.f[2] +
|
||||
(pad->bbox.zmin + pad->bbox.zmax) * pad->look.f[2]) * 0.5f;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -70,13 +70,13 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms)
|
|||
f32 sqdist;
|
||||
s32 k;
|
||||
u32 stack;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
padUnpack(waypoint->padnum, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[waypoint->padnum];
|
||||
|
||||
sqdist = (pos->f[0] - pad.pos.f[0]) * (pos->f[0] - pad.pos.f[0])
|
||||
+ (pos->f[1] - pad.pos.f[1]) * (pos->f[1] - pad.pos.f[1])
|
||||
+ (pos->f[2] - pad.pos.f[2]) * (pos->f[2] - pad.pos.f[2]);
|
||||
sqdist = (pos->f[0] - pad->pos.f[0]) * (pos->f[0] - pad->pos.f[0])
|
||||
+ (pos->f[1] - pad->pos.f[1]) * (pos->f[1] - pad->pos.f[1])
|
||||
+ (pos->f[2] - pad->pos.f[2]) * (pos->f[2] - pad->pos.f[2]);
|
||||
|
||||
// Find the index where this waypoint should go
|
||||
// into the candidates list
|
||||
|
|
@ -113,16 +113,16 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms)
|
|||
|
||||
// Check which candidates have line of sight
|
||||
for (i = 0; i < candlen; i++) {
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
s16 padrooms[8];
|
||||
|
||||
padUnpack(candwaypoints[i]->padnum, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[candwaypoints[i]->padnum];
|
||||
|
||||
padrooms[0] = pad.room;
|
||||
padrooms[0] = pad->room;
|
||||
padrooms[1] = -1;
|
||||
|
||||
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 (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;
|
||||
|
|
@ -146,16 +146,13 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms)
|
|||
// crtieria relating to collisions.
|
||||
for (i = 0; i < candlen; i++) {
|
||||
if (checkmore[i] && (sp250[i].x != sp1d8[i].x || sp250[i].z != sp1d8[i].z)) {
|
||||
struct pad pad;
|
||||
s16 padrooms[8];
|
||||
struct coord sp98;
|
||||
struct coord tmppos;
|
||||
s16 tmprooms[8];
|
||||
f32 mult;
|
||||
|
||||
padUnpack(candwaypoints[i]->padnum, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
|
||||
padrooms[0] = pad.room;
|
||||
padrooms[0] = g_Pads[candwaypoints[i]->padnum].room;
|
||||
padrooms[1] = -1;
|
||||
|
||||
sp98.f[0] = sp250[i].x - sp1d8[i].x;
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
s32 playercount = PLAYERCOUNT();
|
||||
f32 dstangle;
|
||||
u8 stack2[0x10];
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
s32 stack3[2];
|
||||
s16 tmppadrooms[2];
|
||||
f32 bestsqdist;
|
||||
|
|
@ -246,7 +246,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
// Iterate all spawn pads and populate the category arrays
|
||||
for (p = 0; p < numpads; p++) {
|
||||
bestsqdist = U32_MAX;
|
||||
padUnpack(pads[p], PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[pads[p]];
|
||||
verybadpads[p] = false;
|
||||
badpads[p] = false;
|
||||
|
||||
|
|
@ -257,9 +257,9 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
if (g_Vars.players[i]->prop
|
||||
&& g_Vars.players[i]->prop != prop
|
||||
&& (!prop || chrCompareTeams(prop->chr, g_Vars.players[i]->prop->chr, COMPARE_ENEMIES))) {
|
||||
xdiff = g_Vars.players[i]->prop->pos.x - pad.pos.x;
|
||||
ydiff = g_Vars.players[i]->prop->pos.y - pad.pos.y;
|
||||
zdiff = g_Vars.players[i]->prop->pos.z - pad.pos.z;
|
||||
xdiff = g_Vars.players[i]->prop->pos.x - pad->pos.x;
|
||||
ydiff = g_Vars.players[i]->prop->pos.y - pad->pos.y;
|
||||
zdiff = g_Vars.players[i]->prop->pos.z - pad->pos.z;
|
||||
|
||||
sqdist = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
|
||||
|
||||
|
|
@ -267,29 +267,29 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
bestsqdist = sqdist;
|
||||
}
|
||||
|
||||
if (roomIsOnPlayerScreen(pad.room, i)) {
|
||||
if (roomIsOnPlayerScreen(pad->room, i)) {
|
||||
verybadpads[p] = true;
|
||||
}
|
||||
|
||||
if (verybadpads[p] || roomIsOnPlayerStandby(pad.room, i)) {
|
||||
if (verybadpads[p] || roomIsOnPlayerStandby(pad->room, i)) {
|
||||
badpads[p] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do the same as above, but for simulants
|
||||
tmppadrooms[0] = pad.room;
|
||||
tmppadrooms[0] = pad->room;
|
||||
tmppadrooms[1] = -1;
|
||||
|
||||
roomGetNeighbours(pad.room, neighbours, 20);
|
||||
roomGetNeighbours(pad->room, neighbours, 20);
|
||||
|
||||
for (i = 0; i < g_BotCount; i++) {
|
||||
if (g_MpBotChrPtrs[i]->prop
|
||||
&& g_MpBotChrPtrs[i]->prop != prop
|
||||
&& (!prop || chrCompareTeams(prop->chr, g_MpBotChrPtrs[i], COMPARE_ENEMIES))) {
|
||||
xdiff = g_MpBotChrPtrs[i]->prop->pos.x - pad.pos.x;
|
||||
ydiff = g_MpBotChrPtrs[i]->prop->pos.y - pad.pos.y;
|
||||
zdiff = g_MpBotChrPtrs[i]->prop->pos.z - pad.pos.z;
|
||||
xdiff = g_MpBotChrPtrs[i]->prop->pos.x - pad->pos.x;
|
||||
ydiff = g_MpBotChrPtrs[i]->prop->pos.y - pad->pos.y;
|
||||
zdiff = g_MpBotChrPtrs[i]->prop->pos.z - pad->pos.z;
|
||||
|
||||
sqdist = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
|
||||
|
||||
|
|
@ -320,16 +320,16 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
p = i; \
|
||||
while (sllen < 4) {
|
||||
if (padsqdists[p] > 1000 * 1000 && !badpads[p]) {
|
||||
padUnpack(pads[p], PADFIELD_POS | PADFIELD_ROOM | PADFIELD_LOOK, &pad);
|
||||
pad = &g_Pads[pads[p]];
|
||||
|
||||
slrooms[sllen][0] = pad.room;
|
||||
slrooms[sllen][0] = pad->room;
|
||||
slrooms[sllen][1] = -1;
|
||||
|
||||
slpositions[sllen].x = pad.pos.x;
|
||||
slpositions[sllen].y = pad.pos.y;
|
||||
slpositions[sllen].z = pad.pos.z;
|
||||
slpositions[sllen].x = pad->pos.x;
|
||||
slpositions[sllen].y = pad->pos.y;
|
||||
slpositions[sllen].z = pad->pos.z;
|
||||
|
||||
slangles[sllen] = atan2f(pad.look.x, pad.look.z);
|
||||
slangles[sllen] = atan2f(pad->look.x, pad->look.z);
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (chrAdjustPosForSpawn(chrradius, &slpositions[sllen], slrooms[sllen], slangles[sllen], true, false, false)) {
|
||||
|
|
@ -359,16 +359,16 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
|
||||
while (sllen < 4) {
|
||||
if (padsqdists[p] > 1000 * 1000 && !verybadpads[p]) {
|
||||
padUnpack(pads[p], PADFIELD_POS | PADFIELD_ROOM | PADFIELD_LOOK, &pad);
|
||||
pad = &g_Pads[pads[p]];
|
||||
|
||||
slrooms[sllen][0] = pad.room;
|
||||
slrooms[sllen][0] = pad->room;
|
||||
slrooms[sllen][1] = -1;
|
||||
|
||||
slpositions[sllen].x = pad.pos.x;
|
||||
slpositions[sllen].y = pad.pos.y;
|
||||
slpositions[sllen].z = pad.pos.z;
|
||||
slpositions[sllen].x = pad->pos.x;
|
||||
slpositions[sllen].y = pad->pos.y;
|
||||
slpositions[sllen].z = pad->pos.z;
|
||||
|
||||
slangles[sllen] = atan2f(pad.look.x, pad.look.z);
|
||||
slangles[sllen] = atan2f(pad->look.x, pad->look.z);
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (chrAdjustPosForSpawn(chrradius, &slpositions[sllen], slrooms[sllen], slangles[sllen], true, false, false)) {
|
||||
|
|
@ -420,16 +420,16 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
}
|
||||
|
||||
// Add this pad to the shortlist
|
||||
padUnpack(pads[i], PADFIELD_POS | PADFIELD_ROOM | PADFIELD_LOOK, &pad);
|
||||
pad = &g_Pads[pads[i]];
|
||||
|
||||
slrooms[sllen][0] = pad.room;
|
||||
slrooms[sllen][0] = pad->room;
|
||||
slrooms[sllen][1] = -1;
|
||||
|
||||
slpositions[sllen].x = pad.pos.x;
|
||||
slpositions[sllen].y = pad.pos.y;
|
||||
slpositions[sllen].z = pad.pos.z;
|
||||
slpositions[sllen].x = pad->pos.x;
|
||||
slpositions[sllen].y = pad->pos.y;
|
||||
slpositions[sllen].z = pad->pos.z;
|
||||
|
||||
slangles[sllen] = atan2f(pad.look.x, pad.look.z);
|
||||
slangles[sllen] = atan2f(pad->look.x, pad->look.z);
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (chrAdjustPosForSpawn(chrradius, &slpositions[sllen], slrooms[sllen], slangles[sllen], true, false, false)) {
|
||||
|
|
@ -459,16 +459,16 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms
|
|||
dstangle = slangles[p];
|
||||
} else {
|
||||
// No shortlisted pads, so pick a random one from the full selection
|
||||
padUnpack(pads[random() % numpads], PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[pads[random() % numpads]];
|
||||
|
||||
dstrooms[0] = pad.room;
|
||||
dstrooms[0] = pad->room;
|
||||
dstrooms[1] = -1;
|
||||
|
||||
dstpos->x = pad.pos.x;
|
||||
dstpos->y = pad.pos.y;
|
||||
dstpos->z = pad.pos.z;
|
||||
dstpos->x = pad->pos.x;
|
||||
dstpos->y = pad->pos.y;
|
||||
dstpos->z = pad->pos.z;
|
||||
|
||||
dstangle = atan2f(pad.look.x, pad.look.z);
|
||||
dstangle = atan2f(pad->look.x, pad->look.z);
|
||||
}
|
||||
|
||||
return dstangle;
|
||||
|
|
@ -1711,7 +1711,6 @@ void playerPrepareWarpType3(f32 posangle, f32 rotangle, f32 range, f32 height1,
|
|||
|
||||
void playerExecutePreparedWarp(void)
|
||||
{
|
||||
struct pad pad;
|
||||
struct coord pos = {0, 0, 0};
|
||||
struct coord look = {0, 0, 1};
|
||||
struct coord up = {0, 1, 0};
|
||||
|
|
@ -1724,17 +1723,15 @@ void playerExecutePreparedWarp(void)
|
|||
// Warp to an exact position with a static direction of 0, 0, 1.
|
||||
// Used by device and holo training to warp player back to room,
|
||||
// and Deep Sea teleports
|
||||
padUnpack(g_WarpType1Pad, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
|
||||
memcampos.x = pad.pos.x;
|
||||
memcampos.y = pad.pos.y;
|
||||
memcampos.z = pad.pos.z;
|
||||
memcampos.x = g_Pads[g_WarpType1Pad].pos.x;
|
||||
memcampos.y = g_Pads[g_WarpType1Pad].pos.y;
|
||||
memcampos.z = g_Pads[g_WarpType1Pad].pos.z;
|
||||
|
||||
pos.x = memcampos.f[0];
|
||||
pos.y = memcampos.f[1];
|
||||
pos.z = memcampos.f[2];
|
||||
|
||||
room = pad.room;
|
||||
room = g_Pads[g_WarpType1Pad].room;
|
||||
} else if (g_WarpType2Params) {
|
||||
// Warp to an exact position with an optional direction.
|
||||
// Used by AI command 00df, but that command is not used.
|
||||
|
|
@ -1742,13 +1739,11 @@ void playerExecutePreparedWarp(void)
|
|||
pos.y = g_WarpType2Params->pos.y;
|
||||
pos.z = g_WarpType2Params->pos.z;
|
||||
|
||||
padUnpack(g_WarpType2Params->pad, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
room = g_Pads[g_WarpType2Params->pad].room;
|
||||
|
||||
room = pad.room;
|
||||
|
||||
memcampos.x = pad.pos.x;
|
||||
memcampos.y = pad.pos.y;
|
||||
memcampos.z = pad.pos.z;
|
||||
memcampos.x = g_Pads[g_WarpType2Params->pad].pos.x;
|
||||
memcampos.y = g_Pads[g_WarpType2Params->pad].pos.y;
|
||||
memcampos.z = g_Pads[g_WarpType2Params->pad].pos.z;
|
||||
|
||||
if (1);
|
||||
|
||||
|
|
@ -1761,13 +1756,11 @@ void playerExecutePreparedWarp(void)
|
|||
// Warp to a location within a specified range and angle of the pad,
|
||||
// with options for the direction and height offset from the pad.
|
||||
// Used by AI command 00f4, but that command is not used.
|
||||
padUnpack(g_WarpType3Pad, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
room = g_Pads[g_WarpType3Pad].room;
|
||||
|
||||
room = pad.room;
|
||||
|
||||
memcampos.x = pad.pos.x;
|
||||
memcampos.y = pad.pos.y;
|
||||
memcampos.z = pad.pos.z;
|
||||
memcampos.x = g_Pads[g_WarpType3Pad].pos.x;
|
||||
memcampos.y = g_Pads[g_WarpType3Pad].pos.y;
|
||||
memcampos.z = g_Pads[g_WarpType3Pad].pos.z;
|
||||
|
||||
pos.x = memcampos.x + sinf(g_WarpType3PosAngle) * g_WarpType3Range + cosf(g_WarpType3PosAngle) * 0.0f;
|
||||
pos.y = memcampos.y + g_WarpType3MoreHeight + g_WarpType3Height;
|
||||
|
|
@ -4286,19 +4279,20 @@ void playerTick(bool arg0)
|
|||
f32 zdist;
|
||||
f32 diffangle;
|
||||
f32 direction;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
f32 speedfrac;
|
||||
|
||||
playerRemoveChrBody();
|
||||
padUnpack(g_Vars.currentplayer->autocontrol_aimpad, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[g_Vars.currentplayer->autocontrol_aimpad];
|
||||
|
||||
if (mainGetStageNum() == g_Stages[STAGEINDEX_EXTRACTION].id
|
||||
&& g_Vars.currentplayer->autocontrol_aimpad == 0x19) {
|
||||
pad.pos.x -= 100;
|
||||
xdist = pad->pos.x - 100 - g_Vars.currentplayer->bond2.unk10.x;
|
||||
} else {
|
||||
xdist = pad->pos.x - g_Vars.currentplayer->bond2.unk10.x;
|
||||
}
|
||||
|
||||
xdist = pad.pos.x - g_Vars.currentplayer->bond2.unk10.x;
|
||||
zdist = pad.pos.z - g_Vars.currentplayer->bond2.unk10.z;
|
||||
zdist = pad->pos.z - g_Vars.currentplayer->bond2.unk10.z;
|
||||
targetangle = atan2f(xdist, zdist);
|
||||
|
||||
if (targetangle > M_BADTAU) {
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@ void playerInitEyespy(void)
|
|||
* the camspy will start in a trigger point for the mid cutscene,
|
||||
* causing the mid cutscene to play instead of the intro.
|
||||
*/
|
||||
padUnpack(nextpad++, PADFIELD_ROOM | PADFIELD_POS, &pad);
|
||||
prop = bodyAllocateEyespy(&pad, pad.room);
|
||||
prop = bodyAllocateEyespy(&pad, g_Pads[nextpad++].room);
|
||||
|
||||
if (prop) {
|
||||
g_Vars.currentplayer->eyespy = mempAlloc(sizeof(struct eyespy), MEMPOOL_STAGE);
|
||||
|
|
|
|||
|
|
@ -2208,7 +2208,7 @@ void propsTickPlayer(bool islastplayer)
|
|||
void propsTickPadEffects(void)
|
||||
{
|
||||
s32 i;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
u32 stack;
|
||||
struct coord up;
|
||||
s16 rooms[2];
|
||||
|
|
@ -2219,36 +2219,34 @@ void propsTickPadEffects(void)
|
|||
for (i = 0; i <= g_LastPadEffectIndex; i++) {
|
||||
struct padeffectobj *effect = &g_PadEffects[i];
|
||||
|
||||
padUnpack(effect->pad, PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[effect->pad];
|
||||
|
||||
if (roomIsOnscreen(pad.room)) {
|
||||
if (roomIsOnscreen(pad->room)) {
|
||||
switch (effect->effect) {
|
||||
case PADEFFECT_SPARKS:
|
||||
case PADEFFECT_SPARKS2:
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
padUnpack(effect->pad, PADFIELD_POS | PADFIELD_UP, &pad);
|
||||
|
||||
up.x = -pad.up.x;
|
||||
up.y = -pad.up.y;
|
||||
up.z = -pad.up.z;
|
||||
up.x = -pad->up.x;
|
||||
up.y = -pad->up.y;
|
||||
up.z = -pad->up.z;
|
||||
|
||||
if ((random() % 2048) <= 50) {
|
||||
sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
propsnd0f0939f8(NULL, NULL, propsndGetRandomSparkSound(), -1, -1, 0, 0, 0, &pad.pos, -1, rooms, -1, -1, -1, -1);
|
||||
sparksCreate(rooms[0], NULL, &pad->pos, &up, &pad->up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
propsnd0f0939f8(NULL, NULL, propsndGetRandomSparkSound(), -1, -1, 0, 0, 0, &pad->pos, -1, rooms, -1, -1, -1, -1);
|
||||
}
|
||||
|
||||
if ((random() % 2048) <= 15) {
|
||||
sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL2);
|
||||
propsnd0f0939f8(NULL, NULL, propsndGetRandomSparkSound(), -1, -1, 0, 0, 0, &pad.pos, -1, rooms, -1, -1, -1, -1);
|
||||
sparksCreate(rooms[0], NULL, &pad->pos, &up, &pad->up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
sparksCreate(rooms[0], NULL, &pad->pos, &up, &pad->up, SPARKTYPE_ENVIRONMENTAL2);
|
||||
propsnd0f0939f8(NULL, NULL, propsndGetRandomSparkSound(), -1, -1, 0, 0, 0, &pad->pos, -1, rooms, -1, -1, -1, -1);
|
||||
}
|
||||
|
||||
if ((random() % 2048) <= 5) {
|
||||
sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
sparksCreate(rooms[0], NULL, &pad.pos, &up, &pad.up, SPARKTYPE_ENVIRONMENTAL3);
|
||||
propsnd0f0939f8(NULL, NULL, propsndGetRandomSparkSound(), -1, -1, 0, 0, 0, &pad.pos, -1, rooms, -1, -1, -1, -1);
|
||||
sparksCreate(rooms[0], NULL, &pad->pos, &up, &pad->up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
sparksCreate(rooms[0], NULL, &pad->pos, &up, &pad->up, SPARKTYPE_ENVIRONMENTAL3);
|
||||
propsnd0f0939f8(NULL, NULL, propsndGetRandomSparkSound(), -1, -1, 0, 0, 0, &pad->pos, -1, rooms, -1, -1, -1, -1);
|
||||
}
|
||||
break;
|
||||
case PADEFFECT_OUTROSMOKE:
|
||||
|
|
@ -2272,11 +2270,10 @@ void propsTickPadEffects(void)
|
|||
break;
|
||||
}
|
||||
|
||||
rooms2[0] = pad.room;
|
||||
rooms2[0] = pad->room;
|
||||
rooms2[1] = -1;
|
||||
|
||||
padUnpack(effect->pad, PADFIELD_POS | PADFIELD_UP, &pad);
|
||||
smokeCreateAtPadEffect(effect, &pad.pos, rooms2, type);
|
||||
smokeCreateAtPadEffect(effect, &pad->pos, rooms2, type);
|
||||
break;
|
||||
case PADEFFECT_01:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -706,12 +706,10 @@ bool func0f0677ac(struct coord *coord, struct coord *arg1, struct coord *pos,
|
|||
|
||||
bool func0f0678f8(struct coord *coord, struct coord *arg1, s32 padnum)
|
||||
{
|
||||
struct pad pad;
|
||||
struct pad *pad = &g_Pads[padnum];
|
||||
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_NORMAL | PADFIELD_BBOX, &pad);
|
||||
|
||||
return func0f0677ac(coord, arg1, &pad.pos, &pad.normal, &pad.up, &pad.look,
|
||||
pad.bbox.xmin, pad.bbox.xmax, pad.bbox.ymin, pad.bbox.ymax, pad.bbox.zmin, pad.bbox.zmax);
|
||||
return func0f0677ac(coord, arg1, &pad->pos, &pad->normal, &pad->up, &pad->look,
|
||||
pad->bbox.xmin, pad->bbox.xmax, pad->bbox.ymin, pad->bbox.ymax, pad->bbox.zmin, pad->bbox.zmax);
|
||||
}
|
||||
|
||||
bool func0f06797c(struct coord *coord, f32 arg1, s32 padnum)
|
||||
|
|
@ -1390,7 +1388,7 @@ s32 door0f068c04(struct prop *prop, s32 *arg1, s32 *arg2)
|
|||
s32 v1;
|
||||
s32 result;
|
||||
struct prop *loopprop;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
#if VERSION < VERSION_PAL_BETA
|
||||
static u32 debugdoors = 0;
|
||||
|
|
@ -1406,11 +1404,11 @@ s32 door0f068c04(struct prop *prop, s32 *arg1, s32 *arg2)
|
|||
struct coord *campos = &g_Vars.currentplayer->cam_pos;
|
||||
loopprop = sibling->base.prop;
|
||||
|
||||
padUnpack(sibling->base.pad, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_NORMAL | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[sibling->base.pad];
|
||||
|
||||
if (door->base.flags3 & OBJFLAG3_04000000) {
|
||||
s3 += func0f000b24(pad.room);
|
||||
s4 += func0f000c54(pad.room);
|
||||
s3 += func0f000b24(pad->room);
|
||||
s4 += func0f000c54(pad->room);
|
||||
s5++;
|
||||
|
||||
s2 = s3 + s4;
|
||||
|
|
@ -1422,22 +1420,22 @@ s32 door0f068c04(struct prop *prop, s32 *arg1, s32 *arg2)
|
|||
f32 xdist;
|
||||
f32 ydist;
|
||||
f32 zdist;
|
||||
struct coord *pos = &pad.pos;
|
||||
struct coord *normal = &pad.normal;
|
||||
struct coord *pos = &pad->pos;
|
||||
struct coord normal = pad->normal;
|
||||
f32 sum1;
|
||||
f32 sum2;
|
||||
|
||||
if (door->doorflags & DOORFLAG_FLIP) {
|
||||
normal->f[0] = -normal->f[0];
|
||||
normal->f[1] = -normal->f[1];
|
||||
normal->f[2] = -normal->f[2];
|
||||
normal.f[0] = -normal.f[0];
|
||||
normal.f[1] = -normal.f[1];
|
||||
normal.f[2] = -normal.f[2];
|
||||
}
|
||||
|
||||
xdist = campos->f[0] - pos->x;
|
||||
ydist = campos->f[1] - pos->y;
|
||||
zdist = campos->f[2] - pos->z;
|
||||
|
||||
sum1 = xdist * normal->x + ydist * normal->y + zdist * normal->z;
|
||||
sum1 = xdist * normal.x + ydist * normal.y + zdist * normal.z;
|
||||
|
||||
for (i = 0; loopprop->rooms[i] != -1; i++) {
|
||||
f32 roomx = g_Rooms[loopprop->rooms[i]].centre.x;
|
||||
|
|
@ -1447,7 +1445,7 @@ s32 door0f068c04(struct prop *prop, s32 *arg1, s32 *arg2)
|
|||
f32 ydist = roomy - pos->y;
|
||||
f32 zdist = roomz - pos->z;
|
||||
|
||||
sum2 = xdist * normal->x + ydist * normal->y + zdist * normal->z;
|
||||
sum2 = xdist * normal.x + ydist * normal.y + zdist * normal.z;
|
||||
|
||||
// @bug? Duplicate sum1 < 0.0f check in the first part.
|
||||
// Perhaps one of them should be sum2 < 0.0f.
|
||||
|
|
@ -5768,14 +5766,11 @@ void liftActivate(struct prop *prop, u8 liftnum)
|
|||
|
||||
struct prop *liftFindByPad(s16 padnum)
|
||||
{
|
||||
struct pad pad;
|
||||
padUnpack(padnum, PADFIELD_LIFT, &pad);
|
||||
|
||||
if (pad.liftnum <= 0 || pad.liftnum > MAX_LIFTS) {
|
||||
if (g_Pads[padnum].liftnum <= 0 || g_Pads[padnum].liftnum > MAX_LIFTS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_Lifts[pad.liftnum - 1];
|
||||
return g_Lifts[g_Pads[padnum].liftnum - 1];
|
||||
}
|
||||
|
||||
f32 liftGetY(struct liftobj *lift)
|
||||
|
|
@ -5905,9 +5900,9 @@ void liftGoToStop(struct liftobj *lift, s32 stopnum)
|
|||
#if VERSION >= VERSION_NTSC_1_0
|
||||
u32 stack;
|
||||
#endif
|
||||
struct pad curpad;
|
||||
struct pad aimpad;
|
||||
struct pad reqpad;
|
||||
struct pad *curpad;
|
||||
struct pad *aimpad;
|
||||
struct pad *reqpad;
|
||||
|
||||
if (lift->pads[stopnum] >= 0 && lift->levelaim != stopnum) {
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
|
|
@ -5928,35 +5923,25 @@ void liftGoToStop(struct liftobj *lift, s32 stopnum)
|
|||
}
|
||||
#endif
|
||||
|
||||
padUnpack(lift->pads[lift->levelcur], PADFIELD_POS, &curpad);
|
||||
padUnpack(lift->pads[lift->levelaim], PADFIELD_POS, &aimpad);
|
||||
padUnpack(lift->pads[stopnum], PADFIELD_POS, &reqpad);
|
||||
curpad = &g_Pads[lift->pads[lift->levelcur]];
|
||||
aimpad = &g_Pads[lift->pads[lift->levelaim]];
|
||||
reqpad = &g_Pads[lift->pads[stopnum]];
|
||||
|
||||
// Figure out if the lift needs to reverse direction on any axis
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
if (stopnum != lift->levelcur &&
|
||||
((aimpad.pos.x >= curpad.pos.x && reqpad.pos.x >= curpad.pos.x) ||
|
||||
(curpad.pos.x >= aimpad.pos.x && curpad.pos.x >= reqpad.pos.x)) &&
|
||||
((aimpad.pos.y >= curpad.pos.y && reqpad.pos.y >= curpad.pos.y) ||
|
||||
(curpad.pos.y >= aimpad.pos.y && curpad.pos.y >= reqpad.pos.y)) &&
|
||||
((aimpad.pos.z >= curpad.pos.z && reqpad.pos.z >= curpad.pos.z) ||
|
||||
(curpad.pos.z >= aimpad.pos.z && curpad.pos.z >= reqpad.pos.z)))
|
||||
#else
|
||||
if (((aimpad.pos.x >= curpad.pos.x && reqpad.pos.x >= aimpad.pos.x) ||
|
||||
(curpad.pos.x >= aimpad.pos.x && aimpad.pos.x >= reqpad.pos.x)) &&
|
||||
((aimpad.pos.y >= curpad.pos.y && reqpad.pos.y >= aimpad.pos.y) ||
|
||||
(curpad.pos.y >= aimpad.pos.y && aimpad.pos.y >= reqpad.pos.y)) &&
|
||||
((aimpad.pos.z >= curpad.pos.z && reqpad.pos.z >= aimpad.pos.z) ||
|
||||
(curpad.pos.z >= aimpad.pos.z && aimpad.pos.z >= reqpad.pos.z)))
|
||||
#endif
|
||||
{
|
||||
((aimpad->pos.x >= curpad->pos.x && reqpad->pos.x >= curpad->pos.x) ||
|
||||
(curpad->pos.x >= aimpad->pos.x && curpad->pos.x >= reqpad->pos.x)) &&
|
||||
((aimpad->pos.y >= curpad->pos.y && reqpad->pos.y >= curpad->pos.y) ||
|
||||
(curpad->pos.y >= aimpad->pos.y && curpad->pos.y >= reqpad->pos.y)) &&
|
||||
((aimpad->pos.z >= curpad->pos.z && reqpad->pos.z >= curpad->pos.z) ||
|
||||
(curpad->pos.z >= aimpad->pos.z && curpad->pos.z >= reqpad->pos.z))) {
|
||||
// Same direction
|
||||
lift->levelaim = stopnum;
|
||||
} else {
|
||||
// Reverse direction
|
||||
f32 xdiff = aimpad.pos.x - curpad.pos.x;
|
||||
f32 ydiff = aimpad.pos.y - curpad.pos.y;
|
||||
f32 zdiff = aimpad.pos.z - curpad.pos.z;
|
||||
f32 xdiff = aimpad->pos.x - curpad->pos.x;
|
||||
f32 ydiff = aimpad->pos.y - curpad->pos.y;
|
||||
f32 zdiff = aimpad->pos.z - curpad->pos.z;
|
||||
f32 result = sqrtf(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
|
||||
|
||||
lift->levelcur = lift->levelaim;
|
||||
|
|
@ -6462,7 +6447,7 @@ void hovercarFindNextPath(struct hovercarobj *hovercar)
|
|||
void hovercarStartNextPath(struct hovercarobj *hovercar)
|
||||
{
|
||||
s32 *pads;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
Mtxf matrix;
|
||||
s16 rooms[2];
|
||||
|
||||
|
|
@ -6471,14 +6456,14 @@ void hovercarStartNextPath(struct hovercarobj *hovercar)
|
|||
pads = hovercar->path->pads;
|
||||
hovercar->nextstep = 0;
|
||||
|
||||
padUnpack(pads[0], PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[pads[0]];
|
||||
|
||||
mtx3ToMtx4(hovercar->base.realrot, &matrix);
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
func0f06a730(&hovercar->base, &pad.pos, &matrix, rooms, &pad.pos);
|
||||
func0f06a730(&hovercar->base, &pad->pos, &matrix, rooms, &pad->pos);
|
||||
|
||||
hovercar->base.flags |= OBJFLAG_HOVERCAR_20000000;
|
||||
}
|
||||
|
|
@ -7072,7 +7057,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
|
|||
Mtxf sp504;
|
||||
Mtxf sp4c4;
|
||||
Mtxf sp484;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
f32 dist;
|
||||
f32 shield;
|
||||
s32 i;
|
||||
|
|
@ -7177,7 +7162,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
|
|||
haslimitedarea = obj->pad >= 0 && (obj->flags3 & (OBJFLAG3_GRABBABLE | OBJFLAG3_PUSHFREELY)) == 0;
|
||||
|
||||
if (haslimitedarea) {
|
||||
padUnpack(obj->pad, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[obj->pad];
|
||||
|
||||
innerdist = 200.0f;
|
||||
outerdist = 300.0f;
|
||||
|
|
@ -7198,8 +7183,8 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
|
|||
}
|
||||
#endif
|
||||
|
||||
x = pad.pos.x - prop->pos.x;
|
||||
z = pad.pos.z - prop->pos.z;
|
||||
x = pad->pos.x - prop->pos.x;
|
||||
z = pad->pos.z - prop->pos.z;
|
||||
|
||||
dist = sqrtf(x * x + z * z);
|
||||
|
||||
|
|
@ -7228,8 +7213,8 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
|
|||
sp59c.z = projectile->speed.z * g_Vars.lvupdate60freal;
|
||||
|
||||
if (haslimitedarea) {
|
||||
x = pad.pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad.pos.z - prop->pos.z - sp59c.z;
|
||||
x = pad->pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad->pos.z - prop->pos.z - sp59c.z;
|
||||
|
||||
dist = sqrtf(x * x + z * z);
|
||||
|
||||
|
|
@ -7343,8 +7328,8 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
|
|||
sp59c.z = sp590.f[2] * g_Vars.lvupdate60freal;
|
||||
|
||||
if (haslimitedarea) {
|
||||
x = pad.pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad.pos.z - prop->pos.z - sp59c.z;
|
||||
x = pad->pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad->pos.z - prop->pos.z - sp59c.z;
|
||||
|
||||
dist = sqrtf(x * x + z * z);
|
||||
|
||||
|
|
@ -7377,8 +7362,8 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
|
|||
sp59c.z = sp590.f[2] * g_Vars.lvupdate60freal;
|
||||
|
||||
if (haslimitedarea) {
|
||||
x = pad.pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad.pos.z - prop->pos.z - sp59c.z;
|
||||
x = pad->pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad->pos.z - prop->pos.z - sp59c.z;
|
||||
|
||||
dist = sqrtf(x * x + z * z);
|
||||
|
||||
|
|
@ -7426,8 +7411,8 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
|
|||
sp59c.z = sp590.f[2] * g_Vars.lvupdate60freal;
|
||||
|
||||
if (haslimitedarea) {
|
||||
x = pad.pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad.pos.z - prop->pos.z - sp59c.z;
|
||||
x = pad->pos.x - prop->pos.x - sp59c.x;
|
||||
z = pad->pos.z - prop->pos.z - sp59c.z;
|
||||
|
||||
dist = sqrtf(x * x + z * z);
|
||||
|
||||
|
|
@ -8797,8 +8782,8 @@ void liftTick(struct prop *prop)
|
|||
struct liftobj *lift = (struct liftobj *)prop->obj;
|
||||
struct defaultobj *obj = prop->obj;
|
||||
struct doorobj *door;
|
||||
struct pad padcur;
|
||||
struct pad padaim;
|
||||
struct pad *padcur;
|
||||
struct pad *padaim;
|
||||
f32 segdist;
|
||||
f32 xdiff;
|
||||
f32 ydiff;
|
||||
|
|
@ -8848,12 +8833,12 @@ void liftTick(struct prop *prop)
|
|||
}
|
||||
|
||||
padGetCentre(lift->pads[lift->levelcur], &curcentre);
|
||||
padUnpack(lift->pads[lift->levelcur], PADFIELD_POS, &padcur);
|
||||
padUnpack(lift->pads[lift->levelaim], PADFIELD_POS, &padaim);
|
||||
padcur = &g_Pads[lift->pads[lift->levelcur]];
|
||||
padaim = &g_Pads[lift->pads[lift->levelaim]];
|
||||
|
||||
xdiff = padaim.pos.f[0] - padcur.pos.f[0];
|
||||
ydiff = padaim.pos.f[1] - padcur.pos.f[1];
|
||||
zdiff = padaim.pos.f[2] - padcur.pos.f[2];
|
||||
xdiff = padaim->pos.f[0] - padcur->pos.f[0];
|
||||
ydiff = padaim->pos.f[1] - padcur->pos.f[1];
|
||||
zdiff = padaim->pos.f[2] - padcur->pos.f[2];
|
||||
|
||||
segdist = sqrtf(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
|
||||
|
||||
|
|
@ -10794,8 +10779,8 @@ void chopperTickFall(struct prop *chopperprop)
|
|||
f32 *z = &chopper->fall.z;
|
||||
struct coord speed;
|
||||
s32 i;
|
||||
struct pad prevpad;
|
||||
struct pad nextpad;
|
||||
struct pad *prevpad;
|
||||
struct pad *nextpad;
|
||||
f32 xdiff;
|
||||
f32 zdiff;
|
||||
f32 tmp;
|
||||
|
|
@ -10817,11 +10802,11 @@ void chopperTickFall(struct prop *chopperprop)
|
|||
}
|
||||
}
|
||||
|
||||
padUnpack(chopper->path->pads[PREVSTEP()], PADFIELD_POS, &prevpad);
|
||||
padUnpack(chopper->path->pads[NEXTSTEP()], PADFIELD_POS, &nextpad);
|
||||
prevpad = &g_Pads[chopper->path->pads[PREVSTEP()]];
|
||||
nextpad = &g_Pads[chopper->path->pads[NEXTSTEP()]];
|
||||
|
||||
xdiff = prevpad.pos.f[0] - nextpad.pos.f[0];
|
||||
zdiff = prevpad.pos.f[2] - nextpad.pos.f[2];
|
||||
xdiff = prevpad->pos.f[0] - nextpad->pos.f[0];
|
||||
zdiff = prevpad->pos.f[2] - nextpad->pos.f[2];
|
||||
|
||||
tmp = 0.25f / sqrtf(xdiff * xdiff + zdiff * zdiff);
|
||||
|
||||
|
|
@ -10980,7 +10965,7 @@ void chopperTickPatrol(struct prop *chopperprop)
|
|||
f32 roty = chopper->roty;
|
||||
f32 rotx = chopper->rotx;
|
||||
struct coord vector;
|
||||
struct pad pad;
|
||||
struct coord padpos;
|
||||
f32 mult;
|
||||
f32 zdiff;
|
||||
|
||||
|
|
@ -10993,20 +10978,20 @@ void chopperTickPatrol(struct prop *chopperprop)
|
|||
}
|
||||
|
||||
if (chopper->path) {
|
||||
padUnpack(chopper->path->pads[chopper->nextstep], PADFIELD_POS, &pad);
|
||||
pad.pos.y += -250;
|
||||
padpos = g_Pads[chopper->path->pads[chopper->nextstep]].pos;
|
||||
padpos.y += -250;
|
||||
|
||||
if (posIsArrivingLaterallyAtPos(&chopperprop->pos, &chopperprop->pos, &pad.pos, 350)) {
|
||||
if (posIsArrivingLaterallyAtPos(&chopperprop->pos, &chopperprop->pos, &padpos, 350)) {
|
||||
chopper->nextstep = ((chopper->cw ? -1 : 1) + chopper->nextstep + chopper->path->len) % chopper->path->len;
|
||||
|
||||
padUnpack(chopper->path->pads[chopper->nextstep], PADFIELD_POS, &pad);
|
||||
pad.pos.y += -250;
|
||||
padpos = g_Pads[chopper->path->pads[chopper->nextstep]].pos;
|
||||
padpos.y += -250;
|
||||
}
|
||||
|
||||
roty = atan2f(pad.pos.x - chopperprop->pos.x, pad.pos.z - chopperprop->pos.z);
|
||||
xdiff = pad.pos.x - chopperprop->pos.x;
|
||||
zdiff = pad.pos.z - chopperprop->pos.z;
|
||||
rotx = atan2f(pad.pos.y - chopperprop->pos.y, sqrtf(xdiff * xdiff + zdiff * zdiff));
|
||||
roty = atan2f(padpos.x - chopperprop->pos.x, padpos.z - chopperprop->pos.z);
|
||||
xdiff = padpos.x - chopperprop->pos.x;
|
||||
zdiff = padpos.z - chopperprop->pos.z;
|
||||
rotx = atan2f(padpos.y - chopperprop->pos.y, sqrtf(xdiff * xdiff + zdiff * zdiff));
|
||||
}
|
||||
|
||||
if (chopper->base.flags & OBJFLAG_20000000) {
|
||||
|
|
@ -11017,9 +11002,9 @@ void chopperTickPatrol(struct prop *chopperprop)
|
|||
}
|
||||
|
||||
if (chopper->patroltimer60 > 0) {
|
||||
vector.x = pad.pos.x - chopperprop->pos.x;
|
||||
vector.y = pad.pos.y - chopperprop->pos.y;
|
||||
vector.z = pad.pos.z - chopperprop->pos.z;
|
||||
vector.x = padpos.x - chopperprop->pos.x;
|
||||
vector.y = padpos.y - chopperprop->pos.y;
|
||||
vector.z = padpos.z - chopperprop->pos.z;
|
||||
|
||||
guNormalize(&vector.x, &vector.y, &vector.z);
|
||||
} else {
|
||||
|
|
@ -11052,8 +11037,8 @@ void chopperTickCombat(struct prop *chopperprop)
|
|||
f32 dist;
|
||||
struct coord goalpos;
|
||||
struct coord dir;
|
||||
struct pad pad;
|
||||
struct pad nextpad;
|
||||
struct coord padpos;
|
||||
struct coord nextpadpos;
|
||||
f32 f20;
|
||||
s32 sp90;
|
||||
s32 sp8c;
|
||||
|
|
@ -11080,13 +11065,13 @@ void chopperTickCombat(struct prop *chopperprop)
|
|||
f20 = 2.6843546e8f;
|
||||
|
||||
for (i = 0; i < chopper->path->len; i++) {
|
||||
padUnpack(chopper->path->pads[i], PADFIELD_POS, &pad);
|
||||
padUnpack(chopper->path->pads[(i + 1) % chopper->path->len], PADFIELD_POS, &nextpad);
|
||||
padpos = g_Pads[chopper->path->pads[i]].pos;
|
||||
nextpadpos = g_Pads[chopper->path->pads[(i + 1) % chopper->path->len]].pos;
|
||||
|
||||
pad.pos.y += -250.0f;
|
||||
nextpad.pos.y += -250.0f;
|
||||
padpos.y += -250.0f;
|
||||
nextpadpos.y += -250.0f;
|
||||
|
||||
f0 = func0f07b164(&pad.pos, &nextpad.pos, &targetprop->pos, &sp78);
|
||||
f0 = func0f07b164(&padpos, &nextpadpos, &targetprop->pos, &sp78);
|
||||
|
||||
if (f0 < f20) {
|
||||
f20 = f0;
|
||||
|
|
@ -11123,34 +11108,32 @@ void chopperTickCombat(struct prop *chopperprop)
|
|||
|
||||
chopper->nextstep = chopper->cw ? sp8c : (sp8c + 1) % chopper->path->len;
|
||||
|
||||
padUnpack(chopper->path->pads[chopper->nextstep], PADFIELD_POS, &pad);
|
||||
padpos = g_Pads[chopper->path->pads[chopper->nextstep]].pos;
|
||||
padpos.y += -250.0f;
|
||||
|
||||
pad.pos.y += -250.0f;
|
||||
|
||||
if (coordGetSquaredDistanceToCoord(&pad.pos, &chopperprop->pos) < 10000.0f) {
|
||||
if (coordGetSquaredDistanceToCoord(&padpos, &chopperprop->pos) < 10000.0f) {
|
||||
chopper->power = 0.0f;
|
||||
chopper->nextstep = (chopper->nextstep + (chopper->cw ? -1 : 1) + chopper->path->len) % chopper->path->len;
|
||||
|
||||
padUnpack(chopper->path->pads[chopper->nextstep], PADFIELD_POS, &pad);
|
||||
pad.pos.y += -250.0f;
|
||||
padpos = g_Pads[chopper->path->pads[chopper->nextstep]].pos;
|
||||
padpos.y += -250.0f;
|
||||
}
|
||||
|
||||
goalpos.x = pad.pos.x;
|
||||
goalpos.y = pad.pos.y;
|
||||
goalpos.z = pad.pos.z;
|
||||
goalpos.x = padpos.x;
|
||||
goalpos.y = padpos.y;
|
||||
goalpos.z = padpos.z;
|
||||
} else {
|
||||
goalpos.x = sp6c.x;
|
||||
goalpos.y = sp6c.y;
|
||||
goalpos.z = sp6c.z;
|
||||
}
|
||||
} 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);
|
||||
padpos = g_Pads[chopper->path->pads[chopper->cw ? (sp8c + 1) % chopper->path->len : sp8c]].pos;
|
||||
padpos.y += -250.0f;
|
||||
|
||||
pad.pos.y += -250.0f;
|
||||
|
||||
sp78.x = pad.pos.x - goalpos.x;
|
||||
sp78.y = pad.pos.y - goalpos.y;
|
||||
sp78.z = pad.pos.z - goalpos.z;
|
||||
sp78.x = padpos.x - goalpos.x;
|
||||
sp78.y = padpos.y - goalpos.y;
|
||||
sp78.z = padpos.z - goalpos.z;
|
||||
|
||||
guNormalize(&sp78.x, &sp78.y, &sp78.z);
|
||||
|
||||
|
|
@ -11199,7 +11182,7 @@ void chopperTickCombat(struct prop *chopperprop)
|
|||
void hovercarTick(struct prop *prop)
|
||||
{
|
||||
bool stopping;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
struct coord sp214;
|
||||
s16 sp210[2];
|
||||
struct hovercarobj *hovercar = (struct hovercarobj *) prop->obj;
|
||||
|
|
@ -11305,26 +11288,26 @@ void hovercarTick(struct prop *prop)
|
|||
|
||||
if (hovercar->path) {
|
||||
padnum = &hovercar->path->pads[hovercar->nextstep];
|
||||
padUnpack(*padnum, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[*padnum];
|
||||
|
||||
sp214.x = pad.pos.x;
|
||||
sp214.x = pad->pos.x;
|
||||
|
||||
if (active) {
|
||||
sp210[0] = pad.room;
|
||||
sp210[0] = pad->room;
|
||||
sp210[1] = -1;
|
||||
|
||||
sp214.y = cdFindGroundAtCyl(&pad.pos, 5, sp210, NULL, NULL) + 35;
|
||||
sp214.y = cdFindGroundAtCyl(&pad->pos, 5, sp210, NULL, NULL) + 35;
|
||||
} else {
|
||||
sp214.y = pad.pos.y;
|
||||
sp214.y = pad->pos.y;
|
||||
}
|
||||
|
||||
sp214.z = pad.pos.z;
|
||||
sp214.z = pad->pos.z;
|
||||
|
||||
if ((hovercar->base.flags & OBJFLAG_20000000)
|
||||
&& posIsArrivingLaterallyAtPos(&prop->pos, &prop->pos, &sp214, (0, sp1f4))) {
|
||||
hovercarIncrementStep(hovercar);
|
||||
padnum = &hovercar->path->pads[hovercar->nextstep];
|
||||
padUnpack(*padnum, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[*padnum];
|
||||
}
|
||||
|
||||
sp200 = atan2f(sp214.x - prop->pos.x, sp214.z - prop->pos.z);
|
||||
|
|
@ -19755,18 +19738,12 @@ bool doorIsObjInRange(struct doorobj *door, struct defaultobj *obj, bool isbike)
|
|||
return doorIsPosInRange(door, &obj->prop->pos, scale, isbike);
|
||||
}
|
||||
|
||||
/**
|
||||
* @bug: result should be an integer. Its value can only be 0.0f or 1.0f.
|
||||
* Nothing bad comes from this, but it uses unnecessary float conversions.
|
||||
*/
|
||||
bool vectorIsInFrontOfDoor(struct doorobj *door, struct coord *vector)
|
||||
{
|
||||
f32 result;
|
||||
struct pad pad;
|
||||
s32 result;
|
||||
struct pad *pad = &g_Pads[door->base.pad];
|
||||
|
||||
padUnpack(door->base.pad, PADFIELD_NORMAL, &pad);
|
||||
|
||||
result = vector->f[0] * pad.normal.f[0] + vector->f[1] * pad.normal.f[1] + vector->f[2] * pad.normal.f[2] >= 0.0f;
|
||||
result = vector->f[0] * pad->normal.f[0] + vector->f[1] * pad->normal.f[1] + vector->f[2] * pad->normal.f[2] >= 0.0f;
|
||||
|
||||
if (door->doorflags & DOORFLAG_FLIP) {
|
||||
result = !result;
|
||||
|
|
@ -19906,7 +19883,7 @@ void doorUpdateTiles(struct doorobj *door)
|
|||
Mtxf sp98;
|
||||
struct coord sp8c;
|
||||
struct coord sp80;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
if (door->doorflags & DOORFLAG_0080) {
|
||||
door->base.prop->pos.x = door->unk98.x * door->frac + door->startpos.x;
|
||||
|
|
@ -19915,31 +19892,29 @@ void doorUpdateTiles(struct doorobj *door)
|
|||
} else if (door->doortype == DOORTYPE_SWINGING
|
||||
|| door->doortype == DOORTYPE_AZTECCHAIR
|
||||
|| door->doortype == DOORTYPE_HULL) {
|
||||
// @bug: LOOK is not loaded but is used below
|
||||
// It doesn't appear to make any difference though
|
||||
padUnpack(door->base.pad, PADFIELD_POS | PADFIELD_UP | PADFIELD_NORMAL | PADFIELD_BBOX, &pad);
|
||||
pad = &g_Pads[door->base.pad];
|
||||
|
||||
sp8c.x = pad.pos.x + pad.up.x * pad.bbox.ymin;
|
||||
sp8c.y = pad.pos.y + pad.up.y * pad.bbox.ymin;
|
||||
sp8c.z = pad.pos.z + pad.up.z * pad.bbox.ymin;
|
||||
sp8c.x = pad->pos.x + pad->up.x * pad->bbox.ymin;
|
||||
sp8c.y = pad->pos.y + pad->up.y * pad->bbox.ymin;
|
||||
sp8c.z = pad->pos.z + pad->up.z * pad->bbox.ymin;
|
||||
|
||||
if (door->doortype == DOORTYPE_AZTECCHAIR) {
|
||||
sp8c.x += pad.normal.x * pad.bbox.xmax;
|
||||
sp8c.y += pad.normal.y * pad.bbox.xmax;
|
||||
sp8c.z += pad.normal.z * pad.bbox.xmax;
|
||||
sp8c.x += pad->normal.x * pad->bbox.xmax;
|
||||
sp8c.y += pad->normal.y * pad->bbox.xmax;
|
||||
sp8c.z += pad->normal.z * pad->bbox.xmax;
|
||||
} else if (door->doortype == DOORTYPE_HULL) {
|
||||
sp8c.x += pad.look.x * pad.bbox.zmin;
|
||||
sp8c.y += pad.look.y * pad.bbox.zmin;
|
||||
sp8c.z += pad.look.z * pad.bbox.zmin;
|
||||
sp8c.x += pad->look.x * pad->bbox.zmin;
|
||||
sp8c.y += pad->look.y * pad->bbox.zmin;
|
||||
sp8c.z += pad->look.z * pad->bbox.zmin;
|
||||
} else {
|
||||
if (door->base.flags & OBJFLAG_DOOR_OPENTOFRONT) {
|
||||
sp8c.x += pad.normal.x * pad.bbox.xmax;
|
||||
sp8c.y += pad.normal.y * pad.bbox.xmax;
|
||||
sp8c.z += pad.normal.z * pad.bbox.xmax;
|
||||
sp8c.x += pad->normal.x * pad->bbox.xmax;
|
||||
sp8c.y += pad->normal.y * pad->bbox.xmax;
|
||||
sp8c.z += pad->normal.z * pad->bbox.xmax;
|
||||
} else {
|
||||
sp8c.x += pad.normal.x * pad.bbox.xmin;
|
||||
sp8c.y += pad.normal.y * pad.bbox.xmin;
|
||||
sp8c.z += pad.normal.z * pad.bbox.xmin;
|
||||
sp8c.x += pad->normal.x * pad->bbox.xmin;
|
||||
sp8c.y += pad->normal.y * pad->bbox.xmin;
|
||||
sp8c.z += pad->normal.z * pad->bbox.xmin;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -19959,9 +19934,9 @@ void doorUpdateTiles(struct doorobj *door)
|
|||
}
|
||||
} else if (door->doortype == DOORTYPE_HULL) {
|
||||
if (door->base.flags & OBJFLAG_DOOR_OPENTOFRONT) {
|
||||
guRotateF(sp98.m, 360 - door->frac, pad.normal.x, pad.normal.y, pad.normal.z);
|
||||
guRotateF(sp98.m, 360 - door->frac, pad->normal.x, pad->normal.y, pad->normal.z);
|
||||
} else {
|
||||
guRotateF(sp98.m, door->frac, pad.normal.x, pad.normal.y, pad.normal.z);
|
||||
guRotateF(sp98.m, door->frac, pad->normal.x, pad->normal.y, pad->normal.z);
|
||||
}
|
||||
} else {
|
||||
if (door->base.flags & OBJFLAG_DOOR_OPENTOFRONT) {
|
||||
|
|
@ -20785,38 +20760,38 @@ bool posIsInDrawDistance(struct coord *pos)
|
|||
|
||||
void doorCreateSparks(struct doorobj *door)
|
||||
{
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
struct coord sp88;
|
||||
struct coord sp7c;
|
||||
struct coord sp70;
|
||||
s32 i;
|
||||
|
||||
padUnpack(door->base.pad, PADFIELD_POS | PADFIELD_UP | PADFIELD_NORMAL | PADFIELD_BBOX, &pad);
|
||||
pad = &g_Pads[door->base.pad];
|
||||
|
||||
sp88.x = sp7c.f[0] = pad.pos.f[0] + pad.up.f[0] * (pad.bbox.ymin + (1 - door->frac) * (pad.bbox.ymax - pad.bbox.ymin));
|
||||
sp88.y = sp7c.f[1] = pad.pos.f[1] + pad.up.f[1] * (pad.bbox.ymin + (1 - door->frac) * (pad.bbox.ymax - pad.bbox.ymin));
|
||||
sp88.z = sp7c.f[2] = pad.pos.f[2] + pad.up.f[2] * (pad.bbox.ymin + (1 - door->frac) * (pad.bbox.ymax - pad.bbox.ymin));
|
||||
sp88.x = sp7c.f[0] = pad->pos.f[0] + pad->up.f[0] * (pad->bbox.ymin + (1 - door->frac) * (pad->bbox.ymax - pad->bbox.ymin));
|
||||
sp88.y = sp7c.f[1] = pad->pos.f[1] + pad->up.f[1] * (pad->bbox.ymin + (1 - door->frac) * (pad->bbox.ymax - pad->bbox.ymin));
|
||||
sp88.z = sp7c.f[2] = pad->pos.f[2] + pad->up.f[2] * (pad->bbox.ymin + (1 - door->frac) * (pad->bbox.ymax - pad->bbox.ymin));
|
||||
|
||||
sp88.x += pad.look.f[0] * pad.bbox.zmax;
|
||||
sp88.y += pad.look.f[1] * pad.bbox.zmax;
|
||||
sp88.z += pad.look.f[2] * pad.bbox.zmax;
|
||||
sp88.x += pad->look.f[0] * pad->bbox.zmax;
|
||||
sp88.y += pad->look.f[1] * pad->bbox.zmax;
|
||||
sp88.z += pad->look.f[2] * pad->bbox.zmax;
|
||||
|
||||
sp7c.x += pad.look.f[0] * pad.bbox.zmin;
|
||||
sp7c.y += pad.look.f[1] * pad.bbox.zmin;
|
||||
sp7c.z += pad.look.f[2] * pad.bbox.zmin;
|
||||
sp7c.x += pad->look.f[0] * pad->bbox.zmin;
|
||||
sp7c.y += pad->look.f[1] * pad->bbox.zmin;
|
||||
sp7c.z += pad->look.f[2] * pad->bbox.zmin;
|
||||
|
||||
sp70.x = -pad.up.x;
|
||||
sp70.y = -pad.up.y;
|
||||
sp70.z = -pad.up.z;
|
||||
sp70.x = -pad->up.x;
|
||||
sp70.y = -pad->up.y;
|
||||
sp70.z = -pad->up.z;
|
||||
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad.up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad->up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp7c, &sp70, &pad.up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp7c, &sp70, &pad->up, SPARKTYPE_ENVIRONMENTAL1);
|
||||
|
||||
if (random() % 2) {
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad.up, SPARKTYPE_ENVIRONMENTAL4);
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad->up, SPARKTYPE_ENVIRONMENTAL4);
|
||||
} else {
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad.up, SPARKTYPE_ENVIRONMENTAL5);
|
||||
sparksCreate(door->base.prop->rooms[0], door->base.prop, &sp88, &sp70, &pad->up, SPARKTYPE_ENVIRONMENTAL5);
|
||||
}
|
||||
|
||||
propsnd0f0939f8(NULL, door->base.prop, propsndGetRandomSparkSound(), -1,
|
||||
|
|
@ -21161,7 +21136,7 @@ void door0f08f604(struct doorobj *door, f32 *arg1, f32 *arg2, f32 *arg3, f32 *ar
|
|||
f32 spa8;
|
||||
f32 spa4;
|
||||
struct coord playerpos;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
f32 xfrac;
|
||||
f32 zfrac;
|
||||
f32 angle;
|
||||
|
|
@ -21174,30 +21149,30 @@ void door0f08f604(struct doorobj *door, f32 *arg1, f32 *arg2, f32 *arg3, f32 *ar
|
|||
playerprop = g_Vars.currentplayer->prop;
|
||||
}
|
||||
|
||||
padUnpack(door->base.pad, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_BBOX, &pad);
|
||||
pad = &g_Pads[door->base.pad];
|
||||
|
||||
playerpos.f[0] = playerprop->pos.x;
|
||||
playerpos.f[1] = playerprop->pos.y;
|
||||
playerpos.f[2] = playerprop->pos.z;
|
||||
|
||||
if (arg5) {
|
||||
spa8 = pad.bbox.xmin;
|
||||
spa4 = pad.bbox.xmax;
|
||||
spb0 = pad.up.y * pad.look.z - pad.look.y * pad.up.z;
|
||||
spac = pad.up.x * pad.look.y - pad.look.x * pad.up.y;
|
||||
spa8 = pad->bbox.xmin;
|
||||
spa4 = pad->bbox.xmax;
|
||||
spb0 = pad->up.y * pad->look.z - pad->look.y * pad->up.z;
|
||||
spac = pad->up.x * pad->look.y - pad->look.x * pad->up.y;
|
||||
} else {
|
||||
spa8 = pad.bbox.ymin;
|
||||
spa4 = pad.bbox.ymax;
|
||||
spb0 = pad.up.x;
|
||||
spac = pad.up.z;
|
||||
spa8 = pad->bbox.ymin;
|
||||
spa4 = pad->bbox.ymax;
|
||||
spb0 = pad->up.x;
|
||||
spac = pad->up.z;
|
||||
}
|
||||
|
||||
x1 = pad.pos.x + spb0 * spa8 - playerpos.f[0];
|
||||
y1 = pad.pos.z + spac * spa8 - playerpos.f[2];
|
||||
x1 = pad->pos.x + spb0 * spa8 - playerpos.f[0];
|
||||
y1 = pad->pos.z + spac * spa8 - playerpos.f[2];
|
||||
value1 = func0f08f538(x1, y1);
|
||||
|
||||
x2 = pad.pos.x + spb0 * spa4 - playerpos.f[0];
|
||||
y2 = pad.pos.z + spac * spa4 - playerpos.f[2];
|
||||
x2 = pad->pos.x + spb0 * spa4 - playerpos.f[0];
|
||||
y2 = pad->pos.z + spac * spa4 - playerpos.f[2];
|
||||
value2 = func0f08f538(x2, y2);
|
||||
|
||||
if (value1 < value2) {
|
||||
|
|
@ -21220,8 +21195,8 @@ void door0f08f604(struct doorobj *door, f32 *arg1, f32 *arg2, f32 *arg3, f32 *ar
|
|||
cosine = cosf(angle);
|
||||
sine = sinf(angle);
|
||||
|
||||
x1 = pad.pos.x + (spb0 * spa8) - playerpos.f[0] + (spa4 - spa8) * (spb0 * cosine + spac * sine);
|
||||
y1 = pad.pos.z + (spac * spa8) - playerpos.f[2] + (spa4 - spa8) * (-spb0 * sine + spac * cosine);
|
||||
x1 = pad->pos.x + (spb0 * spa8) - playerpos.f[0] + (spa4 - spa8) * (spb0 * cosine + spac * sine);
|
||||
y1 = pad->pos.z + (spac * spa8) - playerpos.f[2] + (spa4 - spa8) * (-spb0 * sine + spac * cosine);
|
||||
|
||||
value4 = func0f08f538(x1, y1);
|
||||
} else if (door->doortype == DOORTYPE_SLIDING
|
||||
|
|
@ -21420,15 +21395,15 @@ bool posIsInFrontOfDoor(struct coord *pos, struct doorobj *door)
|
|||
f32 y;
|
||||
f32 z;
|
||||
f32 value;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
padUnpack(door->base.pad, PADFIELD_POS | PADFIELD_NORMAL, &pad);
|
||||
pad = &g_Pads[door->base.pad];
|
||||
|
||||
x = pos->x - pad.pos.x;
|
||||
y = pos->y - pad.pos.y;
|
||||
z = pos->z - pad.pos.z;
|
||||
x = pos->x - pad->pos.x;
|
||||
y = pos->y - pad->pos.y;
|
||||
z = pos->z - pad->pos.z;
|
||||
|
||||
value = x * pad.normal.f[0] + y * pad.normal.f[1] + z * pad.normal.f[2];
|
||||
value = x * pad->normal.f[0] + y * pad->normal.f[1] + z * pad->normal.f[2];
|
||||
|
||||
if (door->doorflags & DOORFLAG_FLIP) {
|
||||
value = -value;
|
||||
|
|
|
|||
|
|
@ -3919,9 +3919,8 @@ s16 propsnd0f0939f8(
|
|||
#endif
|
||||
|
||||
if (padnum >= 0) {
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_ROOM, &pad);
|
||||
pos = &pad.pos;
|
||||
room = pad.room;
|
||||
pos = &g_Pads[padnum].pos;
|
||||
room = g_Pads[padnum].room;
|
||||
prop = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
166
src/game/setup.c
166
src/game/setup.c
|
|
@ -387,7 +387,7 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex)
|
|||
{
|
||||
f32 f0;
|
||||
s32 modelnum;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
Mtxf mtx;
|
||||
struct coord centre;
|
||||
f32 scale;
|
||||
|
|
@ -443,33 +443,33 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex)
|
|||
return;
|
||||
}
|
||||
|
||||
padUnpack(obj->pad, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_BBOX | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[obj->pad];
|
||||
|
||||
if (pad.room > 0) {
|
||||
mtx00016d58(&mtx, 0, 0, 0, -pad.look.x, -pad.look.y, -pad.look.z, pad.up.x, pad.up.y, pad.up.z);
|
||||
if (pad->room > 0) {
|
||||
mtx00016d58(&mtx, 0, 0, 0, -pad->look.x, -pad->look.y, -pad->look.z, pad->up.x, pad->up.y, pad->up.z);
|
||||
|
||||
pos.x = pad.pos.x;
|
||||
pos.y = pad.pos.y;
|
||||
pos.z = pad.pos.z;
|
||||
pos.x = pad->pos.x;
|
||||
pos.y = pad->pos.y;
|
||||
pos.z = pad->pos.z;
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
if (!padHasBboxData(obj->pad)) {
|
||||
if (obj->flags & OBJFLAG_00000002) {
|
||||
centre.x = pad.pos.x;
|
||||
centre.y = pad.pos.y;
|
||||
centre.z = pad.pos.z;
|
||||
centre.x = pad->pos.x;
|
||||
centre.y = pad->pos.y;
|
||||
centre.z = pad->pos.z;
|
||||
} else {
|
||||
centre.x = pad.pos.x;
|
||||
centre.y = pad.pos.y;
|
||||
centre.z = pad.pos.z;
|
||||
centre.x = pad->pos.x;
|
||||
centre.y = pad->pos.y;
|
||||
centre.z = pad->pos.z;
|
||||
}
|
||||
} else {
|
||||
padGetCentre(obj->pad, ¢re);
|
||||
centre.x += (pad.bbox.ymin - pad.bbox.ymax) * 0.5f * pad.up.x;
|
||||
centre.y += (pad.bbox.ymin - pad.bbox.ymax) * 0.5f * pad.up.y;
|
||||
centre.z += (pad.bbox.ymin - pad.bbox.ymax) * 0.5f * pad.up.z;
|
||||
centre.x += (pad->bbox.ymin - pad->bbox.ymax) * 0.5f * pad->up.x;
|
||||
centre.y += (pad->bbox.ymin - pad->bbox.ymax) * 0.5f * pad->up.y;
|
||||
centre.z += (pad->bbox.ymin - pad->bbox.ymax) * 0.5f * pad->up.z;
|
||||
}
|
||||
|
||||
if (obj->type == OBJTYPE_WEAPON) {
|
||||
|
|
@ -493,9 +493,9 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex)
|
|||
if (obj->flags & OBJFLAG_00000020) {
|
||||
if (bbox->xmin < bbox->xmax) {
|
||||
if (obj->flags & OBJFLAG_00000002) {
|
||||
xscale = (pad.bbox.xmax - pad.bbox.xmin) / ((bbox->xmax - bbox->xmin) * obj->model->scale);
|
||||
xscale = (pad->bbox.xmax - pad->bbox.xmin) / ((bbox->xmax - bbox->xmin) * obj->model->scale);
|
||||
} else {
|
||||
xscale = (pad.bbox.xmax - pad.bbox.xmin) / ((bbox->xmax - bbox->xmin) * obj->model->scale);
|
||||
xscale = (pad->bbox.xmax - pad->bbox.xmin) / ((bbox->xmax - bbox->xmin) * obj->model->scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -503,9 +503,9 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex)
|
|||
if (obj->flags & flag40) {
|
||||
if (bbox->ymin < bbox->ymax) {
|
||||
if (obj->flags & OBJFLAG_00000002) {
|
||||
zscale = (pad.bbox.zmax - pad.bbox.zmin) / ((bbox->ymax - bbox->ymin) * obj->model->scale);
|
||||
zscale = (pad->bbox.zmax - pad->bbox.zmin) / ((bbox->ymax - bbox->ymin) * obj->model->scale);
|
||||
} else {
|
||||
yscale = (pad.bbox.ymax - pad.bbox.ymin) / ((bbox->ymax - bbox->ymin) * obj->model->scale);
|
||||
yscale = (pad->bbox.ymax - pad->bbox.ymin) / ((bbox->ymax - bbox->ymin) * obj->model->scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -513,9 +513,9 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex)
|
|||
if (obj->flags & OBJFLAG_00000080) {
|
||||
if (bbox->zmin < bbox->zmax) {
|
||||
if (obj->flags & OBJFLAG_00000002) {
|
||||
yscale = (pad.bbox.ymax - pad.bbox.ymin) / ((bbox->zmax - bbox->zmin) * obj->model->scale);
|
||||
yscale = (pad->bbox.ymax - pad->bbox.ymin) / ((bbox->zmax - bbox->zmin) * obj->model->scale);
|
||||
} else {
|
||||
zscale = (pad.bbox.zmax - pad.bbox.zmin) / ((bbox->zmax - bbox->zmin) * obj->model->scale);
|
||||
zscale = (pad->bbox.zmax - pad->bbox.zmin) / ((bbox->zmax - bbox->zmin) * obj->model->scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -799,12 +799,12 @@ void setupCreateCctv(struct cctvobj *cctv, s32 cmdindex)
|
|||
if (cctv->lookatpadnum >= 0) {
|
||||
struct coord lenspos;
|
||||
union modelrodata *lens = modelGetPartRodata(obj->model->filedata, MODELPART_CCTV_CASING);
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
f32 xdiff;
|
||||
f32 ydiff;
|
||||
f32 zdiff;
|
||||
|
||||
padUnpack(cctv->lookatpadnum, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[cctv->lookatpadnum];
|
||||
|
||||
lenspos.x = lens->position.pos.x;
|
||||
lenspos.y = lens->position.pos.y;
|
||||
|
|
@ -816,9 +816,9 @@ void setupCreateCctv(struct cctvobj *cctv, s32 cmdindex)
|
|||
lenspos.y += obj->prop->pos.y;
|
||||
lenspos.z += obj->prop->pos.z;
|
||||
|
||||
xdiff = lenspos.x - pad.pos.x;
|
||||
ydiff = lenspos.y - pad.pos.y;
|
||||
zdiff = lenspos.z - pad.pos.z;
|
||||
xdiff = lenspos.x - pad->pos.x;
|
||||
ydiff = lenspos.y - pad->pos.y;
|
||||
zdiff = lenspos.z - pad->pos.z;
|
||||
|
||||
if (ydiff) {
|
||||
// empty
|
||||
|
|
@ -879,13 +879,13 @@ void setupCreateAutogun(struct autogunobj *autogun, s32 cmdindex)
|
|||
f32 ydiff;
|
||||
f32 zdiff;
|
||||
u32 stack2;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
padUnpack(autogun->targetpad, PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[autogun->targetpad];
|
||||
|
||||
xdiff = pad.pos.x - autogun->base.prop->pos.x;
|
||||
ydiff = pad.pos.y - autogun->base.prop->pos.y;
|
||||
zdiff = pad.pos.z - autogun->base.prop->pos.z;
|
||||
xdiff = pad->pos.x - autogun->base.prop->pos.x;
|
||||
ydiff = pad->pos.y - autogun->base.prop->pos.y;
|
||||
zdiff = pad->pos.z - autogun->base.prop->pos.z;
|
||||
|
||||
autogun->yzero = atan2f(xdiff, zdiff);
|
||||
autogun->xzero = atan2f(ydiff, sqrtf(xdiff * xdiff + zdiff * zdiff));
|
||||
|
|
@ -989,20 +989,20 @@ s32 setupGetPortalByPad(s32 padnum)
|
|||
struct coord centre;
|
||||
struct coord coord;
|
||||
u32 stack;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
padGetCentre(padnum, ¢re);
|
||||
padUnpack(padnum, PADFIELD_BBOX | PADFIELD_UP, &pad);
|
||||
pad = &g_Pads[padnum];
|
||||
|
||||
mult = (pad.bbox.ymax - pad.bbox.ymin) * 0.5f + 10;
|
||||
mult = (pad->bbox.ymax - pad->bbox.ymin) * 0.5f + 10;
|
||||
|
||||
coord.x = pad.up.x * mult + centre.x;
|
||||
coord.y = pad.up.y * mult + centre.y;
|
||||
coord.z = pad.up.z * mult + centre.z;
|
||||
coord.x = pad->up.x * mult + centre.x;
|
||||
coord.y = pad->up.y * mult + centre.y;
|
||||
coord.z = pad->up.z * mult + centre.z;
|
||||
|
||||
centre.x = centre.x - pad.up.x * mult;
|
||||
centre.y = centre.y - pad.up.y * mult;
|
||||
centre.z = centre.z - pad.up.z * mult;
|
||||
centre.x = centre.x - pad->up.x * mult;
|
||||
centre.y = centre.y - pad->up.y * mult;
|
||||
centre.z = centre.z - pad->up.z * mult;
|
||||
|
||||
return bg0f164e8c(¢re, &coord);
|
||||
}
|
||||
|
|
@ -1013,20 +1013,21 @@ s32 setupGetPortalByDoorPad(s32 padnum)
|
|||
struct coord centre;
|
||||
struct coord coord;
|
||||
u32 stack;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
padGetCentre(padnum, ¢re);
|
||||
padUnpack(padnum, PADFIELD_BBOX | PADFIELD_NORMAL, &pad);
|
||||
|
||||
mult = (pad.bbox.xmax - pad.bbox.xmin) * 0.5f + 10;
|
||||
pad = &g_Pads[padnum];
|
||||
|
||||
coord.x = pad.normal.x * mult + centre.x;
|
||||
coord.y = pad.normal.y * mult + centre.y;
|
||||
coord.z = pad.normal.z * mult + centre.z;
|
||||
mult = (pad->bbox.xmax - pad->bbox.xmin) * 0.5f + 10;
|
||||
|
||||
centre.x = centre.x - pad.normal.x * mult;
|
||||
centre.y = centre.y - pad.normal.y * mult;
|
||||
centre.z = centre.z - pad.normal.z * mult;
|
||||
coord.x = pad->normal.x * mult + centre.x;
|
||||
coord.y = pad->normal.y * mult + centre.y;
|
||||
coord.z = pad->normal.z * mult + centre.z;
|
||||
|
||||
centre.x = centre.x - pad->normal.x * mult;
|
||||
centre.y = centre.y - pad->normal.y * mult;
|
||||
centre.z = centre.z - pad->normal.z * mult;
|
||||
|
||||
return bg0f164e8c(¢re, &coord);
|
||||
}
|
||||
|
|
@ -1036,7 +1037,7 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex)
|
|||
f32 scale;
|
||||
s32 modelnum = door->base.modelnum;
|
||||
s32 portalnum = -1;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
setupLoadModeldef(modelnum);
|
||||
|
||||
|
|
@ -1048,16 +1049,16 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex)
|
|||
portalnum = setupGetPortalByDoorPad(door->base.pad);
|
||||
}
|
||||
|
||||
padUnpack(door->base.pad, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_NORMAL | PADFIELD_BBOX | PADFIELD_ROOM, &pad);
|
||||
pad = &g_Pads[door->base.pad];
|
||||
|
||||
if (g_DoorScale != 1) {
|
||||
pad.bbox.xmin *= g_DoorScale;
|
||||
pad.bbox.xmax *= g_DoorScale;
|
||||
pad->bbox.xmin *= g_DoorScale;
|
||||
pad->bbox.xmax *= g_DoorScale;
|
||||
|
||||
// If the door has a portal, adjust the pad's bbox to match the portal's dimensions
|
||||
if (portalnum >= 0) {
|
||||
struct var800a4ccc *ptr = &var800a4ccc[portalnum];
|
||||
f32 f0 = pad.pos.f[0] * ptr->coord.f[0] + pad.pos.f[1] * ptr->coord.f[1] + pad.pos.f[2] * ptr->coord.f[2];
|
||||
f32 f0 = pad->pos.f[0] * ptr->coord.f[0] + pad->pos.f[1] * ptr->coord.f[1] + pad->pos.f[2] * ptr->coord.f[2];
|
||||
f32 min = ptr->min;
|
||||
struct coord sp150;
|
||||
f0 = (f0 - min) * (g_DoorScale - 1);
|
||||
|
|
@ -1066,24 +1067,21 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex)
|
|||
sp150.y = ptr->coord.y * f0;
|
||||
sp150.z = ptr->coord.z * f0;
|
||||
|
||||
f0 = sp150.f[0] * pad.normal.f[0] + sp150.f[1] * pad.normal.f[1] + sp150.f[2] * pad.normal.f[2];
|
||||
pad.bbox.xmin += f0;
|
||||
pad.bbox.xmax += f0;
|
||||
f0 = sp150.f[0] * pad->normal.f[0] + sp150.f[1] * pad->normal.f[1] + sp150.f[2] * pad->normal.f[2];
|
||||
pad->bbox.xmin += f0;
|
||||
pad->bbox.xmax += f0;
|
||||
|
||||
f0 = sp150.f[0] * pad.up.f[0] + sp150.f[1] * pad.up.f[1] + sp150.f[2] * pad.up.f[2];
|
||||
pad.bbox.ymin += f0;
|
||||
pad.bbox.ymax += f0;
|
||||
f0 = sp150.f[0] * pad->up.f[0] + sp150.f[1] * pad->up.f[1] + sp150.f[2] * pad->up.f[2];
|
||||
pad->bbox.ymin += f0;
|
||||
pad->bbox.ymax += f0;
|
||||
|
||||
f0 = sp150.f[0] * pad.look.f[0] + sp150.f[1] * pad.look.f[1] + sp150.f[2] * pad.look.f[2];
|
||||
pad.bbox.zmin += f0;
|
||||
pad.bbox.zmax += f0;
|
||||
f0 = sp150.f[0] * pad->look.f[0] + sp150.f[1] * pad->look.f[1] + sp150.f[2] * pad->look.f[2];
|
||||
pad->bbox.zmin += f0;
|
||||
pad->bbox.zmax += f0;
|
||||
}
|
||||
|
||||
// Write the modified bbox into the pad file data
|
||||
padCopyBboxFromPad(door->base.pad, &pad);
|
||||
}
|
||||
|
||||
if (pad.room > 0) {
|
||||
if (pad->room > 0) {
|
||||
Mtxf sp110;
|
||||
struct prop *prop;
|
||||
s32 siblingcmdindex;
|
||||
|
|
@ -1101,8 +1099,8 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex)
|
|||
bbox = modelFileDataFindBboxRodata(g_ModelStates[modelnum].filedata);
|
||||
|
||||
mtx00016d58(&sp110, 0, 0, 0,
|
||||
-pad.look.x, -pad.look.y, -pad.look.z,
|
||||
pad.up.x, pad.up.y, pad.up.z);
|
||||
-pad->look.x, -pad->look.y, -pad->look.z,
|
||||
pad->up.x, pad->up.y, pad->up.z);
|
||||
mtx4LoadXRotation(1.5705462694168f, &finalmtx);
|
||||
mtx4LoadZRotation(1.5705462694168f, &zrotmtx);
|
||||
mtx4MultMtx4InPlace(&zrotmtx, &finalmtx);
|
||||
|
|
@ -1110,9 +1108,9 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex)
|
|||
|
||||
padGetCentre(door->base.pad, ¢re);
|
||||
|
||||
xscale = (pad.bbox.ymax - pad.bbox.ymin) / (bbox->xmax - bbox->xmin);
|
||||
yscale = (pad.bbox.zmax - pad.bbox.zmin) / (bbox->ymax - bbox->ymin);
|
||||
zscale = (pad.bbox.xmax - pad.bbox.xmin) / (bbox->zmax - bbox->zmin);
|
||||
xscale = (pad->bbox.ymax - pad->bbox.ymin) / (bbox->xmax - bbox->xmin);
|
||||
yscale = (pad->bbox.zmax - pad->bbox.zmin) / (bbox->ymax - bbox->ymin);
|
||||
zscale = (pad->bbox.xmax - pad->bbox.xmin) / (bbox->zmax - bbox->zmin);
|
||||
|
||||
if (xscale <= 0.000001f || yscale <= 0.000001f || zscale <= 0.000001f) {
|
||||
xscale = yscale = zscale = 1;
|
||||
|
|
@ -1122,21 +1120,21 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex)
|
|||
mtx00015e80(yscale, &finalmtx);
|
||||
mtx00015edc(zscale, &finalmtx);
|
||||
|
||||
pos.x = pad.pos.x;
|
||||
pos.y = pad.pos.y;
|
||||
pos.z = pad.pos.z;
|
||||
pos.x = pad->pos.x;
|
||||
pos.y = pad->pos.y;
|
||||
pos.z = pad->pos.z;
|
||||
|
||||
rooms[0] = pad.room;
|
||||
rooms[0] = pad->room;
|
||||
rooms[1] = -1;
|
||||
|
||||
if (door->doortype == DOORTYPE_VERTICAL || door->doortype == DOORTYPE_FALLAWAY) {
|
||||
sp54.x = pad.look.f[0] * (pad.bbox.zmax - pad.bbox.zmin);
|
||||
sp54.y = pad.look.f[1] * (pad.bbox.zmax - pad.bbox.zmin);
|
||||
sp54.z = pad.look.f[2] * (pad.bbox.zmax - pad.bbox.zmin);
|
||||
sp54.x = pad->look.f[0] * (pad->bbox.zmax - pad->bbox.zmin);
|
||||
sp54.y = pad->look.f[1] * (pad->bbox.zmax - pad->bbox.zmin);
|
||||
sp54.z = pad->look.f[2] * (pad->bbox.zmax - pad->bbox.zmin);
|
||||
} else {
|
||||
sp54.x = pad.up.f[0] * (pad.bbox.ymin - pad.bbox.ymax);
|
||||
sp54.y = pad.up.f[1] * (pad.bbox.ymin - pad.bbox.ymax);
|
||||
sp54.z = pad.up.f[2] * (pad.bbox.ymin - pad.bbox.ymax);
|
||||
sp54.x = pad->up.f[0] * (pad->bbox.ymin - pad->bbox.ymax);
|
||||
sp54.y = pad->up.f[1] * (pad->bbox.ymin - pad->bbox.ymax);
|
||||
sp54.z = pad->up.f[2] * (pad->bbox.ymin - pad->bbox.ymax);
|
||||
}
|
||||
|
||||
// These values are stored in the setup files as integers, but at
|
||||
|
|
|
|||
|
|
@ -14,13 +14,10 @@
|
|||
|
||||
/**
|
||||
* The function assumes that a pad file's data has been loaded from the ROM
|
||||
* and is pointed to by g_StageSetup.padfiledata. These pads are in a packed
|
||||
* format. During gameplay, the game uses padUnpack as needed to temporarily
|
||||
* populate pad structs from this data.
|
||||
* and is pointed to by g_StageSetup.padfiledata.
|
||||
*
|
||||
* setupPreparePads prepares the packed data by doing the following:
|
||||
* - populates the room field (if -1)
|
||||
* - multiplies each pad's bounding box by 1 (this is effectively a no op)
|
||||
* - sets the g_StageSetup pad/waygroup/waypoint/cover pointers
|
||||
* - promotes file offsets to RAM pointers
|
||||
* - does similar things for cover by calling setupPrepareCover()
|
||||
|
|
@ -32,7 +29,6 @@ void setupPreparePads(void)
|
|||
s32 padnum;
|
||||
s32 numpads;
|
||||
s32 roomnum;
|
||||
struct pad pad;
|
||||
struct waypoint *waypoint;
|
||||
struct waygroup *waygroup;
|
||||
s16 inrooms[24];
|
||||
|
|
@ -45,12 +41,10 @@ void setupPreparePads(void)
|
|||
numpads = g_PadsFile->numpads;
|
||||
|
||||
for (; padnum < numpads; padnum++) {
|
||||
padUnpack(padnum, PADFIELD_POS | PADFIELD_BBOX, &pad);
|
||||
|
||||
// If room is negative (ie. not specified)
|
||||
if (g_Pads[padnum].room < 0) {
|
||||
roomsptr = NULL;
|
||||
bgFindRoomsByPos(&pad.pos, inrooms, aboverooms, 20, NULL);
|
||||
bgFindRoomsByPos(&g_Pads[padnum].pos, inrooms, aboverooms, 20, NULL);
|
||||
|
||||
if (inrooms[0] != -1) {
|
||||
roomsptr = inrooms;
|
||||
|
|
@ -59,7 +53,7 @@ void setupPreparePads(void)
|
|||
}
|
||||
|
||||
if (roomsptr != NULL) {
|
||||
roomnum = cdFindFloorRoomAtPos(&pad.pos, roomsptr);
|
||||
roomnum = cdFindFloorRoomAtPos(&g_Pads[padnum].pos, roomsptr);
|
||||
|
||||
if (roomnum > 0) {
|
||||
g_Pads[padnum].room = roomnum;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ void setupLoadWaypoints(void)
|
|||
s32 numinserted;
|
||||
s32 j;
|
||||
s32 k;
|
||||
struct pad pad;
|
||||
struct pad pad2;
|
||||
struct pad *pad1;
|
||||
struct pad *pad2;
|
||||
s32 i;
|
||||
s32 currentroom;
|
||||
|
||||
|
|
@ -39,20 +39,20 @@ void setupLoadWaypoints(void)
|
|||
// Populate g_Vars.waypointnums, ordering them by roomnum asc, padnum asc
|
||||
for (i = 0; i < numwaypoints; i++) {
|
||||
waypoint = &waypoints[i];
|
||||
padUnpack(waypoint->padnum, PADFIELD_ROOM | PADFIELD_FLAGS, &pad);
|
||||
pad1 = &g_Pads[waypoint->padnum];
|
||||
|
||||
// Iterate previously processed waypoints and bail if the outer loop's
|
||||
// waypoint should be inserted prior to this one
|
||||
for (j = 0; j < numinserted; j++) {
|
||||
waypoint2 = &waypoints[g_Vars.waypointnums[j]];
|
||||
padUnpack(waypoint2->padnum, PADFIELD_ROOM | PADFIELD_FLAGS, &pad2);
|
||||
pad2 = &g_Pads[waypoint2->padnum];
|
||||
|
||||
if (pad.room < pad2.room) {
|
||||
if (pad1->room < pad2->room) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (pad.room == pad2.room
|
||||
&& ((pad2.flags & PADFLAG_AIDROP) || waypoint->padnum < waypoint2->padnum)) {
|
||||
if (pad1->room == pad2->room
|
||||
&& ((pad2->flags & PADFLAG_AIDROP) || waypoint->padnum < waypoint2->padnum)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -78,14 +78,14 @@ void setupLoadWaypoints(void)
|
|||
|
||||
for (i = 0; i < numwaypoints; i++) {
|
||||
waypoint = &g_StageSetup.waypoints[g_Vars.waypointnums[i]];
|
||||
padUnpack(waypoint->padnum, PADFIELD_ROOM | PADFIELD_FLAGS, &pad);
|
||||
pad1 = &g_Pads[waypoint->padnum];
|
||||
|
||||
if (pad.room != currentroom) {
|
||||
currentroom = pad.room;
|
||||
if (pad1->room != currentroom) {
|
||||
currentroom = pad1->room;
|
||||
g_Rooms[currentroom].firstwaypoint = i;
|
||||
}
|
||||
|
||||
if ((pad.flags & PADFLAG_AIDROP) == 0 && currentroom != -1) {
|
||||
if ((pad1->flags & PADFLAG_AIDROP) == 0 && currentroom != -1) {
|
||||
g_Rooms[currentroom].numwaypoints++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2791,7 +2791,7 @@ Gfx *sky0f126de8(Gfx *gdl)
|
|||
f32 f20_2;
|
||||
f32 f22;
|
||||
f32 f22_3;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
struct coord spe0;
|
||||
f32 spd0[4];
|
||||
Mtxf mtx;
|
||||
|
|
@ -2821,17 +2821,17 @@ Gfx *sky0f126de8(Gfx *gdl)
|
|||
f20 = 1.0f;
|
||||
}
|
||||
|
||||
padUnpack(g_Vars.currentplayer->teleportpad, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP, &pad);
|
||||
pad = &g_Pads[g_Vars.currentplayer->teleportpad];
|
||||
|
||||
g_TeleportToPos.x = pad.pos.x;
|
||||
g_TeleportToPos.y = pad.pos.y;
|
||||
g_TeleportToPos.z = pad.pos.z;
|
||||
g_TeleportToLook.x = pad.look.x;
|
||||
g_TeleportToLook.y = pad.look.y;
|
||||
g_TeleportToLook.z = pad.look.z;
|
||||
g_TeleportToUp.x = pad.up.x;
|
||||
g_TeleportToUp.y = pad.up.y;
|
||||
g_TeleportToUp.z = pad.up.z;
|
||||
g_TeleportToPos.x = pad->pos.x;
|
||||
g_TeleportToPos.y = pad->pos.y;
|
||||
g_TeleportToPos.z = pad->pos.z;
|
||||
g_TeleportToLook.x = pad->look.x;
|
||||
g_TeleportToLook.y = pad->look.y;
|
||||
g_TeleportToLook.z = pad->look.z;
|
||||
g_TeleportToUp.x = pad->up.x;
|
||||
g_TeleportToUp.y = pad->up.y;
|
||||
g_TeleportToUp.z = pad->up.z;
|
||||
|
||||
f22 = -cosf(f22 * M_PI) * 0.5f + .5f;
|
||||
f24 = 100 * f22;
|
||||
|
|
|
|||
|
|
@ -505,11 +505,11 @@ u32 frGetDifficulty(void)
|
|||
void frInitDefaults(void)
|
||||
{
|
||||
s32 i;
|
||||
struct pad pad;
|
||||
struct pad *pad;
|
||||
|
||||
g_FrNumSounds = 0;
|
||||
|
||||
padUnpack(g_FrPads[0], PADFIELD_POS, &pad);
|
||||
pad = &g_Pads[g_FrPads[0]];
|
||||
|
||||
g_FrData.maxactivetargets = 0;
|
||||
g_FrData.goalscore = 0;
|
||||
|
|
@ -521,9 +521,9 @@ void frInitDefaults(void)
|
|||
g_FrData.speed = 1;
|
||||
|
||||
for (i = 0; i < ARRAYCOUNT(g_FrData.targets); i++) {
|
||||
g_FrData.targets[i].dstpos.x = pad.pos.x;
|
||||
g_FrData.targets[i].dstpos.y = pad.pos.y;
|
||||
g_FrData.targets[i].dstpos.z = pad.pos.z;
|
||||
g_FrData.targets[i].dstpos.x = pad->pos.x;
|
||||
g_FrData.targets[i].dstpos.y = pad->pos.y;
|
||||
g_FrData.targets[i].dstpos.z = pad->pos.z;
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
g_FrData.targets[i].dstpos.z += 6.0f * i;
|
||||
|
|
@ -861,7 +861,6 @@ bool frExecuteTargetScript(s32 targetnum)
|
|||
s32 index = FRSCRIPTINDEX_TARGETS + g_FrData.targets[targetnum].scriptindex;
|
||||
u8 *script = &g_FrRomData[g_FrScriptOffsets[index]];
|
||||
s32 offset = g_FrData.targets[targetnum].scriptoffset;
|
||||
struct pad pad;
|
||||
s32 frpadnum;
|
||||
|
||||
switch (script[offset]) {
|
||||
|
|
@ -879,11 +878,9 @@ bool frExecuteTargetScript(s32 targetnum)
|
|||
|
||||
g_FrData.targets[targetnum].frpadnum = frpadnum;
|
||||
|
||||
padUnpack(g_FrPads[frpadnum], PADFIELD_POS, &pad);
|
||||
|
||||
g_FrData.targets[targetnum].dstpos.x = pad.pos.x;
|
||||
g_FrData.targets[targetnum].dstpos.y = pad.pos.y;
|
||||
g_FrData.targets[targetnum].dstpos.z = pad.pos.z;
|
||||
g_FrData.targets[targetnum].dstpos.x = g_Pads[g_FrPads[frpadnum]].pos.x;
|
||||
g_FrData.targets[targetnum].dstpos.y = g_Pads[g_FrPads[frpadnum]].pos.y;
|
||||
g_FrData.targets[targetnum].dstpos.z = g_Pads[g_FrPads[frpadnum]].pos.z;
|
||||
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
g_FrData.targets[targetnum].dstpos.z += 6.0f * targetnum;
|
||||
|
|
@ -989,14 +986,12 @@ void frInitTargets(void)
|
|||
g_FrData.targets[i].active = false;
|
||||
}
|
||||
|
||||
padUnpack(g_FrPads[g_FrData.targets[i].frpadindex], PADFIELD_POS, &pad);
|
||||
|
||||
pos.f[0] = pad.pos.f[0];
|
||||
pos.f[1] = pad.pos.f[1];
|
||||
pos.f[0] = g_Pads[g_FrPads[g_FrData.targets[i].frpadindex]].pos.f[0];
|
||||
pos.f[1] = g_Pads[g_FrPads[g_FrData.targets[i].frpadindex]].pos.f[1];
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
pos.f[2] = pad.pos.f[2] + 6.0f * i;
|
||||
pos.f[2] = g_Pads[g_FrPads[g_FrData.targets[i].frpadindex]].pos.f[2] + 6.0f * i;
|
||||
#else
|
||||
pos.f[2] = pad.pos.f[2];
|
||||
pos.f[2] = g_Pads[g_FrPads[g_FrData.targets[i].frpadindex]].pos.f[2];
|
||||
#endif
|
||||
|
||||
frExecuteTargetScript(i);
|
||||
|
|
@ -1013,17 +1008,9 @@ void frInitTargets(void)
|
|||
}
|
||||
|
||||
if (obj->flags2 & OBJFLAG2_INVISIBLE) {
|
||||
#if VERSION < VERSION_NTSC_1_0
|
||||
padUnpack(g_FrPads[g_FrData.targets[i].frpadindex], PADFIELD_POS, &pad);
|
||||
|
||||
pos.x = 0.0f;
|
||||
pos.y = 5000.0f;
|
||||
pos.z = 0.0f;
|
||||
#else
|
||||
pos.x = 0.0f;
|
||||
pos.y = 5000.0f;
|
||||
pos.z = 6.0f * i;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (g_FrData.targets[i].flags & FRTARGETFLAG_SPAWNFACINGAWAY) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue