1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-20 05:19:29 +00:00

warning fixes, signed vs unsigned mismatch, cleanups, c++98 compat

many many more to do but it's a little step closer to get rid of warnings
This commit is contained in:
fgenesis 2024-04-16 00:12:56 +02:00
commit dd7ab0448f
45 changed files with 227 additions and 369 deletions

View file

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ActionInput.h"
#include "ActionMapper.h"
#include "Core.h"
#include "SDL.h"
#include <SDL.h>
#include "GameKeyNames.h"
#include "StringBank.h"
@ -64,7 +64,7 @@ static std::string inputcode2string(int k)
os << "AX:-" << (k - JOY_AXIS_0_NEG);
return os.str();
}
if(k >= JOY_HAT_BEGIN && k < JOY_HAT_END)
{
if(k >= JOY_HAT_0_LEFT && k < JOY_HAT_END_LEFT)
@ -113,13 +113,13 @@ static std::string inputcode2string(int k)
return std::string();
}
static const char *jaxisname(int joystickID, int axis)
static const char *jaxisname(size_t joystickID, int axis)
{
Joystick *j = core->getJoystick(joystickID);
return j ? j->getAxisName(axis) : NULL;
}
static const char *jbtnname(int joystickID, int btn)
static const char *jbtnname(size_t joystickID, int btn)
{
Joystick *j = core->getJoystick(joystickID);
return j ? j->getButtonName(btn) : NULL;

View file

@ -104,7 +104,7 @@ int ActionSet::_whichJoystickForName()
if(!joystickGUID.length() && !joystickName.length())
for(size_t i = 0; i < core->getNumJoysticks(); ++i)
if(Joystick *j = core->getJoystick(i))
return i;
return int(i);
return ACTIONSET_REASSIGN_JOYSTICK;
}

View file

@ -60,7 +60,7 @@ public:
ActionInput *getActionInputByName(const std::string &name);
InputDevice inputMode;
size_t joystickID; // >= 0: use that, -1 = no joystick, or ACTIONSET_REASSIGN_JOYSTICK
int joystickID; // >= 0: use that, -1 = no joystick, or ACTIONSET_REASSIGN_JOYSTICK
// --- Saved in config ---
ActionInputSet inputSet;

View file

@ -12,7 +12,7 @@ ActionButtonStatus::ActionButtonStatus()
void ActionButtonStatus::import(const ActionSet& as)
{
joystickID = as.joystickID;
joystickID = (int)as.joystickID;
unsigned char found[ACTION_BUTTON_ENUM_SIZE];
memset(found, 0, sizeof(found));
@ -29,7 +29,7 @@ void ActionButtonStatus::import(const ActionSet& as)
found[JOY_STICK_RIGHT] = 1;
found[JOY_STICK_UP] = 1;
found[JOY_STICK_DOWN]= 1;
toQuery.clear();
for(int k = 1; k < sizeof(found); ++k) // ignore [0]
if(found[k])

View file

@ -175,10 +175,10 @@ void AfterEffectManager::renderGrid(const RenderState& rs) const
{
if(firstShader < 0)
{
firstShader = i;
firstShader = int(i);
activeShader = shaderPipeline[i];
}
lastShader = i;
lastShader = int(i);
}
}
@ -220,10 +220,6 @@ void AfterEffectManager::renderGrid(const RenderState& rs) const
const FrameBuffer *fbIn = &core->frameBuffer;
const FrameBuffer *fbOut = &backupBuffer;
const float percentX = (float)screenWidth/(float)textureWidth;
const float percentY = (float)screenHeight/(float)textureHeight;
for(int i = firstShader + 1; i <= lastShader; ++i)
{
activeShader = shaderPipeline[i];

View file

@ -33,9 +33,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define compile_assert(pred) switch(0){case 0:case (pred):;}
// C++11's override specifier is too useful not to use it if we have it
#if (__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER+0 >= 1900))
#define OVERRIDE override
// C++11's override specifier is too useful not to use it if we have it.
// However, clang warns about it when -Wc++98-compat is active. Silence this here.
/*#if defined(__GNUC__) && (__cplusplus >= 201103L)
# define DO_PRAGMA(X) _Pragma(#X)
# define OVERRIDE DO_PRAGMA(GCC diagnostic push) DO_PRAGMA(GCC diagnostic ignored "-Wc++98-compat") override DO_PRAGMA(GCC diagnostic pop)
#endif*/
#ifndef OVERRIDE
# if (__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER+0 >= 1900))
# define OVERRIDE override
# endif
#endif
#ifndef OVERRIDE
@ -72,7 +81,7 @@ namespace internal
#pragma warning(disable:26812) // unscoped enum
//#pragma warning(disable:4706) // assignment within conditional expression
//#pragma warning(disable:4389) // signed/unsigned mismatch
#pragma warning(disable:4389) // signed/unsigned mismatch
//#pragma warning(disable:4189) // UqqqqSEFUL: local variable is initialized but not referenced
#endif

View file

@ -140,7 +140,7 @@ void BitmapText::formatText()
text = this->text;
lines.clear();
std::string currentLine;
int lastSpace = -1;
size_t lastSpace = size_t(-1);
float currentWidth = 0;
alignWidth = 0;
maxW = 0;
@ -157,7 +157,7 @@ void BitmapText::formatText()
lastSpace = i;
}
lines.push_back(text.substr(0, lastSpace));
int tsz = text.size();
size_t tsz = text.size();
text = text.substr(lastSpace+1, tsz);
i = 0;
alignWidth = currentWidth;

