Bläddra i källkod

Fixed many 64 to 32 bit warnings

Thomas Buck 10 år sedan
förälder
incheckning
604539e334

+ 0
- 1
CMakeLists.txt Visa fil

@@ -38,7 +38,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
38 38
     set (WARNINGS "${WARNINGS} -Wno-documentation-unknown-command -Wno-c++98-compat-pedantic")
39 39
 
40 40
     set (WARNINGS "${WARNINGS} -Wno-sign-conversion")
41
-    #set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32")
42 41
 
43 42
     set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
44 43
     set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0 -ftrapv")

+ 5
- 0
ChangeLog.md Visa fil

@@ -2,6 +2,11 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140706 ]
6
+    * Use cmake to check for sys/time.h availability
7
+    * Use long nearly everywhere where STL containers are interfaced,
8
+      thereby fixing most 64 to 32 bit conversion warnings
9
+
5 10
     [ 20140705 ]
6 11
     * Added basic Travis CI support
7 12
     * Removed global object, using lazy initialization

+ 1
- 3
TODO.md Visa fil

@@ -30,7 +30,5 @@
30 30
 
31 31
 # Travis CI
32 32
 
33
-* Currently only building on Linux
34
-    * Should also build on Mac, but needs different before_install / install scripts,
35
-      that can detect the platform they’re running on
33
+* Run resulting executable, upload screenshot, post link in IRC
36 34
 

+ 11
- 11
include/Entity.h Visa fil

@@ -36,20 +36,20 @@ public:
36 36
     void setAngles(float a[3]);
37 37
     float getPos(unsigned int i);
38 38
     float getAngle(unsigned int i);
39
-    int getRoom();
39
+    long getRoom();
40 40
 
41 41
     // Animation State
42
-    unsigned int getAnimation();
43
-    void setAnimation(unsigned int index);
44
-    unsigned int getBoneFrame();
45
-    void setBoneFrame(unsigned int index);
46
-    unsigned int getIdleAnimation();
47
-    void setIdleAnimation(unsigned int index);
42
+    unsigned long getAnimation();
43
+    void setAnimation(unsigned long index);
44
+    unsigned long getBoneFrame();
45
+    void setBoneFrame(unsigned long index);
46
+    unsigned long getIdleAnimation();
47
+    void setIdleAnimation(unsigned long index);
48 48
 
49 49
 private:
50 50
     float pos[3];
51 51
     float angles[3];
52
-    int room;
52
+    long room;
53 53
 
54 54
     unsigned int skeletalModel;
55 55
     MoveType moveType;
@@ -58,9 +58,9 @@ private:
58 58
     int objectId;
59 59
 
60 60
     // Animation State
61
-    unsigned int boneFrame;
62
-    unsigned int animationFrame;
63
-    unsigned int idleAnimation;
61
+    unsigned long boneFrame;
62
+    unsigned long animationFrame;
63
+    unsigned long idleAnimation;
64 64
 };
65 65
 
66 66
 #endif

+ 1
- 1
include/Game.h Visa fil

@@ -58,7 +58,7 @@ private:
58 58
     unsigned int mTextureStart;
59 59
     unsigned int mTextureOffset;
60 60
 
61
-    int mLara;
61
+    long mLara;
62 62
 };
63 63
 
64 64
 Game &getGame();

+ 2
- 2
include/Menu.h Visa fil

@@ -47,8 +47,8 @@ private:
47 47
     void play();
48 48
 
49 49
     bool mVisible;
50
-    unsigned int mCursor;
51
-    unsigned int mMin;
50
+    unsigned long mCursor;
51
+    unsigned long mMin;
52 52
 
53 53
     FontString mainText;
54 54
 

+ 2
- 0
include/Render.h Visa fil

@@ -118,6 +118,8 @@ public:
118 118
 
119 119
 private:
120 120
 
121
+    static void lightRoom(Room &room);
122
+
121 123
     void drawLoadScreen();
122 124
 
123 125
     /*!

+ 18
- 18
include/Room.h Visa fil

@@ -27,9 +27,9 @@ public:
27 27
     Mesh &getMesh();
28 28
     void display(bool alpha);
29 29
 
30
-    bool isWall(unsigned int sector);
31
-    int getSector(float x, float z, float *floor, float *ceiling);
32
-    int getSector(float x, float z);
30
+    bool isWall(unsigned long sector);
31
+    long getSector(float x, float z, float *floor, float *ceiling);
32
+    long getSector(float x, float z);
33 33
     void getHeightAtPosition(float x, float *y, float z);
34 34
     int getAdjoiningRoom(float x, float y, float z,
35 35
         float x2, float y2, float z2);
@@ -41,26 +41,26 @@ public:
41 41
     void setFlags(unsigned int f);
42 42
     unsigned int getFlags();
43 43
 
44
-    unsigned int sizeAdjacentRooms();
45
-    int getAdjacentRoom(unsigned int index);
44
+    unsigned long sizeAdjacentRooms();
45
+    long getAdjacentRoom(unsigned long index);
46 46
 
47
-    unsigned int sizePortals();
48
-    Portal &getPortal(unsigned int index);
47
+    unsigned long sizePortals();
48
+    Portal &getPortal(unsigned long index);
49 49
 
50
-    unsigned int sizeSectors();
51
-    Sector &getSector(unsigned int index);
50
+    unsigned long sizeSectors();
51
+    Sector &getSector(unsigned long index);
52 52
 
53
-    unsigned int sizeBox();
54
-    Box &getBox(unsigned int index);
53
+    unsigned long sizeBox();
54
+    Box &getBox(unsigned long index);
55 55
 
56
-    unsigned int sizeModels();
57
-    StaticModel &getModel(unsigned int index);
56
+    unsigned long sizeModels();
57
+    StaticModel &getModel(unsigned long index);
58 58
 
59
-    unsigned int sizeLights();
60
-    Light &getLight(unsigned int index);
59
+    unsigned long sizeLights();
60
+    Light &getLight(unsigned long index);
61 61
 
62
-    unsigned int sizeSprites();
63
-    Sprite &getSprite(unsigned int index);
62
+    unsigned long sizeSprites();
63
+    Sprite &getSprite(unsigned long index);
64 64
 
65 65
 private:
66 66
     void sortModels();
@@ -73,7 +73,7 @@ private:
73 73
     BoundingBox bbox;
74 74
     Mesh mesh;
75 75
 
76
-    std::vector<int> adjacentRooms;
76
+    std::vector<long> adjacentRooms;
77 77
     std::vector<Sprite *> sprites;
78 78
     std::vector<StaticModel *> models;
79 79
     std::vector<Portal *> portals;

+ 9
- 9
include/SkeletalModel.h Visa fil

@@ -36,8 +36,8 @@ public:
36 36
 
37 37
     void getPosition(float p[3]);
38 38
 
39
-    unsigned int size();
40
-    BoneTag &get(unsigned int i);
39
+    unsigned long size();
40
+    BoneTag &get(unsigned long i);
41 41
 
42 42
 private:
43 43
     float pos[3];
@@ -49,8 +49,8 @@ public:
49 49
     AnimationFrame(TombRaider &tr, unsigned int index, int a, unsigned int *frame_offset, int frame_step);
50 50
     ~AnimationFrame();
51 51
 
52
-    unsigned int size();
53
-    BoneFrame &get(unsigned int i);
52
+    unsigned long size();
53
+    BoneFrame &get(unsigned long i);
54 54
 
55 55
 private:
56 56
     char rate;
@@ -61,22 +61,22 @@ class SkeletalModel {
61 61
 public:
62 62
     SkeletalModel(TombRaider &tr, unsigned int index, int objectId);
63 63
     ~SkeletalModel();
64
-    void display(unsigned int aframe, unsigned int bframe);
64
+    void display(unsigned long aframe, unsigned long bframe);
65 65
 
66 66
     int getId();
67 67
     void setPigTail(bool b);
68 68
     void setPonyPos(float x, float y, float z, float angle);
69 69
 
70
-    unsigned int size();
71
-    AnimationFrame &get(unsigned int i);
70
+    unsigned long size();
71
+    AnimationFrame &get(unsigned long i);
72 72
 
73 73
 private:
74 74
     int id;
75 75
     bool tr4Overlay;
76 76
     bool pigtails;
77
-    int ponytailId;
77
+    long ponytailId;
78 78
     float ponytail[3];
79
-    int ponytailMeshId;
79
+    long ponytailMeshId;
80 80
     unsigned int ponytailNumMeshes;
81 81
     float ponytailAngle;
82 82
     float ponyOff;

+ 6
- 6
include/Sound.h Visa fil

@@ -43,7 +43,7 @@ public:
43 43
      * \brief Get number of registered sources
44 44
      * \returns number of registered sources
45 45
      */
