07 September 2008

Minor Bug Fix in Conquest Game

A game that I play, Conquest, occasionally crashes because of some bad input, so I ported it from Borland C to Visual C++ to compile and debug it. Some minimal changes required were:

  • Use double instead of float types.
  • Reimplemented clrscr() and gotoxy() functions using Windows Console functions.
  • Change function names in proto.h: _cprintf(), _getch() and _putch().

In the VC++ debugger, I found that the problem occurs in the get_token() function, which parses the user's input. For some reason, when I type too fast, an illegal character is entered. Changing the get_line() function, called by get_token(), to only allow 7-bit ASCII characters in the input, seems to fix the problem.

See Also

No comments:

Post a Comment