SW: Use Q16.16 for horiz.

This commit is contained in:
Mitchell Richters 2020-03-28 22:31:02 +11:00 committed by Christoph Oelckers
parent c32a8cab29
commit 2bf2055c65
13 changed files with 169 additions and 162 deletions

View file

@ -1865,7 +1865,7 @@ void PreDrawStackedWater(void)
} }
void FAF_DrawRooms(int x, int y, int z, short ang, int horiz, short sectnum) void FAF_DrawRooms(int x, int y, int z, short ang, fix16_t q16horiz, short sectnum)
{ {
short i,nexti; short i,nexti;
@ -1892,7 +1892,7 @@ void FAF_DrawRooms(int x, int y, int z, short ang, int horiz, short sectnum)
} }
} }
drawrooms(x,y,z,ang,horiz,sectnum); renderDrawRoomsQ16(x,y,z,fix16_from_int(ang),q16horiz,sectnum);
TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti) TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti)
{ {
@ -1930,7 +1930,8 @@ void
drawscreen(PLAYERp pp) drawscreen(PLAYERp pp)
{ {
extern SWBOOL DemoMode,CameraTestMode; extern SWBOOL DemoMode,CameraTestMode;
int tx, ty, tz,thoriz; int tx, ty, tz,tinthoriz;
fix16_t tq16horiz;
short tang,tsectnum; short tang,tsectnum;
short i,j; short i,j;
int bob_amt = 0; int bob_amt = 0;
@ -2013,7 +2014,7 @@ drawscreen(PLAYERp pp)
ty = camerapp->oposy + mulscale16(camerapp->posy - camerapp->oposy, smoothratio); ty = camerapp->oposy + mulscale16(camerapp->posy - camerapp->oposy, smoothratio);
tz = camerapp->oposz + mulscale16(camerapp->posz - camerapp->oposz, smoothratio); tz = camerapp->oposz + mulscale16(camerapp->posz - camerapp->oposz, smoothratio);
tang = camerapp->oang + mulscale16(((camerapp->pang + 1024 - camerapp->oang) & 2047) - 1024, smoothratio); tang = camerapp->oang + mulscale16(((camerapp->pang + 1024 - camerapp->oang) & 2047) - 1024, smoothratio);
thoriz = camerapp->ohoriz + mulscale16(camerapp->horiz - camerapp->ohoriz, smoothratio); tq16horiz = camerapp->oq16horiz + mulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio);
tsectnum = camerapp->cursectnum; tsectnum = camerapp->cursectnum;
//ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS); //ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS);
@ -2069,7 +2070,7 @@ drawscreen(PLAYERp pp)
tz = tz + quake_z; tz = tz + quake_z;
tx = tx + quake_x; tx = tx + quake_x;
ty = ty + quake_y; ty = ty + quake_y;
//thoriz = thoriz + quake_x; //tq16horiz = tq16horiz + fix16_from_int(quake_x);
tang = NORM_ANGLE(tang + quake_ang); tang = NORM_ANGLE(tang + quake_ang);
if (pp->sop_remote) if (pp->sop_remote)
@ -2083,14 +2084,17 @@ drawscreen(PLAYERp pp)
//if (TEST(camerapp->Flags, PF_VIEW_FROM_OUTSIDE)) //if (TEST(camerapp->Flags, PF_VIEW_FROM_OUTSIDE))
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE)) if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
{ {
BackView(&tx, &ty, &tz, &tsectnum, &tang, thoriz); BackView(&tx, &ty, &tz, &tsectnum, &tang, fix16_to_int(tq16horiz));
} }
else else
{ {
bob_amt = camerapp->bob_amt; bob_amt = camerapp->bob_amt;
if (DemoMode || CameraTestMode) if (DemoMode || CameraTestMode)
CameraView(camerapp, &tx, &ty, &tz, &tsectnum, &tang, &thoriz); {
tinthoriz = fix16_to_int(tq16horiz);
CameraView(camerapp, &tx, &ty, &tz, &tsectnum, &tang, &tinthoriz);
}
} }
if (!TEST(pp->Flags, PF_VIEW_FROM_CAMERA|PF_VIEW_FROM_OUTSIDE)) if (!TEST(pp->Flags, PF_VIEW_FROM_CAMERA|PF_VIEW_FROM_OUTSIDE))
@ -2099,10 +2103,10 @@ drawscreen(PLAYERp pp)
tz += camerapp->bob_z; tz += camerapp->bob_z;
// recoil only when not in camera // recoil only when not in camera
//thoriz = thoriz + camerapp->recoil_horizoff; //tq16horiz = tq16horiz + fix16_from_int(camerapp->recoil_horizoff);
thoriz = thoriz + pp->recoil_horizoff; tq16horiz = tq16horiz + fix16_from_int(pp->recoil_horizoff);
thoriz = max(thoriz, PLAYER_HORIZ_MIN); tq16horiz = fix16_max(tq16horiz, fix16_from_int(PLAYER_HORIZ_MIN));
thoriz = min(thoriz, PLAYER_HORIZ_MAX); tq16horiz = fix16_min(tq16horiz, fix16_from_int(PLAYER_HORIZ_MAX));
} }
if (r_usenewaspect) if (r_usenewaspect)
@ -2122,20 +2126,20 @@ drawscreen(PLAYERp pp)
screen->BeginScene(); screen->BeginScene();
OverlapDraw = TRUE; OverlapDraw = TRUE;
DrawOverlapRoom(tx, ty, tz, tang, thoriz, tsectnum); DrawOverlapRoom(tx, ty, tz, tang, tq16horiz, tsectnum);
OverlapDraw = FALSE; OverlapDraw = FALSE;
if (dimensionmode != 6)// && !ScreenSavePic) if (dimensionmode != 6)// && !ScreenSavePic)
{ {
// TEST this! Changed to camerapp // TEST this! Changed to camerapp
//JS_DrawMirrors(camerapp, tx, ty, tz, tang, thoriz); //JS_DrawMirrors(camerapp, tx, ty, tz, tang, tq16horiz);
JS_DrawMirrors(pp, tx, ty, tz, tang, thoriz); JS_DrawMirrors(pp, tx, ty, tz, tang, tq16horiz);
} }
// TODO: This call is redundant if the tiled overhead map is shown, but the // TODO: This call is redundant if the tiled overhead map is shown, but the
// HUD elements should be properly outputted with hardware rendering first. // HUD elements should be properly outputted with hardware rendering first.
if (!FAF_DebugView) if (!FAF_DebugView)
FAF_DrawRooms(tx, ty, tz, tang, thoriz, tsectnum); FAF_DrawRooms(tx, ty, tz, tang, tq16horiz, tsectnum);
analyzesprites(tx, ty, tz, FALSE); analyzesprites(tx, ty, tz, FALSE);
post_analyzesprites(); post_analyzesprites();

View file

