1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-01-24 17:26:41 +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
parent ebf49310b3
commit dd7ab0448f
45 changed files with 227 additions and 369 deletions

View file

@ -162,7 +162,7 @@ void AquariaGuiElement::UpdateGlobalFocus(float dt)
Direction AquariaGuiElement::GetDirection()
{
Direction dir = DIR_NONE;
StateObject *obj = dsq->getTopStateObject(); // usually Game...
if (obj)
{
@ -787,7 +787,7 @@ void AquariaKeyConfig::onUpdate(float dt)
break;
case INPUTSET_JOY:
{
size_t ac = 0;
unsigned ac = 0;
bool clear = false;
bool abort = false;
if (core->getKeyState(KEY_DELETE) || core->getKeyState(KEY_BACKSPACE))
@ -805,7 +805,7 @@ void AquariaKeyConfig::onUpdate(float dt)
Joystick *j = core->getJoystick(as.joystickID);
if(j)
{
for (size_t i = 0; i < MAX_JOYSTICK_BTN; i++)
for (unsigned i = 0; i < MAX_JOYSTICK_BTN; i++)
if (j->getButton(i))
{
ac = JOY_BUTTON_0 + i;
@ -815,7 +815,7 @@ void AquariaKeyConfig::onUpdate(float dt)
}
if(!ac)
for(size_t i = 0; i < MAX_JOYSTICK_AXIS; ++i)
for(unsigned i = 0; i < MAX_JOYSTICK_AXIS; ++i)
{
float ax = j->getAxisUncalibrated(i);
if(fabsf(ax) > JOY_AXIS_THRESHOLD)
@ -828,7 +828,7 @@ void AquariaKeyConfig::onUpdate(float dt)
}
if(!ac)
for(size_t i = 0; i < MAX_JOYSTICK_HATS; ++i)
for(unsigned i = 0; i < MAX_JOYSTICK_HATS; ++i)
{
JoyHatDirection hd = j->getHat(i);
if(hd != JOY_HAT_DIR_CENTERED)

View file

@ -1515,42 +1515,26 @@ void DSQ::setStory()
continuity.setFlag(flag, value);
}
Vector DSQ::getNoteVector(int note, float mag)
static const Vector noteVectors[] =
{
Vector(0,1),
Vector(0.5f, 0.5f),
Vector(1, 0),
Vector(0.5f, -0.5f),
Vector(0, -1),
Vector(-0.5f, -0.5f),
Vector(-1, 0),
Vector(-0.5f, 0.5f),
};
Vector DSQ::getNoteVector(size_t note, float mag)
{
Vector vec;
switch(note)
{
case 0:
vec = Vector(0,1);
break;
case 1:
vec = Vector(0.5, 0.5);
break;
case 2:
vec = Vector(1, 0);
break;
case 3:
vec = Vector(0.5, -0.5);
break;
case 4:
vec = Vector(0, -1);
break;
case 5:
vec = Vector(-0.5, -0.5);
break;
case 6:
vec = Vector(-1, 0);
break;
case 7:
vec = Vector(-0.5, 0.5);
break;
}
return vec*mag;
return note < Countof(noteVectors) ? noteVectors[note] * mag : Vector();
}
int DSQ::getRandNote()
{
static int lastRand = -1;
static int lastRand = -1; // FIXME: move to DSQ
int r = rand()%8;
@ -1567,45 +1551,21 @@ int DSQ::getRandNote()
return r;
}
Vector DSQ::getNoteColor(int note)
static const Vector noteColors[] =
{
Vector noteColor;
switch(note)
{
case 0:
// light green
noteColor = Vector(0.5f, 1, 0.5f);
break;
case 1:
// blue/green
noteColor = Vector(0.5f, 1, 0.75f);
break;
case 2:
// blue
noteColor = Vector(0.5f, 0.5f, 1);
break;
case 3:
// purple
noteColor = Vector(1, 0.5f, 1);
break;
case 4:
// red
noteColor = Vector(1, 0.5f, 0.5f);
break;
case 5:
// red/orange
noteColor = Vector(1, 0.6f, 0.5f);
break;
case 6:
// orange
noteColor = Vector(1, 0.75f, 0.5f);
break;
case 7:
// orange
noteColor = Vector(1, 1, 0.5f);
break;
}
return noteColor;
Vector(0.5f, 1, 0.5f), // light green
Vector(0.5f, 1, 0.75f), // blue/green
Vector(0.5f, 0.5f, 1), // blue
Vector(1, 0.5f, 1), // purple
Vector(1, 0.5f, 0.5f), // red
Vector(1, 0.6f, 0.5f), // red/orange
Vector(1, 0.75f, 0.5f), // orange
Vector(1, 1, 0.5f), // yellow
};
Vector DSQ::getNoteColor(size_t note)
{
return note < Countof(noteColors) ? noteColors[note] : Vector();
}
void DSQ::toggleVersionLabel(bool on)
@ -1718,8 +1678,11 @@ void DSQ::LoadModsCallback(const std::string &filename, void *param)
{
DSQ *self = (DSQ*)param;
int pos = filename.find_last_of('/')+1;
int pos2 = filename.find_last_of('.');
size_t pos = filename.find_last_of('/')+1;
size_t pos2 = filename.find_last_of('.');
if(pos2 < pos)
return;
std::string name = filename.substr(pos, pos2-pos);
ModEntry m;
m.path = name;
@ -4134,12 +4097,7 @@ void DSQ::removeEntity(Entity *entity)
void DSQ::clearEntities()
{
const int size = entities.size();
int i;
for (i = 0; i < size; i++)
{
entities[i] = 0;
}
std::fill(entities.begin(), entities.end(), (Entity*)NULL);
}

View file

@ -244,9 +244,9 @@ public:
void voiceOnce(const std::string &file);
void voiceInterupt(const std::string &file);
void stopVoice();
Vector getNoteColor(int note);
Vector getNoteColor(size_t note);
int getRandNote();
Vector getNoteVector(int note, float mag=1);
Vector getNoteVector(size_t note, float mag=1);
void toggleCursor(bool v, float t = -1);
bool isDeveloperKeys() const;

View file

@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../BBGE/AfterEffect.h"
#include "../BBGE/MathFunctions.h"
#include "../BBGE/DebugFont.h"
#include "../BBGE/LensFlare.h"
#include "../BBGE/RoundedRect.h"
#include "../BBGE/SimpleIStringStream.h"
#include "TileRender.h"
@ -788,7 +787,7 @@ void Game::loadEntityTypeList()
InStream in2(fn.c_str());
int curGroup=0;
size_t curGroup=0;
while (std::getline(in2, line))
{
if (line.find("GROUP:")!=std::string::npos)
@ -2980,8 +2979,8 @@ void Game::applyState()
if (verbose) debugLog("paths init");
int pathSz = getNumPaths();
for (int i = 0; i < pathSz; i++)
size_t pathSz = getNumPaths();
for (size_t i = 0; i < pathSz; i++)
getPath(i)->init();
debugLog("Updating bgSfxLoop");
@ -3700,7 +3699,7 @@ bool Game::collideCircleVsCircle(Entity *a, Entity *b)
return (a->position - b->position).isLength2DIn(a->collideRadius + b->collideRadius);
}
bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, float radius, float perc, int *colSegment)
bool Game::collideHairVsCircle(Entity *a, size_t num, const Vector &pos2, float radius, float perc, size_t *colSegment)
{
if (perc == 0)
perc = 1;
@ -3710,7 +3709,7 @@ bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, float rad
if (num == 0)
num = a->hair->hairNodes.size();
// HACK: minus 2
for (int i = 0; i < num; i++)
for (size_t i = 0; i < num; i++)
{
// + a->hair->position
c = ((a->hair->hairNodes[i].position) - pos2).isLength2DIn(a->hair->hairWidth*perc + radius);

View file

@ -155,7 +155,7 @@ public:
bool collideCircleWithGrid(const Vector& position, float r);
bool collideHairVsCircle(Entity *a, int num, const Vector &pos2, float radius, float perc=0, int *colSegment=0);
bool collideHairVsCircle(Entity *a, size_t num, const Vector &pos2, float radius, float perc=0, size_t *colSegment=0);
bool collideCircleVsCircle(Entity *a, Entity *b);
Bone *collideSkeletalVsCircle(Entity *skeletal, CollideQuad *circle);

View file

@ -46,7 +46,7 @@ struct RecipeMenu
void toggle(bool on, bool watch=false);
void createPage(int p);
void createPage(size_t p);
void slide(RenderObject *r, bool in, float t);
void destroyPage();
void goNextPage();
@ -91,7 +91,7 @@ public:
virtual void action(int actionID, int state, int source, InputDevice device);
void refreshFoodSlots(bool effects);
RecipeMenu recipeMenu;
float menuSelectDelay;

View file

@ -7,7 +7,7 @@
#include <map>
#include <set>
#include <cassert>
#include "SDL.h"
#include <SDL.h>
using namespace minihttp;

View file

@ -92,12 +92,7 @@ PathNode *Path::getPathNode(size_t idx)
void Path::reverseNodes()
{
std::vector<PathNode> copy = nodes;
nodes.clear();
for (int i = copy.size()-1; i >= 0; i--)
{
nodes.push_back(copy[i]);
}
std::reverse(nodes.begin(), nodes.end());
}
void Path::setActive(bool v)

View file

@ -115,11 +115,11 @@ void PathFinding::molestPath(VectorPath &path)
path.getPathNode(i)->value += newNormals[i];
// kill bowls
int start = 0;
int runs=0;
size_t start = 0;
size_t runs=0;
bool hadSuccess = false;
int lastSuccessNode = 0;
int adjust = 2;
size_t lastSuccessNode = 0;
const size_t adjust = 2;
sz=path.getNumPathNodes();
for (i = start; i < sz-1; i++)

View file

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
namespace RecipeMenuNamespace
{
int pageSize = 4;
const size_t pageSize = 4;
std::string processFoodName(std::string name)
{
@ -292,7 +292,7 @@ void RecipeMenu::goPrevPage()
currentPage--;
if (currentPage < 0)
currentPage = getNumPages();
currentPage = (int)getNumPages();
createPage(currentPage);
}
@ -307,7 +307,7 @@ void RecipeMenu::goNextPage()
currentPage++;
int pages = getNumPages();
int pages = (int)getNumPages();
if (currentPage > pages)
{
currentPage = 0;
@ -383,12 +383,12 @@ void RecipeMenu::toggle(bool on, bool watch)
toggling = false;
}
void RecipeMenu::createPage(int p)
void RecipeMenu::createPage(size_t p)
{
int num = 0;
int startNum = p*pageSize;
int checkNum = 0;
for (int i = dsq->continuity.recipes.size()-1; i >=0 ; i--)
size_t num = 0;
size_t startNum = p*pageSize;
size_t checkNum = 0;
for (size_t i = dsq->continuity.recipes.size(); i --> 0; )
{
if (dsq->continuity.recipes[i].isKnown())
{
@ -413,11 +413,6 @@ void RecipeMenu::createPage(int p)
}
}
if (num == 0)
{
}
description = new BitmapText(dsq->smallFont);
description->followCamera = 1;
description->scale = Vector(0.7f, 0.7f);

View file

@ -34,7 +34,7 @@ extern "C" {
#include "luaalloc.h"
#include "SDL.h"
#include <SDL.h>
#include "ScriptInterface.h"
#include "ScriptObject.h"
@ -5674,10 +5674,10 @@ luaFunc(entity_collideHairVsCircle)
bool col=false;
if (e && e2)
{
int num = lua_tointeger(L, 3);
size_t num = (size_t)lua_tointeger(L, 3);
// perc: percent of hairWidth to use as collide radius
float perc = lua_tonumber(L, 4);
int colSegment;
size_t colSegment;
col = game->collideHairVsCircle(e, num, e2->position, e2->collideRadius, perc, &colSegment);
if(col)
{

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

View file

@ -1,6 +1,8 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6...3.20)
PROJECT(Aquaria)
SET(CMAKE_CXX_STANDARD 98)
# We don't actually activate this, but the code itself should stay compatible with oldschool C++.
#SET(CMAKE_CXX_STANDARD 98)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
@ -22,6 +24,16 @@ IF(APPLE)
SET(MACOSX TRUE)
ENDIF(APPLE)
if(CMAKE_COMPILER_IS_CLANG OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
set(GCC TRUE)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
set(GCC TRUE)
endif()
set(AQUARIA_WARNING_FLAGS "")
# Recommended compiler flags that cmake doesn't set automatically
if(MSVC)
# /MP: parallel builds
@ -29,17 +41,30 @@ if(MSVC)
# /Oi: enable intrinsic functions
# /fp:fast: -ffast-math
set(AQUARIA_EXTRA_COMPILE_FLAGS "/MP /GS- /Oi /fp:fast" CACHE STRING "Extra compiler flags for MSVC")
option(AQUARIA_MSVC_DEBUG_EDIT_AND_CONTINUE "MSVC: Enable edit+continue for debug builds?" TRUE)
if(AQUARIA_MSVC_DEBUG_EDIT_AND_CONTINUE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set(AQUARIA_EXTRA_COMPILE_FLAGS "-ffast-math" CACHE STRING "Extra compiler flags for GCC/Clang")
elseif(GCC OR CLANG)
set(_FNO_STACK_PROTECTOR "")
# See if -fno-stack-protector is available to us.
# It doesn't seem to work well, and it adds bulk to the binary.
CHECK_C_COMPILER_FLAG("-fno-stack-protector" AQUARIA_GCC_HAS_STACKPROT)
IF(AQUARIA_GCC_HAS_STACKPROT)
set(_FNO_STACK_PROTECTOR "-fno-stack-protector")
ENDIF(AQUARIA_GCC_HAS_STACKPROT)
#CHECK_C_COMPILER_FLAG("-Wc++98-compat" AQUARIA_GCC_HAS_WCPP98_COMPAT)
#if(AQUARIA_GCC_HAS_WCPP98_COMPAT)
# set(_WCPP98_COMPAT "-Wc++98-compat")
#endif()
set(AQUARIA_EXTRA_COMPILE_FLAGS "-ffast-math -pipe -fsigned-char ${_FNO_STACK_PROTECTOR}" CACHE STRING "Extra compiler flags for GCC/Clang")
set(AQUARIA_WARNING_FLAGS "-Wall -Wextra ${_WCPP98_COMPAT} -Wno-unused-parameter -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Wconversion -Wnull-dereference -Wdouble-promotion")
else()
set(AQUARIA_EXTRA_COMPILE_FLAGS "" CACHE STRING "Extra compiler flags")
set(AQUARIA_EXTRA_COMPILE_FLAGS "" CACHE STRING "Extra compiler flags (unknown compiler)")
endif()
if(AQUARIA_EXTRA_COMPILE_FLAGS)
@ -166,27 +191,6 @@ IF(WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(WIN32)
IF(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -pipe -fsigned-char")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -pipe -fsigned-char -std=gnu99")
# See if -fno-stack-protector is available to us.
# It doesn't seem to work well, and it adds bulk to the binary.
CHECK_C_COMPILER_FLAG("-fno-stack-protector" AQUARIA_GCC_HAS_STACKPROT)
IF(AQUARIA_GCC_HAS_STACKPROT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
ENDIF(AQUARIA_GCC_HAS_STACKPROT)
# !!! FIXME: probably not safe long-term.
# CMake mailing list had this hack for getting rid of -rdynamic:
# http://public.kitware.com/pipermail/cmake/2006-July/010404.html
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
IF(HAVE_STRCASECMP)
ADD_DEFINITIONS(-DHAVE_STRCASECMP)
@ -211,6 +215,10 @@ message(STATUS "TINYXML2_INCLUDE_DIRS: ${TINYXML2_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(${TINYXML2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${EXTLIBDIR})
if(AQUARIA_WARNING_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AQUARIA_WARNING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AQUARIA_WARNING_FLAGS}")
endif()
add_subdirectory(Aquaria)
add_subdirectory(BBGE)

View file

@ -46,21 +46,21 @@ namespace ByteBufferTools
convert<sizeof(T)>((char *)(val));
}
inline void EndianConvertRT(char *p, unsigned int size)
inline void EndianConvertRT(char *p, size_t size)
{
std::reverse(p, p + size);
}
#if BB_IS_BIG_ENDIAN
template<typename T> inline void ToLittleEndian(T& val) { EndianConvert<T>(&val); }
inline void ToLittleEndianRT(void *p, unsigned int size) { EndianConvertRT((char*)p, size); }
inline void ToLittleEndianRT(void *p, size_t size) { EndianConvertRT((char*)p, size); }
template<typename T> inline void ToBigEndian(T&) { }
inline void ToBigEndianRT(void *p, unsigned int size) { }
inline void ToBigEndianRT(void *p, size_t size) { }
#else
template<typename T> inline void ToLittleEndian(T&) { }
inline void ToLittleEndianRT(void *p, unsigned int size) { }
inline void ToLittleEndianRT(void *p, size_t size) { }
template<typename T> inline void ToBigEndian(T& val) { EndianConvert<T>(&val); }
inline void ToBigEndianRT(void *p, unsigned int size) { EndianConvertRT((char*)p, size); }
inline void ToBigEndianRT(void *p, size_t size) { EndianConvertRT((char*)p, size); }
#endif
template<typename T> void ToLittleEndian(T*); // will generate link error
@ -87,7 +87,7 @@ public:
COPY, //- Make a copy of the buffer (default action).
REUSE, //- Use the passed-in buffer as is. Requires the pointer
// to remain valid over the life of this object.
TAKE_OVER, //- Take over the passed-in buffer; it will be deleted on object destruction.
TAKE_OVER //- Take over the passed-in buffer; it will be deleted on object destruction.
};
typedef int64_t int64;
@ -102,7 +102,7 @@ public:
class Exception
{
public:
Exception(const ByteBuffer *bb, const char *act, uint32 sp = 0)
Exception(const ByteBuffer *bb, const char *act, size_t sp = 0)
{
action = act;
rpos = bb->rpos();
@ -110,14 +110,14 @@ public:
sizeparam = sp;
cursize = bb->size();
}
uint32 rpos, wpos, sizeparam, cursize;
size_t rpos, wpos, sizeparam, cursize;
const char *action;
};
#ifdef BYTEBUFFER_NO_EXCEPTIONS
#define BYTEBUFFER_EXCEPT(bb, desc, sz) { Exception __e(bb, desc, sz); \
fprintf(stderr, "Exception in ByteBuffer: '%s', rpos: %u, wpos: %u, cursize: %u, sizeparam: %u", \
__e.action, __e.rpos, __e.wpos, __e.cursize, __e.sizeparam); abort(); }
__e.action, (unsigned)__e.rpos, (unsigned)__e.wpos, (unsigned)__e.cursize, (unsigned)__e.sizeparam); abort(); }
#else
#define BYTEBUFFER_EXCEPT(bb, desc, sz) throw Exception(bb, desc, sz)
#endif
@ -125,7 +125,7 @@ public:
protected:
uint8 *_buf; // the ptr to the buffer that holds all the bytes
uint32 _rpos, // read position, [0 ... _size]
size_t _rpos, // read position, [0 ... _size]
_wpos, // write position, [0 ... _size]
_res, // reserved buffer size, [0 ... _size ... _res]
_size; // used buffer size
@ -142,27 +142,27 @@ public:
_allocfunc(NULL), _mybuf(false), _growable(true)
{
}
ByteBuffer(uint32 res)
ByteBuffer(size_t res)
: _buf(NULL), _rpos(0), _wpos(0), _res(0), _size(0), _delfunc(NULL),
_allocfunc(NULL), _mybuf(false), _growable(true)
{
_allocate(res);
}
ByteBuffer(ByteBuffer &buf, Mode mode = COPY, uint32 extra = 0)
ByteBuffer(ByteBuffer &buf, Mode mode = COPY, size_t extra = 0)
: _buf(NULL), _rpos(0), _wpos(0), _res(0), _size(0), _delfunc(NULL),
_allocfunc(NULL), _mybuf(false), _growable(true)
{
init(buf, mode, extra);
}
// del param only used with TAKE_OVER, extra only used with COPY
ByteBuffer(void *buf, uint32 size, Mode mode = COPY, delete_func del = NULL, uint32 extra = 0)
ByteBuffer(void *buf, size_t size, Mode mode = COPY, delete_func del = NULL, size_t extra = 0)
: _buf(NULL), _rpos(0), _wpos(0), _res(0), _size(0), _delfunc(NULL),
_allocfunc(NULL), _mybuf(false), _growable(true) // for mode == REUSE
{
init(buf, size, mode, del, extra);
}
void init(void *buf, uint32 size, Mode mode = COPY, delete_func del = NULL, uint32 extra = 0)
void init(void *buf, size_t size, Mode mode = COPY, delete_func del = NULL, size_t extra = 0)
{
_mybuf = false;
switch(mode)
@ -181,7 +181,7 @@ public:
}
}
void init(ByteBuffer& bb, Mode mode = COPY, uint32 extra = 0)
void init(ByteBuffer& bb, Mode mode = COPY, size_t extra = 0)
{
_allocfunc = bb._allocfunc;
@ -227,7 +227,7 @@ public:
_rpos = _wpos = _size = 0;
}
void resize(uint32 newsize)
void resize(size_t newsize)
{
reserve(newsize);
_rpos = 0;
@ -235,7 +235,7 @@ public:
_size = newsize;
}
void reserve(uint32 newsize)
void reserve(size_t newsize)
{
if(_res < newsize)
_allocate(newsize);
@ -275,7 +275,7 @@ public:
BB_MAKE_READ_OP(float);
BB_MAKE_READ_OP(double);
inline uint8 operator[](uint32 pos) const
inline uint8 operator[](size_t pos) const
{
if(pos >= size())
BYTEBUFFER_EXCEPT(this, "operator[]", 1);
@ -293,15 +293,15 @@ public:
// --------------------------------------------------
uint32 rpos() const { return _rpos; }
uint32 rpos(uint32 rpos)
size_t rpos() const { return _rpos; }
size_t rpos(size_t rpos)
{
_rpos = rpos < size() ? rpos : size();
return _rpos;
}
uint32 wpos() const { return _wpos; }
uint32 wpos(uint32 wpos)
size_t wpos() const { return _wpos; }
size_t wpos(size_t wpos)
{
_wpos = wpos < size() ? wpos : size();
return _wpos;
@ -309,12 +309,12 @@ public:
template <typename T> T read()
{
T r = read<T>(_rpos);
const size_t pos = _rpos;
_rpos += sizeof(T);
return r;
return read<T>(pos);
}
template <typename T> T read(uint32 pos) const
template <typename T> T read(size_t pos) const
{
if(pos + sizeof(T) > size())
BYTEBUFFER_EXCEPT(this, "read", sizeof(T));
@ -331,13 +331,13 @@ public:
return 0;
}
void readT(void *dest, uint32 len)
void readT(void *dest, size_t len)
{
read(dest, len);
ByteBufferTools::ToLittleEndianRT(dest, len);
}
void read(void *dest, uint32 len)
void read(void *dest, size_t len)
{
if (_rpos + len <= size())
memcpy(dest, &_buf[_rpos], len);
@ -346,7 +346,7 @@ public:
_rpos += len;
}
void skipRead(uint32 len)
void skipRead(size_t len)
{
_rpos += len;
}
@ -357,15 +357,15 @@ public:
inline const void *ptr() const { return _buf; }
inline void *ptr() { return _buf; }
inline uint32 size() const { return _size; }
inline size_t size() const { return _size; }
inline uint32 bytes() const { return size(); }
inline uint32 bits() const { return bytes() * 8; }
inline size_t bytes() const { return size(); }
inline size_t bits() const { return bytes() * 8; }
inline uint32 capacity() const { return _res; }
inline size_t capacity() const { return _res; }
inline uint32 readable(void) const { return size() - rpos(); }
inline uint32 writable(void) const { return size() - wpos(); } // free space left before realloc will occur
inline size_t readable(void) const { return size() - rpos(); }
inline size_t writable(void) const { return size() - wpos(); } // free space left before realloc will occur
template <typename T> inline void append(T value)
{
@ -386,13 +386,13 @@ public:
}
// GCC 2.95 fails with an internal error in the template function above
void appendT(const void *src, uint32 bytes)
void appendT(const void *src, size_t bytes)
{
append(src, bytes);
ByteBufferTools::ToLittleEndianRT(_buf + (_wpos - bytes), bytes);
}
void append(const void *src, uint32 bytes)
void append(const void *src, size_t bytes)
{
if (!bytes) return;
_enlargeIfReq(_wpos + bytes);
@ -407,12 +407,12 @@ public:
append(buffer.contents(), buffer.size());
}
void put(uint32 pos, const void *src, uint32 bytes)
void put(size_t pos, const void *src, size_t bytes)
{
memcpy(_buf + pos, src, bytes);
}
template <typename T> void put(uint32 pos, const T& value)
template <typename T> void put(size_t pos, const T& value)
{
if(pos >= size())
BYTEBUFFER_EXCEPT(this, "put", sizeof(T));
@ -441,12 +441,12 @@ public:
_delfunc = f;
}
void _setSize(uint32 s)
void _setSize(size_t s)
{
_size = s;
}
void _setReserved(uint32 s)
void _setReserved(size_t s)
{
_res = s;
}
@ -467,7 +467,7 @@ protected:
}
// allocate larger buffer and copy contents. if we own the current buffer, delete old, otherwise, leave it as it is.
void _allocate(uint32 s)
void _allocate(size_t s)
{
if(!_growable && _buf) // only throw if we already have a buf
BYTEBUFFER_EXCEPT(this, "_alloc+locked", s);
@ -487,11 +487,11 @@ protected:
_delfunc = NULL;
}
void _enlargeIfReq(uint32 minSize)
void _enlargeIfReq(size_t minSize)
{
if(_res < minSize)
{
uint32 a = _res * 2;
size_t a = _res * 2;
if(a < minSize) // fallback if doubling the space was not enough
a += minSize;
_allocate(a);

View file

@ -28,7 +28,7 @@ GzipCompressor::GzipCompressor()
_forceCompress = true; // we want this for gzip
}
void DeflateCompressor::compress(void* dst, uint32 *dst_size, const void* src, uint32 src_size,
void DeflateCompressor::compress(void* dst, size_t *dst_size, const void* src, size_t src_size,
uint8 level, int wbits)
{
z_stream c_stream;
@ -71,7 +71,7 @@ void DeflateCompressor::compress(void* dst, uint32 *dst_size, const void* src, u
*dst_size = c_stream.total_out;
}
void DeflateCompressor::decompress(void *dst, uint32 *origsize, const void *src, uint32 size, int wbits)
void DeflateCompressor::decompress(void *dst, size_t *origsize, const void *src, size_t size, int wbits)
{
z_stream stream;
int err;
@ -115,8 +115,8 @@ void DeflateCompressor::Compress(uint8 level)
char *buf;
uint32 oldsize = size();
uint32 newsize = compressBound(oldsize) + 30; // for optional gzip header
size_t oldsize = size();
size_t newsize = size_t(compressBound(oldsize)) + 30; // for optional gzip header
buf = new char[newsize];
@ -150,8 +150,8 @@ void DeflateCompressor::Decompress(void)
}
else
{
uint32 rs = (uint32)_real_size;
uint32 origsize = rs;
size_t rs = (size_t)_real_size;
size_t origsize = rs;
uint8 *target = new uint8[rs];
wpos(0);
rpos(0);

View file

@ -15,8 +15,8 @@ public:
bool Compressed(void) const { return _iscompressed; }
void Compressed(bool b) { _iscompressed = b; }
void SetForceCompression(bool f) { _forceCompress = f; }
uint32 RealSize(void) const { return _iscompressed ? _real_size : size(); }
void RealSize(uint32 realsize) { _real_size = realsize; }
size_t RealSize(void) const { return _iscompressed ? _real_size : size(); }
void RealSize(size_t realsize) { _real_size = realsize; }
void clear(void) // not required to be strictly virtual; be careful not to mess up static types!
{
ByteBuffer::clear();
@ -26,13 +26,13 @@ public:
protected:
int _windowBits; // read zlib docs to know what this means
unsigned int _real_size;
size_t _real_size;
bool _forceCompress;
bool _iscompressed;
private:
static void decompress(void *dst, uint32 *origsize, const void *src, uint32 size, int wbits);
static void compress(void* dst, uint32 *dst_size, const void* src, uint32 src_size,
static void decompress(void *dst, size_t *origsize, const void *src, size_t size, int wbits);
static void compress(void* dst, size_t *dst_size, const void* src, size_t src_size,
uint8 level, int wbits);
int decompressBlockwise();

View file

@ -47,9 +47,6 @@ GLFont::~GLFont ()
//*******************************************************************
bool GLFont::Create (const char *file_name, int tex, bool loadTexture)
{
ByteBuffer::uint32 num_chars, num_tex_bytes;
char *tex_bytes;
//Destroy the old font if there was one, just to be safe
Destroy();
@ -80,7 +77,7 @@ bool GLFont::Create (const char *file_name, int tex, bool loadTexture)
bb.skipRead(4); // skip chars field
//Allocate space for character array
num_chars = header.end_char - header.start_char + 1;
size_t num_chars = size_t(header.end_char) - header.start_char + 1;
if ((header.chars = new GLFontChar[num_chars]) == NULL)
return false;
@ -96,8 +93,8 @@ bool GLFont::Create (const char *file_name, int tex, bool loadTexture)
}
//Read texture pixel data
num_tex_bytes = header.tex_width * header.tex_height * 2;
tex_bytes = new char[num_tex_bytes];
size_t num_tex_bytes = size_t(header.tex_width) * header.tex_height * 2;
char *tex_bytes = new char[num_tex_bytes];
// HACK: Aquaria uses override textures, so we can live with the truncation.
bb.read(tex_bytes, std::min(num_tex_bytes, bb.readable()));

View file

@ -16,10 +16,18 @@
# endif
# include <winsock2.h>
# include <ws2tcpip.h>
# define EWOULDBLOCK WSAEWOULDBLOCK
# define ETIMEDOUT WSAETIMEDOUT
# define ECONNRESET WSAECONNRESET
# define ENOTCONN WSAENOTCONN
# ifndef EWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK
# endif
# ifndef ETIMEDOUT
# define ETIMEDOUT WSAETIMEDOUT
# endif
# ifndef ECONNRESET
# define ECONNRESET WSAECONNRESET
# endif
# ifndef ENOTCONN
# define ENOTCONN WSAENOTCONN
# endif
# include <io.h>
#else
# include <sys/types.h>
@ -506,7 +514,7 @@ bool TcpSocket::open(const char *host /* = NULL */, unsigned int port /* = 0 */)
traceprint("TcpSocket::open(): host = [%s], port = %d\n", host, port);
assert(!SOCKETVALID(_s));
_recvSize = 0;
{
@ -1071,7 +1079,7 @@ void HttpSocket::_ProcessChunk(void)
return;
}
term += 2; // skip CRLF
// when we are here, the (next) chunk header was completely received.
chunksize = strtoul(_readptr, NULL, 16);
_remaining = chunksize + 2; // the http protocol specifies that each chunk has a trailing CRLF
@ -1140,7 +1148,7 @@ bool HttpSocket::_HandleStatus()
const char *encoding = Hdr("transfer-encoding");
_chunkedTransfer = encoding && !STRNICMP(encoding, "chunked", 7);
const char *conn = Hdr("connection"); // if its not keep-alive, server will close it, so we can too
_mustClose = !conn || STRNICMP(conn, "keep-alive", 10);

View file

@ -281,7 +281,7 @@ public:
bool deleteWhenDone;
// To be extended
};
typedef std::map<TcpSocket*, SocketSetData> Store;
Store _store;