diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index 2d06adcf8..86a3e7aa5 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -75,7 +75,6 @@ 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); @@ -1924,7 +1923,6 @@ short ScreenSavePic = FALSE; SWBOOL PicInView(short, SWBOOL); void DoPlayerDiveMeter(PLAYERp pp); -void MoveScrollMode2D(PLAYERp pp); void drawscreen(PLAYERp pp) @@ -2193,8 +2191,8 @@ drawscreen(PLAYERp pp) if (ScrollMode2D) { - tx = Follow_posx; - ty = Follow_posy; + tx = pp->mfposx; + ty = pp->mfposy; } for (j = 0; j < MAXSPRITES; j++) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index b0efade83..3a89daf8d 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -146,7 +146,6 @@ char DemoText[3][64]; int DemoTextYstart = 0; SWBOOL DoubleInitAWE32 = FALSE; -int Follow_posx=0,Follow_posy=0; SWBOOL NoMeters = FALSE; short IntroAnimCount = 0; @@ -2983,7 +2982,8 @@ void getinput(int const playerNum) static int32_t turnheldtime; - // reset localInput + // reset objects. + SW_PACKET input {}; localInput = {}; localInput.bits = 0; @@ -3018,62 +3018,6 @@ void getinput(int const playerNum) 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 + playerNum && !Prediction) - MoveScrollMode2D(Player + playerNum); - - // !JIM! Added M_Active() so that you don't move at all while using menus - if (M_Active() || ScrollMode2D || InputMode) - return; - - SET_LOC_KEY(localInput.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; @@ -3099,11 +3043,128 @@ 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); + 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; + pp->mfposx = pp->posx; + pp->mfposy = pp->posy; + } + } + + // If in 2D follow mode, scroll around. + if (ScrollMode2D && !Prediction) + { + extern SWBOOL HelpInputMode, ScrollMode2D; + keymove = keymove / 6; + + 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); + ScrollMode2D = !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() || 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; - SW_PACKET input {}; - if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) { input.svel = -info.mousex; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index d5bc2b397..e4d235bdc 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -1030,6 +1030,9 @@ struct PLAYERstruct int oposx, oposy, oposz; + // Map follow mode pos values. + int32_t mfposx, mfposy; + // holds last valid move position short lv_sectnum; int lv_x,lv_y,lv_z; @@ -1843,7 +1846,6 @@ 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 *); diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 5d26daea9..7d6f5d0c9 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -81,7 +81,6 @@ 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)) extern unsigned char palette_data[256][3]; // Global palette array @@ -2211,132 +2210,6 @@ 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(fix16_to_int(pp->q16ang) + 512)]); - momy = mulscale9(mfvel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang))]); - - momx += mulscale9(mfsvel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang))]); - momy += mulscale9(mfsvel, sintable[NORM_ANGLE(fix16_to_int(pp->q16ang) + 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) { diff --git a/source/sw/src/player.h b/source/sw/src/player.h index b841a9644..513277ebe 100644 --- a/source/sw/src/player.h +++ b/source/sw/src/player.h @@ -130,7 +130,6 @@ 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);