home · contact · privacy
Make grids hexagonal, remove all diagonal movement penalty hassle.
[plomrogue] / src / server / io.c
index ba5abd5f2d18b2c95000fe7381b244aae6df455f..4fbf6ed07fad2dee6614a9f0f6843111f9ee7823 100644 (file)
@@ -1,6 +1,6 @@
 /* src/server/io.c */
 
-#define _BSD_SOURCE /* usleep() */
+#define _POSIX_C_SOURCE 199309L
 #include "io.h"
 #include <errno.h> /* global errno */
 #include <limits.h> /* PIPE_BUF */
@@ -10,9 +10,7 @@
 #include <stdlib.h> /* free() */
 #include <string.h> /* strlen(), memcpy() */
 #include <sys/types.h> /* time_t */
-#include <time.h> /* time() */
-#include <unistd.h> /* usleep() */
-#include "../common/err_try_fgets.h" /* err_line() */
+#include <time.h> /* time(), nanosleep() */
 #include "../common/readwrite.h" /* try_fopen(), try_fclose_unlink_rename(),
                                   * try_fwrite(), try_fputc(), try_fgetc()
                                   */
@@ -30,8 +28,8 @@
 */
 static char * get_message_from_queue();
 
-/* Read input file for input into world.queue. new queue input. Wait a few
- * seconds until giving up. Translate '\n' chars in input file into '\0' chars.
+/* Poll input file for world.queue input. Wait a few seconds until giving up;
+ * poll only every 0.03 seconds.. Translate '\n' chars in input file into '\0'.
  */
 static void read_file_into_queue();
 
@@ -93,10 +91,13 @@ static void read_file_into_queue()
     char * f_name = "read_file_into_queue()";
     uint8_t wait_seconds = 5;
     time_t now = time(0);
+    struct timespec dur;
+    dur.tv_sec = 0;
+    dur.tv_nsec = 33333333;
     int test;
     while (EOF == (test = try_fgetc(world.file_in, f_name)))
     {
-        usleep(33);
+        nanosleep(&dur, NULL);
         if (time(0) > now + wait_seconds)
         {
             return;