46
-    virtual int registeredSources() = 0;
46
+    virtual unsigned long registeredSources() = 0;
47 47
 
48 48
     /*!
49 49
      * \brief Remove all loaded sounds
@@ -62,7 +62,7 @@ public:
62 62
      * \param source valid source id
63 63
      * \param pos new position for source
64 64
      */
65
-    virtual void sourceAt(int source, float pos[3]) = 0;
65
+    virtual void sourceAt(unsigned long source, float pos[3]) = 0;
66 66
 
67 67
     /*!
68 68
      * \brief Load wav file from disk
@@ -71,7 +71,7 @@ public:
71 71
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
72 72
      * \returns 0 for no error or < 0 error flag
73 73
      */
74
-    virtual int addFile(const char *filename, int *source, unsigned int flags) = 0;
74
+    virtual int addFile(const char *filename, unsigned long *source, unsigned int flags) = 0;
75 75
 
76 76
     /*!
77 77
      * \brief Load wav file from buffer
@@ -81,19 +81,19 @@ public:
81 81
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
82 82
      * \returns 0 for no error or < 0 error flag
83 83
      */
84
-    virtual int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags) = 0;
84
+    virtual int addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags) = 0;
85 85
 
86 86
     /*!
87 87
      * \brief Play sound source
88 88
      * \param source sound source to play
89 89
      */
90
-    virtual void play(int source) = 0;
90
+    virtual void play(unsigned long source) = 0;
91 91
 
92 92
     /*!
93 93
      * \brief Stop playing sound source
94 94
      * \param source sound source to stop
95 95
      */
96
-    virtual void stop(int source) = 0;
96
+    virtual void stop(unsigned long source) = 0;
97 97
 };
98 98
 
99 99
 Sound &getSound();

+ 8
- 8
include/SoundAL.h Visa fil

@@ -47,7 +47,7 @@ public:
47 47
      * \brief Get number of registered sources
48 48
      * \returns number of registered sources
49 49
      */
50
-    virtual int registeredSources();
50
+    virtual unsigned long registeredSources();
51 51
 
52 52
     /*!
53 53
      * \brief Remove all loaded sounds
@@ -66,7 +66,7 @@ public:
66 66
      * \param source valid source id
67 67
      * \param pos new position for source
68 68
      */
69
-    virtual void sourceAt(int source, float pos[3]);
69
+    virtual void sourceAt(unsigned long source, float pos[3]);
70 70
 
71 71
     /*!
72 72
      * \brief Load wav file from disk
@@ -75,7 +75,7 @@ public:
75 75
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
76 76
      * \returns 0 for no error or < 0 error flag
77 77
      */
78
-    virtual int addFile(const char *filename, int *source, unsigned int flags);
78
+    virtual int addFile(const char *filename, unsigned long *source, unsigned int flags);
79 79
 
80 80
     /*!
81 81
      * \brief Load wav file from buffer
@@ -85,25 +85,25 @@ public:
85 85
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
86 86
      * \returns 0 for no error or < 0 error flag
87 87
      */
88
-    virtual int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
88
+    virtual int addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags);
89 89
 
90 90
     /*!
91 91
      * \brief Play sound source
92 92
      * \param source sound source to play
93 93
      */
94
-    virtual void play(int source);
94
+    virtual void play(unsigned long source);
95 95
 
96 96
     /*!
97 97
      * \brief Stop playing sound source
98 98
      * \param source sound source to stop
99 99
      */
100
-    virtual void stop(int source);
100
+    virtual void stop(unsigned long source);
101 101
 
102 102
 private:
103 103
 
104 104
     bool mEnabled;
105
-    bool mInit;                        //!< Guard to ensure ausio system is active
106
-    float mVolume;                     //!< Listener gain
105
+    bool mInit;                         //!< Guard to ensure ausio system is active
106
+    float mVolume;                      //!< Listener gain
107 107
     std::vector<unsigned int> mBuffer; //!< Audio buffer id list
108 108
     std::vector<unsigned int> mSource; //!< Audio source id list
109 109
 };

+ 6
- 6
include/SoundNull.h Visa fil

@@ -44,7 +44,7 @@ public:
44 44
      * \brief Get number of registered sources
45 45
      * \returns number of registered sources
46 46
      */
47
-    virtual int registeredSources();
47
+    virtual unsigned long registeredSources();
48 48
 
49 49
     /*!
50 50
      * \brief Remove all loaded sounds
@@ -63,7 +63,7 @@ public:
63 63
      * \param source valid source id
64 64
      * \param pos new position for source
65 65
      */
66
-    virtual void sourceAt(int source, float pos[3]);
66
+    virtual void sourceAt(unsigned long source, float pos[3]);
67 67
 
68 68
     /*!
69 69
      * \brief Load wav file from disk
@@ -72,7 +72,7 @@ public:
72 72
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
73 73
      * \returns 0 for no error or < 0 error flag
74 74
      */
75
-    virtual int addFile(const char *filename, int *source, unsigned int flags);
75
+    virtual int addFile(const char *filename, unsigned long *source, unsigned int flags);
76 76
 
77 77
     /*!
78 78
      * \brief Load wav file from buffer
@@ -82,19 +82,19 @@ public:
82 82
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
83 83
      * \returns 0 for no error or < 0 error flag
84 84
      */
85
-    virtual int addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags);
85
+    virtual int addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags);
86 86
 
87 87
     /*!
88 88
      * \brief Play sound source
89 89
      * \param source sound source to play
90 90
      */
91
-    virtual void play(int source);
91
+    virtual void play(unsigned long source);
92 92
 
93 93
     /*!
94 94
      * \brief Stop playing sound source
95 95
      * \param source sound source to stop
96 96
      */
97
-    virtual void stop(int source);
97
+    virtual void stop(unsigned long source);
98 98
 };
99 99
 
100 100
 #endif

+ 2
- 2
include/Sprite.h Visa fil

@@ -29,8 +29,8 @@ public:
29 29
     SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence);
30 30
     ~SpriteSequence();
31 31
 
32
-    unsigned int size();
33
-    Sprite &get(unsigned int index);
32
+    unsigned long size();
33
+    Sprite &get(unsigned long index);
34 34
 
35 35
 private:
