fixed issue panic in console/file input

This commit is contained in:
2024-07-05 21:28:45 -04:00
parent d6503579c4
commit 9495f11c16
3 changed files with 19 additions and 5 deletions

View File

@ -31,8 +31,12 @@ game_command console_input::get_command() {
game_command_panic
? tmp : tmp - move_north +
(use ? apply_north : attack_north));
} else // is just moving
return get_direction(cmd);
} else {
auto tmp = get_direction(cmd);
if (tmp != game_command_panic)
return tmp;
}
return game_command_pass;
}

View File

@ -1,6 +1,7 @@
#include "console_output.h"
#include <string>
#include <utility>
#include <ncurses.h>
@ -73,10 +74,15 @@ void console_output::render() {
if (idx % DISPLAY_WIDTH == 0 && idx)
out << std::endl;
out << get_code(contents[idx]) + (char)contents[idx];
out << get_code(contents[idx]) +
(char)(contents[idx] ? contents[idx] : ' ');
}
}
void console_output::clear() {
}
void console_output::print_char(const position &pos, const char ch,
const int attr) {
if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT)

View File

@ -31,8 +31,12 @@ game_command file_input::get_command() {
game_command_panic
? tmp : tmp - move_north +
(use ? apply_north : attack_north));
} else // is just moving
return get_direction(cmd);
} else {
auto tmp = get_direction(cmd);
if (tmp != game_command_panic)
return tmp;
}
return game_command_pass;
}