@ -3041,7 +3041,7 @@ void getinput(SW_PACKET *loc)
#define MAXVEL ((NORMALKEYMOVE*2)+10) #define MAXVEL ((NORMALKEYMOVE*2)+10)
#define MAXSVEL ((NORMALKEYMOVE*2)+10) #define MAXSVEL ((NORMALKEYMOVE*2)+10)
#define MAXANGVEL 100 #define MAXANGVEL 100
#define MAXAIMVEL 128 #define MAXHORIZVEL 128
#define SET_LOC_KEY(loc, sync_num, key_test) SET(loc, ((!!(key_test)) << (sync_num))) #define SET_LOC_KEY(loc, sync_num, key_test) SET(loc, ((!!(key_test)) << (sync_num)))
static int32_t turnheldtime; static int32_t turnheldtime;
@ -3165,7 +3165,8 @@ void getinput(SW_PACKET *loc)
info.dz = (info.dz * move_scale)>>8; info.dz = (info.dz * move_scale)>>8;
info.dyaw = (info.dyaw * turn_scale)>>8; info.dyaw = (info.dyaw * turn_scale)>>8;
int32_t svel = 0, vel = 0, angvel = 0, aimvel = 0; int32_t svel = 0, vel = 0, angvel = 0;
fix16_t q16horz = 0;
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{ {
@ -3179,14 +3180,14 @@ void getinput(SW_PACKET *loc)
} }
if (mouseaim) if (mouseaim)
aimvel = -info.mousey / 64; q16horz = -fix16_div(fix16_from_int(info.mousey), fix16_from_int(64));
else else
vel = -(info.mousey >> 6); vel = -(info.mousey >> 6);
if (in_mouseflip) if (in_mouseflip)
aimvel = -aimvel; q16horz = -q16horz;
aimvel -= info.dpitch * turnamount / analogExtent; q16horz -= fix16_from_int(info.dpitch) * turnamount / analogExtent;
svel -= info.dx * keymove / analogExtent; svel -= info.dx * keymove / analogExtent;
vel -= info.dz * keymove / analogExtent; vel -= info.dz * keymove / analogExtent;
@ -3246,7 +3247,7 @@ void getinput(SW_PACKET *loc)
svel = clamp(svel, -MAXSVEL, MAXSVEL); svel = clamp(svel, -MAXSVEL, MAXSVEL);
angvel = clamp(angvel, -MAXANGVEL, MAXANGVEL); angvel = clamp(angvel, -MAXANGVEL, MAXANGVEL);
aimvel = clamp(aimvel, -MAXAIMVEL, MAXAIMVEL); q16horz = fix16_clamp(q16horz, -fix16_from_int(MAXHORIZVEL), fix16_from_int(MAXHORIZVEL));
momx = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang + 512)]); momx = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang + 512)]);
momy = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang)]); momy = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang)]);
@ -3257,7 +3258,7 @@ void getinput(SW_PACKET *loc)
loc->vel = momx; loc->vel = momx;
loc->svel = momy; loc->svel = momy;
loc->angvel = angvel; loc->angvel = angvel;
loc->aimvel = aimvel; loc->q16horz = q16horz;
if (!CommEnabled) if (!CommEnabled)
{ {

View file

@ -1070,7 +1070,7 @@ typedef struct
int16_t vel; int16_t vel;
int16_t svel; int16_t svel;
int8_t angvel; int8_t angvel;
int8_t aimvel; fix16_t q16horz;
int32_t bits; int32_t bits;
} SW_PACKET; } SW_PACKET;
#pragma pack(pop) #pragma pack(pop)
@ -1106,7 +1106,7 @@ struct PLAYERstruct
int int
oposx, oposy, oposz; oposx, oposy, oposz;
short oang; short oang;
short ohoriz; fix16_t oq16horiz;
// holds last valid move position // holds last valid move position
short lv_sectnum; short lv_sectnum;
@ -1156,7 +1156,8 @@ struct PLAYERstruct
short turn180_target; // 180 degree turn short turn180_target; // 180 degree turn
// variables that do not fit into sprite structure // variables that do not fit into sprite structure
int horizbase,horiz,horizoff,hvel,tilt,tilt_dest; int hvel,tilt,tilt_dest;
fix16_t q16horiz, q16horizbase, q16horizoff;
short recoil_amt; short recoil_amt;
short recoil_speed; short recoil_speed;
short recoil_ndx; short recoil_ndx;
@ -2435,7 +2436,7 @@ void ScreenCaptureKeys(void); // draw.c
int minigametext(int x,int y,const char *t,short dabits); // jplayer.c int minigametext(int x,int y,const char *t,short dabits); // jplayer.c
void computergetinput(int snum,SW_PACKET *syn); // jplayer.c void computergetinput(int snum,SW_PACKET *syn); // jplayer.c
void DrawOverlapRoom(int tx,int ty,int tz,short tang,int thoriz,short tsectnum); // rooms.c void DrawOverlapRoom(int tx,int ty,int tz,short tang,fix16_t tq16horiz,short tsectnum); // rooms.c
void SetupMirrorTiles(void); // rooms.c void SetupMirrorTiles(void); // rooms.c
SWBOOL FAF_Sector(short sectnum); // rooms.c SWBOOL FAF_Sector(short sectnum); // rooms.c
int GetZadjustment(short sectnum,short hitag); // rooms.c int GetZadjustment(short sectnum,short hitag); // rooms.c

View file

@ -444,7 +444,7 @@ void computergetinput(int snum, SW_PACKET *syn)
syn->vel = 0; syn->vel = 0;
syn->svel = 0; syn->svel = 0;
syn->angvel = 0; syn->angvel = 0;
syn->aimvel = 0; syn->q16horz = 0;
syn->bits = 0; syn->bits = 0;
x1 = p->posx; x1 = p->posx;
@ -596,7 +596,7 @@ void computergetinput(int snum, SW_PACKET *syn)
{ {
vec3_t hit_pos = { x1, y1, z1-PLAYER_HEIGHT }; vec3_t hit_pos = { x1, y1, z1-PLAYER_HEIGHT };
hitscan(&hit_pos,damysect,sintable[(damyang+512)&2047],sintable[damyang&2047], hitscan(&hit_pos,damysect,sintable[(damyang+512)&2047],sintable[damyang&2047],
(100-p->horiz-p->horizoff)*32,&hitinfo,CLIPMASK1); (100-fix16_to_int(p->q16horiz)-fix16_to_int(p->q16horizoff))*32,&hitinfo,CLIPMASK1);
if ((hitinfo.pos.x-x1)*(hitinfo.pos.x-x1)+(hitinfo.pos.y-y1)*(hitinfo.pos.y-y1) < 2560*2560) syn->bits &= ~(1<<SK_SHOOT); if ((hitinfo.pos.x-x1)*(hitinfo.pos.x-x1)+(hitinfo.pos.y-y1)*(hitinfo.pos.y-y1) < 2560*2560) syn->bits &= ~(1<<SK_SHOOT);
} }
@ -650,7 +650,7 @@ void computergetinput(int snum, SW_PACKET *syn)
// Below formula fails in certain cases // Below formula fails in certain cases
//syn->angvel = min(max((((daang+1024-damyang)&2047)-1024)>>1,-MAXANGVEL),MAXANGVEL); //was 127 //syn->angvel = min(max((((daang+1024-damyang)&2047)-1024)>>1,-MAXANGVEL),MAXANGVEL); //was 127
p->pang = daang; p->pang = daang;
syn->aimvel = min(max((zang-p->horiz)>>1,-PLAYER_HORIZ_MAX),PLAYER_HORIZ_MAX); syn->q16horz = min(max((zang-fix16_to_int(p->q16horiz))>>1,-PLAYER_HORIZ_MAX),PLAYER_HORIZ_MAX);
// Sets type of aiming, auto aim for bots // Sets type of aiming, auto aim for bots
syn->bits |= (1<<SK_AUTO_AIM); syn->bits |= (1<<SK_AUTO_AIM);
return; return;