View file

@ -46,8 +46,6 @@ set(BBGE_SRCS
Image.h
Joystick.cpp
Joystick.h
LensFlare.cpp
LensFlare.h
Localization.cpp
Localization.h
MathFunctions.h

View file

@ -89,7 +89,7 @@ void DebugFont::formatText()
text = this->text;
lines.clear();
std::string currentLine;
int lastSpace = -1;
size_t lastSpace = size_t(-1);
float currentWidth = 0;
maxW = 0;
for (size_t i = 0; i < text.size(); i++)
@ -103,7 +103,7 @@ void DebugFont::formatText()
lastSpace = i;
}
lines.push_back(text.substr(0, lastSpace));
int tsz = text.size();
size_t tsz = text.size();
text = text.substr(lastSpace+1, tsz);
i = 0;
maxW = std::max(maxW, currentWidth);

View file

@ -162,7 +162,7 @@ void EventQueue::clear()
eventTimers.clear();
}
int EventQueue::getSize()
size_t EventQueue::getSize()
{
return eventTimers.size();
}

View file

@ -164,7 +164,7 @@ public:
void addEvent(const EventPtr &eventPtr, float t);
void update(float dt);
void clear();
int getSize();
size_t getSize();
private:
typedef std::list<EventTimer> EventTimers;

View file

