|
@@ -35,8 +35,8 @@ private:
|
|
std::ostream& console;
|
|
std::ostream& console;
|
|
std::ostream& file;
|
|
std::ostream& file;
|
|
bool hasFile = 0;
|
|
bool hasFile = 0;
|
|
- Critical cs;
|
|
|
|
int infoLength;
|
|
int infoLength;
|
|
|
|
+ Critical cs;
|
|
|
|
|
|
public:
|
|
public:
|
|
DuplicatingStreamBuf(std::ostream& console, std::ostream& file)
|
|
DuplicatingStreamBuf(std::ostream& console, std::ostream& file)
|
|
@@ -55,14 +55,26 @@ public:
|
|
infoLength(0)
|
|
infoLength(0)
|
|
{}
|
|
{}
|
|
|
|
|
|
- int sync() override
|
|
|
|
|
|
+ void __CLR_OR_THIS_CALL _Lock() override
|
|
{
|
|
{
|
|
cs.lock();
|
|
cs.lock();
|
|
- if (str().length() == 0 && !Game::INSTANCE)
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void __CLR_OR_THIS_CALL _Unlock() override
|
|
|
|
+ {
|
|
|
|
+ cs.unlock();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int sync() override
|
|
|
|
+ {
|
|
|
|
+ _Lock();
|
|
|
|
+ std::string value = str();
|
|
|
|
+ if (value.length() == 0 && !Game::INSTANCE)
|
|
{
|
|
{
|
|
- cs.unlock();
|
|
|
|
|
|
+ _Unlock();
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
+ str("");
|
|
if (infoLength > 0)
|
|
if (infoLength > 0)
|
|
{
|
|
{
|
|
console << /* store cursor position */ "\033[s"
|
|
console << /* store cursor position */ "\033[s"
|
|
@@ -70,11 +82,11 @@ public:
|
|
<< /* 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)
|
|
|
|
|
|
+ int newLines = Text(value.c_str()).anzahlVon('\n');
|
|
|
|
+ if (value.length() > 0)
|
|
{
|
|
{
|
|
- console << str();
|
|
|
|
- if (str().c_str()[str().length() - 1] != '\n')
|
|
|
|
|
|
+ console << value;
|
|
|
|
+ if (value.c_str()[value.length() - 1] != '\n')
|
|
{
|
|
{
|
|
console << "\n";
|
|
console << "\n";
|
|
newLines++;
|
|
newLines++;
|
|
@@ -118,9 +130,8 @@ public:
|
|
{
|
|
{
|
|
infoLength = 0;
|
|
infoLength = 0;
|
|
}
|
|
}
|
|
- if (hasFile) file << str() << std::flush;
|
|
|
|
- str("");
|
|
|
|
- cs.unlock();
|
|
|
|
|
|
+ if (hasFile) file << value << std::flush;
|
|
|
|
+ _Unlock();
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
};
|
|
};
|