View file

@ -460,14 +460,14 @@ void JS_InitMirrors(void)
// Draw a 3d screen to a specific tile // Draw a 3d screen to a specific tile
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
void drawroomstotile(int daposx, int daposy, int daposz, void drawroomstotile(int daposx, int daposy, int daposz,
short daang, int dahoriz, short dacursectnum, short tilenume) short daang, fix16_t daq16horiz, short dacursectnum, short tilenume)
{ {
TileFiles.MakeCanvas(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y); TileFiles.MakeCanvas(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y);
renderSetTarget(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y); renderSetTarget(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y);
screen->BeginScene(); screen->BeginScene();
drawrooms(daposx, daposy, daposz, daang, dahoriz, dacursectnum); drawrooms(daposx, daposy, daposz, daang, daq16horiz, dacursectnum);
analyzesprites(daposx, daposy, daposz, FALSE); analyzesprites(daposx, daposy, daposz, FALSE);
renderDrawMasks(); renderDrawMasks();
screen->FinishScene(); screen->FinishScene();
@ -524,7 +524,7 @@ short camplayerview = 1; // Don't show yourself!
// Hack job alert! // Hack job alert!
// Mirrors and cameras are maintained in the same data structure, but for hardware rendering they cannot be interleaved. // Mirrors and cameras are maintained in the same data structure, but for hardware rendering they cannot be interleaved.
// So this function replicates JS_DrawMirrors to only process the camera textures but not change any global state. // So this function replicates JS_DrawMirrors to only process the camera textures but not change any global state.
void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz) void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, short tpang, fix16_t tpq16horiz)
{ {
int j, cnt; int j, cnt;
int dist; int dist;
@ -717,7 +717,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz
} }
} }
void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz) void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, fix16_t tpq16horiz)
{ {
int j, cnt; int j, cnt;
int dist; int dist;
@ -852,7 +852,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz
if (mirror[cnt].campic != -1) if (mirror[cnt].campic != -1)
tileDelete(mirror[cnt].campic); tileDelete(mirror[cnt].campic);
drawrooms(dx, dy, dz, tpang, tphoriz, sp->sectnum + MAXSECTORS); renderDrawRoomsQ16(dx, dy, dz, fix16_from_int(tpang), tpq16horiz, sp->sectnum + MAXSECTORS);
analyzesprites(dx, dy, dz, FALSE); analyzesprites(dx, dy, dz, FALSE);
renderDrawMasks(); renderDrawMasks();
} }
@ -866,10 +866,10 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz
// Must call preparemirror before drawrooms and // Must call preparemirror before drawrooms and
// completemirror after drawrooms // completemirror after drawrooms
renderPrepareMirror(tx, ty, tz, fix16_from_int(tpang), fix16_from_int(tphoriz), renderPrepareMirror(tx, ty, tz, fix16_from_int(tpang), tpq16horiz,
mirror[cnt].mirrorwall, /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang); mirror[cnt].mirrorwall, /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang);
renderDrawRoomsQ16(tposx, tposy, tz, (tang), fix16_from_int(tphoriz), mirror[cnt].mirrorsector + MAXSECTORS); renderDrawRoomsQ16(tposx, tposy, tz, (tang), tpq16horiz, mirror[cnt].mirrorsector + MAXSECTORS);
analyzesprites(tposx, tposy, tz, TRUE); analyzesprites(tposx, tposy, tz, TRUE);
renderDrawMasks(); renderDrawMasks();
@ -882,7 +882,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz
// g_visibility = tvisibility; // g_visibility = tvisibility;
// g_visibility = NormalVisibility; // g_visibility = NormalVisibility;
// drawrooms(tx, ty, tz, tpang, tphoriz, pp->cursectnum); // renderDrawRoomsQ16(tx, ty, tz, fix16_from_int(tpang), tpq16horiz, pp->cursectnum);
// Clean up anything that the camera view might have done // Clean up anything that the camera view might have done
SetFragBar(pp); SetFragBar(pp);
tileDelete(MIRROR); tileDelete(MIRROR);

View file

@ -71,8 +71,8 @@ extern SWBOOL mirrorinview;
extern short NormalVisibility; extern short NormalVisibility;
void JAnalyzeSprites(tspriteptr_t tspr); void JAnalyzeSprites(tspriteptr_t tspr);
void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz); void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, short tpang,fix16_t tpq16horiz);
void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,short tpang,int tphoriz); void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,short tpang,fix16_t tpq16horiz);
void JS_InitMirrors(void); void JS_InitMirrors(void);
void JS_InitLockouts(void); void JS_InitLockouts(void);
void JS_ToggleLockouts(void); void JS_ToggleLockouts(void);

View file

@ -1423,10 +1423,10 @@ PlayerInitChemBomb(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER); SET(wu->Flags, SPR_UNDERWATER);
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
// //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",pp->horiz, pp->horizoff, // //DSPRINTF(ds,"q16horiz %d, ho %d, ho+ho %d",fix16_to_int(pp->q16horiz), fix16_to_int(pp->q16horizoff),
// pp->horizoff + pp->horiz); // fix16_to_int(pp->q16horizoff + pp->q16horiz));
// MONO_PRINT(ds); // MONO_PRINT(ds);
oclipdist = pp->SpriteP->clipdist; oclipdist = pp->SpriteP->clipdist;
@ -1867,7 +1867,7 @@ PlayerInitCaltrops(PLAYERp pp)
// They go out at different angles // They go out at different angles
// wp->ang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25)); // wp->ang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25));
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
oclipdist = pp->SpriteP->clipdist; oclipdist = pp->SpriteP->clipdist;
pp->SpriteP->clipdist = 0; pp->SpriteP->clipdist = 0;
@ -2501,7 +2501,7 @@ InitShell(int16_t SpriteNum, int16_t ShellNum)
if (u->PlayerP) if (u->PlayerP)
{ {
wp->z += ((100 - u->PlayerP->horiz) * (HORIZ_MULT/3)); wp->z += ((100 - fix16_to_int(u->PlayerP->q16horiz)) * (HORIZ_MULT/3));
} }
switch (wu->ID) switch (wu->ID)

View file