36 36
     std::vector<Sprite *> sprites;

+ 4
- 0
include/Window.h Visa fil

@@ -44,6 +44,10 @@ public:
44 44
 
45 45
     virtual void glExit2D();
46 46
 
47
+    virtual void lookAt(float eyeX, float eyeY, float eyeZ,
48
+                        float lookAtX, float lookAtY, float lookAtZ,
49
+                        float upX, float upY, float upZ);
50
+
47 51
 protected:
48 52
     bool mInit;
49 53
     bool mFullscreen;

+ 12
- 12
include/World.h Visa fil

@@ -34,24 +34,24 @@ public:
34 34
     void destroy();
35 35
 
36 36
     void addRoom(Room &room);
37
-    unsigned int sizeRoom();
38
-    Room &getRoom(unsigned int index);
37
+    unsigned long sizeRoom();
38
+    Room &getRoom(unsigned long index);
39 39
 
40 40
     void addSprite(SpriteSequence &sprite);
41
-    unsigned int sizeSprite();
42
-    SpriteSequence &getSprite(unsigned int index);
41
+    unsigned long sizeSprite();
42
+    SpriteSequence &getSprite(unsigned long index);
43 43
 
44 44
     void addEntity(Entity &entity);
45
-    unsigned int sizeEntity();
46
-    Entity &getEntity(unsigned int index);
45
+    unsigned long sizeEntity();
46
+    Entity &getEntity(unsigned long index);
47 47
 
48 48
     void addSkeletalModel(SkeletalModel &model);
49
-    unsigned int sizeSkeletalModel();
50
-    SkeletalModel &getSkeletalModel(unsigned int index);
49
+    unsigned long sizeSkeletalModel();
50
+    SkeletalModel &getSkeletalModel(unsigned long index);
51 51
 
52 52
     void addStaticMesh(StaticMesh &model);
53
-    unsigned int sizeStaticMesh();
54
-    StaticMesh &getStaticMesh(unsigned int index);
53
+    unsigned long sizeStaticMesh();
54
+    StaticMesh &getStaticMesh(unsigned long index);
55 55
 
56 56
     /*!
57 57
      * \brief Find room a location is in.
@@ -63,7 +63,7 @@ public:
63 63
      * \param z Z coordinate
64 64
      * \returns correct room index or -1 for unknown
65 65
      */
66
-    int getRoomByLocation(int index, float x, float y, float z);
66
+    long getRoomByLocation(long index, float x, float y, float z);
67 67
 
68 68
     /*!
69 69
      * \brief Find room a location is in.
@@ -74,7 +74,7 @@ public:
74 74
      * \param z Z coordinate
75 75
      * \returns correct room index or -1 for unknown
76 76
      */
77
-    int getRoomByLocation(float x, float y, float z);
77
+    long getRoomByLocation(float x, float y, float z);
78 78
 
79 79
 private:
80 80
     std::vector<Room *> mRooms;

+ 3
- 0
include/config.h.in Visa fil

@@ -24,5 +24,8 @@
24 24
 #cmakedefine HAVE_CLOSEDIR
25 25
 #cmakedefine HAVE_DT_DIR
26 26
 
27
+#cmakedefine HAVE_SYS_TIME_H
28
+#cmakedefine HAVE_GETTIMEOFDAY
29
+
27 30
 #endif
28 31
 

+ 2
- 0
include/utils/time.h Visa fil

@@ -8,6 +8,8 @@
8 8
 #ifndef _UTILS_TIME_H_
9 9
 #define _UTILS_TIME_H_
10 10
 
