Browse Source

Fixed console command input bug

Thomas Buck 10 years ago
parent
commit
fa3ff40c5a
8 changed files with 17 additions and 38 deletions
  1. 2
    0
      ChangeLog
  2. 0
    6
      include/SDLSystem.h
  3. 0
    8
      include/System.h
  4. 2
    2
      include/utils/time.h
  5. 9
    12
      src/OpenRaider.cpp
  6. 2
    0
      src/SDLSystem.cpp
  7. 0
    8
      src/System.cpp
  8. 2
    2
      src/utils/time.cpp

+ 2
- 0
ChangeLog View File

@@ -9,6 +9,8 @@
9 9
 	* Removed duplicated GL initialization code
10 10
 	* Removed duplicated TGA writing code from Texture
11 11
 	* Moved system_timer into time utilities, changed its API
12
+	* Fixed a bug that prevented input of console commands using
13
+	  the shift key for eg. uppercase letters or symbols
12 14
 
13 15
 	[ 20140306 ]
14 16
 	* Created utility library

+ 0
- 6
include/SDLSystem.h View File

@@ -29,12 +29,6 @@ public:
29 29
      */
30 30
     virtual ~SDLSystem();
31 31
 
32
-    /*!
33
-     * \brief Get ticks
34
-     * \returns number of milliseconds since start of program
35
-     */
36
-    virtual unsigned int getTicks();
37
-
38 32
     /*
39 33
      * \brief Sets Event binding Cmd to Key press
40 34
      * \param cmd valid command string

+ 0
- 8
include/System.h View File

@@ -68,12 +68,6 @@ public:
68 68
     virtual ~System();
69 69
 
70 70
     /*!
71
-     * \brief Gets the game tick
72
-     * \returns number of milliseconds since start of program
73
-     */
74
-    virtual unsigned int getTicks();
75
-
76
-    /*!
77 71
      * \brief Created a directory
78 72
      * \param path Directory to create
79 73
      * \returns -1 on error
@@ -144,8 +138,6 @@ public:
144 138
      */
145 139
     virtual int loadResourceFile(const char *filename);
146 140
 
147
-    static void resetTicks();
148
-
149 141
     virtual void resizeGL(unsigned int width, unsigned int height);
150 142
 
151 143
     virtual void runGame() = 0;

+ 2
- 2
include/utils/time.h View File

@@ -22,11 +22,11 @@ extern struct timezone system_timer_tz; //!< System timer timezone info
22 22
  * \brief Read the system timer
23 23
  * \returns number of ticks
24 24
  */
25
-unsigned int system_timer();
25
+unsigned int systemTimerGet();
26 26
 
27 27
 /*!
28 28
  * \brief Reset the system timer
29 29
  */
30
-void system_timer_reset();
30
+void systemTimerReset();
31 31
 
32 32
 #endif

+ 9
- 12
src/OpenRaider.cpp View File

@@ -16,6 +16,7 @@
16 16
 
17 17
 #include "World.h"
18 18
 #include "SkeletalModel.h"
19
+#include "utils/time.h"
19 20
 #include "OpenRaider.h"
20 21
 
21 22
 #include "games/TombRaider1.h" // tmp stop-gap
@@ -37,13 +38,6 @@ bool gStartServer = false;
37 38
 skeletal_model_t *gLaraModel = 0x0;
38 39
 char *gFontFilename = 0x0;
39 40
 
40
-unsigned int getTicks()
41
-{
42
-    OpenRaider *game = OpenRaider::Instance();
43
-
44
-    return game->getTicks();
45
-}
46
-
47 41
 
48 42
 ////////////////////////////////////////////////////////////
49 43
 // Constructors
@@ -69,8 +63,7 @@ void killOpenRaiderSingleton() {
69 63
     printf("Shutting down Game...\n");
70 64
 
71 65
     // Requires public deconstructor
72
-    //! \fixme Causes pointer-being-freed-not-allocated error!
73
-    //delete OpenRaider::Instance();
66
+    delete OpenRaider::Instance();
74 67
 
75 68
     printf("\nThanks for testing %s\n", VERSION);
76 69
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
@@ -616,8 +609,12 @@ void OpenRaider::handleConsoleKeyPressEvent(unsigned int key,unsigned int mod)
616 609
                 buffer[2] = 0;
617 610
                 break;
618 611
             default:
612
+                // Workaround until proper SDL2 text input is used
613
+                if ((key >= 1073742049) && (key <= 1073742051))
614
+                    break;
615
+
619 616
                 if (mod & (SYS_MOD_KEY_RSHIFT | SYS_MOD_KEY_LSHIFT) &&
620
-                        key > 96 && key < 122)
617
+                        key > 96 && key < 123)
621 618
                 {
622 619
                     buffer[i++] = (char)(key - 32);
623 620
                 }
@@ -918,7 +915,7 @@ void OpenRaider::start()
918 915
     gWorld.setFlag(World::fEnableHopping);
919 916
     // reenabled, what should be the new room movement? --xythobuz
920 917
 
921
-    resetTicks();
918
+    systemTimerReset();
922 919
 
923 920
     runGame();
924 921
 }
@@ -1168,7 +1165,7 @@ void OpenRaider::gameFrame()
1168 1165
 
1169 1166
 
1170 1167
     // Remember: ticks in milliseconds, time in hundredths
1171
-    gNetTicks = ticks = getTicks();
1168
+    gNetTicks = ticks = systemTimerGet();
1172 1169
     time = gNetTicks * 0.1f;
1173 1170
 
1174 1171
     switch (m_render.getMode())

+ 2
- 0
src/SDLSystem.cpp View File

@@ -28,9 +28,11 @@ SDLSystem::SDLSystem() : System() {
28 28
 SDLSystem::~SDLSystem() {
29 29
 }
30 30
 
31
+/*
31 32
 unsigned int SDLSystem::getTicks() {
32 33
     return SDL_GetTicks();
33 34
 }
35
+*/
34 36
 
35 37
 #ifdef FIXME
36 38
 void SDLSystem::bindKeyCommand(const char *cmd, int key, int event) {

+ 0
- 8
src/System.cpp View File

@@ -57,14 +57,6 @@ System::System() {
57 57
 System::~System() {
58 58
 }
59 59
 
60
-unsigned int System::getTicks() {
61
-    return system_timer();
62
-}
63
-
64
-void System::resetTicks() {
65
-    system_timer_reset();
66
-}
67
-
68 60
 int System::createDir(char *path) {
69 61
 #ifdef WIN32
70 62
     return _mkdir(path);

+ 2
- 2
src/utils/time.cpp View File

@@ -12,7 +12,7 @@ struct timeval system_timer_start;
12 12
 struct timeval system_timer_stop;
13 13
 struct timezone system_timer_tz;
14 14
 
15
-unsigned int system_timer() {
15
+unsigned int systemTimerGet() {
16 16
     gettimeofday(&system_timer_stop, &system_timer_tz);
17 17
 
18 18
     if (system_timer_start.tv_usec > system_timer_stop.tv_usec) {
@@ -27,7 +27,7 @@ unsigned int system_timer() {
27 27
         + ((system_timer_stop.tv_usec - system_timer_start.tv_usec) / 1000);
28 28
 }
29 29
 
30
-void system_timer_reset() {
30
+void systemTimerReset() {
31 31
     gettimeofday(&system_timer_start, &system_timer_tz);
32 32
 }
33 33
 

Loading…
Cancel
Save