@ -105,7 +105,7 @@ typedef struct
int32_t vel; int32_t vel;
int32_t svel; int32_t svel;
int32_t angvel; int32_t angvel;
int32_t aimvel; fix16_t q16horz;
int32_t bits; int32_t bits;
} SW_AVERAGE_PACKET; } SW_AVERAGE_PACKET;
@ -303,10 +303,10 @@ int EncodeBits(SW_PACKET *pak, SW_PACKET *old_pak, uint8_t* buf)
SET(*base_ptr, BIT(2)); SET(*base_ptr, BIT(2));
} }
if (pak->aimvel != old_pak->aimvel) if (pak->q16horz != old_pak->q16horz)
{ {
*((char *)buf) = pak->aimvel; *((char *)buf) = fix16_to_int(pak->q16horz);
buf += sizeof(pak->aimvel); buf += sizeof(fix16_to_int(pak->q16horz));
SET(*base_ptr, BIT(3)); SET(*base_ptr, BIT(3));
} }
@ -354,8 +354,8 @@ int DecodeBits(SW_PACKET *pak, SW_PACKET *old_pak, uint8_t* buf)
if (TEST(*base_ptr, BIT(3))) if (TEST(*base_ptr, BIT(3)))
{ {
pak->aimvel = *(char *)buf; pak->q16horz = fix16_from_int(*(char *)buf);
buf += sizeof(pak->aimvel); buf += sizeof(fix16_to_int(pak->q16horz));
} }
//won't work if > 4 bytes //won't work if > 4 bytes
@ -938,7 +938,7 @@ faketimerhandler(void)
AveragePacket.vel += loc.vel; AveragePacket.vel += loc.vel;
AveragePacket.svel += loc.svel; AveragePacket.svel += loc.svel;
AveragePacket.angvel += loc.angvel; AveragePacket.angvel += loc.angvel;
AveragePacket.aimvel += loc.aimvel; AveragePacket.q16horz += loc.q16horz;
SET(AveragePacket.bits, loc.bits); SET(AveragePacket.bits, loc.bits);
pp = Player + myconnectindex; pp = Player + myconnectindex;
@ -956,7 +956,7 @@ faketimerhandler(void)
loc.vel = AveragePacket.vel / MovesPerPacket; loc.vel = AveragePacket.vel / MovesPerPacket;
loc.svel = AveragePacket.svel / MovesPerPacket; loc.svel = AveragePacket.svel / MovesPerPacket;
loc.angvel = AveragePacket.angvel / MovesPerPacket; loc.angvel = AveragePacket.angvel / MovesPerPacket;
loc.aimvel = AveragePacket.aimvel / MovesPerPacket; loc.q16horz = AveragePacket.q16horz / MovesPerPacket;
loc.bits = AveragePacket.bits; loc.bits = AveragePacket.bits;
memset(&AveragePacket, 0, sizeof(AveragePacket)); memset(&AveragePacket, 0, sizeof(AveragePacket));

View file

