From 9245bee71793e62ec7fdc6404fa5b11e09ef0916 Mon Sep 17 00:00:00 2001 From: Valentin Ochs Date: Fri, 20 Jan 2017 04:51:38 +0100 Subject: [PATCH] Fix some warnings mostly sign-related, but also some about commas after the last item in an enum list, usage of default in switches, implicit or old-style casts --- Aquaria/AquariaComboBox.cpp | 16 +++++++------ Aquaria/AquariaCompileConfig.h | 4 ++-- Aquaria/AquariaMenuItem.cpp | 13 ++++++----- Aquaria/AquariaMenuItem.h | 16 ++++++------- Aquaria/AquariaProgressBar.cpp | 8 +++---- Aquaria/AquariaProgressBar.h | 2 +- Aquaria/Continuity.cpp | 39 ++++++++++++++++---------------- Aquaria/DSQ.h | 10 ++++---- Aquaria/Damage.h | 2 +- Aquaria/GameEnums.h | 2 +- Aquaria/Mod.h | 2 +- Aquaria/Segmented.h | 2 +- BBGE/ActionInput.cpp | 2 +- BBGE/ActionInput.h | 8 +++---- BBGE/ActionSet.h | 4 ++-- BBGE/AfterEffect.h | 2 +- BBGE/BBGECompileConfig.h | 4 ++-- BBGE/BaseText.h | 2 +- BBGE/BitmapFont.cpp | 2 +- BBGE/BitmapFont.h | 2 +- BBGE/Core.cpp | 2 +- BBGE/Core.h | 16 ++++++------- BBGE/DebugFont.h | 2 +- BBGE/Event.h | 4 ++-- BBGE/Joystick.h | 2 +- BBGE/MemoryAllocatorSmallBlock.h | 4 ++-- BBGE/ParticleManager.cpp | 2 +- BBGE/Particles.h | 6 ++--- BBGE/Quad.h | 8 +++---- BBGE/RenderObject.h | 22 +++++++++--------- BBGE/SimpleIStringStream.h | 16 ++++++------- BBGE/SkeletalSprite.h | 6 ++--- BBGE/SoundManager.h | 4 ++-- BBGE/StateManager.h | 4 ++-- BBGE/TTFFont.cpp | 2 +- BBGE/TTFFont.h | 2 +- BBGE/Texture.h | 4 ++-- BBGE/Vector.h | 6 ++--- 38 files changed, 128 insertions(+), 126 deletions(-) diff --git a/Aquaria/AquariaComboBox.cpp b/Aquaria/AquariaComboBox.cpp index 28fd11c..611635c 100644 --- a/Aquaria/AquariaComboBox.cpp +++ b/Aquaria/AquariaComboBox.cpp @@ -67,7 +67,7 @@ AquariaComboBox::AquariaComboBox(Vector textscale) : RenderObject() this->textscale = textscale; } -void AquariaComboBox::enqueueSelectItem(int index) +void AquariaComboBox::enqueueSelectItem(size_t index) { enqueuedSelectItem = index; } @@ -97,7 +97,9 @@ void AquariaComboBox::doScroll(int t) else { scroll++; - if (scroll+numDrops > items.size()) scroll = (items.size()) - numDrops; + if (scroll+numDrops > items.size()) { + scroll = items.size() - numDrops; + } else { close(0); @@ -298,7 +300,7 @@ bool AquariaComboBox::setSelectedItem(const std::string &item) return false; } -void AquariaComboBox::setSelectedItem(int index) +void AquariaComboBox::setSelectedItem(size_t index) { if (isopen) close(); @@ -311,7 +313,7 @@ void AquariaComboBox::setSelectedItem(int index) { doScroll(0); } - else if((size_t)index < items.size()) + else if(index < items.size()) { selectedItem = index; selectedItemLabel->setText(items[index]); @@ -326,12 +328,12 @@ void AquariaComboBox::setSelectedItem(int index) } } -int AquariaComboBox::getSelectedItem() +size_t AquariaComboBox::getSelectedItem() { return selectedItem; } -int AquariaComboBox::addItem(const std::string &n) +size_t AquariaComboBox::addItem(const std::string &n) { items.push_back(n); @@ -346,7 +348,7 @@ int AquariaComboBox::addItem(const std::string &n) Vector unselectedColor(0.7f, 0.7f, 0.7f); Vector selectedColor(1,1,1); -AquariaComboBoxItem::AquariaComboBoxItem(const std::string &str, int idx, AquariaComboBox *combo, Vector textscale) : Quad() +AquariaComboBoxItem::AquariaComboBoxItem(const std::string &str, size_t idx, AquariaComboBox *combo, Vector textscale) : Quad() { this->combo = combo; index = idx; diff --git a/Aquaria/AquariaCompileConfig.h b/Aquaria/AquariaCompileConfig.h index 663ff5a..63cc3b9 100644 --- a/Aquaria/AquariaCompileConfig.h +++ b/Aquaria/AquariaCompileConfig.h @@ -1,5 +1,5 @@ -#ifndef __AQUARIA_COMPILE_CONFIG_H__ -#define __AQUARIA_COMPILE_CONFIG_H__ +#ifndef AQUARIA_COMPILE_CONFIG_H +#define AQUARIA_COMPILE_CONFIG_H // The settings below are also configurable with CMake. // Define BBGE_SKIP_CONFIG_HEADERS to use CMake-only configuration. diff --git a/Aquaria/AquariaMenuItem.cpp b/Aquaria/AquariaMenuItem.cpp index f18abb8..ab0a1d3 100644 --- a/Aquaria/AquariaMenuItem.cpp +++ b/Aquaria/AquariaMenuItem.cpp @@ -263,7 +263,7 @@ AquariaGuiElement *AquariaGuiElement::FindClosestTo(AquariaGuiElement *cur, Vect if (go) { - dist = (p1 - p2).getSquaredLength2D(); + dist = static_cast((p1 - p2).getSquaredLength2D()); if (smallDist == -1 || dist < smallDist) { @@ -576,7 +576,7 @@ void AquariaKeyConfig::onUpdate(float dt) inLoop = true; - int *k = 0; + unsigned int *k = 0; ActionInput *ai = 0; @@ -599,7 +599,8 @@ void AquariaKeyConfig::onUpdate(float dt) case INPUTSET_JOY: k = &ai->data.single.joy[inputIdx]; break; - default: + case INPUTSET_NONE: + case INPUTSET_OTHER: k = 0; break; } @@ -760,7 +761,7 @@ void AquariaKeyConfig::onUpdate(float dt) { bool clear = false; bool abort = false; - int ac = 0; + unsigned int ac = 0; if (core->getKeyState(KEY_DELETE) || core->getKeyState(KEY_BACKSPACE)) { while(core->getKeyState(KEY_DELETE) || core->getKeyState(KEY_BACKSPACE)) @@ -815,7 +816,7 @@ void AquariaKeyConfig::onUpdate(float dt) break; case INPUTSET_JOY: { - int ac = 0; + size_t ac = 0; bool clear = false; bool abort = false; if (core->getKeyState(KEY_DELETE) || core->getKeyState(KEY_BACKSPACE)) @@ -833,7 +834,7 @@ void AquariaKeyConfig::onUpdate(float dt) Joystick *j = core->getJoystick(as.joystickID); if(j) { - for (int i = 0; i < MAX_JOYSTICK_BTN; i++) + for (size_t i = 0; i < MAX_JOYSTICK_BTN; i++) if (j->getButton(i)) { ac = JOY_BUTTON_0 + i; diff --git a/Aquaria/AquariaMenuItem.h b/Aquaria/AquariaMenuItem.h index 81fb3cd..ebb8f36 100644 --- a/Aquaria/AquariaMenuItem.h +++ b/Aquaria/AquariaMenuItem.h @@ -202,12 +202,12 @@ class AquariaComboBoxItem : public Quad { friend class AquariaComboBox; public: - AquariaComboBoxItem(const std::string &str, int idx, AquariaComboBox *combo, Vector textscale); + AquariaComboBoxItem(const std::string &str, size_t idx, AquariaComboBox *combo, Vector textscale); protected: void onUpdate(float dt); - int index; + size_t index; AquariaComboBox *combo; BitmapText *label; @@ -218,13 +218,13 @@ class AquariaComboBox : public RenderObject { public: AquariaComboBox(Vector textscale = Vector(1, 1)); - int addItem(const std::string &n); + size_t addItem(const std::string &n); void open(float t=0.1f); void close(float t=0.1f); - void setSelectedItem(int index); + void setSelectedItem(size_t index); bool setSelectedItem(const std::string &item); - int getSelectedItem(); - void enqueueSelectItem(int index); + size_t getSelectedItem(); + void enqueueSelectItem(size_t index); void setScroll(size_t sc); std::string getSelectedItemString(); void doScroll(int dir); @@ -235,8 +235,8 @@ protected: size_t numDrops; bool mb, isopen; - int scroll; - int enqueuedSelectItem; + size_t scroll; + size_t enqueuedSelectItem; std::vector items; diff --git a/Aquaria/AquariaProgressBar.cpp b/Aquaria/AquariaProgressBar.cpp index 7d5d1ac..b9857f8 100644 --- a/Aquaria/AquariaProgressBar.cpp +++ b/Aquaria/AquariaProgressBar.cpp @@ -31,11 +31,11 @@ AquariaProgressBar::AquariaProgressBar() : RenderObject() followCamera = 1; } -void AquariaProgressBar::progress(float perc) +void AquariaProgressBar::progress(float addPerc) { - if (perc==0) - perc = 0.01f; - this->perc += perc; + if (addPerc==0) + addPerc = 0.01f; + this->perc += addPerc; spinner.rotation = Vector(0,0,this->perc*360); core->render(); core->showBuffer(); diff --git a/Aquaria/AquariaProgressBar.h b/Aquaria/AquariaProgressBar.h index be0a5ad..cf55e5c 100644 --- a/Aquaria/AquariaProgressBar.h +++ b/Aquaria/AquariaProgressBar.h @@ -28,7 +28,7 @@ class AquariaProgressBar : public RenderObject public: AquariaProgressBar(); - void progress(float perc=0); + void progress(float addPerc=0); protected: Quad spinner; diff --git a/Aquaria/Continuity.cpp b/Aquaria/Continuity.cpp index 33f6fd6..123f151 100644 --- a/Aquaria/Continuity.cpp +++ b/Aquaria/Continuity.cpp @@ -473,84 +473,83 @@ std::string Continuity::getIEString(IngredientData *data, size_t i) os << fabsf(fx.magnitude); return os.str(); } - break; + // break; case IET_MAXHP: return dsq->continuity.stringBank.get(201); - break; + // break; case IET_DEFENSE: os << dsq->continuity.stringBank.get(202); os << " " << fx.magnitude << " " << dsq->continuity.stringBank.get(205) << " " << defenseTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_SPEED: os << dsq->continuity.stringBank.get(204) << " " << fx.magnitude; os << " " << dsq->continuity.stringBank.get(205) << " " << speedTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_REGEN: os << dsq->continuity.stringBank.get(206) << " " << fx.magnitude; return os.str(); - break; + // break; case IET_TRIP: return dsq->continuity.stringBank.get(207); - break; + // break; case IET_EAT: return dsq->continuity.stringBank.get(208); - break; + // break; case IET_BITE: os << dsq->continuity.stringBank.get(209); os << " " << dsq->continuity.stringBank.get(205) << " " << biteTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_FISHPOISON: os << dsq->continuity.stringBank.get(217); os << " " << dsq->continuity.stringBank.get(205) << " " << fishPoisonTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_INVINCIBLE: os << dsq->continuity.stringBank.get(210); os << " " << dsq->continuity.stringBank.get(205) << " " << (fx.magnitude*5) << " " << dsq->continuity.stringBank.get(203); return os.str(); - - break; + // break; case IET_ENERGY: os << dsq->continuity.stringBank.get(211) << " " << fx.magnitude; os << " " << dsq->continuity.stringBank.get(205) << " " << energyTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_BLIND: return dsq->continuity.stringBank.get(212); - break; + // break; case IET_POISON: if (fx.magnitude < 0) return dsq->continuity.stringBank.get(213); else return dsq->continuity.stringBank.get(214); - break; + // break; case IET_YUM: return dsq->continuity.stringBank.get(215); - break; + // break; case IET_WEB: os << dsq->continuity.stringBank.get(219); os << " " << dsq->continuity.stringBank.get(205) << " " << webTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_ALLSTATUS: return dsq->continuity.stringBank.get(218); - break; + // break; case IET_PETPOWER: os << dsq->continuity.stringBank.get(216); os << " " << dsq->continuity.stringBank.get(205) << " " << petPowerTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_LIGHT: os << dsq->continuity.stringBank.get(220); os << " " << dsq->continuity.stringBank.get(205) << " " << lightTime << " " << dsq->continuity.stringBank.get(203); return os.str(); - break; + // break; case IET_LI: return dsq->continuity.stringBank.get(227); - break; + // break; case IET_SCRIPT: if(dsq->game->cookingScript) { diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index ae5d8fd..69c7f9e 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __dsq__ -#define __dsq__ +#ifndef DSQ_H +#define DSQ_H #include "AquariaCompileConfig.h" #include "../BBGE/Core.h" @@ -236,8 +236,8 @@ public: void addElement(Element *e); size_t getNumElements() const {return elements.size();} - Element *getElement(int idx) const {return elements[idx];} - Element *getFirstElementOnLayer(int layer) const {return layer<0 || layer>15 ? 0 : firstElementOnLayer[layer];} + Element *getElement(size_t idx) const {return elements[idx];} + Element *getFirstElementOnLayer(size_t layer) const {return layer>15 ? 0 : firstElementOnLayer[layer];} void clearElements(); // Used only by scene editor: void removeElement(size_t idx); @@ -527,7 +527,7 @@ protected: BitmapText *expText, *moneyText; - void clearMenu(float t = 0.01); + void clearMenu(float t = 0.01f); std::vector menu; BitmapText *saveSlotPageCount; diff --git a/Aquaria/Damage.h b/Aquaria/Damage.h index 7a87101..f88b044 100644 --- a/Aquaria/Damage.h +++ b/Aquaria/Damage.h @@ -24,7 +24,7 @@ enum DamageType DT_ENEMY_ACTIVEPOISON = 10, DT_ENEMY_CREATOR = 11, DT_ENEMY_MANTISBOMB = 12, - DT_ENEMY_REALMAX , + DT_ENEMY_REALMAX = 13, DT_ENEMY_MAX = 13, DT_AVATAR = 1000, diff --git a/Aquaria/GameEnums.h b/Aquaria/GameEnums.h index 63927e1..47423d9 100644 --- a/Aquaria/GameEnums.h +++ b/Aquaria/GameEnums.h @@ -141,7 +141,7 @@ enum AquariaActions ACTION_LOOK , ACTION_TOGGLEHELPSCREEN, ACTION_PLACE_AVATAR, - ACTION_SCREENSHOT, + ACTION_SCREENSHOT }; enum AuraType diff --git a/Aquaria/Mod.h b/Aquaria/Mod.h index ecb9532..fa72854 100644 --- a/Aquaria/Mod.h +++ b/Aquaria/Mod.h @@ -14,7 +14,7 @@ namespace tinyxml2 enum ModType { MODTYPE_MOD, - MODTYPE_PATCH, + MODTYPE_PATCH }; diff --git a/Aquaria/Segmented.h b/Aquaria/Segmented.h index 039a41d..31b90ca 100644 --- a/Aquaria/Segmented.h +++ b/Aquaria/Segmented.h @@ -38,7 +38,7 @@ protected: void initSegments(const Vector &position); void updateSegments(const Vector &position, bool reverse=false); void updateSegment(int i, const Vector &diff); - void destroySegments(float life = 0.01); + void destroySegments(float life = 0.01f); std::vector lastPositions; int numSegments; std::vector segments; diff --git a/BBGE/ActionInput.cpp b/BBGE/ActionInput.cpp index 281e78f..823c917 100644 --- a/BBGE/ActionInput.cpp +++ b/BBGE/ActionInput.cpp @@ -106,7 +106,7 @@ std::string getInputCodeToString(int k) return spacesToUnderscores(s); } -std::string getInputCodeToUserString(int k, int joystickID) +std::string getInputCodeToUserString(unsigned int k, size_t joystickID) { const char *pretty = NULL, *tail = NULL; diff --git a/BBGE/ActionInput.h b/BBGE/ActionInput.h index 4b99a97..57cb164 100644 --- a/BBGE/ActionInput.h +++ b/BBGE/ActionInput.h @@ -32,7 +32,7 @@ enum ActionInputSize }; std::string getInputCodeToString(int k); -std::string getInputCodeToUserString(int k, int joystickID); +std::string getInputCodeToUserString(unsigned int k, size_t joystickID); int getStringToInputCode(const std::string& s); class ActionInput @@ -46,9 +46,9 @@ public: { struct { - int mse[INP_MSESIZE]; - int key[INP_KEYSIZE]; - int joy[INP_JOYSIZE]; + unsigned int mse[INP_MSESIZE]; + unsigned int key[INP_KEYSIZE]; + unsigned int joy[INP_JOYSIZE]; } single; int all[INP_COMBINED_SIZE]; } data; diff --git a/BBGE/ActionSet.h b/BBGE/ActionSet.h index 49d9929..38d213a 100644 --- a/BBGE/ActionSet.h +++ b/BBGE/ActionSet.h @@ -37,7 +37,7 @@ const int ACTIONSET_REASSIGN_JOYSTICK = -2; struct JoystickConfig { JoystickConfig(); - int s1ax, s1ay, s2ax, s2ay; + unsigned int s1ax, s1ay, s2ax, s2ay; float s1dead, s2dead; }; @@ -59,7 +59,7 @@ public: ActionInput *addActionInput(const std::string &name); ActionInput *getActionInputByName(const std::string &name); - int joystickID; // >= 0: use that, -1 = no joystick, or ACTIONSET_REASSIGN_JOYSTICK + size_t joystickID; // >= 0: use that, -1 = no joystick, or ACTIONSET_REASSIGN_JOYSTICK // --- Saved in config --- ActionInputSet inputSet; diff --git a/BBGE/AfterEffect.h b/BBGE/AfterEffect.h index ce19869..d1536ad 100644 --- a/BBGE/AfterEffect.h +++ b/BBGE/AfterEffect.h @@ -29,7 +29,7 @@ class Effect { public: Effect(); - virtual ~Effect(){}; + virtual ~Effect(){} virtual void go(){} virtual void update(float dt, Vector ** drawGrid, int xDivs, int yDivs){} bool done; diff --git a/BBGE/BBGECompileConfig.h b/BBGE/BBGECompileConfig.h index 3bd88fc..0ecb6f2 100644 --- a/BBGE/BBGECompileConfig.h +++ b/BBGE/BBGECompileConfig.h @@ -1,5 +1,5 @@ -#ifndef __BBGE_COMPILE_CONFIG_H__ -#define __BBGE_COMPILE_CONFIG_H__ +#ifndef BBGE_COMPILE_CONFIG_H +#define BBGE_COMPILE_CONFIG_H #ifndef BBGE_SKIP_CONFIG_HEADERS diff --git a/BBGE/BaseText.h b/BBGE/BaseText.h index 5fc4d5f..0947cfa 100644 --- a/BBGE/BaseText.h +++ b/BBGE/BaseText.h @@ -14,7 +14,7 @@ public: virtual void setFontSize(float sz) = 0; virtual void setAlign(Align a) = 0; virtual float getLineHeight() = 0; - virtual int getNumLines() = 0; + virtual size_t getNumLines() = 0; virtual float getHeight() = 0; // total height virtual float getStringWidth(const std::string& text) = 0; // width of string when not auto-wrapped virtual float getActualWidth() = 0; // width of text after wrapping diff --git a/BBGE/BitmapFont.cpp b/BBGE/BitmapFont.cpp index 2735099..5145399 100644 --- a/BBGE/BitmapFont.cpp +++ b/BBGE/BitmapFont.cpp @@ -379,7 +379,7 @@ bool BitmapText::isScrollingText() return scrolling; } -int BitmapText::getNumLines() +size_t BitmapText::getNumLines() { return lines.size(); } diff --git a/BBGE/BitmapFont.h b/BBGE/BitmapFont.h index 7f3f450..2e88997 100644 --- a/BBGE/BitmapFont.h +++ b/BBGE/BitmapFont.h @@ -77,7 +77,7 @@ public: float getStringWidth(const std::string& text); float getActualWidth() { return maxW; } float getLineHeight(); - int getNumLines(); + size_t getNumLines(); protected: float scrollSpeed; diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index da8e920..f208d54 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -2840,7 +2840,7 @@ void Core::onJoystickRemoved(int instanceID) } } -Joystick *Core::getJoystick(int idx) +Joystick *Core::getJoystick(size_t idx) { size_t i = idx; return i < joysticks.size() ? joysticks[i] : NULL; diff --git a/BBGE/Core.h b/BBGE/Core.h index ab2ea95..40fe49b 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __core__ -#define __core__ +#ifndef CORE_H +#define CORE_H #include "Base.h" #include "RenderObject.h" @@ -139,8 +139,8 @@ public: RenderObject *getNext() { - const int size = renderObjects.size(); - int i; + const size_t size = renderObjects.size(); + size_t i; for (i = iter; i < size; i++) { if (renderObjects[i] != 0) @@ -322,8 +322,8 @@ public: - void setBaseTextureDirectory(const std::string &baseTextureDirectory) - { this->baseTextureDirectory = baseTextureDirectory; } + void setBaseTextureDirectory(const std::string &newBaseTextureDirectory) + { this->baseTextureDirectory = newBaseTextureDirectory; } std::string getBaseTextureDirectory() { return baseTextureDirectory; @@ -535,9 +535,9 @@ public: // inclusive! inline int getMaxActionStatusIndex() const { return int(actionStatus.size()) - 2; } // pass -1 for is a sentinel that captures all input - inline ActionButtonStatus *getActionStatus(int idx) { return actionStatus[idx + 1]; } + inline ActionButtonStatus *getActionStatus(size_t idx) { return actionStatus[idx + 1]; } - Joystick *getJoystick(int idx); // warning: may return NULL/contain holes + Joystick *getJoystick(size_t idx); // warning: may return NULL/contain holes // not the actual number of joysticks! size_t getNumJoysticks() const { return joysticks.size(); } Joystick *getJoystickForSourceID(int sourceID); diff --git a/BBGE/DebugFont.h b/BBGE/DebugFont.h index 6d86ded..b2a63cac 100644 --- a/BBGE/DebugFont.h +++ b/BBGE/DebugFont.h @@ -31,7 +31,7 @@ public: void setText(const std::string &text); void setWidth(float width); void setFontSize(float sz); - int getNumLines() { return lines.size(); } + size_t getNumLines() { return lines.size(); } virtual void setAlign(Align align); virtual float getHeight(); virtual float getLineHeight(); diff --git a/BBGE/Event.h b/BBGE/Event.h index 6330737..5cf91b6 100644 --- a/BBGE/Event.h +++ b/BBGE/Event.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __event__ -#define __event__ +#ifndef EVENT_H +#define EVENT_H #include diff --git a/BBGE/Joystick.h b/BBGE/Joystick.h index 60d39b3..b89fea0 100644 --- a/BBGE/Joystick.h +++ b/BBGE/Joystick.h @@ -34,7 +34,7 @@ public: void calibrate(Vector &vec, float dead); bool anyButton() const; - bool getButton(unsigned id) const { return !!(buttonBitmask & (1u << id)); } + bool getButton(size_t id) const { return !!(buttonBitmask & (1u << id)); } float getAxisUncalibrated(int id) const; int getNumAxes() const; int getIndex() const { return stickIndex; } diff --git a/BBGE/MemoryAllocatorSmallBlock.h b/BBGE/MemoryAllocatorSmallBlock.h index 0c31475..c0fe1a0 100644 --- a/BBGE/MemoryAllocatorSmallBlock.h +++ b/BBGE/MemoryAllocatorSmallBlock.h @@ -50,11 +50,11 @@ private: inline unsigned char *getPtr() { - return (unsigned char*)&bitmap[bitmapInts]; + return reinterpret_cast(&bitmap[bitmapInts]); } inline const unsigned char *getPtr() const { - return (unsigned char*)&bitmap[bitmapInts]; + return reinterpret_cast(&bitmap[bitmapInts]); } inline unsigned char *getEndPtr() { diff --git a/BBGE/ParticleManager.cpp b/BBGE/ParticleManager.cpp index b52932d..c3875ee 100644 --- a/BBGE/ParticleManager.cpp +++ b/BBGE/ParticleManager.cpp @@ -66,7 +66,7 @@ void ParticleManager::setSize(size_t size) free = oldFree = 0; } -void ParticleManager::setNumSuckPositions(int num) +void ParticleManager::setNumSuckPositions(size_t num) { suckPositions.resize(num); } diff --git a/BBGE/Particles.h b/BBGE/Particles.h index 08f2626..288864e 100644 --- a/BBGE/Particles.h +++ b/BBGE/Particles.h @@ -219,10 +219,10 @@ public: void setFree(size_t free); - int getFree() { return free; } - int getNumActive() { return numActive; } + size_t getFree() { return free; } + size_t getNumActive() { return numActive; } - void setNumSuckPositions(int num); + void setNumSuckPositions(size_t num); void setSuckPosition(size_t idx, const Vector &pos); Vector *getSuckPosition(size_t idx); diff --git a/BBGE/Quad.h b/BBGE/Quad.h index a443332..6404f1f 100644 --- a/BBGE/Quad.h +++ b/BBGE/Quad.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __quad__ -#define __quad__ +#ifndef QUAD_H +#define QUAD_H #include "RenderObject.h" @@ -55,8 +55,8 @@ public: void setWidthHeight(float w, float h=-1); void setWidth(float w); void setHeight(float h); - int getWidth() const {return int(width);} - int getHeight() const {return int(height);} + unsigned int getWidth() const {return static_cast(width);} + unsigned int getHeight() const {return static_cast(height);} void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo); void setDrawGridAlpha(size_t x, size_t y, float alpha); diff --git a/BBGE/RenderObject.h b/BBGE/RenderObject.h index b3f9927..38a78da 100644 --- a/BBGE/RenderObject.h +++ b/BBGE/RenderObject.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __render_object__ -#define __render_object__ +#ifndef RENDER_OBJECT_H +#define RENDER_OBJECT_H #include "Base.h" #include "Texture.h" @@ -91,7 +91,7 @@ public: void setStateDataObject(StateData *state); bool setTexture(const std::string &name); - void toggleAlpha(float t = 0.2); + void toggleAlpha(float t = 0.2f); virtual void update(float dt); bool isDead() const {return _dead;} @@ -109,15 +109,15 @@ public: // optimized rendering. void setStatic(bool staticFlag) {_static = staticFlag;} - void setLife(float life) + void setLife(float newlife) { - maxLife = this->life = life; + maxLife = this->life = newlife; } - void setDecayRate(float decayRate) + void setDecayRate(float newdecayRate) { - this->decayRate = decayRate; + this->decayRate = newdecayRate; } - void setBlendType (int bt) + void setBlendType (unsigned char bt) { blendType = bt; } @@ -136,13 +136,13 @@ public: bool isfvr(); size_t getIdx() const { return idx; } - void setIdx(size_t idx) { this->idx = idx; } + void setIdx(size_t newidx) { this->idx = newidx; } void moveToFront(); void moveToBack(); inline float getCullRadiusSqr() const { - if (overrideCullRadiusSqr) + if (overrideCullRadiusSqr != 0) return overrideCullRadiusSqr; if (width == 0 || height == 0) return 0; @@ -260,7 +260,7 @@ public: bool cull; float updateCull; - int layer; + size_t layer; InterpolatedVector *positionSnapTo; diff --git a/BBGE/SimpleIStringStream.h b/BBGE/SimpleIStringStream.h index 25aa210..7db9406 100644 --- a/BBGE/SimpleIStringStream.h +++ b/BBGE/SimpleIStringStream.h @@ -103,7 +103,7 @@ class SimpleIStringStream { /* Take over the passed-in string buffer, which must have been * allocated with new[]. The buffer will be deleted on object * destruction. */ - TAKE_OVER, + TAKE_OVER }; /*-------------------------------------------------------------------*/ @@ -227,7 +227,7 @@ class SimpleIStringStream { /* Is the given character a whitespace character? */ inline bool my_isspace(char c) const { return c==' ' || c=='\t' || c=='\r' || c=='\n' || c=='\v'; - }; + } /* Skip over leading whitespace. Assumes "position" is valid. */ inline void skip_spaces() { @@ -467,7 +467,7 @@ inline SimpleIStringStream &SimpleIStringStream::operator>>(short &target) target = 0; } else { skip_spaces(); - target = (short)strtol(position, &position, 0); + target = static_cast(strtol(position, &position, 0)); error = (position == old_position || *position == 0); } VERIFY(short, 0); @@ -486,7 +486,7 @@ inline SimpleIStringStream &SimpleIStringStream::operator>>(unsigned short &targ target = 0; } else { skip_spaces(); - target = (unsigned short)strtoul(position, &position, 0); + target = static_cast(strtoul(position, &position, 0)); error = (position == old_position || *position == 0); } VERIFY(unsigned short, 0); @@ -507,7 +507,7 @@ inline SimpleIStringStream &SimpleIStringStream::operator>>(int &target) target = 0; } else { skip_spaces(); - target = (int)strtol(position, &position, 0); + target = static_cast(strtol(position, &position, 0)); error = (position == old_position || *position == 0); } VERIFY(int, 0); @@ -526,7 +526,7 @@ inline SimpleIStringStream &SimpleIStringStream::operator>>(unsigned int &target target = 0; } else { skip_spaces(); - target = (unsigned int)strtoul(position, &position, 0); + target = static_cast(strtoul(position, &position, 0)); error = (position == old_position || *position == 0); } VERIFY(unsigned int, 0); @@ -678,7 +678,7 @@ inline SimpleIStringStream &SimpleIStringStream::operator>>(unsigned char &targe if (error) { target = 0; } else { - target = *position; + target = static_cast(*position); if (*position) { position++; error = (*position == 0); @@ -714,7 +714,7 @@ inline SimpleIStringStream &SimpleIStringStream::operator>>(std::string &target) while (*position && !my_isspace(*position)) { position++; } - target.assign(start, position - start); + target.assign(start, static_cast(position - start)); error = (*position == 0); } } diff --git a/BBGE/SkeletalSprite.h b/BBGE/SkeletalSprite.h index 18dc90a..241028a 100644 --- a/BBGE/SkeletalSprite.h +++ b/BBGE/SkeletalSprite.h @@ -35,7 +35,7 @@ enum AnimationCommand AC_SND_PLAY , AC_SEGS_STOP, AC_SET_PASS, - AC_RESET_PASS, + AC_RESET_PASS }; class ParticleEffect; @@ -257,13 +257,13 @@ public: std::vector animations; std::vector bones; - inline int getSelectedBoneIdx(void) { return selectedBone; } + inline size_t getSelectedBoneIdx(void) { return selectedBone; } void setSelectedBone(int b); void selectPrevBone(); void selectNextBone(); bool isLoaded(); - int getNumAnimLayers() const { return animLayers.size(); } + size_t getNumAnimLayers() const { return animLayers.size(); } AnimationLayer* getAnimationLayer(size_t l); size_t getBoneIdx(Bone *b); diff --git a/BBGE/SoundManager.h b/BBGE/SoundManager.h index 362e99c..dc16b9a 100644 --- a/BBGE/SoundManager.h +++ b/BBGE/SoundManager.h @@ -117,7 +117,7 @@ public: void clearLocalSounds(); - void setVoicePath2(const std::string &voicePath2) { this->voicePath2 = voicePath2; } + void setVoicePath2(const std::string &newVoicePath2) { this->voicePath2 = newVoicePath2; } SoundCore::Buffer loadLocalSound(const std::string &sound); SoundCore::Buffer loadSoundIntoBank(const std::string &filename, const std::string &path, const std::string &format, SoundLoadType = SFXLOAD_CACHE); @@ -156,7 +156,7 @@ public: void stopMusic(); void stopSfx(void *channel); - void fadeSfx(void *channel, SoundFadeType sft=SFT_OUT, float t=0.8); + void fadeSfx(void *channel, SoundFadeType sft=SFT_OUT, float t=0.8f); void fadeMusic(SoundFadeType sft=SFT_OUT, float t=1); diff --git a/BBGE/StateManager.h b/BBGE/StateManager.h index 50065d9..54e3c2c 100644 --- a/BBGE/StateManager.h +++ b/BBGE/StateManager.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __state_data__ -#define __state_data__ +#ifndef STATE_DATA_H +#define STATE_DATA_H #include "Base.h" #include diff --git a/BBGE/TTFFont.cpp b/BBGE/TTFFont.cpp index a80b801..7c89b79 100644 --- a/BBGE/TTFFont.cpp +++ b/BBGE/TTFFont.cpp @@ -110,7 +110,7 @@ void TTFText::updateAlign() } } -int TTFText::getNumLines() +size_t TTFText::getNumLines() { return (int)text.size(); } diff --git a/BBGE/TTFFont.h b/BBGE/TTFFont.h index 6295c9a..1822bd8 100644 --- a/BBGE/TTFFont.h +++ b/BBGE/TTFFont.h @@ -52,7 +52,7 @@ public: bool shadow; int findLine(const std::string &label); float getLineHeight(); - int getNumLines(); + size_t getNumLines(); protected: float width; float lineHeight; diff --git a/BBGE/Texture.h b/BBGE/Texture.h index 29d77a9..bef5f5a 100644 --- a/BBGE/Texture.h +++ b/BBGE/Texture.h @@ -18,8 +18,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __texture__ -#define __texture__ +#ifndef TEXTURE_H +#define TEXTURE_H #include #include "Refcounted.h" diff --git a/BBGE/Vector.h b/BBGE/Vector.h index 51a147a..539269f 100644 --- a/BBGE/Vector.h +++ b/BBGE/Vector.h @@ -227,11 +227,11 @@ public: // length of vector inline scalar_t getLength3D() const { - return (scalar_t)sqrtf(x*x + y*y + z*z); + return static_cast(sqrtf(x*x + y*y + z*z)); } inline scalar_t getLength2D() const { - return (scalar_t)sqrtf(x*x + y*y); + return static_cast(sqrtf(x*x + y*y)); } // return the unit vector @@ -376,7 +376,7 @@ public: void addPathNode(Vector v, float p); Vector getValue(float percent); size_t getNumPathNodes() { return pathNodes.size(); } - void resizePathNodes(int sz) { pathNodes.resize(sz); } + void resizePathNodes(size_t sz) { pathNodes.resize(sz); } VectorPathNode *getPathNode(size_t i) { if (i