[Orxonox-commit 755] r3284 - branches/netp6/src/orxonox/gamestates
rgrieder at orxonox.net
rgrieder at orxonox.net
Mon Jul 13 18:03:24 CEST 2009
Author: rgrieder
Date: 2009-07-13 18:03:24 +0200 (Mon, 13 Jul 2009)
New Revision: 3284
Modified:
branches/netp6/src/orxonox/gamestates/GSDedicated.cc
Log:
Move resource allocation to the corresponding thread and made compiler directives clearer.
Modified: branches/netp6/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- branches/netp6/src/orxonox/gamestates/GSDedicated.cc 2009-07-13 14:59:10 UTC (rev 3283)
+++ branches/netp6/src/orxonox/gamestates/GSDedicated.cc 2009-07-13 16:03:24 UTC (rev 3284)
@@ -41,7 +41,7 @@
#include <iomanip>
#include <boost/bind.hpp>
-#ifndef ORXONOX_PLATFORM_WINDOWS
+#ifdef ORXONOX_PLATFORM_UNIX
#include <termios.h>
#endif
@@ -64,8 +64,6 @@
, cursorX_(0)
, cursorY_(0)
{
- this->commandLine_ = new unsigned char[MAX_COMMAND_LENGTH];
-// memset( this->commandLine_, 0, MAX_COMMAND_LENGTH );
}
GSDedicated::~GSDedicated()
@@ -95,7 +93,7 @@
delete this->server_;
closeThread_ = true;
-#ifndef ORXONOX_PLATFORM_WINDOWS
+#ifdef ORXONOX_PLATFORM_UNIX
std::cout << "\033[0G\033[K";
std::cout.flush();
resetTerminalMode();
@@ -105,9 +103,6 @@
inputThread_->join();
delete this->inputThread_;
- if (this->commandLine_ )
- delete[] this->commandLine_;
-
GameMode::setHasServer(false);
}
@@ -131,6 +126,8 @@
void GSDedicated::inputThread()
{
+ this->commandLine_ = new unsigned char[MAX_COMMAND_LENGTH];
+// memset( this->commandLine_, 0, MAX_COMMAND_LENGTH );
unsigned char c;
unsigned int escapeChar=0;
while(!closeThread_)
@@ -212,11 +209,13 @@
}
}
}
+
+ delete[] this->commandLine_;
}
void GSDedicated::printLine()
{
-#ifndef ORXONOX_PLATFORM_WINDOWS
+#ifdef ORXONOX_PLATFORM_UNIX
// set cursor to the begining of the line and erase the line
std::cout << "\033[0G\033[K";
// boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
@@ -256,7 +255,7 @@
void GSDedicated::setTerminalMode()
{
-#ifndef ORXONOX_PLATFORM_WINDOWS
+#ifdef ORXONOX_PLATFORM_UNIX
termios new_settings;
tcgetattr(0,this->originalTerminalSettings_);
@@ -273,7 +272,7 @@
void GSDedicated::resetTerminalMode()
{
-#ifndef ORXONOX_PLATFORM_WINDOWS
+#ifdef ORXONOX_PLATFORM_UNIX
tcsetattr(0, TCSANOW, GSDedicated::originalTerminalSettings_);
#endif
}
More information about the Orxonox-commit
mailing list