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
 	* Removed duplicated GL initialization code
9
 	* Removed duplicated GL initialization code
10
 	* Removed duplicated TGA writing code from Texture
10
 	* Removed duplicated TGA writing code from Texture
11
 	* Moved system_timer into time utilities, changed its API
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
 	[ 20140306 ]
15
 	[ 20140306 ]
14
 	* Created utility library
16
 	* Created utility library

+ 0
- 6
include/SDLSystem.h View File

29
      */
29
      */
30
     virtual ~SDLSystem();
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
      * \brief Sets Event binding Cmd to Key press
33
      * \brief Sets Event binding Cmd to Key press
40
      * \param cmd valid command string
34
      * \param cmd valid command string

+ 0
- 8
include/System.h View File

68
     virtual ~System();
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
      * \brief Created a directory
71
      * \brief Created a directory
78
      * \param path Directory to create
72
      * \param path Directory to create
79
      * \returns -1 on error
73
      * \returns -1 on error
144
      */
138
      */
145
     virtual int loadResourceFile(const char *filename);
139
     virtual int loadResourceFile(const char *filename);
146
 
140
 
147
-    static void resetTicks();
148
-
149
     virtual void resizeGL(unsigned int width, unsigned int height);
141
     virtual void resizeGL(unsigned int width, unsigned int height);
150
 
142
 
151
     virtual void runGame() = 0;
143
     virtual void runGame() = 0;

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

22
  * \brief Read the system timer
22
  * \brief Read the system timer
23
  * \returns number of ticks
23
  * \returns number of ticks
24
  */
24
  */
25
-unsigned int system_timer();
25
+unsigned int systemTimerGet();
26
 
26
 
27
 /*!
27
 /*!
28
  * \brief Reset the system timer
28
  * \brief Reset the system timer
29
  */
29
  */
30
-void system_timer_reset();
30
+void systemTimerReset();
31
 
31
 
32
 #endif
32
 #endif

+ 9
- 12
src/OpenRaider.cpp View File

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

+ 2
- 0
src/SDLSystem.cpp View File

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

+ 0
- 8
src/System.cpp View File

57
 System::~System() {
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
 int System::createDir(char *path) {
60
 int System::createDir(char *path) {
69
 #ifdef WIN32
61
 #ifdef WIN32
70
     return _mkdir(path);
62
     return _mkdir(path);

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

12
 struct timeval system_timer_stop;
12
 struct timeval system_timer_stop;
13
 struct timezone system_timer_tz;
13
 struct timezone system_timer_tz;
14
 
14
 
15
-unsigned int system_timer() {
15
+unsigned int systemTimerGet() {
16
     gettimeofday(&system_timer_stop, &system_timer_tz);
16
     gettimeofday(&system_timer_stop, &system_timer_tz);
17
 
17
 
18
     if (system_timer_start.tv_usec > system_timer_stop.tv_usec) {
18
     if (system_timer_start.tv_usec > system_timer_stop.tv_usec) {
27
         + ((system_timer_stop.tv_usec - system_timer_start.tv_usec) / 1000);
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
     gettimeofday(&system_timer_start, &system_timer_tz);
31
     gettimeofday(&system_timer_start, &system_timer_tz);
32
 }
32
 }
33
 
33
 

Loading…
Cancel
Save