Skip to content

Commit

Permalink
fix clang compile warnings, fixes #406
Browse files Browse the repository at this point in the history
also, sim.ambientAirTemp takes floats now
  • Loading branch information
jacob1 committed Apr 28, 2017
1 parent 8d492ef commit cdc8f64
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 28 deletions.
2 changes: 0 additions & 2 deletions src/Config.h
Expand Up @@ -180,8 +180,6 @@

#if defined(_MSC_VER)
#define TPT_INLINE _inline
#elif defined(__llvm__)
#define TPT_INLINE
#else
#define TPT_INLINE inline
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/debug/ParticleDebug.cpp
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/gui/game/GameController.cpp
Expand Up @@ -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 "";
Expand All @@ -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 "";
Expand Down
5 changes: 2 additions & 3 deletions src/gui/game/GameView.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/interface/ContextMenu.cpp
Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/gui/interface/ContextMenu.h
Expand Up @@ -20,13 +20,12 @@ class ContextMenuItem
class ContextMenu: public ui::Window, public ButtonAction {
std::vector<Button*> buttons;
std::vector<ContextMenuItem> 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);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/preview/PreviewController.cpp
Expand Up @@ -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):
Expand All @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions src/gui/profile/ProfileActivity.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lua/LuaScriptInterface.cpp
Expand Up @@ -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;
}
Expand Down
5 changes: 1 addition & 4 deletions src/lua/TPTSTypes.h
Expand Up @@ -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_)) {
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/lua/TPTScriptInterface.cpp
Expand Up @@ -20,7 +20,7 @@ int TPTScriptInterface::Command(std::string command)
lastError = "";
std::deque<std::string> words;
std::deque<AnyType> commandWords;
int retCode;
int retCode = -1;

//Split command into words, put them on the stack
char * rawCommand;
Expand Down Expand Up @@ -382,7 +382,7 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * 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)
Expand Down
2 changes: 1 addition & 1 deletion src/resampler/resampler.cpp
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions src/simulation/Simulation.cpp
Expand Up @@ -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));
Expand Down

0 comments on commit cdc8f64

Please sign in to comment.