From 577005a595a1be030dfbdfc2e3d49a7765c2ab41 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 29 Oct 2009 20:21:54 +0000 Subject: [PATCH] helper for cycling through an enum --- stepmania/src/RageUtil.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index a5e115c4a9..79f977482b 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -183,6 +183,14 @@ static inline T enum_add2( T val, int iAmt ) return static_cast( val + iAmt ); } +template +static inline T enum_cycle( T val, int iMax, int iAmt = 1 ) +{ + int iVal = val + iAmt; + iVal %= iMax; + return static_cast( iVal ); +} + /* * We only have unsigned swaps; byte swapping a signed value doesn't make sense.