@ -1828,7 +1828,7 @@ PlayerAutoLook(PLAYERp pp)
if ((pp->cursectnum == tempsect) || if ((pp->cursectnum == tempsect) ||
(klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) (klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)))
{ {
pp->horizoff += (((j - k) * 160) >> 16); pp->q16horizoff += fix16_from_int((((j - k) * 160) >> 16));
} }
} }
} }
@ -1837,17 +1837,17 @@ PlayerAutoLook(PLAYERp pp)
if (TEST(pp->Flags, PF_CLIMBING)) if (TEST(pp->Flags, PF_CLIMBING))
{ {
// tilt when climbing but you can't even really tell it // tilt when climbing but you can't even really tell it
if (pp->horizoff < 100) if (pp->q16horizoff < fix16_from_int(100))
pp->horizoff += (((100 - pp->horizoff) >> 3) + 1); pp->q16horizoff += fix16_from_int((((100 - fix16_to_int(pp->q16horizoff)) >> 3) + 1));
} }
else else
{ {
// Make horizoff grow towards 0 since horizoff is not modified when // Make q16horizoff grow towards 0 since q16horizoff is not modified when
// you're not on a slope // you're not on a slope
if (pp->horizoff > 0) if (pp->q16horizoff > 0)
pp->horizoff -= ((pp->horizoff >> 3) + 1); pp->q16horizoff -= fix16_from_int(((fix16_to_int(pp->q16horizoff) >> 3) + 1));
if (pp->horizoff < 0) if (pp->q16horizoff < 0)
pp->horizoff += (((-pp->horizoff) >> 3) + 1); pp->q16horizoff += fix16_from_int((((fix16_to_int(-pp->q16horizoff)) >> 3) + 1));
} }
} }
@ -1858,23 +1858,23 @@ DoPlayerHorizon(PLAYERp pp)
int i; int i;
#define HORIZ_SPEED (16) #define HORIZ_SPEED (16)
// //DSPRINTF(ds,"pp->horizoff, %d", pp->horizoff); // //DSPRINTF(ds,"fix16_to_int(pp->q16horizoff), %d", fix16_to_int(pp->q16horizoff));
// MONO_PRINT(ds); // MONO_PRINT(ds);
// Fixme: This should probably be made optional. // Fixme: This should probably be made optional.
if (cl_slopetilting) if (cl_slopetilting)
PlayerAutoLook(pp); PlayerAutoLook(pp);
if (pp->input.aimvel) if (pp->input.q16horz)
{ {
pp->horizbase += pp->input.aimvel; pp->q16horizbase += pp->input.q16horz;
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING); SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
} }
if (TEST_SYNC_KEY(pp, SK_CENTER_VIEW)) if (TEST_SYNC_KEY(pp, SK_CENTER_VIEW))
{ {
pp->horiz = pp->horizbase = 100; pp->q16horiz = pp->q16horizbase = fix16_from_int(100);
pp->horizoff = 0; pp->q16horizoff = 0;
} }
// this is the locked type // this is the locked type
@ -1883,13 +1883,13 @@ DoPlayerHorizon(PLAYERp pp)
// set looking because player is manually looking // set looking because player is manually looking
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING); SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
// adjust pp->horizon negative // adjust pp->q16horiz negative
if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN)) if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN))
pp->horizbase -= (HORIZ_SPEED/2); pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2));
// adjust pp->horizon positive // adjust pp->q16horiz positive
if (TEST_SYNC_KEY(pp, SK_SNAP_UP)) if (TEST_SYNC_KEY(pp, SK_SNAP_UP))
pp->horizbase += (HORIZ_SPEED/2); pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2));
} }
@ -1899,13 +1899,13 @@ DoPlayerHorizon(PLAYERp pp)
RESET(pp->Flags, PF_LOCK_HORIZ); RESET(pp->Flags, PF_LOCK_HORIZ);
SET(pp->Flags, PF_LOOKING); SET(pp->Flags, PF_LOOKING);
// adjust pp->horizon negative // adjust pp->q16horiz negative
if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN)) if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN))
pp->horizbase -= HORIZ_SPEED; pp->q16horizbase -= fix16_from_int(HORIZ_SPEED);
// adjust pp->horizon positive // adjust pp->q16horiz positive
if (TEST_SYNC_KEY(pp, SK_LOOK_UP)) if (TEST_SYNC_KEY(pp, SK_LOOK_UP))
pp->horizbase += HORIZ_SPEED; pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
} }
@ -1913,20 +1913,20 @@ DoPlayerHorizon(PLAYERp pp)
{ {
if (!(TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN))) if (!(TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN)))
{ {
// not pressing the pp->horiz keys // not pressing the pp->q16horiz keys
if (pp->horizbase != 100) if (pp->q16horizbase != fix16_from_int(100))
{ {
// move pp->horiz back to 100 // move pp->q16horiz back to 100
for (i = 1; i; i--) for (i = 1; i; i--)
{ {
// this formula does not work for pp->horiz = 101-103 // this formula does not work for pp->q16horiz = 101-103
pp->horizbase += 25 - (pp->horizbase >> 2); pp->q16horizbase += fix16_from_int(25 - (fix16_to_int(pp->q16horizbase) >> 2));
} }
} }
else else
{ {
// not looking anymore because pp->horiz is back at 100 // not looking anymore because pp->q16horiz is back at 100
RESET(pp->Flags, PF_LOOKING); RESET(pp->Flags, PF_LOOKING);
} }
} }
@ -1934,27 +1934,27 @@ DoPlayerHorizon(PLAYERp pp)
#if 1 #if 1
// bound the base // bound the base
pp->horizbase = max(pp->horizbase, PLAYER_HORIZ_MIN); pp->q16horizbase = fix16_max(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MIN));
pp->horizbase = min(pp->horizbase, PLAYER_HORIZ_MAX); pp->q16horizbase = fix16_min(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MAX));
// bound adjust horizoff // bound adjust q16horizoff
if (pp->horizbase + pp->horizoff < PLAYER_HORIZ_MIN) if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN))
pp->horizoff = PLAYER_HORIZ_MIN - pp->horizbase; pp->q16horizoff = fix16_from_int(PLAYER_HORIZ_MIN) - pp->q16horizbase;
else if (pp->horizbase + pp->horizoff > PLAYER_HORIZ_MAX) else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX))
pp->horizoff = PLAYER_HORIZ_MAX - pp->horizbase; pp->q16horizoff = fix16_from_int(PLAYER_HORIZ_MAX) - pp->q16horizbase;
////DSPRINTF(ds,"base %d, off %d, base + off %d",pp->horizbase, pp->horizoff, pp->horizbase + pp->horizoff); ////DSPRINTF(ds,"base %d, off %d, base + off %d",fix16_to_int(pp->q16horizbase), fix16_to_int(pp->q16horizoff), fix16_to_int(pp->q16horizbase + pp->q16horizoff));
//MONO_PRINT(ds); //MONO_PRINT(ds);
// add base and offsets // add base and offsets
pp->horiz = pp->horizbase + pp->horizoff; pp->q16horiz = pp->q16horizbase + pp->q16horizoff;
#else #else
if (pp->horizbase + pp->horizoff < PLAYER_HORIZ_MIN) if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN))
pp->horizbase += HORIZ_SPEED; pp->q16horizbase += fix16_from_int(HORIZ_SPEED);
else if (pp->horizbase + pp->horizoff > PLAYER_HORIZ_MAX) else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX))
pp->horizbase -= HORIZ_SPEED; pp->q16horizbase -= HORIZ_SPEED;
pp->horiz = pp->horizbase + pp->horizoff; pp->q16horiz = pp->q16horizbase + pp->q16horizoff;
#endif #endif
} }
@ -1986,7 +1986,7 @@ DoPlayerBob(PLAYERp pp)
// wrap bcnt // wrap bcnt
pp->bcnt &= 2047; pp->bcnt &= 2047;
// move pp->horiz up and down from 100 using sintable // move pp->q16horiz up and down from 100 using sintable
//pp->bob_z = Z((8 * sintable[pp->bcnt]) >> 14); //pp->bob_z = Z((8 * sintable[pp->bcnt]) >> 14);
pp->bob_z = mulscale14(Z(amt),sintable[pp->bcnt]); pp->bob_z = mulscale14(Z(amt),sintable[pp->bcnt]);
} }
@ -2002,7 +2002,7 @@ DoPlayerBob(PLAYERp pp)
// wrap bcnt // wrap bcnt
pp->bcnt &= 2047; pp->bcnt &= 2047;
// move pp->horiz up and down from 100 using sintable // move pp->q16horiz up and down from 100 using sintable
//pp->bob_z = Z((4 * sintable[pp->bcnt]) >> 14); //pp->bob_z = Z((4 * sintable[pp->bcnt]) >> 14);
pp->bob_z = mulscale14(Z(amt),sintable[pp->bcnt]); pp->bob_z = mulscale14(Z(amt),sintable[pp->bcnt]);
} }
@ -2036,7 +2036,7 @@ DoPlayerRecoil(PLAYERp pp)
return; return;
} }
// move pp->horiz up and down // move pp->q16horiz up and down
pp->recoil_horizoff = ((pp->recoil_amt * sintable[pp->recoil_ndx]) >> 14); pp->recoil_horizoff = ((pp->recoil_amt * sintable[pp->recoil_ndx]) >> 14);
} }
@ -6593,21 +6593,21 @@ DoPlayerBeginDie(PLAYERp pp)
int int
DoPlayerDeathHoriz(PLAYERp pp, short target, short speed) DoPlayerDeathHoriz(PLAYERp pp, short target, short speed)
{ {
if (pp->horiz > target) if (pp->q16horiz > fix16_from_int(target))
{ {
pp->horiz -= speed; pp->q16horiz -= fix16_from_int(speed);
if (pp->horiz <= target) if (pp->q16horiz <= fix16_from_int(target))
pp->horiz = target; pp->q16horiz = fix16_from_int(target);
} }
if (pp->horiz < target) if (pp->q16horiz < fix16_from_int(target))
{ {
pp->horiz += speed; pp->q16horiz += fix16_from_int(speed);
if (pp->horiz >= target) if (pp->q16horiz >= fix16_from_int(target))
pp->horiz = target; pp->q16horiz = fix16_from_int(target);
} }
return pp->horiz == target; return pp->q16horiz == fix16_from_int(target);
} }
int int
@ -6763,7 +6763,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp)
sp->yrepeat = PLAYER_NINJA_YREPEAT; sp->yrepeat = PLAYER_NINJA_YREPEAT;
//pp->tilt = 0; //pp->tilt = 0;
pp->horiz = pp->horizbase = 100; pp->q16horiz = pp->q16horizbase = fix16_from_int(100);
DoPlayerResetMovement(pp); DoPlayerResetMovement(pp);
u->ID = NINJA_RUN_R0; u->ID = NINJA_RUN_R0;
PlayerDeathReset(pp); PlayerDeathReset(pp);
@ -7441,7 +7441,7 @@ MoveSkipSavePos(void)
pp->oposy = pp->posy; pp->oposy = pp->posy;
pp->oposz = pp->posz; pp->oposz = pp->posz;
pp->oang = pp->pang; pp->oang = pp->pang;
pp->ohoriz = pp->horiz; pp->oq16horiz = pp->q16horiz;
} }
// save off stats for skip4 // save off stats for skip4
@ -7508,7 +7508,7 @@ void ChopsCheck(PLAYERp pp)
if (!M_Active() && !HelpInputMode && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1) if (!M_Active() && !HelpInputMode && !TEST(pp->Flags, PF_DEAD) && !pp->sop_riding && numplayers <= 1)
{ {
if ((pp->input.bits|pp->input.vel|pp->input.svel|pp->input.angvel|pp->input.aimvel) || if ((pp->input.bits|pp->input.vel|pp->input.svel|pp->input.angvel|pp->input.q16horz) ||
TEST(pp->Flags, PF_CLIMBING|PF_FALLING|PF_DIVING)) TEST(pp->Flags, PF_CLIMBING|PF_FALLING|PF_DIVING))
{ {
// Hit a input key or other reason to stop chops // Hit a input key or other reason to stop chops
@ -7980,7 +7980,7 @@ InitAllPlayers(void)
//getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz); //getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz);
//pfirst->posz = fz - PLAYER_HEIGHT; //pfirst->posz = fz - PLAYER_HEIGHT;
pfirst->horiz = pfirst->horizbase = 100; pfirst->q16horiz = pfirst->q16horizbase = fix16_from_int(100);
// Initialize all [MAX_SW_PLAYERS] arrays here! // Initialize all [MAX_SW_PLAYERS] arrays here!
for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++)
@ -7989,14 +7989,14 @@ InitAllPlayers(void)
pp->posy = pp->oposy = pfirst->posy; pp->posy = pp->oposy = pfirst->posy;
pp->posz = pp->oposz = pfirst->posz; pp->posz = pp->oposz = pfirst->posz;
pp->pang = pp->oang = pfirst->pang; pp->pang = pp->oang = pfirst->pang;
pp->horiz = pp->ohoriz = pfirst->horiz; pp->q16horiz = pp->oq16horiz = pfirst->q16horiz;
pp->cursectnum = pfirst->cursectnum; pp->cursectnum = pfirst->cursectnum;
// set like this so that player can trigger something on start of the level // set like this so that player can trigger something on start of the level
pp->lastcursectnum = pfirst->cursectnum+1; pp->lastcursectnum = pfirst->cursectnum+1;
//pp->MaxHealth = 100; //pp->MaxHealth = 100;
pp->horizbase = pfirst->horizbase; pp->q16horizbase = pfirst->q16horizbase;
pp->oldposx = 0; pp->oldposx = 0;
pp->oldposy = 0; pp->oldposy = 0;
pp->climb_ndx = 10; pp->climb_ndx = 10;
@ -8028,7 +8028,7 @@ InitAllPlayers(void)
pp->FadeAmt = 0; pp->FadeAmt = 0;
pp->FadeTics = 0; pp->FadeTics = 0;
pp->StartColor = 0; pp->StartColor = 0;
pp->horizoff = 0; pp->q16horizoff = 0;
INITLIST(&pp->PanelSpriteList); INITLIST(&pp->PanelSpriteList);
} }

View file

@ -45,7 +45,8 @@ PLAYERp ppp = &PredictPlayer;
typedef struct typedef struct
{ {
int x,y,z,horiz; int x,y,z;
fix16_t q16horiz;
short ang,filler; short ang,filler;
} PREDICT, *PREDICTp; } PREDICT, *PREDICTp;
@ -160,7 +161,7 @@ DoPrediction(PLAYERp ppp)
ppp->oposx = ppp->posx; ppp->oposx = ppp->posx;
ppp->oposy = ppp->posy; ppp->oposy = ppp->posy;
ppp->oposz = ppp->posz; ppp->oposz = ppp->posz;
ppp->ohoriz = ppp->horiz; ppp->oq16horiz = ppp->q16horiz;
#if PREDICT_DEBUG #if PREDICT_DEBUG
PredictDebug(ppp); PredictDebug(ppp);
@ -182,7 +183,7 @@ DoPrediction(PLAYERp ppp)
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx;
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy;
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz;
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].horiz = ppp->horiz; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].q16horiz = ppp->q16horiz;
predictmovefifoplc++; predictmovefifoplc++;
} }
@ -202,13 +203,13 @@ CorrectPrediction(int actualfifoplc)
predict->x == Player[myconnectindex].posx && predict->x == Player[myconnectindex].posx &&
predict->y == Player[myconnectindex].posy && predict->y == Player[myconnectindex].posy &&
predict->z == Player[myconnectindex].posz && predict->z == Player[myconnectindex].posz &&
predict->horiz == Player[myconnectindex].horiz predict->q16horiz == Player[myconnectindex].q16horiz
) )
{ {
return; return;
} }
// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", predict->ang, Player[myconnectindex].pang, predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, predict->horiz,Player[myconnectindex].horiz); // //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", predict->ang, Player[myconnectindex].pang, predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, fix16_to_int(predict->q16horiz),fix16_to_int(Player[myconnectindex].q16horiz));
// MONO_PRINT(ds); // MONO_PRINT(ds);
InitPrediction(&Player[myconnectindex]); InitPrediction(&Player[myconnectindex]);

