mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 02:42:20 +00:00
Merge branch 'next' of https://git.magicalgirl.moe/STJr/SRB2 into gamequit-hook
This commit is contained in:
commit
566a5a0ab7
13 changed files with 431 additions and 698 deletions
|
@ -620,6 +620,19 @@ extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative
|
|||
extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF
|
||||
extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
|
||||
|
||||
#define WAYPOINTSEQUENCESIZE 256
|
||||
#define NUMWAYPOINTSEQUENCES 256
|
||||
extern mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
|
||||
extern UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
|
||||
|
||||
void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint);
|
||||
mobj_t *P_GetFirstWaypoint(UINT8 sequence);
|
||||
mobj_t *P_GetLastWaypoint(UINT8 sequence);
|
||||
mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap);
|
||||
mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap);
|
||||
mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo);
|
||||
boolean P_IsDegeneratedWaypointSequence(UINT8 sequence);
|
||||
|
||||
// =====================================
|
||||
// Internal parameters, used for engine.
|
||||
// =====================================
|
||||
|
|
|
@ -2898,15 +2898,50 @@ static int lib_gAddGametype(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int Lcheckmapnumber (lua_State *L, int idx, const char *fun)
|
||||
{
|
||||
if (ISINLEVEL)
|
||||
return luaL_optinteger(L, idx, gamemap);
|
||||
else
|
||||
{
|
||||
if (lua_isnoneornil(L, idx))
|
||||
{
|
||||
return luaL_error(L,
|
||||
"%s can only be used without a parameter while in a level.",
|
||||
fun
|
||||
);
|
||||
}
|
||||
else
|
||||
return luaL_checkinteger(L, idx);
|
||||
}
|
||||
}
|
||||
|
||||
static int lib_gBuildMapName(lua_State *L)
|
||||
{
|
||||
INT32 map = luaL_optinteger(L, 1, gamemap);
|
||||
INT32 map = Lcheckmapnumber(L, 1, "G_BuildMapName");
|
||||
//HUDSAFE
|
||||
INLEVEL
|
||||
lua_pushstring(L, G_BuildMapName(map));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_gBuildMapTitle(lua_State *L)
|
||||
{
|
||||
INT32 map = Lcheckmapnumber(L, 1, "G_BuildMapTitle");
|
||||
char *name;
|
||||
if (map < 1 || map > NUMMAPS)
|
||||
{
|
||||
return luaL_error(L,
|
||||
"map number %d out of range (1 - %d)",
|
||||
map,
|
||||
NUMMAPS
|
||||
);
|
||||
}
|
||||
name = G_BuildMapTitle(map);
|
||||
lua_pushstring(L, name);
|
||||
Z_Free(name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_gDoReborn(lua_State *L)
|
||||
{
|
||||
INT32 playernum = luaL_checkinteger(L, 1);
|
||||
|
@ -3292,6 +3327,7 @@ static luaL_Reg lib[] = {
|
|||
// g_game
|
||||
{"G_AddGametype", lib_gAddGametype},
|
||||
{"G_BuildMapName",lib_gBuildMapName},
|
||||
{"G_BuildMapTitle",lib_gBuildMapTitle},
|
||||
{"G_DoReborn",lib_gDoReborn},
|
||||
{"G_SetCustomExitVars",lib_gSetCustomExitVars},
|
||||
{"G_EnoughPlayersFinished",lib_gEnoughPlayersFinished},
|
||||
|
|
|
@ -829,6 +829,15 @@ static int mapthing_set(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mapthing_num(lua_State *L)
|
||||
{
|
||||
mapthing_t *mt = *((mapthing_t **)luaL_checkudata(L, 1, META_MAPTHING));
|
||||
if (!mt)
|
||||
return luaL_error(L, "accessed mapthing_t doesn't exist anymore.");
|
||||
lua_pushinteger(L, mt-mapthings);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_iterateMapthings(lua_State *L)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
@ -893,6 +902,9 @@ int LUA_MobjLib(lua_State *L)
|
|||
|
||||
lua_pushcfunction(L, mapthing_set);
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
|
||||
lua_pushcfunction(L, mapthing_num);
|
||||
lua_setfield(L, -2, "__len");
|
||||
lua_pop(L,1);
|
||||
|
||||
lua_newuserdata(L, 0);
|
||||
|
|
|
@ -99,5 +99,8 @@ void COM_Lua_f(void);
|
|||
// uncomment if you want seg_t/node_t in Lua
|
||||
// #define HAVE_LUA_SEGS
|
||||
|
||||
#define INLEVEL if (gamestate != GS_LEVEL && !titlemapinaction)\
|
||||
#define ISINLEVEL \
|
||||
(gamestate == GS_LEVEL || titlemapinaction)
|
||||
|
||||
#define INLEVEL if (! ISINLEVEL)\
|
||||
return luaL_error(L, "This can only be used in a level!");
|
||||
|
|
|
@ -8852,19 +8852,19 @@ void A_Dye(mobj_t *actor)
|
|||
return;
|
||||
if (color >= MAXTRANSLATIONS)
|
||||
return;
|
||||
|
||||
|
||||
if (!color)
|
||||
target->colorized = false;
|
||||
else
|
||||
target->colorized = true;
|
||||
|
||||
|
||||
// What if it's a player?
|
||||
if (target->player)
|
||||
{
|
||||
target->player->powers[pw_dye] = color;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
target->color = color;
|
||||
}
|
||||
|
||||
|
@ -9707,6 +9707,9 @@ void A_SplitShot(mobj_t *actor)
|
|||
if (LUA_CallAction("A_SplitShot", actor))
|
||||
return;
|
||||
|
||||
if (!actor->target)
|
||||
return;
|
||||
|
||||
A_FaceTarget(actor);
|
||||
{
|
||||
const angle_t an = (actor->angle + ANGLE_90) >> ANGLETOFINESHIFT;
|
||||
|
@ -12700,8 +12703,8 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
|||
else // locvar1 == 0
|
||||
{
|
||||
fixed_t hackoffset = P_MobjFlip(actor)*56*FRACUNIT;
|
||||
INT32 numwaypoints = 0;
|
||||
mobj_t **waypoints;
|
||||
INT32 numfangwaypoints = 0;
|
||||
mobj_t **fangwaypoints;
|
||||
INT32 key;
|
||||
|
||||
actor->z += hackoffset;
|
||||
|
@ -12726,7 +12729,7 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
|||
continue;
|
||||
if (!P_CheckSight(actor, mapthings[i].mobj))
|
||||
continue;
|
||||
numwaypoints++;
|
||||
numfangwaypoints++;
|
||||
}
|
||||
|
||||
// players also count as waypoints apparently
|
||||
|
@ -12748,11 +12751,11 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
|||
continue;
|
||||
if (!P_CheckSight(actor, players[i].mo))
|
||||
continue;
|
||||
numwaypoints++;
|
||||
numfangwaypoints++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!numwaypoints)
|
||||
if (!numfangwaypoints)
|
||||
{
|
||||
// restore z position
|
||||
actor->z -= hackoffset;
|
||||
|
@ -12760,8 +12763,8 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
|||
}
|
||||
|
||||
// allocate the table and reset count to zero
|
||||
waypoints = Z_Calloc(sizeof(*waypoints)*numwaypoints, PU_STATIC, NULL);
|
||||
numwaypoints = 0;
|
||||
fangwaypoints = Z_Calloc(sizeof(*waypoints)*numfangwaypoints, PU_STATIC, NULL);
|
||||
numfangwaypoints = 0;
|
||||
|
||||
// now find them again and add them to the table!
|
||||
for (i = 0; i < nummapthings; i++)
|
||||
|
@ -12786,7 +12789,7 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
|||
}
|
||||
if (!P_CheckSight(actor, mapthings[i].mobj))
|
||||
continue;
|
||||
waypoints[numwaypoints++] = mapthings[i].mobj;
|
||||
fangwaypoints[numfangwaypoints++] = mapthings[i].mobj;
|
||||
}
|
||||
|
||||
if (actor->extravalue2 > 1)
|
||||
|
@ -12807,25 +12810,25 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
|||
continue;
|
||||
if (!P_CheckSight(actor, players[i].mo))
|
||||
continue;
|
||||
waypoints[numwaypoints++] = players[i].mo;
|
||||
fangwaypoints[numfangwaypoints++] = players[i].mo;
|
||||
}
|
||||
}
|
||||
|
||||
// restore z position
|
||||
actor->z -= hackoffset;
|
||||
|
||||
if (!numwaypoints)
|
||||
if (!numfangwaypoints)
|
||||
{
|
||||
Z_Free(waypoints); // free table
|
||||
Z_Free(fangwaypoints); // free table
|
||||
goto nowaypoints; // ???
|
||||
}
|
||||
|
||||
key = P_RandomKey(numwaypoints);
|
||||
key = P_RandomKey(numfangwaypoints);
|
||||
|
||||
P_SetTarget(&actor->tracer, waypoints[key]);
|
||||
P_SetTarget(&actor->tracer, fangwaypoints[key]);
|
||||
if (actor->tracer->type == MT_FANGWAYPOINT)
|
||||
actor->tracer->reactiontime = numwaypoints/4; // Monster Iestyn: is this how it should be? I count center waypoints as waypoints unlike the original Lua script
|
||||
Z_Free(waypoints); // free table
|
||||
actor->tracer->reactiontime = numfangwaypoints/4; // Monster Iestyn: is this how it should be? I count center waypoints as waypoints unlike the original Lua script
|
||||
Z_Free(fangwaypoints); // free table
|
||||
}
|
||||
|
||||
// now face the tracer you just set!
|
||||
|
|
|
@ -12678,9 +12678,14 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
|
|||
mobj->threshold = min(mthing->extrainfo, 7);
|
||||
break;
|
||||
case MT_TUBEWAYPOINT:
|
||||
mobj->health = mthing->angle & 255;
|
||||
mobj->threshold = mthing->angle >> 8;
|
||||
{
|
||||
UINT8 sequence = mthing->angle >> 8;
|
||||
UINT8 id = mthing->angle & 255;
|
||||
mobj->health = id;
|
||||
mobj->threshold = sequence;
|
||||
P_AddWaypoint(sequence, id, mobj);
|
||||
break;
|
||||
}
|
||||
case MT_IDEYAANCHOR:
|
||||
mobj->health = mthing->extrainfo;
|
||||
break;
|
||||
|
|
487
src/p_polyobj.c
487
src/p_polyobj.c
|
@ -1569,17 +1569,39 @@ void T_PolyObjMove(polymove_t *th)
|
|||
}
|
||||
}
|
||||
|
||||
static void T_MovePolyObj(polyobj_t *po, fixed_t distx, fixed_t disty, fixed_t distz)
|
||||
{
|
||||
polyobj_t *child;
|
||||
INT32 start;
|
||||
|
||||
Polyobj_moveXY(po, distx, disty, true);
|
||||
// TODO: use T_MovePlane
|
||||
po->lines[0]->backsector->floorheight += distz;
|
||||
po->lines[0]->backsector->ceilingheight += distz;
|
||||
// Sal: Remember to check your sectors!
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
// Apply action to mirroring polyobjects as well
|
||||
start = 0;
|
||||
while ((child = Polyobj_GetChild(po, &start)))
|
||||
{
|
||||
if (child->isBad)
|
||||
continue;
|
||||
|
||||
Polyobj_moveXY(child, distx, disty, true);
|
||||
// TODO: use T_MovePlane
|
||||
child->lines[0]->backsector->floorheight += distz;
|
||||
child->lines[0]->backsector->ceilingheight += distz;
|
||||
P_CheckSector(child->lines[0]->backsector, (boolean)(child->damage));
|
||||
}
|
||||
}
|
||||
|
||||
void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||
{
|
||||
mobj_t *mo2;
|
||||
mobj_t *target = NULL;
|
||||
mobj_t *waypoint = NULL;
|
||||
thinker_t *wp;
|
||||
fixed_t adjustx, adjusty, adjustz;
|
||||
fixed_t momx, momy, momz, dist;
|
||||
INT32 start;
|
||||
polyobj_t *po = Polyobj_GetForNum(th->polyObjNum);
|
||||
polyobj_t *oldpo = po;
|
||||
fixed_t speed = th->speed;
|
||||
|
||||
if (!po)
|
||||
#ifdef RANGECHECK
|
||||
|
@ -1593,31 +1615,10 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
|||
#endif
|
||||
|
||||
// check for displacement due to override and reattach when possible
|
||||
if (po->thinker == NULL)
|
||||
if (!po->thinker)
|
||||
po->thinker = &th->thinker;
|
||||
|
||||
/*
|
||||
// Find out target first.
|
||||
// We redo this each tic to make savegame compatibility easier.
|
||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
||||
{
|
||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)wp;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold == th->sequence && mo2->health == th->pointnum)
|
||||
{
|
||||
target = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
target = th->target;
|
||||
target = waypoints[th->sequence][th->pointnum];
|
||||
|
||||
if (!target)
|
||||
{
|
||||
|
@ -1625,240 +1626,93 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
|||
return;
|
||||
}
|
||||
|
||||
// Compensate for position offset
|
||||
adjustx = po->centerPt.x + th->diffx;
|
||||
adjusty = po->centerPt.y + th->diffy;
|
||||
adjustz = po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2 + th->diffz;
|
||||
|
||||
dist = P_AproxDistance(P_AproxDistance(target->x - adjustx, target->y - adjusty), target->z - adjustz);
|
||||
|
||||
if (dist < 1)
|
||||
dist = 1;
|
||||
|
||||
momx = FixedMul(FixedDiv(target->x - adjustx, dist), (th->speed));
|
||||
momy = FixedMul(FixedDiv(target->y - adjusty, dist), (th->speed));
|
||||
momz = FixedMul(FixedDiv(target->z - adjustz, dist), (th->speed));
|
||||
|
||||
// Calculate the distance between the polyobject and the waypoint
|
||||
// 'dist' already equals this.
|
||||
|
||||
// Will the polyobject be FURTHER away if the momx/momy/momz is added to
|
||||
// its current coordinates, or closer? (shift down to fracunits to avoid approximation errors)
|
||||
if (dist>>FRACBITS <= P_AproxDistance(P_AproxDistance(target->x - adjustx - momx, target->y - adjusty - momy), target->z - adjustz - momz)>>FRACBITS)
|
||||
// Move along the waypoint sequence until speed for the current tic is exhausted
|
||||
while (speed > 0)
|
||||
{
|
||||
// If further away, set XYZ of polyobject to waypoint location
|
||||
fixed_t amtx, amty, amtz;
|
||||
fixed_t diffz;
|
||||
amtx = (target->x - th->diffx) - po->centerPt.x;
|
||||
amty = (target->y - th->diffy) - po->centerPt.y;
|
||||
Polyobj_moveXY(po, amtx, amty, true);
|
||||
// TODO: use T_MovePlane
|
||||
amtz = (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2;
|
||||
diffz = po->lines[0]->backsector->floorheight - (target->z - amtz);
|
||||
po->lines[0]->backsector->floorheight = target->z - amtz;
|
||||
po->lines[0]->backsector->ceilingheight = target->z + amtz;
|
||||
// Sal: Remember to check your sectors!
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
// Apply action to mirroring polyobjects as well
|
||||
start = 0;
|
||||
while ((po = Polyobj_GetChild(oldpo, &start)))
|
||||
mobj_t *waypoint = NULL;
|
||||
fixed_t pox, poy, poz;
|
||||
fixed_t distx, disty, distz, dist;
|
||||
|
||||
// Current position of polyobject
|
||||
pox = po->centerPt.x;
|
||||
poy = po->centerPt.y;
|
||||
poz = (po->lines[0]->backsector->floorheight + po->lines[0]->backsector->ceilingheight)/2;
|
||||
|
||||
// Calculate the distance between the polyobject and the waypoint
|
||||
distx = target->x - pox;
|
||||
disty = target->y - poy;
|
||||
distz = target->z - poz;
|
||||
dist = P_AproxDistance(P_AproxDistance(distx, disty), distz);
|
||||
|
||||
if (dist < 1)
|
||||
dist = 1;
|
||||
|
||||
// Will the polyobject overshoot its target?
|
||||
if (speed < dist)
|
||||
{
|
||||
if (po->isBad)
|
||||
continue;
|
||||
// No. Move towards waypoint
|
||||
fixed_t momx, momy, momz;
|
||||
|
||||
Polyobj_moveXY(po, amtx, amty, true);
|
||||
// TODO: use T_MovePlane
|
||||
po->lines[0]->backsector->floorheight += diffz; // move up/down by same amount as the parent did
|
||||
po->lines[0]->backsector->ceilingheight += diffz;
|
||||
// Sal: Remember to check your sectors!
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
}
|
||||
|
||||
po = oldpo;
|
||||
|
||||
if (!th->stophere)
|
||||
{
|
||||
CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n");
|
||||
|
||||
// Find next waypoint
|
||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
||||
{
|
||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)wp;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != th->sequence)
|
||||
continue;
|
||||
|
||||
if (th->direction == -1)
|
||||
{
|
||||
if (mo2->health == target->health - 1)
|
||||
{
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mo2->health == target->health + 1)
|
||||
{
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!waypoint && th->wrap) // If specified, wrap waypoints
|
||||
{
|
||||
if (!th->continuous)
|
||||
{
|
||||
th->wrap = 0;
|
||||
th->stophere = true;
|
||||
}
|
||||
|
||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
||||
{
|
||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)wp;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != th->sequence)
|
||||
continue;
|
||||
|
||||
if (th->direction == -1)
|
||||
{
|
||||
if (waypoint == NULL)
|
||||
waypoint = mo2;
|
||||
else if (mo2->health > waypoint->health)
|
||||
waypoint = mo2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mo2->health == 0)
|
||||
{
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!waypoint && th->comeback) // Come back to the start
|
||||
{
|
||||
th->direction = -th->direction;
|
||||
|
||||
if (!th->continuous)
|
||||
th->comeback = false;
|
||||
|
||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
||||
{
|
||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)wp;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != th->sequence)
|
||||
continue;
|
||||
|
||||
if (th->direction == -1)
|
||||
{
|
||||
if (mo2->health == target->health - 1)
|
||||
{
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mo2->health == target->health + 1)
|
||||
{
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (waypoint)
|
||||
{
|
||||
CONS_Debug(DBG_POLYOBJ, "Found waypoint (sequence %d, number %d).\n", waypoint->threshold, waypoint->health);
|
||||
|
||||
target = waypoint;
|
||||
th->pointnum = target->health;
|
||||
// Set the mobj as your target! -- Monster Iestyn 27/12/19
|
||||
P_SetTarget(&th->target, target);
|
||||
|
||||
// calculate MOMX/MOMY/MOMZ for next waypoint
|
||||
// change slope
|
||||
dist = P_AproxDistance(P_AproxDistance(target->x - adjustx, target->y - adjusty), target->z - adjustz);
|
||||
|
||||
if (dist < 1)
|
||||
dist = 1;
|
||||
|
||||
momx = FixedMul(FixedDiv(target->x - adjustx, dist), (th->speed));
|
||||
momy = FixedMul(FixedDiv(target->y - adjusty, dist), (th->speed));
|
||||
momz = FixedMul(FixedDiv(target->z - adjustz, dist), (th->speed));
|
||||
momx = FixedMul(FixedDiv(target->x - pox, dist), speed);
|
||||
momy = FixedMul(FixedDiv(target->y - poy, dist), speed);
|
||||
momz = FixedMul(FixedDiv(target->z - poz, dist), speed);
|
||||
T_MovePolyObj(po, momx, momy, momz);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
momx = momy = momz = 0;
|
||||
// Yes. Teleport to waypoint and look for the next one
|
||||
T_MovePolyObj(po, distx, disty, distz);
|
||||
|
||||
if (!th->stophere)
|
||||
CONS_Debug(DBG_POLYOBJ, "Next waypoint not found!\n");
|
||||
{
|
||||
CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n");
|
||||
waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false);
|
||||
|
||||
if (po->thinker == &th->thinker)
|
||||
po->thinker = NULL;
|
||||
if (!waypoint && th->returnbehavior == PWR_WRAP) // If specified, wrap waypoints
|
||||
{
|
||||
if (!th->continuous)
|
||||
{
|
||||
th->returnbehavior = PWR_STOP;
|
||||
th->stophere = true;
|
||||
}
|
||||
|
||||
P_RemoveThinker(&th->thinker);
|
||||
return;
|
||||
waypoint = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence);
|
||||
}
|
||||
else if (!waypoint && th->returnbehavior == PWR_COMEBACK) // Come back to the start
|
||||
{
|
||||
th->direction = -th->direction;
|
||||
|
||||
if (!th->continuous)
|
||||
th->returnbehavior = PWR_STOP;
|
||||
|
||||
waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (waypoint)
|
||||
{
|
||||
CONS_Debug(DBG_POLYOBJ, "Found waypoint (sequence %d, number %d).\n", waypoint->threshold, waypoint->health);
|
||||
|
||||
target = waypoint;
|
||||
th->pointnum = target->health;
|
||||
|
||||
// Calculate remaining speed
|
||||
speed -= dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!th->stophere)
|
||||
CONS_Debug(DBG_POLYOBJ, "Next waypoint not found!\n");
|
||||
|
||||
if (po->thinker == &th->thinker)
|
||||
po->thinker = NULL;
|
||||
|
||||
P_RemoveThinker(&th->thinker);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// momx/momy/momz already equals the right speed
|
||||
}
|
||||
|
||||
// Move the polyobject
|
||||
Polyobj_moveXY(po, momx, momy, true);
|
||||
// TODO: use T_MovePlane
|
||||
po->lines[0]->backsector->floorheight += momz;
|
||||
po->lines[0]->backsector->ceilingheight += momz;
|
||||
// Sal: Remember to check your sectors!
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
|
||||
// Apply action to mirroring polyobjects as well
|
||||
start = 0;
|
||||
while ((po = Polyobj_GetChild(oldpo, &start)))
|
||||
{
|
||||
if (po->isBad)
|
||||
continue;
|
||||
|
||||
Polyobj_moveXY(po, momx, momy, true);
|
||||
// TODO: use T_MovePlane
|
||||
po->lines[0]->backsector->floorheight += momz;
|
||||
po->lines[0]->backsector->ceilingheight += momz;
|
||||
// Sal: Remember to check your sectors!
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
}
|
||||
}
|
||||
|
||||
void T_PolyDoorSlide(polyslidedoor_t *th)
|
||||
|
@ -2276,11 +2130,7 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
|||
{
|
||||
polyobj_t *po;
|
||||
polywaypoint_t *th;
|
||||
mobj_t *mo2;
|
||||
mobj_t *first = NULL;
|
||||
mobj_t *last = NULL;
|
||||
mobj_t *target = NULL;
|
||||
thinker_t *wp;
|
||||
|
||||
if (!(po = Polyobj_GetForNum(pwdata->polyObjNum)))
|
||||
{
|
||||
|
@ -2304,56 +2154,16 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
|||
// set fields
|
||||
th->polyObjNum = pwdata->polyObjNum;
|
||||
th->speed = pwdata->speed;
|
||||
th->sequence = pwdata->sequence; // Used to specify sequence #
|
||||
if (pwdata->reverse)
|
||||
th->direction = -1;
|
||||
else
|
||||
th->direction = 1;
|
||||
th->sequence = pwdata->sequence;
|
||||
th->direction = (pwdata->flags & PWF_REVERSE) ? -1 : 1;
|
||||
|
||||
th->comeback = pwdata->comeback;
|
||||
th->continuous = pwdata->continuous;
|
||||
th->wrap = pwdata->wrap;
|
||||
th->returnbehavior = pwdata->returnbehavior;
|
||||
if (pwdata->flags & PWF_LOOP)
|
||||
th->continuous = true;
|
||||
th->stophere = false;
|
||||
|
||||
// Find the first waypoint we need to use
|
||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
||||
{
|
||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)wp;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != th->sequence)
|
||||
continue;
|
||||
|
||||
if (th->direction == -1) // highest waypoint #
|
||||
{
|
||||
if (mo2->health == 0)
|
||||
last = mo2;
|
||||
else
|
||||
{
|
||||
if (first == NULL)
|
||||
first = mo2;
|
||||
else if (mo2->health > first->health)
|
||||
first = mo2;
|
||||
}
|
||||
}
|
||||
else // waypoint 0
|
||||
{
|
||||
if (mo2->health == 0)
|
||||
first = mo2;
|
||||
else
|
||||
{
|
||||
if (last == NULL)
|
||||
last = mo2;
|
||||
else if (mo2->health > last->health)
|
||||
last = mo2;
|
||||
}
|
||||
}
|
||||
}
|
||||
first = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence);
|
||||
|
||||
if (!first)
|
||||
{
|
||||
|
@ -2363,77 +2173,16 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Hotfix to not crash on single-waypoint sequences -Red
|
||||
if (!last)
|
||||
last = first;
|
||||
|
||||
// Set diffx, diffy, diffz
|
||||
// Put these at 0 for now...might not be needed after all.
|
||||
th->diffx = 0;//first->x - po->centerPt.x;
|
||||
th->diffy = 0;//first->y - po->centerPt.y;
|
||||
th->diffz = 0;//first->z - (po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2);
|
||||
|
||||
if (last->x == po->centerPt.x
|
||||
&& last->y == po->centerPt.y
|
||||
&& last->z == (po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2))
|
||||
// Sanity check: If all waypoints are in the same location,
|
||||
// don't allow the movement to be continuous so we don't get stuck in an infinite loop.
|
||||
if (th->continuous && P_IsDegeneratedWaypointSequence(th->sequence))
|
||||
{
|
||||
// Already at the destination point...
|
||||
if (!th->wrap)
|
||||
{
|
||||
po->thinker = NULL;
|
||||
P_RemoveThinker(&th->thinker);
|
||||
}
|
||||
CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: All waypoints are in the same location!\n");
|
||||
th->continuous = false;
|
||||
}
|
||||
|
||||
// Find the actual target movement waypoint
|
||||
target = first;
|
||||
/*for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
||||
{
|
||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
th->pointnum = first->health;
|
||||
|
||||
mo2 = (mobj_t *)wp;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != th->sequence)
|
||||
continue;
|
||||
|
||||
if (th->direction == -1) // highest waypoint #
|
||||
{
|
||||
if (mo2->health == first->health - 1)
|
||||
{
|
||||
target = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // waypoint 0
|
||||
{
|
||||
if (mo2->health == first->health + 1)
|
||||
{
|
||||
target = mo2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!target)
|
||||
{
|
||||
CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjWaypoint: Missing target waypoint!\n");
|
||||
po->thinker = NULL;
|
||||
P_RemoveThinker(&th->thinker);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set pointnum
|
||||
th->pointnum = target->health;
|
||||
th->target = NULL; // set to NULL first so the below doesn't go wrong
|
||||
// Set the mobj as your target! -- Monster Iestyn 27/12/19
|
||||
P_SetTarget(&th->target, target);
|
||||
|
||||
// We don't deal with the mirror crap here, we'll
|
||||
// handle that in the T_Thinker function.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,26 +140,26 @@ typedef struct polymove_s
|
|||
UINT32 angle; // angle along which to move
|
||||
} polymove_t;
|
||||
|
||||
// PolyObject waypoint movement return behavior
|
||||
typedef enum
|
||||
{
|
||||
PWR_STOP, // Stop after reaching last waypoint
|
||||
PWR_WRAP, // Wrap back to first waypoint
|
||||
PWR_COMEBACK, // Repeat sequence in reverse
|
||||
} polywaypointreturn_e;
|
||||
|
||||
typedef struct polywaypoint_s
|
||||
{
|
||||
thinker_t thinker; // must be first
|
||||
|
||||
INT32 polyObjNum; // numeric id of polyobject
|
||||
INT32 speed; // resultant velocity
|
||||
INT32 sequence; // waypoint sequence #
|
||||
INT32 pointnum; // waypoint #
|
||||
INT32 direction; // 1 for normal, -1 for backwards
|
||||
UINT8 comeback; // reverses and comes back when the end is reached
|
||||
UINT8 wrap; // Wrap around waypoints
|
||||
UINT8 continuous; // continuously move - used with COMEBACK or WRAP
|
||||
UINT8 stophere; // Will stop after it reaches the next waypoint
|
||||
|
||||
// Difference between location of PO and location of waypoint (offset)
|
||||
fixed_t diffx;
|
||||
fixed_t diffy;
|
||||
fixed_t diffz;
|
||||
|
||||
mobj_t *target; // next waypoint mobj
|
||||
INT32 polyObjNum; // numeric id of polyobject
|
||||
INT32 speed; // resultant velocity
|
||||
INT32 sequence; // waypoint sequence #
|
||||
INT32 pointnum; // waypoint #
|
||||
INT32 direction; // 1 for normal, -1 for backwards
|
||||
UINT8 returnbehavior; // behavior after reaching the last waypoint
|
||||
UINT8 continuous; // continuously move - used with PWR_WRAP or PWR_COMEBACK
|
||||
UINT8 stophere; // Will stop after it reaches the next waypoint
|
||||
} polywaypoint_t;
|
||||
|
||||
typedef struct polyslidedoor_s
|
||||
|
@ -254,15 +254,19 @@ typedef struct polymovedata_s
|
|||
UINT8 overRide; // if true, will override any action on the object
|
||||
} polymovedata_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PWF_REVERSE = 1, // Move through waypoints in reverse order
|
||||
PWF_LOOP = 1<<1, // Loop movement (used with PWR_WRAP or PWR_COMEBACK)
|
||||
} polywaypointflags_e;
|
||||
|
||||
typedef struct polywaypointdata_s
|
||||
{
|
||||
INT32 polyObjNum; // numeric id of polyobject to affect
|
||||
INT32 sequence; // waypoint sequence #
|
||||
fixed_t speed; // linear speed
|
||||
UINT8 reverse; // if true, will go in reverse waypoint order
|
||||
UINT8 comeback; // reverses and comes back when the end is reached
|
||||
UINT8 wrap; // Wrap around waypoints
|
||||
UINT8 continuous; // continuously move - used with COMEBACK or WRAP
|
||||
INT32 polyObjNum; // numeric id of polyobject to affect
|
||||
INT32 sequence; // waypoint sequence #
|
||||
fixed_t speed; // linear speed
|
||||
UINT8 returnbehavior; // behavior after reaching the last waypoint
|
||||
UINT8 flags; // PWF_ flags
|
||||
} polywaypointdata_t;
|
||||
|
||||
// polyobject door types
|
||||
|
|
|
@ -2018,14 +2018,9 @@ static void SavePolywaypointThinker(const thinker_t *th, UINT8 type)
|
|||
WRITEINT32(save_p, ht->sequence);
|
||||
WRITEINT32(save_p, ht->pointnum);
|
||||
WRITEINT32(save_p, ht->direction);
|
||||
WRITEUINT8(save_p, ht->comeback);
|
||||
WRITEUINT8(save_p, ht->wrap);
|
||||
WRITEUINT8(save_p, ht->returnbehavior);
|
||||
WRITEUINT8(save_p, ht->continuous);
|
||||
WRITEUINT8(save_p, ht->stophere);
|
||||
WRITEFIXED(save_p, ht->diffx);
|
||||
WRITEFIXED(save_p, ht->diffy);
|
||||
WRITEFIXED(save_p, ht->diffz);
|
||||
WRITEUINT32(save_p, SaveMobjnum(ht->target));
|
||||
}
|
||||
|
||||
static void SavePolyslidedoorThinker(const thinker_t *th, const UINT8 type)
|
||||
|
@ -3157,14 +3152,9 @@ static inline thinker_t* LoadPolywaypointThinker(actionf_p1 thinker)
|
|||
ht->sequence = READINT32(save_p);
|
||||
ht->pointnum = READINT32(save_p);
|
||||
ht->direction = READINT32(save_p);
|
||||
ht->comeback = READUINT8(save_p);
|
||||
ht->wrap = READUINT8(save_p);
|
||||
ht->returnbehavior = READUINT8(save_p);
|
||||
ht->continuous = READUINT8(save_p);
|
||||
ht->stophere = READUINT8(save_p);
|
||||
ht->diffx = READFIXED(save_p);
|
||||
ht->diffy = READFIXED(save_p);
|
||||
ht->diffz = READFIXED(save_p);
|
||||
ht->target = LoadMobj(READUINT32(save_p));
|
||||
return &ht->thinker;
|
||||
}
|
||||
|
||||
|
@ -3411,7 +3401,6 @@ static void P_NetUnArchiveThinkers(void)
|
|||
|
||||
case tc_polywaypoint:
|
||||
th = LoadPolywaypointThinker((actionf_p1)T_PolyObjWaypoint);
|
||||
restoreNum = true;
|
||||
break;
|
||||
|
||||
case tc_polyslidedoor:
|
||||
|
@ -3471,7 +3460,6 @@ static void P_NetUnArchiveThinkers(void)
|
|||
if (restoreNum)
|
||||
{
|
||||
executor_t *delay = NULL;
|
||||
polywaypoint_t *polywp = NULL;
|
||||
UINT32 mobjnum;
|
||||
for (currentthinker = thlist[THINK_MAIN].next; currentthinker != &thlist[THINK_MAIN]; currentthinker = currentthinker->next)
|
||||
{
|
||||
|
@ -3482,15 +3470,6 @@ static void P_NetUnArchiveThinkers(void)
|
|||
continue;
|
||||
delay->caller = P_FindNewPosition(mobjnum);
|
||||
}
|
||||
for (currentthinker = thlist[THINK_POLYOBJ].next; currentthinker != &thlist[THINK_POLYOBJ]; currentthinker = currentthinker->next)
|
||||
{
|
||||
if (currentthinker->function.acp1 != (actionf_p1)T_PolyObjWaypoint)
|
||||
continue;
|
||||
polywp = (void *)currentthinker;
|
||||
if (!(mobjnum = (UINT32)(size_t)polywp->target))
|
||||
continue;
|
||||
polywp->target = P_FindNewPosition(mobjnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
129
src/p_setup.c
129
src/p_setup.c
|
@ -144,6 +144,133 @@ mapthing_t *playerstarts[MAXPLAYERS];
|
|||
mapthing_t *bluectfstarts[MAXPLAYERS];
|
||||
mapthing_t *redctfstarts[MAXPLAYERS];
|
||||
|
||||
// Maintain waypoints
|
||||
mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
|
||||
UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
|
||||
|
||||
void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint)
|
||||
{
|
||||
waypoints[sequence][id] = waypoint;
|
||||
if (id >= numwaypoints[sequence])
|
||||
numwaypoints[sequence] = id + 1;
|
||||
}
|
||||
|
||||
static void P_ResetWaypoints(void)
|
||||
{
|
||||
UINT16 sequence, id;
|
||||
for (sequence = 0; sequence < NUMWAYPOINTSEQUENCES; sequence++)
|
||||
{
|
||||
for (id = 0; id < numwaypoints[sequence]; id++)
|
||||
waypoints[sequence][id] = NULL;
|
||||
|
||||
numwaypoints[sequence] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
mobj_t *P_GetFirstWaypoint(UINT8 sequence)
|
||||
{
|
||||
return waypoints[sequence][0];
|
||||
}
|
||||
|
||||
mobj_t *P_GetLastWaypoint(UINT8 sequence)
|
||||
{
|
||||
return waypoints[sequence][numwaypoints[sequence] - 1];
|
||||
}
|
||||
|
||||
mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap)
|
||||
{
|
||||
UINT8 sequence = current->threshold;
|
||||
UINT8 id = current->health;
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
if (!wrap)
|
||||
return NULL;
|
||||
|
||||
id = numwaypoints[sequence] - 1;
|
||||
}
|
||||
else
|
||||
id--;
|
||||
|
||||
return waypoints[sequence][id];
|
||||
}
|
||||
|
||||
mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap)
|
||||
{
|
||||
UINT8 sequence = current->threshold;
|
||||
UINT8 id = current->health;
|
||||
|
||||
if (id == numwaypoints[sequence] - 1)
|
||||
{
|
||||
if (!wrap)
|
||||
return NULL;
|
||||
|
||||
id = 0;
|
||||
}
|
||||
else
|
||||
id++;
|
||||
|
||||
return waypoints[sequence][id];
|
||||
}
|
||||
|
||||
mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo)
|
||||
{
|
||||
UINT8 wp;
|
||||
mobj_t *mo2, *result = NULL;
|
||||
fixed_t bestdist = 0;
|
||||
fixed_t curdist;
|
||||
|
||||
for (wp = 0; wp < numwaypoints[sequence]; wp++)
|
||||
{
|
||||
mo2 = waypoints[sequence][wp];
|
||||
|
||||
if (!mo2)
|
||||
continue;
|
||||
|
||||
curdist = P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z);
|
||||
|
||||
if (result && curdist > bestdist)
|
||||
continue;
|
||||
|
||||
result = mo2;
|
||||
bestdist = curdist;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Return true if all waypoints are in the same location
|
||||
boolean P_IsDegeneratedWaypointSequence(UINT8 sequence)
|
||||
{
|
||||
mobj_t *first, *waypoint;
|
||||
UINT8 wp;
|
||||
|
||||
if (numwaypoints[sequence] <= 1)
|
||||
return true;
|
||||
|
||||
first = waypoints[sequence][0];
|
||||
|
||||
for (wp = 1; wp < numwaypoints[sequence]; wp++)
|
||||
{
|
||||
waypoint = waypoints[sequence][wp];
|
||||
|
||||
if (!waypoint)
|
||||
continue;
|
||||
|
||||
if (waypoint->x != first->x)
|
||||
return false;
|
||||
|
||||
if (waypoint->y != first->y)
|
||||
return false;
|
||||
|
||||
if (waypoint->z != first->z)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Logs an error about a map being corrupt, then terminate.
|
||||
* This allows reporting highly technical errors for usefulness, without
|
||||
* confusing a novice map designer who simply needs to run ZenNode.
|
||||
|
@ -3545,6 +3672,8 @@ boolean P_LoadLevel(boolean fromnetsave)
|
|||
|
||||
P_ResetSpawnpoints();
|
||||
|
||||
P_ResetWaypoints();
|
||||
|
||||
P_MapStart();
|
||||
|
||||
if (!P_LoadMapFromFile())
|
||||
|
|
159
src/p_spec.c
159
src/p_spec.c
|
@ -1276,10 +1276,21 @@ static boolean PolyWaypoint(line_t *line)
|
|||
pwd.polyObjNum = line->tag;
|
||||
pwd.speed = sides[line->sidenum[0]].textureoffset / 8;
|
||||
pwd.sequence = sides[line->sidenum[0]].rowoffset >> FRACBITS; // Sequence #
|
||||
pwd.reverse = (line->flags & ML_EFFECT1) == ML_EFFECT1; // Reverse?
|
||||
pwd.comeback = (line->flags & ML_EFFECT2) == ML_EFFECT2; // Return when reaching end?
|
||||
pwd.wrap = (line->flags & ML_EFFECT3) == ML_EFFECT3; // Wrap around waypoints
|
||||
pwd.continuous = (line->flags & ML_EFFECT4) == ML_EFFECT4; // Continuously move - used with COMEBACK or WRAP
|
||||
|
||||
// Behavior after reaching the last waypoint?
|
||||
if (line->flags & ML_EFFECT3)
|
||||
pwd.returnbehavior = PWR_WRAP; // Wrap back to first waypoint
|
||||
else if (line->flags & ML_EFFECT2)
|
||||
pwd.returnbehavior = PWR_COMEBACK; // Go through sequence in reverse
|
||||
else
|
||||
pwd.returnbehavior = PWR_STOP; // Stop
|
||||
|
||||
// Flags
|
||||
pwd.flags = 0;
|
||||
if (line->flags & ML_EFFECT1)
|
||||
pwd.flags |= PWF_REVERSE;
|
||||
if (line->flags & ML_EFFECT4)
|
||||
pwd.flags |= PWF_LOOP;
|
||||
|
||||
return EV_DoPolyObjWaypoint(&pwd);
|
||||
}
|
||||
|
@ -4799,9 +4810,7 @@ DoneSection2:
|
|||
INT32 sequence;
|
||||
fixed_t speed;
|
||||
INT32 lineindex;
|
||||
thinker_t *th;
|
||||
mobj_t *waypoint = NULL;
|
||||
mobj_t *mo2;
|
||||
angle_t an;
|
||||
|
||||
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE)
|
||||
|
@ -4826,25 +4835,7 @@ DoneSection2:
|
|||
break;
|
||||
}
|
||||
|
||||
// scan the thinkers
|
||||
// to find the first waypoint
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
if (mo2->health != 0)
|
||||
continue;
|
||||
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
waypoint = P_GetFirstWaypoint(sequence);
|
||||
|
||||
if (!waypoint)
|
||||
{
|
||||
|
@ -4881,9 +4872,7 @@ DoneSection2:
|
|||
INT32 sequence;
|
||||
fixed_t speed;
|
||||
INT32 lineindex;
|
||||
thinker_t *th;
|
||||
mobj_t *waypoint = NULL;
|
||||
mobj_t *mo2;
|
||||
angle_t an;
|
||||
|
||||
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE)
|
||||
|
@ -4908,25 +4897,7 @@ DoneSection2:
|
|||
break;
|
||||
}
|
||||
|
||||
// scan the thinkers
|
||||
// to find the last waypoint
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
|
||||
if (!waypoint)
|
||||
waypoint = mo2;
|
||||
else if (mo2->health > waypoint->health)
|
||||
waypoint = mo2;
|
||||
}
|
||||
waypoint = P_GetLastWaypoint(sequence);
|
||||
|
||||
if (!waypoint)
|
||||
{
|
||||
|
@ -5008,14 +4979,11 @@ DoneSection2:
|
|||
INT32 sequence;
|
||||
fixed_t speed;
|
||||
INT32 lineindex;
|
||||
thinker_t *th;
|
||||
mobj_t *waypointmid = NULL;
|
||||
mobj_t *waypointhigh = NULL;
|
||||
mobj_t *waypointlow = NULL;
|
||||
mobj_t *mo2;
|
||||
mobj_t *closest = NULL;
|
||||
vector3_t p, line[2], resulthigh, resultlow;
|
||||
mobj_t *highest = NULL;
|
||||
|
||||
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG)
|
||||
break;
|
||||
|
@ -5061,98 +5029,16 @@ DoneSection2:
|
|||
// Determine the closest spot on the line between the three waypoints
|
||||
// Put player at that location.
|
||||
|
||||
// scan the thinkers
|
||||
// to find the first waypoint
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
waypointmid = P_GetClosestWaypoint(sequence, player->mo);
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
|
||||
if (!highest)
|
||||
highest = mo2;
|
||||
else if (mo2->health > highest->health) // Find the highest waypoint # in case we wrap
|
||||
highest = mo2;
|
||||
|
||||
if (closest && P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y),
|
||||
player->mo->z-mo2->z) > P_AproxDistance(P_AproxDistance(player->mo->x-closest->x,
|
||||
player->mo->y-closest->y), player->mo->z-closest->z))
|
||||
continue;
|
||||
|
||||
// Found a target
|
||||
closest = mo2;
|
||||
}
|
||||
|
||||
waypointmid = closest;
|
||||
|
||||
closest = NULL;
|
||||
|
||||
if (waypointmid == NULL)
|
||||
if (!waypointmid)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "ERROR: WAYPOINT(S) IN SEQUENCE %d NOT FOUND.\n", sequence);
|
||||
break;
|
||||
}
|
||||
|
||||
// Find waypoint before this one (waypointlow)
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
|
||||
if (waypointmid->health == 0)
|
||||
{
|
||||
if (mo2->health != highest->health)
|
||||
continue;
|
||||
}
|
||||
else if (mo2->health != waypointmid->health - 1)
|
||||
continue;
|
||||
|
||||
// Found a target
|
||||
waypointlow = mo2;
|
||||
break;
|
||||
}
|
||||
|
||||
// Find waypoint after this one (waypointhigh)
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
|
||||
if (waypointmid->health == highest->health)
|
||||
{
|
||||
if (mo2->health != 0)
|
||||
continue;
|
||||
}
|
||||
else if (mo2->health != waypointmid->health + 1)
|
||||
continue;
|
||||
|
||||
// Found a target
|
||||
waypointhigh = mo2;
|
||||
break;
|
||||
}
|
||||
waypointlow = P_GetPreviousWaypoint(waypointmid, true);
|
||||
waypointhigh = P_GetNextWaypoint(waypointmid, true);
|
||||
|
||||
CONS_Debug(DBG_GAMELOGIC, "WaypointMid: %d; WaypointLow: %d; WaypointHigh: %d\n",
|
||||
waypointmid->health, waypointlow ? waypointlow->health : -1, waypointhigh ? waypointhigh->health : -1);
|
||||
|
@ -5199,6 +5085,7 @@ DoneSection2:
|
|||
|
||||
if (lines[lineindex].flags & ML_EFFECT1) // Don't wrap
|
||||
{
|
||||
mobj_t *highest = P_GetLastWaypoint(sequence);
|
||||
highest->flags |= MF_SLIDEME;
|
||||
}
|
||||
|
||||
|
@ -5210,7 +5097,7 @@ DoneSection2:
|
|||
player->mo->y = resulthigh.y;
|
||||
player->mo->z = resulthigh.z - P_GetPlayerHeight(player);
|
||||
}
|
||||
else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == highest->health)
|
||||
else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == numwaypoints[sequence] - 1)
|
||||
{
|
||||
closest = waypointmid;
|
||||
player->mo->x = resultlow.x;
|
||||
|
|
70
src/p_user.c
70
src/p_user.c
|
@ -8709,10 +8709,7 @@ static void P_MovePlayer(player_t *player)
|
|||
|
||||
static void P_DoZoomTube(player_t *player)
|
||||
{
|
||||
INT32 sequence;
|
||||
fixed_t speed;
|
||||
thinker_t *th;
|
||||
mobj_t *mo2;
|
||||
mobj_t *waypoint = NULL;
|
||||
fixed_t dist;
|
||||
boolean reverse;
|
||||
|
@ -8728,8 +8725,6 @@ static void P_DoZoomTube(player_t *player)
|
|||
|
||||
speed = abs(player->speed);
|
||||
|
||||
sequence = player->mo->tracer->threshold;
|
||||
|
||||
// change slope
|
||||
dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z);
|
||||
|
||||
|
@ -8761,28 +8756,7 @@ static void P_DoZoomTube(player_t *player)
|
|||
CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n");
|
||||
|
||||
// Find next waypoint
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
|
||||
if (reverse && mo2->health != player->mo->tracer->health - 1)
|
||||
continue;
|
||||
|
||||
if (!reverse && mo2->health != player->mo->tracer->health + 1)
|
||||
continue;
|
||||
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
waypoint = reverse ? P_GetPreviousWaypoint(player->mo->tracer, false) : P_GetNextWaypoint(player->mo->tracer, false);
|
||||
|
||||
if (waypoint)
|
||||
{
|
||||
|
@ -8833,8 +8807,6 @@ static void P_DoRopeHang(player_t *player)
|
|||
{
|
||||
INT32 sequence;
|
||||
fixed_t speed;
|
||||
thinker_t *th;
|
||||
mobj_t *mo2;
|
||||
mobj_t *waypoint = NULL;
|
||||
fixed_t dist;
|
||||
fixed_t playerz;
|
||||
|
@ -8897,50 +8869,14 @@ static void P_DoRopeHang(player_t *player)
|
|||
CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n");
|
||||
|
||||
// Find next waypoint
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
|
||||
if (mo2->health != player->mo->tracer->health + 1)
|
||||
continue;
|
||||
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
waypoint = P_GetNextWaypoint(player->mo->tracer, false);
|
||||
|
||||
if (!(player->mo->tracer->flags & MF_SLIDEME) && !waypoint)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found, wrapping to start...\n");
|
||||
|
||||
// Wrap around back to first waypoint
|
||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
||||
{
|
||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
|
||||
if (mo2->type != MT_TUBEWAYPOINT)
|
||||
continue;
|
||||
|
||||
if (mo2->threshold != sequence)
|
||||
continue;
|
||||
|
||||
if (mo2->health != 0)
|
||||
continue;
|
||||
|
||||
waypoint = mo2;
|
||||
break;
|
||||
}
|
||||
waypoint = P_GetFirstWaypoint(sequence);
|
||||
}
|
||||
|
||||
if (waypoint)
|
||||
|
|
|
@ -1346,7 +1346,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
{
|
||||
mobj_t *oldthing = thing;
|
||||
fixed_t tr_x, tr_y;
|
||||
fixed_t gxt, gyt;
|
||||
fixed_t tx, tz;
|
||||
fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!!
|
||||
|
||||
|
@ -1359,7 +1358,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
#endif
|
||||
size_t lump;
|
||||
|
||||
size_t rot;
|
||||
size_t frame, rot;
|
||||
UINT16 flip;
|
||||
boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP));
|
||||
|
||||
|
@ -1399,21 +1398,16 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
tr_x = thing->x - viewx;
|
||||
tr_y = thing->y - viewy;
|
||||
|
||||
gxt = FixedMul(tr_x, viewcos);
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
|
||||
tz = gxt-gyt;
|
||||
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance
|
||||
|
||||
// thing is behind view plane?
|
||||
if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later
|
||||
return;
|
||||
|
||||
gxt = -FixedMul(tr_x, viewsin);
|
||||
gyt = FixedMul(tr_y, viewcos);
|
||||
basetx = tx = -(gyt + gxt);
|
||||
basetx = tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance
|
||||
|
||||
// too far off the side?
|
||||
if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later
|
||||
if (!papersprite && abs(tx) > FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later
|
||||
return;
|
||||
|
||||
// aspect ratio stuff
|
||||
|
@ -1426,7 +1420,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
I_Error("R_ProjectSprite: invalid sprite number %d ", thing->sprite);
|
||||
#endif
|
||||
|
||||
rot = thing->frame&FF_FRAMEMASK;
|
||||
frame = thing->frame&FF_FRAMEMASK;
|
||||
|
||||
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
|
||||
if (thing->skin && thing->sprite == SPR_PLAY)
|
||||
|
@ -1435,15 +1429,15 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
#ifdef ROTSPRITE
|
||||
sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2];
|
||||
#endif
|
||||
if (rot >= sprdef->numframes) {
|
||||
CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid skins[\"%s\"].sprites[%sSPR2_%s] frame %s\n"), ((skin_t *)thing->skin)->name, ((thing->sprite2 & FF_SPR2SUPER) ? "FF_SPR2SUPER|": ""), spr2names[(thing->sprite2 & ~FF_SPR2SUPER)], sizeu5(rot));
|
||||
if (frame >= sprdef->numframes) {
|
||||
CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid skins[\"%s\"].sprites[%sSPR2_%s] frame %s\n"), ((skin_t *)thing->skin)->name, ((thing->sprite2 & FF_SPR2SUPER) ? "FF_SPR2SUPER|": ""), spr2names[(thing->sprite2 & ~FF_SPR2SUPER)], sizeu5(frame));
|
||||
thing->sprite = states[S_UNKNOWN].sprite;
|
||||
thing->frame = states[S_UNKNOWN].frame;
|
||||
sprdef = &sprites[thing->sprite];
|
||||
#ifdef ROTSPRITE
|
||||
sprinfo = NULL;
|
||||
#endif
|
||||
rot = thing->frame&FF_FRAMEMASK;
|
||||
frame = thing->frame&FF_FRAMEMASK;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1453,10 +1447,10 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
sprinfo = NULL;
|
||||
#endif
|
||||
|
||||
if (rot >= sprdef->numframes)
|
||||
if (frame >= sprdef->numframes)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid sprite frame %s/%s for %s\n"),
|
||||
sizeu1(rot), sizeu2(sprdef->numframes), sprnames[thing->sprite]);
|
||||
sizeu1(frame), sizeu2(sprdef->numframes), sprnames[thing->sprite]);
|
||||
if (thing->sprite == thing->state->sprite && thing->frame == thing->state->frame)
|
||||
{
|
||||
thing->state->sprite = states[S_UNKNOWN].sprite;
|
||||
|
@ -1465,11 +1459,11 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
thing->sprite = states[S_UNKNOWN].sprite;
|
||||
thing->frame = states[S_UNKNOWN].frame;
|
||||
sprdef = &sprites[thing->sprite];
|
||||
rot = thing->frame&FF_FRAMEMASK;
|
||||
frame = thing->frame&FF_FRAMEMASK;
|
||||
}
|
||||
}
|
||||
|
||||
sprframe = &sprdef->spriteframes[rot];
|
||||
sprframe = &sprdef->spriteframes[frame];
|
||||
|
||||
#ifdef PARANOIA
|
||||
if (!sprframe)
|
||||
|
@ -1523,7 +1517,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
{
|
||||
rollangle = R_GetRollAngle(thing->rollangle);
|
||||
if (!(sprframe->rotsprite.cached & (1<<rot)))
|
||||
R_CacheRotSprite(thing->sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip);
|
||||
R_CacheRotSprite(thing->sprite, frame, sprinfo, sprframe, rot, flip);
|
||||
rotsprite = sprframe->rotsprite.patch[rot][rollangle];
|
||||
if (rotsprite != NULL)
|
||||
{
|
||||
|
@ -1561,17 +1555,9 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
|
||||
tr_x += FixedMul(offset, cosmul);
|
||||
tr_y += FixedMul(offset, sinmul);
|
||||
gxt = FixedMul(tr_x, viewcos);
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
tz = gxt-gyt;
|
||||
yscale = FixedDiv(projectiony, tz);
|
||||
//if (yscale < 64) return; // Fix some funky visuals
|
||||
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
|
||||
|
||||
gxt = -FixedMul(tr_x, viewsin);
|
||||
gyt = FixedMul(tr_y, viewcos);
|
||||
tx = -(gyt + gxt);
|
||||
xscale = FixedDiv(projection, tz);
|
||||
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
||||
tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
|
||||
|
||||
// Get paperoffset (offset) and paperoffset (distance)
|
||||
paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul);
|
||||
|
@ -1585,17 +1571,9 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
|
||||
tr_x += FixedMul(offset2, cosmul);
|
||||
tr_y += FixedMul(offset2, sinmul);
|
||||
gxt = FixedMul(tr_x, viewcos);
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
tz2 = gxt-gyt;
|
||||
yscale2 = FixedDiv(projectiony, tz2);
|
||||
//if (yscale2 < 64) return; // ditto
|
||||
tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
|
||||
|
||||
gxt = -FixedMul(tr_x, viewsin);
|
||||
gyt = FixedMul(tr_y, viewcos);
|
||||
tx2 = -(gyt + gxt);
|
||||
xscale2 = FixedDiv(projection, tz2);
|
||||
x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS);
|
||||
tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos);
|
||||
|
||||
if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier
|
||||
return;
|
||||
|
@ -1606,24 +1584,31 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz);
|
||||
tx += FixedDiv(tx2-tx, div);
|
||||
tz = FixedMul(MINZ, this_scale);
|
||||
yscale = FixedDiv(projectiony, tz);
|
||||
xscale = FixedDiv(projection, tz);
|
||||
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
||||
}
|
||||
else if (tz2 < FixedMul(MINZ, this_scale))
|
||||
{
|
||||
fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2);
|
||||
tx2 += FixedDiv(tx-tx2, div);
|
||||
tz2 = FixedMul(MINZ, this_scale);
|
||||
yscale2 = FixedDiv(projectiony, tz2);
|
||||
xscale2 = FixedDiv(projection, tz2);
|
||||
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
|
||||
}
|
||||
|
||||
if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side?
|
||||
return;
|
||||
|
||||
yscale = FixedDiv(projectiony, tz);
|
||||
xscale = FixedDiv(projection, tz);
|
||||
|
||||
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
|
||||
|
||||
// off the right side?
|
||||
if (x1 > viewwidth)
|
||||
return;
|
||||
|
||||
yscale2 = FixedDiv(projectiony, tz2);
|
||||
xscale2 = FixedDiv(projection, tz2);
|
||||
|
||||
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
|
||||
|
||||
// off the left side
|
||||
if (x2 < 0)
|
||||
return;
|
||||
|
@ -1670,9 +1655,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
|
||||
tr_x = thing->x - viewx;
|
||||
tr_y = thing->y - viewy;
|
||||
gxt = FixedMul(tr_x, viewcos);
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
tz = gxt-gyt;
|
||||
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
|
||||
linkscale = FixedDiv(projectiony, tz);
|
||||
|
||||
if (tz < FixedMul(MINZ, this_scale))
|
||||
|
@ -1872,7 +1855,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
{
|
||||
fixed_t tr_x, tr_y;
|
||||
fixed_t gxt, gyt;
|
||||
fixed_t tx, tz;
|
||||
fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!!
|
||||
|
||||
|
@ -1893,21 +1875,16 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
|||
tr_x = thing->x - viewx;
|
||||
tr_y = thing->y - viewy;
|
||||
|
||||
gxt = FixedMul(tr_x, viewcos);
|
||||
gyt = -FixedMul(tr_y, viewsin);
|
||||
|
||||
tz = gxt - gyt;
|
||||
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance
|
||||
|
||||
// thing is behind view plane?
|
||||
if (tz < MINZ)
|
||||
return;
|
||||
|
||||
gxt = -FixedMul(tr_x, viewsin);
|
||||
gyt = FixedMul(tr_y, viewcos);
|
||||
tx = -(gyt + gxt);
|
||||
tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance
|
||||
|
||||
// too far off the side?
|
||||
if (abs(tx) > tz<<2)
|
||||
if (abs(tx) > FixedMul(tz, fovtan)<<2)
|
||||
return;
|
||||
|
||||
// aspect ratio stuff :
|
||||
|
|
Loading…
Reference in a new issue