11
+extern unsigned long systemTimerStart;
12
+
11 13
 /*!
12 14
  * \brief Read the system timer
13 15
  * \returns number of ticks

+ 7
- 1
src/CMakeLists.txt Visa fil

@@ -120,6 +120,10 @@ check_function_exists (readdir_r HAVE_READDIR_R)
120 120
 check_function_exists (closedir HAVE_CLOSEDIR)
121 121
 check_symbol_exists (DT_DIR "dirent.h" HAVE_DT_DIR)
122 122
 
123
+# gettimeofday() for timing
124
+check_include_files (sys/time.h HAVE_SYS_TIME_H)
125
+check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
126
+
123 127
 #################################################################
124 128
 
125 129
 # Configuration Header file
@@ -255,4 +259,6 @@ target_link_libraries (OpenRaider ${LIBS})
255 259
 #################################################################
256 260
 
257 261
 # Add target to run executable
258
-add_custom_target(run COMMAND OpenRaider DEPENDS OpenRaider WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
262
+if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" OR ${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles")
263
+    add_custom_target(run COMMAND OpenRaider DEPENDS OpenRaider WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
264
+endif (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" OR ${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles") 

+ 5
- 5
src/Console.cpp Visa fil

@@ -95,7 +95,7 @@ void Console::display() {
95 95
         glRecti(0, 0, getWindow().getWidth(), getWindow().getHeight() / 2);
96 96
         glEnable(GL_TEXTURE_2D);
97 97
 
98
-        int scrollIndicator;
98
+        unsigned long scrollIndicator;
99 99
         if (mHistory.size() > lineCount) {
100 100
             scrollIndicator = (mHistory.size() - lineCount - mLineOffset) * 100 / (mHistory.size() - lineCount);
101 101
         } else {
@@ -107,9 +107,9 @@ void Console::display() {
107 107
                 "%s uptime %lus scroll %d%%", VERSION, systemTimerGet() / 1000, scrollIndicator);
108 108
 
109 109
         // Draw output log
110
-        int end = lineCount;
111
-        int drawOffset = 0;
112
-        int historyOffset = 0;
110
+        long end = lineCount;
111
+        long drawOffset = 0;
112
+        long historyOffset = 0;
113 113
         if (mHistory.size() < lineCount) {
114 114
             end = mHistory.size();
115 115
             drawOffset = lineCount - mHistory.size();
@@ -117,7 +117,7 @@ void Console::display() {
117 117
             historyOffset = mHistory.size() - lineCount;
118 118
         }
119 119
         for (int i = 0; i < end; i++) {
120
-            getFont().drawText(10, ((i + drawOffset) * lineSteps) + firstLine,
120
+            getFont().drawText(10, (unsigned int)((i + drawOffset) * lineSteps) + firstLine,
121 121
                     0.75f, BLUE, "%s", mHistory[i + historyOffset - mLineOffset]);
122 122
         }
123 123
 

+ 10
- 10
src/Entity.cpp Visa fil

@@ -64,7 +64,7 @@ void Entity::move(char movement) {
64 64
     const float testd = 220.0f;
65 65
     const float camHeight = 8.0f;
66 66
     float x, y, z, pitch, h, floor, ceiling;
67
-    int roomNew, sector;
67
+    long roomNew, sector;
68 68
     bool wall;
69 69
     unsigned int roomFlags;
70 70
 
@@ -113,7 +113,7 @@ void Entity::move(char movement) {
113 113
                 x, y, z);
114 114
 
115 115
         if (roomNew > -1)
116
-            getConsole().print("Crossing from room %i to %i", room, roomNew);
116
+            getConsole().print("Crossing from room %li to %li", room, roomNew);
117 117
         else
118 118
             //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
119 119
             return;
@@ -210,7 +210,7 @@ void Entity::move(char movement) {
210 210
 
211 211
 void Entity::print() {
212 212
     getConsole().print("Entity %d:", objectId);
213
-    getConsole().print("  Room %i (0x%X)", room, getWorld().getRoom(room).getFlags());
213
+    getConsole().print("  Room %li (0x%X)", room, getWorld().getRoom(room).getFlags());
214 214
     getConsole().print("  %.1fx %.1fy %.1fz", pos[0], pos[1], pos[2]);
215 215
     getConsole().print("  %.1f Yaw", OR_RAD_TO_DEG(angles[1]));
216 216
 }
@@ -251,32 +251,32 @@ float Entity::getAngle(unsigned int i) {
251 251
     return angles[i];
252 252
 }
253 253
 
254
-int Entity::getRoom() {
254
+long Entity::getRoom() {
255 255
     return room;
256 256
 }
257 257
 
258
-unsigned int Entity::getAnimation() {
258
+unsigned long Entity::getAnimation() {
259 259
     return animationFrame;
260 260
 }
261 261
 
262
-void Entity::setAnimation(unsigned int index) {
262
+void Entity::setAnimation(unsigned long index) {
263 263
     animationFrame = index;
264 264
     boneFrame = 0;
265 265
 }
266 266
 
267
-unsigned int Entity::getBoneFrame() {
267
+unsigned long Entity::getBoneFrame() {
268 268
     return boneFrame;
269 269
 }
270 270
 
271
-void Entity::setBoneFrame(unsigned int index) {
271
+void Entity::setBoneFrame(unsigned long index) {
272 272
     boneFrame = index;
273 273
 }
274 274
 
275
-unsigned int Entity::getIdleAnimation() {
275
+unsigned long Entity::getIdleAnimation() {
276 276
     return idleAnimation;
277 277
 }
278 278
 
279
-void Entity::setIdleAnimation(unsigned int index) {
279
+void Entity::setIdleAnimation(unsigned long index) {
280 280
     idleAnimation = index;
281 281
 }
282 282
 

+ 2
- 2
src/Game.cpp Visa fil

@@ -90,7 +90,7 @@ int Game::loadLevel(const char *level) {
90 90
         char *tmp = bufferString("%sMAIN.SFX", level); // Ensure theres enough space
91 91
         size_t length = strlen(tmp);
92 92
         size_t dir = 0;
93
-        for (int i = length - 1; i >= 0; i--) {
93
+        for (long i = length - 1; i >= 0; i--) {
94 94
             if ((tmp[i] == '/') || (tmp[i] == '\\')) {
95 95
                 dir = i + 1; // Find where the filename (bla.tr2) starts
96 96
                 break;
@@ -215,7 +215,7 @@ void Game::processPakSounds()
215 215
     //tr2_sound_details_t *detail;
216 216
     //float pos[3];
217 217
     unsigned int i;
218
-    int id;
218
+    unsigned long id;
219 219
 
220 220
     /* detail
221 221
        short sample;

+ 4
- 4
src/Menu.cpp Visa fil

@@ -169,8 +169,8 @@ void Menu::displayMapList() {
169 169
     int items = (getWindow().getHeight() - 110) / 25;
170 170
 
171 171
     // Select which part of the list to show
172
-    int min, max;
173
-    if (((int)mCursor - (items / 2)) > 0)
172
+    long min, max;
173
+    if (((long)mCursor - (items / 2)) > 0)
174 174
         min = mCursor - (items / 2);
175 175
     else
176 176
         min = 0;
@@ -267,13 +267,13 @@ void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
267 267
         else
268 268
             mCursor = 0;
269 269
     } else if (key == rightKey) {
270
-        int i = 10;
270
+        long i = 10;
271 271
         if (mCursor > (mMapList.size() - 11))
272 272
             i = mMapList.size() - 1 - mCursor;
273 273
         while (i-- > 0)
274 274
             handleKeyboard(downKey, true);
275 275
     } else if (key == leftKey) {
276
-        int i = 10;
276
+        long i = 10;
277 277
         if (mCursor < 10)
278 278
             i = mCursor;
279 279
         while (i-- > 0)

+ 21
- 73
src/Render.cpp Visa fil

@@ -78,35 +78,7 @@ unsigned int Render::getFlags() {
78 78
 }
79 79
 
80 80
 
81
-void setLighting(bool on)
82
-{
83
-    if (on)
84
-    {
85
-        float color[4];
86
-        color[0] = WHITE[0] * 256.0f;
87
-        color[1] = WHITE[1] * 256.0f;
88
-        color[2] = WHITE[2] * 256.0f;
89
-        color[3] = WHITE[3] * 256.0f;
90
-
91
-        glEnable(GL_LIGHTING);
92
-        glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
93
-        glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
94
-        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
95
-
96
-        color[0] = GREY[0] * 256.0f;
97
-        color[1] = GREY[1] * 256.0f;
98
-        color[2] = GREY[2] * 256.0f;
99
-        color[3] = GREY[3] * 256.0f;
100
-        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color);
101
-    }
102
-    else
103
-    {
104
-        glDisable(GL_LIGHTING);
105
-    }
106
-}
107
-
108
-
109
-void lightRoom(Room &room)
81
+void Render::lightRoom(Room &room)
110 82
 {
111 83
     for (unsigned int i = 0; i < room.sizeLights(); ++i)
112 84
     {
@@ -157,7 +129,7 @@ void Render::clearFlags(unsigned int flags)
157 129
 
158 130
     if (flags & Render::fGL_Lights)
159 131
     {
160
-        setLighting(false);
132
+        glDisable(GL_LIGHTING);
161 133
     }
162 134
 }
163 135
 
@@ -184,7 +156,22 @@ void Render::setFlags(unsigned int flags)
184 156
 
185 157
     if (flags & Render::fGL_Lights)
186 158
     {
187
-        setLighting(true);
159
+        float color[4];
160
+        color[0] = WHITE[0] * 256.0f;
161
+        color[1] = WHITE[1] * 256.0f;
162
+        color[2] = WHITE[2] * 256.0f;
163
+        color[3] = WHITE[3] * 256.0f;
164
+
165
+        glEnable(GL_LIGHTING);
166
+        glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
167
+        glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
168
+        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
169
+
170
+        color[0] = GREY[0] * 256.0f;
171
+        color[1] = GREY[1] * 256.0f;
172
+        color[2] = GREY[2] * 256.0f;
173
+        color[3] = GREY[3] * 256.0f;
174
+        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color);
188 175
     }
189 176
 }
190 177
 
@@ -225,45 +212,6 @@ void Render::setMode(int n)
225 212
     }
226 213
 }
227 214
 
228
-// Replaced the deprecated gluLookAt with slightly modified code from here:
229
-// http://www.khronos.org/message_boards/showthread.php/4991
230
-void gluLookAt(float eyeX, float eyeY, float eyeZ,
231
-        float lookAtX, float lookAtY, float lookAtZ,
232
-        float upX, float upY, float upZ) {
233
-    // calculating the viewing vector
234
-    float f[3] = {
235
-        lookAtX - eyeX,
236
-        lookAtY - eyeY,
237
-        lookAtZ - eyeZ
238
-    };
239
-
240
-    // normalizing the viewing vector
241
-    float fMag = sqrtf(f[0] * f[0] + f[1] * f[1] + f[2] * f[2]);
242
-    f[0] /= fMag;
243
-    f[1] /= fMag;
244
-    f[2] /= fMag;
245
-
246
-    float s[3] = {
247
-        (f[1] * upZ) - (upY * f[2]),
248
-        (upX * f[2]) - (f[0] * upZ),
249
-        (f[0] * upY) - (upX * f[1])
250
-    };
251
-
252
-    float u[3] = {
253
-        (s[1] * f[2]) - (f[1] * s[2]),
254
-        (f[0] * s[2]) - (s[0] * f[2]),
255
-        (s[0] * f[1]) - (f[0] * s[1])
256
-    };
257
-
258
-    float m[16] = {
259
-        s[0], u[0], -f[0], 0,
260
-        s[1], u[1], -f[1], 0,
261
-        s[2], u[2], -f[2], 0,
262
-           0,    0,     0, 1
263
-    };
264
-    glMultMatrixf(m);
265
-    glTranslatef(-eyeX, -eyeY, -eyeZ);
266
-}
267 215
 
268 216
 void Render::display()
269 217
 {
@@ -312,8 +260,8 @@ void Render::display()
312 260
     camPos[1] = curPos[1] - camOffsetH; // UP is lower val
313 261
     camPos[2] = curPos[2] - (1024.0f * cosf(yaw));
314 262
 
315
-    int index = getGame().getLara().getRoom();
316
-    int sector = getWorld().getRoom(index).getSector(camPos[0], camPos[2]);
263
+    long index = getGame().getLara().getRoom();
264
+    long sector = getWorld().getRoom(index).getSector(camPos[0], camPos[2]);
317 265
 
318 266
     // Handle camera out of world
319 267
     if ((sector < 0) ||
@@ -332,7 +280,7 @@ void Render::display()
332 280
     getCamera().update();
333 281
     getCamera().getTarget(atPos);
334 282
     // Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
335
-    gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0f, -1.0f, 0.0f);
283
+    getWindow().lookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0f, -1.0f, 0.0f);
336 284
 
337 285
     // Update view volume for vising
338 286
     updateViewVolume();

+ 23
- 24
src/Room.cpp Visa fil

@@ -529,21 +529,20 @@ void Room::display(bool alpha) {
529 529
     }
530 530
 }
531 531
 
532
-bool Room::isWall(unsigned int sector) {
533
-    assert(sector >= 0);
532
+bool Room::isWall(unsigned long sector) {
534 533
     assert(sector < sectors.size());
535 534
 
536 535
     //! \fixme is (sector > 0) correct??
537 536
     return ((sector > 0) && sectors.at(sector)->isWall());
538 537
 }
539 538
 
540
-int Room::getSector(float x, float z, float *floor, float *ceiling) {
539
+long Room::getSector(float x, float z, float *floor, float *ceiling) {
541 540
     assert(floor != NULL);
542 541
     assert(ceiling != NULL);
543 542
 
544
-    int sector = getSector(x, z);
543
+    long sector = getSector(x, z);
545 544
 
546
-    if ((sector >= 0) && (sector < (int)sectors.size())) {
545
+    if ((sector >= 0) && (sector < (long)sectors.size())) {
547 546
         *floor = sectors.at(sector)->getFloor();
548 547
         *ceiling = sectors.at(sector)->getCeiling();
549 548
     }
@@ -551,8 +550,8 @@ int Room::getSector(float x, float z, float *floor, float *ceiling) {
551 550
     return sector;
552 551
 }
553 552
 
554
-int Room::getSector(float x, float z) {
555
-    int sector = (((((int)x - (int)pos[0]) / 1024) *
553
+long Room::getSector(float x, float z) {
554
+    long sector = (((((int)x - (int)pos[0]) / 1024) *
556 555
         numZSectors) + (((int)z - (int)pos[2]) / 1024));
557 556
 
558 557
     if (sector < 0)
@@ -562,8 +561,8 @@ int Room::getSector(float x, float z) {
562 561
 }
563 562
 
564 563
 void Room::getHeightAtPosition(float x, float *y, float z) {
565
-    int sector = getSector(x, z);
566
-    if ((sector >= 0) && (sector < (int)sectors.size()))
564
+    long sector = getSector(x, z);
565
+    if ((sector >= 0) && (sector < (long)sectors.size()))
567 566
         *y = sectors.at(sector)->getFloor();
568 567
 }
569 568
 
@@ -575,7 +574,7 @@ int Room::getAdjoiningRoom(float x, float y, float z,
575 574
     p1[0] = x;  p1[1] = y;  p1[2] = z;
576 575
     p2[0] = x2; p2[1] = y2; p2[2] = z2;
577 576
 
578
-    for (unsigned int i = 0; i < portals.size(); i++) {
577
+    for (unsigned long i = 0; i < portals.size(); i++) {
579 578
         portals.at(i)->getVertices(vertices);
580 579
         if (intersectionLinePolygon(intersect, p1, p2, //4,
581 580
                     vertices))
@@ -602,47 +601,47 @@ void Room::getPos(float p[3]) {
602 601
         p[i] = pos[i];
603 602
 }
604 603
 
605
-unsigned int Room::sizeAdjacentRooms() {
604
+unsigned long Room::sizeAdjacentRooms() {
606 605
     return adjacentRooms.size();
607 606
 }
608 607
 
609
-int Room::getAdjacentRoom(unsigned int index) {
608
+long Room::getAdjacentRoom(unsigned long index) {
610 609
     assert(index < adjacentRooms.size());
611 610
     return adjacentRooms.at(index);
612 611
 }
613 612
 
614
-unsigned int Room::sizePortals() {
613
+unsigned long Room::sizePortals() {
615 614
     return portals.size();
616 615
 }
617 616
 
618
-Portal &Room::getPortal(unsigned int index) {
617
+Portal &Room::getPortal(unsigned long index) {
619 618
     assert(index < portals.size());
620 619
     return *portals.at(index);
621 620
 }
622 621
 
623
-unsigned int Room::sizeSectors() {
622
+unsigned long Room::sizeSectors() {
624 623
     return sectors.size();
625 624
 }
626 625
 
627
-Sector &Room::getSector(unsigned int index) {
626
+Sector &Room::getSector(unsigned long index) {
628 627
     assert(index < sectors.size());
629 628
     return *sectors.at(index);
630 629
 }
631 630
 
632
-unsigned int Room::sizeBox() {
631
+unsigned long Room::sizeBox() {
633 632
     return boxes.size();
634 633
 }
635 634
 
636
-Box &Room::getBox(unsigned int index) {
635
+Box &Room::getBox(unsigned long index) {
637 636
     assert(index < boxes.size());
638 637
     return *boxes.at(index);
639 638
 }
640 639
 
641
-unsigned int Room::sizeModels() {
640
+unsigned long Room::sizeModels() {
642 641
     return models.size();
643 642
 }
644 643
 
645
-StaticModel &Room::getModel(unsigned int index) {
644
+StaticModel &Room::getModel(unsigned long index) {
646 645
     assert(index < models.size());
647 646
     return *models.at(index);
648 647
 }
@@ -651,20 +650,20 @@ void Room::sortModels() {
651 650
     std::sort(models.begin(), models.end());
652 651
 }
653 652
 
654
-unsigned int Room::sizeLights() {
653
+unsigned long Room::sizeLights() {
655 654
     return lights.size();
656 655
 }
657 656
 
658
-Light &Room::getLight(unsigned int index) {
657
+Light &Room::getLight(unsigned long index) {
659 658
     assert(index < lights.size());
660 659
     return *lights.at(index);
661 660
 }
662 661
 
663
-unsigned int Room::sizeSprites() {
662
+unsigned long Room::sizeSprites() {
664 663
     return sprites.size();
665 664
 }
666 665
 
667
-Sprite &Room::getSprite(unsigned int index) {
666
+Sprite &Room::getSprite(unsigned long index) {
668 667
     assert(index < sprites.size());
669 668
     return *sprites.at(index);
670 669
 }

+ 10
- 10
src/SkeletalModel.cpp Visa fil

@@ -83,15 +83,15 @@ BoneFrame::BoneFrame(TombRaider &tr, unsigned int index, unsigned int frame_offs
83 83
 }
84 84
 
85 85
 BoneFrame::~BoneFrame() {
86
-    for (unsigned int i = 0; i < tag.size(); i++)
86
+    for (unsigned long i = 0; i < tag.size(); i++)
87 87
         delete tag[i];
88 88
 }
89 89
 
90
-unsigned int BoneFrame::size() {
90
+unsigned long BoneFrame::size() {
91 91
     return tag.size();
92 92
 }
93 93
 
94
-BoneTag &BoneFrame::get(unsigned int i) {
94
+BoneTag &BoneFrame::get(unsigned long i) {
95 95
     assert(i < tag.size());
96 96
     return *tag.at(i);
97 97
 }
@@ -147,15 +147,15 @@ AnimationFrame::AnimationFrame(TombRaider &tr, unsigned int index, int a, unsign
147 147
 }
148 148
 
149 149
 AnimationFrame::~AnimationFrame() {
150
-    for (unsigned int i = 0; i < frame.size(); i++)
150
+    for (unsigned long i = 0; i < frame.size(); i++)
151 151
         delete frame[i];
152 152
 }
153 153
 
154
-unsigned int AnimationFrame::size() {
154
+unsigned long AnimationFrame::size() {
155 155
     return frame.size();
156 156
 }
157 157
 
158
-BoneFrame &AnimationFrame::get(unsigned int i) {
158
+BoneFrame &AnimationFrame::get(unsigned long i) {
159 159
     assert(i < frame.size());
160 160
     return *frame.at(i);
161 161
 }
@@ -262,11 +262,11 @@ SkeletalModel::SkeletalModel(TombRaider &tr, unsigned int index, int objectId) {
262 262
 }
263 263
 
264 264
 SkeletalModel::~SkeletalModel() {
265
-    for (unsigned int i = 0; i < animation.size(); i++)
265
+    for (unsigned long i = 0; i < animation.size(); i++)
266 266
         delete animation[i];
267 267
 }
268 268
 
269
-void SkeletalModel::display(unsigned int aframe, unsigned int bframe) {
269
+void SkeletalModel::display(unsigned long aframe, unsigned long bframe) {
270 270
     assert(aframe < size());
271 271
     assert(bframe < get(aframe).size());
272 272
 
@@ -382,11 +382,11 @@ void SkeletalModel::setPonyPos(float x, float y, float z, float angle) {
382 382
     ponytailAngle = angle;
383 383
 }
384 384
 
385
-unsigned int SkeletalModel::size() {
385
+unsigned long SkeletalModel::size() {
386 386
     return animation.size();
387 387
 }
388 388
 
389
-AnimationFrame &SkeletalModel::get(unsigned int i) {
389
+AnimationFrame &SkeletalModel::get(unsigned long i) {
390 390
     assert(i < animation.size());
391 391
     return *animation.at(i);
392 392
 }

+ 15
- 18
src/SoundAL.cpp Visa fil

@@ -72,7 +72,7 @@ void SoundAL::setVolume(float vol) {
72 72
     mVolume = vol;
73 73
 }
74 74
 
75
-int SoundAL::registeredSources() {
75
+unsigned long SoundAL::registeredSources() {
76 76
     assert(mSource.size() == mBuffer.size());
77 77
 
78 78
     if ((!mEnabled) || (!mInit))
@@ -108,10 +108,9 @@ void SoundAL::listenAt(float pos[3], float angle[3]) {
108 108
     alListenerfv(AL_ORIENTATION, angle);
109 109
 }
110 110
 
111
-void SoundAL::sourceAt(int source, float pos[3]) {
111
+void SoundAL::sourceAt(unsigned long source, float pos[3]) {
112 112
     assert(mSource.size() == mBuffer.size());
113
-    assert(source >= 0);
114
-    assert(source < (int)mSource.size());
113
+    assert(source < mSource.size());
115 114
     assert(pos != NULL);
116 115
 
117 116
     if ((!mEnabled) || (!mInit))
@@ -121,12 +120,12 @@ void SoundAL::sourceAt(int source, float pos[3]) {
121 120
 }
122 121
 
123 122
 //! \fixme Seperate sourcing and buffering, Mongoose 2002.01.04
124
-int SoundAL::addFile(const char *filename, int *source, unsigned int flags) {
123
+int SoundAL::addFile(const char *filename, unsigned long *source, unsigned int flags) {
125 124
     ALsizei size;
126 125
     ALfloat freq;
127 126
     ALenum format;
128 127
     ALvoid *data;
129
-    int id;
128
+    unsigned long id;
130 129
 
131 130
     assert(mSource.size() == mBuffer.size());
132 131
     assert(filename != NULL);
@@ -138,7 +137,6 @@ int SoundAL::addFile(const char *filename, int *source, unsigned int flags) {
138 137
         return 0;
139 138
     }
140 139
 
141
-    *source = -1;
142 140
     id = mSource.size();
143 141
 
144 142
     mSource.push_back(0);
@@ -178,13 +176,13 @@ int SoundAL::addFile(const char *filename, int *source, unsigned int flags) {
178 176
     return 0;
179 177
 }
180 178
 
181
-int SoundAL::addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags) {
179
+int SoundAL::addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags) {
182 180
     ALsizei size;
183 181
     ALfloat freq;
184 182
     ALenum format;
185 183
     ALvoid *data;
186 184
     int error = 0;
187
-    int id;
185
+    unsigned long id;
188 186
 
189 187
     assert(mSource.size() == mBuffer.size());
190 188
     assert(wav != NULL);
@@ -195,7 +193,6 @@ int SoundAL::addWave(unsigned char *wav, unsigned int length, int *source, unsig
195 193
         return 0;
196 194
     }
197 195
 
198
-    *source = -1;
199 196
     id = mSource.size();
200 197
 
201 198
     mSource.push_back(0);
@@ -239,23 +236,23 @@ int SoundAL::addWave(unsigned char *wav, unsigned int length, int *source, unsig
239 236
     return 0;
240 237
 }
241 238
 
242
-void SoundAL::play(int source) {
239
+void SoundAL::play(unsigned long source) {
240
+    assert(mInit);
243 241
     assert(mSource.size() == mBuffer.size());
244
-    assert(source >= 0);
245
-    assert(source < (int)mSource.size());
242
+    assert(source < mSource.size());
246 243
 
247
-    if ((!mEnabled) || (!mInit))
244
+    if (!mEnabled)
248 245
         return;
249 246
 
250 247
     alSourcePlay(mSource[source]);
251 248
 }
252 249
 
253
-void SoundAL::stop(int source) {
250
+void SoundAL::stop(unsigned long source) {
251
+    assert(mInit);
254 252
     assert(mSource.size() == mBuffer.size());
255
-    assert(source >= 0);
256
-    assert(source < (int)mSource.size());
253
+    assert(source < mSource.size());
257 254
 
258
-    if ((!mEnabled) || (!mInit))
255
+    if (!mEnabled)
259 256
         return;
260 257
 
261 258
     alSourceStop(mSource[source]);

+ 6
- 6
src/SoundNull.cpp Visa fil

@@ -24,7 +24,7 @@ void SoundNull::setEnabled(bool on) {
24 24
 void SoundNull::setVolume(float vol) {
25 25
 }
26 26
 
27
-int SoundNull::registeredSources() {
27
+unsigned long SoundNull::registeredSources() {
28 28
     return 0;
29 29
 }
30 30
 
@@ -34,20 +34,20 @@ void SoundNull::clear() {
34 34
 void SoundNull::listenAt(float pos[3], float angle[3]) {
35 35
 }
36 36
 
37
-void SoundNull::sourceAt(int source, float pos[3]) {
37
+void SoundNull::sourceAt(unsigned long source, float pos[3]) {
38 38
 }
39 39
 
40
-int SoundNull::addFile(const char *filename, int *source, unsigned int flags) {
40
+int SoundNull::addFile(const char *filename, unsigned long *source, unsigned int flags) {
41 41
     return 0;
42 42
 }
43 43
 
44
-int SoundNull::addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags) {
44
+int SoundNull::addWave(unsigned char *wav, unsigned int length, unsigned long *source, unsigned int flags) {
45 45
     return 0;
46 46
 }
47 47
 
48
-void SoundNull::play(int source) {
48
+void SoundNull::play(unsigned long source) {
49 49
 }
50 50
 
51
-void SoundNull::stop(int source) {
51
+void SoundNull::stop(unsigned long source) {
52 52
 }
53 53
 

+ 3
- 2
src/Sprite.cpp Visa fil

@@ -21,11 +21,12 @@ SpriteSequence::~SpriteSequence() {
21 21
         delete sprites.at(i);
22 22
 }
23 23
 
24
-unsigned int SpriteSequence::size() {
24
+unsigned long SpriteSequence::size() {
25 25
     return sprites.size();
26 26
 }
27 27
 
28
-Sprite &SpriteSequence::get(unsigned int index) {
28
+Sprite &SpriteSequence::get(unsigned long index) {
29
+    assert(index < sprites.size());
29 30
     return *sprites.at(index);
30 31
 }
31 32
 

+ 40
- 0
src/Window.cpp Visa fil

@@ -151,3 +151,43 @@ void Window::glExit2D() {
151 151
     glMatrixMode(GL_MODELVIEW);
152 152
 }
153 153
 
154
+// Replaced the deprecated gluLookAt with slightly modified code from here:
155
+// http://www.khronos.org/message_boards/showthread.php/4991
156
+void Window::lookAt(float eyeX, float eyeY, float eyeZ,
157
+        float lookAtX, float lookAtY, float lookAtZ,
158
+        float upX, float upY, float upZ) {
159
+    // calculating the viewing vector
160
+    float f[3] = {
161
+        lookAtX - eyeX,
162
+        lookAtY - eyeY,
163
+        lookAtZ - eyeZ
164
+    };
165
+
166
+    // normalizing the viewing vector
167
+    float fMag = sqrtf(f[0] * f[0] + f[1] * f[1] + f[2] * f[2]);
168
+    f[0] /= fMag;
169
+    f[1] /= fMag;
170
+    f[2] /= fMag;
171
+
172
+    float s[3] = {
173
+        (f[1] * upZ) - (upY * f[2]),
174
+        (upX * f[2]) - (f[0] * upZ),
175
+        (f[0] * upY) - (upX * f[1])
176
+    };
177
+
178
+    float u[3] = {
179
+        (s[1] * f[2]) - (f[1] * s[2]),
180
+        (f[0] * s[2]) - (s[0] * f[2]),
181
+        (s[0] * f[1]) - (f[0] * s[1])
182
+    };
183
+
184
+    float m[16] = {
185
+        s[0], u[0], -f[0], 0,
186
+        s[1], u[1], -f[1], 0,
187
+        s[2], u[2], -f[2], 0,
188
+           0,    0,     0, 1
189
+    };
190
+    glMultMatrixf(m);
191
+    glTranslatef(-eyeX, -eyeY, -eyeZ);
192
+}
193
+

+ 20
- 20
src/World.cpp Visa fil

@@ -19,11 +19,11 @@ void World::addRoom(Room &room) {
19 19
     mRooms.push_back(&room);
20 20
 }
21 21
 
22
-unsigned int World::sizeRoom() {
22
+unsigned long World::sizeRoom() {
23 23
     return mRooms.size();
24 24
 }
25 25
 
26
-Room &World::getRoom(unsigned int index) {
26
+Room &World::getRoom(unsigned long index) {
27 27
     assert(index < mRooms.size());
28 28
     return *mRooms.at(index);
29 29
 }
@@ -32,11 +32,11 @@ void World::addSprite(SpriteSequence &sprite) {
32 32
     mSprites.push_back(&sprite);
33 33
 }
34 34
 
35
-unsigned int World::sizeSprite() {
35
+unsigned long World::sizeSprite() {
36 36
     return mSprites.size();
37 37
 }
38 38
 
39
-SpriteSequence &World::getSprite(unsigned int index) {
39
+SpriteSequence &World::getSprite(unsigned long index) {
40 40
     assert(index < mSprites.size());
41 41
     return *mSprites.at(index);
42 42
 }
@@ -45,11 +45,11 @@ void World::addEntity(Entity &entity) {
45 45
     mEntities.push_back(&entity);
46 46
 }
47 47
 
48
-unsigned int World::sizeEntity() {
48
+unsigned long World::sizeEntity() {
49 49
     return mEntities.size();
50 50
 }
51 51
 
52
-Entity &World::getEntity(unsigned int index) {
52
+Entity &World::getEntity(unsigned long index) {
53 53
     assert(index < mEntities.size());
54 54
     return *mEntities.at(index);
55 55
 }
@@ -58,11 +58,11 @@ void World::addSkeletalModel(SkeletalModel &model) {
58 58
     mModels.push_back(&model);
59 59
 }
60 60
 
61
-unsigned int World::sizeSkeletalModel() {
61
+unsigned long World::sizeSkeletalModel() {
62 62
     return mModels.size();
63 63
 }
64 64
 
65
-SkeletalModel &World::getSkeletalModel(unsigned int index) {
65
+SkeletalModel &World::getSkeletalModel(unsigned long index) {
66 66
     assert(index < mModels.size());
67 67
     return *mModels.at(index);
68 68
 }
@@ -71,20 +71,20 @@ void World::addStaticMesh(StaticMesh &model) {
71 71
     mMeshes.push_back(&model);
72 72
 }
73 73
 
74
-unsigned int World::sizeStaticMesh() {
74
+unsigned long World::sizeStaticMesh() {
75 75
     return mMeshes.size();
76 76
 }
77 77
 
78
-StaticMesh &World::getStaticMesh(unsigned int index) {
78
+StaticMesh &World::getStaticMesh(unsigned long index) {
79 79
     assert(index < mMeshes.size());
80 80
     return *mMeshes.at(index);
81 81
 }
82 82
 
83 83
 
84
-int World::getRoomByLocation(int index, float x, float y, float z)
84
+long World::getRoomByLocation(long index, float x, float y, float z)
85 85
 {
86 86
     assert(index >= 0);
87
-    assert(index < (int)mRooms.size());
87
+    assert(index < (long)mRooms.size());
88 88
     Room &room = *mRooms.at(index);
89 89
 
90 90
     if (room.getBoundingBox().inBox(x, y, z))
@@ -94,10 +94,10 @@ int World::getRoomByLocation(int index, float x, float y, float z)
94 94
 }
95 95
 
96 96
 
97
-int World::getRoomByLocation(float x, float y, float z) {
98
-    int hop = -1;
97
+long World::getRoomByLocation(float x, float y, float z) {
98
+    long hop = -1;
99 99
 
100
-    for (unsigned int i = 0; i < mRooms.size(); i++) {
100
+    for (unsigned long i = 0; i < mRooms.size(); i++) {
101 101
         if (mRooms.at(i)->getBoundingBox().inBoxPlane(x, z)) {
102 102
             if (mRooms.at(i)->getBoundingBox().inBox(x, y, z))
103 103
                 return i;
@@ -111,23 +111,23 @@ int World::getRoomByLocation(float x, float y, float z) {
111 111
 
112 112
 
113 113
 void World::destroy() {
114
-    for (unsigned int i = 0; i < mRooms.size(); i++)
114
+    for (unsigned long i = 0; i < mRooms.size(); i++)
115 115
         delete mRooms[i];
116 116
     mRooms.clear();
117 117
 
118
-    for (unsigned int i = 0; i < mSprites.size(); i++)
118
+    for (unsigned long i = 0; i < mSprites.size(); i++)
119 119
         delete mSprites[i];
120 120
     mSprites.clear();
121 121
 
122
-    for (unsigned int i = 0; i < mEntities.size(); i++)
122
+    for (unsigned long i = 0; i < mEntities.size(); i++)
123 123
         delete mEntities[i];
124 124
     mEntities.clear();
125 125
 
126
-    for (unsigned int i = 0; i < mModels.size(); i++)
126
+    for (unsigned long i = 0; i < mModels.size(); i++)
127 127
         delete mModels[i];
128 128
     mModels.clear();
129 129
 
130
-    for (unsigned int i = 0; i < mMeshes.size(); i++)
130
+    for (unsigned long i = 0; i < mMeshes.size(); i++)
131 131
         delete mMeshes[i];
132 132
     mMeshes.clear();
133 133
 }

+ 2
- 0
src/main.cpp Visa fil

@@ -34,6 +34,8 @@
34 34
 #error No Windowing Library selected!
35 35
 #endif
36 36
 
37
+void cleanupHandler(void);
38
+
37 39
 Camera &getCamera() {
38 40
     static Camera gCamera;
39 41
     return gCamera;

+ 1
- 1
src/utils/png.cpp Visa fil

@@ -117,7 +117,7 @@ int pngLoad(const char *filename, unsigned char **image,
117 117
 
118 118
     png_read_update_info(png_ptr, info_ptr);
119 119
 
120
-    int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
120
+    png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
121 121
 
122 122
     png_byte *image_data = new png_byte[(rowbytes * *height) + 15];
123 123
     png_bytep *row_pointers = new png_bytep[*height];

+ 8
- 8
src/utils/strings.cpp Visa fil

@@ -124,7 +124,7 @@ char *bufferString(const char *string, ...) {
124 124
 }
125 125
 
126 126
 char *fullPath(const char *path, char end) {
127
-    unsigned int lenPath;
127
+    size_t lenPath;
128 128
     char *dir;
129 129
 
130 130
     assert(path != NULL);
@@ -136,7 +136,7 @@ char *fullPath(const char *path, char end) {
136 136
         wordexp_t word;
137 137
 
138 138
 #ifdef __APPLE__
139
-        // Workaround for Mac OS X. See:
139
+        // Workunsigned long systemTimerStart = 0;around for Mac OS X. See:
140 140
         // http://stackoverflow.com/questions/20534788/why-does-wordexp-fail-with-wrde-syntax-on-os-x
141 141
         signal(SIGCHLD, SIG_DFL);
142 142
 #endif
@@ -163,9 +163,9 @@ char *fullPath(const char *path, char end) {
163 163
         dir = new char[lenPath + 2]; // space for end char
164 164
 
165 165
         // Copy segments into new string
166
-        unsigned int offset = 0;
166
+        size_t offset = 0;
167 167
         for (unsigned int i = 0; i < word.we_wordc; i++) {
168
-            unsigned int len = strlen(word.we_wordv[i]);
168
+            size_t len = strlen(word.we_wordv[i]);
169 169
             strncpy(dir + offset, word.we_wordv[i], len);
170 170
             offset += len;
171 171
         }
@@ -175,14 +175,14 @@ char *fullPath(const char *path, char end) {
175 175
         char newPath[MAX_PATH];
176 176
         if (SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, 0, newPath) == S_OK) {
177 177
             lenPath = strlen(newPath);
178
-            unsigned int lenPath2 = strlen(path);
178
+            size_t lenPath2 = strlen(path);
179 179
             dir = new char[lenPath + lenPath2 + 2]; // space for end char
180 180
             strncpy(dir, newPath, lenPath);
181 181
             strncpy((dir + lenPath), (path + 1), lenPath2 - 1);
182 182
             lenPath += lenPath2 - 1;
183
-			for (unsigned int i = 0; i < lenPath; i++)
184
-				if(dir[i] == '\\')
185
-					dir[i] = '/';
183
+            for (unsigned int i = 0; i < lenPath; i++)
184
+                if(dir[i] == '\\')
185
+                    dir[i] = '/';
186 186
         } else {
187 187
             printf("WARNING: Could not get home folder location for tilde expansion!\n");
188 188
             lenPath = strlen(path);

+ 13
- 15
src/utils/time.cpp Visa fil

@@ -8,41 +8,39 @@
8 8
 #include "global.h"
9 9
 #include "utils/time.h"
10 10
 
11
-#if defined(unix) || defined(__APPLE__) || defined (__linux__)
11
+unsigned long systemTimerStart = 0;
12 12
 
13
-#include <sys/time.h>
13
+#if defined(HAVE_SYS_TIME_H) && defined(HAVE_GETTIMEOFDAY)
14 14
 
15
-struct timeval system_timer_start;
16
-struct timeval system_timer_stop;
17
-struct timezone system_timer_zone;
15
+#include <sys/time.h>
18 16
 
19 17
 unsigned long systemTimerGet() {
20
-    gettimeofday(&system_timer_stop, &system_timer_zone);
21
-    return ((system_timer_stop.tv_sec - system_timer_start.tv_sec) * 1000)
22
-        + (((system_timer_stop.tv_usec - system_timer_start.tv_usec) / 1000));
18
+    struct timeval time;
19
+    struct timezone zone;
20
+    gettimeofday(&time, &zone);
21
+    return ((time.tv_sec * 1000) + (time.tv_usec / 1000)) - systemTimerStart;
23 22
 }
24 23
 
25 24
 void systemTimerReset() {
26
-    gettimeofday(&system_timer_start, &system_timer_zone);
25
+    struct timeval time;
26
+    struct timezone zone;
27
+    gettimeofday(&time, &zone);
28
+    systemTimerStart = (time.tv_sec * 1000) + (time.tv_usec / 1000);
27 29
 }
28 30
 
29 31
 #elif defined(_WIN32)
30 32
 
31 33
 #include <Windows.h>
32 34
 
33
-DWORD system_timer_start = 0;
34
-
35 35
 unsigned long systemTimerGet() {
36
-    return GetTickCount() - system_timer_start;
36
+    return GetTickCount() - systemTimerStart;
37 37
 }
38 38
 
39 39
 void systemTimerReset() {
40
-    system_timer_start = GetTickCount();
40
+    systemTimerStart = GetTickCount();
41 41
 }
42 42
 
43 43
 #else
44
-
45 44
 #error "No support for timer on this platform!"
46
-
47 45
 #endif
48 46
 

Laddar…
Avbryt
Spara