2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#define QUIET
|
|
|
|
#include "build.h"
|
2020-09-06 10:44:58 +00:00
|
|
|
#include "automap.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "pragmas.h"
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "game.h"
|
|
|
|
|
|
|
|
#include "jsector.h"
|
|
|
|
|
|
|
|
#include "mytypes.h"
|
2019-10-25 22:32:49 +00:00
|
|
|
#include "gamecontrol.h"
|
2019-03-21 02:24:19 +00:00
|
|
|
#include "network.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "pal.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "jtags.h"
|
|
|
|
#include "parent.h"
|
|
|
|
|
2020-08-05 15:07:19 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
#include "interp.h"
|
2020-05-01 11:29:12 +00:00
|
|
|
#include "interpso.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "sector.h"
|
2020-06-14 16:57:55 +00:00
|
|
|
#include "menu.h"
|
2019-12-31 18:25:49 +00:00
|
|
|
#include "v_2ddrawer.h"
|
2020-01-12 19:28:07 +00:00
|
|
|
#include "v_video.h"
|
2020-05-30 22:01:00 +00:00
|
|
|
#include "glbackend/glbackend.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
static int OverlapDraw = false;
|
2020-09-09 18:32:24 +00:00
|
|
|
extern bool QuitFlag, SpriteInfo;
|
|
|
|
extern bool Voxel;
|
2015-05-19 21:54:34 +00:00
|
|
|
extern char buffer[];
|
2020-09-09 18:32:24 +00:00
|
|
|
bool DrawScreen;
|
2015-05-19 21:54:34 +00:00
|
|
|
extern short f_c;
|
|
|
|
|
|
|
|
extern ParentalStruct aVoxelArray[MAXTILES];
|
|
|
|
|
2017-01-23 11:21:08 +00:00
|
|
|
int ConnectCopySprite(uspritetype const * tsp);
|
2015-05-19 21:54:34 +00:00
|
|
|
void PreDrawStackedWater(void);
|
|
|
|
|
2020-08-16 16:18:56 +00:00
|
|
|
void SW_InitMultiPsky(void)
|
|
|
|
{
|
|
|
|
// default
|
|
|
|
psky_t* const defaultsky = tileSetupSky(DEFAULTPSKY);
|
|
|
|
defaultsky->lognumtiles = 1;
|
|
|
|
defaultsky->horizfrac = 8192;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#if 1
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
2019-12-26 06:27:48 +00:00
|
|
|
ShadeSprite(tspriteptr_t tsp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// set shade of sprite
|
|
|
|
tsp->shade = sector[tsp->sectnum].floorshade - 25;
|
|
|
|
|
|
|
|
if (tsp->shade > -3)
|
|
|
|
tsp->shade = -3;
|
|
|
|
|
|
|
|
if (tsp->shade < -30)
|
|
|
|
tsp->shade = -30;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
short
|
|
|
|
GetRotation(short tSpriteNum, int viewx, int viewy)
|
|
|
|
{
|
|
|
|
static short RotTable8[] = {0, 7, 6, 5, 4, 3, 2, 1};
|
|
|
|
static short RotTable5[] = {0, 1, 2, 3, 4, 3, 2, 1};
|
|
|
|
short rotation;
|
|
|
|
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t tsp = &tsprite[tSpriteNum];
|
2015-05-19 21:54:34 +00:00
|
|
|
USERp tu = User[tsp->owner];
|
|
|
|
short angle2;
|
|
|
|
|
|
|
|
if (tu->RotNum == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Get which of the 8 angles of the sprite to draw (0-7)
|
|
|
|
// rotation ranges from 0-7
|
|
|
|
angle2 = getangle(tsp->x - viewx, tsp->y - viewy);
|
|
|
|
rotation = ((tsp->ang + 3072 + 128 - angle2) & 2047);
|
|
|
|
rotation = (rotation >> 8) & 7;
|
|
|
|
|
|
|
|
if (tu->RotNum == 5)
|
|
|
|
{
|
|
|
|
if (TEST(tu->Flags, SPR_XFLIP_TOGGLE))
|
|
|
|
{
|
|
|
|
if (rotation <= 4)
|
|
|
|
{
|
|
|
|
// leave rotation alone
|
|
|
|
RESET(tsp->cstat, CSTAT_SPRITE_XFLIP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rotation = (8 - rotation);
|
|
|
|
SET(tsp->cstat, CSTAT_SPRITE_XFLIP); // clear x-flipping bit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (rotation > 3 || rotation == 0)
|
|
|
|
{
|
|
|
|
// leave rotation alone
|
|
|
|
RESET(tsp->cstat, CSTAT_SPRITE_XFLIP); // clear x-flipping bit
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rotation = (8 - rotation);
|
|
|
|
SET(tsp->cstat, CSTAT_SPRITE_XFLIP); // set
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special case bunk
|
|
|
|
if (tu->ID == TOILETGIRL_R0 || tu->ID == WASHGIRL_R0 || tu->ID == TRASHCAN ||
|
|
|
|
tu->ID == CARGIRL_R0 || tu->ID == MECHANICGIRL_R0 || tu->ID == PRUNEGIRL_R0 ||
|
|
|
|
tu->ID == SAILORGIRL_R0)
|
|
|
|
RESET(tsp->cstat, CSTAT_SPRITE_XFLIP); // clear x-flipping bit
|
|
|
|
|
|
|
|
return RotTable5[rotation];
|
|
|
|
}
|
|
|
|
|
|
|
|
return RotTable8[rotation];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
!AIC - At draw time this is called for actor rotation. GetRotation() is more
|
|
|
|
complex than needs to be in part because importing of actor rotations and x-flip
|
|
|
|
directions was not standardized.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
SetActorRotation(short tSpriteNum, int viewx, int viewy)
|
|
|
|
{
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t tsp = &tsprite[tSpriteNum];
|
2015-05-19 21:54:34 +00:00
|
|
|
USERp tu = User[tsp->owner];
|
|
|
|
short StateOffset, Rotation;
|
|
|
|
|
|
|
|
// don't modify ANY tu vars - back them up!
|
|
|
|
STATEp State = tu->State;
|
|
|
|
STATEp StateStart = tu->StateStart;
|
|
|
|
|
|
|
|
if (tu->RotNum == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Get the offset into the State animation
|
|
|
|
StateOffset = State - StateStart;
|
|
|
|
|
|
|
|
// Get the rotation angle
|
|
|
|
Rotation = GetRotation(tSpriteNum, viewx, viewy);
|
|
|
|
|
|
|
|
ASSERT(Rotation < 5);
|
|
|
|
|
|
|
|
// Reset the State animation start based on the Rotation
|
|
|
|
StateStart = tu->Rot[Rotation];
|
|
|
|
|
|
|
|
// Set the sprites state
|
|
|
|
State = StateStart + StateOffset;
|
|
|
|
|
|
|
|
// set the picnum here - may be redundant, but we just changed states and
|
|
|
|
// thats a big deal
|
|
|
|
tsp->picnum = State->Pic;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2019-12-26 06:27:48 +00:00
|
|
|
DoShadowFindGroundPoint(tspriteptr_t sp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// USES TSPRITE !!!!!
|
|
|
|
USERp u = User[sp->owner];
|
|
|
|
SPRITEp hsp;
|
|
|
|
int ceilhit, florhit;
|
|
|
|
int hiz, loz = u->loz;
|
|
|
|
short save_cstat, bak_cstat;
|
|
|
|
|
|
|
|
// recursive routine to find the ground - either sector or floor sprite
|
|
|
|
// skips over enemy and other types of sprites
|
|
|
|
|
|
|
|
// IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
// This will return invalid FAF ceiling and floor heights inside of analyzesprite
|
|
|
|
// because the ceiling and floors get moved out of the way for drawing.
|
|
|
|
|
|
|
|
save_cstat = sp->cstat;
|
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
|
|
|
FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sectnum, &hiz, &ceilhit, &loz, &florhit);
|
|
|
|
sp->cstat = save_cstat;
|
|
|
|
|
|
|
|
ASSERT(TEST(florhit, HIT_SPRITE | HIT_SECTOR));
|
|
|
|
|
|
|
|
switch (TEST(florhit, HIT_MASK))
|
|
|
|
{
|
|
|
|
case HIT_SPRITE:
|
|
|
|
{
|
|
|
|
hsp = &sprite[NORM_SPRITE(florhit)];
|
|
|
|
|
2018-02-16 06:38:31 +00:00
|
|
|
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// found a sprite floor
|
|
|
|
return loz;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// reset the blocking bit of what you hit and try again -
|
|
|
|
// recursive
|
|
|
|
bak_cstat = hsp->cstat;
|
|
|
|
RESET(hsp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
|
|
|
|
loz = DoShadowFindGroundPoint(sp);
|
|
|
|
hsp->cstat = bak_cstat;
|
|
|
|
}
|
2019-04-08 06:28:26 +00:00
|
|
|
break;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case HIT_SECTOR:
|
2019-04-08 06:28:26 +00:00
|
|
|
break;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
default:
|
2020-09-09 17:52:52 +00:00
|
|
|
ASSERT(true == false);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return loz;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
2020-09-09 18:32:24 +00:00
|
|
|
DoShadows(tspriteptr_t tsp, int viewz, bool mirror)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t New = &tsprite[spritesortcnt];
|
2015-05-19 21:54:34 +00:00
|
|
|
USERp tu = User[tsp->owner];
|
|
|
|
int ground_dist = 0;
|
|
|
|
int view_dist = 0;
|
|
|
|
int loz;
|
|
|
|
short xrepeat;
|
|
|
|
short yrepeat;
|
|
|
|
short sectnum;
|
|
|
|
|
|
|
|
sectnum = tsp->sectnum;
|
|
|
|
// make sure its the correct sector
|
|
|
|
// DoShadowFindGroundPoint calls FAFgetzrangepoint and this is sensitive
|
|
|
|
//updatesectorz(tsp->x, tsp->y, tsp->z, §num);
|
|
|
|
updatesector(tsp->x, tsp->y, §num);
|
|
|
|
|
|
|
|
if (sectnum < 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tsp->sectnum = sectnum;
|
2019-12-26 06:27:48 +00:00
|
|
|
*New = *tsp;
|
2015-05-19 21:54:34 +00:00
|
|
|
// shadow is ALWAYS draw last - status is priority
|
2017-01-23 11:21:32 +00:00
|
|
|
New->statnum = MAXSTATUS;
|
|
|
|
New->sectnum = sectnum;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if ((tsp->yrepeat >> 2) > 4)
|
|
|
|
{
|
|
|
|
yrepeat = (tsp->yrepeat >> 2) - (SPRITEp_SIZE_Y(tsp) / 64) * 2;
|
2017-01-23 11:21:32 +00:00
|
|
|
xrepeat = New->xrepeat;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-23 11:21:32 +00:00
|
|
|
yrepeat = New->yrepeat;
|
|
|
|
xrepeat = New->xrepeat;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New->shade = 127;
|
|
|
|
SET(New->cstat, CSTAT_SPRITE_TRANSLUCENT);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
loz = tu->loz;
|
|
|
|
if (tu->lo_sp)
|
|
|
|
{
|
2018-02-16 06:38:31 +00:00
|
|
|
if (!TEST(tu->lo_sp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_ALIGNMENT_FLOOR))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
loz = DoShadowFindGroundPoint(tsp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// need to find the ground here
|
2017-01-23 11:21:32 +00:00
|
|
|
New->z = loz;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// if below or close to sprites z don't bother to draw it
|
|
|
|
if ((viewz - loz) > -Z(8))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// if close to shadows z shrink it
|
|
|
|
view_dist = labs(loz - viewz) >> 8;
|
|
|
|
if (view_dist < 32)
|
|
|
|
view_dist = 256/view_dist;
|
|
|
|
else
|
|
|
|
view_dist = 0;
|
|
|
|
|
|
|
|
// make shadow smaller depending on height from ground
|
|
|
|
ground_dist = labs(loz - SPRITEp_BOS(tsp)) >> 8;
|
|
|
|
ground_dist = DIV16(ground_dist);
|
|
|
|
|
|
|
|
xrepeat = max(xrepeat - ground_dist - view_dist, 4);
|
|
|
|
yrepeat = max(yrepeat - ground_dist - view_dist, 4);
|
2019-04-08 06:25:42 +00:00
|
|
|
xrepeat = min(xrepeat, short(255));
|
|
|
|
yrepeat = min(yrepeat, short(255));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New->xrepeat = xrepeat;
|
|
|
|
New->yrepeat = yrepeat;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-12 22:45:50 +00:00
|
|
|
if (tilehasmodelorvoxel(tsp->picnum,tsp->pal))
|
2020-04-19 18:15:57 +00:00
|
|
|
{
|
2020-08-12 22:45:50 +00:00
|
|
|
New->yrepeat = 0;
|
|
|
|
// cstat: trans reverse
|
|
|
|
// clipdist: tell mdsprite.cpp to use Z-buffer hacks to hide overdraw issues
|
|
|
|
New->clipdist |= TSPR_FLAGS_MDHACK;
|
|
|
|
New->cstat |= 512;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int const camang = mirror ? NORM_ANGLE(2048 - Player[screenpeek].siang) : Player[screenpeek].siang;
|
|
|
|
vec2_t const ofs = { sintable[NORM_ANGLE(camang+512)]>>11, sintable[NORM_ANGLE(camang)]>>11};
|
2020-04-19 18:15:57 +00:00
|
|
|
|
2020-08-12 22:45:50 +00:00
|
|
|
New->x += ofs.x;
|
|
|
|
New->y += ofs.y;
|
2020-04-19 18:15:57 +00:00
|
|
|
}
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// Check for voxel items and use a round generic pic if so
|
2017-01-23 11:21:32 +00:00
|
|
|
//DoVoxelShadow(New);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
spritesortcnt++;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
2019-12-26 06:27:48 +00:00
|
|
|
DoMotionBlur(tspritetype const * const tsp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
USERp tu = User[tsp->owner];
|
|
|
|
int nx,ny,nz = 0,dx,dy,dz;
|
|
|
|
short i, ang;
|
|
|
|
short xrepeat, yrepeat, repeat_adj = 0;
|
|
|
|
int z_amt_per_pixel;
|
|
|
|
|
|
|
|
ang = NORM_ANGLE(tsp->ang + 1024);
|
|
|
|
|
|
|
|
if (tsp->xvel == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY))
|
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
z_amt_per_pixel = IntToFixed((int)-tu->jump_speed * ACTORMOVETICS)/tsp->xvel;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-01 13:00:35 +00:00
|
|
|
z_amt_per_pixel = IntToFixed((int)-tsp->zvel)/tsp->xvel;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (tu->motion_blur_dist)
|
|
|
|
{
|
|
|
|
case 64:
|
|
|
|
dx = nx = MOVEx(64, ang);
|
|
|
|
dy = ny = MOVEy(64, ang);
|
2020-09-01 13:00:35 +00:00
|
|
|
nz = FixedToInt(z_amt_per_pixel * 64);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
case 128:
|
|
|
|
dx = nx = MOVEx(128, ang);
|
|
|
|
dy = ny = MOVEy(128, ang);
|
2020-09-01 13:00:35 +00:00
|
|
|
nz = FixedToInt(z_amt_per_pixel * 128);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
case 256:
|
|
|
|
dx = nx = MOVEx(256, ang);
|
|
|
|
dy = ny = MOVEy(256, ang);
|
2020-09-01 13:00:35 +00:00
|
|
|
nz = FixedToInt(z_amt_per_pixel * 256);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
case 512:
|
|
|
|
dx = nx = MOVEx(512, ang);
|
|
|
|
dy = ny = MOVEy(512, ang);
|
2020-09-01 13:00:35 +00:00
|
|
|
nz = FixedToInt(z_amt_per_pixel * 512);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dx = nx = MOVEx(tu->motion_blur_dist, ang);
|
|
|
|
dy = ny = MOVEy(tu->motion_blur_dist, ang);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dz = nz;
|
|
|
|
|
|
|
|
xrepeat = tsp->xrepeat;
|
|
|
|
yrepeat = tsp->yrepeat;
|
|
|
|
|
|
|
|
switch (TEST(tu->Flags2, SPR2_BLUR_TAPER))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
repeat_adj = 0;
|
|
|
|
break;
|
|
|
|
case SPR2_BLUR_TAPER_SLOW:
|
|
|
|
repeat_adj = xrepeat / (tu->motion_blur_num*2);
|
|
|
|
break;
|
|
|
|
case SPR2_BLUR_TAPER_FAST:
|
|
|
|
repeat_adj = xrepeat / tu->motion_blur_num;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < tu->motion_blur_num; i++)
|
|
|
|
{
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t New = &tsprite[spritesortcnt];
|
|
|
|
*New = *tsp;
|
2018-02-16 06:38:31 +00:00
|
|
|
SET(New->cstat, CSTAT_SPRITE_TRANSLUCENT|CSTAT_SPRITE_TRANSLUCENT_INVERT);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New->x += dx;
|
|
|
|
New->y += dy;
|
2015-05-19 21:54:34 +00:00
|
|
|
dx += nx;
|
|
|
|
dy += ny;
|
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New->z += dz;
|
2015-05-19 21:54:34 +00:00
|
|
|
dz += nz;
|
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New->xrepeat = xrepeat;
|
|
|
|
New->yrepeat = yrepeat;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
xrepeat -= repeat_adj;
|
|
|
|
yrepeat -= repeat_adj;
|
|
|
|
|
|
|
|
spritesortcnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void SetVoxelSprite(SPRITEp sp, short pic)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2018-02-16 06:38:31 +00:00
|
|
|
SET(sp->cstat, CSTAT_SPRITE_ALIGNMENT_SLAB);
|
2015-05-19 21:54:34 +00:00
|
|
|
sp->picnum = pic;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void WarpCopySprite(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2017-01-23 11:21:08 +00:00
|
|
|
SPRITEp sp1, sp2, sp;
|
2015-05-19 21:54:34 +00:00
|
|
|
short sn, nsn;
|
|
|
|
short sn2, nsn2;
|
|
|
|
short spnum, next_spnum;
|
|
|
|
int xoff,yoff,zoff;
|
|
|
|
short match;
|
|
|
|
short sect1, sect2;
|
|
|
|
|
|
|
|
// look for the first one
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_WARP_COPY_SPRITE1], sn, nsn)
|
|
|
|
{
|
|
|
|
sp1 = &sprite[sn];
|
|
|
|
match = sp1->lotag;
|
|
|
|
|
|
|
|
// look for the second one
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_WARP_COPY_SPRITE2], sn2, nsn2)
|
|
|
|
{
|
|
|
|
sp = &sprite[sn2];
|
|
|
|
|
|
|
|
if (sp->lotag == match)
|
|
|
|
{
|
|
|
|
sp2 = sp;
|
|
|
|
sect1 = sp1->sectnum;
|
|
|
|
sect2 = sp2->sectnum;
|
|
|
|
|
|
|
|
TRAVERSE_SPRITE_SECT(headspritesect[sect1], spnum, next_spnum)
|
|
|
|
{
|
|
|
|
if (&sprite[spnum] == sp1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sprite[spnum].picnum == ST1)
|
|
|
|
continue;
|
|
|
|
|
2019-12-26 06:27:58 +00:00
|
|
|
tspriteptr_t New = renderAddTSpriteFromSprite(spnum);
|
2017-01-23 11:21:32 +00:00
|
|
|
New->statnum = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
xoff = sp1->x - New->x;
|
|
|
|
yoff = sp1->y - New->y;
|
|
|
|
zoff = sp1->z - New->z;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New->x = sp2->x - xoff;
|
|
|
|
New->y = sp2->y - yoff;
|
|
|
|
New->z = sp2->z - zoff;
|
|
|
|
New->sectnum = sp2->sectnum;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TRAVERSE_SPRITE_SECT(headspritesect[sect2], spnum, next_spnum)
|
|
|
|
{
|
|
|
|
if (&sprite[spnum] == sp2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sprite[spnum].picnum == ST1)
|
|
|
|
continue;
|
|
|
|
|
2019-12-26 06:27:58 +00:00
|
|
|
tspriteptr_t New = renderAddTSpriteFromSprite(spnum);
|
2017-01-23 11:21:32 +00:00
|
|
|
New->statnum = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
xoff = sp2->x - New->x;
|
|
|
|
yoff = sp2->y - New->y;
|
|
|
|
zoff = sp2->z - New->z;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New->x = sp1->x - xoff;
|
|
|
|
New->y = sp1->y - yoff;
|
|
|
|
New->z = sp1->z - zoff;
|
|
|
|
New->sectnum = sp1->sectnum;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-26 06:27:48 +00:00
|
|
|
void DoStarView(tspriteptr_t tsp, USERp tu, int viewz)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
extern STATE s_Star[], s_StarDown[];
|
|
|
|
extern STATE s_StarStuck[], s_StarDownStuck[];
|
|
|
|
int zdiff = viewz - tsp->z;
|
|
|
|
|
|
|
|
if (labs(zdiff) > Z(24))
|
|
|
|
{
|
|
|
|
if (tu->StateStart == s_StarStuck)
|
|
|
|
tsp->picnum = s_StarDownStuck[tu->State - s_StarStuck].Pic;
|
|
|
|
else
|
|
|
|
tsp->picnum = s_StarDown[tu->State - s_Star].Pic;
|
|
|
|
|
|
|
|
if (zdiff > 0)
|
|
|
|
SET(tsp->cstat, CSTAT_SPRITE_YFLIP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (zdiff > 0)
|
|
|
|
SET(tsp->cstat, CSTAT_SPRITE_YFLIP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
2020-09-09 18:32:24 +00:00
|
|
|
analyzesprites(int viewx, int viewy, int viewz, bool mirror)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-03-06 15:49:49 +00:00
|
|
|
int tSpriteNum;
|
|
|
|
short SpriteNum;
|
2015-05-19 21:54:34 +00:00
|
|
|
int smr4, smr2;
|
|
|
|
USERp tu;
|
|
|
|
static int ang = 0;
|
|
|
|
PLAYERp pp = Player + screenpeek;
|
|
|
|
short newshade=0;
|
|
|
|
|
2020-08-16 07:04:24 +00:00
|
|
|
const int DART_PIC = 2526;
|
|
|
|
const int DART_REPEAT = 16;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ang = NORM_ANGLE(ang + 12);
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
smr4 = smoothratio + IntToFixed(MoveSkip4);
|
|
|
|
smr2 = smoothratio + IntToFixed(MoveSkip2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
|
|
|
|
{
|
|
|
|
SpriteNum = tsprite[tSpriteNum].owner;
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t tsp = &tsprite[tSpriteNum];
|
2015-05-19 21:54:34 +00:00
|
|
|
tu = User[SpriteNum];
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Brighten up the sprite if set somewhere else to do so
|
|
|
|
if (tu && tu->Vis > 0)
|
|
|
|
{
|
|
|
|
short tmpshade; // Having this prevent overflow
|
|
|
|
|
|
|
|
tmpshade = tsp->shade - tu->Vis;
|
|
|
|
if (tmpshade < -128) tmpshade = -128;
|
|
|
|
|
|
|
|
tsp->shade = tmpshade;
|
|
|
|
tu->Vis -= 8;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// don't draw these
|
|
|
|
if (tsp->statnum >= STAT_DONT_DRAW)
|
|
|
|
{
|
|
|
|
tsp->owner = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Diss any parentally locked sprites
|
2020-08-16 09:42:13 +00:00
|
|
|
if (adult_lockout)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (aVoxelArray[tsp->picnum].Parental == 6145)
|
|
|
|
{
|
|
|
|
tsp->owner = -1;
|
|
|
|
tu = NULL;
|
|
|
|
}
|
|
|
|
else if (aVoxelArray[tsp->picnum].Parental > 0)
|
|
|
|
{
|
|
|
|
ASSERT(aVoxelArray[tsp->picnum].Parental >= 0 && aVoxelArray[tsp->picnum].Parental < 6145);
|
|
|
|
tsp->picnum=aVoxelArray[tsp->picnum].Parental; // Change the pic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tu)
|
|
|
|
{
|
|
|
|
if (tsp->statnum != STAT_DEFAULT)
|
|
|
|
{
|
|
|
|
if (TEST(tu->Flags, SPR_SKIP4))
|
|
|
|
{
|
|
|
|
if (tsp->statnum <= STAT_SKIP4_INTERP_END)
|
|
|
|
{
|
2017-06-24 09:20:21 +00:00
|
|
|
tsp->x = tu->ox + mulscale18(tsp->x - tu->ox, smr4);
|
|
|
|
tsp->y = tu->oy + mulscale18(tsp->y - tu->oy, smr4);
|
|
|
|
tsp->z = tu->oz + mulscale18(tsp->z - tu->oz, smr4);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(tu->Flags, SPR_SKIP2))
|
|
|
|
{
|
|
|
|
if (tsp->statnum <= STAT_SKIP2_INTERP_END)
|
|
|
|
{
|
2017-06-24 09:20:21 +00:00
|
|
|
tsp->x = tu->ox + mulscale17(tsp->x - tu->ox, smr2);
|
|
|
|
tsp->y = tu->oy + mulscale17(tsp->y - tu->oy, smr2);
|
|
|
|
tsp->z = tu->oz + mulscale17(tsp->z - tu->oz, smr2);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-02 06:41:29 +00:00
|
|
|
// workaround for mines and floor decals beneath the floor
|
|
|
|
if (tsp->picnum == BETTY_R0 || tsp->picnum == FLOORBLOOD1)
|
2020-02-02 06:41:25 +00:00
|
|
|
{
|
|
|
|
auto sp = (uspriteptr_t)&sprite[SpriteNum];
|
|
|
|
int32_t const floorz = getflorzofslope(sp->sectnum, sp->x, sp->y);
|
|
|
|
if (sp->z > floorz)
|
|
|
|
tsp->z = floorz;
|
|
|
|
}
|
|
|
|
|
2019-10-27 15:53:00 +00:00
|
|
|
if (r_shadows && TEST(tu->Flags, SPR_SHADOW))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-04-19 18:15:57 +00:00
|
|
|
DoShadows(tsp, viewz, mirror);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//#define UK_VERSION 1
|
|
|
|
|
|
|
|
//#define DART_REPEAT 6
|
|
|
|
//#define DART_PIC 2233
|
2019-12-07 19:48:16 +00:00
|
|
|
if (sw_darts)
|
2015-05-19 21:54:34 +00:00
|
|
|
if (tu->ID == 1793 || tsp->picnum == 1793)
|
|
|
|
{
|
|
|
|
tsp->picnum = 2519;
|
|
|
|
tsp->xrepeat = 27;
|
|
|
|
tsp->yrepeat = 29;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tu->ID == STAR1)
|
|
|
|
{
|
2019-12-07 19:48:16 +00:00
|
|
|
if (sw_darts)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-16 07:04:24 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
tsp->picnum = DART_PIC;
|
|
|
|
tsp->ang = NORM_ANGLE(tsp->ang - 512 - 24);
|
|
|
|
tsp->xrepeat = tsp->yrepeat = DART_REPEAT;
|
2018-02-16 06:38:31 +00:00
|
|
|
SET(tsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DoStarView(tsp, tu, viewz);
|
|
|
|
}
|
|
|
|
|
|
|
|
// rotation
|
|
|
|
if (tu->RotNum > 0)
|
|
|
|
SetActorRotation(tSpriteNum, viewx, viewy);
|
|
|
|
|
|
|
|
if (tu->motion_blur_num)
|
|
|
|
{
|
|
|
|
DoMotionBlur(tsp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// set palette lookup correctly
|
|
|
|
if (tsp->pal != sector[tsp->sectnum].floorpal)
|
|
|
|
{
|
|
|
|
if (sector[tsp->sectnum].floorpal == PALETTE_DEFAULT)
|
|
|
|
{
|
|
|
|
// default pal for sprite is stored in tu->spal
|
|
|
|
// mostly for players and other monster types
|
|
|
|
tsp->pal = tu->spal;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if sector pal is something other than default
|
|
|
|
SECT_USERp sectu = SectUser[tsp->sectnum];
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t pal = sector[tsp->sectnum].floorpal;
|
2020-09-09 18:32:24 +00:00
|
|
|
bool nosectpal=false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// sprite does not take on the new pal if sector flag is set
|
|
|
|
if (sectu && TEST(sectu->flags, SECTFU_DONT_COPY_PALETTE))
|
|
|
|
{
|
|
|
|
pal = PALETTE_DEFAULT;
|
2020-09-09 17:52:52 +00:00
|
|
|
nosectpal = true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//if(tu->spal == PALETTE_DEFAULT)
|
|
|
|
if (tsp->hitag != SECTFU_DONT_COPY_PALETTE && tsp->hitag != LUMINOUS
|
|
|
|
&& !nosectpal
|
|
|
|
&& pal != PALETTE_FOG && pal != PALETTE_DIVE &&
|
|
|
|
pal != PALETTE_DIVE_LAVA)
|
|
|
|
tsp->pal = pal;
|
|
|
|
else
|
|
|
|
tsp->pal = tu->spal;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sprite debug information mode
|
|
|
|
if (tsp->hitag == 9997)
|
|
|
|
{
|
|
|
|
tsp->pal = PALETTE_RED_LIGHTING;
|
|
|
|
// Turn it off, it gets reset by PrintSpriteInfo
|
|
|
|
sprite[tu->SpriteNum].hitag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-07 19:48:16 +00:00
|
|
|
if (sw_darts)
|
2015-05-19 21:54:34 +00:00
|
|
|
if (tsp->statnum == STAT_STAR_QUEUE)
|
|
|
|
{
|
|
|
|
tsp->picnum = DART_PIC;
|
|
|
|
tsp->ang = NORM_ANGLE(tsp->ang - 512);
|
|
|
|
tsp->xrepeat = tsp->yrepeat = DART_REPEAT;
|
2018-02-16 06:38:31 +00:00
|
|
|
SET(tsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Call my sprite handler
|
|
|
|
// Does autosizing and voxel handling
|
|
|
|
JAnalyzeSprites(tsp);
|
|
|
|
|
|
|
|
// only do this of you are a player sprite
|
|
|
|
//if (tsp->statnum >= STAT_PLAYER0 && tsp->statnum < STAT_PLAYER0 + MAX_SW_PLAYERS)
|
|
|
|
if (tu && tu->PlayerP)
|
|
|
|
{
|
|
|
|
// Shadow spell
|
|
|
|
if (!TEST(tsp->cstat, CSTAT_SPRITE_TRANSLUCENT))
|
|
|
|
ShadeSprite(tsp);
|
|
|
|
|
|
|
|
// sw if its your playersprite
|
|
|
|
//if ((Player + screenpeek)->PlayerSprite == SpriteNum)
|
|
|
|
if ((Player + screenpeek)->PlayerSprite == tu->SpriteNum)
|
|
|
|
{
|
|
|
|
PLAYERp pp = Player + screenpeek;
|
|
|
|
if (mirror || TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE|PF_VIEW_FROM_CAMERA))
|
|
|
|
{
|
|
|
|
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
|
|
|
SET(tsp->cstat, CSTAT_SPRITE_TRANSLUCENT);
|
|
|
|
|
|
|
|
if (TEST(pp->Flags, PF_CLIMBING))
|
|
|
|
{
|
|
|
|
// move sprite forward some so he looks like he's
|
|
|
|
// climbing
|
|
|
|
tsp->x = pp->six + MOVEx(128 + 80, tsp->ang);
|
|
|
|
tsp->y = pp->siy + MOVEy(128 + 80, tsp->ang);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tsp->x = pp->six;
|
|
|
|
tsp->y = pp->siy;
|
|
|
|
}
|
|
|
|
|
|
|
|
tsp->z = tsp->z + pp->siz;
|
2020-04-03 21:51:51 +00:00
|
|
|
tsp->ang = pp->siang;
|
2015-05-19 21:54:34 +00:00
|
|
|
//continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// dont draw your sprite
|
|
|
|
tsp->owner = -1;
|
|
|
|
//SET(tsp->cstat, CSTAT_SPRITE_INVISIBLE);
|
|
|
|
}
|
|
|
|
}
|
2020-09-01 13:08:07 +00:00
|
|
|
else // Otherwise just interpolate the player sprite
|
2020-04-18 14:38:31 +00:00
|
|
|
{
|
|
|
|
PLAYERp pp = tu->PlayerP;
|
|
|
|
tsp->x -= mulscale16(pp->posx - pp->oposx, 65536-smoothratio);
|
|
|
|
tsp->y -= mulscale16(pp->posy - pp->oposy, 65536-smoothratio);
|
|
|
|
tsp->z -= mulscale16(pp->posz - pp->oposz, 65536-smoothratio);
|
2020-09-01 13:00:35 +00:00
|
|
|
tsp->ang -= FixedToInt(mulscale16(pp->q16ang - pp->oq16ang, 65536-smoothratio));
|
2020-04-18 14:38:31 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (OverlapDraw && FAF_ConnectArea(tsp->sectnum) && tsp->owner >= 0)
|
|
|
|
{
|
2020-09-04 19:24:48 +00:00
|
|
|
static_assert(sizeof(uspritetype) == sizeof(tspritetype)); // see TSPRITE_SIZE
|
2019-12-26 06:27:48 +00:00
|
|
|
ConnectCopySprite((uspriteptr_t)tsp);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// kens original sprite shade code he moved out of the engine
|
|
|
|
//
|
|
|
|
|
|
|
|
switch (tsp->statnum)
|
|
|
|
{
|
|
|
|
case STAT_ENEMY:
|
|
|
|
case STAT_DEAD_ACTOR:
|
|
|
|
case STAT_FAF_COPY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
newshade = tsp->shade;
|
|
|
|
newshade += 6;
|
|
|
|
if (newshade > 127) newshade = 127;
|
|
|
|
tsp->shade = newshade;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(sector[tsp->sectnum].ceilingstat, CEILING_STAT_PLAX))
|
|
|
|
{
|
|
|
|
newshade = tsp->shade;
|
|
|
|
newshade += sector[tsp->sectnum].ceilingshade;
|
|
|
|
if (newshade > 127) newshade = 127;
|
|
|
|
if (newshade < -128) newshade = -128;
|
|
|
|
tsp->shade = newshade;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newshade = tsp->shade;
|
|
|
|
newshade += sector[tsp->sectnum].floorshade;
|
|
|
|
if (newshade > 127) newshade = 127;
|
|
|
|
if (newshade < -128) newshade = -128;
|
|
|
|
tsp->shade = newshade;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tsp->hitag == 9998)
|
|
|
|
tsp->shade = 127; // Invisible enemy ninjas
|
|
|
|
|
|
|
|
// Correct shades for luminous sprites
|
|
|
|
if (tsp->hitag == LUMINOUS)
|
|
|
|
{
|
|
|
|
tsp->shade = -128;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pp->NightVision && TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY))
|
|
|
|
{
|
|
|
|
if (tu && tu->ID == TRASHCAN) continue; // Don't light up trashcan
|
|
|
|
|
|
|
|
tsp->pal = PALETTE_ILLUMINATE; // Make sprites REALLY bright green.
|
|
|
|
tsp->shade = -128;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tu && tu->PlayerP)
|
|
|
|
{
|
|
|
|
if (TEST(tu->Flags2, SPR2_VIS_SHADING))
|
|
|
|
{
|
|
|
|
if ((Player + screenpeek)->PlayerSprite != tu->SpriteNum)
|
|
|
|
{
|
|
|
|
if (!TEST(tu->PlayerP->Flags, PF_VIEW_FROM_OUTSIDE))
|
|
|
|
{
|
|
|
|
RESET(tsp->cstat, CSTAT_SPRITE_TRANSLUCENT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tsp->shade = 12 - STD_RANDOM_RANGE(30);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WarpCopySprite();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 1
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t get_tsprite(short SpriteNum)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int tSpriteNum;
|
|
|
|
|
|
|
|
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
|
|
|
|
{
|
|
|
|
if (tsprite[tSpriteNum].owner == SpriteNum)
|
|
|
|
return &tsprite[tSpriteNum];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
2015-05-19 21:54:34 +00:00
|
|
|
post_analyzesprites(void)
|
|
|
|
{
|
|
|
|
int tSpriteNum;
|
|
|
|
short SpriteNum;
|
|
|
|
USERp tu;
|
|
|
|
|
|
|
|
for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--)
|
|
|
|
{
|
|
|
|
SpriteNum = tsprite[tSpriteNum].owner;
|
|
|
|
if (SpriteNum < 0) continue; // JBF: verify this is safe
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t tsp = &tsprite[tSpriteNum];
|
2015-05-19 21:54:34 +00:00
|
|
|
tu = User[SpriteNum];
|
|
|
|
|
|
|
|
if (tu)
|
|
|
|
{
|
|
|
|
if (tu->ID == FIREBALL_FLAMES && tu->Attach >= 0)
|
|
|
|
{
|
2017-01-23 11:21:08 +00:00
|
|
|
//uspritetype * const atsp = &sprite[tu->Attach];
|
2019-12-26 06:27:48 +00:00
|
|
|
tspriteptr_t const atsp = get_tsprite(tu->Attach);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!atsp)
|
|
|
|
{
|
|
|
|
//DSPRINTF(ds,"Attach not found");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
tsp->x = atsp->x;
|
|
|
|
tsp->y = atsp->y;
|
|
|
|
// statnum is priority - draw this ALWAYS first at 0
|
|
|
|
// statnum is priority - draw this ALWAYS last at MAXSTATUS
|
|
|
|
if (TEST(atsp->extra, SPRX_BURNABLE))
|
|
|
|
{
|
|
|
|
atsp->statnum = 1;
|
|
|
|
tsp->statnum = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tsp->statnum = MAXSTATUS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2020-09-25 07:52:00 +00:00
|
|
|
bool
|
2020-09-23 13:12:59 +00:00
|
|
|
BackView(int *nx, int *ny, int *nz, short *vsect, fixed_t *nq16ang, fixed_t q16horiz)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
vec3_t n = { *nx, *ny, *nz };
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
2015-05-19 22:01:22 +00:00
|
|
|
hitdata_t hitinfo;
|
2020-03-06 15:49:49 +00:00
|
|
|
int i, vx, vy, vz, hx, hy;
|
2015-05-19 22:01:22 +00:00
|
|
|
short bakcstat, daang;
|
2015-05-19 21:54:34 +00:00
|
|
|
PLAYERp pp = &Player[screenpeek];
|
|
|
|
short ang;
|
|
|
|
|
|
|
|
ASSERT(*vsect >= 0 && *vsect < MAXSECTORS);
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
ang = FixedToInt(*nq16ang) + pp->view_outside_dang;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Calculate the vector (nx,ny,nz) to shoot backwards
|
|
|
|
vx = (sintable[NORM_ANGLE(ang + 1536)] >> 3);
|
|
|
|
vy = (sintable[NORM_ANGLE(ang + 1024)] >> 3);
|
2020-09-23 13:12:59 +00:00
|
|
|
vz = (q16horiz - IntToFixed(100)) >> 8;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Player sprite of current view
|
|
|
|
sp = &sprite[pp->PlayerSprite];
|
|
|
|
|
|
|
|
bakcstat = sp->cstat;
|
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
|
|
|
|
|
|
|
// Make sure sector passed to FAFhitscan is correct
|
|
|
|
//COVERupdatesector(*nx, *ny, vsect);
|
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
hitscan(&n, *vsect, vx, vy, vz,
|
|
|
|
&hitinfo, CLIPMASK_PLAYER);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-25 07:52:00 +00:00
|
|
|
if (*vsect < 0)
|
|
|
|
{
|
|
|
|
sp->cstat = bakcstat;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
ASSERT(*vsect >= 0 && *vsect < MAXSECTORS);
|
|
|
|
|
|
|
|
sp->cstat = bakcstat; // Restore cstat
|
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
hx = hitinfo.pos.x - (*nx);
|
|
|
|
hy = hitinfo.pos.y - (*ny);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// If something is in the way, make pp->camera_dist lower if necessary
|
|
|
|
if (klabs(vx) + klabs(vy) > klabs(hx) + klabs(hy))
|
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
if (hitinfo.wall >= 0) // Push you a little bit off the wall
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
*vsect = hitinfo.sect;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
daang = getangle(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x,
|
|
|
|
wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
i = vx * sintable[daang] + vy * sintable[NORM_ANGLE(daang + 1536)];
|
|
|
|
if (klabs(vx) > klabs(vy))
|
|
|
|
hx -= mulscale28(vx, i);
|
|
|
|
else
|
|
|
|
hy -= mulscale28(vy, i);
|
|
|
|
}
|
2015-05-19 22:01:22 +00:00
|
|
|
else if (hitinfo.sprite < 0) // Push you off the ceiling/floor
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
*vsect = hitinfo.sect;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (klabs(vx) > klabs(vy))
|
|
|
|
hx -= (vx >> 5);
|
|
|
|
else
|
|
|
|
hy -= (vy >> 5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
SPRITEp hsp = &sprite[hitinfo.sprite];
|
2015-05-19 21:54:34 +00:00
|
|
|
int flag_backup;
|
|
|
|
|
|
|
|
// if you hit a sprite that's not a wall sprite - try again
|
2018-02-16 06:38:31 +00:00
|
|
|
if (!TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
flag_backup = hsp->cstat;
|
|
|
|
RESET(hsp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
|
|
|
ASSERT(*vsect >= 0 && *vsect < MAXSECTORS);
|
2020-09-23 13:12:59 +00:00
|
|
|
BackView(nx, ny, nz, vsect, nq16ang, q16horiz);
|
2015-05-19 21:54:34 +00:00
|
|
|
hsp->cstat = flag_backup;
|
2020-09-25 07:52:00 +00:00
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// same as wall calculation
|
|
|
|
daang = NORM_ANGLE(sp->ang-512);
|
|
|
|
|
|
|
|
i = vx * sintable[daang] + vy * sintable[NORM_ANGLE(daang + 1536)];
|
|
|
|
if (klabs(vx) > klabs(vy))
|
|
|
|
hx -= mulscale28(vx, i);
|
|
|
|
else
|
|
|
|
hy -= mulscale28(vy, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (klabs(vx) > klabs(vy))
|
2020-09-01 13:00:35 +00:00
|
|
|
i = IntToFixed(hx) / vx;
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2020-09-01 13:00:35 +00:00
|
|
|
i = IntToFixed(hy) / vy;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (i < pp->camera_dist)
|
|
|
|
pp->camera_dist = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Actually move you! (Camerdist is 65536 if nothing is in the way)
|
|
|
|
*nx = (*nx) + mulscale16(vx, pp->camera_dist);
|
|
|
|
*ny = (*ny) + mulscale16(vy, pp->camera_dist);
|
|
|
|
*nz = (*nz) + mulscale16(vz, pp->camera_dist);
|
|
|
|
|
|
|
|
// Slowly increase pp->camera_dist until it reaches 65536
|
|
|
|
// Synctics is a timer variable so it increases the same rate
|
|
|
|
// on all speed computers
|
|
|
|
pp->camera_dist = min(pp->camera_dist + (3 << 10), 65536);
|
|
|
|
//pp->camera_dist = min(pp->camera_dist + (synctics << 10), 65536);
|
|
|
|
|
|
|
|
// Make sure vsect is correct
|
|
|
|
updatesectorz(*nx, *ny, *nz, vsect);
|
|
|
|
|
2020-09-25 07:52:00 +00:00
|
|
|
*nq16ang += IntToFixed(pp->view_outside_dang);
|
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-09-23 13:12:59 +00:00
|
|
|
CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, fixed_t q16horiz)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
vec3_t n = { *nx, *ny, *nz };
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
2015-05-19 22:01:22 +00:00
|
|
|
hitdata_t hitinfo;
|
2020-03-06 15:49:49 +00:00
|
|
|
int i, vx, vy, vz, hx, hy;
|
2015-05-19 22:01:22 +00:00
|
|
|
short bakcstat, daang;
|
2015-05-19 21:54:34 +00:00
|
|
|
PLAYERp pp = &Player[screenpeek];
|
|
|
|
short ang;
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
ang = FixedToInt(*nq16ang) + pp->circle_camera_ang;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Calculate the vector (nx,ny,nz) to shoot backwards
|
|
|
|
vx = (sintable[NORM_ANGLE(ang + 1536)] >> 4);
|
|
|
|
vy = (sintable[NORM_ANGLE(ang + 1024)] >> 4);
|
|
|
|
|
|
|
|
// lengthen the vector some
|
|
|
|
vx += DIV2(vx);
|
|
|
|
vy += DIV2(vy);
|
|
|
|
|
2020-09-23 13:12:59 +00:00
|
|
|
vz = (q16horiz - IntToFixed(100)) >> 8;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Player sprite of current view
|
|
|
|
sp = &sprite[pp->PlayerSprite];
|
|
|
|
|
|
|
|
bakcstat = sp->cstat;
|
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
|
|
|
|
|
|
|
// Make sure sector passed to hitscan is correct
|
|
|
|
//COVERupdatesector(*nx, *ny, vsect);
|
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
hitscan(&n, *vsect, vx, vy, vz,
|
|
|
|
&hitinfo, CLIPMASK_MISSILE);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->cstat = bakcstat; // Restore cstat
|
2015-05-19 22:01:22 +00:00
|
|
|
//ASSERT(hitinfo.sect >= 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
hx = hitinfo.pos.x - (*nx);
|
|
|
|
hy = hitinfo.pos.y - (*ny);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// If something is in the way, make pp->circle_camera_dist lower if necessary
|
|
|
|
if (klabs(vx) + klabs(vy) > klabs(hx) + klabs(hy))
|
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
if (hitinfo.wall >= 0) // Push you a little bit off the wall
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
*vsect = hitinfo.sect;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
daang = getangle(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x,
|
|
|
|
wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
i = vx * sintable[daang] + vy * sintable[NORM_ANGLE(daang + 1536)];
|
|
|
|
if (klabs(vx) > klabs(vy))
|
|
|
|
hx -= mulscale28(vx, i);
|
|
|
|
else
|
|
|
|
hy -= mulscale28(vy, i);
|
|
|
|
}
|
2015-05-19 22:01:22 +00:00
|
|
|
else if (hitinfo.sprite < 0) // Push you off the ceiling/floor
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
*vsect = hitinfo.sect;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (klabs(vx) > klabs(vy))
|
|
|
|
hx -= (vx >> 5);
|
|
|
|
else
|
|
|
|
hy -= (vy >> 5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
SPRITEp hsp = &sprite[hitinfo.sprite];
|
2015-05-19 21:54:34 +00:00
|
|
|
int flag_backup;
|
|
|
|
|
|
|
|
// if you hit a sprite that's not a wall sprite - try again
|
2018-02-16 06:38:31 +00:00
|
|
|
if (!TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
flag_backup = hsp->cstat;
|
|
|
|
RESET(hsp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
|
|
|
|
2020-09-23 13:12:59 +00:00
|
|
|
CircleCamera(nx, ny, nz, vsect, nq16ang, q16horiz);
|
2015-05-19 21:54:34 +00:00
|
|
|
hsp->cstat = flag_backup;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (klabs(vx) > klabs(vy))
|
2020-09-01 13:00:35 +00:00
|
|
|
i = IntToFixed(hx) / vx;
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2020-09-01 13:00:35 +00:00
|
|
|
i = IntToFixed(hy) / vy;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (i < pp->circle_camera_dist)
|
|
|
|
pp->circle_camera_dist = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Actually move you! (Camerdist is 65536 if nothing is in the way)
|
2020-09-01 13:00:35 +00:00
|
|
|
*nx = (*nx) + FixedToInt(vx * pp->circle_camera_dist);
|
|
|
|
*ny = (*ny) + FixedToInt(vy * pp->circle_camera_dist);
|
|
|
|
*nz = (*nz) + FixedToInt(vz * pp->circle_camera_dist);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Slowly increase pp->circle_camera_dist until it reaches 65536
|
|
|
|
// Synctics is a timer variable so it increases the same rate
|
|
|
|
// on all speed computers
|
|
|
|
pp->circle_camera_dist = min(pp->circle_camera_dist + (3 << 8), 65536);
|
|
|
|
//pp->circle_camera_dist = min(pp->circle_camera_dist + (synctics << 10), 65536);
|
|
|
|
|
|
|
|
// Make sure vsect is correct
|
|
|
|
updatesectorz(*nx, *ny, *nz, vsect);
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
*nq16ang = IntToFixed(ang);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-23 19:55:12 +00:00
|
|
|
FString GameInterface::GetCoordString()
|
|
|
|
{
|
|
|
|
PLAYERp pp = Player + myconnectindex;
|
|
|
|
FString out;
|
|
|
|
out.AppendFormat("POSX:%d ", pp->posx);
|
|
|
|
out.AppendFormat("POSY:%d ", pp->posy);
|
|
|
|
out.AppendFormat("POSZ:%d ", pp->posz);
|
2020-09-06 22:40:14 +00:00
|
|
|
out.AppendFormat("ANG:%d\n", FixedToInt(pp->q16ang));
|
2019-12-23 19:55:12 +00:00
|
|
|
|
|
|
|
return out;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void PrintSpriteInfo(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-16 07:04:24 +00:00
|
|
|
const int Y_STEP = 7;
|
2017-01-05 05:29:06 +00:00
|
|
|
int x = windowxy1.x+2;
|
|
|
|
int y = windowxy1.y+2;
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
|
|
|
USERp u;
|
|
|
|
|
2019-12-23 19:55:12 +00:00
|
|
|
//if (SpriteInfo && !LocationInfo)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 22:01:22 +00:00
|
|
|
short hit_sprite = DoPickTarget(pp->SpriteP, 32, 2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
sp = &sprite[hit_sprite];
|
|
|
|
u = User[hit_sprite];
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->hitag = 9997; // Special tag to make the actor glow red for one frame
|
|
|
|
|
2015-05-19 22:01:22 +00:00
|
|
|
if (hit_sprite == -1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-23 19:55:12 +00:00
|
|
|
Printf("SPRITENUM: NONE TARGETED\n");
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2019-12-23 19:55:12 +00:00
|
|
|
Printf("SPRITENUM:%d\n", hit_sprite);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (u)
|
|
|
|
{
|
2019-12-23 19:55:12 +00:00
|
|
|
Printf("ID:%d, ", u->ID);
|
|
|
|
Printf("PALETTE:%d, ", u->spal);
|
|
|
|
Printf("HEALTH:%d, ", u->Health);
|
|
|
|
Printf("WAITTICS:%d, ", u->WaitTics);
|
|
|
|
Printf("COUNTER:%d, ", u->Counter);
|
|
|
|
Printf("COUNTER2:%d\n", u->Counter);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-12-25 10:26:19 +00:00
|
|
|
if (sp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-23 19:55:12 +00:00
|
|
|
Printf("POSX:%d, ", TrackerCast(sp->x));
|
|
|
|
Printf("POSY:%d, ", TrackerCast(sp->y));
|
|
|
|
Printf("POSZ:%d,", TrackerCast(sp->z));
|
|
|
|
Printf("ANG:%d\n", TrackerCast(sp->ang));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void SpriteSortList2D(int tx, int ty)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SPRITEp sp;
|
|
|
|
int i;
|
|
|
|
int dist,a,b,c;
|
|
|
|
|
|
|
|
spritesortcnt = 0;
|
|
|
|
for (i = 0; i < MAXSPRITES; i++)
|
|
|
|
{
|
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
|
|
|
{
|
|
|
|
sp = &sprite[i];
|
|
|
|
|
|
|
|
if (!TEST(sp->cstat, CSTAT_SPRITE_INVISIBLE) &&
|
|
|
|
(sp->xrepeat > 0) && (sp->yrepeat > 0) &&
|
|
|
|
(spritesortcnt < MAXSPRITESONSCREEN))
|
|
|
|
{
|
|
|
|
DISTANCE(tx,ty,sp->x,sp->y,dist,a,b,c);
|
|
|
|
|
|
|
|
if (dist < 22000)
|
|
|
|
{
|
2019-12-26 06:27:58 +00:00
|
|
|
renderAddTSpriteFromSprite(i);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DrawCrosshair(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-09-09 18:32:24 +00:00
|
|
|
extern bool CameraTestMode;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-25 07:52:00 +00:00
|
|
|
if (!(CameraTestMode))
|
2020-08-15 20:04:37 +00:00
|
|
|
{
|
2020-09-05 11:57:26 +00:00
|
|
|
USERp u = User[pp->PlayerSprite];
|
2020-09-25 07:52:00 +00:00
|
|
|
::DrawCrosshair(2326, u->Health, -getHalfLookAng(pp->oq16look_ang, pp->q16look_ang, cl_syncinput, smoothratio), TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE) ? 5 : 0, 2, shadeToLight(10));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fixed_t *tq16ang, fixed_t *tq16horiz)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i,nexti;
|
|
|
|
short ang;
|
|
|
|
SPRITEp sp;
|
2020-09-09 18:32:24 +00:00
|
|
|
bool found_camera = false;
|
|
|
|
bool player_in_camera = false;
|
|
|
|
bool FAFcansee_test;
|
|
|
|
bool ang_test;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (pp == &Player[screenpeek])
|
|
|
|
{
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEMO_CAMERA], i, nexti)
|
|
|
|
{
|
|
|
|
sp = &sprite[i];
|
|
|
|
|
|
|
|
ang = getangle(*tx - sp->x, *ty - sp->y);
|
2020-09-16 11:46:03 +00:00
|
|
|
ang_test = getincangle(ang, sp->ang) < sp->lotag;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
FAFcansee_test =
|
|
|
|
(FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, *tx, *ty, *tz, pp->cursectnum) ||
|
|
|
|
FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, *tx, *ty, *tz + SPRITEp_SIZE_Z(pp->SpriteP), pp->cursectnum));
|
|
|
|
|
|
|
|
player_in_camera = ang_test && FAFcansee_test;
|
|
|
|
|
|
|
|
if (player_in_camera || pp->camera_check_time_delay > 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
// if your not in the camera but are still looking
|
|
|
|
// make sure that only the last camera shows you
|
|
|
|
|
|
|
|
if (!player_in_camera && pp->camera_check_time_delay > 0)
|
|
|
|
{
|
|
|
|
if (pp->last_camera_sp != sp)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (sp->clipdist)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
pp->last_camera_sp = sp;
|
2020-09-23 13:12:59 +00:00
|
|
|
CircleCamera(tx, ty, tz, tsectnum, tq16ang, IntToFixed(100));
|
2020-09-09 17:52:52 +00:00
|
|
|
found_camera = true;
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
int xvect,yvect,zvect,zdiff;
|
|
|
|
|
|
|
|
pp->last_camera_sp = sp;
|
|
|
|
|
|
|
|
xvect = sintable[NORM_ANGLE(ang + 512)] >> 3;
|
|
|
|
yvect = sintable[NORM_ANGLE(ang)] >> 3;
|
|
|
|
|
|
|
|
zdiff = sp->z - *tz;
|
|
|
|
if (labs(sp->x - *tx) > 1000)
|
|
|
|
zvect = scale(xvect, zdiff, sp->x - *tx);
|
|
|
|
else if (labs(sp->y - *ty) > 1000)
|
|
|
|
zvect = scale(yvect, zdiff, sp->y - *ty);
|
|
|
|
else if (sp->x - *tx != 0)
|
|
|
|
zvect = scale(xvect, zdiff, sp->x - *tx);
|
|
|
|
else if (sp->y - *ty != 0)
|
|
|
|
zvect = scale(yvect, zdiff, sp->y - *ty);
|
|
|
|
else
|
|
|
|
zvect = 0;
|
|
|
|
|
|
|
|
// new horiz to player
|
2020-09-01 13:00:35 +00:00
|
|
|
*tq16horiz = IntToFixed(100 - (zvect/256));
|
|
|
|
*tq16horiz = max(*tq16horiz, IntToFixed(PLAYER_HORIZ_MIN));
|
|
|
|
*tq16horiz = min(*tq16horiz, IntToFixed(PLAYER_HORIZ_MAX));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-20 08:10:27 +00:00
|
|
|
//DSPRINTF(ds,"xvect %d,yvect %d,zvect %d,tq16horiz %d",xvect,yvect,zvect,*tq16horiz);
|
2015-05-19 21:54:34 +00:00
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
*tq16ang = IntToFixed(ang);
|
2015-05-19 21:54:34 +00:00
|
|
|
*tx = sp->x;
|
|
|
|
*ty = sp->y;
|
|
|
|
*tz = sp->z;
|
|
|
|
*tsectnum = sp->sectnum;
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
found_camera = true;
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found_camera)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if you player_in_camera you definately have a camera
|
|
|
|
if (player_in_camera)
|
|
|
|
{
|
|
|
|
pp->camera_check_time_delay = 120/2;
|
|
|
|
SET(pp->Flags, PF_VIEW_FROM_CAMERA);
|
|
|
|
|
|
|
|
ASSERT(found_camera);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// if you !player_in_camera you still might have a camera
|
|
|
|
// for a split second
|
|
|
|
{
|
|
|
|
if (found_camera)
|
|
|
|
{
|
|
|
|
SET(pp->Flags, PF_VIEW_FROM_CAMERA);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pp->circle_camera_ang = 0;
|
|
|
|
pp->circle_camera_dist = CIRCLE_CAMERA_DIST_MIN;
|
|
|
|
RESET(pp->Flags, PF_VIEW_FROM_CAMERA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
PreDraw(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short i, nexti;
|
|
|
|
|
|
|
|
PreDrawStackedWater();
|
|
|
|
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FLOOR_SLOPE_DONT_DRAW], i, nexti)
|
|
|
|
{
|
|
|
|
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_SLOPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
PostDraw(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short i, nexti;
|
|
|
|
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FLOOR_SLOPE_DONT_DRAW], i, nexti)
|
|
|
|
{
|
|
|
|
SET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_SLOPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF_COPY], i, nexti)
|
|
|
|
{
|
|
|
|
if (User[i])
|
|
|
|
{
|
|
|
|
FreeMem(User[i]);
|
|
|
|
User[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
deletesprite(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-23 11:21:08 +00:00
|
|
|
int CopySprite(uspritetype const * tsp, short newsector)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2017-01-23 11:21:32 +00:00
|
|
|
short New;
|
2015-05-19 21:54:34 +00:00
|
|
|
SPRITEp sp;
|
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New = COVERinsertsprite(newsector, STAT_FAF_COPY);
|
|
|
|
sp = &sprite[New];
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sp->x = tsp->x;
|
|
|
|
sp->y = tsp->y;
|
|
|
|
sp->z = tsp->z;
|
|
|
|
sp->cstat = tsp->cstat;
|
|
|
|
sp->picnum = tsp->picnum;
|
|
|
|
sp->pal = tsp->pal;
|
|
|
|
sp->xrepeat = tsp->xrepeat;
|
|
|
|
sp->yrepeat = tsp->yrepeat;
|
|
|
|
sp->xoffset = tsp->xoffset;
|
|
|
|
sp->yoffset = tsp->yoffset;
|
|
|
|
sp->ang = tsp->ang;
|
|
|
|
sp->xvel = tsp->xvel;
|
|
|
|
sp->yvel = tsp->yvel;
|
|
|
|
sp->zvel = tsp->zvel;
|
|
|
|
sp->shade = tsp->shade;
|
|
|
|
|
|
|
|
RESET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
|
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
return New;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 11:21:08 +00:00
|
|
|
int ConnectCopySprite(uspritetype const * tsp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short newsector;
|
|
|
|
int testz;
|
|
|
|
|
|
|
|
if (FAF_ConnectCeiling(tsp->sectnum))
|
|
|
|
{
|
|
|
|
newsector = tsp->sectnum;
|
|
|
|
testz = SPRITEp_TOS(tsp) - Z(10);
|
|
|
|
|
|
|
|
if (testz < sector[tsp->sectnum].ceilingz)
|
|
|
|
updatesectorz(tsp->x, tsp->y, testz, &newsector);
|
|
|
|
|
|
|
|
if (newsector >= 0 && newsector != tsp->sectnum)
|
|
|
|
{
|
|
|
|
return CopySprite(tsp, newsector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FAF_ConnectFloor(tsp->sectnum))
|
|
|
|
{
|
|
|
|
newsector = tsp->sectnum;
|
|
|
|
testz = SPRITEp_BOS(tsp) + Z(10);
|
|
|
|
|
|
|
|
if (testz > sector[tsp->sectnum].floorz)
|
|
|
|
updatesectorz(tsp->x, tsp->y, testz, &newsector);
|
|
|
|
|
|
|
|
if (newsector >= 0 && newsector != tsp->sectnum)
|
|
|
|
{
|
|
|
|
return CopySprite(tsp, newsector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PreDrawStackedWater(void)
|
|
|
|
{
|
|
|
|
short si,snexti;
|
|
|
|
short i,nexti;
|
2020-03-06 15:49:49 +00:00
|
|
|
SPRITEp sp;
|
2015-05-19 21:54:34 +00:00
|
|
|
USERp u,nu;
|
2017-01-23 11:21:32 +00:00
|
|
|
short New;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], si, snexti)
|
|
|
|
{
|
|
|
|
TRAVERSE_SPRITE_SECT(headspritesect[sprite[si].sectnum], i, nexti)
|
|
|
|
{
|
|
|
|
if (User[i])
|
|
|
|
{
|
|
|
|
if (sprite[i].statnum == STAT_ITEM)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sprite[i].statnum <= STAT_DEFAULT || sprite[i].statnum > STAT_PLAYER0 + MAX_SW_PLAYERS)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// code so that a copied sprite will not make another copy
|
|
|
|
if (User[i]->xchange == -989898)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sp = &sprite[i];
|
|
|
|
u = User[i];
|
|
|
|
|
2017-01-23 11:21:32 +00:00
|
|
|
New = ConnectCopySprite((uspritetype const *)sp);
|
|
|
|
if (New >= 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// spawn a user
|
2017-01-23 11:21:32 +00:00
|
|
|
User[New] = nu = (USERp)CallocMem(sizeof(USER), 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
ASSERT(nu != NULL);
|
|
|
|
|
|
|
|
nu->xchange = -989898;
|
|
|
|
|
|
|
|
// copy everything reasonable from the user that
|
|
|
|
// analyzesprites() needs to draw the image
|
|
|
|
nu->State = u->State;
|
|
|
|
nu->Rot = u->Rot;
|
|
|
|
nu->StateStart = u->StateStart;
|
|
|
|
nu->StateEnd = u->StateEnd;
|
|
|
|
nu->ox = u->ox;
|
|
|
|
nu->oy = u->oy;
|
|
|
|
nu->oz = u->oz;
|
|
|
|
nu->Flags = u->Flags;
|
|
|
|
nu->Flags2 = u->Flags2;
|
|
|
|
nu->RotNum = u->RotNum;
|
|
|
|
nu->ID = u->ID;
|
|
|
|
|
|
|
|
// set these to other sprite for players draw
|
|
|
|
nu->SpriteNum = i;
|
|
|
|
nu->SpriteP = sp;
|
|
|
|
|
|
|
|
nu->PlayerP = u->PlayerP;
|
|
|
|
nu->spal = u->spal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
void FAF_DrawRooms(int x, int y, int z, fixed_t q16ang, fixed_t q16horiz, short sectnum)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short i,nexti;
|
|
|
|
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti)
|
|
|
|
{
|
|
|
|
if (SPRITE_TAG3(i) == 0)
|
|
|
|
{
|
|
|
|
// back up ceilingpicnum and ceilingstat
|
|
|
|
SPRITE_TAG5(i) = sector[sprite[i].sectnum].ceilingpicnum;
|
|
|
|
sector[sprite[i].sectnum].ceilingpicnum = SPRITE_TAG2(i);
|
|
|
|
SPRITE_TAG4(i) = sector[sprite[i].sectnum].ceilingstat;
|
|
|
|
//SET(sector[sprite[i].sectnum].ceilingstat, ((int)SPRITE_TAG7(i))<<7);
|
|
|
|
SET(sector[sprite[i].sectnum].ceilingstat, SPRITE_TAG6(i));
|
|
|
|
RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_PLAX);
|
|
|
|
}
|
|
|
|
else if (SPRITE_TAG3(i) == 1)
|
|
|
|
{
|
|
|
|
SPRITE_TAG5(i) = sector[sprite[i].sectnum].floorpicnum;
|
|
|
|
sector[sprite[i].sectnum].floorpicnum = SPRITE_TAG2(i);
|
|
|
|
SPRITE_TAG4(i) = sector[sprite[i].sectnum].floorstat;
|
|
|
|
//SET(sector[sprite[i].sectnum].floorstat, ((int)SPRITE_TAG7(i))<<7);
|
|
|
|
SET(sector[sprite[i].sectnum].floorstat, SPRITE_TAG6(i));
|
|
|
|
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_PLAX);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-29 08:03:00 +00:00
|
|
|
renderDrawRoomsQ16(x,y,z,q16ang,q16horiz,sectnum);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti)
|
|
|
|
{
|
|
|
|
// manually set gotpic
|
|
|
|
if (TEST_GOTSECTOR(sprite[i].sectnum))
|
|
|
|
{
|
|
|
|
SET_GOTPIC(FAF_MIRROR_PIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SPRITE_TAG3(i) == 0)
|
|
|
|
{
|
|
|
|
// restore ceilingpicnum and ceilingstat
|
|
|
|
sector[sprite[i].sectnum].ceilingpicnum = SPRITE_TAG5(i);
|
|
|
|
sector[sprite[i].sectnum].ceilingstat = SPRITE_TAG4(i);
|
|
|
|
//RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_TYPE_MASK);
|
|
|
|
RESET(sector[sprite[i].sectnum].ceilingstat, CEILING_STAT_PLAX);
|
|
|
|
}
|
|
|
|
else if (SPRITE_TAG3(i) == 1)
|
|
|
|
{
|
|
|
|
sector[sprite[i].sectnum].floorpicnum = SPRITE_TAG5(i);
|
|
|
|
sector[sprite[i].sectnum].floorstat = SPRITE_TAG4(i);
|
|
|
|
//RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_TYPE_MASK);
|
|
|
|
RESET(sector[sprite[i].sectnum].floorstat, FLOOR_STAT_PLAX);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
short ScreenSavePic = false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 18:32:24 +00:00
|
|
|
bool PicInView(short, bool);
|
2019-10-09 17:58:09 +00:00
|
|
|
void DoPlayerDiveMeter(PLAYERp pp);
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
2020-08-25 11:46:52 +00:00
|
|
|
drawscreen(PLAYERp pp, double smoothratio)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-09-09 18:32:24 +00:00
|
|
|
extern bool CameraTestMode;
|
2020-05-20 08:10:27 +00:00
|
|
|
int tx, ty, tz;
|
2020-09-21 07:00:07 +00:00
|
|
|
fixed_t tq16horiz, tq16ang, tq16rotscrnang;
|
2020-03-29 08:03:00 +00:00
|
|
|
short tsectnum;
|
2015-05-19 21:54:34 +00:00
|
|
|
short i,j;
|
|
|
|
int bob_amt = 0;
|
|
|
|
int quake_z, quake_x, quake_y;
|
|
|
|
short quake_ang;
|
2020-09-09 18:32:24 +00:00
|
|
|
extern bool FAF_DebugView;
|
2015-05-19 21:54:34 +00:00
|
|
|
PLAYERp camerapp; // prediction player if prediction is on, else regular player
|
|
|
|
|
|
|
|
// last valid stuff
|
|
|
|
static short lv_sectnum = -1;
|
|
|
|
static int lv_x, lv_y, lv_z;
|
|
|
|
|
2019-12-03 09:44:42 +00:00
|
|
|
int const viewingRange = viewingrange;
|
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
DrawScreen = true;
|
2015-05-19 21:54:34 +00:00
|
|
|
PreDraw();
|
|
|
|
|
2020-08-18 06:25:12 +00:00
|
|
|
PreUpdatePanel(smoothratio);
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
if (!ScreenSavePic)
|
|
|
|
{
|
|
|
|
dointerpolations(smoothratio); // Stick at beginning of drawscreen
|
|
|
|
short_dointerpolations(smoothratio); // Stick at beginning of drawscreen
|
2020-05-22 23:26:51 +00:00
|
|
|
if (cl_sointerpolation)
|
2020-05-01 11:29:12 +00:00
|
|
|
so_dointerpolations(smoothratio); // Stick at beginning of drawscreen
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TENSW: when rendering with prediction, the only thing that counts should
|
|
|
|
// be the predicted player.
|
|
|
|
if (PredictionOn && CommEnabled && pp == Player+myconnectindex)
|
|
|
|
camerapp = ppp;
|
|
|
|
else
|
|
|
|
camerapp = pp;
|
|
|
|
|
2020-08-25 12:13:02 +00:00
|
|
|
tx = camerapp->oposx + xs_CRoundToInt(fmulscale16(camerapp->posx - camerapp->oposx, smoothratio));
|
|
|
|
ty = camerapp->oposy + xs_CRoundToInt(fmulscale16(camerapp->posy - camerapp->oposy, smoothratio));
|
|
|
|
tz = camerapp->oposz + xs_CRoundToInt(fmulscale16(camerapp->posz - camerapp->oposz, smoothratio));
|
2020-09-10 10:47:41 +00:00
|
|
|
|
|
|
|
// Interpolate the player's angle while on a sector object, just like VoidSW.
|
|
|
|
// This isn't needed for the turret as it was fixable, but moving sector objects are problematic.
|
|
|
|
if (cl_syncinput || pp != Player+myconnectindex || (!cl_syncinput && pp->sop && !TEST(pp->Flags2, PF2_INPUT_CAN_TURN_TURRET)))
|
2020-04-11 07:17:59 +00:00
|
|
|
{
|
2020-09-21 07:00:07 +00:00
|
|
|
fixed_t dang = IntToFixed(1024);
|
|
|
|
fixed_t oang = camerapp->oq16ang + camerapp->oq16look_ang;
|
|
|
|
fixed_t ang = camerapp->q16ang + camerapp->q16look_ang;
|
|
|
|
tq16ang = oang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(ang + dang - oang) - dang, smoothratio));
|
2020-08-25 12:13:02 +00:00
|
|
|
tq16horiz = camerapp->oq16horiz + xs_CRoundToInt(fmulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio));
|
2020-09-21 07:00:07 +00:00
|
|
|
tq16rotscrnang = camerapp->oq16rotscrnang + xs_CRoundToInt(fmulscale16(NORM_Q16ANGLE(camerapp->q16rotscrnang + dang - camerapp->oq16rotscrnang) - dang, smoothratio));
|
2020-04-11 07:17:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-21 07:00:07 +00:00
|
|
|
tq16ang = pp->q16ang + pp->q16look_ang;
|
2020-09-06 22:40:14 +00:00
|
|
|
tq16horiz = pp->q16horiz;
|
2020-09-21 07:00:07 +00:00
|
|
|
tq16rotscrnang = pp->q16rotscrnang;
|
2020-04-11 07:17:59 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
tsectnum = camerapp->cursectnum;
|
|
|
|
|
2020-09-21 07:00:07 +00:00
|
|
|
renderSetRollAngle(FixedToFloat(tq16rotscrnang));
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
COVERupdatesector(tx, ty, &tsectnum);
|
|
|
|
|
2020-08-16 07:04:24 +00:00
|
|
|
if (tsectnum >= 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// last valid stuff
|
|
|
|
lv_sectnum = tsectnum;
|
|
|
|
lv_x = tx;
|
|
|
|
lv_y = ty;
|
|
|
|
lv_z = tz;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pp->sop_riding || pp->sop_control)
|
|
|
|
{
|
2020-05-01 15:10:48 +00:00
|
|
|
if (pp->sop_control &&
|
2020-05-22 23:26:51 +00:00
|
|
|
(!cl_sointerpolation || (CommEnabled && !pp->sop_remote)))
|
2020-04-13 19:47:19 +00:00
|
|
|
{
|
|
|
|
tx = pp->posx;
|
|
|
|
ty = pp->posy;
|
|
|
|
tz = pp->posz;
|
|
|
|
tq16ang = pp->q16ang;
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
tsectnum = pp->cursectnum;
|
|
|
|
updatesectorz(tx, ty, tz, &tsectnum);
|
2020-05-19 11:44:52 +00:00
|
|
|
}
|
2020-04-03 21:49:57 +00:00
|
|
|
|
2020-04-03 21:49:57 +00:00
|
|
|
pp->six = tx;
|
|
|
|
pp->siy = ty;
|
|
|
|
pp->siz = tz - pp->posz;
|
2020-09-01 13:00:35 +00:00
|
|
|
pp->siang = FixedToInt(tq16ang);
|
2020-04-03 21:49:57 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
QuakeViewChange(camerapp, &quake_z, &quake_x, &quake_y, &quake_ang);
|
2015-05-19 22:03:30 +00:00
|
|
|
VisViewChange(camerapp, &g_visibility);
|
2015-05-19 21:54:34 +00:00
|
|
|
tz = tz + quake_z;
|
|
|
|
tx = tx + quake_x;
|
|
|
|
ty = ty + quake_y;
|
2020-09-01 13:00:35 +00:00
|
|
|
//tq16horiz = tq16horiz + IntToFixed(quake_x);
|
2020-09-16 23:01:19 +00:00
|
|
|
tq16ang = NORM_Q16ANGLE(tq16ang + IntToFixed(quake_ang));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (pp->sop_remote)
|
|
|
|
{
|
|
|
|
if (TEST_BOOL1(pp->remote_sprite))
|
2020-09-01 13:00:35 +00:00
|
|
|
tq16ang = IntToFixed(pp->remote_sprite->ang);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
2020-09-01 13:08:07 +00:00
|
|
|
tq16ang = gethiq16angle(pp->sop_remote->xmid - tx, pp->sop_remote->ymid - ty);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
|
|
|
{
|
2020-09-25 07:52:00 +00:00
|
|
|
tz -= 8448;
|
|
|
|
|
|
|
|
if (!BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, tq16horiz))
|
|
|
|
{
|
|
|
|
tz += 8448;
|
|
|
|
BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, tq16horiz);
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bob_amt = camerapp->bob_amt;
|
|
|
|
|
2020-08-15 20:31:44 +00:00
|
|
|
if (CameraTestMode)
|
2020-03-28 11:31:02 +00:00
|
|
|
{
|
2020-05-20 08:10:27 +00:00
|
|
|
CameraView(camerapp, &tx, &ty, &tz, &tsectnum, &tq16ang, &tq16horiz);
|
2020-03-28 11:31:02 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!TEST(pp->Flags, PF_VIEW_FROM_CAMERA|PF_VIEW_FROM_OUTSIDE))
|
|
|
|
{
|
2020-09-20 08:25:16 +00:00
|
|
|
if (cl_viewbob)
|
|
|
|
{
|
|
|
|
tz += bob_amt;
|
|
|
|
tz += pp->obob_z + xs_CRoundToInt(fmulscale16(pp->bob_z - pp->obob_z, smoothratio));
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// recoil only when not in camera
|
2020-09-07 11:34:13 +00:00
|
|
|
tq16horiz = tq16horiz + pp->recoil_horizoff;
|
2020-09-01 13:00:35 +00:00
|
|
|
tq16horiz = max(tq16horiz, IntToFixed(PLAYER_HORIZ_MIN));
|
|
|
|
tq16horiz = min(tq16horiz, IntToFixed(PLAYER_HORIZ_MAX));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-08-24 17:36:17 +00:00
|
|
|
if (automapMode != am_full)// && !ScreenSavePic)
|
2020-03-29 12:01:46 +00:00
|
|
|
{
|
|
|
|
// Cameras must be done before the main loop.
|
2020-05-20 10:44:04 +00:00
|
|
|
JS_DrawCameras(pp, tx, ty, tz);
|
2020-03-29 12:01:46 +00:00
|
|
|
}
|
|
|
|
|
2020-08-28 07:06:49 +00:00
|
|
|
|
|
|
|
videoSetCorrectedAspect();
|
2020-09-04 19:24:48 +00:00
|
|
|
renderSetAspect(xs_CRoundToInt(double(viewingrange)* tan(r_fov* (PI / 360.))), yxaspect);
|
2020-09-09 17:52:52 +00:00
|
|
|
OverlapDraw = true;
|
2020-03-29 08:03:00 +00:00
|
|
|
DrawOverlapRoom(tx, ty, tz, tq16ang, tq16horiz, tsectnum);
|
2020-09-09 17:52:52 +00:00
|
|
|
OverlapDraw = false;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-24 17:36:17 +00:00
|
|
|
if (automapMode != am_full)// && !ScreenSavePic)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// TEST this! Changed to camerapp
|
2020-03-29 08:03:00 +00:00
|
|
|
//JS_DrawMirrors(camerapp, tx, ty, tz, tq16ang, tq16horiz);
|
|
|
|
JS_DrawMirrors(pp, tx, ty, tz, tq16ang, tq16horiz);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-03-21 21:51:59 +00:00
|
|
|
// TODO: This call is redundant if the tiled overhead map is shown, but the
|
|
|
|
// HUD elements should be properly outputted with hardware rendering first.
|
|
|
|
if (!FAF_DebugView)
|
2020-03-29 08:03:00 +00:00
|
|
|
FAF_DrawRooms(tx, ty, tz, tq16ang, tq16horiz, tsectnum);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-09 17:52:52 +00:00
|
|
|
analyzesprites(tx, ty, tz, false);
|
2015-05-19 21:54:34 +00:00
|
|
|
post_analyzesprites();
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawMasks();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-28 07:06:49 +00:00
|
|
|
|
|
|
|
renderSetAspect(viewingRange, divscale16(ydim * 8, xdim * 5));
|
2020-09-19 19:31:35 +00:00
|
|
|
if (!ScreenSavePic) UpdatePanel(smoothratio);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#define SLIME 2305
|
|
|
|
// Only animate lava if its picnum is on screen
|
|
|
|
// gotpic is a bit array where the tile number's bit is set
|
|
|
|
// whenever it is drawn (ceilings, walls, sprites, etc.)
|
2019-10-11 21:31:59 +00:00
|
|
|
#if 0 // This needs a different implementation.
|
2015-05-19 21:54:34 +00:00
|
|
|
if ((gotpic[SLIME >> 3] & (1 << (SLIME & 7))) > 0)
|
|
|
|
{
|
|
|
|
gotpic[SLIME >> 3] &= ~(1 << (SLIME & 7));
|
|
|
|
|
|
|
|
if (waloff[SLIME])
|
|
|
|
movelava((char *) waloff[SLIME]);
|
|
|
|
}
|
2019-10-11 21:31:59 +00:00
|
|
|
#endif
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-19 19:31:35 +00:00
|
|
|
// if doing a screen save don't need to process the rest
|
|
|
|
if (ScreenSavePic)
|
|
|
|
{
|
|
|
|
DrawScreen = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-09-06 10:14:08 +00:00
|
|
|
MarkSectorSeen(pp->cursectnum);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-24 17:36:17 +00:00
|
|
|
if ((automapMode != am_off) && pp == Player+myconnectindex)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
for (j = 0; j < MAXSPRITES; j++)
|
|
|
|
{
|
|
|
|
// Don't show sprites tagged with 257
|
|
|
|
if (sprite[j].lotag == 257)
|
|
|
|
{
|
2018-02-16 06:38:31 +00:00
|
|
|
if (TEST(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2018-02-16 06:38:31 +00:00
|
|
|
RESET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
2015-05-19 21:54:34 +00:00
|
|
|
sprite[j].owner = -2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-06 10:14:08 +00:00
|
|
|
DrawOverheadMap(tx, ty, FixedToInt(tq16ang));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < MAXSPRITES; j++)
|
|
|
|
{
|
|
|
|
// Don't show sprites tagged with 257
|
|
|
|
if (sprite[j].lotag == 257 && sprite[j].owner == -2)
|
2018-02-16 06:38:31 +00:00
|
|
|
SET(sprite[j].cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-11-20 21:01:44 +00:00
|
|
|
|
2019-12-23 19:55:12 +00:00
|
|
|
//PrintLocationInfo(pp);
|
|
|
|
//PrintSpriteInfo(pp);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#if SYNC_TEST
|
|
|
|
SyncStatMessage();
|
|
|
|
#endif
|
|
|
|
|
2020-09-02 16:59:56 +00:00
|
|
|
UpdateStatusBar();
|
2015-05-19 21:54:34 +00:00
|
|
|
DrawCrosshair(pp);
|
|
|
|
DoPlayerDiveMeter(pp); // Do the underwater breathing bar
|
|
|
|
|
|
|
|
// Boss Health Meter, if Boss present
|
|
|
|
BossHealthMeter();
|
|
|
|
|
|
|
|
#if SYNC_TEST
|
|
|
|
SyncStatMessage();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
restoreinterpolations(); // Stick at end of drawscreen
|
|
|
|
short_restoreinterpolations(); // Stick at end of drawscreen
|
2020-05-22 23:26:51 +00:00
|
|
|
if (cl_sointerpolation)
|
2020-05-01 11:29:12 +00:00
|
|
|
so_restoreinterpolations(); // Stick at end of drawscreen
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-29 00:32:53 +00:00
|
|
|
if (paused && !M_Active())
|
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 100, "Game Paused", 0, 0, 0);
|
2020-05-29 00:32:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!CommEnabled && TEST(pp->Flags, PF_DEAD))
|
|
|
|
{
|
|
|
|
if (ReloadPrompt)
|
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
ReloadPrompt = false;
|
2020-05-29 00:32:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
PostDraw();
|
2020-09-09 17:52:52 +00:00
|
|
|
DrawScreen = false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-01-14 19:44:20 +00:00
|
|
|
bool GameInterface::GenerateSavePic()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-09-09 17:52:52 +00:00
|
|
|
ScreenSavePic = true;
|
2020-08-25 11:46:52 +00:00
|
|
|
drawscreen(Player + myconnectindex, 65536);
|
2020-09-09 17:52:52 +00:00
|
|
|
ScreenSavePic = false;
|
2020-01-14 19:44:20 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-06 19:50:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang)
|
|
|
|
{
|
|
|
|
int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff;
|
|
|
|
int dax, day, cosang, sinang, xspan, yspan, sprx, spry;
|
|
|
|
int xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang;
|
|
|
|
int xvect, yvect, xvect2, yvect2;
|
|
|
|
walltype* wal, * wal2;
|
|
|
|
spritetype* spr;
|
|
|
|
short p;
|
|
|
|
static int pspr_ndx[8] = { 0,0,0,0,0,0,0,0 };
|
|
|
|
bool sprisplayer = false;
|
|
|
|
short txt_x, txt_y;
|
|
|
|
|
|
|
|
xvect = sintable[(2048 - cang) & 2047] * czoom;
|
|
|
|
yvect = sintable[(1536 - cang) & 2047] * czoom;
|
|
|
|
xvect2 = mulscale16(xvect, yxaspect);
|
|
|
|
yvect2 = mulscale16(yvect, yxaspect);
|
|
|
|
|
|
|
|
|
|
|
|
// Draw sprites
|
|
|
|
k = Player[screenpeek].PlayerSprite;
|
|
|
|
for (i = 0; i < numsectors; i++)
|
|
|
|
for (j = headspritesect[i]; j >= 0; j = nextspritesect[j])
|
|
|
|
{
|
|
|
|
for (p = connecthead; p >= 0; p = connectpoint2[p])
|
|
|
|
{
|
|
|
|
if (Player[p].PlayerSprite == j)
|
|
|
|
{
|
|
|
|
if (sprite[Player[p].PlayerSprite].xvel > 16)
|
|
|
|
pspr_ndx[myconnectindex] = ((PlayClock >> 4) & 3);
|
2020-09-09 17:52:52 +00:00
|
|
|
sprisplayer = true;
|
2020-09-06 19:50:02 +00:00
|
|
|
|
|
|
|
goto SHOWSPRITE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gFullMap || show2dsprite[j])
|
|
|
|
{
|
|
|
|
SHOWSPRITE:
|
|
|
|
spr = &sprite[j];
|
|
|
|
|
|
|
|
PalEntry col = GPalette.BaseColors[56]; // 1=white / 31=black / 44=green / 56=pink / 128=yellow / 210=blue / 248=orange / 255=purple
|
|
|
|
if ((spr->cstat & 1) > 0)
|
|
|
|
col = GPalette.BaseColors[248];
|
|
|
|
if (j == k)
|
|
|
|
col = GPalette.BaseColors[31];
|
|
|
|
|
|
|
|
sprx = spr->x;
|
|
|
|
spry = spr->y;
|
|
|
|
|
|
|
|
k = spr->statnum;
|
|
|
|
if ((k >= 1) && (k <= 8) && (k != 2)) // Interpolate moving
|
|
|
|
{
|
|
|
|
sprx = sprite[j].x;
|
|
|
|
spry = sprite[j].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (spr->cstat & 48)
|
|
|
|
{
|
|
|
|
case 0: // Regular sprite
|
|
|
|
if (Player[p].PlayerSprite == j)
|
|
|
|
{
|
|
|
|
ox = sprx - cposx;
|
|
|
|
oy = spry - cposy;
|
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
|
|
|
|
|
|
|
if (((gotsector[i >> 3] & (1 << (i & 7))) > 0) && (czoom > 192))
|
|
|
|
{
|
|
|
|
daang = (spr->ang - cang) & 2047;
|
|
|
|
|
|
|
|
// Special case tiles
|
|
|
|
if (spr->picnum == 3123) break;
|
|
|
|
|
|
|
|
int spnum = -1;
|
|
|
|
if (sprisplayer)
|
|
|
|
{
|
|
|
|
if (gNet.MultiGameType != MULTI_GAME_COMMBAT || j == Player[screenpeek].PlayerSprite)
|
|
|
|
spnum = 1196 + pspr_ndx[myconnectindex];
|
|
|
|
}
|
|
|
|
else spnum = spr->picnum;
|
|
|
|
|
|
|
|
double xd = ((x1 << 4) + (xdim << 15)) / 65536.;
|
|
|
|
double yd = ((y1 << 4) + (ydim << 15)) / 65536.;
|
|
|
|
double sc = mulscale16(czoom * (spr->yrepeat), yxaspect) / 32768.;
|
|
|
|
if (spnum >= 0)
|
|
|
|
{
|
2020-09-06 21:30:19 +00:00
|
|
|
DrawTexture(twod, tileGetTexture(1196 + pspr_ndx[myconnectindex], true), xd, yd, DTA_ScaleX, sc, DTA_ScaleY, sc, DTA_Rotate, daang * (-360. / 2048),
|
2020-09-06 19:50:02 +00:00
|
|
|
DTA_CenterOffsetRel, true, DTA_TranslationIndex, TRANSLATION(Translation_Remap, spr->pal), DTA_Color, shadeToLight(spr->shade),
|
|
|
|
DTA_Alpha, (spr->cstat & 2) ? 0.33 : 1., TAG_DONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16: // Rotated sprite
|
|
|
|
x1 = sprx;
|
|
|
|
y1 = spry;
|
|
|
|
tilenum = spr->picnum;
|
|
|
|
xoff = (int)tileLeftOffset(tilenum) + (int)spr->xoffset;
|
|
|
|
if ((spr->cstat & 4) > 0)
|
|
|
|
xoff = -xoff;
|
|
|
|
k = spr->ang;
|
|
|
|
l = spr->xrepeat;
|
|
|
|
dax = sintable[k & 2047] * l;
|
|
|
|
day = sintable[(k + 1536) & 2047] * l;
|
|
|
|
l = tilesiz[tilenum].x;
|
|
|
|
k = (l >> 1) + xoff;
|
|
|
|
x1 -= mulscale16(dax, k);
|
|
|
|
x2 = x1 + mulscale16(dax, l);
|
|
|
|
y1 -= mulscale16(day, k);
|
|
|
|
y2 = y1 + mulscale16(day, l);
|
|
|
|
|
|
|
|
ox = x1 - cposx;
|
|
|
|
oy = y1 - cposy;
|
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
|
|
|
|
|
|
|
ox = x2 - cposx;
|
|
|
|
oy = y2 - cposy;
|
|
|
|
x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
|
|
|
|
|
|
|
drawlinergb(x1 + (xdim << 11), y1 + (ydim << 11),
|
|
|
|
x2 + (xdim << 11), y2 + (ydim << 11), col);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 32: // Floor sprite
|
|
|
|
if (automapMode == am_overlay)
|
|
|
|
{
|
|
|
|
tilenum = spr->picnum;
|
|
|
|
xoff = (int)tileLeftOffset(tilenum) + (int)spr->xoffset;
|
|
|
|
yoff = (int)tileTopOffset(tilenum) + (int)spr->yoffset;
|
|
|
|
if ((spr->cstat & 4) > 0)
|
|
|
|
xoff = -xoff;
|
|
|
|
if ((spr->cstat & 8) > 0)
|
|
|
|
yoff = -yoff;
|
|
|
|
|
|
|
|
k = spr->ang;
|
|
|
|
cosang = sintable[(k + 512) & 2047];
|
|
|
|
sinang = sintable[k];
|
|
|
|
xspan = tilesiz[tilenum].x;
|
|
|
|
xrepeat = spr->xrepeat;
|
|
|
|
yspan = tilesiz[tilenum].y;
|
|
|
|
yrepeat = spr->yrepeat;
|
|
|
|
|
|
|
|
dax = ((xspan >> 1) + xoff) * xrepeat;
|
|
|
|
day = ((yspan >> 1) + yoff) * yrepeat;
|
|
|
|
x1 = sprx + mulscale16(sinang, dax) + mulscale16(cosang, day);
|
|
|
|
y1 = spry + mulscale16(sinang, day) - mulscale16(cosang, dax);
|
|
|
|
l = xspan * xrepeat;
|
|
|
|
x2 = x1 - mulscale16(sinang, l);
|
|
|
|
y2 = y1 + mulscale16(cosang, l);
|
|
|
|
l = yspan * yrepeat;
|
|
|
|
k = -mulscale16(cosang, l);
|
|
|
|
x3 = x2 + k;
|
|
|
|
x4 = x1 + k;
|
|
|
|
k = -mulscale16(sinang, l);
|
|
|
|
y3 = y2 + k;
|
|
|
|
y4 = y1 + k;
|
|
|
|
|
|
|
|
ox = x1 - cposx;
|
|
|
|
oy = y1 - cposy;
|
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
|
|
|
|
|
|
|
ox = x2 - cposx;
|
|
|
|
oy = y2 - cposy;
|
|
|
|
x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
|
|
|
|
|
|
|
ox = x3 - cposx;
|
|
|
|
oy = y3 - cposy;
|
|
|
|
x3 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y3 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
|
|
|
|
|
|
|
ox = x4 - cposx;
|
|
|
|
oy = y4 - cposy;
|
|
|
|
x4 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y4 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
|
|
|
|
|
|
|
drawlinergb(x1 + (xdim << 11), y1 + (ydim << 11),
|
|
|
|
x2 + (xdim << 11), y2 + (ydim << 11), col);
|
|
|
|
|
|
|
|
drawlinergb(x2 + (xdim << 11), y2 + (ydim << 11),
|
|
|
|
x3 + (xdim << 11), y3 + (ydim << 11), col);
|
|
|
|
|
|
|
|
drawlinergb(x3 + (xdim << 11), y3 + (ydim << 11),
|
|
|
|
x4 + (xdim << 11), y4 + (ydim << 11), col);
|
|
|
|
|
|
|
|
drawlinergb(x4 + (xdim << 11), y4 + (ydim << 11),
|
|
|
|
x1 + (xdim << 11), y1 + (ydim << 11), col);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|