From 4661d103eb213c4b724d3748eb62867ccd59cee7 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 17 Jan 2009 15:15:02 +0000 Subject: [PATCH] Use C++ style declarations --- src/AnimatedImage.cpp | 2 +- src/AnimatedImage.hpp | 2 +- src/Asteroid.cpp | 4 ++-- src/Asteroid.hpp | 4 ++-- src/ConfigFile.cpp | 12 ++++++------ src/ConfigFile.hpp | 10 +++++----- src/ElectricGate.cpp | 6 +++--- src/ElectricGate.hpp | 8 ++++---- src/Emitter.cpp | 2 +- src/Emitter.hpp | 2 +- src/Font.cpp | 14 +++++++------- src/Font.hpp | 14 +++++++------- src/Game.cpp | 30 +++++++++++++++--------------- src/Game.hpp | 10 +++++----- src/HighScores.cpp | 28 ++++++++++++++-------------- src/HighScores.hpp | 14 +++++++------- src/Image.cpp | 2 +- src/Image.hpp | 2 +- src/Input.cpp | 6 +++--- src/Input.hpp | 6 +++--- src/Key.cpp | 26 +++++++++++++------------- src/Key.hpp | 14 +++++++------- src/LandingPad.cpp | 6 +++--- src/LandingPad.hpp | 6 +++--- src/Main.cpp | 18 +++++++++--------- src/Menu.cpp | 18 +++++++++--------- src/Menu.hpp | 4 ++-- src/Mine.cpp | 6 +++--- src/Mine.hpp | 10 +++++----- src/Missile.cpp | 10 +++++----- src/Missile.hpp | 14 +++++++------- src/ObjectGrid.cpp | 8 ++++---- src/ObjectGrid.hpp | 10 +++++----- src/OpenGL.cpp | 24 ++++++++++++------------ src/OpenGL.hpp | 28 ++++++++++++++-------------- src/Options.cpp | 16 ++++++++-------- src/Options.hpp | 2 +- src/Platform.hpp | 4 ++-- src/ScreenManager.cpp | 6 +++--- src/ScreenManager.hpp | 8 ++++---- src/Ship.cpp | 10 +++++----- src/Ship.hpp | 10 +++++----- src/SoundEffect.cpp | 2 +- src/SoundEffect.hpp | 4 ++-- src/Surface.cpp | 12 ++++++------ src/Surface.hpp | 12 ++++++------ src/Texture.cpp | 4 ++-- src/Texture.hpp | 2 +- 48 files changed, 236 insertions(+), 236 deletions(-) diff --git a/src/AnimatedImage.cpp b/src/AnimatedImage.cpp index b62cac3..6df6c41 100644 --- a/src/AnimatedImage.cpp +++ b/src/AnimatedImage.cpp @@ -17,7 +17,7 @@ #include "AnimatedImage.hpp" -AnimatedImage::AnimatedImage(const char *file, int frameWidth, int frameHeight, +AnimatedImage::AnimatedImage(const char* file, int frameWidth, int frameHeight, int frameCount) : Image(file), frameWidth(frameWidth), frameHeight(frameHeight), frameCount(frameCount) diff --git a/src/AnimatedImage.hpp b/src/AnimatedImage.hpp index fe75905..e33c4a7 100644 --- a/src/AnimatedImage.hpp +++ b/src/AnimatedImage.hpp @@ -22,7 +22,7 @@ class AnimatedImage : public Image { public: - AnimatedImage(const char *file, int frameWidth, int frameHeight, int frameCount=0); + AnimatedImage(const char* file, int frameWidth, int frameHeight, int frameCount=0); void Draw(int x, int y, double rotate=0.0, double scale=1.0, double alpha=1.0, double white=1.0) const; diff --git a/src/Asteroid.cpp b/src/Asteroid.cpp index 41e79e3..231cb02 100644 --- a/src/Asteroid.cpp +++ b/src/Asteroid.cpp @@ -19,7 +19,7 @@ #include "OpenGL.hpp" #include "LoadOnce.hpp" -Texture *Asteroid::surfTexture[Surface::NUM_SURF_TEX]; +Texture* Asteroid::surfTexture[Surface::NUM_SURF_TEX]; Asteroid::Asteroid() { @@ -192,7 +192,7 @@ void Asteroid::Draw(int viewadjust_x, int viewadjust_y) const glCallList(display_list); } -bool Asteroid::CheckCollision(Ship &ship) +bool Asteroid::CheckCollision(Ship& ship) { // Look at polys for (int k = 0; k < GetWidth(); k++) { diff --git a/src/Asteroid.hpp b/src/Asteroid.hpp index 8adcd8c..9201929 100644 --- a/src/Asteroid.hpp +++ b/src/Asteroid.hpp @@ -32,7 +32,7 @@ public: void ConstructAsteroid(int x, int y, int width, int surftex); void Draw(int viewadjust_x, int viewadjust_y) const; - bool CheckCollision(Ship &ship); + bool CheckCollision(Ship& ship); LineSegment GetUpBoundary(int poly); LineSegment GetDownBoundary(int poly); @@ -43,7 +43,7 @@ private: void GenerateDisplayList(int texidx); - static Texture *surfTexture[Surface::NUM_SURF_TEX]; + static Texture* surfTexture[Surface::NUM_SURF_TEX]; GLuint display_list; struct AsteroidSection { diff --git a/src/ConfigFile.cpp b/src/ConfigFile.cpp index 4404851..19a44e7 100644 --- a/src/ConfigFile.cpp +++ b/src/ConfigFile.cpp @@ -52,12 +52,12 @@ ConfigFile::~ConfigFile() } } -bool ConfigFile::has(const string &key) const +bool ConfigFile::has(const string& key) const { return settings.find(key) != settings.end(); } -const string &ConfigFile::get(const string &key) +const string& ConfigFile::get(const string& key) { if (!has(key)) throw runtime_error(key + " not in config file"); @@ -65,7 +65,7 @@ const string &ConfigFile::get(const string &key) return settings[key]; } -const string &ConfigFile::get_string(const string &key, const string &def) +const string& ConfigFile::get_string(const string& key, const string& def) { if (has(key)) return get(key); @@ -75,7 +75,7 @@ const string &ConfigFile::get_string(const string &key, const string &def) } } -int ConfigFile::get_int(const string &key, int def) +int ConfigFile::get_int(const string& key, int def) { if (has(key)) { istringstream is(get(key)); @@ -91,10 +91,10 @@ int ConfigFile::get_int(const string &key, int def) } } -bool ConfigFile::get_bool(const string &key, bool def) +bool ConfigFile::get_bool(const string& key, bool def) { if (has(key)) { - const string &value = get(key); + const string& value = get(key); if (value == "true") return true; else if (value == "false") diff --git a/src/ConfigFile.hpp b/src/ConfigFile.hpp index 6485d42..60f8423 100644 --- a/src/ConfigFile.hpp +++ b/src/ConfigFile.hpp @@ -25,12 +25,12 @@ public: ConfigFile(string filename = ".lander.config"); ~ConfigFile(); - bool has(const string &key) const; + bool has(const string& key) const; - const string &get(const string &key); - const string &get_string(const string &key, const string &def = ""); - int get_int(const string &key, int def = 0); - bool get_bool(const string &key, bool def = false); + const string& get(const string& key); + const string& get_string(const string& key, const string& def = ""); + int get_int(const string& key, int def = 0); + bool get_bool(const string& key, bool def = false); void put(string key, string value); void put(string key, int value); diff --git a/src/ElectricGate.cpp b/src/ElectricGate.cpp index 0ede187..7cec0ce 100644 --- a/src/ElectricGate.cpp +++ b/src/ElectricGate.cpp @@ -18,9 +18,9 @@ #include "ElectricGate.hpp" #include "LoadOnce.hpp" -Image *ElectricGate::gateImage = NULL; +Image* ElectricGate::gateImage = NULL; -ElectricGate::ElectricGate(Viewport *v, int length, bool vertical, int x, int y) +ElectricGate::ElectricGate(Viewport* v, int length, bool vertical, int x, int y) : StaticObject(x, y), length(length), vertical(vertical), viewport(v) { LOAD_ONCE { @@ -32,7 +32,7 @@ ElectricGate::ElectricGate(Viewport *v, int length, bool vertical, int x, int y) timer = rand() % 70 + 10; } -bool ElectricGate::CheckCollision(Ship &ship) +bool ElectricGate::CheckCollision(Ship& ship) { int dx = vertical ? 0 : length; int dy = vertical ? length : 0; diff --git a/src/ElectricGate.hpp b/src/ElectricGate.hpp index c75ed5d..a8289b9 100644 --- a/src/ElectricGate.hpp +++ b/src/ElectricGate.hpp @@ -54,9 +54,9 @@ private: class ElectricGate : public StaticObject { public: - ElectricGate(Viewport *v, int length, bool vertical, int x, int y); + ElectricGate(Viewport* v, int length, bool vertical, int x, int y); - bool CheckCollision(Ship &ship); + bool CheckCollision(Ship& ship); void Draw(); private: @@ -64,10 +64,10 @@ private: int length, timer; bool vertical; - Viewport *viewport; + Viewport* viewport; Lightning lightning; - static Image *gateImage; + static Image* gateImage; }; #endif diff --git a/src/Emitter.cpp b/src/Emitter.cpp index a78cc88..9690846 100644 --- a/src/Emitter.cpp +++ b/src/Emitter.cpp @@ -21,7 +21,7 @@ #include "OpenGL.hpp" #include "LoadOnce.hpp" -Texture *Emitter::texture = NULL; +Texture* Emitter::texture = NULL; // // Creates a new particle emitter. diff --git a/src/Emitter.hpp b/src/Emitter.hpp index 34c68cb..17a1971 100644 --- a/src/Emitter.hpp +++ b/src/Emitter.hpp @@ -59,7 +59,7 @@ protected: float xg, yg; } particle[MAX_PARTICLES]; - static Texture *texture; + static Texture* texture; }; diff --git a/src/Font.cpp b/src/Font.cpp index e02b535..91cdf95 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -81,7 +81,7 @@ int Font::NextPowerOf2(int a) } void Font::MakeDisplayList(FT_Face face, char ch, GLuint listBase, - GLuint *texBase, unsigned short *widths) + GLuint* texBase, unsigned short* widths) { int i, j; @@ -164,18 +164,18 @@ void Font::MakeDisplayList(FT_Face face, char ch, GLuint listBase, glEndList(); } -void Font::SplitIntoLines(vector &lines, const char *fmt, va_list ap) +void Font::SplitIntoLines(vector &lines, const char* fmt, va_list ap) { if (fmt == NULL) *buf = 0; else vsnprintf(buf, MAX_TXT_BUF, fmt, ap); - const char *start_line = buf, *c; + const char* start_line = buf, *c; for (c = buf; *c; c++) { if (*c == '\n') { string line; - for (const char *n = start_line; n < c; n++) + for (const char* n = start_line; n < c; n++) line.append(1, *n); lines.push_back(line); start_line = c+1; @@ -184,13 +184,13 @@ void Font::SplitIntoLines(vector &lines, const char *fmt, va_list ap) if (start_line) { string line; - for (const char *n = start_line; n < c; n++) + for (const char* n = start_line; n < c; n++) line.append(1, *n); lines.push_back(line); } } -void Font::Print(int x, int y, const char *fmt, ...) +void Font::Print(int x, int y, const char* fmt, ...) { // Store the current matrix glPushMatrix(); @@ -226,7 +226,7 @@ void Font::Print(int x, int y, const char *fmt, ...) glPopMatrix(); } -int Font::GetStringWidth(const char *fmt, ...) +int Font::GetStringWidth(const char* fmt, ...) { va_list ap; vector lines; diff --git a/src/Font.hpp b/src/Font.hpp index 2a58eff..561efbb 100644 --- a/src/Font.hpp +++ b/src/Font.hpp @@ -27,19 +27,19 @@ public: Font(string filename, unsigned int h); ~Font(); - void Print(int x, int y, const char *fmt, ...); - int GetStringWidth(const char *fmt, ...); + void Print(int x, int y, const char* fmt, ...); + int GetStringWidth(const char* fmt, ...); private: int NextPowerOf2(int a); void MakeDisplayList(FT_Face face, char ch, GLuint listBase, - GLuint *texBase, unsigned short *widths); - void SplitIntoLines(vector &lines, const char *fmt, va_list ap); + GLuint* texBase, unsigned short* widths); + void SplitIntoLines(vector &lines, const char* fmt, va_list ap); - GLuint *textures; + GLuint* textures; GLuint listBase; float height; - unsigned short *widths; - char *buf; + unsigned short* widths; + char* buf; static const int MAX_TXT_BUF = 1024; diff --git a/src/Game.cpp b/src/Game.cpp index 69ea433..7895d03 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -118,8 +118,8 @@ void Game::EnterDeathWait(int timeout) void Game::Process() { - Input &input = Input::GetInstance(); - OpenGL &opengl = OpenGL::GetInstance(); + Input& input = Input::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); // Check keys if (input.QueryAction(Input::PAUSE)) { @@ -332,8 +332,8 @@ void Game::Process() else if (state == gsFadeToDeath) { if (fade.Process()) { // Return to main menu - ScreenManager &sm = ScreenManager::GetInstance(); - HighScores *hs = static_cast(sm.GetScreenById("HIGH SCORES")); + ScreenManager& sm = ScreenManager::GetInstance(); + HighScores* hs = static_cast(sm.GetScreenById("HIGH SCORES")); hs->CheckScore(score); } } @@ -538,7 +538,7 @@ void Game::ExplodeShip() void Game::Display() { - OpenGL &opengl = OpenGL::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); // Draw the stars for (int i = 0; i < nStarCount; i++) { @@ -618,7 +618,7 @@ void Game::Display() if (state == gsExplode) { ship.DrawExplosion(); glColor3f(0.0f, 1.0f, 0.0f); - const char *sdeath = i18n("Press SPACE to continue"); + const char* sdeath = i18n("Press SPACE to continue"); int x = (opengl.GetWidth() - normalFont.GetStringWidth(sdeath)) / 2; int y = opengl.GetHeight() - 40; normalFont.Print(x, y, sdeath); @@ -676,13 +676,13 @@ void Game::Display() i += 32; } glColor3f(0.0f, 1.0f, 0.0f); - const char *sland = i18n("Land now"); + const char* sland = i18n("Land now"); int x = (opengl.GetWidth() - normalFont.GetStringWidth(sland)) / 2; normalFont.Print(x, 30, sland); } // Draw level complete messages - const char *scoretxt = i18n("Score: %d"); + const char* scoretxt = i18n("Score: %d"); if (state == gsLevelComplete) { int lc_x = (opengl.GetWidth() - levelComp.GetWidth()) / 2; int lc_y = (opengl.GetHeight() - levelComp.GetHeight()) / 2 - 50; @@ -698,7 +698,7 @@ void Game::Display() // Draw level number text if (leveltext_timeout) { glColor3f(0.9f, 0.9f, 0.0f); - const char *lvltxt = i18n("Level %d"); + const char* lvltxt = i18n("Level %d"); int x = (opengl.GetWidth() - bigFont.GetStringWidth(lvltxt, level)) / 2; int y = (opengl.GetHeight() - 30) / 2; bigFont.Print(x, y, lvltxt, level); @@ -717,7 +717,7 @@ void Game::Display() // Draw paused message if (state == gsPaused) { - const char *txtpaused = i18n("Paused"); + const char* txtpaused = i18n("Paused"); glColor3f(0.0f, 0.5f, 1.0f); int x = (opengl.GetWidth() - bigFont.GetStringWidth(txtpaused) - 20) / 2; int y = (opengl.GetHeight() - 150) / 2; @@ -725,8 +725,8 @@ void Game::Display() } } -Image *FuelMeter::fuelMeterImage = NULL; -Texture *FuelMeter::fuelBarTexture = NULL; +Image* FuelMeter::fuelMeterImage = NULL; +Texture* FuelMeter::fuelBarTexture = NULL; FuelMeter::FuelMeter() : fuel(0), maxfuel(1) @@ -739,7 +739,7 @@ FuelMeter::FuelMeter() void FuelMeter::Display() { - OpenGL &opengl = OpenGL::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); int fbsize = (int)(((float)fuel/(float)maxfuel)*(256-FUELBAR_OFFSET)); float texsize = fbsize/(256.0f-FUELBAR_OFFSET); @@ -781,9 +781,9 @@ bool FuelMeter::OutOfFuel() const return fuel <= 0; } -Image *SpeedMeter::speedMeterImage = NULL; +Image* SpeedMeter::speedMeterImage = NULL; -SpeedMeter::SpeedMeter(Ship *ship) +SpeedMeter::SpeedMeter(Ship* ship) : ship(ship) { LOAD_ONCE { diff --git a/src/Game.hpp b/src/Game.hpp index ac529ce..6baac5c 100644 --- a/src/Game.hpp +++ b/src/Game.hpp @@ -58,8 +58,8 @@ public: int GetFuel() const { return fuel; } private: - static Image *fuelMeterImage; - static Texture *fuelBarTexture; + static Image* fuelMeterImage; + static Texture* fuelBarTexture; static const int FUELBAR_Y; @@ -69,18 +69,18 @@ private: class SpeedMeter { public: - SpeedMeter(Ship *ship); + SpeedMeter(Ship* ship); bool SafeLandingSpeed() const; void Display(); private: - static Image *speedMeterImage; + static Image* speedMeterImage; static const float LAND_SPEED; ColourQuad speedbar; - Ship *ship; + Ship* ship; }; class Game : public Screen { diff --git a/src/HighScores.cpp b/src/HighScores.cpp index 1a4cf9a..d5595ac 100644 --- a/src/HighScores.cpp +++ b/src/HighScores.cpp @@ -45,8 +45,8 @@ void HighScores::Load() // void HighScores::Process() { - Input &input = Input::GetInstance(); - OpenGL &opengl = OpenGL::GetInstance(); + Input& input = Input::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); int i; // Check for input @@ -152,7 +152,7 @@ void HighScores::Process() // void HighScores::Display() { - OpenGL &opengl = OpenGL::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); // Draw the fireworks for (int i = 0; i < MAX_FIREWORKS; i++) @@ -171,7 +171,7 @@ void HighScores::Display() } // Draw other stuff - const char *hsnext = i18n("Press SPACE or FIRE to return"); + const char* hsnext = i18n("Press SPACE or FIRE to return"); if (state == hssDisplay) { int title_x = (opengl.GetWidth() - hscoreImage.GetWidth()) / 2; int title_y = 50; @@ -184,20 +184,20 @@ void HighScores::Display() largeFont.Print(x, y, hsnext); } else if (state == hssEnterName) { - Input &input = Input::GetInstance(); + Input& input = Input::GetInstance(); - const char *hsscore = i18n("Well done - You got a high score"); + const char* hsscore = i18n("Well done - You got a high score"); int x = (opengl.GetWidth() - largeFont.GetStringWidth(hsscore)) / 2; glColor4f(0.0f, 1.0f, 0.0f, flAlpha); largeFont.Print(x, 100, hsscore); - const char *hscont = i18n("Press ENTER or FIRE to continue"); + const char* hscont = i18n("Press ENTER or FIRE to continue"); x = (opengl.GetWidth() - largeFont.GetStringWidth(hscont)) / 2; int y = opengl.GetHeight() - 60; largeFont.Print(x, y, hscont); - const char *name = input.GetInput(); - const char *hsname = i18n("Name? %s"); + const char* name = input.GetInput(); + const char* hsname = i18n("Name? %s"); x = (opengl.GetWidth() - largeFont.GetStringWidth(hsname, name)) / 2; y = (opengl.GetHeight() - 50) / 2; glColor4f(0.8f, 0.0f, 1.0f, flAlpha); @@ -284,7 +284,7 @@ string ScoreFile::GetHighScoreFile() return GetConfigDir() + ".lander.scores"; } -bool operator<(const ScoreFile::ScoreEntry &a, const ScoreFile::ScoreEntry &b) +bool operator<(const ScoreFile::ScoreEntry& a, const ScoreFile::ScoreEntry& b) { return a.GetScore() > b.GetScore(); } @@ -322,26 +322,26 @@ void ScoreFile::Save() (*it).WriteOnStream(fout); } -void ScoreFile::Insert(const char *name, int score) +void ScoreFile::Insert(const char* name, int score) { scores[9] = ScoreEntry(name, score); Sort(); needsWrite = true; } -ScoreFile::ScoreEntry::ScoreEntry(const char *name, int score) +ScoreFile::ScoreEntry::ScoreEntry(const char* name, int score) : score(score) { strncpy(this->name, name, MAX_NAME); } -void ScoreFile::ScoreEntry::WriteOnStream(ostream &os) +void ScoreFile::ScoreEntry::WriteOnStream(ostream& os) { os.write((const char*)&score, sizeof(int)); os.write(name, MAX_NAME); } -void ScoreFile::ScoreEntry::ReadFromStream(istream &is) +void ScoreFile::ScoreEntry::ReadFromStream(istream& is) { is.read((char*)&score, sizeof(int)); is.read(name, MAX_NAME); diff --git a/src/HighScores.hpp b/src/HighScores.hpp index a55a464..64588ee 100644 --- a/src/HighScores.hpp +++ b/src/HighScores.hpp @@ -37,20 +37,20 @@ public: void Load(); void Save(); - void Insert(const char *name, int score); + void Insert(const char* name, int score); // An entry in the highscores chart class ScoreEntry { public: - ScoreEntry(const char *name, int score); + ScoreEntry(const char* name, int score); static const int MAX_NAME = 16; - const char *GetName() const { return name; } + const char* GetName() const { return name; } int GetScore() const { return score; } - void WriteOnStream(ostream &os); - void ReadFromStream(istream &is); + void WriteOnStream(ostream& os); + void ReadFromStream(istream& is); private: char name[MAX_NAME]; @@ -59,7 +59,7 @@ public: static const int NUM_SCORES = 10; - const ScoreEntry &operator[](int n) const { return scores[n]; } + const ScoreEntry& operator[](int n) const { return scores[n]; } private: void Sort(); @@ -111,7 +111,7 @@ private: delete em; } - Emitter *em; + Emitter* em; int x, y, speed, life, timeout; bool active; } fw[MAX_FIREWORKS]; diff --git a/src/Image.cpp b/src/Image.cpp index 424a1ea..4d33164 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -18,7 +18,7 @@ #include "Image.hpp" #include "OpenGL.hpp" -Image::Image(const char *file) +Image::Image(const char* file) : Texture(file) { diff --git a/src/Image.hpp b/src/Image.hpp index 1be9885..7278bbd 100644 --- a/src/Image.hpp +++ b/src/Image.hpp @@ -23,7 +23,7 @@ class Image : public Texture { public: - Image(const char *file); + Image(const char* file); virtual ~Image(); virtual void Draw(int x, int y, double rotate=0.0, double scale=1.0, diff --git a/src/Input.cpp b/src/Input.cpp index 2356548..28bc51d 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -61,7 +61,7 @@ Input::~Input() // // Returns the only instance of Input. // -Input &Input::GetInstance() +Input& Input::GetInstance() { static Input g_input; @@ -173,7 +173,7 @@ void Input::Update() bool Input::QueryAction(Action a) const { int numkeys; - Uint8 *keystate; + Uint8* keystate; if (actionIgnore[a] > 0) return false; @@ -243,7 +243,7 @@ void Input::CloseCharBuffer() // // Returns a pointer to the data read in text input mode. // -const char *Input::GetInput() const +const char* Input::GetInput() const { return text.c_str(); } diff --git a/src/Input.hpp b/src/Input.hpp index dafb1ec..299a78c 100644 --- a/src/Input.hpp +++ b/src/Input.hpp @@ -33,7 +33,7 @@ public: SKIP, ABORT, DEBUG, PAUSE, THRUST }; - static Input &GetInstance(); + static Input& GetInstance(); bool QueryAction(Action a) const; void ResetAction(Action a); @@ -41,7 +41,7 @@ public: void OpenCharBuffer(int max=256); void CloseCharBuffer(); - const char *GetInput() const; + const char* GetInput() const; private: Input(); @@ -50,7 +50,7 @@ private: static const int NUM_ACTIONS = 10; static const int RESET_TIMEOUT = 10; // Frames between key presses - SDL_Joystick *joystick; + SDL_Joystick* joystick; int actionIgnore[NUM_ACTIONS]; // Timeout for actions being ignored diff --git a/src/Key.cpp b/src/Key.cpp index 452c39e..efb9cfa 100644 --- a/src/Key.cpp +++ b/src/Key.cpp @@ -19,16 +19,16 @@ #include "OpenGL.hpp" #include "LoadOnce.hpp" -AnimatedImage *Key::blueImage = NULL; -AnimatedImage *Key::redImage = NULL; -AnimatedImage *Key::greenImage = NULL; -AnimatedImage *Key::yellowImage = NULL; -AnimatedImage *Key::pinkImage = NULL; -Image *Key::blueArrow = NULL; -Image *Key::redArrow = NULL; -Image *Key::greenArrow = NULL; -Image *Key::yellowArrow = NULL; -Image *Key::pinkArrow = NULL; +AnimatedImage* Key::blueImage = NULL; +AnimatedImage* Key::redImage = NULL; +AnimatedImage* Key::greenImage = NULL; +AnimatedImage* Key::yellowImage = NULL; +AnimatedImage* Key::pinkImage = NULL; +Image* Key::blueArrow = NULL; +Image* Key::redArrow = NULL; +Image* Key::greenArrow = NULL; +Image* Key::yellowArrow = NULL; +Image* Key::pinkArrow = NULL; Key::Key(bool active, int xpos, int ypos, ArrowColour acol) : StaticObject(xpos, ypos, 1, 1), @@ -78,7 +78,7 @@ Key::Key(bool active, int xpos, int ypos, ArrowColour acol) } } -void Key::DrawKey(Viewport *viewport) +void Key::DrawKey(Viewport* viewport) { int draw_x = xpos*OBJ_GRID_SIZE - viewport->GetXAdjust(); int draw_y = ypos*OBJ_GRID_SIZE - viewport->GetYAdjust() + OBJ_GRID_TOP; @@ -92,7 +92,7 @@ void Key::DrawKey(Viewport *viewport) alpha -= 0.02f; } -void Key::DrawArrow(Viewport *viewport) +void Key::DrawArrow(Viewport* viewport) { if (active && !ObjectInScreen(viewport)) { int ax = xpos*OBJ_GRID_SIZE - viewport->GetXAdjust(); @@ -134,7 +134,7 @@ void Key::DrawIcon(int offset, float minAlpha) image->SetFrame(prevFrame); } -bool Key::CheckCollision(Ship &ship) const +bool Key::CheckCollision(Ship& ship) const { bool collide = ship.BoxCollision (xpos*OBJ_GRID_SIZE + 3, diff --git a/src/Key.hpp b/src/Key.hpp index 12d37e0..08ac0fb 100644 --- a/src/Key.hpp +++ b/src/Key.hpp @@ -29,10 +29,10 @@ class Key : public StaticObject { public: Key(bool active, int xpos, int ypos, ArrowColour acol); - void DrawKey(Viewport *viewport); - void DrawArrow(Viewport *viewport); + void DrawKey(Viewport* viewport); + void DrawArrow(Viewport* viewport); void DrawIcon(int offset, float minAlpha); - bool CheckCollision(Ship &ship) const; + bool CheckCollision(Ship& ship) const; void Collected() { active = false; } @@ -44,12 +44,12 @@ private: int rotcount; float alpha; bool active; - AnimatedImage *image; - Image *arrow; + AnimatedImage* image; + Image* arrow; - static AnimatedImage *blueImage, *redImage, *yellowImage, + static AnimatedImage* blueImage, *redImage, *yellowImage, *pinkImage, *greenImage; - static Image *blueArrow, *redArrow, *yellowArrow, + static Image* blueArrow, *redArrow, *yellowArrow, *pinkArrow, *greenArrow; }; diff --git a/src/LandingPad.cpp b/src/LandingPad.cpp index 36dcf37..4de6238 100644 --- a/src/LandingPad.cpp +++ b/src/LandingPad.cpp @@ -19,10 +19,10 @@ #include "Surface.hpp" #include "LoadOnce.hpp" -Texture *LandingPad::landTexture = NULL; -Texture *LandingPad::noLandTexture = NULL; +Texture* LandingPad::landTexture = NULL; +Texture* LandingPad::noLandTexture = NULL; -LandingPad::LandingPad(Viewport *v, int index, int length) +LandingPad::LandingPad(Viewport* v, int index, int length) : index(index), length(length), viewport(v) { LOAD_ONCE { diff --git a/src/LandingPad.hpp b/src/LandingPad.hpp index c8b99a4..fa478d0 100644 --- a/src/LandingPad.hpp +++ b/src/LandingPad.hpp @@ -25,7 +25,7 @@ class LandingPad { public: - LandingPad(Viewport *v, int index, int length); + LandingPad(Viewport* v, int index, int length); void Draw(bool locked); void SetYPos(int ypos) { this->ypos = ypos; } @@ -36,9 +36,9 @@ public: private: TextureQuad quad; int index, length, ypos; - Viewport *viewport; + Viewport* viewport; - static Texture *landTexture, *noLandTexture; + static Texture* landTexture, *noLandTexture; }; typedef vector LandingPadList; diff --git a/src/Main.cpp b/src/Main.cpp index 80ffbe3..00df5c7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -26,10 +26,10 @@ #include -static MainMenu *menu = NULL; -static Game *game = NULL; -static HighScores *scores = NULL; -static Options *options = NULL; +static MainMenu* menu = NULL; +static Game* game = NULL; +static HighScores* scores = NULL; +static Options* options = NULL; static void DestroyScreens() { @@ -61,7 +61,7 @@ void RecreateScreens() scores = new HighScores(); options = new Options(); - ScreenManager &sm = ScreenManager::GetInstance(); + ScreenManager& sm = ScreenManager::GetInstance(); sm.AddScreen("MAIN MENU", menu); sm.AddScreen("GAME", game); sm.AddScreen("HIGH SCORES", scores); @@ -113,7 +113,7 @@ int main(int argc, char **argv) try { // Create the game window - OpenGL &opengl = OpenGL::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); opengl.Init(width, height, depth, fullscreen); RecreateScreens(); @@ -138,7 +138,7 @@ int main(int argc, char **argv) // // Find a filename in the installation tree. // -const char *LocateResource(const char *file) +const char* LocateResource(const char* file) { #ifdef MACOSX static char path[MAX_RES_PATH]; @@ -173,13 +173,13 @@ const char *LocateResource(const char *file) #endif } -bool FileExists(const string &file) +bool FileExists(const string& file) { #ifdef UNIX struct stat buf; return stat(file.c_str(), &buf) == 0; #else - FILE *f = fopen(file.c_str(), "r"); + FILE* f = fopen(file.c_str(), "r"); if (NULL == f) return false; else { diff --git a/src/Menu.cpp b/src/Menu.cpp index 5af4531..4cfe3a1 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -36,7 +36,7 @@ const unsigned MainMenu::MAX_STARS(80); const double MenuOption::SEL_ENLARGE(1.2); const double MenuOption::UNSEL_DIM(0.5); -Image *MenuStar::starImage = NULL; +Image* MenuStar::starImage = NULL; MainMenu::MainMenu() : startOpt("images/start_option.png", OPTIONS_OFFSET, 0), @@ -65,9 +65,9 @@ void MainMenu::Load() void MainMenu::Process() { - Input &input = Input::GetInstance(); - OpenGL &opengl = OpenGL::GetInstance(); - ScreenManager &sm = ScreenManager::GetInstance(); + Input& input = Input::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); + ScreenManager& sm = ScreenManager::GetInstance(); // Stop user doing something when they're not supposed to if (state == msInMenu) { @@ -145,7 +145,7 @@ void MainMenu::Process() if (fade <= 0.0) { // Move to the game screen sm.SelectScreen("GAME"); - Game *g = static_cast(sm.GetScreenById("GAME")); + Game* g = static_cast(sm.GetScreenById("GAME")); g->NewGame(); } else { @@ -157,7 +157,7 @@ void MainMenu::Process() // Apply fade if (fade <= 0.0f) { // Move to the high score screen - HighScores *hs = static_cast(sm.GetScreenById("HIGH SCORES")); + HighScores* hs = static_cast(sm.GetScreenById("HIGH SCORES")); hs->DisplayScores(); } else { @@ -219,7 +219,7 @@ void MainMenu::DisplayStars() void MainMenu::Display() { - OpenGL &opengl = OpenGL::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); DisplayStars(); @@ -235,7 +235,7 @@ void MainMenu::Display() // Draw some hint texts const int numhints = 7; - const char *hints[] = { + const char* hints[] = { i18n("Use the arrow keys to rotate the ship"), i18n("Press the up arrow to fire the thruster"), i18n("Smaller landing pads give you more points"), @@ -304,7 +304,7 @@ bool MenuStar::Move() || y + starImage->GetWidth() < 0); } -MenuOption::MenuOption(const char *imgFile, int off, int order) +MenuOption::MenuOption(const char* imgFile, int off, int order) : image(imgFile) { y = (OpenGL::GetInstance().GetHeight() - off) / 2 + (order*image.GetHeight()); diff --git a/src/Menu.hpp b/src/Menu.hpp index a55a18e..c1386d0 100644 --- a/src/Menu.hpp +++ b/src/Menu.hpp @@ -40,12 +40,12 @@ private: double x, y, angle; static double starRotate; - static Image *starImage; + static Image* starImage; }; class MenuOption { public: - MenuOption(const char *imgFile, int off, int order); + MenuOption(const char* imgFile, int off, int order); void Display(bool selected, double bigness, double fade) const; diff --git a/src/Mine.cpp b/src/Mine.cpp index 6cf20b0..143b804 100644 --- a/src/Mine.cpp +++ b/src/Mine.cpp @@ -19,9 +19,9 @@ #include "OpenGL.hpp" #include "LoadOnce.hpp" -AnimatedImage *Mine::image = NULL; +AnimatedImage* Mine::image = NULL; -Mine::Mine(ObjectGrid *o, Viewport *v, int x, int y) +Mine::Mine(ObjectGrid* o, Viewport* v, int x, int y) : objgrid(o), viewport(v) { LOAD_ONCE { @@ -138,7 +138,7 @@ void Mine::Move() } } -bool Mine::CheckCollision(Ship &ship) +bool Mine::CheckCollision(Ship& ship) { return ship.BoxCollision (xpos*OBJ_GRID_SIZE + 3 + displace_x, diff --git a/src/Mine.hpp b/src/Mine.hpp index b490141..0ad0c48 100644 --- a/src/Mine.hpp +++ b/src/Mine.hpp @@ -25,11 +25,11 @@ class Mine : public StaticObject { public: - Mine(ObjectGrid *o, Viewport *v, int x, int y); + Mine(ObjectGrid* o, Viewport* v, int x, int y); void Move(); void Draw() const; - bool CheckCollision(Ship &ship); + bool CheckCollision(Ship& ship); static const int MINE_FRAME_COUNT = 18; @@ -39,13 +39,13 @@ private: enum Direction { dirUp, dirRight, dirDown, dirLeft, dirNone }; - ObjectGrid *objgrid; - Viewport *viewport; + ObjectGrid* objgrid; + Viewport* viewport; Direction dir; int current, rotcount, movetimeout; int displace_x, displace_y, movedelay; - static AnimatedImage *image; + static AnimatedImage* image; }; #endif diff --git a/src/Missile.cpp b/src/Missile.cpp index be8f331..11bc022 100644 --- a/src/Missile.cpp +++ b/src/Missile.cpp @@ -23,11 +23,11 @@ #include "ObjectGrid.hpp" #include "Ship.hpp" -Image *Missile::image = NULL; +Image* Missile::image = NULL; const double Missile::ACCEL(0.1); -Missile::Missile(ObjectGrid *o, Viewport *v, Side s) +Missile::Missile(ObjectGrid* o, Viewport* v, Side s) : viewport(v), objgrid(o), speed(0.0), state(FIXED) { // This constructor builds a missile attached to the side of the screen @@ -55,7 +55,7 @@ void Missile::Draw() const image->Draw(dx - viewport->GetXAdjust(), dy - viewport->GetYAdjust(), angle); } -bool Missile::CheckCollison(const Ship &ship) +bool Missile::CheckCollison(const Ship& ship) { // A bounding box collision isn't exactly accurate but should // work OK @@ -65,7 +65,7 @@ bool Missile::CheckCollison(const Ship &ship) return collided; } -void Missile::Move(const Ship &ship) +void Missile::Move(const Ship& ship) { switch (state) { case FIXED: MoveFixed(ship); break; @@ -74,7 +74,7 @@ void Missile::Move(const Ship &ship) } } -void Missile::MoveFixed(const Ship &ship) +void Missile::MoveFixed(const Ship& ship) { // Hmm... add some fancy logic here to decided when to fire if (ship.GetY() > dy) diff --git a/src/Missile.hpp b/src/Missile.hpp index 5437b15..4f37c47 100644 --- a/src/Missile.hpp +++ b/src/Missile.hpp @@ -26,25 +26,25 @@ class Missile { public: enum Side { SIDE_LEFT, SIDE_RIGHT }; - Missile(ObjectGrid *o, Viewport *v, Side s); + Missile(ObjectGrid* o, Viewport* v, Side s); void Draw() const; - void Move(const Ship &ship); - bool CheckCollison(const Ship &ship); + void Move(const Ship& ship); + bool CheckCollison(const Ship& ship); private: - void MoveFixed(const Ship &ship); + void MoveFixed(const Ship& ship); void MoveFlying(); void MoveDestroyed(); - Viewport *viewport; - ObjectGrid *objgrid; + Viewport* viewport; + ObjectGrid* objgrid; int x, y, dx, dy; double angle, speed; enum State { FIXED, FLYING, DESTROYED }; State state; - static Image *image; + static Image* image; static const double ACCEL; }; diff --git a/src/ObjectGrid.cpp b/src/ObjectGrid.cpp index 1efd0ab..4c1d2c6 100644 --- a/src/ObjectGrid.cpp +++ b/src/ObjectGrid.cpp @@ -35,7 +35,7 @@ ObjectGrid::~ObjectGrid() // x, y -> Output x, y, co-ordinates. // Returns falce if area could not be allocated. // -bool ObjectGrid::AllocFreeSpace(int &x, int &y) +bool ObjectGrid::AllocFreeSpace(int& x, int& y) { int timeout = 10000; @@ -59,7 +59,7 @@ bool ObjectGrid::AllocFreeSpace(int &x, int &y) // width, height -> Size of desired space. // Returns false if area could not be allocated. // -bool ObjectGrid::AllocFreeSpace(int &x, int &y, int width, int height) +bool ObjectGrid::AllocFreeSpace(int& x, int& y, int width, int height) { bool isOk; int counter_x, counter_y; @@ -126,7 +126,7 @@ bool ObjectGrid::IsFilled(int x, int y) const return grid[x + (width * y)]; } -void ObjectGrid::Offset(int ox, int oy, int *x, int *y) +void ObjectGrid::Offset(int ox, int oy, int* x, int* y) { // Find the absolute coordinates of object grid point // (ox, oy) and store them in (x, y) @@ -134,7 +134,7 @@ void ObjectGrid::Offset(int ox, int oy, int *x, int *y) *y = OBJ_GRID_TOP + oy*OBJ_GRID_SIZE; } -bool StaticObject::ObjectInScreen(Viewport *viewport) +bool StaticObject::ObjectInScreen(Viewport* viewport) { return viewport->ObjectInScreen(xpos, ypos, width, height); } diff --git a/src/ObjectGrid.hpp b/src/ObjectGrid.hpp index be1f29c..185a0f7 100644 --- a/src/ObjectGrid.hpp +++ b/src/ObjectGrid.hpp @@ -28,21 +28,21 @@ public: ~ObjectGrid(); void Reset(int width, int height); - bool AllocFreeSpace(int &x, int &y); - bool AllocFreeSpace(int &x, int &y, int width, int height); + bool AllocFreeSpace(int& x, int& y); + bool AllocFreeSpace(int& x, int& y, int width, int height); void UnlockSpace(int x, int y); bool IsFilled(int x, int y) const; int GetWidth() const { return width; } int GetHeight() const { return height; } - static void Offset(int ox, int oy, int *x, int *y); + static void Offset(int ox, int oy, int* x, int* y); static const int OBJ_GRID_SIZE = 32; static const int OBJ_GRID_TOP = 100; private: - bool *grid; + bool* grid; int width, height; }; @@ -53,7 +53,7 @@ public: : xpos(xpos), ypos(ypos), width(width), height(height) {} StaticObject() { StaticObject(0, 0, 1, 1); } - bool ObjectInScreen(Viewport *viewport); + bool ObjectInScreen(Viewport* viewport); int GetX() const { return xpos; } int GetY() const { return ypos; } diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp index 0146366..5231ff8 100644 --- a/src/OpenGL.cpp +++ b/src/OpenGL.cpp @@ -34,7 +34,7 @@ OpenGL::OpenGL() // // Returns the singleton instance of OpenGL. // -OpenGL &OpenGL::GetInstance() +OpenGL& OpenGL::GetInstance() { static OpenGL opengl; @@ -174,7 +174,7 @@ void OpenGL::Viewport(int x, int y, int width, int height) glViewport(x, y, width, height); } -void OpenGL::Draw(Renderable *r) +void OpenGL::Draw(Renderable* r) { glDisable(GL_BLEND); glLoadIdentity(); @@ -183,7 +183,7 @@ void OpenGL::Draw(Renderable *r) r->Render(); } -void OpenGL::Draw(Poly *cp) +void OpenGL::Draw(Poly* cp) { glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); @@ -203,7 +203,7 @@ void OpenGL::Draw(Poly *cp) glEnd(); } -void OpenGL::DrawRotate(Renderable *r, float angle) +void OpenGL::DrawRotate(Renderable* r, float angle) { glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); @@ -214,7 +214,7 @@ void OpenGL::DrawRotate(Renderable *r, float angle) r->Render(); } -void OpenGL::DrawBlend(Renderable *r, float alpha) +void OpenGL::DrawBlend(Renderable* r, float alpha) { glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -224,7 +224,7 @@ void OpenGL::DrawBlend(Renderable *r, float alpha) r->Render(); } -void OpenGL::DrawRotateBlend(Renderable *r, float angle, float alpha) +void OpenGL::DrawRotateBlend(Renderable* r, float angle, float alpha) { glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -235,7 +235,7 @@ void OpenGL::DrawRotateBlend(Renderable *r, float angle, float alpha) r->Render(); } -void OpenGL::DrawScale(Renderable *r, float factor) +void OpenGL::DrawScale(Renderable* r, float factor) { glDisable(GL_BLEND); glLoadIdentity(); @@ -245,7 +245,7 @@ void OpenGL::DrawScale(Renderable *r, float factor) r->Render(); } -void OpenGL::DrawRotateScale(Renderable *r, float angle, float factor) +void OpenGL::DrawRotateScale(Renderable* r, float angle, float factor) { glDisable(GL_BLEND); glLoadIdentity(); @@ -256,7 +256,7 @@ void OpenGL::DrawRotateScale(Renderable *r, float angle, float factor) r->Render(); } -void OpenGL::DrawBlendScale(Renderable *r, float alpha, float factor) +void OpenGL::DrawBlendScale(Renderable* r, float alpha, float factor) { glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -267,7 +267,7 @@ void OpenGL::DrawBlendScale(Renderable *r, float alpha, float factor) r->Render(); } -void OpenGL::DrawRotateBlendScale(Renderable *r, float angle, float alpha, float factor) +void OpenGL::DrawRotateBlendScale(Renderable* r, float angle, float alpha, float factor) { glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -332,7 +332,7 @@ GLvoid OpenGL::ResizeGLScene(GLsizei width, GLsizei height) // Displays a message to the user. On Windows this will appear as a message // box. On other platforms the message will be printed to stdout. // -void OpenGL::MsgBox(const char *text, const char *title) +void OpenGL::MsgBox(const char* text, const char* title) { #ifdef WIN32 MessageBox(NULL, text, title, MB_OK | MB_ICONINFORMATION); @@ -347,7 +347,7 @@ void OpenGL::MsgBox(const char *text, const char *title) // as a popup error message. On other platforms the message will be // printed to stderr. // -void OpenGL::ErrorMsg(const char *text, const char *title) +void OpenGL::ErrorMsg(const char* text, const char* title) { #ifdef WIN32 MessageBox(NULL, text, title, MB_OK | MB_ICONEXCLAMATION); diff --git a/src/OpenGL.hpp b/src/OpenGL.hpp index b865918..e7e8cab 100644 --- a/src/OpenGL.hpp +++ b/src/OpenGL.hpp @@ -83,11 +83,11 @@ struct Poly { // class OpenGL { public: - static OpenGL &GetInstance(); + static OpenGL& GetInstance(); void Init(int width, int height, int depth, bool fullscreen); - void MsgBox(const char *text, const char *title="Message"); - void ErrorMsg(const char *text, const char *title="Error"); + void MsgBox(const char* text, const char* title="Message"); + void ErrorMsg(const char* text, const char* title="Error"); void Stop(); void Run(); void SkipDisplay(); @@ -96,15 +96,15 @@ public: void Viewport(int x, int y, int width, int height); // Renderer functions - void Draw(Renderable *r); - void Draw(Poly *cp); - void DrawRotate(Renderable *r, float angle); - void DrawBlend(Renderable *r, float alpha); - void DrawRotateBlend(Renderable *r, float angle, float alpha); - void DrawScale(Renderable *r, float factor); - void DrawRotateScale(Renderable *r, float angle, float factor); - void DrawBlendScale(Renderable *r, float alpha, float factor); - void DrawRotateBlendScale(Renderable *r, float angle, float alpha, float factor); + void Draw(Renderable* r); + void Draw(Poly* cp); + void DrawRotate(Renderable* r, float angle); + void DrawBlend(Renderable* r, float alpha); + void DrawRotateBlend(Renderable* r, float angle, float alpha); + void DrawScale(Renderable* r, float factor); + void DrawRotateScale(Renderable* r, float angle, float factor); + void DrawBlendScale(Renderable* r, float alpha, float factor); + void DrawRotateBlendScale(Renderable* r, float angle, float alpha, float factor); int GetWidth() const { return screen_width; } int GetHeight() const { return screen_height; } @@ -121,8 +121,8 @@ private: ~OpenGL(); GLvoid ResizeGLScene(GLsizei width, GLsizei height); - GLuint BindTexture(unsigned char *data, int width, int height, int fmt); - GLubyte *BuildAlphaChannel(const unsigned char *pixels, int width, int height); + GLuint BindTexture(unsigned char* data, int width, int height, int fmt); + GLubyte* BuildAlphaChannel(const unsigned char* pixels, int width, int height); bool InitGL(); void DrawGLScene(); string SDLErrorString(); diff --git a/src/Options.cpp b/src/Options.cpp index d67eaf1..228430f 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -83,7 +83,7 @@ void Options::ProcessFadeIn() void Options::ProcessMain() { - Input &input = Input::GetInstance(); + Input& input = Input::GetInstance(); if (input.QueryAction(Input::FIRE)) { state = optFadeOut; @@ -99,7 +99,7 @@ void Options::ProcessMain() input.ResetAction(Input::DOWN); } else if (input.QueryAction(Input::LEFT)) { - Item &item = items[selected]; + Item& item = items[selected]; if (item.active == 0) item.active = item.values.size() - 1; else @@ -107,7 +107,7 @@ void Options::ProcessMain() input.ResetAction(Input::LEFT); } else if (input.QueryAction(Input::RIGHT)) { - Item &item = items[selected]; + Item& item = items[selected]; item.active = (item.active + 1) % item.values.size(); input.ResetAction(Input::RIGHT); } @@ -141,7 +141,7 @@ void Options::Apply() assert(hres > 0 && vres > 0); if (OpenGL::GetInstance().SetVideoMode(fullscreen, hres, vres)) { - // This *must* be the very last thing that is done! + // This* must* be the very last thing that is done! RecreateScreens(); } } @@ -223,17 +223,17 @@ void Options::DisplayHelpText() glColor4d(0.0, 1.0, 0.0, fadeAlpha); - const char *help1 = i18n("Use UP and DOWN to select options"); + const char* help1 = i18n("Use UP and DOWN to select options"); x = (screen_w - helpFont.GetStringWidth(help1)) / 2; y = screen_h - 100; helpFont.Print(x, y, help1); - const char *help2 = i18n("Use LEFT and RIGHT to change values"); + const char* help2 = i18n("Use LEFT and RIGHT to change values"); x = (screen_w - helpFont.GetStringWidth(help2)) / 2; y += 25; helpFont.Print(x, y, help2); - const char *help3 = i18n("Press FIRE or RETURN to exit"); + const char* help3 = i18n("Press FIRE or RETURN to exit"); x = (screen_w - helpFont.GetStringWidth(help3)) / 2; y += 25; helpFont.Print(x, y, help3); @@ -257,7 +257,7 @@ string Options::MakeResolutionString(int hres, int vres) const return ss.str(); } -void Options::ParseResolutionString(const string &str, int *hres, int *vres) const +void Options::ParseResolutionString(const string& str, int* hres, int* vres) const { char x; istringstream ss(str); diff --git a/src/Options.hpp b/src/Options.hpp index ca2bab8..b413de6 100644 --- a/src/Options.hpp +++ b/src/Options.hpp @@ -40,7 +40,7 @@ private: void DisplayItems(); string MakeResolutionString(int hres, int vres) const; - void ParseResolutionString(const string &str, int *hres, int *vres) const; + void ParseResolutionString(const string& str, int* hres, int* vres) const; void Apply(); diff --git a/src/Platform.hpp b/src/Platform.hpp index 1de39e1..faf2a56 100644 --- a/src/Platform.hpp +++ b/src/Platform.hpp @@ -164,8 +164,8 @@ using namespace std; #endif /* #ifdef LANDER_BIG_ENDIAN */ void RecreateScreens(); -const char *LocateResource(const char *file); -bool FileExists(const string &file); +const char* LocateResource(const char* file); +bool FileExists(const string& file); string GetConfigDir(); #endif /* #ifdef INC_PLATFORM_HPP */ diff --git a/src/ScreenManager.cpp b/src/ScreenManager.cpp index 82a742b..369467c 100644 --- a/src/ScreenManager.cpp +++ b/src/ScreenManager.cpp @@ -32,14 +32,14 @@ ScreenManager::~ScreenManager() } -ScreenManager &ScreenManager::GetInstance() +ScreenManager& ScreenManager::GetInstance() { static ScreenManager sm; return sm; } -void ScreenManager::AddScreen(const char *id, Screen *ptr) +void ScreenManager::AddScreen(const char* id, Screen* ptr) { if (screens.find(string(id)) != screens.end()) throw runtime_error("Screen already registered: " + string(id)); @@ -68,7 +68,7 @@ void ScreenManager::SelectScreen(const string id) OpenGL::GetInstance().SkipDisplay(); } -Screen *ScreenManager::GetScreenById(const char *id) const +Screen* ScreenManager::GetScreenById(const char* id) const { ScreenMap::const_iterator it; diff --git a/src/ScreenManager.hpp b/src/ScreenManager.hpp index 0c08388..075f536 100644 --- a/src/ScreenManager.hpp +++ b/src/ScreenManager.hpp @@ -39,14 +39,14 @@ public: // class ScreenManager { public: - static ScreenManager &GetInstance(); + static ScreenManager& GetInstance(); - void AddScreen(const char *id, Screen *ptr); + void AddScreen(const char* id, Screen* ptr); void SelectScreen(const string id); void Process(); void Display(); void RemoveAllScreens(); - Screen *GetScreenById(const char *id) const; + Screen* GetScreenById(const char* id) const; private: ScreenManager(); @@ -55,7 +55,7 @@ private: // Holds data about the state of an individual screen struct ScreenData { bool loaded; - Screen *ptr; + Screen* ptr; }; typedef map ScreenMap; diff --git a/src/Ship.cpp b/src/Ship.cpp index 3a3d9eb..7d77e7f 100644 --- a/src/Ship.cpp +++ b/src/Ship.cpp @@ -26,7 +26,7 @@ const Point Ship::hotspots[] = { {29, 14}, {31, 26}, {31, 31}, {17, 31} }; -Ship::Ship(Viewport *v) +Ship::Ship(Viewport* v) : shipImage("images/ship.png"), xpos(0), ypos(0), speedX(0), speedY(0), angle(0), viewport(v), thrusting(false), @@ -141,7 +141,7 @@ void Ship::CentreInViewport() { int centrex = (int)xpos + (shipImage.GetWidth()/2); int centrey = (int)ypos + (shipImage.GetHeight()/2); - OpenGL &opengl = OpenGL::GetInstance(); + OpenGL& opengl = OpenGL::GetInstance(); viewport->SetXAdjust(centrex - (opengl.GetWidth()/2)); viewport->SetYAdjust(centrey - (opengl.GetHeight()/2)); } @@ -162,7 +162,7 @@ void Ship::Reset() speedY = 0.0f; } -void Ship::RotatePoints(const Point *pPoints, Point *pDest, int nCount, +void Ship::RotatePoints(const Point* pPoints, Point* pDest, int nCount, double angle, int adjustx, int adjusty) { for (int i = 0; i < nCount; i++) { @@ -179,7 +179,7 @@ void Ship::RotatePoints(const Point *pPoints, Point *pDest, int nCount, // // Check for collision between the ship and a polygon. // -bool Ship::HotSpotCollision(LineSegment &l, double dx, double dy) const +bool Ship::HotSpotCollision(LineSegment& l, double dx, double dy) const { for (int i = 0; i < NUM_HOTSPOTS; i++) { if (CheckCollision(l, dx + points[i].x, dy + points[i].y)) @@ -209,7 +209,7 @@ bool Ship::BoxCollision(int x, int y, int w, int h) const // // Checks for collision between the ship and a line segment. // -bool Ship::CheckCollision(LineSegment &l, double dx, double dy) const +bool Ship::CheckCollision(LineSegment& l, double dx, double dy) const { double xpos = this->xpos + dx; double ypos = this->ypos + dy; diff --git a/src/Ship.hpp b/src/Ship.hpp index 37e60b3..c1b19a7 100644 --- a/src/Ship.hpp +++ b/src/Ship.hpp @@ -27,7 +27,7 @@ class Ship { public: - Ship(Viewport *v); + Ship(Viewport* v); void Reset(); @@ -44,8 +44,8 @@ public: void ApplyGravity(double gravity); void CentreInViewport(); - bool CheckCollision(LineSegment &l, double dx=0, double dy=0) const; - bool HotSpotCollision(LineSegment &l, double dx=0, double dy=0) const; + bool CheckCollision(LineSegment& l, double dx=0, double dy=0) const; + bool HotSpotCollision(LineSegment& l, double dx=0, double dy=0) const; bool BoxCollision(int x, int y, int w, int h) const; double GetX() const { return xpos; } @@ -57,7 +57,7 @@ public: static const int SHIP_START_Y = 100; private: - void RotatePoints(const Point *pPoints, Point *pDest, int nCount, + void RotatePoints(const Point* pPoints, Point* pDest, int nCount, double angle, int adjustx=0, int adjusty=0); Image shipImage; @@ -65,7 +65,7 @@ private: double xpos, ypos; double speedX, speedY, angle; - Viewport *viewport; + Viewport* viewport; Explosion explosion; SmokeTrail exhaust; bool thrusting; diff --git a/src/SoundEffect.cpp b/src/SoundEffect.cpp index c621cf1..7d84670 100644 --- a/src/SoundEffect.cpp +++ b/src/SoundEffect.cpp @@ -25,7 +25,7 @@ int SoundEffect::audioBuffers(4096); Uint16 SoundEffect::audioFormat(AUDIO_S16); bool SoundEffect::enabled(true); -SoundEffect::SoundEffect(const char *filename) +SoundEffect::SoundEffect(const char* filename) : sound(NULL), channel(-1) { if (++loadCount == 1) { diff --git a/src/SoundEffect.hpp b/src/SoundEffect.hpp index 01335e4..51c2d7b 100644 --- a/src/SoundEffect.hpp +++ b/src/SoundEffect.hpp @@ -24,14 +24,14 @@ class SoundEffect { public: - SoundEffect(const char *filename); + SoundEffect(const char* filename); ~SoundEffect(); static void SetEnabled(bool state) { enabled = state; } void Play(); private: - Mix_Chunk *sound; + Mix_Chunk* sound; int channel; static int loadCount; diff --git a/src/Surface.cpp b/src/Surface.cpp index 8b8e0a9..c90738f 100644 --- a/src/Surface.cpp +++ b/src/Surface.cpp @@ -23,9 +23,9 @@ const int Surface::MAX_SURFACE_HEIGHT(300); const int Surface::MIN_SURFACE_HEIGHT(10); const int Surface::SURFACE_SIZE(20); -Texture *Surface::surfTexture[Surface::NUM_SURF_TEX]; +Texture* Surface::surfTexture[Surface::NUM_SURF_TEX]; -Surface::Surface(Viewport *v) +Surface::Surface(Viewport* v) : viewport(v), surface(NULL) { LOAD_ONCE { @@ -42,7 +42,7 @@ Surface::~Surface() delete[] surface; } -void Surface::Generate(int surftex, LandingPadList &pads) +void Surface::Generate(int surftex, LandingPadList& pads) { if (surface) delete[] surface; @@ -63,7 +63,7 @@ void Surface::Generate(int surftex, LandingPadList &pads) surface[i].points[0].y = MAX_SURFACE_HEIGHT; // See if we want to place a landing pad here - LandingPad *padHere = NULL; + LandingPad* padHere = NULL; for (LandingPadListIt it = pads.begin(); it != pads.end(); ++it) { for (int k = 0; k < (*it).GetLength(); k++) { if ((*it).GetIndex() + k == i) { @@ -149,7 +149,7 @@ void Surface::Display() // Returns true if ship has collided with surface. Sets padIndex to the index // of pad if the player hit it, -1 otherwise. // -bool Surface::CheckCollisions(Ship &ship, LandingPadList &pads, int *padIndex) +bool Surface::CheckCollisions(Ship& ship, LandingPadList& pads, int* padIndex) { LineSegment l; int lookmin = (int)(ship.GetX()/SURFACE_SIZE) - 2; @@ -176,7 +176,7 @@ bool Surface::CheckCollisions(Ship &ship, LandingPadList &pads, int *padIndex) for (LandingPadListIt it = pads.begin(); it != pads.end(); ++it, ++j) { - LandingPad &pad = *it; + LandingPad& pad = *it; for (int m = 0; m < pad.GetLength(); m++) { if (pad.GetIndex() + m == i) { // Hit a landing pad diff --git a/src/Surface.hpp b/src/Surface.hpp index bcbb90d..dea36d8 100644 --- a/src/Surface.hpp +++ b/src/Surface.hpp @@ -26,11 +26,11 @@ class Surface { public: - Surface(Viewport *v); + Surface(Viewport* v); ~Surface(); - void Generate(int surftex, LandingPadList &pads); - bool CheckCollisions(Ship &ship, LandingPadList &pads, int *padIndex); + void Generate(int surftex, LandingPadList& pads); + bool CheckCollisions(Ship& ship, LandingPadList& pads, int* padIndex); void Display(); static const int NUM_SURF_TEX = 4; // Number of available surface textures @@ -40,16 +40,16 @@ public: static const int VARIANCE; private: - static Texture *surfTexture[NUM_SURF_TEX]; + static Texture* surfTexture[NUM_SURF_TEX]; int texidx; - Viewport *viewport; + Viewport* viewport; struct SurfaceSection { double texX, texwidth; Point points[4]; }; - SurfaceSection *surface; + SurfaceSection* surface; }; #endif diff --git a/src/Texture.cpp b/src/Texture.cpp index 0aad3f2..1929f90 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -20,9 +20,9 @@ #include -Texture::Texture(const char *file) +Texture::Texture(const char* file) { - SDL_Surface *surface = IMG_Load(LocateResource(file)); + SDL_Surface* surface = IMG_Load(LocateResource(file)); if (NULL == surface) { ostringstream os; os << "Failed to load image: " << IMG_GetError(); diff --git a/src/Texture.hpp b/src/Texture.hpp index 8bc09f0..f6baa91 100644 --- a/src/Texture.hpp +++ b/src/Texture.hpp @@ -22,7 +22,7 @@ class Texture { public: - Texture(const char *file); + Texture(const char* file); virtual ~Texture(); GLuint GetGLTexture() const { return texture; } -- 2.39.2