From: RĂ©mi Verschelde Date: Sat, 11 Feb 2017 18:30:36 +0000 (+0100) Subject: clang-format: Apply to all headers X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=commitdiff_plain;h=6a8cb464330e92163c8feaf101b8b5837c973bba clang-format: Apply to all headers Apparently it had only been applied to .cpp files until now. Also added `AccessModifierOffset: -4` in the configuration. --- diff --git a/.clang-format b/.clang-format index 8d246a3..f5d41db 100644 --- a/.clang-format +++ b/.clang-format @@ -2,6 +2,7 @@ BasedOnStyle: Mozilla --- Language: Cpp +AccessModifierOffset: -4 AllowShortIfStatementsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None diff --git a/Source/Animation/Animation.hpp b/Source/Animation/Animation.hpp index 1a03f8e..f9e0482 100644 --- a/Source/Animation/Animation.hpp +++ b/Source/Animation/Animation.hpp @@ -24,29 +24,39 @@ along with Lugaru. If not, see . #include -enum anim_attack_type { - neutral, normalattack, reversed, reversal +enum anim_attack_type +{ + neutral, + normalattack, + reversed, + reversal }; -enum anim_height_type { - lowheight, middleheight, highheight +enum anim_height_type +{ + lowheight, + middleheight, + highheight }; -enum animation_type { +enum animation_type +{ #define DECLARE_ANIM(id, ...) id, #include "Animation.def" #undef DECLARE_ANIM animation_count }; -enum animation_bit_offsets { +enum animation_bit_offsets +{ #define DECLARE_ANIM_BIT(bit) o_##bit, #include "Animation.def" #undef DECLARE_ANIM_BIT animation_bit_count }; -enum animation_bits_def { +enum animation_bits_def +{ #define DECLARE_ANIM_BIT(bit) bit = 1 << o_##bit, #include "Animation.def" #undef DECLARE_ANIM_BIT @@ -60,7 +70,7 @@ static const int animation_bits[animation_count] = { struct AnimationFrameJointInfo { - XYZ position; + XYZ position; float twist; float twist2; bool onground; diff --git a/Source/Animation/Joint.hpp b/Source/Animation/Joint.hpp index b03c823..0e6c629 100644 --- a/Source/Animation/Joint.hpp +++ b/Source/Animation/Joint.hpp @@ -25,13 +25,28 @@ along with Lugaru. If not, see . #include -enum bodypart { - head, neck, - leftshoulder, leftelbow, leftwrist, lefthand, - rightshoulder, rightelbow, rightwrist, righthand, - abdomen, lefthip, righthip, groin, - leftknee, leftankle, leftfoot, - rightknee, rightankle, rightfoot +enum bodypart +{ + head, + neck, + leftshoulder, + leftelbow, + leftwrist, + lefthand, + rightshoulder, + rightelbow, + rightwrist, + righthand, + abdomen, + lefthip, + righthip, + groin, + leftknee, + leftankle, + leftfoot, + rightknee, + rightankle, + rightfoot }; class Joint diff --git a/Source/Animation/Muscle.hpp b/Source/Animation/Muscle.hpp index ffca26b..6499f0e 100644 --- a/Source/Animation/Muscle.hpp +++ b/Source/Animation/Muscle.hpp @@ -25,7 +25,12 @@ along with Lugaru. If not, see . #include -enum muscle_type {boneconnect, constraint, muscle}; +enum muscle_type +{ + boneconnect, + constraint, + muscle +}; class Muscle { diff --git a/Source/Animation/Skeleton.hpp b/Source/Animation/Skeleton.hpp index 0290960..908d2a8 100644 --- a/Source/Animation/Skeleton.hpp +++ b/Source/Animation/Skeleton.hpp @@ -24,9 +24,9 @@ along with Lugaru. If not, see . #include "Animation/Animation.hpp" #include "Animation/Joint.hpp" #include "Animation/Muscle.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Models.hpp" #include "Graphic/Sprite.hpp" +#include "Graphic/gamegl.hpp" #include "Math/XYZ.hpp" #include "Objects/Object.hpp" #include "Utils/binio.h" @@ -79,8 +79,8 @@ public: bool freefall; void FindForwards(); - float DoConstraints(XYZ *coords, float *scale); - void DoGravity(float *scale); + float DoConstraints(XYZ* coords, float* scale); + void DoGravity(float* scale); void FindRotationJoint(int which); void FindRotationJointSameTwist(int which); void FindRotationMuscle(int which, int animation); @@ -94,7 +94,6 @@ private: inline Joint& joint(int bodypart) { return joints[jointlabels[bodypart]]; } inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; } inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; } - }; #endif diff --git a/Source/Audio/Sounds.hpp b/Source/Audio/Sounds.hpp index 81192d5..e4acf4f 100644 --- a/Source/Audio/Sounds.hpp +++ b/Source/Audio/Sounds.hpp @@ -22,23 +22,24 @@ along with Lugaru. If not, see . #include "Math/XYZ.hpp" -enum sound_type { +enum sound_type +{ #define DECLARE_SOUND(id, filename) id, #include "Sounds.def" #undef DECLARE_SOUND sounds_count }; -extern struct OPENAL_SAMPLE *samp[sounds_count]; +extern struct OPENAL_SAMPLE* samp[sounds_count]; extern int channels[]; extern void loadAllSounds(); extern void addEnvSound(XYZ coords, float vol = 16, float life = .4); -extern void emit_sound_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f); +extern void emit_sound_at(int soundid, const XYZ& pos = XYZ(), float vol = 256.f); extern void emit_sound_np(int soundid, float vol = 256.f); -extern void emit_stream_at(int soundid, const XYZ &pos = XYZ(), float vol = 256.f); +extern void emit_stream_at(int soundid, const XYZ& pos = XYZ(), float vol = 256.f); extern void emit_stream_np(int soundid, float vol = 256.f); extern void resume_stream(int soundid); extern void pause_sound(int soundid); diff --git a/Source/Audio/openal_wrapper.hpp b/Source/Audio/openal_wrapper.hpp index e417597..379949f 100644 --- a/Source/Audio/openal_wrapper.hpp +++ b/Source/Audio/openal_wrapper.hpp @@ -25,11 +25,11 @@ along with Lugaru. If not, see . #include "Platform/Platform.hpp" #ifdef __APPLE__ - #include - #include +#include +#include #else - #include - #include +#include +#include #endif #include @@ -68,17 +68,16 @@ along with Lugaru. If not, see . #endif /* DLL_EXPORTS */ #endif /* if 0 */ +typedef struct OPENAL_SAMPLE OPENAL_SAMPLE; +typedef OPENAL_SAMPLE OPENAL_STREAM; +typedef struct OPENAL_DSPUNIT OPENAL_DSPUNIT; -typedef struct OPENAL_SAMPLE OPENAL_SAMPLE; -typedef OPENAL_SAMPLE OPENAL_STREAM; -typedef struct OPENAL_DSPUNIT OPENAL_DSPUNIT; - -#define OPENAL_LOOP_OFF 0x00000001 /* For non looping samples. */ -#define OPENAL_LOOP_NORMAL 0x00000002 /* For forward looping samples. */ -#define OPENAL_HW3D 0x00001000 /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */ -#define OPENAL_2D 0x00002000 /* Tells software (not hardware) based sample not to be included in 3d processing. */ -#define OPENAL_FREE -1 /* value to play on any free channel, or to allocate a sample in a free sample slot. */ -#define OPENAL_ALL -3 /* for a channel index , this flag will affect ALL channels available! Not supported by every function. */ +#define OPENAL_LOOP_OFF 0x00000001 /* For non looping samples. */ +#define OPENAL_LOOP_NORMAL 0x00000002 /* For forward looping samples. */ +#define OPENAL_HW3D 0x00001000 /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */ +#define OPENAL_2D 0x00002000 /* Tells software (not hardware) based sample not to be included in 3d processing. */ +#define OPENAL_FREE -1 /* value to play on any free channel, or to allocate a sample in a free sample slot. */ +#define OPENAL_ALL -3 /* for a channel index , this flag will affect ALL channels available! Not supported by every function. */ #ifdef __cplusplus extern "C" { @@ -87,22 +86,22 @@ extern "C" { #undef AL_API #define AL_API - AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz); - AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos); - AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos); - AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags); - AL_API void OPENAL_Close(); - AL_API OPENAL_SAMPLE *OPENAL_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length); - AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr); - AL_API signed char OPENAL_SetFrequency(int channel, bool slomo = false); - AL_API signed char OPENAL_SetVolume(int channel, int vol); - AL_API signed char OPENAL_SetPaused(int channel, signed char paused); - AL_API void OPENAL_SetSFXMasterVolume(int volume); - AL_API signed char OPENAL_StopSound(int channel); - AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM *stream, unsigned int mode); - AL_API void OPENAL_Update(); - void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); - void PlayStreamEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); +AL_API void OPENAL_3D_Listener_SetAttributes(const float* pos, const float* vel, float fx, float fy, float fz, float tx, float ty, float tz); +AL_API signed char OPENAL_3D_SetAttributes(int channel, const float* pos); +AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ& pos); +AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags); +AL_API void OPENAL_Close(); +AL_API OPENAL_SAMPLE* OPENAL_Sample_Load(int index, const char* name_or_data, unsigned int mode, int offset, int length); +AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE* sptr); +AL_API signed char OPENAL_SetFrequency(int channel, bool slomo = false); +AL_API signed char OPENAL_SetVolume(int channel, int vol); +AL_API signed char OPENAL_SetPaused(int channel, signed char paused); +AL_API void OPENAL_SetSFXMasterVolume(int volume); +AL_API signed char OPENAL_StopSound(int channel); +AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM* stream, unsigned int mode); +AL_API void OPENAL_Update(); +void PlaySoundEx(int chan, OPENAL_SAMPLE* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused); +void PlayStreamEx(int chan, OPENAL_SAMPLE* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused); #ifdef __cplusplus } diff --git a/Source/Devtools/ConsoleCmds.hpp b/Source/Devtools/ConsoleCmds.hpp index 3d0f718..b0045a9 100644 --- a/Source/Devtools/ConsoleCmds.hpp +++ b/Source/Devtools/ConsoleCmds.hpp @@ -18,20 +18,21 @@ You should have received a copy of the GNU General Public License along with Lugaru. If not, see . */ -typedef void (*console_handler)(const char *args); +typedef void (*console_handler)(const char* args); -#define DECLARE_COMMAND(cmd) void ch_##cmd(const char *args); +#define DECLARE_COMMAND(cmd) void ch_##cmd(const char* args); #include "ConsoleCmds.def" -#undef DECLARE_COMMAND +#undef DECLARE_COMMAND /* FIXME - This is only to get cmd_count, not very clean */ -enum console_command { +enum console_command +{ #define DECLARE_COMMAND(cmd) cmd_##cmd, #include "ConsoleCmds.def" #undef DECLARE_COMMAND cmd_count }; -extern const char *cmd_names[cmd_count]; +extern const char* cmd_names[cmd_count]; extern console_handler cmd_handlers[cmd_count]; diff --git a/Source/Environment/Lights.hpp b/Source/Environment/Lights.hpp index 42de553..776e5b1 100644 --- a/Source/Environment/Lights.hpp +++ b/Source/Environment/Lights.hpp @@ -33,7 +33,8 @@ public: int attach; XYZ location; inline void setColors(GLfloat cr, GLfloat cg, GLfloat cb, - GLfloat ar, GLfloat ag, GLfloat ab) { + GLfloat ar, GLfloat ag, GLfloat ab) + { color[0] = cr; color[1] = cg; color[2] = cb; diff --git a/Source/Environment/Skybox.hpp b/Source/Environment/Skybox.hpp index 5da5f43..e22341f 100644 --- a/Source/Environment/Skybox.hpp +++ b/Source/Environment/Skybox.hpp @@ -21,8 +21,8 @@ along with Lugaru. If not, see . #ifndef _SKYBOX_HPP_ #define _SKYBOX_HPP_ -#include "Graphic/gamegl.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Math/XYZ.hpp" #include "Math/XYZ.hpp" #include "Utils/ImageIO.hpp" @@ -33,7 +33,7 @@ public: Texture front, left, back, right, up, down; void load(const std::string& ffront, const std::string& fleft, const std::string& fback, - const std::string& fright, const std::string& fup, const std::string& fdown); + const std::string& fright, const std::string& fup, const std::string& fdown); void draw(); SkyBox() {} diff --git a/Source/Environment/Terrain.hpp b/Source/Environment/Terrain.hpp index f4876cf..cc1accc 100644 --- a/Source/Environment/Terrain.hpp +++ b/Source/Environment/Terrain.hpp @@ -23,16 +23,16 @@ along with Lugaru. If not, see . #include "Environment/Lights.hpp" #include "Graphic/Decal.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Math/Frustum.hpp" #include "Math/XYZ.hpp" #include "Utils/ImageIO.hpp" -#define max_terrain_size 256 -#define curr_terrain_size size -#define subdivision 64 -#define max_patch_elements (max_terrain_size/subdivision)*(max_terrain_size/subdivision)*54 +#define max_terrain_size 256 +#define curr_terrain_size size +#define subdivision 64 +#define max_patch_elements (max_terrain_size / subdivision) * (max_terrain_size / subdivision) * 54 #define allfirst 0 #define mixed 1 @@ -74,7 +74,7 @@ public: int numtris[subdivision][subdivision]; int textureness[subdivision][subdivision]; - GLfloat vArray[(max_patch_elements)*subdivision*subdivision]; + GLfloat vArray[(max_patch_elements)*subdivision * subdivision]; bool visible[subdivision][subdivision]; float avgypatch[subdivision][subdivision]; @@ -91,7 +91,7 @@ public: void DeleteDecal(int which); void MakeDecal(decal_type type, XYZ where, float size, float opacity, float rotation); void MakeDecalLock(decal_type type, XYZ where, int whichx, int whichy, float size, float opacity, float rotation); - int lineTerrain(XYZ p1, XYZ p2, XYZ *p); + int lineTerrain(XYZ p1, XYZ p2, XYZ* p); float getHeight(float pointx, float pointz); float getOpacity(float pointx, float pointz); XYZ getLighting(float pointx, float pointz); diff --git a/Source/Game.hpp b/Source/Game.hpp index c5a3632..51232cc 100644 --- a/Source/Game.hpp +++ b/Source/Game.hpp @@ -26,22 +26,22 @@ along with Lugaru. If not, see . #include "Environment/Lights.hpp" #include "Environment/Skybox.hpp" #include "Environment/Terrain.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Models.hpp" #include "Graphic/Sprite.hpp" #include "Graphic/Stereo.hpp" #include "Graphic/Text.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Objects/Object.hpp" #include "Objects/Person.hpp" #include "Objects/Weapons.hpp" #include "Thirdparty/optionparser.h" #include "User/Account.hpp" -#include "Utils/binio.h" #include "Utils/ImageIO.hpp" +#include "Utils/binio.h" -#include #include +#include #define NB_CAMPAIGN_MENU_ITEM 7 @@ -70,7 +70,7 @@ extern float deltah, deltav; extern int mousecoordh, mousecoordv; extern int oldmousecoordh, oldmousecoordv; extern float yaw, pitch; -extern SkyBox *skybox; +extern SkyBox* skybox; extern bool cameramode; extern bool firstLoadDone; @@ -97,8 +97,8 @@ extern int musictype; extern XYZ mapcenter; extern float mapradius; -extern Text *text; -extern Text *textmono; +extern Text* text; +extern Text* textmono; extern float fps; extern bool editorenabled; @@ -168,43 +168,69 @@ float pitchTo(XYZ start, XYZ end); float sq(float n); #ifndef __forceinline -# ifdef __GNUC__ -# define __forceinline inline __attribute__((always_inline)) -# endif +#ifdef __GNUC__ +#define __forceinline inline __attribute__((always_inline)) +#endif #endif static __forceinline void swap_gl_buffers(void) { - extern SDL_Window *sdlwindow; + extern SDL_Window* sdlwindow; SDL_GL_SwapWindow(sdlwindow); // try to limit this to 60fps, even if vsync fails. Uint32 now; static Uint32 frameticks = 0; const Uint32 endticks = (frameticks + 16); - while ((now = SDL_GetTicks()) < endticks) { /* spin. */ } + while ((now = SDL_GetTicks()) < endticks) { /* spin. */ + } frameticks = now; } -enum maptypes { - mapkilleveryone, mapgosomewhere, - mapkillsomeone, mapkillmost // These two are unused +enum maptypes +{ + mapkilleveryone, + mapgosomewhere, + mapkillsomeone, + mapkillmost // These two are unused }; -enum pathtypes {wpkeepwalking, wppause}; - -extern const char *pathtypenames[2]; +enum pathtypes +{ + wpkeepwalking, + wppause +}; -enum editortypes {typeactive, typesitting, typesittingwall, typesleeping, - typedead1, typedead2, typedead3, typedead4 - }; +extern const char* pathtypenames[2]; -extern const char *editortypenames[8]; +enum editortypes +{ + typeactive, + typesitting, + typesittingwall, + typesleeping, + typedead1, + typedead2, + typedead3, + typedead4 +}; -SDL_bool sdlEventProc(const SDL_Event &e); +extern const char* editortypenames[8]; +SDL_bool sdlEventProc(const SDL_Event& e); -enum optionIndex { UNKNOWN, VERSION, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS, DEVTOOLS }; +enum optionIndex +{ + UNKNOWN, + VERSION, + HELP, + FULLSCREEN, + NOMOUSEGRAB, + SOUND, + OPENALINFO, + SHOWRESOLUTIONS, + DEVTOOLS +}; /* Number of options + 1 */ const int commandLineOptionsNumber = 10; diff --git a/Source/Graphic/Decal.hpp b/Source/Graphic/Decal.hpp index d4c9941..2899491 100644 --- a/Source/Graphic/Decal.hpp +++ b/Source/Graphic/Decal.hpp @@ -26,7 +26,8 @@ class Model; #include "Math/XYZ.hpp" -enum decal_type { +enum decal_type +{ shadowdecal = 0, footprintdecal = 1, blooddecal = 2, diff --git a/Source/Graphic/Models.hpp b/Source/Graphic/Models.hpp index 58d8649..e6dbb50 100644 --- a/Source/Graphic/Models.hpp +++ b/Source/Graphic/Models.hpp @@ -22,8 +22,8 @@ along with Lugaru. If not, see . #define _MODELS_HPP_ #include "Environment/Terrain.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Math/XYZ.hpp" #include "Utils/binio.h" @@ -35,9 +35,10 @@ along with Lugaru. If not, see . // // Textures List // -typedef struct { +typedef struct +{ long xsz, ysz; - GLubyte *txt; + GLubyte* txt; } ModelTexture; // @@ -96,15 +97,15 @@ public: Model(); ~Model(); void DeleteDecal(int which); - void MakeDecal(decal_type atype, XYZ *where, float *size, float *opacity, float *rotation); + void MakeDecal(decal_type atype, XYZ* where, float* size, float* opacity, float* rotation); void MakeDecal(decal_type atype, XYZ where, float size, float opacity, float rotation); const XYZ& getTriangleVertex(unsigned triangleId, unsigned vertexId) const; void drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture); - int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate); - int SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate); - int LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate); - int LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate); - int LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *move, float *rotate); + int SphereCheck(XYZ* p1, float radius, XYZ* p, XYZ* move, float* rotate); + int SphereCheckPossible(XYZ* p1, float radius, XYZ* move, float* rotate); + int LineCheck(XYZ* p1, XYZ* p2, XYZ* p, XYZ* move, float* rotate); + int LineCheckPossible(XYZ* p1, XYZ* p2, XYZ* p, XYZ* move, float* rotate); + int LineCheckSlidePossible(XYZ* p1, XYZ* p2, XYZ* move, float* rotate); void UpdateVertexArray(); void UpdateVertexArrayNoTex(); void UpdateVertexArrayNoTexNoNorm(); diff --git a/Source/Graphic/Sprite.hpp b/Source/Graphic/Sprite.hpp index 5e88e96..7ac5cfd 100644 --- a/Source/Graphic/Sprite.hpp +++ b/Source/Graphic/Sprite.hpp @@ -23,8 +23,8 @@ along with Lugaru. If not, see . #include "Environment/Lights.hpp" #include "Environment/Terrain.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Math/Frustum.hpp" #include "Math/XYZ.hpp" #include "Objects/Object.hpp" @@ -34,7 +34,8 @@ along with Lugaru. If not, see . #define max_sprites 20000 -enum { +enum +{ cloudsprite = 0, bloodsprite, flamesprite, @@ -74,16 +75,20 @@ public: static void DeleteSprite(int which); static void MakeSprite(int atype, XYZ where, XYZ avelocity, float red, float green, float blue, float asize, float aopacity); static void Draw(); - static void deleteSprites() { + static void deleteSprites() + { sprites.clear(); } - static void setLastSpriteSpecial(int s) { + static void setLastSpriteSpecial(int s) + { sprites.back()->special = s; } - static void setLastSpriteSpeed(int s) { + static void setLastSpriteSpeed(int s) + { sprites.back()->speed = s; } - static void setLastSpriteAlivetime(float al) { + static void setLastSpriteAlivetime(float al) + { sprites.back()->alivetime = al; } diff --git a/Source/Graphic/Stereo.hpp b/Source/Graphic/Stereo.hpp index 2de2db6..a6c97c2 100644 --- a/Source/Graphic/Stereo.hpp +++ b/Source/Graphic/Stereo.hpp @@ -23,29 +23,30 @@ along with Lugaru. If not, see . #include -enum StereoMode { +enum StereoMode +{ stereoNone, stereoAnaglyph, /* red/cyan */ stereoHorizontalInterlaced, /* some 3D monitors */ stereoVerticalInterlaced, - stereoHorizontalSplit, /* cross-eyed view */ + stereoHorizontalSplit, /* cross-eyed view */ stereoVerticalSplit, - stereoOpenGL, /* Whatever OpenGL does, if supported */ - stereoCount /* must be last element */ + stereoOpenGL, /* Whatever OpenGL does, if supported */ + stereoCount /* must be last element */ }; - -enum StereoSide { +enum StereoSide +{ // Code multiplies by StereoSide to calculate camera offsets - stereoLeft = -1, + stereoLeft = -1, stereoCenter = 0, - stereoRight = 1 + stereoRight = 1 }; extern StereoMode stereomode; extern StereoMode newstereomode; extern float stereoseparation; -extern bool stereoreverse; +extern bool stereoreverse; bool CanInitStereo(StereoMode mode); void InitStereo(StereoMode mode); diff --git a/Source/Graphic/Text.hpp b/Source/Graphic/Text.hpp index efa6a4e..494ee91 100644 --- a/Source/Graphic/Text.hpp +++ b/Source/Graphic/Text.hpp @@ -21,8 +21,8 @@ along with Lugaru. If not, see . #ifndef _TEXT_HPP_ #define _TEXT_HPP_ -#include "Graphic/gamegl.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Math/XYZ.hpp" #include "Utils/ImageIO.hpp" diff --git a/Source/Graphic/Texture.hpp b/Source/Graphic/Texture.hpp index 4688447..b47ab1c 100644 --- a/Source/Graphic/Texture.hpp +++ b/Source/Graphic/Texture.hpp @@ -24,9 +24,9 @@ along with Lugaru. If not, see . #include "Graphic/gamegl.hpp" #include +#include #include #include -#include class TextureRes { @@ -49,15 +49,19 @@ public: /* Make sure TextureRes never gets copied */ TextureRes(TextureRes const& other) = delete; - TextureRes & operator=(TextureRes const& other) = delete; + TextureRes& operator=(TextureRes const& other) = delete; }; class Texture { private: std::shared_ptr tex; + public: - inline Texture(): tex(nullptr) {} + inline Texture() + : tex(nullptr) + { + } void load(const string& filename, bool hasMipmap); void load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep); void bind(); diff --git a/Source/Graphic/gamegl.hpp b/Source/Graphic/gamegl.hpp index 706c2b9..b824a43 100644 --- a/Source/Graphic/gamegl.hpp +++ b/Source/Graphic/gamegl.hpp @@ -31,29 +31,27 @@ along with Lugaru. If not, see . #include #ifdef WIN32 - #define WIN32_LEAN_AND_MEAN - #define Polygon WinPolygon - #include - #undef Polygon +#define WIN32_LEAN_AND_MEAN +#define Polygon WinPolygon +#include +#undef Polygon #endif #define GL_GLEXT_PROTOTYPES 1 #ifdef __APPLE__ - #include - #include - #include +#include +#include +#include #else - #include - #include - #include +#include +#include +#include #endif using namespace std; /* !!! FIXME: until we replace logger better. --ryan. */ #define LOGFUNC -void LOG(const std::string &fmt, ...); +void LOG(const std::string& fmt, ...); #endif - - diff --git a/Source/Level/Awards.hpp b/Source/Level/Awards.hpp index 5841e26..dbb8770 100644 --- a/Source/Level/Awards.hpp +++ b/Source/Level/Awards.hpp @@ -20,14 +20,15 @@ along with Lugaru. If not, see . #ifndef _AWARDS_HPP_ #define _AWARDS_HPP_ -enum bonus_types { +enum bonus_types +{ #define DECLARE_BONUS(id, ...) id, #include "Bonuses.def" #undef DECLARE_BONUS bonus_count }; -extern const char *bonus_names[bonus_count]; +extern const char* bonus_names[bonus_count]; extern int bonus; extern int bonusvalue; @@ -38,16 +39,17 @@ extern float bonusnum[100]; extern void award_bonus(int playerid, int bonusid, int alt_value = 0); -enum award_types { +enum award_types +{ #define DECLARE_AWARD(id, name) id, #include "Awards.def" #undef DECLARE_AWARD award_count }; -extern const char *award_names[award_count]; +extern const char* award_names[award_count]; -extern int award_awards(int *); +extern int award_awards(int*); extern float damagetaken; extern int numfalls; @@ -67,4 +69,3 @@ extern int numreversals; extern int numattacks; extern int maxalarmed; #endif - diff --git a/Source/Level/Campaign.hpp b/Source/Level/Campaign.hpp index 514a686..0a3d734 100644 --- a/Source/Level/Campaign.hpp +++ b/Source/Level/Campaign.hpp @@ -35,9 +35,11 @@ class CampaignLevel { private: int width; - struct Position { + struct Position + { int x, y; }; + public: std::string mapname; std::string description; @@ -57,8 +59,9 @@ public: int getEndY(); XYZ getCenter(); int getWidth(); - std::istream& operator<< (std::istream& is); - friend std::istream& operator>> (std::istream& is, CampaignLevel& cl) { + std::istream& operator<<(std::istream& is); + friend std::istream& operator>>(std::istream& is, CampaignLevel& cl) + { return cl << is; } }; diff --git a/Source/Level/Dialog.hpp b/Source/Level/Dialog.hpp index e417aea..52058c7 100644 --- a/Source/Level/Dialog.hpp +++ b/Source/Level/Dialog.hpp @@ -30,7 +30,7 @@ class DialogScene { public: DialogScene(FILE* tfile); - DialogScene(ifstream &ipstream); + DialogScene(ifstream& ipstream); void save(FILE* tfile); int location; diff --git a/Source/Level/Hotspot.hpp b/Source/Level/Hotspot.hpp index 1ca0bbe..210ba91 100644 --- a/Source/Level/Hotspot.hpp +++ b/Source/Level/Hotspot.hpp @@ -38,7 +38,7 @@ public: XYZ position; int type; float size; - char text[256] = {0}; + char text[256] = { 0 }; }; #endif diff --git a/Source/Math/XYZ.hpp b/Source/Math/XYZ.hpp index c26f8e8..f664410 100644 --- a/Source/Math/XYZ.hpp +++ b/Source/Math/XYZ.hpp @@ -31,7 +31,12 @@ public: float x; float y; float z; - XYZ() : x(0.0f), y(0.0f), z(0.0f) {} + XYZ() + : x(0.0f) + , y(0.0f) + , z(0.0f) + { + } inline XYZ operator+(XYZ add); inline XYZ operator-(XYZ add); inline XYZ operator*(float add); @@ -46,38 +51,37 @@ public: inline bool operator==(XYZ add); }; -inline void CrossProduct(XYZ *P, XYZ *Q, XYZ *V); -inline void CrossProduct(XYZ P, XYZ Q, XYZ *V); -inline void Normalise(XYZ *vectory); +inline void CrossProduct(XYZ* P, XYZ* Q, XYZ* V); +inline void CrossProduct(XYZ P, XYZ Q, XYZ* V); +inline void Normalise(XYZ* vectory); inline float normaldotproduct(XYZ point1, XYZ point2); -inline float fast_sqrt (register float arg); -bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3); -bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p); -float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p); -float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ *p); -float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *n, XYZ *p); -float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *p); -inline void ReflectVector(XYZ *vel, const XYZ *n); -inline void ReflectVector(XYZ *vel, const XYZ &n); +inline float fast_sqrt(register float arg); +bool PointInTriangle(XYZ* p, XYZ normal, XYZ* p1, XYZ* p2, XYZ* p3); +bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ* p); +float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ* p); +float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ* p); +float LineFacetd(XYZ* p1, XYZ* p2, XYZ* pa, XYZ* pb, XYZ* pc, XYZ* n, XYZ* p); +float LineFacetd(XYZ* p1, XYZ* p2, XYZ* pa, XYZ* pb, XYZ* pc, XYZ* p); +inline void ReflectVector(XYZ* vel, const XYZ* n); +inline void ReflectVector(XYZ* vel, const XYZ& n); inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang); inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang); -inline float findDistance(XYZ *point1, XYZ *point2); -inline float findLength(XYZ *point1); -inline float findLengthfast(XYZ *point1); -inline float distsq(XYZ *point1, XYZ *point2); +inline float findDistance(XYZ* point1, XYZ* point2); +inline float findLength(XYZ* point1); +inline float findLengthfast(XYZ* point1); +inline float distsq(XYZ* point1, XYZ* point2); inline float distsq(XYZ point1, XYZ point2); -inline float distsqflat(XYZ *point1, XYZ *point2); -inline float dotproduct(const XYZ *point1, const XYZ *point2); -bool sphere_line_intersection ( - float x1, float y1 , float z1, - float x2, float y2 , float z2, - float x3, float y3 , float z3, float r ); -bool sphere_line_intersection ( - XYZ *p1, XYZ *p2, XYZ *p3, float *r ); -inline bool DistancePointLine( XYZ *Point, XYZ *LineStart, XYZ *LineEnd, float *Distance, XYZ *Intersection ); - - -inline void Normalise(XYZ *vectory) +inline float distsqflat(XYZ* point1, XYZ* point2); +inline float dotproduct(const XYZ* point1, const XYZ* point2); +bool sphere_line_intersection( + float x1, float y1, float z1, + float x2, float y2, float z2, + float x3, float y3, float z3, float r); +bool sphere_line_intersection( + XYZ* p1, XYZ* p2, XYZ* p3, float* r); +inline bool DistancePointLine(XYZ* Point, XYZ* LineStart, XYZ* LineEnd, float* Distance, XYZ* Intersection); + +inline void Normalise(XYZ* vectory) { static float d; d = fast_sqrt(vectory->x * vectory->x + vectory->y * vectory->y + vectory->z * vectory->z); @@ -185,21 +189,21 @@ inline bool XYZ::operator==(XYZ add) return 0; } -inline void CrossProduct(XYZ *P, XYZ *Q, XYZ *V) +inline void CrossProduct(XYZ* P, XYZ* Q, XYZ* V) { V->x = P->y * Q->z - P->z * Q->y; V->y = P->z * Q->x - P->x * Q->z; V->z = P->x * Q->y - P->y * Q->x; } -inline void CrossProduct(XYZ P, XYZ Q, XYZ *V) +inline void CrossProduct(XYZ P, XYZ Q, XYZ* V) { V->x = P.y * Q.z - P.z * Q.y; V->y = P.z * Q.x - P.x * Q.z; V->z = P.x * Q.y - P.y * Q.x; } -inline float fast_sqrt (register float arg) +inline float fast_sqrt(register float arg) { return sqrtf(arg); } @@ -213,12 +217,12 @@ inline float normaldotproduct(XYZ point1, XYZ point2) return returnvalue; } -inline void ReflectVector(XYZ *vel, const XYZ *n) +inline void ReflectVector(XYZ* vel, const XYZ* n) { ReflectVector(vel, *n); } -inline void ReflectVector(XYZ *vel, const XYZ &n) +inline void ReflectVector(XYZ* vel, const XYZ& n) { static XYZ vn; static XYZ vt; @@ -238,42 +242,41 @@ inline void ReflectVector(XYZ *vel, const XYZ &n) vel->z = vt.z - vn.z; } -inline float dotproduct(const XYZ *point1, const XYZ *point2) +inline float dotproduct(const XYZ* point1, const XYZ* point2) { static GLfloat returnvalue; returnvalue = (point1->x * point2->x + point1->y * point2->y + point1->z * point2->z); return returnvalue; } -inline float findDistance(XYZ *point1, XYZ *point2) +inline float findDistance(XYZ* point1, XYZ* point2) { - return(fast_sqrt((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z))); + return (fast_sqrt((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z))); } -inline float findLength(XYZ *point1) +inline float findLength(XYZ* point1) { - return(fast_sqrt((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z))); + return (fast_sqrt((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z))); } - -inline float findLengthfast(XYZ *point1) +inline float findLengthfast(XYZ* point1) { - return((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z)); + return ((point1->x) * (point1->x) + (point1->y) * (point1->y) + (point1->z) * (point1->z)); } -inline float distsq(XYZ *point1, XYZ *point2) +inline float distsq(XYZ* point1, XYZ* point2) { - return((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z)); + return ((point1->x - point2->x) * (point1->x - point2->x) + (point1->y - point2->y) * (point1->y - point2->y) + (point1->z - point2->z) * (point1->z - point2->z)); } inline float distsq(XYZ point1, XYZ point2) { - return((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y) + (point1.z - point2.z) * (point1.z - point2.z)); + return ((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y) + (point1.z - point2.z) * (point1.z - point2.z)); } -inline float distsqflat(XYZ *point1, XYZ *point2) +inline float distsqflat(XYZ* point1, XYZ* point2) { - return((point1->x - point2->x) * (point1->x - point2->x) + (point1->z - point2->z) * (point1->z - point2->z)); + return ((point1->x - point2->x) * (point1->x - point2->x) + (point1->z - point2->z) * (point1->z - point2->z)); } inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang) @@ -292,7 +295,6 @@ inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang) zang /= 360; } - if (yang) { newpoint.z = thePoint.z * cosf(yang) - thePoint.x * sinf(yang); newpoint.x = thePoint.z * sinf(yang) + thePoint.x * cosf(yang); @@ -317,15 +319,15 @@ inline XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang) return thePoint; } -inline float square( float f ) +inline float square(float f) { - return (f * f) ; + return (f * f); } -inline bool sphere_line_intersection ( - float x1, float y1 , float z1, - float x2, float y2 , float z2, - float x3, float y3 , float z3, float r ) +inline bool sphere_line_intersection( + float x1, float y1, float z1, + float x2, float y2, float z2, + float x3, float y3, float z3, float r) { // x1,y1,z1 P1 coordinates (point of line) @@ -337,33 +339,37 @@ inline bool sphere_line_intersection ( // the number of intersection point, followed by coordinate pairs. //~ static float x , y , z; - static float a, b, c, /*mu,*/ i ; - - if (x1 > x3 + r && x2 > x3 + r) return(0); - if (x1 < x3 - r && x2 < x3 - r) return(0); - if (y1 > y3 + r && y2 > y3 + r) return(0); - if (y1 < y3 - r && y2 < y3 - r) return(0); - if (z1 > z3 + r && z2 > z3 + r) return(0); - if (z1 < z3 - r && z2 < z3 - r) return(0); - a = square(x2 - x1) + square(y2 - y1) + square(z2 - z1); - b = 2 * ( (x2 - x1) * (x1 - x3) - + (y2 - y1) * (y1 - y3) - + (z2 - z1) * (z1 - z3) ) ; - c = square(x3) + square(y3) + - square(z3) + square(x1) + - square(y1) + square(z1) - - 2 * ( x3 * x1 + y3 * y1 + z3 * z1 ) - square(r) ; - i = b * b - 4 * a * c ; - - if ( i < 0.0 ) { + static float a, b, c, /*mu,*/ i; + + if (x1 > x3 + r && x2 > x3 + r) + return (0); + if (x1 < x3 - r && x2 < x3 - r) + return (0); + if (y1 > y3 + r && y2 > y3 + r) + return (0); + if (y1 < y3 - r && y2 < y3 - r) + return (0); + if (z1 > z3 + r && z2 > z3 + r) + return (0); + if (z1 < z3 - r && z2 < z3 - r) + return (0); + a = square(x2 - x1) + square(y2 - y1) + square(z2 - z1); + b = 2 * ((x2 - x1) * (x1 - x3) + (y2 - y1) * (y1 - y3) + (z2 - z1) * (z1 - z3)); + c = square(x3) + square(y3) + + square(z3) + square(x1) + + square(y1) + square(z1) - + 2 * (x3 * x1 + y3 * y1 + z3 * z1) - square(r); + i = b * b - 4 * a * c; + + if (i < 0.0) { // no intersection - return(0); + return (0); } - return(1); + return (1); } -inline bool sphere_line_intersection ( - XYZ *p1, XYZ *p2, XYZ *p3, float *r ) +inline bool sphere_line_intersection( + XYZ* p1, XYZ* p2, XYZ* p3, float* r) { // x1,p1->y,p1->z P1 coordinates (point of line) @@ -375,29 +381,33 @@ inline bool sphere_line_intersection ( // the number of intersection point, followed by coordinate pairs. //~ static float x , y , z; - static float a, b, c, /*mu,*/ i ; - - if (p1->x > p3->x + *r && p2->x > p3->x + *r) return(0); - if (p1->x < p3->x - *r && p2->x < p3->x - *r) return(0); - if (p1->y > p3->y + *r && p2->y > p3->y + *r) return(0); - if (p1->y < p3->y - *r && p2->y < p3->y - *r) return(0); - if (p1->z > p3->z + *r && p2->z > p3->z + *r) return(0); - if (p1->z < p3->z - *r && p2->z < p3->z - *r) return(0); - a = square(p2->x - p1->x) + square(p2->y - p1->y) + square(p2->z - p1->z); - b = 2 * ( (p2->x - p1->x) * (p1->x - p3->x) - + (p2->y - p1->y) * (p1->y - p3->y) - + (p2->z - p1->z) * (p1->z - p3->z) ) ; - c = square(p3->x) + square(p3->y) + - square(p3->z) + square(p1->x) + - square(p1->y) + square(p1->z) - - 2 * ( p3->x * p1->x + p3->y * p1->y + p3->z * p1->z ) - square(*r) ; - i = b * b - 4 * a * c ; - - if ( i < 0.0 ) { + static float a, b, c, /*mu,*/ i; + + if (p1->x > p3->x + *r && p2->x > p3->x + *r) + return (0); + if (p1->x < p3->x - *r && p2->x < p3->x - *r) + return (0); + if (p1->y > p3->y + *r && p2->y > p3->y + *r) + return (0); + if (p1->y < p3->y - *r && p2->y < p3->y - *r) + return (0); + if (p1->z > p3->z + *r && p2->z > p3->z + *r) + return (0); + if (p1->z < p3->z - *r && p2->z < p3->z - *r) + return (0); + a = square(p2->x - p1->x) + square(p2->y - p1->y) + square(p2->z - p1->z); + b = 2 * ((p2->x - p1->x) * (p1->x - p3->x) + (p2->y - p1->y) * (p1->y - p3->y) + (p2->z - p1->z) * (p1->z - p3->z)); + c = square(p3->x) + square(p3->y) + + square(p3->z) + square(p1->x) + + square(p1->y) + square(p1->z) - + 2 * (p3->x * p1->x + p3->y * p1->y + p3->z * p1->z) - square(*r); + i = b * b - 4 * a * c; + + if (i < 0.0) { // no intersection - return(0); + return (0); } - return(1); + return (1); } inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang) @@ -429,29 +439,28 @@ inline XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang) } return oldpoint; - } -inline bool DistancePointLine( XYZ *Point, XYZ *LineStart, XYZ *LineEnd, float *Distance, XYZ *Intersection ) +inline bool DistancePointLine(XYZ* Point, XYZ* LineStart, XYZ* LineEnd, float* Distance, XYZ* Intersection) { float LineMag; float U; - LineMag = findDistance( LineEnd, LineStart ); + LineMag = findDistance(LineEnd, LineStart); - U = ( ( ( Point->x - LineStart->x ) * ( LineEnd->x - LineStart->x ) ) + - ( ( Point->y - LineStart->y ) * ( LineEnd->y - LineStart->y ) ) + - ( ( Point->z - LineStart->z ) * ( LineEnd->z - LineStart->z ) ) ) / - ( LineMag * LineMag ); + U = (((Point->x - LineStart->x) * (LineEnd->x - LineStart->x)) + + ((Point->y - LineStart->y) * (LineEnd->y - LineStart->y)) + + ((Point->z - LineStart->z) * (LineEnd->z - LineStart->z))) / + (LineMag * LineMag); - if ( U < 0.0f || U > 1.0f ) - return 0; // closest point does not fall within the line segment + if (U < 0.0f || U > 1.0f) + return 0; // closest point does not fall within the line segment - Intersection->x = LineStart->x + U * ( LineEnd->x - LineStart->x ); - Intersection->y = LineStart->y + U * ( LineEnd->y - LineStart->y ); - Intersection->z = LineStart->z + U * ( LineEnd->z - LineStart->z ); + Intersection->x = LineStart->x + U * (LineEnd->x - LineStart->x); + Intersection->y = LineStart->y + U * (LineEnd->y - LineStart->y); + Intersection->z = LineStart->z + U * (LineEnd->z - LineStart->z); - *Distance = findDistance( Point, Intersection ); + *Distance = findDistance(Point, Intersection); return 1; } diff --git a/Source/Menu/Menu.hpp b/Source/Menu/Menu.hpp index 0ed6ed9..713a59c 100644 --- a/Source/Menu/Menu.hpp +++ b/Source/Menu/Menu.hpp @@ -23,8 +23,19 @@ along with Lugaru. If not, see . #include "Game.hpp" -struct MenuItem { - enum MenuItemType {NONE, LABEL, BUTTON, IMAGE, IMAGEBUTTON, MAPMARKER, MAPLINE, MAPLABEL} type; +struct MenuItem +{ + enum MenuItemType + { + NONE, + LABEL, + BUTTON, + IMAGE, + IMAGEBUTTON, + MAPMARKER, + MAPLINE, + MAPLABEL + } type; int id; string text; Texture texture; @@ -36,8 +47,8 @@ struct MenuItem { float lineendsize; MenuItem(MenuItemType _type, int _id, const string& _text, Texture _texture, - int _x, int _y, int _w, int _h, float _r, float _g, float _b, - float _linestartsize = 1, float _lineendsize = 1); + int _x, int _y, int _w, int _h, float _r, float _g, float _b, + float _linestartsize = 1, float _lineendsize = 1); }; class Menu diff --git a/Source/Objects/Object.hpp b/Source/Objects/Object.hpp index d8ce273..61ba4ab 100644 --- a/Source/Objects/Object.hpp +++ b/Source/Objects/Object.hpp @@ -23,10 +23,10 @@ along with Lugaru. If not, see . #include "Environment/Lights.hpp" #include "Environment/Terrain.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Models.hpp" #include "Graphic/Sprite.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Math/Frustum.hpp" #include "Math/XYZ.hpp" #include "Utils/ImageIO.hpp" @@ -39,7 +39,8 @@ along with Lugaru. If not, see . #define max_objects 300 -enum object_type { +enum object_type +{ boxtype = 0, weirdtype = 1, spiketype = 2, @@ -55,7 +56,6 @@ enum object_type { firetype = 13 }; - class Object { public: @@ -94,7 +94,7 @@ public: static void ComputeRadius(); static void AddObjectsToTerrain(); static void LoadObjectsFromFile(FILE* tfile, bool skip); - static void SphereCheckPossible(XYZ *p1, float radius); + static void SphereCheckPossible(XYZ* p1, float radius); static void DeleteObject(int which); static void MakeObject(int atype, XYZ where, float ayaw, float apitch, float ascale); static void Draw(); @@ -114,4 +114,3 @@ private: }; #endif - diff --git a/Source/Objects/Person.hpp b/Source/Objects/Person.hpp index 0734eaa..2ead16e 100644 --- a/Source/Objects/Person.hpp +++ b/Source/Objects/Person.hpp @@ -24,9 +24,9 @@ along with Lugaru. If not, see . #include "Animation/Animation.hpp" #include "Animation/Skeleton.hpp" #include "Environment/Terrain.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Models.hpp" #include "Graphic/Sprite.hpp" +#include "Graphic/gamegl.hpp" #include "Math/XYZ.hpp" #include "Objects/PersonType.hpp" #include "Objects/Weapons.hpp" @@ -44,10 +44,12 @@ along with Lugaru. If not, see . #define getweapontype 7 #define pathfindtype 8 -struct InvalidPersonException : public exception { - const char * what () const throw () { - return "Invalid weapon number"; - } +struct InvalidPersonException : public exception +{ + const char* what() const throw() + { + return "Invalid weapon number"; + } }; class Person : public enable_shared_from_this @@ -183,7 +185,6 @@ public: float jumpkeydowntime; bool freefall; - float turnspeed; int aitype; @@ -375,13 +376,14 @@ public: void Reverse(); void DoDamage(float howmuch); void DoHead(); - void DoMipmaps() { + void DoMipmaps() + { skeleton.drawmodel.textureptr.bind(); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]); } - int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model); + int SphereCheck(XYZ* p1, float radius, XYZ* p, XYZ* move, float* rotate, Model* model); int DrawSkeleton(); void Puff(int whichlabel); void FootLand(bodypart whichfoot, float opacity); @@ -390,7 +392,7 @@ public: void DoAnimations(); void RagDoll(bool checkcollision); - void takeWeapon (int weaponId); + void takeWeapon(int weaponId); bool addClothes(const int& clothesId); void addClothes(); diff --git a/Source/Objects/Weapons.hpp b/Source/Objects/Weapons.hpp index 90b9567..e12b11e 100644 --- a/Source/Objects/Weapons.hpp +++ b/Source/Objects/Weapons.hpp @@ -23,10 +23,10 @@ along with Lugaru. If not, see . #include "Animation/Skeleton.hpp" #include "Environment/Terrain.hpp" -#include "Graphic/gamegl.hpp" #include "Graphic/Models.hpp" #include "Graphic/Sprite.hpp" #include "Graphic/Texture.hpp" +#include "Graphic/gamegl.hpp" #include "Math/XYZ.hpp" #include "Objects/Person.hpp" @@ -46,7 +46,8 @@ public: void draw(); void doStuff(int); - int getType() { + int getType() + { return type; } void setType(int); diff --git a/Source/Platform/Platform.hpp b/Source/Platform/Platform.hpp index 7b03008..4004cef 100644 --- a/Source/Platform/Platform.hpp +++ b/Source/Platform/Platform.hpp @@ -28,11 +28,11 @@ along with Lugaru. If not, see . #include #if defined(WIN32) && !defined(strcasecmp) -#define strcasecmp(a,b) stricmp(a,b) +#define strcasecmp(a, b) stricmp(a, b) #endif - -struct Point { +struct Point +{ short v; short h; }; @@ -40,9 +40,10 @@ struct Point { typedef signed char SInt8; typedef unsigned int UInt32; -typedef struct AbsoluteTime { - unsigned long hi; - unsigned long lo; +typedef struct AbsoluteTime +{ + unsigned long hi; + unsigned long lo; } AbsoluteTime; /* Returns time since the app started, not system start. */ @@ -50,27 +51,27 @@ AbsoluteTime UpTime(); typedef long Duration; -enum { +enum +{ durationMicrosecond = -1, durationMillisecond = 1, - durationSecond = 1000, - durationMinute = 1000 * 60, - durationHour = 1000 * 60 * 60, - durationDay = 1000 * 60 * 60 * 24, - durationForever = 0x7FFFFFFF, - durationImmediate = 0, + durationSecond = 1000, + durationMinute = 1000 * 60, + durationHour = 1000 * 60 * 60, + durationDay = 1000 * 60 * 60 * 24, + durationForever = 0x7FFFFFFF, + durationImmediate = 0, }; Duration AbsoluteDeltaToDuration(AbsoluteTime& a, AbsoluteTime& b); - /* Workaround missing math stuff on MSVC * FIXME: Check that it is still necessary nowadays. */ #ifdef _MSC_VER -inline bool isnormal( double x) +inline bool isnormal(double x) { - int ret = _fpclass( x); + int ret = _fpclass(x); return (ret == _FPCLASS_NN || ret == _FPCLASS_PN); } diff --git a/Source/Platform/PlatformUnix.cpp b/Source/Platform/PlatformUnix.cpp index 9635753..ba164a5 100644 --- a/Source/Platform/PlatformUnix.cpp +++ b/Source/Platform/PlatformUnix.cpp @@ -53,7 +53,7 @@ static int QueryPerformanceCounter(LARGE_INTEGER* liptr) class AppTime { - public: +public: AppTime() { counterRate = 1; diff --git a/Source/Platform/PlatformWindows.cpp b/Source/Platform/PlatformWindows.cpp index 5c413f8..71eff10 100644 --- a/Source/Platform/PlatformWindows.cpp +++ b/Source/Platform/PlatformWindows.cpp @@ -29,7 +29,7 @@ along with Lugaru. If not, see . class AppTime { - public: +public: AppTime() { counterRate = 1; diff --git a/Source/User/Account.hpp b/Source/User/Account.hpp index 0b52531..4146946 100644 --- a/Source/User/Account.hpp +++ b/Source/User/Account.hpp @@ -26,13 +26,15 @@ along with Lugaru. If not, see . #include #include -struct CampaignProgress { +struct CampaignProgress +{ int highscore; float fasttime; int score; float time; std::vector choices; - CampaignProgress() { + CampaignProgress() + { highscore = 0; fasttime = 0; score = 0; @@ -63,52 +65,66 @@ public: // getter and setters int getDifficulty(); - void setDifficulty(int i) { + void setDifficulty(int i) + { difficulty = i; }; - const std::string& getName() { + const std::string& getName() + { return name; }; - int getCampaignScore() { + int getCampaignScore() + { return campaignProgress[currentCampaign].score; }; - int getCampaignChoicesMade() { + int getCampaignChoicesMade() + { return campaignProgress[currentCampaign].choices.size(); }; - int getCampaignChoice(int i) { + int getCampaignChoice(int i) + { return campaignProgress[currentCampaign].choices[i]; }; - void setCampaignScore(int s) { + void setCampaignScore(int s) + { campaignProgress[currentCampaign].score = s; if (s > campaignProgress[currentCampaign].highscore) { campaignProgress[currentCampaign].highscore = s; } }; - void setCampaignFinalTime(float t) { + void setCampaignFinalTime(float t) + { campaignProgress[currentCampaign].time = t; if ((t < campaignProgress[currentCampaign].fasttime) || ((campaignProgress[currentCampaign].fasttime == 0) && (t != 0))) { campaignProgress[currentCampaign].fasttime = t; } }; - float getCampaignFasttime() { + float getCampaignFasttime() + { return campaignProgress[currentCampaign].fasttime; }; - void resetFasttime() { + void resetFasttime() + { campaignProgress[currentCampaign].fasttime = 0; }; - int getCampaignHighScore() { + int getCampaignHighScore() + { return campaignProgress[currentCampaign].highscore; }; - int getHighScore(int i) { + int getHighScore(int i) + { return highscore[i]; }; - float getFastTime(int i) { + float getFastTime(int i) + { return fasttime[i]; }; - int getProgress() { + int getProgress() + { return progress; }; - std::string getCurrentCampaign() { + std::string getCurrentCampaign() + { return currentCampaign; }; void setCurrentCampaign(const std::string& name); diff --git a/Source/User/Settings.hpp b/Source/User/Settings.hpp index aeac90d..e07d895 100644 --- a/Source/User/Settings.hpp +++ b/Source/User/Settings.hpp @@ -56,5 +56,4 @@ void DefaultSettings(); void SaveSettings(); bool LoadSettings(); - #endif diff --git a/Source/Utils/Folders.hpp b/Source/Utils/Folders.hpp index c50ab6d..c2c8587 100644 --- a/Source/Utils/Folders.hpp +++ b/Source/Utils/Folders.hpp @@ -27,15 +27,17 @@ along with Lugaru. If not, see . #define DATA_DIR "Data" #endif -struct FileNotFoundException: public std::exception +struct FileNotFoundException : public std::exception { std::string errorText; - FileNotFoundException (const std::string& filename) - : errorText(filename + " could not be found") - {} + FileNotFoundException(const std::string& filename) + : errorText(filename + " could not be found") + { + } - const char * what () const throw () { + const char* what() const throw() + { return errorText.c_str(); } }; @@ -60,11 +62,15 @@ public: /* Returns full path for a game resource */ static inline std::string getResourcePath(const std::string& filepath) - { return dataDir + '/' + filepath; } + { + return dataDir + '/' + filepath; + } /** Returns full path for user progress save */ static inline std::string getUserSavePath() - { return getUserDataPath() + "/users"; } + { + return getUserDataPath() + "/users"; + } static bool makeDirectory(const std::string& path); diff --git a/Source/Utils/ImageIO.hpp b/Source/Utils/ImageIO.hpp index 6b420dd..4683b0a 100644 --- a/Source/Utils/ImageIO.hpp +++ b/Source/Utils/ImageIO.hpp @@ -40,22 +40,23 @@ along with Lugaru. If not, see . #endif /**> DATA STRUCTURES <**/ -class ImageRec { +class ImageRec +{ public: - GLubyte *data; // Image Data (Up To 32 Bits) - GLuint bpp; // Image Color Depth In Bits Per Pixel. + GLubyte* data; // Image Data (Up To 32 Bits) + GLuint bpp; // Image Color Depth In Bits Per Pixel. GLuint sizeX; GLuint sizeY; ImageRec(); ~ImageRec(); + private: /* Make sure this class cannot be copied to avoid memory problems */ - ImageRec(ImageRec const &); - ImageRec& operator=(ImageRec const &); + ImageRec(ImageRec const&); + ImageRec& operator=(ImageRec const&); }; -bool load_image(const char * fname, ImageRec & tex); -bool save_screenshot(const char * fname); +bool load_image(const char* fname, ImageRec& tex); +bool save_screenshot(const char* fname); #endif -