|
@@ -6,7 +6,6 @@
|
|
#include <iostream>
|
|
#include <iostream>
|
|
#include <Klient.h>
|
|
#include <Klient.h>
|
|
#ifndef _WINDOWS
|
|
#ifndef _WINDOWS
|
|
-# include <curses.h>
|
|
|
|
# include <sys/resource.h>
|
|
# include <sys/resource.h>
|
|
#endif
|
|
#endif
|
|
#include <AsynchronCall.h>
|
|
#include <AsynchronCall.h>
|
|
@@ -37,20 +36,6 @@ private:
|
|
Critical cs;
|
|
Critical cs;
|
|
int infoLength;
|
|
int infoLength;
|
|
|
|
|
|
- int getCursorColumn()
|
|
|
|
- {
|
|
|
|
-#ifdef _WINDOWS
|
|
|
|
- CONSOLE_SCREEN_BUFFER_INFO csbi;
|
|
|
|
- int columns, rows;
|
|
|
|
-
|
|
|
|
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
|
|
|
- return csbi.dwCursorPosition.X;
|
|
|
|
-#else
|
|
|
|
- int x = getcurx(curscr);
|
|
|
|
- return x;
|
|
|
|
-#endif
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public:
|
|
public:
|
|
DuplicatingStreamBuf(std::ostream& console, std::ostream& file)
|
|
DuplicatingStreamBuf(std::ostream& console, std::ostream& file)
|
|
: std::stringbuf(),
|
|
: std::stringbuf(),
|
|
@@ -76,19 +61,21 @@ public:
|
|
cs.unlock();
|
|
cs.unlock();
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
- int column = getCursorColumn();
|
|
|
|
if (infoLength > 0)
|
|
if (infoLength > 0)
|
|
{
|
|
{
|
|
- console << /* move cursor a line up*/ "\033[1A"
|
|
|
|
|
|
+ console << /* store cursor position */ "\033[s"
|
|
|
|
+ << /* move cursor a line up*/ "\033[1A"
|
|
<< /* clear the line */ "\x1b[2K"
|
|
<< /* clear the line */ "\x1b[2K"
|
|
<< /* return to beginning of line */ "\r";
|
|
<< /* return to beginning of line */ "\r";
|
|
}
|
|
}
|
|
|
|
+ int newLines = Text(str().c_str()).anzahlVon('\n');
|
|
if (str().length() > 0)
|
|
if (str().length() > 0)
|
|
{
|
|
{
|
|
console << str();
|
|
console << str();
|
|
if (str().c_str()[str().length() - 1] != '\n')
|
|
if (str().c_str()[str().length() - 1] != '\n')
|
|
{
|
|
{
|
|
console << "\n";
|
|
console << "\n";
|
|
|
|
+ newLines++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (Game::INSTANCE)
|
|
if (Game::INSTANCE)
|
|
@@ -110,13 +97,18 @@ public:
|
|
{ // green
|
|
{ // green
|
|
infoLine += "\033[1;32m";
|
|
infoLine += "\033[1;32m";
|
|
}
|
|
}
|
|
- infoLine.append()
|
|
|
|
- << tps << /* reset color */ "\033[0m"
|
|
|
|
- << "\tAverage Tick Time: "
|
|
|
|
- << Game::INSTANCE->getAverageTickTime()
|
|
|
|
- << /* move cursor a line down */ "\033[1B"
|
|
|
|
- // << /* move cursor to beginning of line */ "\r"
|
|
|
|
- << /* set cursor position back */ "\033[" << column + 1 << "G";
|
|
|
|
|
|
+ infoLine.append() << tps << /* reset color */ "\033[0m"
|
|
|
|
+ << "\tAverage Tick Time: "
|
|
|
|
+ << Game::INSTANCE->getAverageTickTime() << "\n";
|
|
|
|
+ if (infoLength > 0)
|
|
|
|
+ {
|
|
|
|
+ infoLine.append()
|
|
|
|
+ << /* restore cursor position */ "\033[u"
|
|
|
|
+ << /* set cursor down by amount of new lines */
|
|
|
|
+ (newLines > 0 ? (Text("\033[") + newLines + "B").getText()
|
|
|
|
+ : "");
|
|
|
|
+ // << "\x1b[0K";
|
|
|
|
+ }
|
|
infoLength = infoLine.getLength();
|
|
infoLength = infoLine.getLength();
|
|
console << infoLine << std::flush;
|
|
console << infoLine << std::flush;
|
|
}
|
|
}
|
|
@@ -138,7 +130,6 @@ int main()
|
|
initializeMultiblockTypes();
|
|
initializeMultiblockTypes();
|
|
|
|
|
|
#ifndef _WINDOWS
|
|
#ifndef _WINDOWS
|
|
- initscr();
|
|
|
|
struct rlimit core_limits;
|
|
struct rlimit core_limits;
|
|
core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
|
|
core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
|
|
setrlimit(RLIMIT_CORE, &core_limits);
|
|
setrlimit(RLIMIT_CORE, &core_limits);
|
|
@@ -208,9 +199,9 @@ int main()
|
|
std::string line;
|
|
std::string line;
|
|
std::getline(std::cin, line);
|
|
std::getline(std::cin, line);
|
|
if (!mserver) return;
|
|
if (!mserver) return;
|
|
- std::cout << "\033[1A"
|
|
|
|
|
|
+ std::cout << std::flush << "\033[1A"
|
|
<< "\x1b[2K"
|
|
<< "\x1b[2K"
|
|
- << "\r" << line << std::flush;
|
|
|
|
|
|
+ << "\x1b[0G" << line << "\n\033[1A\033[s" << std::flush;
|
|
if (Text(line.c_str()) == Text("exit"))
|
|
if (Text(line.c_str()) == Text("exit"))
|
|
{
|
|
{
|
|
std::cout << "The server will be terminated and the game "
|
|
std::cout << "The server will be terminated and the game "
|