Browse Source

Fixed many 64 to 32 bit warnings

Thomas Buck 10 years ago
parent
commit
604539e334

+ 0
- 1
CMakeLists.txt View File

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

+ 5
- 0
ChangeLog.md View File

2
 
2
 
3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
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
     [ 20140705 ]
10
     [ 20140705 ]
6
     * Added basic Travis CI support
11
     * Added basic Travis CI support
7
     * Removed global object, using lazy initialization
12
     * Removed global object, using lazy initialization

+ 1
- 3
TODO.md View File

30
 
30
 
31
 # Travis CI
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 View File

36
     void setAngles(float a[3]);
36
     void setAngles(float a[3]);
37
     float getPos(unsigned int i);
37
     float getPos(unsigned int i);
38
     float getAngle(unsigned int i);
38
     float getAngle(unsigned int i);
39
-    int getRoom();
39
+    long getRoom();
40
 
40
 
41
     // Animation State
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
 private:
49
 private:
50
     float pos[3];
50
     float pos[3];
51
     float angles[3];
51
     float angles[3];
52
-    int room;
52
+    long room;
53
 
53
 
54
     unsigned int skeletalModel;
54
     unsigned int skeletalModel;
55
     MoveType moveType;
55
     MoveType moveType;
58
     int objectId;
58
     int objectId;
59
 
59
 
60
     // Animation State
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
 #endif
66
 #endif

+ 1
- 1
include/Game.h View File

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

+ 2
- 2
include/Menu.h View File

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

+ 2
- 0
include/Render.h View File

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

+ 18
- 18
include/Room.h View File

27
     Mesh &getMesh();
27
     Mesh &getMesh();
28
     void display(bool alpha);
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
     void getHeightAtPosition(float x, float *y, float z);
33
     void getHeightAtPosition(float x, float *y, float z);
34
     int getAdjoiningRoom(float x, float y, float z,
34
     int getAdjoiningRoom(float x, float y, float z,
35
         float x2, float y2, float z2);
35
         float x2, float y2, float z2);
41
     void setFlags(unsigned int f);
41
     void setFlags(unsigned int f);
42
     unsigned int getFlags();
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
 private:
65
 private:
66
     void sortModels();
66
     void sortModels();
73
     BoundingBox bbox;
73
     BoundingBox bbox;
74
     Mesh mesh;
74
     Mesh mesh;
75
 
75
 
76
-    std::vector<int> adjacentRooms;
76
+    std::vector<long> adjacentRooms;
77
     std::vector<Sprite *> sprites;
77
     std::vector<Sprite *> sprites;
78
     std::vector<StaticModel *> models;
78
     std::vector<StaticModel *> models;
79
     std::vector<Portal *> portals;
79
     std::vector<Portal *> portals;

+ 9
- 9
include/SkeletalModel.h View File

36
 
36
 
37
     void getPosition(float p[3]);
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
 private:
42
 private:
43
     float pos[3];
43
     float pos[3];
49
     AnimationFrame(TombRaider &tr, unsigned int index, int a, unsigned int *frame_offset, int frame_step);
49
     AnimationFrame(TombRaider &tr, unsigned int index, int a, unsigned int *frame_offset, int frame_step);
50
     ~AnimationFrame();
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
 private:
55
 private:
56
     char rate;
56
     char rate;
61
 public:
61
 public:
62
     SkeletalModel(TombRaider &tr, unsigned int index, int objectId);
62
     SkeletalModel(TombRaider &tr, unsigned int index, int objectId);
63
     ~SkeletalModel();
63
     ~SkeletalModel();
64
-    void display(unsigned int aframe, unsigned int bframe);
64
+    void display(unsigned long aframe, unsigned long bframe);
65
 
65
 
66
     int getId();
66
     int getId();
67
     void setPigTail(bool b);
67
     void setPigTail(bool b);
68
     void setPonyPos(float x, float y, float z, float angle);
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
 private:
73
 private:
74
     int id;
74
     int id;
75
     bool tr4Overlay;
75
     bool tr4Overlay;
76
     bool pigtails;
76
     bool pigtails;
77
-    int ponytailId;
77
+    long ponytailId;
78
     float ponytail[3];
