diff --git a/src/g_input.c b/src/g_input.c index 0082df273..1a420c996 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -945,6 +945,8 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color) static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) { + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); + if (cv_gamepadled[playernum].value == 0) { I_SetGamepadIndicatorColor(playernum, 0, 0, 255); @@ -973,13 +975,8 @@ void G_DeviceLEDTick(void) newcolor = G_GetSkinColorForGamepad(i); - // compiler be absolutely tripping - // delet this if this gets fixed within gcc -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" if (curcolor[i] == newcolor) // dont update if same colour continue; -#pragma GCC diagnostic pop G_SetPlayerGamepadIndicatorColor(i, newcolor); curcolor[i] = newcolor; @@ -994,6 +991,7 @@ void G_ResetDeviceLED(void) static void G_ResetPlayerDeviceRumble(INT32 playernum) { + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); I_GamepadRumble(playernum, 0, 0, 0); } diff --git a/src/m_menu.c b/src/m_menu.c index 16f261ae5..e69f834ce 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7901,7 +7901,7 @@ static void M_HandleConnectIP(INT32 choice) if (exitmenu) { if (currentMenu->prevMenu) - M_SetupNextMenu (currentMenu->prevMenu); + M_SetupNextMenu(currentMenu->prevMenu); else M_ClearMenus(true); } @@ -8270,10 +8270,9 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 curx = (((setupm_skinselect % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH/2)) + SKINXSHIFT) + 20; INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ gridyoffset); - UINT8 cursorframe = (I_GetTime() / 4) % 7; - - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); - V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); + UINT8 cursorframe = (I_GetTime() / 4) % 7; + cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); + V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } break; @@ -8312,14 +8311,12 @@ static void M_DrawSetupMultiPlayerMenu(void) if (setupm_skinselect < numskins) { UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE); - cursor = facewantprefix[skinsorted[setupm_skinselect]]; V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap); } else { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } @@ -8383,7 +8380,6 @@ static void M_DrawSetupMultiPlayerMenu(void) else { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } @@ -8508,7 +8504,7 @@ static void M_DrawSetupMultiPlayerMenu(void) switch (cv_skinselectmenu.value) { case SKINMENUTYPE_2D: - skintodisplay = setupm_fakeskin; + skintodisplay = (UINT8)setupm_fakeskin; if (setupm_skinlockedselect) // show the skin we are trying to select skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) @@ -8516,13 +8512,16 @@ static void M_DrawSetupMultiPlayerMenu(void) break; case SKINMENUTYPE_EXTENDED: case SKINMENUTYPE_GRID: - skintodisplay = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin); + skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (UINT8)setupm_fakeskin); break; default: - skintodisplay = setupm_fakeskin; + skintodisplay = (UINT8)setupm_fakeskin; break; } + if (skintodisplay >= MAXSKINS) + skintodisplay = 0; + skinnum = R_SkinAvailable(skins[skintodisplay].name); if (skinnum < 0 || skinnum >= MAXSKINS) @@ -8537,18 +8536,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (frame >= sprdef->numframes) // Walking animation missing frame = 0; // Try to use standing frame - sprframe = &sprdef->spriteframes[frame]; - - // minenice's speen css, it's a piece of shit but hey - speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; - - // this is a very shitty solution for checking if a sprite needs flipping - // but it works - if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) - flags = V_FLIP; // This sprite is left/right flipped! - - patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); - // draw box around guy V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); #undef charw @@ -8559,33 +8546,47 @@ static void M_DrawSetupMultiPlayerMenu(void) UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); #ifdef HWRENDER md2_t *md2 = &md2_playermodels[skinnum]; - +#endif + mx += 36; + my += 131; +#ifdef HWRENDER // if we have 3d models enabled and a model exists // try to show it instead of the sprite if (rendermode == render_opengl && cv_glmdls.value && !md2->error && !md2->notfound) { - mx += 36; - my += 131; - const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 8*FRACUNIT/3, frame, angle); } else #endif { + sprframe = &sprdef->spriteframes[frame]; + + // minenice's speen css, it's a piece of shit but hey + speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; + + // this is a very shitty solution for checking if a sprite needs flipping + // but it works + if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) + { + flags = V_FLIP; // This sprite is left/right flipped! + } + + patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); + if (skins[skintodisplay].flags & SF_HIRES) { - V_DrawFixedPatch((mx+36)<= sprdef->numframes) // Walking animation missing frame = 0; // Try to use standing frame - sprframe = &sprdef->spriteframes[frame]; - - //minenice's speen css, it's a piece of shit but hey - //patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[1], PU_PATCH); - speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; - - //this is a very shitty solution for checking if a sprite needs flipping - //but it works - if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) - { - flags = V_FLIP; // This sprite is left/right flipped! - } - patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); - // draw box around guy V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239); #undef charw - // draw player sprite UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin); V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap); @@ -9946,6 +9932,9 @@ static void M_DrawLocalSkinMenu(void) V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname); // draw player sprite + mx += 220; + my += 120; + #ifdef HWRENDER md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[skintodisplay] : &md2_playermodels[skintodisplay]); @@ -9954,24 +9943,35 @@ static void M_DrawLocalSkinMenu(void) if (rendermode == render_opengl && cv_glmdls.value && !md2->error && !md2->notfound) { - mx += 220; - my += 120; - const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - HWR_Draw2DModel(md2, mx, my, skintodisplay, (skincolors_t)cv_playercolor.value, colormap, 8*FRACUNIT/3, frame, angle); } else #endif { + sprframe = &sprdef->spriteframes[frame]; + + // minenice's speen css, it's a piece of shit but hey + speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; + + // this is a very shitty solution for checking if a sprite needs flipping + // but it works + if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) + { + flags = V_FLIP; // This sprite is left/right flipped! + } + + patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); + if (displayskin.flags & SF_HIRES) { - V_DrawFixedPatch((mx+220)<dev = NULL; JoySet->oldjoy = -1; JoySet->id = -1; - JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0; } /** \brief SDL info about joystick */ -SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS]; +SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS] = {}; INT32 numcontrollers = 0; // @@ -740,26 +739,26 @@ INT32 numcontrollers = 0; // void I_JoyScale(void) { - Joystick[0].bGamepadStyle = cv_joyscale[0].value==0; - JoyInfo[0].scale = Joystick[0].bGamepadStyle?1:cv_joyscale[0].value; + Joystick[0].bGamepadStyle = cv_joyscale[0].value == 0; + JoyInfo[0].scale = Joystick[0].bGamepadStyle ? 1 : cv_joyscale[0].value; } void I_JoyScale2(void) { - Joystick[1].bGamepadStyle = cv_joyscale[1].value==0; - JoyInfo[1].scale = Joystick[1].bGamepadStyle?1:cv_joyscale[1].value; + Joystick[1].bGamepadStyle = cv_joyscale[1].value == 0; + JoyInfo[1].scale = Joystick[1].bGamepadStyle ? 1 : cv_joyscale[1].value; } void I_JoyScale3(void) { - Joystick[2].bGamepadStyle = cv_joyscale[2].value==0; - JoyInfo[2].scale = Joystick[2].bGamepadStyle?1:cv_joyscale[2].value; + Joystick[2].bGamepadStyle = cv_joyscale[2].value == 0; + JoyInfo[2].scale = Joystick[2].bGamepadStyle ? 1 : cv_joyscale[2].value; } void I_JoyScale4(void) { - Joystick[3].bGamepadStyle = cv_joyscale[3].value==0; - JoyInfo[3].scale = Joystick[3].bGamepadStyle?1:cv_joyscale[3].value; + Joystick[3].bGamepadStyle = cv_joyscale[3].value == 0; + JoyInfo[3].scale = Joystick[3].bGamepadStyle ? 1 : cv_joyscale[3].value; } // Cheat to get the device index for a joystick handle @@ -931,33 +930,18 @@ static int joy_open(int playerIndex, int joyIndex) } JoyInfo[playerIndex].dev = newdev; - JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); if (JoyInfo[playerIndex].dev == NULL) { CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError()); return -1; } - else - { - CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); - JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX; - if (JoyInfo[playerIndex].axises > JOYAXISSET*2) - JoyInfo[playerIndex].axises = JOYAXISSET*2; + CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); - JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX ; // dpad is 4 buttons - if (JoyInfo[playerIndex].buttons > JOYBUTTONS) - JoyInfo[playerIndex].buttons = JOYBUTTONS; + JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); - JoyInfo[playerIndex].hats = 4; - if (JoyInfo[playerIndex].hats > JOYHATS) - JoyInfo[playerIndex].hats = JOYHATS; - - JoyInfo[playerIndex].balls = 0; - - return JoyInfo[playerIndex].axises; - } + return SDL_CONTROLLER_AXIS_MAX; } // @@ -1002,7 +986,6 @@ void I_InitJoystick(UINT8 index) JoyInfo[index].dev = NULL; JoyInfo[index].oldjoy = -1; JoyInfo[index].id = -1; - JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0; if (cv_usejoystick[index].value) newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 1dcf028fb..982485a81 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -437,7 +437,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) } else { - raxis = JoyInfo[pid].scale!=1?((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale):raxis; + raxis = JoyInfo[pid].scale != 1 ? ((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale) : raxis; #ifdef SDL_JDEADZONE if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE) diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index e5bdca395..f7f4c011c 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -44,15 +44,15 @@ typedef struct SDLJoyInfo_s /// number of old joystick int oldjoy; /// number of axies - int axises; + //int axises; /// scale of axises INT32 scale; /// number of buttons - int buttons; + //int buttons; /// number of hats - int hats; + //int hats; /// number of balls - int balls; + //int balls; } SDLJoyInfo_t; /** \brief SDL info about controller 1