[Orxonox-commit 821] r3341 - trunk/src/orxonox/gamestates

rgrieder at orxonox.net rgrieder at orxonox.net
Fri Jul 24 11:17:34 CEST 2009


Author: rgrieder
Date: 2009-07-24 11:17:34 +0200 (Fri, 24 Jul 2009)
New Revision: 3341

Modified:
   trunk/src/orxonox/gamestates/GSDedicated.cc
Log:
Dedicated input thread now ends without hitting enter on Unix

Modified: trunk/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSDedicated.cc	2009-07-23 18:47:55 UTC (rev 3340)
+++ trunk/src/orxonox/gamestates/GSDedicated.cc	2009-07-24 09:17:34 UTC (rev 3341)
@@ -97,8 +97,9 @@
         std::cout.flush();
         resetTerminalMode();
         delete this->originalTerminalSettings_;
+#else
+        COUT(0) << "Press enter to end the game..." << std::endl;
 #endif
-        COUT(0) << "Press enter to end the game..." << std::endl;
         inputThread_->join();
         delete this->inputThread_;
 
@@ -120,7 +121,8 @@
         unsigned int  escapeChar=0;
         while(!closeThread_)
         {
-            c = getchar();
+            size_t count = read(STDIN_FILENO, &c, 1);
+            if (count == 1)
             {
 //                 boost::recursive_mutex::scoped_lock(this->inputLineMutex_);
                 if ( inputIterator_>=MAX_COMMAND_LENGTH-1 && c!='\n' )
@@ -250,8 +252,8 @@
         new_settings = *this->originalTerminalSettings_;
         new_settings.c_lflag &= ~( ICANON | ECHO );
 //         new_settings.c_lflag |= ( ISIG | IEXTEN );
-        new_settings.c_cc[VTIME] = 0;
-        new_settings.c_cc[VMIN] = 1;
+        new_settings.c_cc[VTIME] = 1;
+        new_settings.c_cc[VMIN] = 0;
         tcsetattr(0,TCSANOW,&new_settings);
         COUT(0) << endl;
 //       atexit(&GSDedicated::resetTerminalMode);




More information about the Orxonox-commit mailing list