|
@@ -27,6 +27,30 @@ void exit()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+class DuplicatingStreamBuf : public std::stringbuf
|
|
|
+{
|
|
|
+private:
|
|
|
+ std::ostream& m_os1;
|
|
|
+ std::ostream& m_os2;
|
|
|
+ Critical cs;
|
|
|
+
|
|
|
+public:
|
|
|
+ DuplicatingStreamBuf(std::ostream& os1, std::ostream& os2)
|
|
|
+ : std::stringbuf(),
|
|
|
+ m_os1(os1),
|
|
|
+ m_os2(os2)
|
|
|
+ {}
|
|
|
+
|
|
|
+ int sync() override
|
|
|
+ {
|
|
|
+ cs.lock();
|
|
|
+ m_os1 << str();
|
|
|
+ m_os2 << str();
|
|
|
+ str("");
|
|
|
+ cs.unlock();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
int main()
|
|
|
{
|
|
|
Framework::initFramework();
|
|
@@ -52,7 +76,9 @@ int main()
|
|
|
file.open(pfad->getText());
|
|
|
std::streambuf* sbuf = std::cout.rdbuf();
|
|
|
#ifndef _DEBUG
|
|
|
- std::cout.rdbuf( file.rdbuf() );
|
|
|
+ std::ostream newCout(sbuf);
|
|
|
+ DuplicatingStreamBuf duplicator(file, newCout);
|
|
|
+ std::cout.rdbuf(&duplicator);
|
|
|
#endif
|
|
|
pfad->release();
|
|
|
|
|
@@ -99,6 +125,7 @@ int main()
|
|
|
{
|
|
|
std::string line;
|
|
|
std::getline(std::cin, line);
|
|
|
+ if (!mserver) return;
|
|
|
if (Text(line.c_str()) == Text("exit"))
|
|
|
{
|
|
|
std::cout << "The server will be terminated and the game progress will be saved.\n";
|