mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2025-08-18 12:45:36 +00:00
fix getch spin
This commit is contained in:
parent
04de729d7c
commit
a78f65b274
@ -174,11 +174,19 @@ static void ProcessCompositeInput() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]] void ReadCin() {
|
void ReadCin() {
|
||||||
DebugPrintTID();
|
DebugPrintTID();
|
||||||
|
size_t null_byte_counter = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int In = _getch();
|
int In = _getch();
|
||||||
// info(std::to_string(In));
|
info(std::to_string(In));
|
||||||
|
if (In == 0) {
|
||||||
|
++null_byte_counter;
|
||||||
|
if (null_byte_counter > 0) {
|
||||||
|
info("too many null bytes in input, this is now assumed to be a background thread - console input is now disabled");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (CompositeInputExpected) {
|
if (CompositeInputExpected) {
|
||||||
CompositeInput += char(In);
|
CompositeInput += char(In);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <unistd.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
static RWMutex ThreadNameMapMutex;
|
static RWMutex ThreadNameMapMutex;
|
||||||
@ -94,7 +95,7 @@ void DebugPrintTIDInternal(const std::string& func, bool overwrite) {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::scoped_lock Guard(LogLock);
|
std::scoped_lock Guard(LogLock);
|
||||||
std::stringstream Print;
|
std::stringstream Print;
|
||||||
Print << "(debug build) Thread '" << std::this_thread::get_id() << "' is " << func << "\n";
|
Print << "(debug build) Thread '" << std::this_thread::get_id() << "' / '" << gettid() << "' is " << func << "\n";
|
||||||
ConsoleOut(Print.str());
|
ConsoleOut(Print.str());
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user