Browse Source

Consistent use of rc_get_bool.

Also removed some more unused code.
Thomas Buck 10 years ago
parent
commit
95ac4ecec2
6 changed files with 41 additions and 90 deletions
  1. 5
    1
      README.md
  2. 0
    7
      include/System.h
  3. 0
    18
      include/utils/math.h
  4. 36
    17
      src/OpenRaider.cpp
  5. 0
    8
      src/System.cpp
  6. 0
    39
      src/utils/math.cpp

+ 5
- 1
README.md View File

128
 
128
 
129
 ### Console/Config Commands
129
 ### Console/Config Commands
130
 
130
 
131
-Console commands (BOOL is now '0' or '1' for less typing).
131
+Console commands (BOOL is '0', '1', "true" or "false").
132
 Pressing <UP> will go back to last command entered (saves typing).
132
 Pressing <UP> will go back to last command entered (saves typing).
133
 
133
 
134
 #### Game
134
 #### Game
183
 
183
 
184
 #### Set Commands
184
 #### Set Commands
185
 
185
 
186
+These commands have to be entered as `set COMMAND VALUE` or `set COMMAND=VALUE`.
187
+
186
 | Command        | Action                    |
188
 | Command        | Action                    |
187
 | --------------:|:------------------------- |
189
 | --------------:|:------------------------- |
188
 | mousegrab BOOL | Set mouse grabbing on/off |
190
 | mousegrab BOOL | Set mouse grabbing on/off |
189
 
191
 
190
 #### Stat Commands
192
 #### Stat Commands
191
 
193
 
194
+These commands have to be entered as `stat COMMAND`.
195
+
192
 | Command | Action                 |
196
 | Command | Action                 |
193
 | -------:|:---------------------- |
197
 | -------:|:---------------------- |
194
 | fps     | Toggle showing FPS     |
198
 | fps     | Toggle showing FPS     |

+ 0
- 7
include/System.h View File

68
     virtual ~System();
68
     virtual ~System();
69
 
69
 