View file

@ -33,7 +33,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
void FAF_DrawRooms(int posx, int posy, int posz, short ang, int horiz, short cursectnum); void FAF_DrawRooms(int posx, int posy, int posz, short ang, fix16_t q16horiz, short cursectnum);
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
@ -1089,7 +1089,7 @@ ViewSectorInScene(short cursectnum, short level)
} }
void void
DrawOverlapRoom(int tx, int ty, int tz, short tang, int thoriz, short tsectnum) DrawOverlapRoom(int tx, int ty, int tz, short tang, fix16_t tq16horiz, short tsectnum)
{ {
short i; short i;
short match; short match;
@ -1104,8 +1104,8 @@ DrawOverlapRoom(int tx, int ty, int tz, short tang, int thoriz, short tsectnum)
if (tsectnum < 0) if (tsectnum < 0)
return; return;
drawrooms(tx, ty, tz, tang, thoriz, tsectnum); renderDrawRoomsQ16(tx, ty, tz, fix16_from_int(tang), tq16horiz, tsectnum);
//FAF_DrawRooms(tx, ty, tz, tang, thoriz, tsectnum); //FAF_DrawRooms(tx, ty, tz, tang, tq16horiz, tsectnum);
// reset Z's // reset Z's
for (i = 0; i < save.zcount; i++) for (i = 0; i < save.zcount; i++)
@ -1130,8 +1130,8 @@ DrawOverlapRoom(int tx, int ty, int tz, short tang, int thoriz, short tsectnum)
if (tsectnum < 0) if (tsectnum < 0)
return; return;
drawrooms(tx, ty, tz, tang, thoriz, tsectnum); renderDrawRoomsQ16(tx, ty, tz, fix16_from_int(tang), tq16horiz, tsectnum);
//FAF_DrawRooms(tx, ty, tz, tang, thoriz, tsectnum); //FAF_DrawRooms(tx, ty, tz, ftang, tq16horiz, tsectnum);
// reset Z's // reset Z's
for (i = 0; i < save.zcount; i++) for (i = 0; i < save.zcount; i++)

View file

@ -93,7 +93,7 @@ PlayerSync2(void)
{ {
pp = Player + i; pp = Player + i;
updatecrc(crc, pp->horiz & 255); updatecrc(crc, fix16_to_int(pp->q16horiz) & 255);
updatecrc(crc, User[pp->PlayerSprite]->Health & 255); updatecrc(crc, User[pp->PlayerSprite]->Health & 255);
updatecrc(crc, pp->bcnt & 255); updatecrc(crc, pp->bcnt & 255);
} }
@ -544,7 +544,7 @@ getsyncbyte()
{ {
pp = Player + i; pp = Player + i;
u = User[pp->SpriteP - sprite]; u = User[pp->SpriteP - sprite];
ch ^= (pp->posx ^ pp->posy ^ pp->posz ^ pp->pang ^ pp->horiz ^ u->Health); ch ^= (pp->posx ^ pp->posy ^ pp->posz ^ pp->pang ^ fix16_to_int(pp->q16horiz) ^ u->Health);
} }
for (j = headspritestat[STAT_ENEMY]; j >= 0; j = nextspritestat[j]) for (j = headspritestat[STAT_ENEMY]; j >= 0; j = nextspritestat[j])

View file

@ -12841,7 +12841,7 @@ DoRing(int16_t Weapon)
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14; sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14;
if (User[sp->owner]->PlayerP) if (User[sp->owner]->PlayerP)
sp->z += (u->Dist * ((100 - pp->horiz) * HORIZ_MULT)) >> 9; sp->z += (u->Dist * ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT)) >> 9;
//sp->ang = NORM_ANGLE(sp->ang + 512); //sp->ang = NORM_ANGLE(sp->ang + 512);
//updatesector(sp->x, sp->y); //updatesector(sp->x, sp->y);
@ -12928,7 +12928,7 @@ InitSpellRing(PLAYERp pp)
// put it out there // put it out there
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14; sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14;
sp->z = pp->posz + Z(20) + ((u->Dist * ((100 - pp->horiz) * HORIZ_MULT)) >> 9); sp->z = pp->posz + Z(20) + ((u->Dist * ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT)) >> 9);
sp->ang = NORM_ANGLE(sp->ang + 512); sp->ang = NORM_ANGLE(sp->ang + 512);
@ -13467,7 +13467,7 @@ InitSpellNapalm(PLAYERp pp)
sp->xrepeat = 32; sp->xrepeat = 32;
sp->yrepeat = 32; sp->yrepeat = 32;
sp->clipdist = 0; sp->clipdist = 0;
sp->zvel = ((100 - pp->horiz) * HORIZ_MULT); sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
SET(u->Flags2, SPR2_BLUR_TAPER_FAST); SET(u->Flags2, SPR2_BLUR_TAPER_FAST);
@ -13622,7 +13622,7 @@ InitSpellMirv(PLAYERp pp)
sp->xrepeat = 72; sp->xrepeat = 72;
sp->yrepeat = 72; sp->yrepeat = 72;
sp->clipdist = 32L >> 2; sp->clipdist = 32L >> 2;
sp->zvel = ((100 - pp->horiz) * HORIZ_MULT); sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
@ -13773,7 +13773,7 @@ InitSwordAttack(PLAYERp pp)
int daz; int daz;
daang = pp->pang; daang = pp->pang;
daz = ((100 - pp->horiz) * 2000) + (RANDOM_RANGE(24000) - 12000); daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
@ -13963,7 +13963,7 @@ InitFistAttack(PLAYERp pp)
int daz; int daz;
daang = pp->pang; daang = pp->pang;
daz = ((100 - pp->horiz) * 2000) + (RANDOM_RANGE(24000) - 12000); daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
@ -14636,7 +14636,7 @@ InitStar(PLAYERp pp)
wp->clipdist = 32L >> 2; wp->clipdist = 32L >> 2;
// wp->zvel was overflowing with this calculation - had to move to a local // wp->zvel was overflowing with this calculation - had to move to a local
// long var // long var
zvel = ((100 - pp->horiz) * (HORIZ_MULT+STAR_HORIZ_ADJ)); zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ));
wu->ceiling_dist = Z(1); wu->ceiling_dist = Z(1);
wu->floor_dist = Z(1); wu->floor_dist = Z(1);
@ -14693,7 +14693,7 @@ InitStar(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np))
SET(nu->Flags, SPR_UNDERWATER); SET(nu->Flags, SPR_UNDERWATER);
zvel = ((100 - pp->horiz) * (HORIZ_MULT+STAR_HORIZ_ADJ)); zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ));
np->zvel = zvel >> 1; np->zvel = zvel >> 1;
if (MissileSetPos(nw, DoStar, 1000)) if (MissileSetPos(nw, DoStar, 1000))
@ -14757,7 +14757,7 @@ InitHeartAttack(PLAYERp pp)
sp->xrepeat = 52; sp->xrepeat = 52;
sp->yrepeat = 52; sp->yrepeat = 52;
sp->clipdist = 0; sp->clipdist = 0;
sp->zvel = ((100 - pp->horiz) * HORIZ_MULT); sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
SET(u->Flags2, SPR2_DONT_TARGET_OWNER); SET(u->Flags2, SPR2_DONT_TARGET_OWNER);
SET(sp->cstat, CSTAT_SPRITE_INVISIBLE); SET(sp->cstat, CSTAT_SPRITE_INVISIBLE);
@ -14981,7 +14981,7 @@ InitShotgun(PLAYERp pp)
} }
else else
{ {
daz = (100 - pp->horiz) * 2000; daz = (100 - fix16_to_int(pp->q16horiz)) * 2000;
daang = pp->pang; daang = pp->pang;
} }
@ -15157,7 +15157,7 @@ InitLaser(PLAYERp pp)
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// the slower the missile travels the less of a zvel it needs // the slower the missile travels the less of a zvel it needs
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel /= 4; wp->zvel /= 4;
wu->WeaponNum = u->WeaponNum; wu->WeaponNum = u->WeaponNum;
@ -15265,7 +15265,7 @@ InitRail(PLAYERp pp)
wp->yrepeat = 52; wp->yrepeat = 52;
wp->xrepeat = 52; wp->xrepeat = 52;
wp->shade = -15; wp->shade = -15;
zvel = ((100 - pp->horiz) * (HORIZ_MULT+17)); zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+17));
wu->RotNum = 5; wu->RotNum = 5;
NewStateGroup(w, &sg_Rail[0]); NewStateGroup(w, &sg_Rail[0]);
@ -15465,7 +15465,7 @@ InitRocket(PLAYERp pp)
wp->yrepeat = 90; wp->yrepeat = 90;
wp->xrepeat = 90; wp->xrepeat = 90;
wp->shade = -15; wp->shade = -15;
zvel = ((100 - pp->horiz) * (HORIZ_MULT+35)); zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+35));
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
@ -15586,7 +15586,7 @@ InitBunnyRocket(PLAYERp pp)
wp->yrepeat = 64; wp->yrepeat = 64;
wp->xrepeat = 64; wp->xrepeat = 64;
wp->shade = -15; wp->shade = -15;
zvel = ((100 - pp->horiz) * (HORIZ_MULT+35)); zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+35));
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
@ -15700,7 +15700,7 @@ InitNuke(PLAYERp pp)
wp->yrepeat = 128; wp->yrepeat = 128;
wp->xrepeat = 128; wp->xrepeat = 128;
wp->shade = -15; wp->shade = -15;
zvel = ((100 - pp->horiz) * (HORIZ_MULT-36)); zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT-36));
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// Set to red palette // Set to red palette
@ -15907,7 +15907,7 @@ InitMicro(PLAYERp pp)
wp->yrepeat = 24; wp->yrepeat = 24;
wp->xrepeat = 24; wp->xrepeat = 24;
wp->shade = -15; wp->shade = -15;
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// randomize zvelocity // randomize zvelocity
@ -17437,8 +17437,8 @@ InitTracerUzi(PLAYERp pp)
nx = pp->posx; nx = pp->posx;
ny = pp->posy; ny = pp->posy;
//nz = pp->posz + pp->bob_z + Z(8); //nz = pp->posz + pp->bob_z + Z(8);
//nz = pp->posz + pp->bob_z + Z(8) + ((100 - pp->horiz) * 72); //nz = pp->posz + pp->bob_z + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72);
nz = pp->posz + Z(8) + ((100 - pp->horiz) * 72); nz = pp->posz + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72);
// Spawn a shot // Spawn a shot
// Inserting and setting up variables // Inserting and setting up variables
@ -17456,7 +17456,7 @@ InitTracerUzi(PLAYERp pp)
wp->xrepeat = 10; wp->xrepeat = 10;
wp->shade = -40; wp->shade = -40;
wp->zvel = 0; wp->zvel = 0;
//wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); //wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->clipdist = 32 >> 2; wp->clipdist = 32 >> 2;
wu->WeaponNum = u->WeaponNum; wu->WeaponNum = u->WeaponNum;
@ -17483,7 +17483,7 @@ InitTracerUzi(PLAYERp pp)
return 0; return 0;
} }
wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
pp->SpriteP->clipdist = oclipdist; pp->SpriteP->clipdist = oclipdist;
@ -17835,7 +17835,7 @@ InitUzi(PLAYERp pp)
{ {
//daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25)); //daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25));
daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(24) - 12)); daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(24) - 12));
daz = ((100 - pp->horiz) * 2000) + (RANDOM_RANGE(24000) - 12000); daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000);
} }
@ -18010,7 +18010,7 @@ InitEMP(PLAYERp pp)
InitTracerUzi(pp); InitTracerUzi(pp);
//daz = nz = pp->posz + Z(8) + ((100 - pp->horiz) * 72); //daz = nz = pp->posz + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72);
//daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25)); //daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25));
daz = nz = pp->posz + pp->bob_z; daz = nz = pp->posz + pp->bob_z;
@ -18020,7 +18020,7 @@ InitEMP(PLAYERp pp)
} }
else else
{ {
daz = (100 - pp->horiz) * 2000; daz = (100 - fix16_to_int(pp->q16horiz)) * 2000;
daang = pp->pang; daang = pp->pang;
} }
@ -18194,7 +18194,7 @@ InitTankShell(short SpriteNum, PLAYERp pp)
SET(wp->cstat, CSTAT_SPRITE_YCENTER); SET(wp->cstat, CSTAT_SPRITE_YCENTER);
SET(wp->cstat, CSTAT_SPRITE_INVISIBLE); SET(wp->cstat, CSTAT_SPRITE_INVISIBLE);
wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
WeaponAutoAim(sp, w, 64, FALSE); WeaponAutoAim(sp, w, 64, FALSE);
// a bit of randomness // a bit of randomness
@ -18273,7 +18273,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp)
wp->yrepeat = 24; wp->yrepeat = 24;
wp->xrepeat = 24; wp->xrepeat = 24;
wp->shade = -15; wp->shade = -15;
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->clipdist = 64L>>2; wp->clipdist = 64L>>2;
// randomize zvelocity // randomize zvelocity
@ -18354,7 +18354,7 @@ InitTurretRocket(short SpriteNum, PLAYERp pp)
SET(wu->Flags2, SPR2_SO_MISSILE); SET(wu->Flags2, SPR2_SO_MISSILE);
SET(wp->cstat, CSTAT_SPRITE_YCENTER); SET(wp->cstat, CSTAT_SPRITE_YCENTER);
wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
WeaponAutoAim(sp, w, 64, FALSE); WeaponAutoAim(sp, w, 64, FALSE);
// a bit of randomness // a bit of randomness
@ -18401,7 +18401,7 @@ InitTurretFireball(short SpriteNum, PLAYERp pp)
SET(wu->Flags2, SPR2_SO_MISSILE); SET(wu->Flags2, SPR2_SO_MISSILE);
SET(wp->cstat, CSTAT_SPRITE_YCENTER); SET(wp->cstat, CSTAT_SPRITE_YCENTER);
wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8));
WeaponAutoAim(sp, w, 64, FALSE); WeaponAutoAim(sp, w, 64, FALSE);
// a bit of randomness // a bit of randomness
@ -18450,7 +18450,7 @@ InitTurretRail(short SpriteNum, PLAYERp pp)
wp->yrepeat = 52; wp->yrepeat = 52;
wp->xrepeat = 52; wp->xrepeat = 52;
wp->shade = -15; wp->shade = -15;
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wu->RotNum = 5; wu->RotNum = 5;
NewStateGroup(w, &sg_Rail[0]); NewStateGroup(w, &sg_Rail[0]);
@ -18510,7 +18510,7 @@ InitTurretLaser(short SpriteNum, PLAYERp pp)
wp->shade = -15; wp->shade = -15;
// the slower the missile travels the less of a zvel it needs // the slower the missile travels the less of a zvel it needs
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wp->zvel /= 4; wp->zvel /= 4;
wu->Radius = 200; wu->Radius = 200;
@ -18557,7 +18557,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
nsect = sp->sectnum; nsect = sp->sectnum;
if (RANDOM_P2(1024) < 200) if (RANDOM_P2(1024) < 200)
InitTracerTurret(sp - sprite, pp->PlayerSprite, pp->horiz); InitTracerTurret(sp - sprite, pp->PlayerSprite, fix16_to_int(pp->q16horiz));
daang = 64; daang = 64;
if (WeaponAutoAimHitscan(sp, &daz, &daang, FALSE) != -1) if (WeaponAutoAimHitscan(sp, &daz, &daang, FALSE) != -1)
@ -18568,7 +18568,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
else else
{ {
int horiz; int horiz;
horiz = pp->horiz; horiz = fix16_to_int(pp->q16horiz);
if (horiz < 75) if (horiz < 75)
horiz = 75; horiz = 75;
@ -19310,9 +19310,9 @@ InitGrenade(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER); SET(wu->Flags, SPR_UNDERWATER);
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",pp->horiz, pp->horizoff, pp->horizoff + pp->horiz); ////DSPRINTF(ds,"q16horiz %d, ho %d, ho+ho %d",fix16_to_int(pp->q16horiz), fix16_to_int(pp->q16horizoff), fix16_to_int(pp->q16horizoff + pp->q16horiz));
//MONO_PRINT(ds); //MONO_PRINT(ds);
oclipdist = pp->SpriteP->clipdist; oclipdist = pp->SpriteP->clipdist;
@ -19457,7 +19457,7 @@ InitMine(PLAYERp pp)
wp->xrepeat = 32; wp->xrepeat = 32;
wp->shade = -15; wp->shade = -15;
wp->clipdist = 128L>>2; wp->clipdist = 128L>>2;
wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
wu->WeaponNum = u->WeaponNum; wu->WeaponNum = u->WeaponNum;
wu->Radius = 200; wu->Radius = 200;
wu->ceiling_dist = Z(5); wu->ceiling_dist = Z(5);
@ -19470,7 +19470,7 @@ InitMine(PLAYERp pp)
if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp))
SET(wu->Flags, SPR_UNDERWATER); SET(wu->Flags, SPR_UNDERWATER);
//wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); //wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT);
MissileSetPos(w, DoMine, 800); MissileSetPos(w, DoMine, 800);
@ -19623,8 +19623,8 @@ InitFireball(PLAYERp pp)
wu->ceiling_dist = Z(6); wu->ceiling_dist = Z(6);
wu->floor_dist = Z(6); wu->floor_dist = Z(6);
//zvel = ((100 - pp->horiz) * (100+ADJUST)); //zvel = ((100 - fix16_to_int(pp->q16horiz)) * (100+ADJUST));
zvel = ((100 - pp->horiz) * (240L)); zvel = ((100 - fix16_to_int(pp->q16horiz)) * (240L));
//wu->RotNum = 5; //wu->RotNum = 5;
//NewStateGroup(w, &sg_Fireball); //NewStateGroup(w, &sg_Fireball);