From: Ash Tyndall Date: Sat, 8 Oct 2011 06:53:49 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=a1385468a8cf5aea7ae2f6db5a066e30c4bc0900;p=atyndall%2Fcits2231.git --- diff --git a/scene.c b/scene.c index 53b3187..553092e 100644 --- a/scene.c +++ b/scene.c @@ -246,10 +246,21 @@ void processLightEvents(int id) { } +int roundUp(int numToRound, int multiple) { + if(multiple == 0) { + return numToRound; + } + + int remainder = numToRound % multiple; + if (remainder == 0) + return numToRound; + return numToRound + multiple - remainder; +} + int makeSubmenuFromArray( const char *menuEntries[], unsigned int menuEntriesSize, void *callback ) { if ( menuEntriesSize == 0 ) return -1; - int menuNumber = menuEntriesSize / 10 + 1; + int menuNumber = roundUp(menuEntriesSize, 10) / 10; int submenuObjects[menuNumber-1]; for( int i = 0; i < menuNumber; i++ ) {