Skip to content

Commit

Permalink
fix: extra character left on input after accessing cosole history
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenapte committed Dec 23, 2023
1 parent 5db210b commit d2240c0
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 13 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/server.yml
Expand Up @@ -30,11 +30,8 @@ jobs:
- name: Fetch git submodules
run: git submodule update --init --recursive

- name: Install OpenSSL
run: sudo apt install libssl-dev

- name: Install protobuf
run: sudo apt install libprotobuf-dev protobuf-compiler
- name: Install dependencies (OpenSSL, Protobuf, Readline)
run: sudo apt install libssl-dev libprotobuf-dev protobuf-compiler libreadline-dev

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
1 change: 0 additions & 1 deletion BallanceMMOClient/console_window.cpp
Expand Up @@ -111,7 +111,6 @@ void console_window::run() {
if (owned_console_)
for (const auto& i : previous_msg_) role::Printf(i.c_str());
while (true) {
std::cout << "\r> " << std::flush;
std::string line;
/*wchar_t wc;
do {
Expand Down
4 changes: 3 additions & 1 deletion BallanceMMOCommon/src/utility/console.cpp
Expand Up @@ -40,14 +40,16 @@ const std::vector<std::string> console::get_command_hints(bool fuzzy_matching) c

bool console::read_input(std::string &buf) {
#ifdef _WIN32
std::cout << "\r> " << std::flush;
std::wstring wbuf;
bool success = bool(std::getline(std::wcin, wbuf));
buf = bmmo::string_utils::ConvertWideToANSI(wbuf);
if (auto pos = buf.rfind('\r'); pos != std::string::npos)
buf.erase(pos);
return success;
#else
auto input_cstr = readline("\r> ");
std::putchar('\r');
auto input_cstr = readline("> ");
if (!input_cstr)
return false;
buf.assign(input_cstr);
Expand Down
1 change: 0 additions & 1 deletion BallanceMMOServer/client.cpp
Expand Up @@ -1117,7 +1117,6 @@ int main(int argc, char** argv) {
});
}
while (client.running()) {
std::cout << "\r> " << std::flush;
std::string input;
if (!console.read_input(input)) {
puts("stop");
Expand Down
1 change: 0 additions & 1 deletion BallanceMMOServer/record_parser.cpp
Expand Up @@ -1024,7 +1024,6 @@ int main(int argc, char** argv) {
replayer.wait_till_started();

while (replayer.running()) {
std::cout << "\r> " << std::flush;
std::string line;
if (!console.read_input(line)) {
puts("stop");
Expand Down
1 change: 0 additions & 1 deletion BallanceMMOServer/server.cpp
Expand Up @@ -1747,7 +1747,6 @@ int main(int argc, char** argv) {
server.shutdown();

while (server.running()) {
std::cout << "\r> " << std::flush;
std::string line;
if (!console.read_input(line)) {
puts("stop");
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -38,9 +38,9 @@ BallanceMMO is a project which brings online experiences to Ballance.
- A build tool like GNU Make, Ninja: Build server binary
- A compiler with core C++20 feature support
- This project has been successfully compiled under:
- GCC ~~9.4~~, 10.3, 11.3, and 12.2 (server-side components; GCC 9 support dropped since January 2023)
- Apple Clang 13.1 (server-side)
- Visual Studio 2019 and 2022 (client-side, or specifically, BML related stuff)
- GCC ~~9.4~~, 10.3, 11.3, 12.2, and 13.2 (server-side components; GCC 9 support dropped since January 2023)
- Apple Clang 13.1 and 16.0 (server-side)
- Visual Studio 2019 and 2022 (client-side, or specifically, BML-related stuff)
- One of the following crypto solutions:
- OpenSSL 1.1.1 or later
- OpenSSL 1.1.x, plus ed25519-donna and curve25519-donna. (Valve GNS has made some minor changes, so the source is included in this project.)
Expand Down

0 comments on commit d2240c0

Please sign in to comment.