@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <signal.h>
#endif
#include "SDL.h"
#include <SDL.h>
#include "Base.h"
#include "Core.h"
@ -532,7 +532,7 @@ size_t OggDecoder::mem_read(void *ptr, size_t size, size_t nmemb, void *datasour
{
OggDecoder *this_ = (OggDecoder *)datasource;
long to_read = size * nmemb;
long to_read = (long)(size * nmemb);
if (to_read > this_->data_size - this_->data_pos)
to_read = this_->data_size - this_->data_pos;
if (to_read < 0)
@ -623,7 +623,7 @@ public:
OpenALSound(ALuint _bid, const bool _looping); // ctor for raw samples already assigned an opanAL buffer ID
VFILE *getFile() const { return fp; }
const void *getData() const { return data; }
long getSize() const { return size; }
long getSize() const { return (long)size; }
bool isLooping() const { return looping; }
bool isRaw() const { return raw; }
FMOD_RESULT release();

View file

@ -1,7 +1,7 @@
#ifndef BBGE_GAME_KEYS_H
#define BBGE_GAME_KEYS_H
#include <SDL_version.h>
#include <SDL.h>
#if SDL_VERSION_ATLEAST(2,0,0)

View file

@ -10,7 +10,7 @@ bool pngSaveRGBA(const char *filename, size_t width, size_t height, unsigned cha
{
const int oldlevel = stbi_write_png_compression_level;
stbi_write_png_compression_level = compressLevel; // HACK: ugly API but what can you do
bool ok = !!stbi_write_png(filename, (int)width, (int)height, 4, data, width * 4);
bool ok = !!stbi_write_png(filename, (int)width, (int)height, 4, data, (int)(width * 4));
stbi_write_png_compression_level = oldlevel;
return ok;
}
@ -27,7 +27,7 @@ bool zgaSaveRGBA(const char *filename, size_t w, size_t h, unsigned char *data)
ByteBuffer::uint8 type ,mode,aux, pixelDepth = 32;
ByteBuffer::uint8 cGarbage = 0;
ByteBuffer::uint16 iGarbage = 0;
ByteBuffer::uint16 width = w, height = h;
ByteBuffer::uint16 width = (ByteBuffer::uint16)w, height = (ByteBuffer::uint16)h;
// open file and check for errors
FILE *file = fopen(filename, "wb");
@ -131,7 +131,7 @@ ImageData imageLoadZGA(const char *filename)
if(buf)
{
int x = 0, y = 0, comp = 0;
stbi_uc *pix = stbi_load_from_memory((stbi_uc*)buf, size, &x, &y, &comp, 0);
stbi_uc *pix = stbi_load_from_memory((stbi_uc*)buf, (int)size, &x, &y, &comp, 0);
delete [] buf;
ret.pixels = pix;
ret.channels = comp;
@ -149,7 +149,7 @@ ImageData imageLoadQOI(const char* filename, bool forceRGBA)
if(buf)
{
qoi_desc d;
stbi_uc *pix = (stbi_uc*)qoi_decode(buf, size, &d, forceRGBA ? 4 : 0);
stbi_uc *pix = (stbi_uc*)qoi_decode(buf, (int)size, &d, forceRGBA ? 4 : 0);
if(pix)
{
ret.w = d.width;

View file

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Joystick.h"
#include "Core.h"
#include "SDL.h"
#include <SDL.h>
unsigned Joystick::GetNumJoysticks()
{
@ -140,11 +140,11 @@ bool Joystick::init(int stick)
numHats = SDL_JoystickNumHats(sdl_joy);
numButtons = SDL_JoystickNumButtons(sdl_joy);
return true;
}
std::ostringstream os;
os << "Failed to init Joystick [" << stick << "]";
debugLog(os.str());

View file

@ -2,8 +2,7 @@
#define BBGE_JOYSTICK_H
#include <string>
#include <SDL_joystick.h>
#include <SDL_version.h>
#include <SDL.h>
#if SDL_VERSION_ATLEAST(2,0,0)
#include <SDL_gamecontroller.h>

View file

@ -1,65 +0,0 @@
/*
Copyright (C) 2007, 2010 - Bit-Blot
This file is part of Aquaria.
Aquaria is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
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.
*/
#include "LensFlare.h"
#include "Core.h"
LensFlare::LensFlare()
{
cull = false;
inc = 0.5;
maxLen = 1500;
}
void LensFlare::addFlare(const std::string &tex, Vector color, int w, int h)
{
Quad *q = new Quad(tex, Vector(0,0,0));
q->color = color;
q->setBlendType(BLEND_ADD);
if (w != -1)
q->setWidth(w);
if (h != -1)
q->setHeight(h);
flares.push_back(q);
addChild(q, PM_POINTER);
}
void LensFlare::onUpdate(float dt)
{
RenderObject::onUpdate(dt);
Vector v = core->screenCenter - this->position;
if (v.getSquaredLength2D() > sqr(maxLen))
return;
else
{
float l = v.getLength2D();
float a = 1.0f-(l/(float)maxLen);
a*=0.8f;
Vector vbit = v;
vbit *= inc;
for (size_t i = 0; i < flares.size(); i++)
{
flares[i]->position = vbit*i;
flares[i]->alpha = a;
}
}
}

View file

@ -1,39 +0,0 @@
/*
Copyright (C) 2007, 2010 - Bit-Blot
This file is part of Aquaria.
Aquaria is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
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 LENSFLARE_H
#define LENSFLARE_H
#include "Quad.h"
// 2D lens flare
class LensFlare : public RenderObject
{
public:
LensFlare();
void addFlare(const std::string &tex, Vector color=Vector(1,1,1), int w=-1, int h=-1);
float inc;
int maxLen;
protected:
void onUpdate(float dt);
std::vector <Quad*> flares;
};
#endif

View file

@ -1,5 +1,5 @@
#include "MT.h"
#include "SDL.h"
#include <SDL.h>
// --------- Lockable ----------

View file

@ -48,8 +48,8 @@ static std::string _CFToStdString(CFStringRef cs)
#include "ttvfs.h"
#endif
#include "SDL.h"
#include "SDL_syswm.h"
#include <SDL.h>
#include <SDL_syswm.h>
#ifdef BBGE_BUILD_WINDOWS
static HICON icon_windows = 0;
@ -269,7 +269,7 @@ void forEachFile(const std::string& inpath, std::string type, void callback(cons
TCHAR szDir[MAX_PATH+1];
WIN32_FIND_DATA FileData;
int end = path.size()-1;
size_t end = path.size()-1;
if (path[end] != '/')
path[end] += '/';

View file

@ -77,7 +77,7 @@ void Precacher::_precacheTex(const std::string &tex)
static void texLoadProgressCallback(size_t done, void *ud)
{
Precacher::ProgressCallback cb = (Precacher::ProgressCallback)(ud);
Precacher::ProgressCallback cb = reinterpret_cast<Precacher::ProgressCallback>(ud);
cb();
}
@ -90,7 +90,7 @@ void Precacher::doCache(ProgressCallback progress)
debugLog(os.str());
std::vector<Texture*> tmp(todo.size());
core->texmgr.loadBatch(&tmp[0], &todo[0], todo.size(), TextureMgr::KEEP,
progress ? texLoadProgressCallback : NULL, (void*)progress);
progress ? texLoadProgressCallback : NULL, reinterpret_cast<void*>(progress));
todo.clear();
texkeep.reserve(texkeep.size() + tmp.size());
for(size_t i = 0; i < tmp.size(); ++i)

View file

@ -1,7 +1,7 @@
#ifndef BBGE_RENDERBASE_H
#define BBGE_RENDERBASE_H
#include "SDL.h"
#include <SDL.h>
// Define this before including GL headers to avoid pulling in windows.h
#if defined(_WIN32) && !defined(APIENTRY)

View file

@ -22,7 +22,7 @@ enum GridType
GRID_UNDEFINED = 0,
GRID_WAVY = 1,
GRID_STRIP = 2, // quad is in strip mode
GRID_INTERP = 3, // quad is in grid mode
GRID_INTERP = 3 // quad is in grid mode
};
// simple render grid, must be manually uploaded to GPU if changed

View file

@ -76,7 +76,7 @@ class StateManager
public:
friend class StateObject;
StateManager();
~StateManager();
virtual ~StateManager();
void clearStateObjects();

View file

@ -12,7 +12,7 @@ enum StringBankIndexBBGE
SB_BBGE_INVALID_JOY_BTN = 2155,
SB_BBGE_INVALID_MOUSE_BTN = 2156,
SB_BBGE_INVALID_JOY_AXIS_POS = 2157,
SB_BBGE_INVALID_JOY_AXIS_NEG = 2158,
SB_BBGE_INVALID_JOY_AXIS_NEG = 2158
};
class StringBank

View file

@ -27,7 +27,7 @@ public:
{
KEEP, // if already exists, keep unchanged
KEEP_IF_SAME, // load if we resolve to a different file than the texture that's already there, if any.
OVERWRITE, // always overwrite
OVERWRITE // always overwrite
};
size_t loadBatch(Texture *pdst[], const std::string texnames[], size_t n, LoadMode mode = KEEP, ProgressCallback cb = 0, void *cbUD = 0);

View file

@ -106,4 +106,4 @@ private:
};
#endif // BBGE_VERTEXBUFFER_H
#endif // BBGE_VERTEXBUFFER_H