78
     float ponytail[3];
79
-    int ponytailMeshId;
79
+    long ponytailMeshId;
80
     unsigned int ponytailNumMeshes;
80
     unsigned int ponytailNumMeshes;
81
     float ponytailAngle;
81
     float ponytailAngle;
82
     float ponyOff;
82
     float ponyOff;

+ 6
- 6
include/Sound.h View File

43
      * \brief Get number of registered sources
43
      * \brief Get number of registered sources
44
      * \returns number of registered sources
44
      * \returns number of registered sources
45
      */
45
      */
46
-    virtual int registeredSources() = 0;
46
+    virtual unsigned long registeredSources() = 0;
47
 
47
 
48
     /*!
48
     /*!
49
      * \brief Remove all loaded sounds
49
      * \brief Remove all loaded sounds
62
      * \param source valid source id
62
      * \param source valid source id
63
      * \param pos new position for source
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
      * \brief Load wav file from disk
68
      * \brief Load wav file from disk
71
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
71
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
72
      * \returns 0 for no error or < 0 error flag
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
      * \brief Load wav file from buffer
77
      * \brief Load wav file from buffer
81
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
81
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
82
      * \returns 0 for no error or < 0 error flag
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
      * \brief Play sound source
87
      * \brief Play sound source
88
      * \param source sound source to play
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
      * \brief Stop playing sound source
93
      * \brief Stop playing sound source
94
      * \param source sound source to stop
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
 Sound &getSound();
99
 Sound &getSound();

+ 8
- 8
include/SoundAL.h View File

47
      * \brief Get number of registered sources
47
      * \brief Get number of registered sources
48
      * \returns number of registered sources
48
      * \returns number of registered sources
49
      */
49
      */
50
-    virtual int registeredSources();
50
+    virtual unsigned long registeredSources();
51
 
51
 
52
     /*!
52
     /*!
53
      * \brief Remove all loaded sounds
53
      * \brief Remove all loaded sounds
66
      * \param source valid source id
66
      * \param source valid source id
67
      * \param pos new position for source
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
      * \brief Load wav file from disk
72
      * \brief Load wav file from disk
75
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
75
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
76
      * \returns 0 for no error or < 0 error flag
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
      * \brief Load wav file from buffer
81
      * \brief Load wav file from buffer
85
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
85
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
86
      * \returns 0 for no error or < 0 error flag
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
      * \brief Play sound source
91
      * \brief Play sound source
92
      * \param source sound source to play
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
      * \brief Stop playing sound source
97
      * \brief Stop playing sound source
98
      * \param source sound source to stop
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
 private:
102
 private:
103
 
103
 
104
     bool mEnabled;
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
     std::vector<unsigned int> mBuffer; //!< Audio buffer id list
107
     std::vector<unsigned int> mBuffer; //!< Audio buffer id list
108
     std::vector<unsigned int> mSource; //!< Audio source id list
108
     std::vector<unsigned int> mSource; //!< Audio source id list
109
 };
109
 };

+ 6
- 6
include/SoundNull.h View File

44
      * \brief Get number of registered sources
44
      * \brief Get number of registered sources
45
      * \returns number of registered sources
45
      * \returns number of registered sources
46
      */
46
      */
47
-    virtual int registeredSources();
47
+    virtual unsigned long registeredSources();
48
 
48
 
