Procházet zdrojové kódy

rewrote time lib using ctime

Thomas Buck před 10 roky
rodič
revize
e6fc5fc572
3 změnil soubory, kde provedl 35 přidání a 46 odebrání
  1. 26
    19
      data/OpenRaider.init
  2. 0
    10
      include/utils/time.h
  3. 9
    17
      src/utils/time.cpp

+ 26
- 19
data/OpenRaider.init Zobrazit soubor

@@ -1,25 +1,32 @@
1 1
 # OpenRaider configuration file
2 2
 
3
-set basedir   "~/.OpenRaider"
4
-set pakdir    "$(basedir)/paks"
5
-set audiodir  "$(basedir)/music"
6
-set datadir   "$(basedir)/data"
7
-set font      "$(datadir)/test.ttf"
3
+# File locations
4
+set basedir    "~/.OpenRaider"
5
+set pakdir     "$(basedir)/paks"
6
+set audiodir   "$(basedir)/music"
7
+set datadir    "$(basedir)/data"
8
+set font       "$(datadir)/test.ttf"
8 9
 
9
-set gldriver  "/usr/lib/libGL.so.1" # Not needed for Mac!
10
-set size      "1280x720"
10
+ # Not needed for Mac OS X
11
+set gldriver   "/usr/lib/libGL.so.1"
11 12
 
12
-set audio     true # Enable Audio Output
13
-set volume    0.5
13
+# Windowing
14
+set size       "1280x720"
15
+set fullscreen false
14 16
 
15
-set mouse_x   1.0
16
-set mouse_y   1.0
17
+# Audio
18
+set audio      true # Enable Audio Output
19
+set volume     0.5
17 20
 
18
-bind console  96
19
-bind forward  119
20
-bind backward 115
21
-bind jump     32
22
-bind crouch   99
23
-bind left     97
24
-bind right    100
25
-# bind attack   122
21
+# Input
22
+set mouse_x    1.0
23
+set mouse_y    1.0
24
+
25
+bind console   96
26
+bind forward   119
27
+bind backward  115
28
+bind jump      32
29
+bind crouch    99
30
+bind left      97
31
+bind right     100
32
+# bind attack    122

+ 0
- 10
include/utils/time.h Zobrazit soubor

@@ -3,21 +3,11 @@
3 3
  * \brief Time handling utilities
4 4
  *
5 5
  * \author xythobuz
6
- * \author Mongoose
7 6
  */
8 7
 
9 8
 #ifndef _UTILS_TIME_H_
10 9
 #define _UTILS_TIME_H_
11 10
 
12
-#if defined(linux) || defined(__APPLE__)
13
-#include <time.h>
14
-#include <sys/time.h>
15
-#endif
16
-
17
-extern struct timeval system_timer_start; //!< System timer start time
18
-extern struct timeval system_timer_stop; //!< System timer last read time
19
-extern struct timezone system_timer_tz; //!< System timer timezone info
20
-
21 11
 /*!
22 12
  * \brief Read the system timer
23 13
  * \returns number of ticks

+ 9
- 17
src/utils/time.cpp Zobrazit soubor

@@ -3,31 +3,23 @@
3 3
  * \brief Time handling utilities
4 4
  *
5 5
  * \author xythobuz
6
- * \author Mongoose
7 6
  */
8 7
 
9
-#include "utils/time.h"
10
-
11
-struct timeval system_timer_start;
12
-struct timeval system_timer_stop;
13
-struct timezone system_timer_tz;
8
+#include <ctime>
14 9
 
15
-unsigned int systemTimerGet() {
16
-    gettimeofday(&system_timer_stop, &system_timer_tz);
10
+#include "utils/time.h"
17 11
 
18
-    if (system_timer_start.tv_usec > system_timer_stop.tv_usec) {
19
-        system_timer_stop.tv_usec += 1000000;
20
-        system_timer_stop.tv_sec--;
21
-    }
12
+#define CLOCKS_PER_MS (CLOCKS_PER_SEC / 1000)
22 13
 
23
-    system_timer_stop.tv_usec -= system_timer_start.tv_usec;
24
-    system_timer_stop.tv_sec -= system_timer_start.tv_sec;
14
+clock_t system_timer_start;
15
+clock_t system_timer_stop;
25 16
 
26
-    return ((system_timer_stop.tv_sec - system_timer_start.tv_sec) * 1000)
27
-        + ((system_timer_stop.tv_usec - system_timer_start.tv_usec) / 1000);
17
+unsigned int systemTimerGet() {
18
+    system_timer_stop = clock();
19
+    return (system_timer_stop - system_timer_start) / CLOCKS_PER_MS;
28 20
 }
29 21
 
30 22
 void systemTimerReset() {
31
-    gettimeofday(&system_timer_start, &system_timer_tz);
23
+    system_timer_start = clock();
32 24
 }
33 25
 

Loading…
Zrušit
Uložit