From cdc8f648962daa24d16da30b9b767c303cdbc4cb Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 27 Apr 2017 23:08:06 -0400 Subject: [PATCH] fix clang compile warnings, fixes #406 also, sim.ambientAirTemp takes floats now --- src/Config.h | 2 -- src/debug/ParticleDebug.cpp | 2 +- src/gui/game/GameController.cpp | 6 +++--- src/gui/game/GameView.cpp | 5 ++--- src/gui/interface/ContextMenu.cpp | 4 ++-- src/gui/interface/ContextMenu.h | 3 +-- src/gui/preview/PreviewController.cpp | 2 ++ src/gui/profile/ProfileActivity.cpp | 4 +--- src/lua/LuaScriptInterface.cpp | 2 +- src/lua/TPTSTypes.h | 5 +---- src/lua/TPTScriptInterface.cpp | 4 ++-- src/resampler/resampler.cpp | 2 +- src/simulation/Simulation.cpp | 6 ++---- 13 files changed, 19 insertions(+), 28 deletions(-) diff --git a/src/Config.h b/src/Config.h index 7b4d0da426..906f14d4a6 100644 --- a/src/Config.h +++ b/src/Config.h @@ -180,8 +180,6 @@ #if defined(_MSC_VER) #define TPT_INLINE _inline -#elif defined(__llvm__) -#define TPT_INLINE #else #define TPT_INLINE inline #endif diff --git a/src/debug/ParticleDebug.cpp b/src/debug/ParticleDebug.cpp index 6583626b8f..8155f87da1 100644 --- a/src/debug/ParticleDebug.cpp +++ b/src/debug/ParticleDebug.cpp @@ -15,7 +15,7 @@ ParticleDebug::ParticleDebug(unsigned int id, Simulation * sim, GameModel * mode void ParticleDebug::Debug(int mode, int x, int y) { int debug_currentParticle = sim->debug_currentParticle; - int i; + int i = 0; std::stringstream logmessage; if (mode == 0) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index e108001105..5548061ac0 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -1507,9 +1507,9 @@ std::string GameController::ElementResolve(int type, int ctype) { if(gameModel && gameModel->GetSimulation()) { - if (type == PT_LIFE && ctype >= 0 && ctype < NGOL && gameModel->GetSimulation()->gmenu) + if (type == PT_LIFE && ctype >= 0 && ctype < NGOL) return gameModel->GetSimulation()->gmenu[ctype].name; - else if (type >= 0 && type < PT_NUM && gameModel->GetSimulation()->elements) + else if (type >= 0 && type < PT_NUM) return std::string(gameModel->GetSimulation()->elements[type].Name); } return ""; @@ -1527,7 +1527,7 @@ bool GameController::IsValidElement(int type) std::string GameController::WallName(int type) { - if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0 && type < UI_WALLCOUNT) + if(gameModel && gameModel->GetSimulation() && type >= 0 && type < UI_WALLCOUNT) return std::string(gameModel->GetSimulation()->wtypes[type].name); else return ""; diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 1023f58976..ff97c4d809 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -1861,10 +1861,9 @@ void GameView::NotifyNotificationsChanged(GameModel * sender) { class NotificationButtonAction : public ui::ButtonAction { - GameView * v; Notification * notification; public: - NotificationButtonAction(GameView * v, Notification * notification) : v(v), notification(notification) { } + NotificationButtonAction(Notification * notification) : notification(notification) { } void ActionCallback(ui::Button * sender) { notification->Action(); @@ -1901,7 +1900,7 @@ void GameView::NotifyNotificationsChanged(GameModel * sender) { int width = (Graphics::textwidth((*iter)->Message.c_str()))+8; ui::Button * tempButton = new ui::Button(ui::Point(XRES-width-22, currentY), ui::Point(width, 15), (*iter)->Message); - tempButton->SetActionCallback(new NotificationButtonAction(this, *iter)); + tempButton->SetActionCallback(new NotificationButtonAction(*iter)); tempButton->Appearance.BorderInactive = style::Colour::WarningTitle; tempButton->Appearance.TextInactive = style::Colour::WarningTitle; tempButton->Appearance.BorderHover = ui::Colour(255, 175, 0); diff --git a/src/gui/interface/ContextMenu.cpp b/src/gui/interface/ContextMenu.cpp index 9efd4834cf..7dfa207159 100644 --- a/src/gui/interface/ContextMenu.cpp +++ b/src/gui/interface/ContextMenu.cpp @@ -11,7 +11,7 @@ class ContextMenu::ItemSelectedAction: public ButtonAction ItemSelectedAction(ContextMenu * window, int itemID): window(window), item(itemID) { } virtual void ActionCallback(ui::Button *sender) { - window->ActionCallback(sender, item); + window->ActionCallbackItem(sender, item); } }; @@ -55,7 +55,7 @@ void ContextMenu::Show(ui::Point position) ui::Engine::Ref().ShowWindow(this); } -void ContextMenu::ActionCallback(ui::Button *sender, int item) +void ContextMenu::ActionCallbackItem(ui::Button *sender, int item) { ui::Engine::Ref().CloseWindow(); Halt(); diff --git a/src/gui/interface/ContextMenu.h b/src/gui/interface/ContextMenu.h index bbb1ef59f8..0a77e07a40 100644 --- a/src/gui/interface/ContextMenu.h +++ b/src/gui/interface/ContextMenu.h @@ -20,13 +20,12 @@ class ContextMenuItem class ContextMenu: public ui::Window, public ButtonAction { std::vector buttons; std::vector items; - bool isMouseInside; ui::Component * source; public: ui::Appearance Appearance; class ItemSelectedAction; ContextMenu(Component * source); - virtual void ActionCallback(ui::Button *sender, int item); + virtual void ActionCallbackItem(ui::Button *sender, int item); virtual void AddItem(ContextMenuItem item); virtual void RemoveItem(int id); virtual void SetItem(int id, std::string text); diff --git a/src/gui/preview/PreviewController.cpp b/src/gui/preview/PreviewController.cpp index cb2bccd91f..4bd47d848e 100644 --- a/src/gui/preview/PreviewController.cpp +++ b/src/gui/preview/PreviewController.cpp @@ -32,6 +32,7 @@ PreviewController::PreviewController(int saveID, int saveDate, bool instant, Con Client::Ref().AddListener(this); this->callback = callback; + (void)saveDate; //pretend this is used } PreviewController::PreviewController(int saveID, bool instant, ControllerCallback * callback): @@ -55,6 +56,7 @@ PreviewController::PreviewController(int saveID, bool instant, ControllerCallbac Client::Ref().AddListener(this); this->callback = callback; + (void)saveDate; //pretend this is used } void PreviewController::Update() diff --git a/src/gui/profile/ProfileActivity.cpp b/src/gui/profile/ProfileActivity.cpp index 1bfe72bb4b..793a432590 100644 --- a/src/gui/profile/ProfileActivity.cpp +++ b/src/gui/profile/ProfileActivity.cpp @@ -76,9 +76,7 @@ void ProfileActivity::setUserInfo(UserInfo newInfo) { class EditAvatarAction: public ui::ButtonAction { - ProfileActivity * a; public: - EditAvatarAction(ProfileActivity * a) : a(a) { } void ActionCallback(ui::Button * sender_) { Platform::OpenURI("http://" SERVER "/Profile/Avatar.html"); @@ -112,7 +110,7 @@ void ProfileActivity::setUserInfo(UserInfo newInfo) if (editable) { ui::Button * editAvatar = new ui::Button(ui::Point(Size.X - (40 + 16 + 75), currentY), ui::Point(75, 15), "Edit Avatar"); - editAvatar->SetActionCallback(new EditAvatarAction(this)); + editAvatar->SetActionCallback(new EditAvatarAction()); scrollPanel->AddChild(editAvatar); } currentY += 23; diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 08f9bee280..a05aa0dd9d 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -1849,7 +1849,7 @@ int LuaScriptInterface::simulation_ambientAirTemp(lua_State * l) lua_pushnumber(l, luacon_sim->air->ambientAirTemp); return 1; } - int ambientAirTemp = luaL_optint(l, 1, 295.15f); + float ambientAirTemp = luaL_optnumber(l, 1, 295.15f); luacon_sim->air->ambientAirTemp = ambientAirTemp; return 0; } diff --git a/src/lua/TPTSTypes.h b/src/lua/TPTSTypes.h index 1f58e56ad2..12f34d8122 100644 --- a/src/lua/TPTSTypes.h +++ b/src/lua/TPTSTypes.h @@ -85,12 +85,9 @@ class AnyType class InvalidConversionException: public GeneralException { -private: - ValueType from; - ValueType to; public: InvalidConversionException(ValueType from_, ValueType to_): - GeneralException("Invalid conversion from " + AnyType::TypeName(from_) + " to " + AnyType::TypeName(to_)), from(from_), to(to_) { + GeneralException("Invalid conversion from " + AnyType::TypeName(from_) + " to " + AnyType::TypeName(to_)) { } }; diff --git a/src/lua/TPTScriptInterface.cpp b/src/lua/TPTScriptInterface.cpp index 98f66ab5b6..bf09543c8b 100644 --- a/src/lua/TPTScriptInterface.cpp +++ b/src/lua/TPTScriptInterface.cpp @@ -20,7 +20,7 @@ int TPTScriptInterface::Command(std::string command) lastError = ""; std::deque words; std::deque commandWords; - int retCode; + int retCode = -1; //Split command into words, put them on the stack char * rawCommand; @@ -382,7 +382,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque * words) } else if(selector.GetType() == TypeString || selector.GetType() == TypeNumber) { - int type; + int type = 0; if (selector.GetType() == TypeNumber) type = ((NumberType)selector).Value(); else if (selector.GetType() == TypeString) diff --git a/src/resampler/resampler.cpp b/src/resampler/resampler.cpp index 22833dd4f0..50826445e2 100644 --- a/src/resampler/resampler.cpp +++ b/src/resampler/resampler.cpp @@ -339,7 +339,7 @@ static double bessel0(double x) return sum; } -static const Resample_Real KAISER_ALPHA = 4.0; +//static const Resample_Real KAISER_ALPHA = 4.0; static double kaiser(double alpha, double half_width, double x) { const double ratio = (x / half_width); diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 80f61cc470..1aa70709df 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1970,10 +1970,8 @@ void Simulation::clear_sim(void) pfree = 0; parts_lastActiveIndex = 0; memset(pmap, 0, sizeof(pmap)); - if(fvx) - memset(fvx, 0, sizeof(fvx)); - if(fvy) - memset(fvy, 0, sizeof(fvy)); + memset(fvx, 0, sizeof(fvx)); + memset(fvy, 0, sizeof(fvy)); memset(photons, 0, sizeof(photons)); memset(wireless, 0, sizeof(wireless)); memset(gol2, 0, sizeof(gol2));