mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
Fix Control enum order which was causing excessive aliasing
This commit is contained in:
parent
f0e0e6e747
commit
9c8690bfae
@ -10,9 +10,7 @@ struct GameInputState {
|
||||
/* On Foot */
|
||||
FireWeapon = 0,
|
||||
NextWeapon,
|
||||
NextTarget = NextWeapon,
|
||||
LastWeapon,
|
||||
LastTarget = LastWeapon,
|
||||
GoForward,
|
||||
GoBackwards,
|
||||
GoLeft,
|
||||
@ -29,11 +27,8 @@ struct GameInputState {
|
||||
LookBehind,
|
||||
|
||||
/* In Vehicle */
|
||||
VehicleFireWeapon = FireWeapon,
|
||||
VehicleAccelerate,
|
||||
VehicleBrake,
|
||||
VehicleLeft = GoLeft,
|
||||
VehicleRight = GoRight,
|
||||
VehicleDown,
|
||||
VehicleUp,
|
||||
ChangeRadio,
|
||||
@ -47,7 +42,13 @@ struct GameInputState {
|
||||
VehicleAimUp,
|
||||
VehicleAimDown,
|
||||
|
||||
_MaxControls
|
||||
_MaxControls,
|
||||
|
||||
NextTarget = NextWeapon,
|
||||
LastTarget = LastWeapon,
|
||||
VehicleLeft = GoLeft,
|
||||
VehicleRight = GoRight,
|
||||
VehicleFireWeapon = FireWeapon,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,7 @@ set(TEST_SOURCES
|
||||
"test_GameWorld.cpp"
|
||||
"test_globals.hpp"
|
||||
"test_items.cpp"
|
||||
"test_Input.cpp"
|
||||
"test_lifetime.cpp"
|
||||
"test_loaderdff.cpp"
|
||||
"test_Logger.cpp"
|
||||
@ -49,6 +50,7 @@ set(TEST_SOURCES
|
||||
# Hack in rwgame sources until there's a per-target test suite
|
||||
"${CMAKE_SOURCE_DIR}/rwgame/GameConfig.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/rwgame/GameWindow.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/rwgame/GameInput.cpp"
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
|
||||
|
35
tests/test_Input.cpp
Normal file
35
tests/test_Input.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "GameInput.hpp"
|
||||
#include "test_globals.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(InputTests)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestStateUpdate) {
|
||||
BOOST_CHECK(GameInputState::Handbrake != GameInputState::Submission);
|
||||
BOOST_CHECK(GameInputState::Jump != GameInputState::Sprint);
|
||||
{
|
||||
// Currently tests against hard-coded input
|
||||
GameInputState state;
|
||||
|
||||
SDL_Event ev;
|
||||
ev.type = SDL_KEYDOWN;
|
||||
ev.key.keysym.sym = SDLK_SPACE;
|
||||
|
||||
GameInput::updateGameInputState(&state, ev);
|
||||
|
||||
// Check that the correct inputs report pressed
|
||||
for (int c = 0; c < GameInputState::_MaxControls; ++c) {
|
||||
switch ((GameInputState::Control)c) {
|
||||
case GameInputState::Jump:
|
||||
case GameInputState::Handbrake:
|
||||
BOOST_CHECK(state.pressed((GameInputState::Control)c));
|
||||
break;
|
||||
default:
|
||||
BOOST_CHECK(!state.pressed((GameInputState::Control)c));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
Loading…
Reference in New Issue
Block a user