49
     /*!
49
     /*!
50
      * \brief Remove all loaded sounds
50
      * \brief Remove all loaded sounds
63
      * \param source valid source id
63
      * \param source valid source id
64
      * \param pos new position for source
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
      * \brief Load wav file from disk
69
      * \brief Load wav file from disk
72
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
72
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
73
      * \returns 0 for no error or < 0 error flag
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
      * \brief Load wav file from buffer
78
      * \brief Load wav file from buffer
82
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
82
      * \param flags set options. Use SoundFlags enum bitwise OR-ed
83
      * \returns 0 for no error or < 0 error flag
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
      * \brief Play sound source
88
      * \brief Play sound source
89
      * \param source sound source to play
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
      * \brief Stop playing sound source
94
      * \brief Stop playing sound source
95
      * \param source sound source to stop
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
 #endif
100
 #endif

+ 2
- 2
include/Sprite.h View File

29
     SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence);
29
     SpriteSequence(TombRaider &tr, unsigned int item, unsigned int sequence);
30
     ~SpriteSequence();
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
 private:
35
 private:
36
     std::vector<Sprite *> sprites;
36
     std::vector<Sprite *> sprites;

+ 4
- 0
include/Window.h View File

44
 
44
 
45
     virtual void glExit2D();
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
 protected:
51
 protected:
48
     bool mInit;
52
     bool mInit;
49
     bool mFullscreen;
53
     bool mFullscreen;

+ 12
- 12
include/World.h View File

34
     void destroy();
34
     void destroy();
35
 
35
 
36
     void addRoom(Room &room);
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
     void addSprite(SpriteSequence &sprite);
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
     void addEntity(Entity &entity);
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
     void addSkeletalModel(SkeletalModel &model);
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
     void addStaticMesh(StaticMesh &model);
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
      * \brief Find room a location is in.
57
      * \brief Find room a location is in.
63
      * \param z Z coordinate
63
      * \param z Z coordinate
64
      * \returns correct room index or -1 for unknown
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
      * \brief Find room a location is in.
69
      * \brief Find room a location is in.
74
      * \param z Z coordinate
74
      * \param z Z coordinate
75
      * \returns correct room index or -1 for unknown
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
 private:
79
 private:
80
     std::vector<Room *> mRooms;
80
     std::vector<Room *> mRooms;

+ 3
- 0
include/config.h.in View File

24
 #cmakedefine HAVE_CLOSEDIR
24
 #cmakedefine HAVE_CLOSEDIR
25
 #cmakedefine HAVE_DT_DIR
25
 #cmakedefine HAVE_DT_DIR
26
 
26
 
27
+#cmakedefine HAVE_SYS_TIME_H
28
+#cmakedefine HAVE_GETTIMEOFDAY
29
+
27
 #endif
30
 #endif
28
 
31
 

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

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

+ 7
- 1
src/CMakeLists.txt View File

120
 check_function_exists (closedir HAVE_CLOSEDIR)
120
 check_function_exists (closedir HAVE_CLOSEDIR)
121
 check_symbol_exists (DT_DIR "dirent.h" HAVE_DT_DIR)
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
 # Configuration Header file
129
 # Configuration Header file
255
 #################################################################
259
 #################################################################
256
 
260
 
257
 # Add target to run executable
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 View File

95
         glRecti(0, 0, getWindow().getWidth(), getWindow().getHeight() / 2);
95
         glRecti(0, 0, getWindow().getWidth(), getWindow().getHeight() / 2);
96
         glEnable(GL_TEXTURE_2D);
96
         glEnable(GL_TEXTURE_2D);
97
 
97
 
98
-        int scrollIndicator;
98
+        unsigned long scrollIndicator;
99
         if (mHistory.size() > lineCount) {
99
         if (mHistory.size() > lineCount) {
100
             scrollIndicator = (mHistory.size() - lineCount - mLineOffset) * 100 / (mHistory.size() - lineCount);
100
             scrollIndicator = (mHistory.size() - lineCount - mLineOffset) * 100 / (mHistory.size() - lineCount);
101
         } else {
101
         } else {
107
                 "%s uptime %lus scroll %d%%", VERSION, systemTimerGet() / 1000, scrollIndicator);
107
                 "%s uptime %lus scroll %d%%", VERSION, systemTimerGet() / 1000, scrollIndicator);
108
 
108
 
109
         // Draw output log
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
         if (mHistory.size() < lineCount) {
113
         if (mHistory.size() < lineCount) {
114
             end = mHistory.size();
114
             end = mHistory.size();
115
             drawOffset = lineCount - mHistory.size();
115
             drawOffset = lineCount - mHistory.size();
117
             historyOffset = mHistory.size() - lineCount;
117
             historyOffset = mHistory.size() - lineCount;
118
         }
118
         }
119
         for (int i = 0; i < end; i++) {
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
                     0.75f, BLUE, "%s", mHistory[i + historyOffset - mLineOffset]);
121
                     0.75f, BLUE, "%s", mHistory[i + historyOffset - mLineOffset]);
122
         }
122
         }
123
 
123
 

+ 10
- 10
src/Entity.cpp View File

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

+ 2
- 2
src/Game.cpp View File

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

+ 4
- 4
src/Menu.cpp View File

169
     int items = (getWindow().getHeight() - 110) / 25;
169
     int items = (getWindow().getHeight() - 110) / 25;
170
 
170
 
171
     // Select which part of the list to show
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
         min = mCursor - (items / 2);
174
         min = mCursor - (items / 2);
175
     else
175
     else
176
         min = 0;
176
         min = 0;
267
         else
267
         else
268
             mCursor = 0;
268
             mCursor = 0;
269
     } else if (key == rightKey) {
269
     } else if (key == rightKey) {
270
-        int i = 10;
270
+        long i = 10;
271
         if (mCursor > (mMapList.size() - 11))
271
         if (mCursor > (mMapList.size() - 11))
272
             i = mMapList.size() - 1 - mCursor;
272
             i = mMapList.size() - 1 - mCursor;
273
         while (i-- > 0)
273
         while (i-- > 0)
274
             handleKeyboard(downKey, true);
274
             handleKeyboard(downKey, true);
275
     } else if (key == leftKey) {
275
     } else if (key == leftKey) {
276
-        int i = 10;
276
+        long i = 10;
277
         if (mCursor < 10)
277
         if (mCursor < 10)
278
             i = mCursor;
278
             i = mCursor;
279
         while (i-- > 0)
279
         while (i-- > 0)

+ 21
- 73
src/Render.cpp View File

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
     for (unsigned int i = 0; i < room.sizeLights(); ++i)
83
     for (unsigned int i = 0; i < room.sizeLights(); ++i)
112
     {
84
     {
157
 
129
 
158
     if (flags & Render::fGL_Lights)
130
     if (flags & Render::fGL_Lights)
159
     {
131
     {
160
-        setLighting(false);
132
+        glDisable(GL_LIGHTING);
161
     }
133
     }
162
 }
134
 }
163
 
135
 
184
 
156
 
185
     if (flags & Render::fGL_Lights)
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
     }
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
 void Render::display()
216
 void Render::display()
269
 {
217
 {
312
     camPos[1] = curPos[1] - camOffsetH; // UP is lower val
260
     camPos[1] = curPos[1] - camOffsetH; // UP is lower val
313
     camPos[2] = curPos[2] - (1024.0f * cosf(yaw));
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
     // Handle camera out of world
266
     // Handle camera out of world
319
     if ((sector < 0) ||
267
     if ((sector < 0) ||
332
     getCamera().update();
280
     getCamera().update();
333
     getCamera().getTarget(atPos);
281
     getCamera().getTarget(atPos);
334
     // Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
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
     // Update view volume for vising
285
     // Update view volume for vising
338
     updateViewVolume();
286
     updateViewVolume();

+ 23
- 24
src/Room.cpp View File

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

+ 10
- 10
src/SkeletalModel.cpp View File

83
 }
83
 }
84
 
84
 
85
 BoneFrame::~BoneFrame() {
85
 BoneFrame::~BoneFrame() {
86
-    for (unsigned int i = 0; i < tag.size(); i++)
86
+    for (unsigned long i = 0; i < tag.size(); i++)
87
         delete tag[i];
87
         delete tag[i];
88
 }
88
 }
89
 
89
 
90
-unsigned int BoneFrame::size() {
90
+unsigned long BoneFrame::size() {
91
     return tag.size();
91
     return tag.size();
92
 }
92
 }
93
 
93
 
94
-BoneTag &BoneFrame::get(unsigned int i) {
94
+BoneTag &BoneFrame::get(unsigned long i) {
95
     assert(i < tag.size());
95
     assert(i < tag.size());
96
     return *tag.at(i);
96
     return *tag.at(i);
97
 }
97
 }
147
 }
147
 }
148
 
148
 
149
 AnimationFrame::~AnimationFrame() {
149
 AnimationFrame::~AnimationFrame() {
150
-    for (unsigned int i = 0; i < frame.size(); i++)
150
+    for (unsigned long i = 0; i < frame.size(); i++)
151
         delete frame[i];
151
         delete frame[i];
152
 }
152
 }
153
 
153
 
154
-unsigned int AnimationFrame::size() {
154
+unsigned long AnimationFrame::size() {
155
     return frame.size();
155
     return frame.size();
156
 }
156
 }
157
 
157
 
158
-BoneFrame &AnimationFrame::get(unsigned int i) {
158
+BoneFrame &AnimationFrame::get(unsigned long i) {
159
     assert(i < frame.size());
159
     assert(i < frame.size());
160
     return *frame.at(i);
160
     return *frame.at(i);
161
 }
161
 }
262
 }
262
 }
263
 
263
 
264
 SkeletalModel::~SkeletalModel() {
264
 SkeletalModel::~SkeletalModel() {
265
-    for (unsigned int i = 0; i < animation.size(); i++)
265
+    for (unsigned long i = 0; i < animation.size(); i++)
266
         delete animation[i];
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
     assert(aframe < size());
270
     assert(aframe < size());
271
     assert(bframe < get(aframe).size());
271
     assert(bframe < get(aframe).size());
272
 
272
 
382
     ponytailAngle = angle;
382
     ponytailAngle = angle;
383
 }
383
 }
384
 
384
 
385
-unsigned int SkeletalModel::size() {
385
+unsigned long SkeletalModel::size() {
386
     return animation.size();
386
     return animation.size();
387
 }
387
 }
388
 
388
 
389
-AnimationFrame &SkeletalModel::get(unsigned int i) {
389
+AnimationFrame &SkeletalModel::get(unsigned long i) {
390
     assert(i < animation.size());
390
     assert(i < animation.size());
391
     return *animation.at(i);
391
     return *animation.at(i);
392
 }
392
 }

+ 15
- 18
src/SoundAL.cpp View File

72
     mVolume = vol;
72
     mVolume = vol;
73
 }
73
 }
74
 
74
 
75
-int SoundAL::registeredSources() {
75
+unsigned long SoundAL::registeredSources() {
76
     assert(mSource.size() == mBuffer.size());
76
     assert(mSource.size() == mBuffer.size());
77
 
77
 
78
     if ((!mEnabled) || (!mInit))
78
     if ((!mEnabled) || (!mInit))
108
     alListenerfv(AL_ORIENTATION, angle);
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
     assert(mSource.size() == mBuffer.size());
112
     assert(mSource.size() == mBuffer.size());
113
-    assert(source >= 0);
114
-    assert(source < (int)mSource.size());
113
+    assert(source < mSource.size());
115
     assert(pos != NULL);
114
     assert(pos != NULL);
116
 
115
 
117
     if ((!mEnabled) || (!mInit))
116
     if ((!mEnabled) || (!mInit))
121
 }
120
 }
122
 
121
 
123
 //! \fixme Seperate sourcing and buffering, Mongoose 2002.01.04
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
     ALsizei size;
124
     ALsizei size;
126
     ALfloat freq;
125
     ALfloat freq;
127
     ALenum format;
126
     ALenum format;
128
     ALvoid *data;
127
     ALvoid *data;
129
-    int id;
128
+    unsigned long id;
130
 
129
 
131
     assert(mSource.size() == mBuffer.size());
130
     assert(mSource.size() == mBuffer.size());
132
     assert(filename != NULL);
131
     assert(filename != NULL);
138
         return 0;
137
         return 0;
139
     }
138
     }
140
 
139
 
141
-    *source = -1;
142
     id = mSource.size();
140
     id = mSource.size();
143
 
141
 
144
     mSource.push_back(0);
142
     mSource.push_back(0);
178
     return 0;
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
     ALsizei size;
180
     ALsizei size;
183
     ALfloat freq;
181
     ALfloat freq;
184
     ALenum format;
182
     ALenum format;
185
     ALvoid *data;
183
     ALvoid *data;
186
     int error = 0;
184
     int error = 0;
187
-    int id;
185
+    unsigned long id;
188
 
186
 
189
     assert(mSource.size() == mBuffer.size());
187
     assert(mSource.size() == mBuffer.size());
190
     assert(wav != NULL);
188
     assert(wav != NULL);
195
         return 0;
193
         return 0;
196
     }
194
     }
197
 
195
 
198
-    *source = -1;
199
     id = mSource.size();
196
     id = mSource.size();
200
 
197
 
201
     mSource.push_back(0);
198
     mSource.push_back(0);
239
     return 0;
236
     return 0;
240
 }
237
 }
241
 
238
 
242
-void SoundAL::play(int source) {
239
+void SoundAL::play(unsigned long source) {
240
+    assert(mInit);
243
     assert(mSource.size() == mBuffer.size());
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
         return;
245
         return;
249
 
246
 
250
     alSourcePlay(mSource[source]);
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
     assert(mSource.size() == mBuffer.size());
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
         return;
256
         return;
260
 
257
 
261
     alSourceStop(mSource[source]);
258
     alSourceStop(mSource[source]);

+ 6
- 6
src/SoundNull.cpp View File

24
 void SoundNull::setVolume(float vol) {
24
 void SoundNull::setVolume(float vol) {
25
 }
25
 }
26
 
26
 
27
-int SoundNull::registeredSources() {
27
+unsigned long SoundNull::registeredSources() {
28
     return 0;
28
     return 0;
29
 }
29
 }
30
 
30
 
34
 void SoundNull::listenAt(float pos[3], float angle[3]) {
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
     return 0;
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
     return 0;
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 View File

21
         delete sprites.at(i);
21
         delete sprites.at(i);
22
 }
22
 }
23
 
23
 
24
-unsigned int SpriteSequence::size() {
24
+unsigned long SpriteSequence::size() {
25
     return sprites.size();
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
     return *sprites.at(index);
30
     return *sprites.at(index);
30
 }
31
 }
31
 
32
 

+ 40
- 0
src/Window.cpp View File

151
     glMatrixMode(GL_MODELVIEW);
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 View File

19
     mRooms.push_back(&room);
19
     mRooms.push_back(&room);
20
 }
20
 }
21
 
21
 
22
-unsigned int World::sizeRoom() {
22
+unsigned long World::sizeRoom() {
23
     return mRooms.size();
23
     return mRooms.size();
24
 }
24
 }
25
 
25
 
26
-Room &World::getRoom(unsigned int index) {
26
+Room &World::getRoom(unsigned long index) {
27
     assert(index < mRooms.size());
27
     assert(index < mRooms.size());
28
     return *mRooms.at(index);
28
     return *mRooms.at(index);
29
 }
29
 }
32
     mSprites.push_back(&sprite);
32
     mSprites.push_back(&sprite);
33
 }
33
 }
34
 
34
 
35
-unsigned int World::sizeSprite() {
35
+unsigned long World::sizeSprite() {
36
     return mSprites.size();
36
     return mSprites.size();
37
 }
37
 }
38
 
38
 
39
-SpriteSequence &World::getSprite(unsigned int index) {
39
+SpriteSequence &World::getSprite(unsigned long index) {
40
     assert(index < mSprites.size());
40
     assert(index < mSprites.size());
41
     return *mSprites.at(index);
41
     return *mSprites.at(index);
42
 }
42
 }
45
     mEntities.push_back(&entity);
45
     mEntities.push_back(&entity);
46
 }
46
 }
47
 
47
 
48
-unsigned int World::sizeEntity() {
48
+unsigned long World::sizeEntity() {
49
     return mEntities.size();
49
     return mEntities.size();
50
 }
50
 }
51
 
51
 
52
-Entity &World::getEntity(unsigned int index) {
52
+Entity &World::getEntity(unsigned long index) {
53
     assert(index < mEntities.size());
53
     assert(index < mEntities.size());
54
     return *mEntities.at(index);
54
     return *mEntities.at(index);
55
 }
55
 }
58
     mModels.push_back(&model);
58
     mModels.push_back(&model);
59
 }
59
 }
60
 
60
 
61
-unsigned int World::sizeSkeletalModel() {
61
+unsigned long World::sizeSkeletalModel() {
62
     return mModels.size();
62
     return mModels.size();
63
 }
63
 }
64
 
64
 
65
-SkeletalModel &World::getSkeletalModel(unsigned int index) {
65
+SkeletalModel &World::getSkeletalModel(unsigned long index) {
66
     assert(index < mModels.size());
66
     assert(index < mModels.size());
67
     return *mModels.at(index);
67
     return *mModels.at(index);
68
 }
68
 }
71
     mMeshes.push_back(&model);
71
     mMeshes.push_back(&model);
72
 }
72
 }
73
 
73
 
74
-unsigned int World::sizeStaticMesh() {
74
+unsigned long World::sizeStaticMesh() {
75
     return mMeshes.size();
75
     return mMeshes.size();
76
 }
76
 }
77
 
77
 
78
-StaticMesh &World::getStaticMesh(unsigned int index) {
78
+StaticMesh &World::getStaticMesh(unsigned long index) {
79
     assert(index < mMeshes.size());
79
     assert(index < mMeshes.size());
80
     return *mMeshes.at(index);
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
     assert(index >= 0);
86
     assert(index >= 0);
87
-    assert(index < (int)mRooms.size());
87
+    assert(index < (long)mRooms.size());
88
     Room &room = *mRooms.at(index);
88
     Room &room = *mRooms.at(index);
89
 
89
 
90
     if (room.getBoundingBox().inBox(x, y, z))
90
     if (room.getBoundingBox().inBox(x, y, 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
         if (mRooms.at(i)->getBoundingBox().inBoxPlane(x, z)) {
101
         if (mRooms.at(i)->getBoundingBox().inBoxPlane(x, z)) {
102
             if (mRooms.at(i)->getBoundingBox().inBox(x, y, z))
102
             if (mRooms.at(i)->getBoundingBox().inBox(x, y, z))
103
                 return i;
103
                 return i;
111
 
111
 
112
 
112
 
113
 void World::destroy() {
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
         delete mRooms[i];
115
         delete mRooms[i];
116
     mRooms.clear();
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
         delete mSprites[i];
119
         delete mSprites[i];
120
     mSprites.clear();
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
         delete mEntities[i];
123
         delete mEntities[i];
124
     mEntities.clear();
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
         delete mModels[i];
127
         delete mModels[i];
128
     mModels.clear();
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
         delete mMeshes[i];
131
         delete mMeshes[i];
132
     mMeshes.clear();
132
     mMeshes.clear();
133
 }
133
 }

+ 2
- 0
src/main.cpp View File

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

+ 1
- 1
src/utils/png.cpp View File

117
 
117
 
118
     png_read_update_info(png_ptr, info_ptr);
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
     png_byte *image_data = new png_byte[(rowbytes * *height) + 15];
122
     png_byte *image_data = new png_byte[(rowbytes * *height) + 15];
123
     png_bytep *row_pointers = new png_bytep[*height];
123
     png_bytep *row_pointers = new png_bytep[*height];

+ 8
- 8
src/utils/strings.cpp View File

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

+ 13
- 15
src/utils/time.cpp View File

8
 #include "global.h"
8
 #include "global.h"
9
 #include "utils/time.h"
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
 unsigned long systemTimerGet() {
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
 void systemTimerReset() {
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
 #elif defined(_WIN32)
31
 #elif defined(_WIN32)
30
 
32
 
31
 #include <Windows.h>
33
 #include <Windows.h>
32
 
34
 
33
-DWORD system_timer_start = 0;
34
-
35
 unsigned long systemTimerGet() {
35
 unsigned long systemTimerGet() {
36
-    return GetTickCount() - system_timer_start;
36
+    return GetTickCount() - systemTimerStart;
37
 }
37
 }
38
 
38
 
39
 void systemTimerReset() {
39
 void systemTimerReset() {
40
-    system_timer_start = GetTickCount();
40
+    systemTimerStart = GetTickCount();
41
 }
41
 }
42
 
42
 
43
 #else
43
 #else
44
-
45
 #error "No support for timer on this platform!"
44
 #error "No support for timer on this platform!"
46
-
47
 #endif
45
 #endif
48
 
46
 

Loading…
Cancel
Save