Guess Word input is now limited to MAXWORDLENGTH; Clean up #14
This commit is contained in:
11
hangman.c
11
hangman.c
@@ -139,7 +139,7 @@ void initGuessWord(game_state *gs, char *filename) {
|
||||
if (strlen(filename) == 0) {
|
||||
/* Manual input */
|
||||
curs_set(1);
|
||||
getstr(gs->guessWord);
|
||||
getnstr(gs->guessWord, MAXWORDLENGTH - 1); /* Reads the guessWord with a limit */
|
||||
curs_set(0);
|
||||
} else {
|
||||
/* Random line from file */
|
||||
@@ -205,10 +205,11 @@ void drawGuessWord(game_state *gs) {
|
||||
int startpos = gs->centerx - gs->wordLength;
|
||||
int i, wordpos = 0;
|
||||
int switchspace = 0;
|
||||
int xcounter = startpos;
|
||||
int ycounter = 0;
|
||||
int tempstartpos = startpos, deltawordlength = gs->wordLength;
|
||||
int rows = 1;
|
||||
int xcounter = startpos; /* counter of the x position on screen */
|
||||
int ycounter = 0; /* counter of the y position on sceen (row) */
|
||||
int tempstartpos = startpos; /* the calculated start position to draw the characters */
|
||||
int rows = 1; /* number of rows */
|
||||
|
||||
if (gs->wordLength * 2 > gs->maxx - LINEBREAK) {
|
||||
/* The word will be longer then the max. linesize with offset. */
|
||||
rows = 2;
|
||||
|
Reference in New Issue
Block a user