70
     /*!
70
     /*!
71
-     * \brief Created a directory
72
-     * \param path Directory to create
73
-     * \returns -1 on error
74
-     */
75
-    static int createDir(char *path);
76
-
77
-    /*!
78
      * \brief Created a new Command Mode.
71
      * \brief Created a new Command Mode.
79
      * \param command valid command mode for the resource file, eg "[Engine.OpenGL.Driver]"
72
      * \param command valid command mode for the resource file, eg "[Engine.OpenGL.Driver]"
80
      * \returns id given to mode
73
      * \returns id given to mode

+ 0
- 18
include/utils/math.h View File

45
 int helIntersectionLineAndPolygon(vec3_t intersect, vec3_t p1, vec3_t p2, vec3_t *polygon);
45
 int helIntersectionLineAndPolygon(vec3_t intersect, vec3_t p1, vec3_t p2, vec3_t *polygon);
46
 
46
 
47
 /*!
47
 /*!
48
- * \brief Calculate the distance from a sphere to a plane
49
- * \param center Center of sphere
50
- * \param radius Radius of sphere
51
- * \param plane Plane
52
- * \returns distance
53
- */
54
-vec_t helDistToSphereFromPlane3v(vec3_t center, vec_t radius, vec4_t plane);
55
-
56
-/*!
57
- * \brief Calculate the distance from a box to a plane
58
- * \param min Minimum Point of a bounding box
59
- * \param max Maximum Point of a bounding box
60
- * \param plane Plane
61
- * \returns distance
62
- */
63
-vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane);
64
-
65
-/*!
66
  * \brief Calculate the length of a line segment / the distance between two points
48
  * \brief Calculate the length of a line segment / the distance between two points
67
  * \param a First point
49
  * \param a First point
68
  * \param b Second point
50
  * \param b Second point

+ 36
- 17
src/OpenRaider.cpp View File

2698
 //! \fixme Use rc_get_bool consistently!
2698
 //! \fixme Use rc_get_bool consistently!
2699
 void OpenRaider::consoleCommand(char *cmd)
2699
 void OpenRaider::consoleCommand(char *cmd)
2700
 {
2700
 {
2701
+    bool b = false;
2702
+
2701
     if (!cmd || !cmd[0])
2703
     if (!cmd || !cmd[0])
2702
         return;
2704
         return;
2703
 
2705
 
2805
     }
2807
     }
2806
     else if (rc_command("r_animate", cmd))
2808
     else if (rc_command("r_animate", cmd))
2807
     {
2809
     {
2808
-        if (atoi(cmd))
2810
+        rc_get_bool(cmd, &b);
2811
+        if (b)
2809
         {
2812
         {
2810
             m_render.setFlags(Render::fAnimateAllModels);
2813
             m_render.setFlags(Render::fAnimateAllModels);
2811
             print(false, "Animating all models");
2814
             print(false, "Animating all models");
2818
     }
2821
     }
2819
     else if (rc_command("r_ponytail", cmd))
2822
     else if (rc_command("r_ponytail", cmd))
2820
     {
2823
     {
2821
-        if (atoi(cmd))
2824
+        rc_get_bool(cmd, &b);
2825
+        if (b)
2822
         {
2826
         {
2823
             m_render.setFlags(Render::fRenderPonytail);
2827
             m_render.setFlags(Render::fRenderPonytail);
2824
             print(false, "Rendering ponytail");
2828
             print(false, "Rendering ponytail");
2831
     }
2835
     }
2832
     else if (rc_command("r_light", cmd))
2836
     else if (rc_command("r_light", cmd))
2833
     {
2837
     {
2834
-        if (atoi(cmd))
2838
+        rc_get_bool(cmd, &b);
2839
+        if (b)
2835
         {
2840
         {
2836
             m_render.setFlags(Render::fGL_Lights);
2841
             m_render.setFlags(Render::fGL_Lights);
2837
         }
2842
         }
2842
     }
2847
     }
2843
     else if (rc_command("hop", cmd))
2848
     else if (rc_command("hop", cmd))
2844
     {
2849
     {
2845
-        if (atoi(cmd))
2850
+        rc_get_bool(cmd, &b);
2851
+        if (b)
2846
         {
2852
         {
2847
             gWorld.setFlag(World::fEnableHopping);
2853
             gWorld.setFlag(World::fEnableHopping);
2848
             print(true, "Room hopping is on");
2854
             print(true, "Room hopping is on");
2855
     }
2861
     }
2856
     else if (rc_command("r_fog", cmd))
2862
     else if (rc_command("r_fog", cmd))
2857
     {
2863
     {
2858
-        if (atoi(cmd))
2864
+        rc_get_bool(cmd, &b);
2865
+        if (b)
2859
         {
2866
         {
2860
             m_render.setFlags(Render::fFog);
2867
             m_render.setFlags(Render::fFog);
2861
         }
2868
         }
2906
     }
2913
     }
2907
     else if (rc_command("r_oneroom", cmd))
2914
     else if (rc_command("r_oneroom", cmd))
2908
     {
2915
     {
2909
-        if (atoi(cmd))
2916
+        rc_get_bool(cmd, &b);
2917
+        if (b)
2910
         {
2918
         {
2911
             m_render.setFlags(Render::fOneRoom);
2919
             m_render.setFlags(Render::fOneRoom);
2912
         }
2920
         }
2917
     }
2925
     }
2918
     else if (rc_command("r_allrooms", cmd))
2926
     else if (rc_command("r_allrooms", cmd))
2919
     {
2927
     {
2920
-        if (atoi(cmd))
2928
+        rc_get_bool(cmd, &b);
2929
+        if (b)
2921
         {
2930
         {
2922
             m_render.setFlags(Render::fAllRooms);
2931
             m_render.setFlags(Render::fAllRooms);
2923
         }
2932
         }
2930
     }
2939
     }
2931
     else if (rc_command("r_sprite", cmd))
2940
     else if (rc_command("r_sprite", cmd))
2932
     {
2941
     {
2933
-        if (atoi(cmd))
2942
+        rc_get_bool(cmd, &b);
2943
+        if (b)
2934
         {
2944
         {
2935
             m_render.setFlags(Render::fSprites);
2945
             m_render.setFlags(Render::fSprites);
2936
         }
2946
         }
2941
     }
2951
     }
2942
     else if (rc_command("r_roommodel", cmd))
2952
     else if (rc_command("r_roommodel", cmd))
2943
     {
2953
     {
2944
-        if (atoi(cmd))
2954
+        rc_get_bool(cmd, &b);
2955
+        if (b)
2945
         {
2956
         {
2946
             m_render.setFlags(Render::fRoomModels);
2957
             m_render.setFlags(Render::fRoomModels);
2947
         }
2958
         }
2952
     }
2963
     }
2953
     else if (rc_command("r_entmodel", cmd))
2964
     else if (rc_command("r_entmodel", cmd))
2954
     {
2965
     {
2955
-        if (atoi(cmd))
2966
+        rc_get_bool(cmd, &b);
2967
+        if (b)
2956
         {
2968
         {
2957
             m_render.setFlags(Render::fEntityModels);
2969
             m_render.setFlags(Render::fEntityModels);
2958
         }
2970
         }
2963
     }
2975
     }
2964
     else if (rc_command("r_particle", cmd))
2976
     else if (rc_command("r_particle", cmd))
2965
     {
2977
     {
2966
-        if (atoi(cmd))
2978
+        rc_get_bool(cmd, &b);
2979
+        if (b)
2967
         {
2980
         {
2968
             m_render.setFlags(Render::fParticles);
2981
             m_render.setFlags(Render::fParticles);
2969
         }
2982
         }
2974
     }
2987
     }
2975
     else if (rc_command("r_vis", cmd))
2988
     else if (rc_command("r_vis", cmd))
2976
     {
2989
     {
2977
-        if (atoi(cmd))
2990
+        rc_get_bool(cmd, &b);
2991
+        if (b)
2978
         {
2992
         {
2979
             m_render.setFlags(Render::fUsePortals);
2993
             m_render.setFlags(Render::fUsePortals);
2980
         }
2994
         }
2985
     }
2999
     }
2986
     else if (rc_command("r_upf", cmd))
3000
     else if (rc_command("r_upf", cmd))
2987
     {
3001
     {
2988
-        if (atoi(cmd))
3002
+        rc_get_bool(cmd, &b);
3003
+        if (b)
2989
         {
3004
         {
2990
             m_render.setFlags(Render::fUpdateRoomListPerFrame);
3005
             m_render.setFlags(Render::fUpdateRoomListPerFrame);
2991
         }
3006
         }
2996
     }
3011
     }
2997
     else if (rc_command("r_portal", cmd))
3012
     else if (rc_command("r_portal", cmd))
2998
     {
3013
     {
2999
-        if (atoi(cmd))
3014
+        rc_get_bool(cmd, &b);
3015
+        if (b)
3000
         {
3016
         {
3001
             m_render.setFlags(Render::fPortals);
3017
             m_render.setFlags(Render::fPortals);
3002
         }
3018
         }
3007
     }
3023
     }
3008
     else if (rc_command("r_vmodel", cmd))
3024
     else if (rc_command("r_vmodel", cmd))
3009
     {
3025
     {
3010
-        if (atoi(cmd))
3026
+        rc_get_bool(cmd, &b);
3027
+        if (b)
3011
         {
3028
         {
3012
             m_render.setFlags(Render::fViewModel);
3029
             m_render.setFlags(Render::fViewModel);
3013
         }
3030
         }
3018
     }
3035
     }
3019
     else if (rc_command("r_ralpha", cmd))
3036
     else if (rc_command("r_ralpha", cmd))
3020
     {
3037
     {
3021
-        if (atoi(cmd))
3038
+        rc_get_bool(cmd, &b);
3039
+        if (b)
3022
         {
3040
         {
3023
             m_render.setFlags(Render::fRoomAlpha);
3041
             m_render.setFlags(Render::fRoomAlpha);
3024
         }
3042
         }
3062
     {
3080
     {
3063
         m_flags |= OpenRaider_ShowFPS;
3081
         m_flags |= OpenRaider_ShowFPS;
3064
 
3082
 
3065
-        if (!atoi(cmd))
3083
+        rc_get_bool(cmd, &b);
3084
+        if (!b)
3066
         {
3085
         {
3067
             m_flags ^= OpenRaider_ShowFPS;
3086
             m_flags ^= OpenRaider_ShowFPS;
3068
         }
3087
         }

+ 0
- 8
src/System.cpp View File

57
 System::~System() {
57
 System::~System() {
58
 }
58
 }
59
 
59
 
60
-int System::createDir(char *path) {
61
-#ifdef WIN32
62
-    return _mkdir(path);
63
-#else
64
-    return mkdir(path, S_IRWXU | S_IRWXG);
65
-#endif
66
-}
67
-
68
 unsigned int System::addCommandMode(const char *command) {
60
 unsigned int System::addCommandMode(const char *command) {
69
     if (command && command[0] == '[') {
61
     if (command && command[0] == '[') {
70
         mCmdModes.pushBack(command);
62
         mCmdModes.pushBack(command);

+ 0
- 39
src/utils/math.cpp View File

93
 }
93
 }
94
 
94
 
95
 
95
 
96
-vec_t helDistToSphereFromPlane3v(vec3_t center, vec_t radius, vec4_t plane)
97
-{
98
-    vec_t d;
99
-
100
-
101
-    d = (plane[0] * center[0] +
102
-            plane[1] * center[1] +
103
-            plane[2] * center[2] +
104
-            plane[3]);
105
-
106
-    if (d <= -radius)
107
-        return 0;
108
-
109
-    return d + radius;
110
-}
111
-
112
-
113
-vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane)
114
-{
115
-    vec3_t center;
116
-    vec_t d, radius;
117
-
118
-
119
-    helMidpoint3v(min, max, center);
120
-
121
-    d = (plane[0] * center[0] +
122
-            plane[1] * center[1] +
123
-            plane[2] * center[2] +
124
-            plane[3]);
125
-
126
-    radius = helDist3v(max, center);
127
-
128
-    if (d <= -radius)
129
-        return 0;
130
-
131
-    return d + radius;
132
-}
133
-
134
-
135
 vec_t helDist3v(vec3_t a, vec3_t b)
96
 vec_t helDist3v(vec3_t a, vec3_t b)
136
 {
97
 {
137
     return (sqrtf( ((b[0] - a[0]) * (b[0] - a[0])) +
98
     return (sqrtf( ((b[0] - a[0]) * (b[0] - a[0])) +

Loading…
Cancel
Save