Fix: entering long numbers in preferences is no longer allowed
This commit is contained in:
		
							parent
							
								
									6ae1bdbfd7
								
							
						
					
					
						commit
						f6ba560da3
					
				
							
								
								
									
										19
									
								
								src/menu.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/menu.c
									
									
									
									
									
								
							| @ -135,6 +135,9 @@ void showInfoScreen() | |||||||
| // delete text at the end of one menu section
 | // delete text at the end of one menu section
 | ||||||
| void menuHandleInput(SDL_Event event){ | void menuHandleInput(SDL_Event event){ | ||||||
|     //compare 'handleInput_runningState(SDL_Event event)' in input.c
 |     //compare 'handleInput_runningState(SDL_Event event)' in input.c
 | ||||||
|  | 
 | ||||||
|  |     int numberOfContents = 0;   // count number of entered numbers by the user 
 | ||||||
|  | 
 | ||||||
|     switch(activeMenu) |     switch(activeMenu) | ||||||
|     {   |     {   | ||||||
|     // start
 |     // start
 | ||||||
| @ -189,8 +192,14 @@ void menuHandleInput(SDL_Event event){ | |||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|             case 1:     // confirm difficulty level
 |             case 1:     // confirm difficulty level
 | ||||||
|  |                 // count number of entered numbers
 | ||||||
|  |                 while (ttlStorage.textInput[numberOfContents] != '\0' && numberOfContents < sizeof(ttlStorage.textInput))  | ||||||
|  |                 { | ||||||
|  |                     numberOfContents++; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|                 // user input must be between 1 and 3
 |                 // user input must be between 1 and 3
 | ||||||
|                 if((ttlStorage.textInput[0] > '0') && (ttlStorage.textInput[0]  <= '3'))       |                 if((ttlStorage.textInput[0] > '0') && (ttlStorage.textInput[0]  <= '3') && numberOfContents == 1)       | ||||||
|                 {    |                 {    | ||||||
|                     ttlStorage.inputStatus++; |                     ttlStorage.inputStatus++; | ||||||
|                     strcpy(ttlStorage.numbers[0], ttlStorage.textInput);               // copy textInput to userDifficultyLevel     
 |                     strcpy(ttlStorage.numbers[0], ttlStorage.textInput);               // copy textInput to userDifficultyLevel     
 | ||||||
| @ -200,8 +209,14 @@ void menuHandleInput(SDL_Event event){ | |||||||
|                 break;   |                 break;   | ||||||
| 
 | 
 | ||||||
|             case 2:     // confirm map
 |             case 2:     // confirm map
 | ||||||
|  |                 // count number of entered numbers
 | ||||||
|  |                 while (ttlStorage.textInput[numberOfContents] != '\0' && numberOfContents < sizeof(ttlStorage.textInput))  | ||||||
|  |                 { | ||||||
|  |                     numberOfContents++; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|                 // user input must be between 1 and 3
 |                 // user input must be between 1 and 3
 | ||||||
|                 if((ttlStorage.textInput[0] > '0') && (ttlStorage.textInput[0]  <= '3'))       |                 if((ttlStorage.textInput[0] > '0') && (ttlStorage.textInput[0]  <= '3') && numberOfContents == 1)       | ||||||
|                 {    |                 {    | ||||||
|                     ttlStorage.inputStatus++; |                     ttlStorage.inputStatus++; | ||||||
|                     strcpy(ttlStorage.numbers[1], ttlStorage.textInput);               // copy textInput to userSelectedMap
 |                     strcpy(ttlStorage.numbers[1], ttlStorage.textInput);               // copy textInput to userSelectedMap
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user