diff --git a/source/sw/src/demo.cpp b/source/sw/src/demo.cpp index d835b32f8..1aacf6ff6 100644 --- a/source/sw/src/demo.cpp +++ b/source/sw/src/demo.cpp @@ -194,7 +194,7 @@ DemoWriteHeader(void) dsp.z = pp->posz; fwrite(&dsp, sizeof(dsp), 1, DemoFileOut); fwrite(&pp->Flags, sizeof(pp->Flags), 1, DemoFileOut); - fwrite(&pp->q16ang, sizeof(pp->q16ang), 1, DemoFileOut); + fwrite(&pp->pang, sizeof(pp->pang), 1, DemoFileOut); } fwrite(&Skill, sizeof(Skill), 1, DemoFileOut); @@ -252,7 +252,7 @@ DemoReadHeader(void) //pp->cursectnum = 0; //updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum); DREAD(&pp->Flags, sizeof(pp->Flags), 1, DemoFileIn); - DREAD(&pp->q16ang, sizeof(pp->q16ang), 1, DemoFileIn); + DREAD(&pp->pang, sizeof(pp->pang), 1, DemoFileIn); } DREAD(&Skill, sizeof(Skill), 1, DemoFileIn); diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 1daece273..bc026624c 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -75,6 +75,7 @@ extern short HelpPagePic[]; extern ParentalStruct aVoxelArray[MAXTILES]; extern SWBOOL RedrawScreen; SWBOOL RedrawCompass=FALSE; +extern int Follow_posx,Follow_posy; int ConnectCopySprite(uspritetype const * tsp); void PreDrawStackedWater(void); @@ -885,7 +886,7 @@ analyzesprites(int viewx, int viewy, int viewz, SWBOOL mirror) } tsp->z = tsp->z + pp->siz; - tsp->ang = fix16_to_int(pp->q16ang); + tsp->ang = pp->siang; //continue; } else @@ -1054,9 +1055,11 @@ ResizeView(PLAYERp pp) if (inputState.GetKeyStatus(KEYSC_ESC)) { + extern SWBOOL ScrollMode2D; + inputState.ClearKeyStatus(sc_Escape); dimensionmode = 3; - pp->ScrollMode2D = FALSE; + ScrollMode2D = FALSE; SetRedrawScreen(pp); } } @@ -1090,7 +1093,7 @@ ViewOutsidePlayerRecurse(PLAYERp pp, int32_t* vx, int32_t* vy, int32_t* vz, int1 *vz = pp->posz; *vsectnum = pp->cursectnum; - *ang = fix16_to_int(pp->q16ang) + pp->view_outside_dang; + *ang = pp->pang + pp->view_outside_dang; nx = sintable[NORM_ANGLE(*ang + 512 + 1024)] << 11; ny = sintable[NORM_ANGLE(*ang + 1024)] << 11; @@ -1138,7 +1141,7 @@ ViewOutsidePlayerRecurse(PLAYERp pp, int32_t* vx, int32_t* vy, int32_t* vz, int1 void -BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz) +BackView(int *nx, int *ny, int *nz, short *vsect, short *nang, short horiz) { vec3_t n = { *nx, *ny, *nz }; SPRITEp sp; @@ -1150,7 +1153,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz) ASSERT(*vsect >= 0 && *vsect < MAXSECTORS); - ang = fix16_to_int(*nq16ang) + pp->view_outside_dang; + ang = *nang + pp->view_outside_dang; // Calculate the vector (nx,ny,nz) to shoot backwards vx = (sintable[NORM_ANGLE(ang + 1536)] >> 3); @@ -1212,7 +1215,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz) flag_backup = hsp->cstat; RESET(hsp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); ASSERT(*vsect >= 0 && *vsect < MAXSECTORS); - BackView(nx, ny, nz, vsect, nq16ang, horiz); + BackView(nx, ny, nz, vsect, nang, horiz); hsp->cstat = flag_backup; return; } @@ -1253,11 +1256,11 @@ BackView(int *nx, int *ny, int *nz, short *vsect, fix16_t *nq16ang, short horiz) // Make sure vsect is correct updatesectorz(*nx, *ny, *nz, vsect); - *nq16ang = fix16_from_int(ang); + *nang = ang; } void -CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, short horiz) +CircleCamera(int *nx, int *ny, int *nz, short *vsect, short *nang, short horiz) { vec3_t n = { *nx, *ny, *nz }; SPRITEp sp; @@ -1267,7 +1270,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, short horiz) PLAYERp pp = &Player[screenpeek]; short ang; - ang = fix16_to_int(*nq16ang) + pp->circle_camera_ang; + ang = *nang + pp->circle_camera_ang; // Calculate the vector (nx,ny,nz) to shoot backwards vx = (sintable[NORM_ANGLE(ang + 1536)] >> 4); @@ -1333,7 +1336,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, short horiz) flag_backup = hsp->cstat; RESET(hsp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); - CircleCamera(nx, ny, nz, vsect, nq16ang, horiz); + CircleCamera(nx, ny, nz, vsect, nang, horiz); hsp->cstat = flag_backup; return; } @@ -1362,7 +1365,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, int *nq16ang, short horiz) // Make sure vsect is correct updatesectorz(*nx, *ny, *nz, vsect); - *nq16ang = fix16_from_int(ang); + *nang = ang; } FString GameInterface::statFPS() @@ -1394,7 +1397,7 @@ FString GameInterface::GetCoordString() out.AppendFormat("POSX:%d ", pp->posx); out.AppendFormat("POSY:%d ", pp->posy); out.AppendFormat("POSZ:%d ", pp->posz); - out.AppendFormat("ANG:%d\n", (int32_t)fix16_to_int(pp->q16ang)); + out.AppendFormat("ANG:%d\n", (int32_t)pp->pang); return out; } @@ -1573,7 +1576,7 @@ void DrawCrosshair(PLAYERp pp) } -void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fix16_t *tq16ang, fix16_t *tq16horiz) +void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, short *tang, int *thoriz) { int i,nexti; short ang; @@ -1614,7 +1617,7 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fix16_t { case 1: pp->last_camera_sp = sp; - CircleCamera(tx, ty, tz, tsectnum, tq16ang, 100); + CircleCamera(tx, ty, tz, tsectnum, tang, 100); found_camera = TRUE; break; @@ -1640,12 +1643,14 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fix16_t zvect = 0; // new horiz to player - *tq16horiz = fix16_clamp(fix16_from_int(100 - (zvect/256)), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX)); + *thoriz = 100 - (zvect/256); + *thoriz = max(*thoriz, PLAYER_HORIZ_MIN); + *thoriz = min(*thoriz, PLAYER_HORIZ_MAX); - //DSPRINTF(ds,"xvect %d,yvect %d,zvect %d,tq16horiz %d",xvect,yvect,zvect,*tq16horiz); + //DSPRINTF(ds,"xvect %d,yvect %d,zvect %d,thoriz %d",xvect,yvect,zvect,*thoriz); MONO_PRINT(ds); - *tq16ang = fix16_from_int(ang); + *tang = ang; *tx = sp->x; *ty = sp->y; *tz = sp->z; @@ -1860,7 +1865,7 @@ void PreDrawStackedWater(void) } -void FAF_DrawRooms(int x, int y, int z, fix16_t q16ang, fix16_t q16horiz, short sectnum) +void FAF_DrawRooms(int x, int y, int z, short ang, int horiz, short sectnum) { short i,nexti; @@ -1887,7 +1892,7 @@ void FAF_DrawRooms(int x, int y, int z, fix16_t q16ang, fix16_t q16horiz, short } } - renderDrawRoomsQ16(x,y,z,q16ang,q16horiz,sectnum); + drawrooms(x,y,z,ang,horiz,sectnum); TRAVERSE_SPRITE_STAT(headspritestat[STAT_CEILING_FLOOR_PIC_OVERRIDE], i, nexti) { @@ -1919,14 +1924,14 @@ short ScreenSavePic = FALSE; SWBOOL PicInView(short, SWBOOL); void DoPlayerDiveMeter(PLAYERp pp); +void MoveScrollMode2D(PLAYERp pp); void drawscreen(PLAYERp pp) { extern SWBOOL DemoMode,CameraTestMode; - int tx, ty, tz; - fix16_t tq16horiz, tq16ang; - short tsectnum; + int tx, ty, tz,thoriz; + short tang,tsectnum; short i,j; int bob_amt = 0; int quake_z, quake_x, quake_y; @@ -2007,17 +2012,8 @@ drawscreen(PLAYERp pp) tx = camerapp->oposx + mulscale16(camerapp->posx - camerapp->oposx, smoothratio); ty = camerapp->oposy + mulscale16(camerapp->posy - camerapp->oposy, smoothratio); tz = camerapp->oposz + mulscale16(camerapp->posz - camerapp->oposz, smoothratio); - if (pp == Player+myconnectindex && (pp->on_vehicle || pp->sop_control || TEST(pp->Flags, PF_DEAD))) - { - tq16ang = camerapp->oq16ang + mulscale16(((camerapp->q16ang + fix16_from_int(1024) - camerapp->oq16ang) & 0x7FFFFFF) - fix16_from_int(1024), smoothratio); - tq16horiz = camerapp->oq16horiz + mulscale16(camerapp->q16horiz - camerapp->oq16horiz, smoothratio); - } - else - { - tq16ang = camerapp->q16ang; - tq16horiz = camerapp->q16horiz; - } - + tang = camerapp->oang + mulscale16(((camerapp->pang + 1024 - camerapp->oang) & 2047) - 1024, smoothratio); + thoriz = camerapp->ohoriz + mulscale16(camerapp->horiz - camerapp->ohoriz, smoothratio); tsectnum = camerapp->cursectnum; //ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS); @@ -2048,52 +2044,53 @@ drawscreen(PLAYERp pp) // with "last valid" code this should never happen // ASSERT(tsectnum >= 0 && tsectnum <= MAXSECTORS); - if (pp->sop_riding || pp->sop_control) - { - if (pp->sop_control && !InterpolateSectObj) - { - tx = pp->posx; - ty = pp->posy; - tz = pp->posz; - tq16ang = pp->q16ang; - } - tsectnum = pp->cursectnum; - updatesectorz(tx, ty, tz, &tsectnum); - } - pp->six = tx; pp->siy = ty; pp->siz = tz - pp->posz; + pp->siang = tang; + + if (pp->sop_riding || pp->sop_control) + { + tx = pp->posx; + ty = pp->posy; + tz = pp->posz; + tang = pp->pang; + tsectnum = pp->cursectnum; + updatesectorz(tx, ty, tz, &tsectnum); + + pp->six = tx; + pp->siy = ty; + pp->siz = tz - pp->posz; + pp->siang = tang; + } QuakeViewChange(camerapp, &quake_z, &quake_x, &quake_y, &quake_ang); VisViewChange(camerapp, &g_visibility); tz = tz + quake_z; tx = tx + quake_x; ty = ty + quake_y; - //tq16horiz = tq16horiz + fix16_from_int(quake_x); - tq16ang = fix16_sadd(tq16ang, fix16_from_int(quake_ang)) & 0x7FFFFFF; + //thoriz = thoriz + quake_x; + tang = NORM_ANGLE(tang + quake_ang); if (pp->sop_remote) { if (TEST_BOOL1(pp->remote_sprite)) - tq16ang = fix16_from_int(pp->remote_sprite->ang); + tang = pp->remote_sprite->ang; else - tq16ang = fix16_from_int(getangle(pp->sop_remote->xmid - tx, pp->sop_remote->ymid - ty)); + tang = getangle(pp->sop_remote->xmid - tx, pp->sop_remote->ymid - ty); } //if (TEST(camerapp->Flags, PF_VIEW_FROM_OUTSIDE)) if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE)) { - BackView(&tx, &ty, &tz, &tsectnum, &tq16ang, fix16_to_int(tq16horiz)); + BackView(&tx, &ty, &tz, &tsectnum, &tang, thoriz); } else { bob_amt = camerapp->bob_amt; if (DemoMode || CameraTestMode) - { - CameraView(camerapp, &tx, &ty, &tz, &tsectnum, &tq16ang, &tq16horiz); - } + CameraView(camerapp, &tx, &ty, &tz, &tsectnum, &tang, &thoriz); } if (!TEST(pp->Flags, PF_VIEW_FROM_CAMERA|PF_VIEW_FROM_OUTSIDE)) @@ -2102,8 +2099,10 @@ drawscreen(PLAYERp pp) tz += camerapp->bob_z; // recoil only when not in camera - //tq16horiz = fix16_clamp(fix16_sadd(tq16horiz, fix16_from_int(camerapp->recoil_horizoff)), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX)); - tq16horiz = fix16_clamp(fix16_sadd(tq16horiz, fix16_from_int(pp->recoil_horizoff)), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX)); + //thoriz = thoriz + camerapp->recoil_horizoff; + thoriz = thoriz + pp->recoil_horizoff; + thoriz = max(thoriz, PLAYER_HORIZ_MIN); + thoriz = min(thoriz, PLAYER_HORIZ_MAX); } if (r_usenewaspect) @@ -2118,25 +2117,25 @@ drawscreen(PLAYERp pp) if (dimensionmode != 6)// && !ScreenSavePic) { // Cameras must be done before the main loop. - JS_DrawCameras(pp, tx, ty, tz); + JS_DrawCameras(pp, tx, ty, tz, tang, thoriz); } screen->BeginScene(); OverlapDraw = TRUE; - DrawOverlapRoom(tx, ty, tz, tq16ang, tq16horiz, tsectnum); + DrawOverlapRoom(tx, ty, tz, tang, thoriz, tsectnum); OverlapDraw = FALSE; if (dimensionmode != 6)// && !ScreenSavePic) { // TEST this! Changed to camerapp - //JS_DrawMirrors(camerapp, tx, ty, tz, tq16ang, tq16horiz); - JS_DrawMirrors(pp, tx, ty, tz, tq16ang, tq16horiz); + //JS_DrawMirrors(camerapp, tx, ty, tz, tang, thoriz); + JS_DrawMirrors(pp, tx, ty, tz, tang, thoriz); } // 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) - FAF_DrawRooms(tx, ty, tz, tq16ang, tq16horiz, tsectnum); + FAF_DrawRooms(tx, ty, tz, tang, thoriz, tsectnum); analyzesprites(tx, ty, tz, FALSE); post_analyzesprites(); @@ -2187,10 +2186,12 @@ drawscreen(PLAYERp pp) if ((dimensionmode == 5 || dimensionmode == 6) && pp == Player+myconnectindex) { - if (pp->ScrollMode2D) + extern SWBOOL ScrollMode2D; + + if (ScrollMode2D) { - tx = pp->mfposx; - ty = pp->mfposy; + tx = Follow_posx; + ty = Follow_posy; } for (j = 0; j < MAXSPRITES; j++) @@ -2210,11 +2211,11 @@ drawscreen(PLAYERp pp) { // only clear the actual window. twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000); - renderDrawMapView(tx, ty, zoom, fix16_to_int(tq16ang)); + renderDrawMapView(tx, ty, zoom, tang); } // Draw the line map on top of texture 2d map or just stand alone - drawoverheadmap(tx, ty, zoom, fix16_to_int(tq16ang), pp->ScrollMode2D); + drawoverheadmap(tx, ty, zoom, tang); } for (j = 0; j < MAXSPRITES; j++) @@ -2259,6 +2260,8 @@ drawscreen(PLAYERp pp) if (!M_Active()) SecretInfo(pp); + videoNextPage(); + #if SYNC_TEST SyncStatMessage(); #endif @@ -2270,9 +2273,6 @@ drawscreen(PLAYERp pp) short_restoreinterpolations(); // Stick at end of drawscreen PostDraw(); - - videoNextPage(); - DrawScreen = FALSE; } @@ -2345,7 +2345,7 @@ DrawCompass(PLAYERp pp) if (gs.BorderNum < BORDER_BAR || pp - Player != screenpeek) return; - ang = fix16_to_int(pp->q16ang); + ang = pp->pang; if (pp->sop_remote) ang = 0; diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index c60f87b52..25fdbcc51 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -52,7 +52,6 @@ Things required to make savegames work: #include "names2.h" #include "panel.h" #include "game.h" -#include "interp.h" #include "tags.h" #include "sector.h" #include "sprite.h" @@ -147,6 +146,7 @@ char DemoText[3][64]; int DemoTextYstart = 0; SWBOOL DoubleInitAWE32 = FALSE; +int Follow_posx=0,Follow_posy=0; SWBOOL NoMeters = FALSE; short IntroAnimCount = 0; @@ -186,8 +186,8 @@ SWBOOL NoDemoStartup = FALSE; SWBOOL FirstTimeIntoGame; SWBOOL BorderAdjust = FALSE; -SWBOOL InterpolateSectObj; SWBOOL LocationInfo = 0; +void drawoverheadmap(int cposx, int cposy, int czoom, short cang); int DispFrameRate = FALSE; int DispMono = TRUE; int Fog = FALSE; @@ -228,6 +228,7 @@ SWBOOL PauseMode = FALSE; SWBOOL PauseKeySet = FALSE; SWBOOL SlowMode = FALSE; SWBOOL FrameAdvanceTics = 3; +SWBOOL ScrollMode2D = FALSE; SWBOOL DebugSO = FALSE; SWBOOL DebugPanel = FALSE; @@ -275,8 +276,6 @@ uint8_t DebugPrintColor = 255; int krandcount; -SW_PACKET localInput; - /// L O C A L P R O T O T Y P E S ///////////////////////////////////////////////////////// void BOT_DeleteAllBots(void); void BotPlayerInsert(PLAYERp pp); @@ -286,7 +285,6 @@ void MenuLevel(void); void StatScreen(PLAYERp mpp); void InitRunLevel(void); void RunLevel(void); -void getinput(int playerNum); ///////////////////////////////////////////////////////////////////////////////////////////// static FILE *debug_fout = NULL; @@ -588,8 +586,7 @@ void TerminateGame(void) bool LoadLevel(const char *filename) { - int16_t ang; - if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &ang, &Player[0].cursectnum) == -1) + if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &Player[0].pang, &Player[0].cursectnum) == -1) { Printf("Level not found: %s", filename); return false; @@ -597,7 +594,6 @@ bool LoadLevel(const char *filename) currentLevel = &mapList[Level]; SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); STAT_NewLevel(currentLevel->labelName); - Player[0].q16ang = fix16_from_int(ang); return true; } @@ -943,7 +939,6 @@ void InitLevelGlobals(void) AnimCnt = 0; left_foot = FALSE; screenpeek = myconnectindex; - numinterpolations = short_numinterpolations = 0; gNet.TimeLimitClock = gNet.TimeLimit; @@ -951,7 +946,6 @@ void InitLevelGlobals(void) sumowasseen = FALSE; zillawasseen = FALSE; memset(BossSpriteNum,-1,sizeof(BossSpriteNum)); - InterpolateSectObj = !CommEnabled;// && !PedanticMode; } void InitLevelGlobals2(void) @@ -2392,6 +2386,48 @@ void dsprintf_null(char *str, const char *format, ...) va_list arglist; } +void MoveLoop(void) +{ + int pnum; + + getpackets(); + + if (PredictionOn && CommEnabled) + { + while (predictmovefifoplc < Player[myconnectindex].movefifoend) + { + DoPrediction(ppp); + } + } + + //While you have new input packets to process... + if (!CommEnabled) + bufferjitter = 0; + + while (Player[myconnectindex].movefifoend - movefifoplc > bufferjitter) + { + //Make sure you have at least 1 packet from everyone else + for (pnum=connecthead; pnum>=0; pnum=connectpoint2[pnum]) + { + if (movefifoplc == Player[pnum].movefifoend) + { + break; + } + } + + //Pnum is >= 0 only if last loop was broken, meaning a player wasn't caught up + if (pnum >= 0) + break; + + domovethings(); + +#if DEBUG + //if (DemoSyncRecord) + // demosync_record(); +#endif + } +} + void InitPlayerGameSettings(void) { @@ -2505,6 +2541,8 @@ void InitRunLevel(void) StartAmbientSound(); } +void faketimerhandler(); + void RunLevel(void) { InitRunLevel(); @@ -2519,45 +2557,22 @@ void RunLevel(void) handleevents(); OSD_DispatchQueued(); D_ProcessEvents(); + faketimerhandler(); if (LoadGameOutsideMoveLoop) { return; // Stop the game loop if a savegame was loaded from the menu. } - if (M_Active() || GUICapture || GamePaused) + if (M_Active()) { - ototalclock = (int)totalclock - (120 / synctics); - buttonMap.ResetButtonStates(); + ototalclock = (int)totalclock; } else { - PLAYERp const pp = Player + myconnectindex; - - while ((totalclock - ototalclock) >= synctics) - { - ototalclock += synctics; - - getinput(myconnectindex); - - auto const q16ang = fix16_to_int(pp->q16ang); - auto & input = pp->inputfifo[Player[myconnectindex].movefifoend & (MOVEFIFOSIZ - 1)]; - - input = localInput; - input.vel = mulscale9(localInput.vel, sintable[NORM_ANGLE(q16ang + 512)]) + - mulscale9(localInput.svel, sintable[NORM_ANGLE(q16ang)]); - input.svel = mulscale9(localInput.vel, sintable[NORM_ANGLE(q16ang)]) + - mulscale9(localInput.svel, sintable[NORM_ANGLE(q16ang + 1536)]); - - pp->movefifoend++; - localInput = {}; - - domovethings(); - } - - if (!pp->ScrollMode2D && !pp->on_vehicle) - getinput(myconnectindex); + MoveLoop(); } + drawscreen(Player + screenpeek); if (QuitFlag) @@ -2774,7 +2789,7 @@ void ManualPlayerInsert(PLAYERp pp) npp->posx = pp->posx; npp->posy = pp->posy; npp->posz = pp->posz; - npp->q16ang = pp->q16ang; + npp->pang = pp->pang; npp->cursectnum = pp->cursectnum; myconnectindex = numplayers; @@ -2804,7 +2819,7 @@ void BotPlayerInsert(PLAYERp pp) npp->posx = pp->posx; npp->posy = pp->posy; npp->posz = pp->posz-Z(100); - npp->q16ang = pp->q16ang; + npp->pang = pp->pang; npp->cursectnum = pp->cursectnum; //myconnectindex = numplayers; @@ -3007,15 +3022,11 @@ void PauseKey(PLAYERp pp) short MirrorDelay; -double elapsedInputTicks; -double scaleAdjustmentToInterval(double x) { return x * (120 / synctics) / (1000.0 / elapsedInputTicks); } - -void DoPlayerHorizon(PLAYERp pp, fix16_t *q16horz); - -void getinput(int const playerNum) +void getinput(SW_PACKET *loc) { int i; - PLAYERp pp = Player + playerNum; + PLAYERp pp = Player + myconnectindex; + PLAYERp newpp = Player + myconnectindex; int inv_hotkey = 0; #define TURBOTURNTIME (120/8) @@ -3025,27 +3036,26 @@ void getinput(int const playerNum) #define NORMALKEYMOVE 35 #define MAXVEL ((NORMALKEYMOVE*2)+10) #define MAXSVEL ((NORMALKEYMOVE*2)+10) -#define MAXANGVEL 1024 -#define MAXHORIZVEL 256 -#define TURN_SHIFT 4 -#define SET_LOC_KEY(bits, sync_num, key_test) SET(bits, ((!!(key_test)) << (sync_num))) +#define MAXANGVEL 100 +#define MAXAIMVEL 128 +#define SET_LOC_KEY(loc, sync_num, key_test) SET(loc, ((!!(key_test)) << (sync_num))) static int32_t turnheldtime; + int32_t momx, momy; - // reset objects. - SW_PACKET input {}; - localInput = {}; - localInput.bits = 0; - + extern SWBOOL MenuButtonAutoRun; extern SWBOOL MenuButtonAutoAim; if (Prediction && CommEnabled) { - pp = ppp; + newpp = ppp; } + // reset all syncbits + loc->bits = 0; + // MAKE SURE THIS WILL GET SET - SET_LOC_KEY(localInput.bits, SK_QUIT_GAME, MultiPlayQuitFlag); + SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag); bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming); @@ -3055,23 +3065,78 @@ void getinput(int const playerNum) // this needs to be fixed properly - as it is this can never be compatible with demo playback. if (mouseaim) - SET(Player[playerNum].Flags, PF_MOUSE_AIMING_ON); + SET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON); else - RESET(Player[playerNum].Flags, PF_MOUSE_AIMING_ON); + RESET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON); if (cl_autoaim) - SET(Player[playerNum].Flags, PF_AUTO_AIM); - else - RESET(Player[playerNum].Flags, PF_AUTO_AIM); - } + SET(Player[myconnectindex].Flags, PF_AUTO_AIM); + else + RESET(Player[myconnectindex].Flags, PF_AUTO_AIM); + } ControlInfo info; CONTROL_GetInput(&info); + + //info.dz = (info.dz * move_scale)>>8; + //info.dyaw = (info.dyaw * turn_scale)>>8; + + PauseKey(pp); + + if (PauseKeySet) + return; + + // MAP KEY + if (buttonMap.ButtonDown(gamefunc_Map)) + { + buttonMap.ClearButton(gamefunc_Map); + + // Init follow coords + Follow_posx = pp->posx; + Follow_posy = pp->posy; + + if (dimensionmode == 3) + dimensionmode = 5; + else if (dimensionmode == 5) + dimensionmode = 6; + else + { + MirrorDelay = 1; + dimensionmode = 3; + SetFragBar(pp); + ScrollMode2D = FALSE; + SetRedrawScreen(pp); + } + } + + // Toggle follow map mode on/off + if (dimensionmode == 5 || dimensionmode == 6) + { + if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode)) + { + buttonMap.ClearButton(gamefunc_Map_Follow_Mode); + ScrollMode2D = !ScrollMode2D; + Follow_posx = pp->posx; + Follow_posy = pp->posy; + } + } + + // If in 2D follow mode, scroll around using glob vars + // Tried calling this in domovethings, but key response it too poor, skips key presses + // Note: ScrollMode2D = Follow mode, so this get called only during follow mode + if (ScrollMode2D && pp == Player + myconnectindex && !Prediction) + MoveScrollMode2D(Player + myconnectindex); + + // !JIM! Added M_Active() so that you don't move at all while using menus + if (M_Active() || ScrollMode2D || InputMode) + return; + + SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | buttonMap.ButtonDown(gamefunc_Open))); + int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)); int32_t turnamount; int32_t keymove; - constexpr int analogTurnAmount = (NORMALTURN << 1); constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp if (running) @@ -3093,178 +3158,58 @@ void getinput(int const playerNum) keymove = NORMALKEYMOVE; } - PauseKey(pp); - - if (PauseKeySet) - return; - - // MAP KEY - if (buttonMap.ButtonDown(gamefunc_Map)) - { - buttonMap.ClearButton(gamefunc_Map); - - // Init follow coords - pp->mfposx = pp->posx; - pp->mfposy = pp->posy; - - if (dimensionmode == 3) - dimensionmode = 5; - else if (dimensionmode == 5) - dimensionmode = 6; - else - { - MirrorDelay = 1; - dimensionmode = 3; - SetFragBar(pp); - pp->ScrollMode2D = FALSE; - SetRedrawScreen(pp); - } - } - - // Toggle follow map mode on/off - if (dimensionmode == 5 || dimensionmode == 6) - { - if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode)) - { - buttonMap.ClearButton(gamefunc_Map_Follow_Mode); - pp->ScrollMode2D = !pp->ScrollMode2D; - pp->mfposx = pp->posx; - pp->mfposy = pp->posy; - } - } - - // If in 2D follow mode, scroll around. - if (pp->ScrollMode2D && !Prediction) - { - keymove = keymove / 2; - - if (M_Active()) - return; - - // Recenter view if told - if (buttonMap.ButtonDown(gamefunc_Center_View)) - { - pp->mfposx = pp->posx; - pp->mfposy = pp->posy; - } - - // Toggle follow map mode on/off - if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode)) - { - buttonMap.ClearButton(gamefunc_Map_Follow_Mode); - pp->ScrollMode2D = !pp->ScrollMode2D; - // Reset coords - pp->mfposx = pp->posx; - pp->mfposy = pp->posy; - } - - if (buttonMap.ButtonDown(gamefunc_Strafe)) - input.svel -= info.dyaw>>2; - - input.svel -= info.dx>>2; - input.vel = -info.dz>>2; - - if (!ConPanel) - { - if (!HelpInputMode) - { - if (buttonMap.ButtonDown(gamefunc_Turn_Left)) - input.svel += keymove; - - if (buttonMap.ButtonDown(gamefunc_Turn_Right)) - input.svel += -keymove; - - if (buttonMap.ButtonDown(gamefunc_Move_Forward)) - input.vel += keymove; - - if (buttonMap.ButtonDown(gamefunc_Move_Backward)) - input.vel += -keymove; - } - - if (!InputMode) - { - if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) - input.svel += keymove; - - if (buttonMap.ButtonDown(gamefunc_Strafe_Right)) - input.svel += -keymove; - } - } - - input.vel = clamp(input.vel, -MAXVEL, MAXVEL); - input.svel = clamp(input.svel, -MAXSVEL, MAXSVEL); - - pp->mfposx += mulscale9(input.vel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + 512)]) + - mulscale9(input.svel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang))]); - pp->mfposy += mulscale9(input.vel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang))]) + - mulscale9(input.svel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + 1536)]); - - pp->mfposx = max(pp->mfposx, x_min_bound); - pp->mfposy = max(pp->mfposy, y_min_bound); - pp->mfposx = min(pp->mfposx, x_max_bound); - pp->mfposy = min(pp->mfposy, y_max_bound); - } - - // !JIM! Added M_Active() so that you don't move at all while using menus - if (M_Active() || pp->ScrollMode2D || InputMode) - return; - - SET_LOC_KEY(localInput.bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | buttonMap.ButtonDown(gamefunc_Open))); - info.dz = (info.dz * move_scale)>>8; info.dyaw = (info.dyaw * turn_scale)>>8; + int32_t svel = 0, vel = 0, angvel = 0, aimvel = 0; + if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) { - input.svel = -info.mousex; - input.svel -= info.dyaw * keymove / analogExtent; + svel = -info.mousex; + svel -= info.dyaw * keymove / analogExtent; } else { - input.q16avel = fix16_sadd(input.q16avel, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32))); - input.q16avel = fix16_sadd(input.q16avel, fix16_from_int(info.dyaw * analogTurnAmount / (analogExtent >> 1))); + angvel = info.mousex / 32; + angvel += info.dyaw * (turnamount << 1) / analogExtent; } if (mouseaim) - input.q16horz = fix16_sadd(input.q16horz, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_int(64))); + aimvel = -info.mousey / 64; else - input.vel = -(info.mousey >> 6); + vel = -(info.mousey >> 6); - if (!in_mouseflip) - input.q16horz = -input.q16horz; + if (in_mouseflip) + aimvel = -aimvel; - input.q16horz = fix16_ssub(input.q16horz, fix16_from_int(info.dpitch * analogTurnAmount / analogExtent)); - input.svel -= info.dx * keymove / analogExtent; - input.vel -= info.dz * keymove / analogExtent; - - static double lastInputTicks; - - auto const currentHiTicks = timerGetHiTicks(); - elapsedInputTicks = currentHiTicks - lastInputTicks; - - lastInputTicks = currentHiTicks; + aimvel -= info.dpitch * turnamount / analogExtent; + svel -= info.dx * keymove / analogExtent; + vel -= info.dz * keymove / analogExtent; if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) { - if (!localInput.svel) - { - if (buttonMap.ButtonDown(gamefunc_Turn_Left) && !localInput.svel) - input.svel = keymove; - if (buttonMap.ButtonDown(gamefunc_Turn_Right) && !localInput.svel) - input.svel = -keymove; - } + if (buttonMap.ButtonDown(gamefunc_Turn_Left)) + svel -= -keymove; + if (buttonMap.ButtonDown(gamefunc_Turn_Right)) + svel -= keymove; } else { if (buttonMap.ButtonDown(gamefunc_Turn_Left)) { turnheldtime += synctics; - input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN))); + if (turnheldtime >= TURBOTURNTIME) + angvel -= turnamount; + else + angvel -= PREAMBLETURN; } else if (buttonMap.ButtonDown(gamefunc_Turn_Right)) { turnheldtime += synctics; - input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN))); + if (turnheldtime >= TURBOTURNTIME) + angvel += turnamount; + else + angvel += PREAMBLETURN; } else { @@ -3272,119 +3217,43 @@ void getinput(int const playerNum) } } - if (localInput.svel < keymove && localInput.svel > -keymove) - { - if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !pp->sop) - input.svel += keymove; + if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !pp->sop) + svel += keymove; - if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !pp->sop) - input.svel += -keymove; + if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !pp->sop) + svel += -keymove; + + if (buttonMap.ButtonDown(gamefunc_Move_Forward)) + { + vel += keymove; + //DSPRINTF(ds,"vel key %d",vel); + //DebugWriteString(ds); + } + else + { + //DSPRINTF(ds,"vel %d",vel); + //DebugWriteString(ds); } - if (localInput.vel < keymove && localInput.vel > -keymove) - { - if (buttonMap.ButtonDown(gamefunc_Move_Forward)) - input.vel += keymove; + if (buttonMap.ButtonDown(gamefunc_Move_Backward)) + vel += -keymove; - if (buttonMap.ButtonDown(gamefunc_Move_Backward)) - input.vel += -keymove; - } + vel = clamp(vel, -MAXVEL, MAXVEL); + svel = clamp(svel, -MAXSVEL, MAXSVEL); - localInput.vel = clamp(localInput.vel + input.vel, -MAXVEL, MAXVEL); - localInput.svel = clamp(localInput.svel + input.svel, -MAXSVEL, MAXSVEL); + angvel = clamp(angvel, -MAXANGVEL, MAXANGVEL); + aimvel = clamp(aimvel, -MAXAIMVEL, MAXAIMVEL); - localInput.q16avel = fix16_clamp(fix16_sadd(localInput.q16avel, input.q16avel), fix16_from_int(-MAXANGVEL), fix16_from_int(MAXANGVEL)); - localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), fix16_from_int(-MAXHORIZVEL), fix16_from_int(MAXHORIZVEL)); + momx = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang + 512)]); + momy = mulscale9(vel, sintable[NORM_ANGLE(newpp->pang)]); - // actually snap - SET_LOC_KEY(localInput.bits, SK_SNAP_UP, buttonMap.ButtonDown(gamefunc_Aim_Up)); - SET_LOC_KEY(localInput.bits, SK_SNAP_DOWN, buttonMap.ButtonDown(gamefunc_Aim_Down)); + momx += mulscale9(svel, sintable[NORM_ANGLE(newpp->pang)]); + momy += mulscale9(svel, sintable[NORM_ANGLE(newpp->pang + 1536)]); - // actually just look - SET_LOC_KEY(localInput.bits, SK_LOOK_UP, buttonMap.ButtonDown(gamefunc_Look_Up)); - SET_LOC_KEY(localInput.bits, SK_LOOK_DOWN, buttonMap.ButtonDown(gamefunc_Look_Down)); - - SET_LOC_KEY(localInput.bits, SK_CENTER_VIEW, buttonMap.ButtonDown(gamefunc_Center_View)); - SET_LOC_KEY(localInput.bits, SK_TURN_180, buttonMap.ButtonDown(gamefunc_TurnAround)); - - pp->on_vehicle = P_CheckOperatingVehicle(pp); - - if (!TEST(pp->Flags, PF_DEAD) && !pp->on_vehicle) - { - if (!TEST(pp->Flags, PF_CLIMBING)) - { - if (!TEST(pp->Flags, PF_TURN_180)) - { - if (TEST_SYNC_KEY(pp, SK_TURN_180)) - { - if (FLAG_KEY_PRESSED(pp, SK_TURN_180)) - { - fix16_t delta_q16ang; - - FLAG_KEY_RELEASE(pp, SK_TURN_180); - - pp->turn180_target = fix16_sadd(pp->q16ang, fix16_from_int(1024)) & 0x7FFFFFF; - - // make the first turn in the clockwise direction - // the rest will follow - delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang); - - pp->q16ang = fix16_sadd(pp->q16ang, fix16_max(fix16_one, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_sdiv(fix16_abs(delta_q16ang), fix16_from_int(TURN_SHIFT))))))) & 0x7FFFFFF; - - SET(pp->Flags, PF_TURN_180); - } - } - else - { - FLAG_KEY_RESET(pp, SK_TURN_180); - } - } - - if (TEST(pp->Flags, PF_TURN_180)) - { - fix16_t delta_q16ang; - - delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang); - pp->q16ang = fix16_sadd(pp->q16ang, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_sdiv(fix16_abs(delta_q16ang), fix16_from_int(TURN_SHIFT)))))) & 0x7FFFFFF; - - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); - if (!Prediction) - { - if (pp->PlayerUnderSprite >= 0) - sprite[pp->PlayerUnderSprite].ang = fix16_to_int(pp->q16ang); - } - - // get new delta to see how close we are - delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang); - - if (fix16_abs(delta_q16ang) < (fix16_one << 1)) - { - pp->q16ang = pp->turn180_target; - RESET(pp->Flags, PF_TURN_180); - } - else - return; - } - - if (input.q16avel != 0) - { - pp->q16ang = fix16_sadd(pp->q16ang, input.q16avel) & 0x7FFFFFF; - - // update players sprite angle - // NOTE: It's also updated in UpdatePlayerSprite, but needs to be - // here to cover - // all cases. - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); - if (!Prediction) - { - if (pp->PlayerUnderSprite >= 0) - sprite[pp->PlayerUnderSprite].ang = fix16_to_int(pp->q16ang); - } - } - } - - DoPlayerHorizon(pp, &localInput.q16horz); - } + loc->vel = momx; + loc->svel = momy; + loc->angvel = angvel; + loc->aimvel = aimvel; if (!CommEnabled) { @@ -3394,29 +3263,39 @@ void getinput(int const playerNum) { MenuButtonAutoAim = FALSE; if ((!!TEST(pp->Flags, PF_AUTO_AIM)) != !!cl_autoaim) - SET_LOC_KEY(localInput.bits, SK_AUTO_AIM, TRUE); + SET_LOC_KEY(loc->bits, SK_AUTO_AIM, TRUE); } #endif } else if (inputState.GetKeyStatus(sc_Pause)) { - SET_LOC_KEY(localInput.bits, SK_PAUSE, inputState.GetKeyStatus(sc_Pause)); + SET_LOC_KEY(loc->bits, SK_PAUSE, inputState.GetKeyStatus(sc_Pause)); inputState.ClearKeyStatus(sc_Pause); } - SET_LOC_KEY(localInput.bits, SK_RUN, buttonMap.ButtonDown(gamefunc_Run)); - SET_LOC_KEY(localInput.bits, SK_SHOOT, buttonMap.ButtonDown(gamefunc_Fire)); + SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, buttonMap.ButtonDown(gamefunc_Center_View)); + + SET_LOC_KEY(loc->bits, SK_RUN, buttonMap.ButtonDown(gamefunc_Run)); + SET_LOC_KEY(loc->bits, SK_SHOOT, buttonMap.ButtonDown(gamefunc_Fire)); + + // actually snap + SET_LOC_KEY(loc->bits, SK_SNAP_UP, buttonMap.ButtonDown(gamefunc_Aim_Up)); + SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, buttonMap.ButtonDown(gamefunc_Aim_Down)); + + // actually just look + SET_LOC_KEY(loc->bits, SK_LOOK_UP, buttonMap.ButtonDown(gamefunc_Look_Up)); + SET_LOC_KEY(loc->bits, SK_LOOK_DOWN, buttonMap.ButtonDown(gamefunc_Look_Down)); for (i = 0; i < MAX_WEAPONS_KEYS; i++) { if (buttonMap.ButtonDown(gamefunc_Weapon_1 + i)) { - SET(localInput.bits, i + 1); + SET(loc->bits, i + 1); break; } } - if (buttonMap.ButtonPressed(gamefunc_Next_Weapon)) + if (buttonMap.ButtonDown(gamefunc_Next_Weapon)) { USERp u = User[pp->PlayerSprite]; short next_weapon = u->WeaponNum + 1; @@ -3452,11 +3331,11 @@ void getinput(int const playerNum) } } - SET(localInput.bits, next_weapon + 1); + SET(loc->bits, next_weapon + 1); } - if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon)) + if (buttonMap.ButtonDown(gamefunc_Previous_Weapon)) { USERp u = User[pp->PlayerSprite]; short prev_weapon = u->WeaponNum - 1; @@ -3490,7 +3369,7 @@ void getinput(int const playerNum) } } - SET(localInput.bits, prev_weapon + 1); + SET(loc->bits, prev_weapon + 1); } if (buttonMap.ButtonDown(gamefunc_Alt_Weapon)) @@ -3498,7 +3377,7 @@ void getinput(int const playerNum) buttonMap.ClearButton(gamefunc_Alt_Weapon); USERp u = User[pp->PlayerSprite]; short const which_weapon = u->WeaponNum + 1; - SET(localInput.bits, which_weapon); + SET(loc->bits, which_weapon); } @@ -3516,21 +3395,23 @@ void getinput(int const playerNum) if (buttonMap.ButtonDown(gamefunc_Caltrops)) inv_hotkey = INVENTORY_CALTROPS+1; - SET(localInput.bits, inv_hotkey<bits, inv_hotkey<bits, SK_INV_USE, buttonMap.ButtonDown(gamefunc_Inventory)); - SET_LOC_KEY(localInput.bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open)); - SET_LOC_KEY(localInput.bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump)); - SET_LOC_KEY(localInput.bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch)); + SET_LOC_KEY(loc->bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open)); + SET_LOC_KEY(loc->bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump)); + SET_LOC_KEY(loc->bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch)); - SET_LOC_KEY(localInput.bits, SK_INV_LEFT, buttonMap.ButtonDown(gamefunc_Inventory_Left)); - SET_LOC_KEY(localInput.bits, SK_INV_RIGHT, buttonMap.ButtonDown(gamefunc_Inventory_Right)); + SET_LOC_KEY(loc->bits, SK_TURN_180, buttonMap.ButtonDown(gamefunc_TurnAround)); - SET_LOC_KEY(localInput.bits, SK_HIDE_WEAPON, buttonMap.ButtonDown(gamefunc_Holster_Weapon)); + SET_LOC_KEY(loc->bits, SK_INV_LEFT, buttonMap.ButtonDown(gamefunc_Inventory_Left)); + SET_LOC_KEY(loc->bits, SK_INV_RIGHT, buttonMap.ButtonDown(gamefunc_Inventory_Right)); + + SET_LOC_KEY(loc->bits, SK_HIDE_WEAPON, buttonMap.ButtonDown(gamefunc_Holster_Weapon)); // need BUTTON - SET_LOC_KEY(localInput.bits, SK_CRAWL_LOCK, inputState.GetKeyStatus(KEYSC_NUM)); + SET_LOC_KEY(loc->bits, SK_CRAWL_LOCK, inputState.GetKeyStatus(KEYSC_NUM)); if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE) { @@ -3543,7 +3424,7 @@ void getinput(int const playerNum) if (screenpeek < 0) screenpeek = connecthead; - if (dimensionmode != 2 && screenpeek == playerNum) + if (dimensionmode != 2 && screenpeek == myconnectindex) { // JBF: figure out what's going on here DoPlayerDivePalette(pp); // Check Dive again @@ -3583,7 +3464,7 @@ void getinput(int const playerNum) #define MAP_BLOCK_SPRITE (DK_BLUE + 6) -void drawoverheadmap(int cposx, int cposy, int czoom, short cang, SWBOOL ScrollMode2D) +void drawoverheadmap(int cposx, int cposy, int czoom, short 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; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 94d0338f2..dd7b93782 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -540,11 +540,11 @@ int StdRandomRange(int range); #define KENFACING_PLAYER(pp,sp) (sintable[NORM_ANGLE(sp->ang+512)]*(pp->posy-sp->y) >= sintable[NORM_ANGLE(sp-ang)]*(pp->posx-sp->x)) #define FACING_PLAYER(pp,sp) (labs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < 512) -#define PLAYER_FACING(pp,sp) (labs(GetDeltaAngle(fix16_to_int((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < 320) +#define PLAYER_FACING(pp,sp) (labs(GetDeltaAngle((pp)->pang, NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < 320) #define FACING(sp1,sp2) (labs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < 512) #define FACING_PLAYER_RANGE(pp,sp,range) (labs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < (range)) -#define PLAYER_FACING_RANGE(pp,sp,range) (labs(GetDeltaAngle(fix16_to_int((pp)->q16ang), NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < (range)) +#define PLAYER_FACING_RANGE(pp,sp,range) (labs(GetDeltaAngle((pp)->pang, NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < (range)) #define FACING_RANGE(sp1,sp2,range) (labs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < (range)) // two vectors @@ -874,8 +874,6 @@ extern int PlayerYellVocs[MAX_YELLSOUNDS]; void BossHealthMeter(void); -extern SWBOOL InterpolateSectObj; - // Global variables used for modifying variouse things from the Console /////////////////////////////////////////////////////////////////////////////////////////// @@ -1060,7 +1058,8 @@ typedef struct { int16_t vel; int16_t svel; - fix16_t q16horz, q16avel; + int8_t angvel; + int8_t aimvel; int32_t bits; } SW_PACKET; @@ -1094,10 +1093,8 @@ struct PLAYERstruct // interpolation int oposx, oposy, oposz; - fix16_t oq16horiz, oq16ang; - - // Map follow mode pos values. - int32_t mfposx, mfposy; + short oang; + short ohoriz; // holds last valid move position short lv_sectnum; @@ -1121,6 +1118,7 @@ struct PLAYERstruct int camera_dist; // view mode dist int circle_camera_dist; int six,siy,siz; // save player interp position for PlayerSprite + short siang; int xvect, yvect; int oxvect, oyvect; @@ -1131,6 +1129,8 @@ struct PLAYERstruct int drive_angvel; int drive_oangvel; + + // scroll 2D mode stuff int scr_x, scr_y, oscr_x, oscr_y; int scr_xvect, scr_yvect; @@ -1140,12 +1140,11 @@ struct PLAYERstruct short circle_camera_ang; short camera_check_time_delay; - short cursectnum,lastcursectnum; - fix16_t turn180_target; // 180 degree turn + short pang,cursectnum,lastcursectnum; + short turn180_target; // 180 degree turn // variables that do not fit into sprite structure - int hvel,tilt,tilt_dest; - fix16_t q16horiz, q16horizbase, q16horizoff, q16ang; + int horizbase,horiz,horizoff,hvel,tilt,tilt_dest; short recoil_amt; short recoil_speed; short recoil_ndx; @@ -1153,7 +1152,7 @@ struct PLAYERstruct int oldposx,oldposy,oldposz; int RevolveX, RevolveY; - fix16_t RevolveDeltaAng, RevolveAng; + short RevolveDeltaAng, RevolveAng; // under vars are for wading and swimming short PlayerSprite, PlayerUnderSprite; @@ -1282,8 +1281,6 @@ struct PLAYERstruct short Reverb; // Player's current reverb setting short Heads; // Number of Accursed Heads orbiting player int PlayerVersion; - - SWBOOL on_vehicle, ScrollMode2D; }; extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; @@ -1909,6 +1906,7 @@ typedef struct extern SPIN Spin[17]; extern DOOR_AUTO_CLOSE DoorAutoClose[MAX_DOOR_AUTO_CLOSE]; +extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound; #define MAXANIM 256 typedef void ANIM_CALLBACK (ANIMp, void *); @@ -2127,7 +2125,6 @@ void SetBorder(PLAYERp pp, int); void SetFragBar(PLAYERp pp); int Distance(int x1, int y1, int x2, int y2); short GetDeltaAngle(short, short); -fix16_t GetDeltaAngleQ16(fix16_t, fix16_t); int SetActorRotation(short SpriteNum,int,int); int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]); @@ -2295,6 +2292,7 @@ extern int lockspeed,totalsynctics; #define synctics 3 #define ACTORMOVETICS (synctics<<1) #define TICSPERMOVEMENT synctics +#define FAKETIMERHANDLER() if (totalclock >= ototalclock + synctics) faketimerhandler() // subtract value from clipdist on getzrange calls #define GETZRANGE_CLIP_ADJ 8 @@ -2402,7 +2400,7 @@ int DoSkullBeginDeath(int16_t SpriteNum); // skull.c void AnimateCacheCursor(void); // game.c void TerminateGame(void); // game.c void TerminateLevel(void); // game.c -void drawoverheadmap(int cposx,int cposy,int czoom,short cang, SWBOOL ScrollMode2D); // game.c +void drawoverheadmap(int cposx,int cposy,int czoom,short cang); // game.c void DrawMenuLevelScreen(void); // game.c void DebugWriteString(char *string); // game.c void ManualPlayerInsert(PLAYERp pp); // game.c @@ -2425,7 +2423,7 @@ void ScreenCaptureKeys(void); // draw.c int minigametext(int x,int y,const char *t,short dabits); // jplayer.c void computergetinput(int snum,SW_PACKET *syn); // jplayer.c -void DrawOverlapRoom(int tx,int ty,int tz,fix16_t tq16ang,fix16_t tq16horiz,short tsectnum); // rooms.c +void DrawOverlapRoom(int tx,int ty,int tz,short tang,int thoriz,short tsectnum); // rooms.c void SetupMirrorTiles(void); // rooms.c SWBOOL FAF_Sector(short sectnum); // rooms.c int GetZadjustment(short sectnum,short hitag); // rooms.c diff --git a/source/sw/src/interp.cpp b/source/sw/src/interp.cpp index df437a003..923db284b 100644 --- a/source/sw/src/interp.cpp +++ b/source/sw/src/interp.cpp @@ -33,6 +33,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS +#define MAXINTERPOLATIONS 1024 int numinterpolations = 0, startofdynamicinterpolations = 0; int oldipos[MAXINTERPOLATIONS]; int bakipos[MAXINTERPOLATIONS]; @@ -110,12 +111,4 @@ void restoreinterpolations(void) // Stick at end of drawscreen for (i = numinterpolations - 1; i >= 0; i--) *curipos[i] = bakipos[i]; } - -void togglespriteinterpolation(spritetype *sp, int set) -{ - auto func = set ? setinterpolation : stopinterpolation; - func(&sp->x); - func(&sp->y); - func(&sp->z); -} END_SW_NS diff --git a/source/sw/src/interp.h b/source/sw/src/interp.h index 9ee3a2fe3..9b8704a9f 100644 --- a/source/sw/src/interp.h +++ b/source/sw/src/interp.h @@ -23,13 +23,6 @@ Original Source: 1997 - Frank Maddin and Jim Norwood Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- - -#ifndef INTERP_H - -#define INTERP_H - -#include "build.h" - BEGIN_SW_NS #define SHORT_MAXINTERPOLATIONS 256 @@ -38,7 +31,7 @@ extern short short_oldipos[SHORT_MAXINTERPOLATIONS]; extern short short_bakipos[SHORT_MAXINTERPOLATIONS]; extern short *short_curipos[SHORT_MAXINTERPOLATIONS]; -#define MAXINTERPOLATIONS MAXSPRITES +#define MAXINTERPOLATIONS 1024 extern int numinterpolations, startofdynamicinterpolations; extern int oldipos[MAXINTERPOLATIONS]; extern int bakipos[MAXINTERPOLATIONS]; @@ -49,12 +42,4 @@ void stopinterpolation(int *posptr); void updateinterpolations(void); void dointerpolations(int smoothratio); void restoreinterpolations(void); - -void togglespriteinterpolation(spritetype *sp, int set); - -static void FORCE_INLINE setspriteinterpolation(spritetype *sp) { togglespriteinterpolation(sp, 1); } -static void FORCE_INLINE stopspriteinterpolation(spritetype *sp) { togglespriteinterpolation(sp, 0); } - END_SW_NS - -#endif diff --git a/source/sw/src/jplayer.cpp b/source/sw/src/jplayer.cpp index a16d603f3..aa9a879bd 100644 --- a/source/sw/src/jplayer.cpp +++ b/source/sw/src/jplayer.cpp @@ -437,21 +437,21 @@ void computergetinput(int snum, SW_PACKET *syn) myx = p->posx; myy = p->posy; myz = p->posz; - myang = fix16_to_int(p->q16ang); + myang = p->pang; mycursectnum = p->cursectnum; // Reset input bits syn->vel = 0; syn->svel = 0; - syn->q16avel = 0; - syn->q16horz = 0; + syn->angvel = 0; + syn->aimvel = 0; syn->bits = 0; x1 = p->posx; y1 = p->posy; z1 = p->posz; - damyang = fix16_to_int(p->q16ang); + damyang = p->pang; damysect = sprite[p->PlayerSprite].sectnum; if ((numplayers >= 2) && (snum == myconnectindex)) { x1 = myx; y1 = myy; z1 = myz+PLAYER_HEIGHT; damyang = myang; damysect = mycursectnum; } @@ -596,7 +596,7 @@ void computergetinput(int snum, SW_PACKET *syn) { vec3_t hit_pos = { x1, y1, z1-PLAYER_HEIGHT }; hitscan(&hit_pos,damysect,sintable[(damyang+512)&2047],sintable[damyang&2047], - (100-fix16_to_int(p->q16horiz)-fix16_to_int(p->q16horizoff))*32,&hitinfo,CLIPMASK1); + (100-p->horiz-p->horizoff)*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<q16avel = fix16_from_int(min(max((((daang+1024-damyang)&2047)-1024)>>1,-MAXANGVEL),MAXANGVEL)); //was 127 - p->q16ang = fix16_from_int(daang); - syn->q16horz = fix16_clamp(fix16_sdiv(fix16_ssub(fix16_from_int(zang), p->q16horiz), fix16_from_int(2)), -fix16_from_int(PLAYER_HORIZ_MAX), fix16_from_int(PLAYER_HORIZ_MAX)); + //syn->angvel = min(max((((daang+1024-damyang)&2047)-1024)>>1,-MAXANGVEL),MAXANGVEL); //was 127 + p->pang = daang; + syn->aimvel = min(max((zang-p->horiz)>>1,-PLAYER_HORIZ_MAX),PLAYER_HORIZ_MAX); // Sets type of aiming, auto aim for bots syn->bits |= (1<vel += (x2-x1)*2047/dist; syn->svel += (y2-y1)*2047/dist; - syn->q16avel = fix16_from_int(min(max((((daang+1024-damyang)&2047)-1024)>>3,-MAXANGVEL),MAXANGVEL)); + syn->angvel = min(max((((daang+1024-damyang)&2047)-1024)>>3,-MAXANGVEL),MAXANGVEL); } else goalsprite[snum] = -1; @@ -869,7 +869,7 @@ void computergetinput(int snum, SW_PACKET *syn) daang = ((getangle(wall[wall[goalwall[snum]].point2].x-wall[goalwall[snum]].x,wall[wall[goalwall[snum]].point2].y-wall[goalwall[snum]].y)+1536)&2047); syn->vel += (x2-x1)*2047/dist; syn->svel += (y2-y1)*2047/dist; - syn->q16avel = fix16_from_int(min(max((((daang+1024-damyang)&2047)-1024)>>3,-MAXANGVEL),MAXANGVEL)); + syn->angvel = min(max((((daang+1024-damyang)&2047)-1024)>>3,-MAXANGVEL),MAXANGVEL); } @@ -890,7 +890,7 @@ void computergetinput(int snum, SW_PACKET *syn) daang = ((getangle(wall[wall[goalwall[snum]].point2].x-wall[goalwall[snum]].x,wall[wall[goalwall[snum]].point2].y-wall[goalwall[snum]].y)+1536)&2047); syn->vel += (x2-x1)*2047/dist; syn->svel += (y2-y1)*2047/dist; - syn->q16avel = fix16_from_int(min(max((((daang+1024-damyang)&2047)-1024)>>3,-MAXANGVEL),MAXANGVEL)); + syn->angvel = min(max((((daang+1024-damyang)&2047)-1024)>>3,-MAXANGVEL),MAXANGVEL); } */ } diff --git a/source/sw/src/jsector.cpp b/source/sw/src/jsector.cpp index 18bfcfc05..84829de07 100644 --- a/source/sw/src/jsector.cpp +++ b/source/sw/src/jsector.cpp @@ -460,14 +460,14 @@ void JS_InitMirrors(void) // Draw a 3d screen to a specific tile ///////////////////////////////////////////////////// void drawroomstotile(int daposx, int daposy, int daposz, - fix16_t daq16ang, fix16_t daq16horiz, short dacursectnum, short tilenume) + short daang, int dahoriz, short dacursectnum, short tilenume) { TileFiles.MakeCanvas(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y); renderSetTarget(tilenume, tilesiz[tilenume].x, tilesiz[tilenume].y); screen->BeginScene(); - renderDrawRoomsQ16(daposx, daposy, daposz, daq16ang, daq16horiz, dacursectnum); + drawrooms(daposx, daposy, daposz, daang, dahoriz, dacursectnum); analyzesprites(daposx, daposy, daposz, FALSE); renderDrawMasks(); screen->FinishScene(); @@ -524,13 +524,16 @@ short camplayerview = 1; // Don't show yourself! // Hack job alert! // 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. -void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz) +void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz) { int j, cnt; int dist; int tposx, tposy; // Camera int* longptr; + fix16_t tang; + // int tx, ty, tz, tpang; // Interpolate so mirror doesn't + // drift! SWBOOL bIsWallMirror = FALSE; camloopcnt += (int32_t)(totalclock - ototalclock); @@ -700,11 +703,11 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz) if (TEST_BOOL11(sp) && numplayers > 1) { - drawroomstotile(cp->posx, cp->posy, cp->posz, cp->q16ang, cp->q16horiz, cp->cursectnum, mirror[cnt].campic); + drawroomstotile(cp->posx, cp->posy, cp->posz, cp->pang, cp->horiz, cp->cursectnum, mirror[cnt].campic); } else { - drawroomstotile(sp->x, sp->y, sp->z, fix16_from_int(SP_TAG5(sp)), fix16_from_int(camhoriz), sp->sectnum, mirror[cnt].campic); + drawroomstotile(sp->x, sp->y, sp->z, SP_TAG5(sp), camhoriz, sp->sectnum, mirror[cnt].campic); } } } @@ -714,7 +717,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz) } } -void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16_t tpq16horiz) +void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz) { int j, cnt; int dist; @@ -752,7 +755,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16 // tx = pp->oposx + mulscale16(pp->posx - pp->oposx, smoothratio); // ty = pp->oposy + mulscale16(pp->posy - pp->oposy, smoothratio); // tz = pp->oposz + mulscale16(pp->posz - pp->oposz, smoothratio); -// tpq16ang = pp->q16ang +// tpang = pp->oang + mulscale16(((pp->pang + 1024 - pp->oang) & 2047) - 1024, smoothratio); dist = 0x7fffffff; @@ -849,7 +852,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16 if (mirror[cnt].campic != -1) tileDelete(mirror[cnt].campic); - renderDrawRoomsQ16(dx, dy, dz, tpq16ang, tpq16horiz, sp->sectnum + MAXSECTORS); + drawrooms(dx, dy, dz, tpang, tphoriz, sp->sectnum + MAXSECTORS); analyzesprites(dx, dy, dz, FALSE); renderDrawMasks(); } @@ -863,10 +866,10 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16 // Must call preparemirror before drawrooms and // completemirror after drawrooms - renderPrepareMirror(tx, ty, tz, tpq16ang, tpq16horiz, + renderPrepareMirror(tx, ty, tz, fix16_from_int(tpang), fix16_from_int(tphoriz), mirror[cnt].mirrorwall, /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang); - renderDrawRoomsQ16(tposx, tposy, tz, (tang), tpq16horiz, mirror[cnt].mirrorsector + MAXSECTORS); + renderDrawRoomsQ16(tposx, tposy, tz, (tang), fix16_from_int(tphoriz), mirror[cnt].mirrorsector + MAXSECTORS); analyzesprites(tposx, tposy, tz, TRUE); renderDrawMasks(); @@ -879,7 +882,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fix16_t tpq16ang, fix16 // g_visibility = tvisibility; // g_visibility = NormalVisibility; - // renderDrawRoomsQ16(tx, ty, tz, tpq16ang, tpq16horiz, pp->cursectnum); + // drawrooms(tx, ty, tz, tpang, tphoriz, pp->cursectnum); // Clean up anything that the camera view might have done SetFragBar(pp); tileDelete(MIRROR); diff --git a/source/sw/src/jsector.h b/source/sw/src/jsector.h index 71e660bab..be5f96ac0 100644 --- a/source/sw/src/jsector.h +++ b/source/sw/src/jsector.h @@ -71,8 +71,8 @@ extern SWBOOL mirrorinview; extern short NormalVisibility; void JAnalyzeSprites(tspriteptr_t tspr); -void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz); -void JS_DrawMirrors(PLAYERp pp,int tx,int ty,int tz,fix16_t tpq16ang,fix16_t tpq16horiz); +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_InitMirrors(void); void JS_InitLockouts(void); void JS_ToggleLockouts(void); diff --git a/source/sw/src/jweapon.cpp b/source/sw/src/jweapon.cpp index 5ddc64d93..29075c85c 100644 --- a/source/sw/src/jweapon.cpp +++ b/source/sw/src/jweapon.cpp @@ -1393,7 +1393,7 @@ PlayerInitChemBomb(PLAYERp pp) // Spawn a shot // Inserting and setting up variables w = SpawnSprite(STAT_MISSILE, CHEMBOMB, s_ChemBomb, pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), CHEMBOMB_VELOCITY); + nx, ny, nz, pp->pang, CHEMBOMB_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -1423,10 +1423,10 @@ PlayerInitChemBomb(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) SET(wu->Flags, SPR_UNDERWATER); - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); - // //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",fix16_to_int(pp->q16horiz), fix16_to_int(pp->q16horizoff), - // fix16_to_int(pp->q16horizoff + pp->q16horiz)); + // //DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",pp->horiz, pp->horizoff, + // pp->horizoff + pp->horiz); // MONO_PRINT(ds); oclipdist = pp->SpriteP->clipdist; @@ -1837,7 +1837,7 @@ PlayerInitCaltrops(PLAYERp pp) // Spawn a shot // Inserting and setting up variables w = SpawnSprite(STAT_DEAD_ACTOR, CALTROPS, s_Caltrops, pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), (CHEMBOMB_VELOCITY + RANDOM_RANGE(CHEMBOMB_VELOCITY)) / 2); + nx, ny, nz, pp->pang, (CHEMBOMB_VELOCITY + RANDOM_RANGE(CHEMBOMB_VELOCITY)) / 2); wp = &sprite[w]; wu = User[w]; @@ -1865,9 +1865,9 @@ PlayerInitCaltrops(PLAYERp pp) SET(wu->Flags, SPR_UNDERWATER); // They go out at different angles -// wp->ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(50) - 25)); +// wp->ang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25)); - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; @@ -2501,7 +2501,7 @@ InitShell(int16_t SpriteNum, int16_t ShellNum) if (u->PlayerP) { - wp->z += ((100 - fix16_to_int(u->PlayerP->q16horiz)) * (HORIZ_MULT/3)); + wp->z += ((100 - u->PlayerP->horiz) * (HORIZ_MULT/3)); } switch (wu->ID) diff --git a/source/sw/src/mclip.cpp b/source/sw/src/mclip.cpp index 959827838..056181211 100644 --- a/source/sw/src/mclip.cpp +++ b/source/sw/src/mclip.cpp @@ -58,7 +58,7 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) for (i = 0; i < sop->clipbox_num; i++) { - ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + sop->clipbox_ang[i]); + ang = NORM_ANGLE(pp->pang + sop->clipbox_ang[i]); ox[i] = x[i] = pp->posx + (sop->clipbox_vdist[i] * sintable[NORM_ANGLE(ang + 512)] >> 14); oy[i] = y[i] = pp->posy + (sop->clipbox_vdist[i] * sintable[ang] >> 14); @@ -102,7 +102,7 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) for (i = 0; i < sop->clipbox_num; i++) { - ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + sop->clipbox_ang[i]); + ang = NORM_ANGLE(pp->pang + sop->clipbox_ang[i]); ox[i] = x[i] = pp->posx + (sop->clipbox_vdist[i] * sintable[NORM_ANGLE(ang + 512)] >> 14); oy[i] = y[i] = pp->posy + (sop->clipbox_vdist[i] * sintable[ang] >> 14); @@ -153,7 +153,7 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) { // move the box to position instead of using offset- this prevents small rounding errors // allowing you to move through wall - ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + sop->clipbox_ang[i]); + ang = NORM_ANGLE(pp->pang + sop->clipbox_ang[i]); xs = pp->posx; ys = pp->posy; @@ -219,7 +219,7 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) { // move the box to position instead of using offset- this prevents small rounding errors // allowing you to move through wall - ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + sop->clipbox_ang[i]); + ang = NORM_ANGLE(pp->pang + sop->clipbox_ang[i]); xs = pp->posx; ys = pp->posy; @@ -300,7 +300,7 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist) { // move the box to position instead of using offset- this prevents small rounding errors // allowing you to move through wall - ang = NORM_ANGLE(fix16_to_int(pp->q16ang) + sop->clipbox_ang[i]); + ang = NORM_ANGLE(pp->pang + sop->clipbox_ang[i]); xs = pp->posx; ys = pp->posy; diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp index 0956b9db4..88c86e3f2 100644 --- a/source/sw/src/network.cpp +++ b/source/sw/src/network.cpp @@ -44,8 +44,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -// getinput() calls will require redoing with regard to local input changes. -// void getinput(int playerNum); +void getinput(SW_PACKET*); /* SYNC BUG NOTES: @@ -105,7 +104,8 @@ typedef struct { int32_t vel; int32_t svel; - fix16_t q16horz, q16avel; + int32_t angvel; + int32_t aimvel; int32_t bits; } SW_AVERAGE_PACKET; @@ -282,7 +282,6 @@ int EncodeBits(SW_PACKET *pak, SW_PACKET *old_pak, uint8_t* buf) *buf = 0; buf++; - // TODO: Properly copy the values in a cross-platform manner if (pak->vel != old_pak->vel) { *((short *)buf) = pak->vel; @@ -297,17 +296,17 @@ int EncodeBits(SW_PACKET *pak, SW_PACKET *old_pak, uint8_t* buf) SET(*base_ptr, BIT(1)); } - if (pak->q16avel != old_pak->q16avel) + if (pak->angvel != old_pak->angvel) { - *((fix16_t *)buf) = pak->q16avel; - buf += sizeof(pak->q16avel); + *((char *)buf) = pak->angvel; + buf += sizeof(pak->angvel); SET(*base_ptr, BIT(2)); } - if (pak->q16horz != old_pak->q16horz) + if (pak->aimvel != old_pak->aimvel) { - *((fix16_t *)buf) = pak->q16horz; - buf += sizeof(pak->q16horz); + *((char *)buf) = pak->aimvel; + buf += sizeof(pak->aimvel); SET(*base_ptr, BIT(3)); } @@ -335,7 +334,6 @@ int DecodeBits(SW_PACKET *pak, SW_PACKET *old_pak, uint8_t* buf) *pak = *old_pak; - // TODO: Properly copy the values in a cross-platform manner if (TEST(*base_ptr, BIT(0))) { pak->vel = *(short *)buf; @@ -350,14 +348,14 @@ int DecodeBits(SW_PACKET *pak, SW_PACKET *old_pak, uint8_t* buf) if (TEST(*base_ptr, BIT(2))) { - pak->q16avel = *(fix16_t *)buf; - buf += sizeof(pak->q16avel); + pak->angvel = *(char *)buf; + buf += sizeof(pak->angvel); } if (TEST(*base_ptr, BIT(3))) { - pak->q16horz = *(fix16_t *)buf; - buf += sizeof(pak->q16horz); + pak->aimvel = *(char *)buf; + buf += sizeof(pak->aimvel); } //won't work if > 4 bytes @@ -935,13 +933,12 @@ faketimerhandler(void) if (Player[myconnectindex].movefifoend - movefifoplc >= 100) return; - // getinput() calls will require redoing with regard to local input changes. - // getinput(&loc); + getinput(&loc); AveragePacket.vel += loc.vel; AveragePacket.svel += loc.svel; - AveragePacket.q16avel += loc.q16avel; - AveragePacket.q16horz += loc.q16horz; + AveragePacket.angvel += loc.angvel; + AveragePacket.aimvel += loc.aimvel; SET(AveragePacket.bits, loc.bits); pp = Player + myconnectindex; @@ -958,8 +955,8 @@ faketimerhandler(void) loc.vel = AveragePacket.vel / MovesPerPacket; loc.svel = AveragePacket.svel / MovesPerPacket; - loc.q16avel = AveragePacket.q16avel / fix16_from_int(MovesPerPacket); - loc.q16horz = AveragePacket.q16horz / fix16_from_int(MovesPerPacket); + loc.angvel = AveragePacket.angvel / MovesPerPacket; + loc.aimvel = AveragePacket.aimvel / MovesPerPacket; loc.bits = AveragePacket.bits; memset(&AveragePacket, 0, sizeof(AveragePacket)); diff --git a/source/sw/src/ninja.cpp b/source/sw/src/ninja.cpp index ed6c0999f..056724c2d 100644 --- a/source/sw/src/ninja.cpp +++ b/source/sw/src/ninja.cpp @@ -2405,7 +2405,7 @@ InitPlayerSprite(PLAYERp pp) COVER_SetReverb(0); // Turn off any echoing that may have been going before pp->Reverb = 0; sp_num = pp->PlayerSprite = SpawnSprite(STAT_PLAYER0 + pnum, NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx, - pp->posy, pp->posz, fix16_to_int(pp->q16ang), 0); + pp->posy, pp->posz, pp->pang, 0); pp->SpriteP = sp = &sprite[sp_num]; pp->pnum = pnum; @@ -2481,7 +2481,7 @@ SpawnPlayerUnderSprite(PLAYERp pp) int pnum = pp - Player, sp_num; sp_num = pp->PlayerUnderSprite = SpawnSprite(STAT_PLAYER_UNDER0 + pnum, - NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, fix16_to_int(pp->q16ang), 0); + NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->pang, 0); sp = &sprite[sp_num]; u = User[sp_num]; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index b37617385..d1dbee981 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -81,6 +81,7 @@ void pWeaponForceRest(PLAYERp pp); #define SO_IDLE_SOUND 1 extern SWBOOL NoMeters; +extern int Follow_posx,Follow_posy; #define TEST_UNDERWATER(pp) (TEST(sector[(pp)->cursectnum].extra, SECTFX_UNDERWATER)) @@ -1152,26 +1153,6 @@ GetDeltaAngle(short ang1, short ang2) } -fix16_t -GetDeltaAngleQ16(fix16_t ang1, fix16_t ang2) -{ - // Look at the smaller angle if > 1024 (180 degrees) - if (fix16_abs(fix16_sub(ang1, ang2)) > fix16_from_int(1024)) - { - if (ang1 <= fix16_from_int(1024)) - ang1 = fix16_add(ang1, fix16_from_int(2048)); - - if (ang2 <= fix16_from_int(1024)) - ang2 = fix16_add(ang2, fix16_from_int(2048)); - } - - //if (ang1 - ang2 == -fix16_from_int(1024)) - // return(fix16_from_int(1024)); - - return fix16_sub(ang1, ang2); - -} - TARGET_SORT TargetSort[MAX_TARGET_SORT]; unsigned TargetSortCount; @@ -1188,16 +1169,6 @@ SWBOOL FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, int32_t xe, int32_t ye, int32_t ze, int16_t secte); -SWBOOL -P_CheckOperatingVehicle(PLAYERp pp) -{ - SWBOOL on_vehicle = pp->DoPlayerAction == DoPlayerOperateBoat || - pp->DoPlayerAction == DoPlayerOperateTank || - pp->DoPlayerAction == DoPlayerOperateTurret; - - return on_vehicle; -} - int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets) { @@ -1257,7 +1228,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, SWBOOL skip_targets) angle2 = NORM_ANGLE(getangle(ep->x - sp->x, ep->y - sp->y)); // Get the angle difference - // delta_ang = labs(fix16_to_int(pp->q16ang) - angle2); + // delta_ang = labs(pp->pang - angle2); delta_ang = labs(GetDeltaAngle(sp->ang, angle2)); @@ -1361,7 +1332,7 @@ DoPlayerTeleportPause(PLAYERp pp) void DoPlayerTeleportToSprite(PLAYERp pp, SPRITEp sp) { - pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang); + pp->pang = pp->oang = sp->ang; pp->posx = pp->oposx = pp->oldposx = sp->x; pp->posy = pp->oposy = pp->oldposy = sp->y; @@ -1564,41 +1535,124 @@ DoPlayerCrawlHeight(PLAYERp pp) pp->posz = pp->posz - (DIV4(diff) + DIV8(diff)); } +void +DoPlayerTurn(PLAYERp pp) +{ + short angvel; + +#define TURN_SHIFT 2 + + if (!TEST(pp->Flags, PF_TURN_180)) + { + if (TEST_SYNC_KEY(pp, SK_TURN_180)) + { + if (FLAG_KEY_PRESSED(pp, SK_TURN_180)) + { + short delta_ang; + + FLAG_KEY_RELEASE(pp, SK_TURN_180); + + pp->turn180_target = NORM_ANGLE(pp->pang + 1024); + + // make the first turn in the clockwise direction + // the rest will follow + delta_ang = GetDeltaAngle(pp->turn180_target, pp->pang); + pp->pang = NORM_ANGLE(pp->pang + (labs(delta_ang) >> TURN_SHIFT)); + + SET(pp->Flags, PF_TURN_180); + } + } + else + { + FLAG_KEY_RESET(pp, SK_TURN_180); + } + } + + if (TEST(pp->Flags, PF_TURN_180)) + { + short delta_ang; + + delta_ang = GetDeltaAngle(pp->turn180_target, pp->pang); + pp->pang = NORM_ANGLE(pp->pang + (delta_ang >> TURN_SHIFT)); + + sprite[pp->PlayerSprite].ang = pp->pang; + if (!Prediction) + { + if (pp->PlayerUnderSprite >= 0) + sprite[pp->PlayerUnderSprite].ang = pp->pang; + } + + // get new delta to see how close we are + delta_ang = GetDeltaAngle(pp->turn180_target, pp->pang); + + if (labs(delta_ang) < (3<pang = pp->turn180_target; + RESET(pp->Flags, PF_TURN_180); + } + else + return; + } + + angvel = pp->input.angvel * PLAYER_TURN_SCALE; + + if (angvel != 0) + { + // running is not handled here now + angvel += DIV4(angvel); + + pp->pang += DIV32(angvel * synctics); + pp->pang = NORM_ANGLE(pp->pang); + + // update players sprite angle + // NOTE: It's also updated in UpdatePlayerSprite, but needs to be + // here to cover + // all cases. + sprite[pp->PlayerSprite].ang = pp->pang; + if (!Prediction) + { + if (pp->PlayerUnderSprite >= 0) + sprite[pp->PlayerUnderSprite].ang = pp->pang; + } + + } +} + void DoPlayerTurnBoat(PLAYERp pp) { - fix16_t angvel; + int angvel; int angslide; SECTOR_OBJECTp sop = pp->sop; if (sop->drive_angspeed) { pp->drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(pp->input.angvel, sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; - angvel = fix16_from_int(pp->drive_angvel); + angvel = pp->drive_angvel; } else { - angvel = fix16_smul(pp->input.q16avel, fix16_from_int(PLAYER_TURN_SCALE)); - angvel = fix16_sadd(angvel, fix16_ssub(angvel, fix16_sdiv(angvel, fix16_from_int(4)))); - angvel = fix16_sdiv(fix16_smul(angvel, fix16_from_int(synctics)), fix16_from_int(32)); + angvel = pp->input.angvel * PLAYER_TURN_SCALE; + angvel += angvel - DIV4(angvel); + angvel = DIV32(angvel * synctics); } if (angvel != 0) { - pp->q16ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF; - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); + pp->pang = NORM_ANGLE(pp->pang + angvel); + sprite[pp->PlayerSprite].ang = pp->pang; } } void DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) { - fix16_t angvel; + int angvel; SECTOR_OBJECTp sop = pp->sop; if (sop->drive_angspeed) @@ -1606,24 +1660,24 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) int angslide; pp->drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(pp->input.angvel, sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; - angvel = fix16_from_int(pp->drive_angvel); + angvel = pp->drive_angvel; } else { - angvel = fix16_sdiv(fix16_smul(pp->input.q16avel, fix16_from_int(synctics)), fix16_from_int(8)); + angvel = DIV8(pp->input.angvel * synctics); } if (angvel != 0) { - if (MultiClipTurn(pp, NORM_ANGLE(fix16_to_int(fix16_sadd(pp->q16ang, angvel))), z, floor_dist)) + if (MultiClipTurn(pp, NORM_ANGLE(pp->pang + angvel), z, floor_dist)) { - pp->q16ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF; - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); + pp->pang = NORM_ANGLE(pp->pang + angvel); + sprite[pp->PlayerSprite].ang = pp->pang; } } } @@ -1631,7 +1685,7 @@ DoPlayerTurnTank(PLAYERp pp, int z, int floor_dist) void DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) { - fix16_t angvel; + int angvel; SECTOR_OBJECTp sop = pp->sop; if (sop->drive_angspeed) @@ -1639,24 +1693,24 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) int angslide; pp->drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(pp->input.angvel, sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; - angvel = fix16_from_int(pp->drive_angvel); + angvel = pp->drive_angvel; } else { - angvel = fix16_sdiv(fix16_smul(pp->input.q16avel, fix16_from_int(synctics)), fix16_from_int(8)); + angvel = DIV8(pp->input.angvel * synctics); } if (angvel != 0) { - if (RectClipTurn(pp, NORM_ANGLE(fix16_to_int(fix16_sadd(pp->q16ang, angvel))), x, y, ox, oy)) + if (RectClipTurn(pp, NORM_ANGLE(pp->pang + angvel), x, y, ox, oy)) { - pp->q16ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF; - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); + pp->pang = NORM_ANGLE(pp->pang + angvel); + sprite[pp->PlayerSprite].ang = pp->pang; } } } @@ -1664,8 +1718,8 @@ DoPlayerTurnTankRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) void DoPlayerTurnTurret(PLAYERp pp) { - fix16_t angvel; - fix16_t new_ang; + int angvel; + short new_ang; short diff; SECTOR_OBJECTp sop = pp->sop; SW_PACKET last_input; @@ -1677,9 +1731,9 @@ DoPlayerTurnTurret(PLAYERp pp) fifo_ndx = (movefifoplc-2) & (MOVEFIFOSIZ - 1); last_input = pp->inputfifo[fifo_ndx]; - if (pp->input.q16avel && !last_input.q16avel) + if (pp->input.angvel && !last_input.angvel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); - else if (!pp->input.q16avel && last_input.q16avel) + else if (!pp->input.angvel && last_input.angvel) PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); } @@ -1688,38 +1742,38 @@ DoPlayerTurnTurret(PLAYERp pp) int angslide; pp->drive_oangvel = pp->drive_angvel; - pp->drive_angvel = mulscale16(fix16_to_int(pp->input.q16avel), sop->drive_angspeed); + pp->drive_angvel = mulscale16(pp->input.angvel, sop->drive_angspeed); angslide = sop->drive_angslide; pp->drive_angvel = (pp->drive_angvel + (pp->drive_oangvel*(angslide-1)))/angslide; - angvel = fix16_from_int(pp->drive_angvel); + angvel = pp->drive_angvel; } else { - angvel = fix16_sdiv(fix16_smul(pp->input.q16avel, fix16_from_int(synctics)), fix16_from_int(4)); + angvel = DIV4(pp->input.angvel * synctics); } if (angvel != 0) { - new_ang = fix16_sadd(pp->q16ang, angvel) & 0x7FFFFFF; + new_ang = NORM_ANGLE(pp->pang + angvel); if (sop->limit_ang_center >= 0) { - diff = GetDeltaAngle(fix16_to_int(new_ang), sop->limit_ang_center); + diff = GetDeltaAngle(new_ang, sop->limit_ang_center); if (labs(diff) >= sop->limit_ang_delta) { if (diff < 0) - new_ang = fix16_from_int(sop->limit_ang_center - sop->limit_ang_delta); + new_ang = sop->limit_ang_center - sop->limit_ang_delta; else - new_ang = fix16_from_int(sop->limit_ang_center + sop->limit_ang_delta); + new_ang = sop->limit_ang_center + sop->limit_ang_delta; } } - pp->q16ang = new_ang; - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); + pp->pang = new_ang; + sprite[pp->PlayerSprite].ang = pp->pang; } } @@ -1741,229 +1795,168 @@ void SlipSlope(PLAYERp pp) pp->yvect += mulscale(sintable[ang], sector[pp->cursectnum].floorheinum, sectu->speed); } -extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust; - -double scaleAdjustmentToInterval(double x); - void -DoPlayerHorizon(PLAYERp pp, fix16_t *q16horz) +PlayerAutoLook(PLAYERp pp) { -#define HORIZ_SPEED (16) + int x,y,k,j; + short tempsect; - // Fixme: This should probably be made optional. - if (cl_slopetilting) + + if (!TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) { - int x,y,k,j; - short tempsect; - - if (!TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) + if (!TEST(pp->Flags, PF_MOUSE_AIMING_ON) && TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE)) // If the floor is sloped { - if (!TEST(pp->Flags, PF_MOUSE_AIMING_ON) && TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE)) // If the floor is sloped - { - // Get a point, 512 units ahead of player's position - x = pp->posx + (sintable[(fix16_to_int(pp->q16ang) + 512) & 2047] >> 5); - y = pp->posy + (sintable[fix16_to_int(pp->q16ang) & 2047] >> 5); - tempsect = pp->cursectnum; - COVERupdatesector(x, y, &tempsect); + // Get a point, 512 units ahead of player's position + x = pp->posx + (sintable[(pp->pang + 512) & 2047] >> 5); + y = pp->posy + (sintable[pp->pang & 2047] >> 5); + tempsect = pp->cursectnum; + COVERupdatesector(x, y, &tempsect); - if (tempsect >= 0) // If the new point is inside a valid sector... - { - // Get the floorz as if the new (x,y) point was still in - // your sector - j = getflorzofslope(pp->cursectnum, pp->posx, pp->posy); - k = getflorzofslope(pp->cursectnum, x, y); + if (tempsect >= 0) // If the new point is inside a valid + // sector... + { + // Get the floorz as if the new (x,y) point was still in + // your sector + j = getflorzofslope(pp->cursectnum, pp->posx, pp->posy); + k = getflorzofslope(pp->cursectnum, x, y); - // If extended point is in same sector as you or the slopes - // of the sector of the extended point and your sector match - // closely (to avoid accidently looking straight out when - // you're at the edge of a sector line) then adjust horizon - // accordingly - if ((pp->cursectnum == tempsect) || (klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) - { - if (!pp->on_vehicle) - { - pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_dbl(scaleAdjustmentToInterval(mulscale16((j - k), 160)))); - } - else - { - pp->q16horizoff += fix16_from_int((((j - k) * 160) >> 16)); - } - } - } - } - } - - if (TEST(pp->Flags, PF_CLIMBING)) - { - // tilt when climbing but you can't even really tell it - if (pp->q16horizoff < fix16_from_int(100)) - { - if (!pp->on_vehicle) + // If extended point is in same sector as you or the slopes + // of the sector of the extended point and your sector match + // closely (to avoid accidently looking straight out when + // you're at the edge of a sector line) then adjust horizon + // accordingly + if ((pp->cursectnum == tempsect) || + (klabs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) { - pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(((fix16_from_int(100) - pp->q16horizoff) >> 3) + fix16_one)))); - } - else - { - pp->q16horizoff += fix16_from_int((((100 - fix16_to_int(pp->q16horizoff)) >> 3) + 1)); - } - } - } - else - { - // Make q16horizoff grow towards 0 since q16horizoff is not modified when - // you're not on a slope - if (pp->q16horizoff > 0) - { - if (!pp->on_vehicle) - { - pp->q16horizoff = fix16_ssub(pp->q16horizoff, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl((pp->q16horizoff >> 3) + fix16_one)))); - pp->q16horizoff = fix16_max(pp->q16horizoff, 0); - } - else - { - pp->q16horizoff -= fix16_from_int(((fix16_to_int(pp->q16horizoff) >> 3) + 1)); - } - } - else if (pp->q16horizoff < 0) - { - if (!pp->on_vehicle) - { - pp->q16horizoff = fix16_sadd(pp->q16horizoff, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl((-pp->q16horizoff >> 3) + fix16_one)))); - pp->q16horizoff = fix16_min(pp->q16horizoff, 0); - } - else - { - pp->q16horizoff += fix16_from_int((((fix16_to_int(-pp->q16horizoff)) >> 3) + 1)); + pp->horizoff += (((j - k) * 160) >> 16); } } } } - if (*q16horz) + if (TEST(pp->Flags, PF_CLIMBING)) { - if (!pp->on_vehicle) - { - pp->q16horizbase = fix16_sadd(pp->q16horizbase, *q16horz); - } - else - { - pp->q16horizbase += *q16horz; - } + // tilt when climbing but you can't even really tell it + if (pp->horizoff < 100) + pp->horizoff += (((100 - pp->horizoff) >> 3) + 1); + } + else + { + // Make horizoff grow towards 0 since horizoff is not modified when + // you're not on a slope + if (pp->horizoff > 0) + pp->horizoff -= ((pp->horizoff >> 3) + 1); + if (pp->horizoff < 0) + pp->horizoff += (((-pp->horizoff) >> 3) + 1); + } +} + +extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust; +void +DoPlayerHorizon(PLAYERp pp) +{ + int i; +#define HORIZ_SPEED (16) + +// //DSPRINTF(ds,"pp->horizoff, %d", pp->horizoff); +// MONO_PRINT(ds); + + // Fixme: This should probably be made optional. + if (cl_slopetilting) + PlayerAutoLook(pp); + + if (pp->input.aimvel) + { + pp->horizbase += pp->input.aimvel; SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING); } + if (TEST_SYNC_KEY(pp, SK_CENTER_VIEW)) + { + pp->horiz = pp->horizbase = 100; + pp->horizoff = 0; + } + // this is the locked type if (TEST_SYNC_KEY(pp, SK_SNAP_UP) || TEST_SYNC_KEY(pp, SK_SNAP_DOWN)) { // set looking because player is manually looking SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING); - // adjust pp->q16horiz negative + // adjust pp->horizon negative if (TEST_SYNC_KEY(pp, SK_SNAP_DOWN)) - { - if (!pp->on_vehicle) - { - pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_dbl(scaleAdjustmentToInterval(HORIZ_SPEED / 2))); - } - else - { - pp->q16horizbase -= fix16_from_int((HORIZ_SPEED/2)); - } - } + pp->horizbase -= (HORIZ_SPEED/2); - // adjust pp->q16horiz positive + // adjust pp->horizon positive if (TEST_SYNC_KEY(pp, SK_SNAP_UP)) - { - if (!pp->on_vehicle) - { - pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_dbl(scaleAdjustmentToInterval(HORIZ_SPEED / 2))); - } - else - { - pp->q16horizbase += fix16_from_int((HORIZ_SPEED/2)); - } - } + pp->horizbase += (HORIZ_SPEED/2); } + // this is the unlocked type - if (TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN) || TEST_SYNC_KEY(pp, SK_CENTER_VIEW)) + if (TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN)) { RESET(pp->Flags, PF_LOCK_HORIZ); SET(pp->Flags, PF_LOOKING); - // adjust pp->q16horiz negative + // adjust pp->horizon negative if (TEST_SYNC_KEY(pp, SK_LOOK_DOWN)) - { - if (!pp->on_vehicle) - { - pp->q16horizbase = fix16_ssub(pp->q16horizbase, fix16_from_dbl(scaleAdjustmentToInterval(HORIZ_SPEED))); - } - else - { - pp->q16horizbase -= fix16_from_int(HORIZ_SPEED); - } - } + pp->horizbase -= HORIZ_SPEED; - // adjust pp->q16horiz positive + // adjust pp->horizon positive if (TEST_SYNC_KEY(pp, SK_LOOK_UP)) - { - if (!pp->on_vehicle) - { - pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_dbl(scaleAdjustmentToInterval(HORIZ_SPEED))); - } - else - { - pp->q16horizbase += fix16_from_int(HORIZ_SPEED); - } - } - - // reset pp->q16horizoff when resetting to center. - if (TEST_SYNC_KEY(pp, SK_CENTER_VIEW)) - pp->q16horizoff = 0; + pp->horizbase += HORIZ_SPEED; } + if (!TEST(pp->Flags, PF_LOCK_HORIZ)) { if (!(TEST_SYNC_KEY(pp, SK_LOOK_UP) || TEST_SYNC_KEY(pp, SK_LOOK_DOWN))) { - // not pressing the pp->q16horiz keys - if (pp->q16horizbase != fix16_from_int(100)) + // not pressing the pp->horiz keys + if (pp->horizbase != 100) { - int i; - // move pp->q16horiz back to 100 + // move pp->horiz back to 100 for (i = 1; i; i--) { - // this formula does not work for pp->q16horiz = 101-103 - if (!pp->on_vehicle) - { - pp->q16horizbase = fix16_sadd(pp->q16horizbase, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl(fix16_ssub(fix16_from_int(25), fix16_sdiv(pp->q16horizbase, fix16_from_int(4))))))); - } - else - { - pp->q16horizbase += fix16_from_int(25 - (fix16_to_int(pp->q16horizbase) >> 2)); - } + // this formula does not work for pp->horiz = 101-103 + pp->horizbase += 25 - (pp->horizbase >> 2); } } else { - // not looking anymore because pp->q16horiz is back at 100 + // not looking anymore because pp->horiz is back at 100 RESET(pp->Flags, PF_LOOKING); } } } +#if 1 // bound the base - pp->q16horizbase = fix16_clamp(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX)); + pp->horizbase = max(pp->horizbase, PLAYER_HORIZ_MIN); + pp->horizbase = min(pp->horizbase, PLAYER_HORIZ_MAX); - // bound adjust q16horizoff - if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN)) - pp->q16horizoff = fix16_ssub(fix16_from_int(PLAYER_HORIZ_MIN), pp->q16horizbase); - else if (pp->q16horizbase + pp->q16horizoff > fix16_from_int(PLAYER_HORIZ_MAX)) - pp->q16horizoff = fix16_ssub(fix16_from_int(PLAYER_HORIZ_MAX), pp->q16horizbase); + // bound adjust horizoff + if (pp->horizbase + pp->horizoff < PLAYER_HORIZ_MIN) + pp->horizoff = PLAYER_HORIZ_MIN - pp->horizbase; + else if (pp->horizbase + pp->horizoff > PLAYER_HORIZ_MAX) + pp->horizoff = PLAYER_HORIZ_MAX - pp->horizbase; + + ////DSPRINTF(ds,"base %d, off %d, base + off %d",pp->horizbase, pp->horizoff, pp->horizbase + pp->horizoff); + //MONO_PRINT(ds); // add base and offsets - pp->q16horiz = fix16_clamp((pp->q16horizbase + pp->q16horizoff), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX)); + pp->horiz = pp->horizbase + pp->horizoff; +#else + if (pp->horizbase + pp->horizoff < PLAYER_HORIZ_MIN) + pp->horizbase += HORIZ_SPEED; + else if (pp->horizbase + pp->horizoff > PLAYER_HORIZ_MAX) + pp->horizbase -= HORIZ_SPEED; + + pp->horiz = pp->horizbase + pp->horizoff; +#endif + } void @@ -1993,7 +1986,7 @@ DoPlayerBob(PLAYERp pp) // wrap bcnt pp->bcnt &= 2047; - // move pp->q16horiz up and down from 100 using sintable + // move pp->horiz up and down from 100 using sintable //pp->bob_z = Z((8 * sintable[pp->bcnt]) >> 14); pp->bob_z = mulscale14(Z(amt),sintable[pp->bcnt]); } @@ -2009,7 +2002,7 @@ DoPlayerBob(PLAYERp pp) // wrap bcnt pp->bcnt &= 2047; - // move pp->q16horiz up and down from 100 using sintable + // move pp->horiz up and down from 100 using sintable //pp->bob_z = Z((4 * sintable[pp->bcnt]) >> 14); pp->bob_z = mulscale14(Z(amt),sintable[pp->bcnt]); } @@ -2043,7 +2036,7 @@ DoPlayerRecoil(PLAYERp pp) return; } - // move pp->q16horiz up and down + // move pp->horiz up and down pp->recoil_horizoff = ((pp->recoil_amt * sintable[pp->recoil_ndx]) >> 14); } @@ -2153,7 +2146,7 @@ UpdatePlayerSprite(PLAYERp pp) if (TEST(pp->Flags, PF_DEAD)) { changespritesect(pp->PlayerSprite, pp->cursectnum); - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); + sprite[pp->PlayerSprite].ang = pp->pang; UpdatePlayerUnderSprite(pp); return; } @@ -2228,7 +2221,7 @@ UpdatePlayerSprite(PLAYERp pp) UpdatePlayerUnderSprite(pp); - sprite[pp->PlayerSprite].ang = fix16_to_int(pp->q16ang); + sprite[pp->PlayerSprite].ang = pp->pang; } void @@ -2380,6 +2373,132 @@ void PlayerCheckValidMove(PLAYERp pp) } } +void +MoveScrollMode2D(PLAYERp pp) +{ +#define TURBOTURNTIME (120/8) +#define NORMALTURN (12+6) +#define RUNTURN (28) +#define PREAMBLETURN 3 +#define NORMALKEYMOVE 35 +#define MAXVEL ((NORMALKEYMOVE*2)+10) +#define MAXSVEL ((NORMALKEYMOVE*2)+10) +#define MAXANGVEL 100 + + ControlInfo scrl_input; + int32_t keymove; + int32_t momx, momy; + static int mfvel=0, mfsvel=0; + extern SWBOOL HelpInputMode, ScrollMode2D; + + + CONTROL_GetInput(&scrl_input); + + mfsvel = mfvel = 0; + + if (M_Active()) + return; + + // Recenter view if told + if (buttonMap.ButtonDown(gamefunc_Center_View)) + { + Follow_posx = pp->posx; + Follow_posy = pp->posy; + } + + // Toggle follow map mode on/off + if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode)) + { + buttonMap.ClearButton(gamefunc_Map_Follow_Mode); + ScrollMode2D = !ScrollMode2D; + // Reset coords + Follow_posx = pp->posx; + Follow_posy = pp->posy; + } + + if (buttonMap.ButtonDown(gamefunc_Strafe)) + mfsvel -= scrl_input.dyaw>>2; + mfsvel -= scrl_input.dx>>2; + mfvel = -scrl_input.dz>>2; + +#if 0 + int const running = !!BUTTON(gamefunc_Run) ^ !!TEST(pp->Flags, PF_LOCK_RUN); + if (running) + { + keymove = NORMALKEYMOVE << 1; + } + else +#endif + { + keymove = NORMALKEYMOVE; + } + + if (!HelpInputMode && !ConPanel) + { + if (buttonMap.ButtonDown(gamefunc_Turn_Left)) + { + mfsvel -= -keymove; + } + if (buttonMap.ButtonDown(gamefunc_Turn_Right)) + { + mfsvel -= keymove; + } + } + + if (!InputMode && !ConPanel) + { + if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) + { + mfsvel += keymove; + } + + if (buttonMap.ButtonDown(gamefunc_Strafe_Right)) + { + mfsvel += -keymove; + } + } + + if (!HelpInputMode && !ConPanel) + { + if (buttonMap.ButtonDown(gamefunc_Move_Forward)) + { + mfvel += keymove; + } + + if (buttonMap.ButtonDown(gamefunc_Move_Backward)) + { + mfvel += -keymove; + } + } + + if (mfvel < -MAXVEL) + mfvel = -MAXVEL; + if (mfvel > MAXVEL) + mfvel = MAXVEL; + if (mfsvel < -MAXSVEL) + mfsvel = -MAXSVEL; + if (mfsvel > MAXSVEL) + mfsvel = MAXSVEL; + + momx = mulscale9(mfvel, sintable[NORM_ANGLE(pp->pang + 512)]); + momy = mulscale9(mfvel, sintable[NORM_ANGLE(pp->pang)]); + + momx += mulscale9(mfsvel, sintable[NORM_ANGLE(pp->pang)]); + momy += mulscale9(mfsvel, sintable[NORM_ANGLE(pp->pang + 1536)]); + + //mfvel = momx; + //mfsvel = momy; + + Follow_posx += momx; + Follow_posy += momy; + + Follow_posx = max(Follow_posx, x_min_bound); + Follow_posy = max(Follow_posy, y_min_bound); + Follow_posx = min(Follow_posx, x_max_bound); + Follow_posy = min(Follow_posy, y_max_bound); + +} + void DoPlayerMenuKeys(PLAYERp pp) { @@ -2421,6 +2540,8 @@ DoPlayerMove(PLAYERp pp) void SlipSlope(PLAYERp pp); SlipSlope(pp); + + DoPlayerTurn(pp); pp->oldposx = pp->posx; pp->oldposy = pp->posy; @@ -2524,6 +2645,8 @@ DoPlayerMove(PLAYERp pp) DoPlayerSetWadeDepth(pp); + DoPlayerHorizon(pp); + if (pp->cursectnum >= 0 && TEST(sector[pp->cursectnum].extra, SECTFX_DYNAMIC_AREA)) { if (TEST(pp->Flags, PF_FLYING|PF_JUMPING|PF_FALLING)) @@ -2721,16 +2844,16 @@ DoPlayerMoveBoat(PLAYERp pp) z = pp->posz + Z(10); save_sectnum = pp->cursectnum; - OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), MAXSO, MAXSO); + OperateSectorObject(pp->sop, pp->pang, MAXSO, MAXSO); pp->cursectnum = pp->sop->op_main_sector; // for speed floor_dist = labs(z - pp->sop->floor_loz); clipmove_old(&pp->posx, &pp->posy, &z, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER); - OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->posx, pp->posy); + OperateSectorObject(pp->sop, pp->pang, pp->posx, pp->posy); pp->cursectnum = save_sectnum; // for speed - DoPlayerHorizon(pp, &pp->input.q16horz); + DoPlayerHorizon(pp); } #if 0 @@ -2760,7 +2883,7 @@ void DoTankTreads(PLAYERp pp) return; vel = FindDistance2D(pp->xvect>>8, pp->yvect>>8); - dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]); + dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(pp->pang+512)], sintable[pp->pang]); if (dot < 0) reverse = TRUE; @@ -2900,7 +3023,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) return; // not moving - don't crush - if ((pp->xvect|pp->yvect) == 0 && pp->input.q16avel == 0) + if ((pp->xvect|pp->yvect) == 0 && pp->input.angvel == 0) return; // main sector @@ -3006,7 +3129,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) continue; damage = -(u->Health + 100); - PlayerDamageSlide(u->PlayerP, damage, fix16_to_int(pp->q16ang)); + PlayerDamageSlide(u->PlayerP, damage, pp->pang); PlayerUpdateHealth(u->PlayerP, damage); //PlayerCheckDeath(u->PlayerP, -1); PlayerCheckDeath(u->PlayerP, pp->PlayerSprite); @@ -3141,7 +3264,7 @@ DoPlayerMoveTank(PLAYERp pp) } save_sectnum = pp->cursectnum; - OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), MAXSO, MAXSO); + OperateSectorObject(pp->sop, pp->pang, MAXSO, MAXSO); pp->cursectnum = pp->sop->op_main_sector; // for speed floor_dist = labs(z - pp->sop->floor_loz); @@ -3171,7 +3294,7 @@ DoPlayerMoveTank(PLAYERp pp) hitscan(&hit_pos, pp->cursectnum, //pp->xvect, pp->yvect, 0, - MOVEx(256, fix16_to_int(pp->q16ang)), MOVEy(256, fix16_to_int(pp->q16ang)), 0, + MOVEx(256, pp->pang), MOVEy(256, pp->pang), 0, &hitinfo, CLIPMASK_PLAYER); ////DSPRINTF(ds,"hitinfo.sect %d, hitinfo.wall %d, hitinfo.pos.x %d, hitinfo.pos.y %d, hitinfo.pos.z %d",hitinfo.sect, hitinfo.wall, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z); @@ -3238,10 +3361,10 @@ DoPlayerMoveTank(PLAYERp pp) } } - OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->posx, pp->posy); + OperateSectorObject(pp->sop, pp->pang, pp->posx, pp->posy); pp->cursectnum = save_sectnum; // for speed - DoPlayerHorizon(pp, &pp->input.q16horz); + DoPlayerHorizon(pp); DoTankTreads(pp); } @@ -3256,9 +3379,9 @@ DoPlayerMoveTurret(PLAYERp pp) else SET(pp->Flags, PF_PLAYER_MOVED); - OperateSectorObject(pp->sop, fix16_to_int(pp->q16ang), pp->sop->xmid, pp->sop->ymid); + OperateSectorObject(pp->sop, pp->pang, pp->sop->xmid, pp->sop->ymid); - DoPlayerHorizon(pp, &pp->input.q16horz); + DoPlayerHorizon(pp); } void @@ -3685,7 +3808,7 @@ DoPlayerClimb(PLAYERp pp) pp->xvect = pp->yvect = 0; climbvel = FindDistance2D(pp->xvect, pp->yvect)>>9; - dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]); + dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(pp->pang+512)], sintable[pp->pang]); if (dot < 0) climbvel = -climbvel; @@ -3834,6 +3957,8 @@ DoPlayerClimb(PLAYERp pp) sp->z = pp->posz + PLAYER_HEIGHT; changespritesect(pp->PlayerSprite, pp->cursectnum); + DoPlayerHorizon(pp); + if (FAF_ConnectArea(pp->cursectnum)) { updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum); @@ -3853,7 +3978,7 @@ DoPlayerClimb(PLAYERp pp) // constantly look for new ladder sector because of warping at any time neartag(pp->posx, pp->posy, pp->posz, - pp->cursectnum, fix16_to_int(pp->q16ang), + pp->cursectnum, pp->pang, &sec, &wal, &spr, &dist, 800L, NTAG_SEARCH_LO_HI, NULL); @@ -3878,7 +4003,7 @@ DoPlayerClimb(PLAYERp pp) pp->lx = lsp->x + nx * 5; pp->ly = lsp->y + ny * 5; - pp->q16ang = fix16_from_int(pp->LadderAngle); + pp->pang = pp->LadderAngle; } } } @@ -3898,8 +4023,8 @@ DoPlayerWadeSuperJump(PLAYERp pp) for (i = 0; i < SIZ(angs); i++) { FAFhitscan(pp->posx, pp->posy, zh, pp->cursectnum, // Start position - sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angs[i] + 512)], // X vector of 3D ang - sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angs[i])], // Y vector of 3D ang + sintable[NORM_ANGLE(pp->pang + angs[i] + 512)], // X vector of 3D ang + sintable[NORM_ANGLE(pp->pang + angs[i])], // Y vector of 3D ang 0, // Z vector of 3D ang &hitinfo, CLIPMASK_MISSILE); @@ -4337,11 +4462,11 @@ PlayerOnLadder(PLAYERp pp) if (Prediction) return 0; - neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, fix16_to_int(pp->q16ang), + neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, pp->pang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, 1024L+768L, NTAG_SEARCH_LO_HI, NULL); - dir = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]); + dir = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(pp->pang+512)], sintable[pp->pang]); if (dir < 0) return FALSE; @@ -4351,7 +4476,7 @@ PlayerOnLadder(PLAYERp pp) for (i = 0; i < SIZ(angles); i++) { - neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, NORM_ANGLE(fix16_to_int(pp->q16ang) + angles[i]), + neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, NORM_ANGLE(pp->pang + angles[i]), &sec, &wal, &spr, &dist, 600L, NTAG_SEARCH_LO_HI, NULL); @@ -4359,8 +4484,8 @@ PlayerOnLadder(PLAYERp pp) return FALSE; FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, - sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angles[i] + 512)], - sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + angles[i])], + sintable[NORM_ANGLE(pp->pang + angles[i] + 512)], + sintable[NORM_ANGLE(pp->pang + angles[i])], 0, &hitinfo, CLIPMASK_MISSILE); @@ -4415,7 +4540,7 @@ PlayerOnLadder(PLAYERp pp) pp->lx = lsp->x + nx * 5; pp->ly = lsp->y + ny * 5; - pp->q16ang = fix16_from_int(pp->LadderAngle); + pp->pang = pp->LadderAngle; return TRUE; } @@ -5668,7 +5793,7 @@ DoPlayerBeginOperate(PLAYERp pp) pp->sop = pp->sop_control = sop; sop->controller = pp->SpriteP; - pp->q16ang = fix16_from_int(sop->ang); + pp->pang = sop->ang; pp->posx = sop->xmid; pp->posy = sop->ymid; COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum); @@ -5703,7 +5828,7 @@ DoPlayerBeginOperate(PLAYERp pp) break; case SO_TURRET_MGUN: case SO_TURRET: - if (pp->input.q16avel) + if (pp->input.angvel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5753,7 +5878,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop) save_sectnum = pp->cursectnum; - pp->q16ang = fix16_from_int(sop->ang); + pp->pang = sop->ang; pp->posx = sop->xmid; pp->posy = sop->ymid; COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum); @@ -5791,7 +5916,7 @@ DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop) break; case SO_TURRET_MGUN: case SO_TURRET: - if (pp->input.q16avel) + if (pp->input.angvel) PlaySOsound(pp->sop->mid_sector, SO_DRIVE_SOUND); else PlaySOsound(pp->sop->mid_sector, SO_IDLE_SOUND); @@ -5882,9 +6007,9 @@ DoPlayerStopOperate(PLAYERp pp) if (pp->sop_remote) { if (TEST_BOOL1(pp->remote_sprite)) - pp->q16ang = pp->oq16ang = fix16_from_int(pp->remote_sprite->ang); + pp->pang = pp->oang = pp->remote_sprite->ang; else - pp->q16ang = pp->oq16ang = fix16_from_int(getangle(pp->sop_remote->xmid - pp->posx, pp->sop_remote->ymid - pp->posy)); + pp->pang = pp->oang = getangle(pp->sop_remote->xmid - pp->posx, pp->sop_remote->ymid - pp->posy); } if (pp->sop_control) @@ -6468,21 +6593,21 @@ DoPlayerBeginDie(PLAYERp pp) int DoPlayerDeathHoriz(PLAYERp pp, short target, short speed) { - if (pp->q16horiz > fix16_from_int(target)) + if (pp->horiz > target) { - pp->q16horiz = fix16_ssub(pp->q16horiz, fix16_from_int(speed)); - if (pp->q16horiz <= fix16_from_int(target)) - pp->q16horiz = fix16_from_int(target); + pp->horiz -= speed; + if (pp->horiz <= target) + pp->horiz = target; } - if (pp->q16horiz < fix16_from_int(target)) + if (pp->horiz < target) { - pp->q16horiz = fix16_sadd(pp->q16horiz, fix16_from_int(speed)); - if (pp->q16horiz >= fix16_from_int(target)) - pp->q16horiz = fix16_from_int(target); + pp->horiz += speed; + if (pp->horiz >= target) + pp->horiz = target; } - return pp->q16horiz == fix16_from_int(target); + return pp->horiz == target; } int @@ -6558,17 +6683,26 @@ void DoPlayerDeathFollowKiller(PLAYERp pp) DoPlayerDeathHoriz(pp, PLAYER_DEATH_HORIZ_UP_VALUE, 4); //DoPlayerDeathTilt(pp, pp->tilt_dest, 4 * synctics); + // allow turning + if ((TEST(pp->Flags, PF_DEAD_HEAD) && pp->input.angvel != 0) || TEST(pp->Flags, PF_HEAD_CONTROL)) + { + DoPlayerTurn(pp); + return; + } + // follow what killed you if its available if (pp->Killer > -1) { SPRITEp kp = &sprite[pp->Killer]; - fix16_t delta_q16ang; + short ang2,delta_ang; if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum)) { - delta_q16ang = GetDeltaAngleQ16(fix16_from_int(getangle(kp->x - pp->posx, kp->y - pp->posy)), pp->q16ang); - pp->q16ang = fix16_sadd(pp->q16ang, fix16_sdiv(delta_q16ang, fix16_from_int(16))) & 0x7FFFFFF; + ang2 = getangle(kp->x - pp->posx, kp->y - pp->posy); + + delta_ang = GetDeltaAngle(ang2, pp->pang); + pp->pang = NORM_ANGLE(pp->pang + (delta_ang >> 4)); } } } @@ -6608,7 +6742,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp) pp->SpriteP->x = pp->posx; pp->SpriteP->y = pp->posy; pp->SpriteP->z = pp->posz+PLAYER_HEIGHT; - pp->SpriteP->ang = fix16_to_int(pp->q16ang); + pp->SpriteP->ang = pp->pang; DoSpawnTeleporterEffect(pp->SpriteP); PlaySound(DIGI_TELEPORT, pp, v3df_none); @@ -6629,7 +6763,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp) sp->yrepeat = PLAYER_NINJA_YREPEAT; //pp->tilt = 0; - pp->q16horiz = pp->q16horizbase = fix16_from_int(100); + pp->horiz = pp->horizbase = 100; DoPlayerResetMovement(pp); u->ID = NINJA_RUN_R0; PlayerDeathReset(pp); @@ -7306,8 +7440,8 @@ MoveSkipSavePos(void) pp->oposx = pp->posx; pp->oposy = pp->posy; pp->oposz = pp->posz; - pp->oq16ang = pp->q16ang; - pp->oq16horiz = pp->q16horiz; + pp->oang = pp->pang; + pp->ohoriz = pp->horiz; } // save off stats for skip4 @@ -7374,7 +7508,7 @@ void ChopsCheck(PLAYERp pp) 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.q16avel|pp->input.q16horz) || + if ((pp->input.bits|pp->input.vel|pp->input.svel|pp->input.angvel|pp->input.aimvel) || TEST(pp->Flags, PF_CLIMBING|PF_FALLING|PF_DIVING)) { // Hit a input key or other reason to stop chops @@ -7774,7 +7908,7 @@ domovethings(void) // auto tracking mode for single player multi-game if (numplayers <= 1 && PlayerTrackingMode && pnum == screenpeek && screenpeek != myconnectindex) { - Player[screenpeek].q16ang = fix16_from_int(getangle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy)); + Player[screenpeek].pang = getangle(Player[myconnectindex].posx - Player[screenpeek].posx, Player[myconnectindex].posy - Player[screenpeek].posy); } if (!TEST(pp->Flags, PF_DEAD)) @@ -7794,7 +7928,8 @@ domovethings(void) DoPlayerSectorUpdatePreMove(pp); ChopsCheck(pp); - //if (!pp->ScrollMode2D) +// extern SWBOOL ScrollMode2D; + //if (!ScrollMode2D) if (pp->DoPlayerAction) pp->DoPlayerAction(pp); UpdatePlayerSprite(pp); @@ -7845,7 +7980,7 @@ InitAllPlayers(void) //getzsofslope(pfirst->cursectnum, pfirst->posx, pfirst->posy, &cz, &fz); //pfirst->posz = fz - PLAYER_HEIGHT; - pfirst->q16horiz = pfirst->q16horizbase = fix16_from_int(100); + pfirst->horiz = pfirst->horizbase = 100; // Initialize all [MAX_SW_PLAYERS] arrays here! for (pp = Player; pp < &Player[MAX_SW_PLAYERS]; pp++) @@ -7853,15 +7988,15 @@ InitAllPlayers(void) pp->posx = pp->oposx = pfirst->posx; pp->posy = pp->oposy = pfirst->posy; pp->posz = pp->oposz = pfirst->posz; - pp->q16ang = pp->oq16ang = pfirst->q16ang; - pp->q16horiz = pp->oq16horiz = pfirst->q16horiz; + pp->pang = pp->oang = pfirst->pang; + pp->horiz = pp->ohoriz = pfirst->horiz; pp->cursectnum = pfirst->cursectnum; // set like this so that player can trigger something on start of the level pp->lastcursectnum = pfirst->cursectnum+1; //pp->MaxHealth = 100; - pp->q16horizbase = pfirst->q16horizbase; + pp->horizbase = pfirst->horizbase; pp->oldposx = 0; pp->oldposy = 0; pp->climb_ndx = 10; @@ -7893,7 +8028,7 @@ InitAllPlayers(void) pp->FadeAmt = 0; pp->FadeTics = 0; pp->StartColor = 0; - pp->q16horizoff = 0; + pp->horizoff = 0; INITLIST(&pp->PanelSpriteList); } @@ -8004,7 +8139,7 @@ PlayerSpawnPosition(PLAYERp pp) pp->posx = pp->oposx = sp->x; pp->posy = pp->oposy = sp->y; pp->posz = pp->oposz = sp->z; - pp->q16ang = pp->oq16ang = fix16_from_int(sp->ang); + pp->pang = pp->oang = sp->ang; pp->cursectnum = sp->sectnum; getzsofslope(pp->cursectnum, pp->posx, pp->posy, &cz, &fz); @@ -8063,7 +8198,7 @@ InitMultiPlayerInfo(void) continue; } - start0 = SpawnSprite(MultiStatList[stat], ST1, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, fix16_to_int(pp->q16ang), 0); + start0 = SpawnSprite(MultiStatList[stat], ST1, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->pang, 0); ASSERT(start0 >= 0); if (User[start0]) { diff --git a/source/sw/src/player.h b/source/sw/src/player.h index 080642069..b841a9644 100644 --- a/source/sw/src/player.h +++ b/source/sw/src/player.h @@ -130,6 +130,7 @@ void DoPlayer(void); void domovethings(void); void InitAllPlayers(void); void InitMultiPlayerInfo(void); +void MoveScrollMode2D(PLAYERp pp); void DoPlayerDivePalette(PLAYERp pp); void DoPlayerNightVisionPalette(PLAYERp pp); void DoPlayerStopDiveNoWarp(PLAYERp pp); @@ -143,8 +144,6 @@ void PlaySOsound(short sectnum,short sound_num); void DoSpawnTeleporterEffectPlace(SPRITEp sp); void FindMainSector(SECTOR_OBJECTp sop); -SWBOOL P_CheckOperatingVehicle(PLAYERp pp); - END_SW_NS #endif diff --git a/source/sw/src/predict.cpp b/source/sw/src/predict.cpp index 8314f9a30..7440372c2 100644 --- a/source/sw/src/predict.cpp +++ b/source/sw/src/predict.cpp @@ -45,9 +45,8 @@ PLAYERp ppp = &PredictPlayer; typedef struct { - int x,y,z; - fix16_t q16horiz, q16ang; - short filler; + int x,y,z,horiz; + short ang,filler; } PREDICT, *PREDICTp; PREDICT Predict[MOVEFIFOSIZ]; @@ -157,11 +156,11 @@ DoPrediction(PLAYERp ppp) u = User[ppp->PlayerSprite]; User[ppp->PlayerSprite] = &PredictUser; - ppp->oq16ang = ppp->q16ang; + ppp->oang = ppp->pang; ppp->oposx = ppp->posx; ppp->oposy = ppp->posy; ppp->oposz = ppp->posz; - ppp->oq16horiz = ppp->q16horiz; + ppp->ohoriz = ppp->horiz; #if PREDICT_DEBUG PredictDebug(ppp); @@ -179,11 +178,11 @@ DoPrediction(PLAYERp ppp) sprite[Player[myconnectindex].PlayerSprite] = spr; randomseed = bakrandomseed; - Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].q16ang = ppp->q16ang; + Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].ang = ppp->pang; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy; Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz; - Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].q16horiz = ppp->q16horiz; + Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].horiz = ppp->horiz; predictmovefifoplc++; } @@ -199,17 +198,17 @@ CorrectPrediction(int actualfifoplc) return; // see if player position is predicted position - if (predict->q16ang == Player[myconnectindex].q16ang && + if (predict->ang == Player[myconnectindex].pang && predict->x == Player[myconnectindex].posx && predict->y == Player[myconnectindex].posy && predict->z == Player[myconnectindex].posz && - predict->q16horiz == Player[myconnectindex].q16horiz + predict->horiz == Player[myconnectindex].horiz ) { return; } -// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", fix16_to_int(predict->q16ang), fix16_to_int(Player[myconnectindex].q16ang), 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)); +// //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); // MONO_PRINT(ds); InitPrediction(&Player[myconnectindex]); diff --git a/source/sw/src/rooms.cpp b/source/sw/src/rooms.cpp index e5dd3447c..7b551c7d7 100644 --- a/source/sw/src/rooms.cpp +++ b/source/sw/src/rooms.cpp @@ -33,7 +33,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -void FAF_DrawRooms(int posx, int posy, int posz, fix16_t q16ang, fix16_t q16horiz, short cursectnum); +void FAF_DrawRooms(int posx, int posy, int posz, short ang, int horiz, short cursectnum); //////////////////////////////////////////////////////////////////// // @@ -1089,7 +1089,7 @@ ViewSectorInScene(short cursectnum, short level) } void -DrawOverlapRoom(int tx, int ty, int tz, fix16_t tq16ang, fix16_t tq16horiz, short tsectnum) +DrawOverlapRoom(int tx, int ty, int tz, short tang, int thoriz, short tsectnum) { short i; short match; @@ -1104,8 +1104,8 @@ DrawOverlapRoom(int tx, int ty, int tz, fix16_t tq16ang, fix16_t tq16horiz, shor if (tsectnum < 0) return; - renderDrawRoomsQ16(tx, ty, tz, tq16ang, tq16horiz, tsectnum); - //FAF_DrawRooms(tx, ty, tz, tq16ang, tq16horiz, tsectnum); + drawrooms(tx, ty, tz, tang, thoriz, tsectnum); + //FAF_DrawRooms(tx, ty, tz, tang, thoriz, tsectnum); // reset Z's for (i = 0; i < save.zcount; i++) @@ -1130,8 +1130,8 @@ DrawOverlapRoom(int tx, int ty, int tz, fix16_t tq16ang, fix16_t tq16horiz, shor if (tsectnum < 0) return; - renderDrawRoomsQ16(tx, ty, tz, tq16ang, tq16horiz, tsectnum); - //FAF_DrawRooms(tx, ty, tz, tq16ang, tq16horiz, tsectnum); + drawrooms(tx, ty, tz, tang, thoriz, tsectnum); + //FAF_DrawRooms(tx, ty, tz, tang, thoriz, tsectnum); // reset Z's for (i = 0; i < save.zcount; i++) diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index 207bf74d4..145b3a20b 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -2339,7 +2339,7 @@ SWBOOL NearThings(PLAYERp pp) return FALSE; } - neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, fix16_to_int(pp->q16ang), + neartag(pp->posx, pp->posy, pp->posz, pp->cursectnum, pp->pang, &neartagsect, &neartagwall, &neartagsprite, &neartaghitdist, 1024L, NTAG_SEARCH_LO_HI, NULL); @@ -2373,7 +2373,7 @@ SWBOOL NearThings(PLAYERp pp) // This only gets called if nothing else worked, check for nearness to a wall { hitdata_t hitinfo = { { 0, 0, 0 }, 0, 0, 0 }; - short dang = fix16_to_int(pp->q16ang); + short dang = pp->pang; FAFhitscan(pp->posx, pp->posy, pp->posz - Z(30), pp->cursectnum, // Start position sintable[NORM_ANGLE(dang + 512)], // X vector of 3D ang @@ -2437,7 +2437,7 @@ NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int coun int neartaghitdist; - neartag(pp->posx, pp->posy, z, pp->cursectnum, fix16_to_int(pp->q16ang), + neartag(pp->posx, pp->posy, z, pp->cursectnum, pp->pang, &neartagsector, &neartagwall, &neartagsprite, &neartaghitdist, dist, type, NULL); diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index 276000243..6a3c0dc16 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -586,7 +586,7 @@ void DoUpdateSounds(void) PLAYERp pp = Player + screenpeek; SoundListener listener; - listener.angle = -(float)fix16_to_float(pp->q16ang) * pi::pi() / 1024; // Build uses a period of 2048. + listener.angle = -(float)pp->pang * pi::pi() / 1024; // Build uses a period of 2048. listener.velocity.Zero(); listener.position = GetSoundPos((vec3_t*)&pp->posx); listener.underwater = false; diff --git a/source/sw/src/sync.cpp b/source/sw/src/sync.cpp index b52a6129b..f521ff3c9 100644 --- a/source/sw/src/sync.cpp +++ b/source/sw/src/sync.cpp @@ -76,7 +76,7 @@ PlayerSync(void) updatecrc(crc, pp->posx & 255); updatecrc(crc, pp->posy & 255); updatecrc(crc, pp->posz & 255); - updatecrc(crc, fix16_to_int(pp->q16ang) & 255); + updatecrc(crc, pp->pang & 255); } return (uint8_t) crc & 255; @@ -93,7 +93,7 @@ PlayerSync2(void) { pp = Player + i; - updatecrc(crc, fix16_to_int(pp->q16horiz) & 255); + updatecrc(crc, pp->horiz & 255); updatecrc(crc, User[pp->PlayerSprite]->Health & 255); updatecrc(crc, pp->bcnt & 255); } @@ -544,7 +544,7 @@ getsyncbyte() { pp = Player + i; u = User[pp->SpriteP - sprite]; - ch ^= (pp->posx ^ pp->posy ^ pp->posz ^ fix16_to_int(pp->q16ang) ^ fix16_to_int(pp->q16horiz) ^ u->Health); + ch ^= (pp->posx ^ pp->posy ^ pp->posz ^ pp->pang ^ pp->horiz ^ u->Health); } for (j = headspritestat[STAT_ENEMY]; j >= 0; j = nextspritestat[j]) diff --git a/source/sw/src/track.cpp b/source/sw/src/track.cpp index b09bb3b53..f18ef84ac 100644 --- a/source/sw/src/track.cpp +++ b/source/sw/src/track.cpp @@ -34,7 +34,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "ai.h" #include "player.h" #include "game.h" -#include "interp.h" #include "network.h" #include "sprite.h" #include "track.h" @@ -789,7 +788,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) if (pp->posx > xlow && pp->posx < xhigh && pp->posy > ylow && pp->posy < yhigh) { - pp->RevolveAng = pp->q16ang; + pp->RevolveAng = pp->pang; pp->RevolveX = pp->posx; pp->RevolveY = pp->posy; pp->RevolveDeltaAng = 0; @@ -849,7 +848,6 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) // // Make sure every sector object has an outer loop tagged - important - // Further setup interpolation // FoundOutsideLoop = FALSE; @@ -862,21 +860,6 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) // move all walls in sectors for (k = startwall; k <= endwall; k++) { - uint16_t const nextwall = wall[k].nextwall; - - // setup interpolation - if (InterpolateSectObj) - { - setinterpolation(&wall[k].x); - setinterpolation(&wall[k].y); - - if (nextwall < MAXWALLS) - { - setinterpolation(&wall[wall[nextwall].point2].x); - setinterpolation(&wall[wall[nextwall].point2].y); - } - } - // for morph point - tornado style if (wall[k].lotag == TAG_WALL_ALIGN_SLOPE_TO_POINT) sop->morph_wall_point = k; @@ -886,16 +869,10 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) // each wall has this set - for collision detection SET(wall[k].extra, WALLFX_SECTOR_OBJECT|WALLFX_DONT_STICK); + uint16_t const nextwall = wall[k].nextwall; if (nextwall < MAXWALLS) SET(wall[nextwall].extra, WALLFX_SECTOR_OBJECT|WALLFX_DONT_STICK); } - - // interpolate floor and ceiling - if (InterpolateSectObj && (k != startwall)) - { - setinterpolation(&(*sectp)->ceilingz); - setinterpolation(&(*sectp)->floorz); - } } if (!FoundOutsideLoop) @@ -995,8 +972,6 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) ASSERT(sn < SIZ(sop->sp_num) - 1); sop->sp_num[sn] = sp_num; - if (InterpolateSectObj) - setspriteinterpolation(sp); if (!TEST(sop->flags, SOBJ_SPRITE_OBJ)) @@ -1644,7 +1619,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny) { SET(pp->Flags, PF_PLAYER_RIDING); - pp->RevolveAng = pp->q16ang; + pp->RevolveAng = pp->pang; pp->RevolveX = pp->posx; pp->RevolveY = pp->posy; @@ -1655,11 +1630,6 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny) pp->posx += BOUND_4PIX(nx); pp->posy += BOUND_4PIX(ny); - if (!InterpolateSectObj) - { - pp->oposx = pp->posx; - pp->oposy = pp->posy; - } if (TEST(sop->flags, SOBJ_DONT_ROTATE)) { @@ -1674,7 +1644,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny) // save the current information so when Player stops // moving then you // know where he was last - pp->RevolveAng = pp->q16ang; + pp->RevolveAng = pp->pang; pp->RevolveX = pp->posx; pp->RevolveY = pp->posy; @@ -1690,13 +1660,13 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny) pp->RevolveY += BOUND_4PIX(ny); // Last known angle is now adjusted by the delta angle - pp->RevolveAng = fix16_ssub(pp->q16ang, pp->RevolveDeltaAng) & 0x7FFFFFF; + pp->RevolveAng = NORM_ANGLE(pp->pang - pp->RevolveDeltaAng); } // increment Players delta angle - pp->RevolveDeltaAng = fix16_sadd(pp->RevolveDeltaAng, fix16_from_int(GlobSpeedSO)) & 0x7FFFFFF; + pp->RevolveDeltaAng = NORM_ANGLE(pp->RevolveDeltaAng + GlobSpeedSO); - rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&pp->RevolveX, fix16_to_int(pp->RevolveDeltaAng), (vec2_t *)&pp->posx); + rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&pp->RevolveX, pp->RevolveDeltaAng, (vec2_t *)&pp->posx); // THIS WAS CAUSING PROLEMS!!!! // Sectors are still being manipulated so you can end up in a void (-1) sector @@ -1704,9 +1674,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny) // New angle is formed by taking last known angle and // adjusting by the delta angle - pp->q16ang = fix16_sadd(pp->RevolveAng, pp->RevolveDeltaAng) & 0x7FFFFFF; - if (!InterpolateSectObj) - pp->oq16ang = pp->q16ang; + pp->pang = NORM_ANGLE(pp->RevolveAng + pp->RevolveDeltaAng); UpdatePlayerSprite(pp); } @@ -1959,8 +1927,6 @@ PlayerPart: pp->SpriteP->z = pp->loz; } } - if (!InterpolateSectObj) - pp->oposz = pp->posz; } else { @@ -2075,8 +2041,6 @@ void KillSectorObjectSprites(SECTOR_OBJECTp sop) if (sp->picnum == ST1 && sp->hitag == SPAWN_SPOT) continue; - if (InterpolateSectObj) - stopspriteinterpolation(sp); KillSprite(sop->sp_num[i]); } diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 0756a69db..37d5cb9ca 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -31,7 +31,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "names2.h" #include "panel.h" #include "game.h" -#include "interp.h" #include "tags.h" #include "common_game.h" #include "break.h" @@ -11393,8 +11392,6 @@ AddSpriteToSectorObject(short SpriteNum, SECTOR_OBJECTp sop) ASSERT(sn < SIZ(sop->sp_num) - 1); sop->sp_num[sn] = SpriteNum; - if (InterpolateSectObj) - setspriteinterpolation(sp); SET(u->Flags, SPR_ON_SO_SECTOR|SPR_SO_ATTACHED); @@ -11461,8 +11458,6 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop) ASSERT(sn < SIZ(sop->sp_num) - 1); sop->sp_num[sn] = explosion; - if (InterpolateSectObj) - setspriteinterpolation(exp); // Place sprite exactly where shoot point is //exp->x = eu->ox = sop->xmid - u->sx; @@ -12846,7 +12841,7 @@ DoRing(int16_t Weapon) sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14; if (User[sp->owner]->PlayerP) - sp->z += (u->Dist * ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT)) >> 9; + sp->z += (u->Dist * ((100 - pp->horiz) * HORIZ_MULT)) >> 9; //sp->ang = NORM_ANGLE(sp->ang + 512); //updatesector(sp->x, sp->y); @@ -12894,7 +12889,7 @@ InitSpellRing(PLAYERp pp) ang_diff = 2048 / max_missiles; - ang_start = NORM_ANGLE(fix16_to_int(pp->q16ang) - DIV2(2048)); + ang_start = NORM_ANGLE(pp->pang - DIV2(2048)); if (!SW_SHAREWARE) PlaySound(DIGI_RFWIZ, pp, v3df_none); @@ -12933,7 +12928,7 @@ InitSpellRing(PLAYERp pp) // put it out there sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14; sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14; - sp->z = pp->posz + Z(20) + ((u->Dist * ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT)) >> 9); + sp->z = pp->posz + Z(20) + ((u->Dist * ((100 - pp->horiz) * HORIZ_MULT)) >> 9); sp->ang = NORM_ANGLE(sp->ang + 512); @@ -13453,7 +13448,7 @@ InitSpellNapalm(PLAYERp pp) for (i = 0; i < SIZ(mp); i++) { SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Napalm, pp->cursectnum, - pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), NAPALM_VELOCITY*2); + pp->posx, pp->posy, pp->posz + Z(12), pp->pang, NAPALM_VELOCITY*2); sp = &sprite[SpriteNum]; u = User[SpriteNum]; @@ -13472,7 +13467,7 @@ InitSpellNapalm(PLAYERp pp) sp->xrepeat = 32; sp->yrepeat = 32; sp->clipdist = 0; - sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + sp->zvel = ((100 - pp->horiz) * HORIZ_MULT); SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); SET(u->Flags2, SPR2_BLUR_TAPER_FAST); @@ -13613,7 +13608,7 @@ InitSpellMirv(PLAYERp pp) return 0; SpriteNum = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Mirv, pp->cursectnum, - pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), MIRV_VELOCITY); + pp->posx, pp->posy, pp->posz + Z(12), pp->pang, MIRV_VELOCITY); sp = &sprite[SpriteNum]; u = User[SpriteNum]; @@ -13627,7 +13622,7 @@ InitSpellMirv(PLAYERp pp) sp->xrepeat = 72; sp->yrepeat = 72; sp->clipdist = 32L >> 2; - sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + sp->zvel = ((100 - pp->horiz) * HORIZ_MULT); SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); @@ -13728,7 +13723,7 @@ InitSwordAttack(PLAYERp pp) { bp = &sprite[bubble]; - bp->ang = fix16_to_int(pp->q16ang); + bp->ang = pp->pang; random_amt = (RANDOM_P2(32<<8)>>8) - 16; @@ -13777,8 +13772,8 @@ InitSwordAttack(PLAYERp pp) short daang; int daz; - daang = fix16_to_int(pp->q16ang); - daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000); + daang = pp->pang; + daz = ((100 - pp->horiz) * 2000) + (RANDOM_RANGE(24000) - 12000); FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang @@ -13905,7 +13900,7 @@ InitFistAttack(PLAYERp pp) { bp = &sprite[bubble]; - bp->ang = fix16_to_int(pp->q16ang); + bp->ang = pp->pang; random_amt = (RANDOM_P2(32<<8)>>8) - 16; @@ -13967,8 +13962,8 @@ InitFistAttack(PLAYERp pp) short daang; int daz; - daang = fix16_to_int(pp->q16ang); - daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000); + daang = pp->pang; + daz = ((100 - pp->horiz) * 2000) + (RANDOM_RANGE(24000) - 12000); FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang @@ -14626,7 +14621,7 @@ InitStar(PLAYERp pp) // Spawn a shot // Inserting and setting up variables - w = SpawnSprite(STAT_MISSILE, STAR1, s_Star, pp->cursectnum, nx, ny, nz, fix16_to_int(pp->q16ang), STAR_VELOCITY); + w = SpawnSprite(STAT_MISSILE, STAR1, s_Star, pp->cursectnum, nx, ny, nz, pp->pang, STAR_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -14641,7 +14636,7 @@ InitStar(PLAYERp pp) wp->clipdist = 32L >> 2; // wp->zvel was overflowing with this calculation - had to move to a local // long var - zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ)); + zvel = ((100 - pp->horiz) * (HORIZ_MULT+STAR_HORIZ_ADJ)); wu->ceiling_dist = Z(1); wu->floor_dist = Z(1); @@ -14698,7 +14693,7 @@ InitStar(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(np)) SET(nu->Flags, SPR_UNDERWATER); - zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+STAR_HORIZ_ADJ)); + zvel = ((100 - pp->horiz) * (HORIZ_MULT+STAR_HORIZ_ADJ)); np->zvel = zvel >> 1; if (MissileSetPos(nw, DoStar, 1000)) @@ -14749,7 +14744,7 @@ InitHeartAttack(PLAYERp pp) return; SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum, - pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), BLOOD_WORM_VELOCITY*2); + pp->posx, pp->posy, pp->posz + Z(12), pp->pang, BLOOD_WORM_VELOCITY*2); sp = &sprite[SpriteNum]; u = User[SpriteNum]; @@ -14762,7 +14757,7 @@ InitHeartAttack(PLAYERp pp) sp->xrepeat = 52; sp->yrepeat = 52; sp->clipdist = 0; - sp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + sp->zvel = ((100 - pp->horiz) * HORIZ_MULT); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); SET(u->Flags2, SPR2_DONT_TARGET_OWNER); SET(sp->cstat, CSTAT_SPRITE_INVISIBLE); @@ -14825,7 +14820,7 @@ InitHeartAttack(PLAYERp pp) return; SpriteNum = SpawnSprite(STAT_MISSILE_SKIP4, BLOOD_WORM, s_BloodWorm, pp->cursectnum, - pp->posx, pp->posy, pp->posz + Z(12), fix16_to_int(pp->q16ang), BLOOD_WORM_VELOCITY*2); + pp->posx, pp->posy, pp->posz + Z(12), pp->pang, BLOOD_WORM_VELOCITY*2); sp = &sprite[SpriteNum]; u = User[SpriteNum]; @@ -14986,8 +14981,8 @@ InitShotgun(PLAYERp pp) } else { - daz = (100 - fix16_to_int(pp->q16horiz)) * 2000; - daang = fix16_to_int(pp->q16ang); + daz = (100 - pp->horiz) * 2000; + daang = pp->pang; } for (i = 0; i < 12; i++) @@ -15149,7 +15144,7 @@ InitLaser(PLAYERp pp) // Inserting and setting up variables w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, s_Laser, pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), 300); + nx, ny, nz, pp->pang, 300); wp = &sprite[w]; wu = User[w]; @@ -15162,7 +15157,7 @@ InitLaser(PLAYERp pp) wp->clipdist = 64L>>2; // the slower the missile travels the less of a zvel it needs - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel /= 4; wu->WeaponNum = u->WeaponNum; @@ -15261,7 +15256,7 @@ InitRail(PLAYERp pp) // Inserting and setting up variables w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R1, &s_Rail[0][0], pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), 1200); + nx, ny, nz, pp->pang, 1200); wp = &sprite[w]; wu = User[w]; @@ -15270,7 +15265,7 @@ InitRail(PLAYERp pp) wp->yrepeat = 52; wp->xrepeat = 52; wp->shade = -15; - zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+17)); + zvel = ((100 - pp->horiz) * (HORIZ_MULT+17)); wu->RotNum = 5; NewStateGroup(w, &sg_Rail[0]); @@ -15460,7 +15455,7 @@ InitRocket(PLAYERp pp) //nz = pp->posz + pp->bob_z + Z(12); nz = pp->posz + pp->bob_z + Z(8); w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), ROCKET_VELOCITY); + nx, ny, nz, pp->pang, ROCKET_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -15470,7 +15465,7 @@ InitRocket(PLAYERp pp) wp->yrepeat = 90; wp->xrepeat = 90; wp->shade = -15; - zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+35)); + zvel = ((100 - pp->horiz) * (HORIZ_MULT+35)); wp->clipdist = 64L>>2; @@ -15581,7 +15576,7 @@ InitBunnyRocket(PLAYERp pp) //nz = pp->posz + pp->bob_z + Z(12); nz = pp->posz + pp->bob_z + Z(8); w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R4, &s_BunnyRocket[0][0], pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), ROCKET_VELOCITY); + nx, ny, nz, pp->pang, ROCKET_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -15591,7 +15586,7 @@ InitBunnyRocket(PLAYERp pp) wp->yrepeat = 64; wp->xrepeat = 64; wp->shade = -15; - zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT+35)); + zvel = ((100 - pp->horiz) * (HORIZ_MULT+35)); wp->clipdist = 64L>>2; @@ -15695,7 +15690,7 @@ InitNuke(PLAYERp pp) //nz = pp->posz + pp->bob_z + Z(12); nz = pp->posz + pp->bob_z + Z(8); w = SpawnSprite(STAT_MISSILE, BOLT_THINMAN_R0, &s_Rocket[0][0], pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), 700); + nx, ny, nz, pp->pang, 700); wp = &sprite[w]; wu = User[w]; @@ -15705,7 +15700,7 @@ InitNuke(PLAYERp pp) wp->yrepeat = 128; wp->xrepeat = 128; wp->shade = -15; - zvel = ((100 - fix16_to_int(pp->q16horiz)) * (HORIZ_MULT-36)); + zvel = ((100 - pp->horiz) * (HORIZ_MULT-36)); wp->clipdist = 64L>>2; // Set to red palette @@ -15758,7 +15753,7 @@ InitNuke(PLAYERp pp) wu->ychange = MOVEy(wp->xvel, wp->ang); wu->zchange = zvel; - PlayerDamageSlide(pp, -40, NORM_ANGLE(fix16_to_int(pp->q16ang)+1024)); // Recoil slide + PlayerDamageSlide(pp, -40, NORM_ANGLE(pp->pang+1024)); // Recoil slide return 0; } @@ -15893,7 +15888,7 @@ InitMicro(PLAYERp pp) { hp = NULL; hu = NULL; - ang = fix16_to_int(pp->q16ang); + ang = pp->pang; } nz = pp->posz + pp->bob_z + Z(14); @@ -15912,7 +15907,7 @@ InitMicro(PLAYERp pp) wp->yrepeat = 24; wp->xrepeat = 24; wp->shade = -15; - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->clipdist = 64L>>2; // randomize zvelocity @@ -17442,14 +17437,14 @@ InitTracerUzi(PLAYERp pp) nx = pp->posx; ny = pp->posy; //nz = pp->posz + pp->bob_z + Z(8); - //nz = pp->posz + pp->bob_z + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72); - nz = pp->posz + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72); + //nz = pp->posz + pp->bob_z + Z(8) + ((100 - pp->horiz) * 72); + nz = pp->posz + Z(8) + ((100 - pp->horiz) * 72); // Spawn a shot // Inserting and setting up variables w = SpawnSprite(STAT_MISSILE, 0, s_Tracer, pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), TRACER_VELOCITY); + nx, ny, nz, pp->pang, TRACER_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -17461,7 +17456,7 @@ InitTracerUzi(PLAYERp pp) wp->xrepeat = 10; wp->shade = -40; wp->zvel = 0; - //wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + //wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->clipdist = 32 >> 2; wu->WeaponNum = u->WeaponNum; @@ -17488,7 +17483,7 @@ InitTracerUzi(PLAYERp pp) return 0; } - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8)); + wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); pp->SpriteP->clipdist = oclipdist; @@ -17731,8 +17726,8 @@ int SpawnWallHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_ sp->ang = NORM_ANGLE(wall_ang + 1024); // int nx,ny; - //nx = (sintable[(512 + fix16_to_int(Player[0].q16ang)) & 2047] >> 7); - //ny = (sintable[fix16_to_int(Player[0].q16ang)] >> 7); + //nx = (sintable[(512 + Player[0].pang) & 2047] >> 7); + //ny = (sintable[Player[0].pang] >> 7); //sp->x -= nx; //sp->y -= ny; @@ -17838,9 +17833,9 @@ InitUzi(PLAYERp pp) } else { - //daang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(50) - 25)); - daang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(24) - 12)); - daz = ((100 - fix16_to_int(pp->q16horiz)) * 2000) + (RANDOM_RANGE(24000) - 12000); + //daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25)); + daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(24) - 12)); + daz = ((100 - pp->horiz) * 2000) + (RANDOM_RANGE(24000) - 12000); } @@ -18015,8 +18010,8 @@ InitEMP(PLAYERp pp) InitTracerUzi(pp); - //daz = nz = pp->posz + Z(8) + ((100 - fix16_to_int(pp->q16horiz)) * 72); - //daang = NORM_ANGLE(fix16_to_int(pp->q16ang) + (RANDOM_RANGE(50) - 25)); + //daz = nz = pp->posz + Z(8) + ((100 - pp->horiz) * 72); + //daang = NORM_ANGLE(pp->pang + (RANDOM_RANGE(50) - 25)); daz = nz = pp->posz + pp->bob_z; daang = 64; @@ -18025,8 +18020,8 @@ InitEMP(PLAYERp pp) } else { - daz = (100 - fix16_to_int(pp->q16horiz)) * 2000; - daang = fix16_to_int(pp->q16ang); + daz = (100 - pp->horiz) * 2000; + daang = pp->pang; } FAFhitscan(pp->posx, pp->posy, nz, pp->cursectnum, // Start position @@ -18199,7 +18194,7 @@ InitTankShell(short SpriteNum, PLAYERp pp) SET(wp->cstat, CSTAT_SPRITE_YCENTER); SET(wp->cstat, CSTAT_SPRITE_INVISIBLE); - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8)); + wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); WeaponAutoAim(sp, w, 64, FALSE); // a bit of randomness @@ -18278,7 +18273,7 @@ InitTurretMicro(short SpriteNum, PLAYERp pp) wp->yrepeat = 24; wp->xrepeat = 24; wp->shade = -15; - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->clipdist = 64L>>2; // randomize zvelocity @@ -18359,7 +18354,7 @@ InitTurretRocket(short SpriteNum, PLAYERp pp) SET(wu->Flags2, SPR2_SO_MISSILE); SET(wp->cstat, CSTAT_SPRITE_YCENTER); - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8)); + wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); WeaponAutoAim(sp, w, 64, FALSE); // a bit of randomness @@ -18406,7 +18401,7 @@ InitTurretFireball(short SpriteNum, PLAYERp pp) SET(wu->Flags2, SPR2_SO_MISSILE); SET(wp->cstat, CSTAT_SPRITE_YCENTER); - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * (wp->xvel/8)); + wp->zvel = ((100 - pp->horiz) * (wp->xvel/8)); WeaponAutoAim(sp, w, 64, FALSE); // a bit of randomness @@ -18455,7 +18450,7 @@ InitTurretRail(short SpriteNum, PLAYERp pp) wp->yrepeat = 52; wp->xrepeat = 52; wp->shade = -15; - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wu->RotNum = 5; NewStateGroup(w, &sg_Rail[0]); @@ -18515,7 +18510,7 @@ InitTurretLaser(short SpriteNum, PLAYERp pp) wp->shade = -15; // the slower the missile travels the less of a zvel it needs - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wp->zvel /= 4; wu->Radius = 200; @@ -18562,7 +18557,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp) nsect = sp->sectnum; if (RANDOM_P2(1024) < 200) - InitTracerTurret(sp - sprite, pp->PlayerSprite, fix16_to_int(pp->q16horiz)); + InitTracerTurret(sp - sprite, pp->PlayerSprite, pp->horiz); daang = 64; if (WeaponAutoAimHitscan(sp, &daz, &daang, FALSE) != -1) @@ -18573,7 +18568,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp) else { int horiz; - horiz = fix16_to_int(pp->q16horiz); + horiz = pp->horiz; if (horiz < 75) horiz = 75; @@ -19283,7 +19278,7 @@ InitGrenade(PLAYERp pp) // Inserting and setting up variables w = SpawnSprite(STAT_MISSILE, GRENADE, &s_Grenade[0][0], pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), GRENADE_VELOCITY); + nx, ny, nz, pp->pang, GRENADE_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -19315,9 +19310,9 @@ InitGrenade(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) SET(wu->Flags, SPR_UNDERWATER); - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); - ////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",fix16_to_int(pp->q16horiz), fix16_to_int(pp->q16horizoff), fix16_to_int(pp->q16horizoff + pp->q16horiz)); + ////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d",pp->horiz, pp->horizoff, pp->horizoff + pp->horiz); //MONO_PRINT(ds); oclipdist = pp->SpriteP->clipdist; @@ -19452,7 +19447,7 @@ InitMine(PLAYERp pp) // Inserting and setting up variables w = SpawnSprite(STAT_MISSILE, MINE, s_Mine, pp->cursectnum, - nx, ny, nz, fix16_to_int(pp->q16ang), MINE_VELOCITY); + nx, ny, nz, pp->pang, MINE_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -19462,7 +19457,7 @@ InitMine(PLAYERp pp) wp->xrepeat = 32; wp->shade = -15; wp->clipdist = 128L>>2; - wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); wu->WeaponNum = u->WeaponNum; wu->Radius = 200; wu->ceiling_dist = Z(5); @@ -19475,7 +19470,7 @@ InitMine(PLAYERp pp) if (TEST(pp->Flags, PF_DIVING) || SpriteInUnderwaterArea(wp)) SET(wu->Flags, SPR_UNDERWATER); - //wp->zvel = ((100 - fix16_to_int(pp->q16horiz)) * HORIZ_MULT); + //wp->zvel = ((100 - pp->horiz) * HORIZ_MULT); MissileSetPos(w, DoMine, 800); @@ -19483,7 +19478,7 @@ InitMine(PLAYERp pp) wu->xchange = MOVEx(wp->xvel, wp->ang); wu->ychange = MOVEy(wp->xvel, wp->ang); - dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang)+512)], sintable[fix16_to_int(pp->q16ang)]); + dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(pp->pang+512)], sintable[pp->pang]); // don't adjust for strafing if (labs(dot) > 10000) @@ -19613,7 +19608,7 @@ InitFireball(PLAYERp pp) nz = pp->posz + pp->bob_z + Z(15); - w = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Fireball, pp->cursectnum, nx, ny, nz, fix16_to_int(pp->q16ang), FIREBALL_VELOCITY); + w = SpawnSprite(STAT_MISSILE, FIREBALL1, s_Fireball, pp->cursectnum, nx, ny, nz, pp->pang, FIREBALL_VELOCITY); wp = &sprite[w]; wu = User[w]; @@ -19628,8 +19623,8 @@ InitFireball(PLAYERp pp) wu->ceiling_dist = Z(6); wu->floor_dist = Z(6); - //zvel = ((100 - fix16_to_int(pp->q16horiz)) * (100+ADJUST)); - zvel = ((100 - fix16_to_int(pp->q16horiz)) * (240L)); + //zvel = ((100 - pp->horiz) * (100+ADJUST)); + zvel = ((100 - pp->horiz) * (240L)); //wu->RotNum = 5; //NewStateGroup(w, &sg_Fireball); diff --git a/source/sw/src/zombie.cpp b/source/sw/src/zombie.cpp index 709f2a8f0..9f35a5020 100644 --- a/source/sw/src/zombie.cpp +++ b/source/sw/src/zombie.cpp @@ -790,7 +790,7 @@ SpawnZombie(PLAYERp pp, short Weapon) //Zombies++; - New = SpawnSprite(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], pp->cursectnum, pp->posx, pp->posy, pp->posz, fix16_to_int(pp->q16ang), 0); + New = SpawnSprite(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->pang, 0); np = &sprite[New]; nu = User[New]; np->sectnum = pp->cursectnum;