|
|
@ -67,18 +67,26 @@ commandFunction getCommandById( struct command* commands, int id ){ |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
char* getUserInput(){ |
|
|
|
static char userInput[MAX_INPUT_LENGTH]; |
|
|
|
printf( ":" ); |
|
|
|
fgets(userInput, sizeof(userInput), stdin); |
|
|
|
|
|
|
|
size_t len = strlen(userInput); |
|
|
|
if (len > 0 && userInput[len - 1] == '\n') { |
|
|
|
userInput[len - 1] = '\0'; |
|
|
|
} |
|
|
|
|
|
|
|
return userInput; |
|
|
|
} |
|
|
|
|
|
|
|
int startMenu( int code ){ |
|
|
|
if( code == 1 ){ // command test |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
while( GAME.currentState == 0 ){ |
|
|
|
char userInput[50]; |
|
|
|
printf( ":" ); |
|
|
|
scanf( "%s", &userInput ); |
|
|
|
|
|
|
|
int nextState = 0; |
|
|
|
nextState = handleCommand(userInput); |
|
|
|
int nextState = handleCommand( getUserInput() ); |
|
|
|
|
|
|
|
if( nextState == -1 ){ |
|
|
|
printf("command not found!"); |
|
|
|