1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-17 20:09:35 +00:00

Get rid of a lot of gcc warnings

Mostly signed/unsigned comparisons. Also some bugs, but I don't remember
where :D
This commit is contained in:
Valentin Ochs 2017-01-14 18:10:20 +01:00
commit fe0ab0418b
88 changed files with 801 additions and 831 deletions

View file

@ -102,7 +102,7 @@ void ActionMapper::addAction(Event *event, int k, int state)
Event* ActionMapper::addCreatedEvent(Event *event)
{
for (int i = 0; i < createdEvents.size(); i++)
for (size_t i = 0; i < createdEvents.size(); i++)
{
if (createdEvents[i] == event)
return event;
@ -113,7 +113,7 @@ Event* ActionMapper::addCreatedEvent(Event *event)
void ActionMapper::clearCreatedEvents()
{
for (int i = 0; i < createdEvents.size(); i++)
for (size_t i = 0; i < createdEvents.size(); i++)
{
delete createdEvents[i];
}
@ -326,7 +326,7 @@ void ActionMapper::removeAllActions()
{
deleteList.push_back(i->id);
}
for (int c = 0; c < deleteList.size(); c++)
for (size_t c = 0; c < deleteList.size(); c++)
{
removeAction (deleteList[c]);
}

View file

@ -44,7 +44,7 @@ void ActionSet::importAction(ActionMapper *mapper, const std::string &name, int
{
if (!mapper) return;
for (int i = 0; i < inputSet.size(); i++)
for (size_t i = 0; i < inputSet.size(); i++)
{
ActionInput *actionInput = &inputSet[i];
if (actionInput->name == name)
@ -68,7 +68,7 @@ void ActionSet::importAction(ActionMapper *mapper, const std::string &name, Even
{
if (!mapper) return;
for (int i = 0; i < inputSet.size(); i++)
for (size_t i = 0; i < inputSet.size(); i++)
{
ActionInput *actionInput = &inputSet[i];
if (actionInput->name == name)
@ -108,8 +108,8 @@ std::string ActionSet::insertInputIntoString(const std::string &string)
{
std::string str = string;
int start = str.find('{');
int end = str.find('}');
size_t start = str.find('{');
size_t end = str.find('}');
if (start == std::string::npos || end == std::string::npos)
return string;
std::string code = str.substr(start+1, end - start);

View file

@ -85,7 +85,7 @@ AfterEffectManager::~AfterEffectManager()
void AfterEffectManager::deleteEffects()
{
for (int i = 0; i < effects.size(); i++)
for (size_t i = 0; i < effects.size(); i++)
{
if (effects[i])
{
@ -137,7 +137,7 @@ void AfterEffectManager::update(float dt)
else
active = false;
for (int i = 0; i < effects.size(); i++)
for (size_t i = 0; i < effects.size(); i++)
{
Effect *e = effects[i];
if (e)

View file

@ -161,7 +161,7 @@ int randRange(int n1, int n2)
std::string removeSpaces(const std::string &input)
{
std::string result;
for (int i = 0; i < input.size(); i++)
for (size_t i = 0; i < input.size(); i++)
{
if (input[i] != ' ')
{
@ -175,7 +175,7 @@ unsigned hash(const std::string &string)
{
unsigned hash = 5381;
for (int i = 0; i < string.size(); i++)
for (size_t i = 0; i < string.size(); i++)
hash = ((hash << 5) + hash) + (unsigned char)string[i];
return hash;
@ -235,7 +235,7 @@ std::string splitCamelCase(const std::string &input)
{
std::string result;
int last = 0;
for (int i = 0; i < input.size(); i++)
for (size_t i = 0; i < input.size(); i++)
{
if (last == 1)
{
@ -257,7 +257,7 @@ std::string splitCamelCase(const std::string &input)
return result;
}
std::string numToZeroString(int num, int zeroes)
std::string numToZeroString(int num, size_t zeroes)
{
std::ostringstream num_os;
num_os << num;
@ -266,7 +266,7 @@ std::string numToZeroString(int num, int zeroes)
if (num_os.str().size() <= zeroes)
{
for (int j = 0; j < zeroes - num_os.str().size(); j++)
for (size_t j = 0; j < zeroes - num_os.str().size(); j++)
{
os << "0";
}
@ -282,13 +282,13 @@ bool isVectorInRect(const Vector &vec, const Vector &coord1, const Vector &coord
void stringToUpper(std::string &s)
{
for (int i = 0; i < s.size(); i++)
for (size_t i = 0; i < s.size(); i++)
s[i] = charToUpper(s[i]);
}
void stringToLower(std::string &s)
{
for (int i = 0; i < s.size(); i++)
for (size_t i = 0; i < s.size(); i++)
s[i] = charToLower(s[i]);
}
@ -388,7 +388,7 @@ void exit_error(const std::string &message)
std::string parseCommand(const std::string &line, const std::string &command)
{
int stringPos = line.find(command);
size_t stringPos = line.find(command);
if (stringPos != std::string::npos)
{
return line.substr((command.length()), line.length());
@ -470,7 +470,7 @@ char *readFile(const std::string& path, unsigned long *size_ret)
return NULL;
}
long bytesRead = vfread(buffer, 1, fileSize, f);
size_t bytesRead = vfread(buffer, 1, fileSize, f);
if (bytesRead != fileSize)
{
std::ostringstream os;
@ -539,7 +539,7 @@ void doSingleFile(const std::string &path, const std::string &type, std::string
std::string stripEndlineForUnix(const std::string &in)
{
std::string out;
for (int i = 0; i < in.size(); i++)
for (size_t i = 0; i < in.size(); i++)
{
if (int(in[i]) != 13)
{
@ -1071,7 +1071,7 @@ Vector colorRGB(int r, int g, int b)
std::string underscoresToSpaces(const std::string &str)
{
std::string s = str;
for (int i = 0; i < s.size(); i++)
for (size_t i = 0; i < s.size(); i++)
if (s[i] == '_') s[i] = ' ';
return s;
}
@ -1079,7 +1079,7 @@ std::string underscoresToSpaces(const std::string &str)
std::string spacesToUnderscores(const std::string &str)
{
std::string s = str;
for (int i = 0; i < s.size(); i++)
for (size_t i = 0; i < s.size(); i++)
if (s[i] == ' ') s[i] = '_';
return s;
}

View file

@ -152,7 +152,7 @@ struct IntPair
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
std::string numToZeroString(int num, int zeroes);
std::string numToZeroString(int num, size_t zeroes);
bool chance(int perc);
bool chancef(float p);
void initCharTranslationTables(const std::map<unsigned char, unsigned char>& tab);

View file

@ -161,7 +161,7 @@ void BitmapText::formatText()
float currentWidth = 0;
alignWidth = 0;
maxW = 0;
for (int i = 0; i < text.size(); i++)
for (size_t i = 0; i < text.size(); i++)
{
float sz = bmpFont->font.GetCharWidth(text[i])*bmpFont->scale;
@ -207,10 +207,10 @@ void BitmapText::setBitmapFontEffect(BitmapFontEffect bfe)
void BitmapText::updateWordColoring()
{
colorIndices.resize(lines.size());
for (int i = 0; i < colorIndices.size(); i++)
for (size_t i = 0; i < colorIndices.size(); i++)
{
colorIndices[i].resize(lines[i].size());
for (int j = 0; j < colorIndices[i].size(); j++)
for (size_t j = 0; j < colorIndices[i].size(); j++)
{
colorIndices[i][j] = Vector(1,1,1);
}
@ -278,7 +278,7 @@ void BitmapText::onUpdate(float dt)
}
}
Vector BitmapText::getColorIndex(int i, int j)
Vector BitmapText::getColorIndex(size_t i, size_t j)
{
Vector c(1,1,1);
if (!(i < 0 || j < 0))
@ -314,7 +314,7 @@ void BitmapText::onRender()
if (scrolling)
{
for (int i = 0; i <= currentScrollLine; i++)
for (size_t i = 0; i <= currentScrollLine; i++)
{
std::string theLine = lines[i];
if (i == currentScrollLine)
@ -336,7 +336,7 @@ void BitmapText::onRender()
}
else
{
for (int i = 0; i < lines.size(); i++)
for (size_t i = 0; i < lines.size(); i++)
{
x=0;
if (align == ALIGN_CENTER)

View file

@ -67,7 +67,7 @@ public:
std::string getText();
int getWidthOnScreen();
void loadSpacingMap(const std::string &file);
Vector getColorIndex(int i, int j);
Vector getColorIndex(size_t i, size_t j);
void updateWordColoring();
void autoKern();
void setBitmapFontEffect(BitmapFontEffect bfe);
@ -88,8 +88,8 @@ protected:
void onUpdate(float dt);
float scrollDelay;
bool scrolling;
int currentScrollLine;
int currentScrollChar;
size_t currentScrollLine;
size_t currentScrollChar;
Align align;
float alignWidth;
typedef std::map<char, float> SpacingMap;

View file

@ -111,7 +111,7 @@ ParticleEffect* Core::createParticleEffect(const std::string &name, const Vector
void Core::unloadDevice()
{
for (int i = 0; i < renderObjectLayers.size(); i++)
for (size_t i = 0; i < renderObjectLayers.size(); i++)
{
RenderObjectLayer *r = &renderObjectLayers[i];
RenderObject *robj = r->getFirst();
@ -129,7 +129,7 @@ void Core::unloadDevice()
void Core::reloadDevice()
{
for (int i = 0; i < renderObjectLayers.size(); i++)
for (size_t i = 0; i < renderObjectLayers.size(); i++)
{
RenderObjectLayer *r = &renderObjectLayers[i];
r->reloadDevice();
@ -507,7 +507,7 @@ void Core::initPlatform(const std::string &filesystem)
char path[PATH_MAX];
// always a symlink to this process's binary, on modern Linux systems.
const ssize_t rc = readlink("/proc/self/exe", path, sizeof (path));
if ( (rc == -1) || (rc >= sizeof (path)) )
if ( (rc == -1) || (rc >= (ssize_t) sizeof (path)) )
{
// error!
debugLog("readlink");
@ -1415,7 +1415,7 @@ void Core::resetTimer()
{
nowTicks = thenTicks = SDL_GetTicks();
for (int i = 0; i < avgFPS.size(); i++)
for (size_t i = 0; i < avgFPS.size(); i++)
{
avgFPS[i] = 0;
}
@ -1427,8 +1427,6 @@ void Core::setDockIcon(const std::string &ident)
void Core::setMousePosition(const Vector &p)
{
Vector lp = core->mouse.position;
core->mouse.position = p;
float px = p.x + virtualOffX;
float py = p.y;
@ -1438,15 +1436,12 @@ void Core::setMousePosition(const Vector &p)
#else
SDL_WarpMouse( px * (float(width)/float(virtualWidth)), py * (float(height)/float(virtualHeight)));
#endif
}
// used to update all render objects either uniformly or as part of a time sliced update process
void Core::updateRenderObjects(float dt)
{
for (int c = 0; c < renderObjectLayers.size(); c++)
for (size_t c = 0; c < renderObjectLayers.size(); c++)
{
RenderObjectLayer *rl = &renderObjectLayers[c];
@ -1557,7 +1552,7 @@ void Core::main(float runTime)
if (!avgFPS.empty())
{
int i = 0;
size_t i = 0;
for (i = avgFPS.size()-1; i > 0; i--)
{
avgFPS[i] = avgFPS[i-1];
@ -2190,11 +2185,9 @@ void Core::print(int x, int y, const char *str, float sz)
float xx = x;
float yy = y;
glTranslatef(x, y-0.5f*sz, 0);
x = y = 0;
xx = 0; yy = 0;
bool isLower = false, wasLower = false;
xx = 0;
int c=0;
@ -2205,13 +2198,6 @@ void Core::print(int x, int y, const char *str, float sz)
while (str[c] != '\0')
{
if (str[c] <= 'z' && str[c] >= 'a')
isLower = true;
else
isLower = false;
switch(toupper(str[c]))
{
case '_':
@ -2461,11 +2447,6 @@ void Core::print(int x, int y, const char *str, float sz)
default:
break;
}
if (isLower)
{
wasLower = true;
}
c++;
xx += 1.4f;
@ -2536,7 +2517,7 @@ void Core::render(int startLayer, int endLayer, bool useFrameBufferIfAvail)
RenderObject::rlayer = 0;
for (int c = 0; c < renderObjectLayerOrder.size(); c++)
for (size_t c = 0; c < renderObjectLayerOrder.size(); c++)
{
int i = renderObjectLayerOrder[c];
@ -2633,7 +2614,7 @@ void Core::shutdownJoystickLibrary()
void Core::clearRenderObjects()
{
for (int i = 0; i < renderObjectLayers.size(); i++)
for (size_t i = 0; i < renderObjectLayers.size(); i++)
{
RenderObject *r = renderObjectLayers[i].getFirst();
@ -2857,11 +2838,11 @@ CountedPtr<Texture> Core::addTexture(const std::string &textureName)
return ptex;
}
void Core::addRenderObject(RenderObject *o, int layer)
void Core::addRenderObject(RenderObject *o, size_t layer)
{
if (!o) return;
o->layer = layer;
if (layer < 0 || layer >= renderObjectLayers.size())
if (layer >= renderObjectLayers.size())
{
std::ostringstream os;
os << "attempted to add render object to invalid layer [" << layer << "]";
@ -2880,7 +2861,7 @@ void Core::switchRenderObjectLayer(RenderObject *o, int toLayer)
void Core::unloadResources()
{
for (int i = 0; i < resources.size(); i++)
for (size_t i = 0; i < resources.size(); i++)
{
resources[i]->unload();
}
@ -2892,7 +2873,7 @@ void Core::onReloadResources()
void Core::reloadResources()
{
for (int i = 0; i < resources.size(); i++)
for (size_t i = 0; i < resources.size(); i++)
{
resources[i]->reload();
}
@ -3179,8 +3160,8 @@ void Core::save64x64ScreenshotTGA(const std::string &filename)
// saves an array of pixels as a TGA image (frees the image data passed in)
int Core::tgaSave( const char *filename,
short int width,
short int height,
short unsigned int width,
short unsigned int height,
unsigned char pixelDepth,
unsigned char *imageData) {
@ -3282,8 +3263,8 @@ int Core::tgaSaveSeries(char *filename,
// saves an array of pixels as a TGA image (frees the image data passed in)
int Core::zgaSave( const char *filename,
short int w,
short int h,
short unsigned int w,
short unsigned int h,
unsigned char depth,
unsigned char *imageData) {

View file

@ -378,9 +378,9 @@ protected:
std::vector<DisplayListElement> displayList;
RenderObjects renderObjects;
int objectCount;
int firstFreeIdx;
int iter;
size_t objectCount;
size_t firstFreeIdx;
size_t iter;
};
class Core : public ActionMapper, public StateManager
@ -439,7 +439,7 @@ public:
void toggleScreenMode(int t=0);
void enable2D(int pixelScaleX=0, int pixelScaleY=0, bool forcePixelScale=false);
void addRenderObject(RenderObject *o, int layer=0);
void addRenderObject(RenderObject *o, size_t layer=0);
void switchRenderObjectLayer(RenderObject *o, int toLayer);
void addTexture(Texture *r);
CountedPtr<Texture> findTexture(const std::string &name);
@ -690,8 +690,8 @@ public:
CoreSettings settings;
int tgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
int zgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
int tgaSave(const char *filename, short unsigned int width, short unsigned int height, unsigned char pixelDepth, unsigned char *imageData);
int zgaSave(const char *filename, short unsigned int width, short unsigned int height, unsigned char pixelDepth, unsigned char *imageData);
volatile int dbg_numThreadDecoders;
static unsigned int dbg_numRenderCalls;

View file

@ -90,7 +90,7 @@ void DebugFont::formatText()
int lastSpace = -1;
float currentWidth = 0;
maxW = 0;
for (int i = 0; i < text.size(); i++)
for (size_t i = 0; i < text.size(); i++)
{
currentWidth += fontDrawSize;
@ -132,7 +132,7 @@ void DebugFont::onRender()
{
const float vspc = 1.5;
for (int i = 0; i < lines.size(); i++)
for (size_t i = 0; i < lines.size(); i++)
{
float width = (lines[i].size()) * fontDrawSize * 1.4f * 0.75f;

View file

@ -1379,7 +1379,7 @@ static void *decode_to_pcm(VFILE *io, ALenum &format, ALsizei &size, ALuint &fre
if (rc > 0)
{
size += rc;
if (size >= allocated)
if ((size_t) size >= allocated)
{
allocated *= 2;
ALubyte *tmp = (ALubyte *) realloc(retval, allocated);
@ -1739,7 +1739,7 @@ FMOD_RESULT OpenALSystem::update()
}
ALBRIDGE(System, set3DListenerAttributes, (int listener, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *forward, const FMOD_VECTOR *up),
(listener, pos, vel, forward, up));
(listener, pos, vel, forward, up))
FMOD_RESULT OpenALSystem::set3DListenerAttributes(int listener, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *forward, const FMOD_VECTOR *up)
{
// ignore listener parameter; there is only one listener in OpenAL.

View file

@ -56,7 +56,7 @@ void LensFlare::onUpdate(float dt)
Vector vbit = v;
vbit *= inc;
for (int i = 0; i < flares.size(); i++)
for (size_t i = 0; i < flares.size(); i++)
{
flares[i]->position = vbit*i;
flares[i]->alpha = a;

View file

@ -58,5 +58,5 @@ namespace MathFunctions
return angle;
}
};
}

View file

@ -44,10 +44,10 @@ ParticleManager::ParticleManager(int size)
setSize(size);
}
void ParticleManager::setSize(int size)
void ParticleManager::setSize(size_t size)
{
// dangerous!
for (int i = 0; i < particles.size(); i++)
for (size_t i = 0; i < particles.size(); i++)
{
Particle *p = &particles[i];
if (p->emitter)
@ -71,15 +71,15 @@ void ParticleManager::setNumSuckPositions(int num)
suckPositions.resize(num);
}
void ParticleManager::setSuckPosition(int idx, const Vector &pos)
void ParticleManager::setSuckPosition(size_t idx, const Vector &pos)
{
if (idx < 0 || idx >= suckPositions.size()) return;
if (idx >= suckPositions.size()) return;
suckPositions[idx] = pos;
}
Vector *ParticleManager::getSuckPosition(int idx)
Vector *ParticleManager::getSuckPosition(size_t idx)
{
if (idx < 0 || idx >= suckPositions.size()) return 0;
if (idx >= suckPositions.size()) return 0;
return &suckPositions[idx];
}
@ -363,7 +363,7 @@ void ParticleManager::update(float dt)
{
BBGE_PROF(ParticleManager_update);
numActive = 0;
for (int i = 0; i < particles.size(); i++)
for (size_t i = 0; i < particles.size(); i++)
{
if (particles[i].active)
{

View file

@ -198,7 +198,7 @@ class ParticleManager
{
public:
ParticleManager(int size);
void setSize(int size);
void setSize(size_t size);
void loadParticleBank(const std::string &bank1, const std::string &bank2);
void clearParticleBank();
@ -223,9 +223,9 @@ public:
int getNumActive() { return numActive; }
void setNumSuckPositions(int num);
void setSuckPosition(int idx, const Vector &pos);
void setSuckPosition(size_t idx, const Vector &pos);
Vector *getSuckPosition(int idx);
Vector *getSuckPosition(size_t idx);
static std::string particleBankPath;
@ -234,18 +234,18 @@ protected:
std::vector<Vector> suckPositions;
int numActive;
size_t numActive;
Particle* stomp();
void nextFree(int f=1);
void prevFree(int f=1);
int oldFree;
size_t oldFree;
typedef std::vector<ParticleInfluence> Influences;
Influences influences;
int size, used, free, halfSize;
size_t size, used, free, halfSize;
Particles particles;

View file

@ -62,9 +62,10 @@ void Precacher::loadTextureRange(const std::string &file, const std::string &typ
std::ostringstream os;
os << file;
for (int j = 0; j < 4 - num_os.str().size(); j++)
{
os << "0";
if(num_os.str().size() <= 4) {
for (size_t j = 0; j < 4 - num_os.str().size(); j++) {
os << "0";
}
}
os << t;

View file

@ -74,7 +74,7 @@ void Quad::createStrip(bool vert, int num)
void Quad::setStrip(const std::vector<Vector> &st)
{
resetStrip();
for (int i = 0; i < st.size(); i++)
for (size_t i = 0; i < st.size(); i++)
{
if (i < strip.size())
{
@ -92,10 +92,10 @@ void Quad::createGrid(int xd, int yd)
yDivs = yd;
drawGrid = new Vector * [xDivs];
for (int i = 0; i < xDivs; i++)
for (size_t i = 0; i < xDivs; i++)
{
drawGrid[i] = new Vector [yDivs];
for (int j = 0; j < yDivs; j++)
for (size_t j = 0; j < yDivs; j++)
{
drawGrid[i][j].z = 1;
}
@ -104,7 +104,7 @@ void Quad::createGrid(int xd, int yd)
resetGrid();
}
void Quad::setDrawGridAlpha(int x, int y, float alpha)
void Quad::setDrawGridAlpha(size_t x, size_t y, float alpha)
{
if (x < xDivs && x >= 0 && y < yDivs && y >= 0)
{
@ -116,13 +116,13 @@ void Quad::setGridPoints(bool vert, const std::vector<Vector> &points)
{
if (!drawGrid) return;
resetGrid();
for (int i = 0; i < points.size(); i++)
for (size_t i = 0; i < points.size(); i++)
{
if (!vert) // horz
{
for (int y = 0; y < yDivs; y++)
for (size_t y = 0; y < yDivs; y++)
{
for (int x = 0; x < xDivs; x++)
for (size_t x = 0; x < xDivs; x++)
{
if (x < points.size())
{
@ -133,9 +133,9 @@ void Quad::setGridPoints(bool vert, const std::vector<Vector> &points)
}
else
{
for (int x = 0; x < xDivs; x++)
for (size_t x = 0; x < xDivs; x++)
{
for (int y = 0; y < yDivs; y++)
for (size_t y = 0; y < yDivs; y++)
{
if (y < points.size())
{
@ -156,7 +156,7 @@ void Quad::resetStrip()
{
if (!stripVert)
{
for (int i = 0; i < strip.size(); i++)
for (size_t i = 0; i < strip.size(); i++)
{
float v = (i/(float(strip.size())));
@ -172,9 +172,9 @@ void Quad::resetStrip()
void Quad::resetGrid()
{
for (int i = 0; i < xDivs; i++)
for (size_t i = 0; i < xDivs; i++)
{
for (int j = 0; j < yDivs; j++)
for (size_t j = 0; j < yDivs; j++)
{
drawGrid[i][j].x = i/(float)(xDivs-1)-0.5f;
drawGrid[i][j].y = j/(float)(yDivs-1)-0.5f;
@ -226,7 +226,7 @@ void Quad::deleteGrid()
{
if (drawGrid)
{
for (int i = 0; i < xDivs; i++)
for (size_t i = 0; i < xDivs; i++)
{
delete[] drawGrid[i];
}
@ -308,14 +308,14 @@ void Quad::updateGrid(float dt)
{
gridTimer += dt * drawGridTimeMultiplier;
resetGrid();
int hx = xDivs/2;
for (int x = 0; x < xDivs; x++)
size_t hx = xDivs/2;
for (size_t x = 0; x < xDivs; x++)
{
float yoffset = x * drawGridOffsetY;
float addY = 0;
if (drawGridModY != 0)
addY = cosf(gridTimer+yoffset)*drawGridModY;
for (int y = 0; y < yDivs; y++)
for (size_t y = 0; y < yDivs; y++)
{
float xoffset = y * drawGridOffsetX;
if (drawGridModX != 0)
@ -366,11 +366,11 @@ void Quad::renderGrid()
glBegin(GL_QUADS);
float u0 = baseX;
float u1 = u0 + incX;
for (int i = 0; i < (xDivs-1); i++, u0 = u1, u1 += incX)
for (size_t i = 0; i < (xDivs-1); i++, u0 = u1, u1 += incX)
{
float v0 = 1 - percentY + baseY;
float v1 = v0 + incY;
for (int j = 0; j < (yDivs-1); j++, v0 = v1, v1 += incY)
for (size_t j = 0; j < (yDivs-1); j++, v0 = v1, v1 += incY)
{
if (drawGrid[i][j].z != 0 || drawGrid[i][j+1].z != 0 || drawGrid[i+1][j].z != 0 || drawGrid[i+1][j+1].z != 0)
{
@ -410,9 +410,10 @@ void Quad::renderGrid()
glPointSize(2);
glColor3f(1,0,0);
glBegin(GL_POINTS);
for (int i = 0; i < (xDivs-1); i++)
if(xDivs > 0 && yDivs > 0)
for (size_t i = 0; i < (xDivs-1); i++)
{
for (int j = 0; j < (yDivs-1); j++)
for (size_t j = 0; j < (yDivs-1); j++)
{
glVertex2f(w*drawGrid[i][j].x, h*drawGrid[i][j].y);
glVertex2f(w*drawGrid[i][j+1].x, h*drawGrid[i][j+1].y);
@ -453,7 +454,7 @@ void Quad::onRender()
if (!stripVert)
{
for (int i = 0; i < strip.size(); i++)
for (size_t i = 0; i < strip.size(); i++)
{
glTexCoord2f(texBits*i, 0);
glVertex2f(strip[i].x*width-_w2, strip[i].y*_h2*10 - _h2);
@ -469,7 +470,7 @@ void Quad::onRender()
glPointSize(64);
glBegin(GL_POINTS);
for (int i = 0; i < strip.size(); i++)
for (size_t i = 0; i < strip.size(); i++)
{
glVertex2f((strip[i].x*width)-_w2, strip[i].y*height);
}

View file

@ -59,7 +59,7 @@ public:
int getHeight() const {return int(height);}
void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo);
void setDrawGridAlpha(int x, int y, float alpha);
void setDrawGridAlpha(size_t x, size_t y, float alpha);
void repeatTextureToFill(bool on);
void refreshRepeatTextureToFill();
bool isRepeatingTextureToFill() const { return repeatingTextureToFill; }
@ -99,7 +99,7 @@ public:
protected:
bool repeatingTextureToFill;
float gridTimer;
int xDivs, yDivs;
size_t xDivs, yDivs;
Vector ** drawGrid;
void resetGrid();

View file

@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
bool RenderObject::renderCollisionShape = false;
int RenderObject::lastTextureApplied = 0;
size_t RenderObject::lastTextureApplied = 0;
bool RenderObject::lastTextureRepeat = false;
bool RenderObject::renderPaths = false;
@ -473,7 +473,7 @@ void RenderObject::enableMotionBlur(int sz, int off)
motionBlurPositions.resize(sz);
motionBlurFrameOffsetCounter = 0;
motionBlurFrameOffset = off;
for (int i = 0; i < motionBlurPositions.size(); i++)
for (size_t i = 0; i < motionBlurPositions.size(); i++)
{
motionBlurPositions[i].position = position;
motionBlurPositions[i].rotz = rotation.z;
@ -560,7 +560,7 @@ void RenderObject::render()
Vector oldPos = position;
float oldAlpha = alpha.x;
float oldRotZ = rotation.z;
for (int i = 0; i < motionBlurPositions.size(); i++)
for (size_t i = 0; i < motionBlurPositions.size(); i++)
{
position = motionBlurPositions[i].position;
rotation.z = motionBlurPositions[i].rotz;
@ -649,7 +649,7 @@ void RenderObject::renderCall()
glLineWidth(4);
glEnable(GL_BLEND);
int i = 0;
size_t i = 0;
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
glBindTexture(GL_TEXTURE_2D, 0);
@ -786,7 +786,7 @@ void RenderObject::renderCollision()
glColor4f(1,1,0,0.5);
for (int i = 0; i < transformedCollisionMask.size(); i++)
for (size_t i = 0; i < transformedCollisionMask.size(); i++)
{
Vector collide = this->transformedCollisionMask[i];
@ -839,11 +839,11 @@ void RenderObject::deathNotify(RenderObject *r)
deathNotifications.remove(r);
}
Vector RenderObject::getCollisionMaskNormal(int index)
Vector RenderObject::getCollisionMaskNormal(size_t index)
{
Vector sum;
int num=0;
for (int i = 0; i < this->transformedCollisionMask.size(); i++)
size_t num=0;
for (size_t i = 0; i < this->transformedCollisionMask.size(); i++)
{
if (i != index)
{

View file

@ -133,8 +133,8 @@ public:
bool isfhr();
bool isfvr();
int getIdx() const { return idx; }
void setIdx(int idx) { this->idx = idx; }
size_t getIdx() const { return idx; }
void setIdx(size_t idx) { this->idx = idx; }
void moveToFront();
void moveToBack();
@ -215,13 +215,13 @@ public:
virtual void unloadDevice();
virtual void reloadDevice();
Vector getCollisionMaskNormal(int index);
Vector getCollisionMaskNormal(size_t index);
//-------------------------------- Methods above, fields below
static bool renderCollisionShape;
static bool renderPaths;
static int lastTextureApplied;
static size_t lastTextureApplied;
static bool lastTextureRepeat;
float width, height; // Only used by Quads, but stored here for getCullRadius()
@ -329,7 +329,7 @@ protected:
bool _static;
bool _fv, _fh;
int idx;
size_t idx;
RenderObject *parent;
StateData *stateData;
float decayRate;

View file

@ -64,7 +64,7 @@ void RenderObjectLayer::setOptimizeStatic(bool opt)
void RenderObjectLayer::add(RenderObject* r)
{
int size = renderObjects.size();
size_t size = renderObjects.size();
if (firstFreeIdx >= size)
{
size += size/2; // Increase size by 50% each time we fill up.
@ -86,8 +86,8 @@ void RenderObjectLayer::add(RenderObject* r)
void RenderObjectLayer::remove(RenderObject* r)
{
const int idx = r->getIdx();
if (idx < 0 || idx >= renderObjects.size())
const size_t idx = r->getIdx();
if (idx >= renderObjects.size())
{
errorLog("Trying to remove RenderObject with invalid index");
return;
@ -101,16 +101,16 @@ void RenderObjectLayer::remove(RenderObject* r)
objectCount--;
if (idx < firstFreeIdx)
firstFreeIdx = idx;
r->setIdx(-1);
r->setIdx(~0UL);
clearDisplayList();
}
void RenderObjectLayer::moveToFront(RenderObject *r)
{
const int size = renderObjects.size();
const int curIdx = r->getIdx();
int lastUsed;
const size_t size = renderObjects.size();
const size_t curIdx = r->getIdx();
size_t lastUsed;
for (lastUsed = size-1; lastUsed > curIdx; lastUsed--)
{
if (renderObjects[lastUsed])
@ -123,7 +123,7 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
}
else if (lastUsed < size-1)
{
const int newIdx = lastUsed + 1;
const size_t newIdx = lastUsed + 1;
renderObjects[curIdx] = 0;
renderObjects[newIdx] = r;
r->setIdx(newIdx);
@ -133,12 +133,12 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
else if (objectCount == size)
{
// Expand the array so future calls have a bit of breathing room.
const int newSize = size + 10;
const size_t newSize = size + 10;
renderObjects.resize(newSize);
renderObjects[curIdx] = 0;
renderObjects[size] = r;
r->setIdx(size);
for (int i = size+1; i < newSize; i++)
for (size_t i = size+1; i < newSize; i++)
renderObjects[i] = 0;
if (firstFreeIdx > curIdx)
firstFreeIdx = curIdx;
@ -147,13 +147,13 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
{
// Need to shift elements downward to make room for the new one.
renderObjects[curIdx] = 0;
int lastFree;
size_t lastFree;
for (lastFree = lastUsed-1; lastFree > curIdx; lastFree--)
{
if (!renderObjects[lastFree])
break;
}
for (int i = lastFree + 1; i <= lastUsed; i++)
for (size_t i = lastFree + 1; i <= lastUsed; i++)
{
renderObjects[i-1] = renderObjects[i];
renderObjects[i-1]->setIdx(i-1); // Known to be non-NULL.
@ -171,9 +171,9 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
void RenderObjectLayer::moveToBack(RenderObject *r)
{
const int size = renderObjects.size();
const int curIdx = r->getIdx();
int firstUsed;
const size_t size = renderObjects.size();
const size_t curIdx = r->getIdx();
size_t firstUsed;
for (firstUsed = 0; firstUsed < curIdx; firstUsed++)
{
if (renderObjects[firstUsed])
@ -197,19 +197,19 @@ void RenderObjectLayer::moveToBack(RenderObject *r)
}
else if (objectCount == size)
{
const int newSize = size + 10;
const int sizeDiff = newSize - size;
const int newIdx = sizeDiff - 1;
const size_t newSize = size + 10;
const size_t sizeDiff = newSize - size;
const size_t newIdx = sizeDiff - 1;
renderObjects.resize(newSize);
renderObjects[curIdx] = 0;
for (int i = newSize - 1; i >= sizeDiff; i--)
for (size_t i = newSize - 1; i >= sizeDiff; i--)
{
renderObjects[i] = renderObjects[i - sizeDiff];
if(renderObjects[i])
renderObjects[i]->setIdx(i);
}
for (int i = 0; i < newIdx; i++)
for (size_t i = 0; i < newIdx; i++)
renderObjects[i] = 0;
renderObjects[newIdx] = r;
r->setIdx(newIdx);

View file

@ -368,7 +368,7 @@ bool Shader::Uniform::operator< (const Uniform& b) const
void Shader::_queryUniforms()
{
glGetObjectParameterivARB(g_programObj, GL_OBJECT_ACTIVE_UNIFORMS_ARB , &numUniforms);
glGetObjectParameterivARB(g_programObj, GL_OBJECT_ACTIVE_UNIFORMS_ARB , (GLint*)&numUniforms);
if (numUniforms <= 0)
{

View file

@ -46,7 +46,7 @@ protected:
std::string vertFile, fragFile;
std::string vertSrc, fragSrc;
GLuint g_programObj;
int numUniforms;
size_t numUniforms;
private:
static void staticInit();
@ -58,7 +58,7 @@ private:
struct Uniform
{
int location; // GL location variable
int type;
size_t type;
bool dirty; // need to flush if true
union
{

View file

@ -87,7 +87,7 @@ void Bone::destroy()
{
Quad::destroy();
for (int i = 0; i < segments.size(); i++)
for (size_t i = 0; i < segments.size(); i++)
{
segments[i]->setLife(1.0);
segments[i]->setDecayRate(10);
@ -241,7 +241,7 @@ void Bone::updateSegments()
if (!reverse)
{
for (int i = 0; i < segments.size(); i++)
for (size_t i = 0; i < segments.size(); i++)
{
Vector diff;
if (i == 0)
@ -411,7 +411,7 @@ void AnimationLayer::animate(const std::string &a, int loop)
stringToLower(animation);
bool played = false;
for (int i = 0; i < s->animations.size(); i++)
for (size_t i = 0; i < s->animations.size(); i++)
{
if (s->animations[i].name == animation)
{
@ -487,9 +487,9 @@ void AnimationLayer::setSkeletalSprite(SkeletalSprite *s)
Animation* AnimationLayer::getCurrentAnimation()
{
if (currentAnimation == -1)
if (currentAnimation == ~0UL)
return &blendAnimation;
if (currentAnimation < 0 || currentAnimation >= s->animations.size())
if (currentAnimation >= s->animations.size())
{
std::ostringstream os;
os << "skel: " << s->filenameLoaded << " currentAnimation: " << currentAnimation << " is out of range\n error in anim file?";
@ -507,7 +507,7 @@ bool AnimationLayer::createTransitionAnimation(const std::string& anim, float ti
blendAnimation.keyframes.clear();
SkeletalKeyframe k;
k.t = 0;
for (int i = 0; i < s->bones.size(); i++)
for (size_t i = 0; i < s->bones.size(); i++)
{
BoneKeyframe b;
b.idx = s->bones[i]->boneIdx;
@ -561,14 +561,14 @@ Animation::Animation()
{
}
int Animation::getNumKeyframes()
size_t Animation::getNumKeyframes()
{
return keyframes.size();
}
SkeletalKeyframe *Animation::getKeyframe(int key)
SkeletalKeyframe *Animation::getKeyframe(size_t key)
{
if (key < 0 || key >= keyframes.size()) return 0;
if (key >= keyframes.size()) return 0;
return &keyframes[key];
}
@ -608,9 +608,9 @@ SkeletalKeyframe *Animation::getFirstKeyframe()
void Animation::reorderKeyframes()
{
for (int i = 0; i < keyframes.size(); i++)
for (size_t i = 0; i < keyframes.size(); i++)
{
for (int j = 0; j < keyframes.size()-1; j++)
for (size_t j = 0; j < keyframes.size()-1; j++)
{
if (keyframes[j].t > keyframes[j+1].t)
{
@ -622,11 +622,11 @@ void Animation::reorderKeyframes()
}
}
void Animation::cloneKey(int key, float toffset)
void Animation::cloneKey(size_t key, float toffset)
{
std::vector<SkeletalKeyframe> copy = this->keyframes;
keyframes.clear();
int i = 0;
size_t i = 0;
for (i = 0; i <= key; i++)
keyframes.push_back(copy[i]);
for (i = key; i < copy.size(); i++)
@ -634,30 +634,30 @@ void Animation::cloneKey(int key, float toffset)
keyframes[key+1].t += toffset;
}
void Animation::deleteKey(int key)
void Animation::deleteKey(size_t key)
{
std::vector<SkeletalKeyframe> copy = this->keyframes;
keyframes.clear();
int i = 0;
size_t i = 0;
for (i = 0; i < key; i++)
keyframes.push_back(copy[i]);
for (i = key+1; i < copy.size(); i++)
keyframes.push_back(copy[i]);
}
int Animation::getSkeletalKeyframeIndex(SkeletalKeyframe *skey)
size_t Animation::getSkeletalKeyframeIndex(SkeletalKeyframe *skey)
{
for (int i = 0; i < keyframes.size(); i++)
for (size_t i = 0; i < keyframes.size(); i++)
{
if (&keyframes[i] == skey)
return i;
}
return -1;
return ~0UL;
}
BoneKeyframe *SkeletalKeyframe::getBoneKeyframe(int idx)
BoneKeyframe *SkeletalKeyframe::getBoneKeyframe(size_t idx)
{
for (int i = 0; i < keyframes.size(); i++)
for (size_t i = 0; i < keyframes.size(); i++)
{
if (keyframes[i].idx == idx)
{
@ -669,8 +669,8 @@ BoneKeyframe *SkeletalKeyframe::getBoneKeyframe(int idx)
SkeletalKeyframe *Animation::getPrevKeyframe(float t)
{
int kf = -1;
for (int i = keyframes.size()-1; i >= 0; i--)
size_t kf = ~0UL;
for (size_t i = keyframes.size(); i-- > 0; )
{
if (t >= keyframes[i].t)
{
@ -678,19 +678,17 @@ SkeletalKeyframe *Animation::getPrevKeyframe(float t)
break;
}
}
if (kf == -1)
if (kf == ~0UL)
return 0;
if (kf >= keyframes.size())
kf = keyframes.size()-1;
if (kf < 0)
kf = 0;
return &keyframes[kf];
}
SkeletalKeyframe *Animation::getNextKeyframe(float t)
{
int kf = -1;
for (int i = 0; i < keyframes.size(); i++)
size_t kf = ~0UL;
for (size_t i = 0; i < keyframes.size(); i++)
{
if (t <= keyframes[i].t)
{
@ -699,12 +697,10 @@ SkeletalKeyframe *Animation::getNextKeyframe(float t)
}
}
if (kf == -1)
if (kf == ~0UL)
return 0;
if (kf >= keyframes.size())
kf = keyframes.size()-1;
if (kf < 0)
kf = 0;
return &keyframes[kf];
}
@ -714,7 +710,7 @@ SkeletalSprite::SkeletalSprite() : RenderObject()
animKeyNotify = 0;
loaded = false;
animLayers.resize(10);
for (int i = 0; i < animLayers.size(); i++)
for (size_t i = 0; i < animLayers.size(); i++)
animLayers[i].setSkeletalSprite(this);
selectedBone = -1;
}
@ -742,9 +738,9 @@ float SkeletalSprite::transitionAnimate(const std::string& anim, float time, int
return 0;
}
AnimationLayer* SkeletalSprite::getAnimationLayer(int l)
AnimationLayer* SkeletalSprite::getAnimationLayer(size_t l)
{
if (l >= 0 && l < animLayers.size())
if (l < animLayers.size())
{
return &animLayers[l];
}
@ -764,7 +760,7 @@ void SkeletalSprite::onUpdate(float dt)
if (frozen) return;
RenderObject::onUpdate(dt);
int i = 0;
size_t i = 0;
for (i = 0; i < bones.size(); i++)
{
@ -775,7 +771,7 @@ void SkeletalSprite::onUpdate(float dt)
{
b->transformedCollisionMask.resize(b->collisionMask.size());
}
for (int i = 0; i < b->collisionMask.size(); i++)
for (size_t i = 0; i < b->collisionMask.size(); i++)
{
b->transformedCollisionMask[i] = b->getWorldCollidePosition(b->collisionMask[i]);
}
@ -846,7 +842,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
file = animationPath + filename + ".xml";
}
int i = 0;
size_t i = 0;
XMLDocument *xml = _retrieveSkeletalXML(file, true);
xml->Clear();
@ -857,7 +853,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
if (animLayers[i].ignoreBones.size() > 0)
{
std::ostringstream os;
for (int j = 0; j < animLayers[i].ignoreBones.size(); j++)
for (size_t j = 0; j < animLayers[i].ignoreBones.size(); j++)
{
os << animLayers[i].ignoreBones[j] << " ";
}
@ -866,7 +862,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
if (animLayers[i].includeBones.size() > 0)
{
std::ostringstream os;
for (int j = 0; j < animLayers[i].includeBones.size(); j++)
for (size_t j = 0; j < animLayers[i].includeBones.size(); j++)
{
os << animLayers[i].includeBones[j] << " ";
}
@ -886,7 +882,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
for (i = 0; i < this->bones.size(); i++)
{
XMLElement *bone = xml->NewElement("Bone");
bone->SetAttribute("idx", this->bones[i]->boneIdx);
bone->SetAttribute("idx", (unsigned int) this->bones[i]->boneIdx);
bone->SetAttribute("gfx", this->bones[i]->gfx.c_str());
bone->SetAttribute("pidx", this->bones[i]->pidx);
bone->SetAttribute("name", this->bones[i]->name.c_str());
@ -964,7 +960,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
animation->SetAttribute("name", a->name.c_str());
if(a->resetPassOnEnd)
animation->SetAttribute("resetPassOnEnd", a->resetPassOnEnd);
for (int j = 0; j < a->keyframes.size(); j++)
for (size_t j = 0; j < a->keyframes.size(); j++)
{
XMLElement *key = xml->NewElement("Key");
if (!a->keyframes[j].sound.empty())
@ -980,12 +976,12 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
std::ostringstream os;
os << a->keyframes[j].t << " ";
std::ostringstream szos;
for (int k = 0; k < a->keyframes[j].keyframes.size(); k++)
for (size_t k = 0; k < a->keyframes[j].keyframes.size(); k++)
{
BoneKeyframe *b = &a->keyframes[j].keyframes[k];
os << b->idx << " " << b->x << " " << b->y << " " << b->rot << " ";
os << b->strip.size() << " ";
for (int i = 0; i < b->strip.size(); i++)
for (size_t i = 0; i < b->strip.size(); i++)
{
os << b->strip[i].x << " " << b->strip[i].y << " ";
}
@ -1008,19 +1004,19 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
return xml->SaveFile(file.c_str()) == XML_SUCCESS;
}
int SkeletalSprite::getBoneIdx(Bone *b)
size_t SkeletalSprite::getBoneIdx(Bone *b)
{
for (int i = 0; i < bones.size(); i++)
for (size_t i = 0; i < bones.size(); i++)
{
if (bones[i] == b)
return i;
}
return -1;
return ~0UL;
}
void SkeletalSprite::toggleBone(int idx, int v)
void SkeletalSprite::toggleBone(size_t idx, int v)
{
if (idx >= 0 && idx < bones.size())
if (idx < bones.size())
{
bones[idx]->alpha.x = v;
}
@ -1028,7 +1024,7 @@ void SkeletalSprite::toggleBone(int idx, int v)
Bone *SkeletalSprite::getBoneByName(const std::string &name)
{
for (int i = 0; i < bones.size(); i++)
for (size_t i = 0; i < bones.size(); i++)
{
if (bones[i]->name == name)
return bones[i];
@ -1039,9 +1035,9 @@ Bone *SkeletalSprite::getBoneByName(const std::string &name)
return 0;
}
Bone *SkeletalSprite::getBoneByIdx(int idx)
Bone *SkeletalSprite::getBoneByIdx(size_t idx)
{
for (int i = 0; i < bones.size(); i++)
for (size_t i = 0; i < bones.size(); i++)
{
if (bones[i]->boneIdx == idx)
return bones[i];
@ -1112,7 +1108,7 @@ void SkeletalSprite::deleteBones()
Animation *SkeletalSprite::getAnimation(const std::string& anim)
{
for (int i = 0; i < animations.size(); i++)
for (size_t i = 0; i < animations.size(); i++)
{
if (animations[i].name == anim)
return &animations[i];
@ -1215,7 +1211,7 @@ void SkeletalSprite::stopAnimation(int layer)
void SkeletalSprite::stopAllAnimations()
{
for (int i = 0; i < animLayers.size(); i++)
for (size_t i = 0; i < animLayers.size(); i++)
{
animLayers[i].stopAnimation();
}
@ -1435,7 +1431,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
bone = bone->NextSiblingElement("Bone");
}
// attach bones
for (int i = 0; i < this->bones.size(); i++)
for (size_t i = 0; i < this->bones.size(); i++)
{
Bone *b = this->bones[i];
if (b->pidx != -1)
@ -1535,7 +1531,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
if (strip>0)
{
b.strip.resize(strip);
for (int i = 0; i < b.strip.size(); i++)
for (size_t i = 0; i < b.strip.size(); i++)
{
is >> b.strip[i].x >> b.strip[i].y;
@ -1609,7 +1605,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
}
}
// generate empty bone keys
for (int i = 0; i < this->bones.size(); i++)
for (size_t i = 0; i < this->bones.size(); i++)
{
if (newSkeletalKeyframe.getBoneKeyframe(this->bones[i]->boneIdx))
{
@ -1630,12 +1626,12 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
}
}
Animation *SkeletalSprite::getCurrentAnimation(int layer)
Animation *SkeletalSprite::getCurrentAnimation(size_t layer)
{
return layer < animLayers.size() ? animLayers[layer].getCurrentAnimation() : NULL;
}
void SkeletalSprite::setTime(float time, int layer)
void SkeletalSprite::setTime(float time, size_t layer)
{
if(layer < animLayers.size())
animLayers[layer].timer = time;
@ -1643,7 +1639,7 @@ void SkeletalSprite::setTime(float time, int layer)
void AnimationLayer::resetPass()
{
for (int i = 0; i < s->bones.size(); i++)
for (size_t i = 0; i < s->bones.size(); i++)
{
Bone *b = s->bones[i];
if (contains(b))
@ -1656,13 +1652,13 @@ bool AnimationLayer::contains(const Bone *b) const
const int idx = b->boneIdx;
if (!ignoreBones.empty())
{
for (int j = 0; j < ignoreBones.size(); j++)
for (size_t j = 0; j < ignoreBones.size(); j++)
if (idx == ignoreBones[j])
return false;
}
else if (!includeBones.empty())
{
for (int j = 0; j < includeBones.size(); j++)
for (size_t j = 0; j < includeBones.size(); j++)
if (idx == includeBones[j])
return true;
return false;
@ -1698,7 +1694,7 @@ void AnimationLayer::updateBones()
}
if (!key2->commands.empty())
{
for (int i = 0; i < key2->commands.size(); i++)
for (size_t i = 0; i < key2->commands.size(); i++)
{
key2->commands[i].run();
}
@ -1710,7 +1706,7 @@ void AnimationLayer::updateBones()
}
lastNewKey = key2;
for (int i = 0; i < s->bones.size(); i++)
for (size_t i = 0; i < s->bones.size(); i++)
{
Bone *b = s->bones[i];
@ -1762,7 +1758,7 @@ void AnimationLayer::updateBones()
bkey2->strip.resize(b->changeStrip.size());
if (bkey1->strip.size() < b->changeStrip.size())
bkey1->strip.resize(b->changeStrip.size());
for (int i = 0; i < b->changeStrip.size(); i++)
for (size_t i = 0; i < b->changeStrip.size(); i++)
{
b->changeStrip[i] = Vector(lerp(bkey1->strip[i].x, bkey2->strip[i].x, dt, lerpType), lerp(bkey1->strip[i].y, bkey2->strip[i].y, dt, lerpType));
}
@ -1784,7 +1780,7 @@ void SkeletalSprite::updateBones()
{
if (!frozen)
{
for (int i = 0; i < animLayers.size(); i++)
for (size_t i = 0; i < animLayers.size(); i++)
{
animLayers[i].updateBones();
}
@ -1811,7 +1807,7 @@ Bone* SkeletalSprite::getSelectedBone(bool mouseBased)
float closestDist = HUGE_VALF;
Bone *b = 0;
Vector p = core->mouse.position;
for (int i = 0; i < bones.size(); i++)
for (size_t i = 0; i < bones.size(); i++)
{
if (bones[i]->renderQuad || core->getShiftState())
{
@ -1835,7 +1831,7 @@ Bone* SkeletalSprite::getSelectedBone(bool mouseBased)
return b;
}
// else
if (!bones.empty() && selectedBone >= 0 && selectedBone < bones.size())
if (!bones.empty() && selectedBone < bones.size())
return bones[selectedBone];
return 0;
@ -1844,7 +1840,7 @@ Bone* SkeletalSprite::getSelectedBone(bool mouseBased)
void SkeletalSprite::updateSelectedBoneColor()
{
for (int i = 0; i < bones.size(); i++)
for (size_t i = 0; i < bones.size(); i++)
{
bones[i]->color = Vector(1,1,1);
}
@ -1861,7 +1857,7 @@ void SkeletalSprite::setSelectedBone(int b)
void SkeletalSprite::selectPrevBone()
{
const int oldsel = selectedBone;
const size_t oldsel = selectedBone;
do
{
selectedBone++;
@ -1876,7 +1872,7 @@ void SkeletalSprite::selectPrevBone()
void SkeletalSprite::selectNextBone()
{
const int oldsel = selectedBone;
const size_t oldsel = selectedBone;
do
{
selectedBone--;

View file

@ -59,7 +59,8 @@ public:
void destroy();
std::string gfx;
std::string name;
int boneIdx, pidx, rbp;
size_t boneIdx;
int pidx, rbp;
std::map<int, ParticleEffect*> emitters;
std::string prt;
std::vector<Vector> changeStrip;
@ -106,7 +107,8 @@ class BoneKeyframe
{
public:
BoneKeyframe() : idx(0), x(0), y(0), rot(0), sx(1), sy(1), doScale(0) {}
int idx, x, y, rot;
size_t idx;
int x, y, rot;
float sx, sy;
bool doScale;
std::vector<Vector> strip;
@ -124,7 +126,7 @@ public:
float t;
std::string sound;
std::vector<BoneKeyframe> keyframes;
BoneKeyframe *getBoneKeyframe(int idx);
BoneKeyframe *getBoneKeyframe(size_t idx);
std::string cmd;
std::vector<BoneCommand> commands;
@ -138,17 +140,17 @@ public:
std::string name;
typedef std::vector <SkeletalKeyframe> Keyframes;
Keyframes keyframes;
SkeletalKeyframe *getKeyframe(int key);
SkeletalKeyframe *getKeyframe(size_t key);
SkeletalKeyframe *getLastKeyframe();
SkeletalKeyframe *getFirstKeyframe();
SkeletalKeyframe *getPrevKeyframe(float t);
SkeletalKeyframe *getNextKeyframe(float t);
void cloneKey(int key, float toffset);
void deleteKey(int key);
void cloneKey(size_t key, float toffset);
void deleteKey(size_t key);
void reorderKeyframes();
float getAnimationLength();
int getSkeletalKeyframeIndex(SkeletalKeyframe *skey);
int getNumKeyframes();
size_t getSkeletalKeyframeIndex(SkeletalKeyframe *skey);
size_t getNumKeyframes();
void reverse();
bool resetPassOnEnd;
};
@ -197,7 +199,7 @@ public:
//HACK: should be a lerped float
InterpolatedVector timeMultiplier;
float animationLength;
int currentAnimation;
size_t currentAnimation;
bool animating;
@ -212,13 +214,13 @@ public:
bool saveSkeletal(const std::string &fn);
void loadSkin(const std::string &fn);
Bone *getBoneByIdx(int idx);
Bone *getBoneByIdx(size_t idx);
Bone *getBoneByName(const std::string &name);
void animate(const std::string &animation, int loop = 0, int layer=0);
void setTime(float time, int layer=0);
void setTime(float time, size_t layer=0);
void updateBones();
void playCurrentAnimation(int loop=0, int layer=0);
@ -232,7 +234,7 @@ public:
void setTimeMultiplier(float t, int layer=0);
Bone* getSelectedBone(bool mouseBased = true);
Animation *getCurrentAnimation(int layer=0);
Animation *getCurrentAnimation(size_t layer=0);
void nextAnimation();
@ -259,9 +261,9 @@ public:
bool isLoaded();
int getNumAnimLayers() const { return animLayers.size(); }
AnimationLayer* getAnimationLayer(int l);
int getBoneIdx(Bone *b);
void toggleBone(int idx, int v);
AnimationLayer* getAnimationLayer(size_t l);
size_t getBoneIdx(Bone *b);
void toggleBone(size_t idx, int v);
void setAnimationKeyNotify(RenderObject *r);
@ -274,7 +276,7 @@ protected:
bool frozen;
RenderObject *animKeyNotify;
bool loaded;
int selectedBone;
size_t selectedBone;
friend class AnimationLayer;
std::vector<AnimationLayer> animLayers;
Bone* initBone(int idx, std::string gfx, int pidx, int rbp=0, std::string name="", float cr=0, bool fh=false, bool fv=false);

View file

@ -1388,8 +1388,8 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
f = core->adjustFilenameCase(f);
}
int loc = f.find_last_of('/');
int loc2 = f.rfind('.');
size_t loc = f.find_last_of('/');
size_t loc2 = f.rfind('.');
if (loc != std::string::npos && loc2 != std::string::npos)
{
name = f.substr(loc+1, loc2-(loc+1));

View file

@ -72,7 +72,7 @@ StateData::StateData()
StateData::~StateData()
{
for (int i = 0; i < renderObjects.size(); i++)
for (size_t i = 0; i < renderObjects.size(); i++)
{
removeRenderObject (renderObjects[i]);
delete renderObjects[i];
@ -115,7 +115,7 @@ void StateData::eraseRenderObjects()
// why clear garbage here?
//core->clearGarbage();
for (int i = 0; i < renderObjects.size(); i++)
for (size_t i = 0; i < renderObjects.size(); i++)
{
RenderObject *r = renderObjects[i];
if (r && !r->isDead())
@ -278,7 +278,7 @@ StateObject *StateManager::addStateInstance(StateObject *s)
void StateManager::clearStateInstances()
{
for (int i = 0; i < stateInstances.size(); i++)
for (size_t i = 0; i < stateInstances.size(); i++)
{
StateObject *obj = stateInstances[i];
delete obj;

View file

@ -147,7 +147,7 @@ std::string getInputCodeToUserString(int key)
if ((*i).second == key)
{
std::string use = (*i).first;
int idx = 0;
size_t idx = 0;
idx = use.find("KEY_");
if (idx != std::string::npos)
{

View file

@ -221,7 +221,7 @@ float TTFText::getLineHeight()
int TTFText::findLine(const std::string &label)
{
for (int i = 0; i < text.size(); i++)
for (size_t i = 0; i < text.size(); i++)
{
if (text[i].find(label) != std::string::npos)
{
@ -235,7 +235,7 @@ void TTFText::onRender()
{
for (int i = 0; i < text.size(); i++)
for (size_t i = 0; i < text.size(); i++)
{
if (shadow)
{

View file

@ -156,7 +156,7 @@ int Texture::getPixelWidth()
if (!data)
return 0;
int smallestx = -1, largestx = -1;
size_t smallestx = ~0UL, largestx = 0;
for (unsigned int x = 0; x < unsigned(w); x++)
{
for (unsigned int y = 0; y < unsigned(h); y++)
@ -164,9 +164,9 @@ int Texture::getPixelWidth()
unsigned int p = (y*unsigned(w)*4) + (x*4) + 3;
if (p < size && data[p] >= 254)
{
if (smallestx == -1 || x < smallestx)
if (x < smallestx)
smallestx = x;
if (largestx == -1 || x > largestx)
if (x > largestx)
largestx = x;
}
}
@ -183,17 +183,17 @@ int Texture::getPixelHeight()
if (!data)
return 0;
int smallesty = -1, largesty = -1;
size_t smallesty = ~0UL, largesty = 0;
for (unsigned int x = 0; x < unsigned(w); x++)
{
for (unsigned int y = 0; y < unsigned(h); y++)
{
int p = (y*unsigned(w)*4) + (x*4) + 3;
size_t p = (y*unsigned(w)*4) + (x*4) + 3;
if (p < size && data[p] >= 254)
{
if (smallesty == -1 || y < smallesty)
if (y < smallesty)
smallesty = y;
if (largesty == -1 || y > largesty)
if (y > largesty)
largesty = y;
}
}
@ -453,9 +453,9 @@ ImageTGA *Texture::TGAloadMem(void *mem, int size)
byte length = 0; // The length in bytes to the pixels
byte imageType = 0; // The image type (RLE, RGB, Alpha...)
byte bits = 0; // The bits per pixel for the image (16, 24, 32)
int channels = 0; // The channels of the image (3 = RGA : 4 = RGBA)
int stride = 0; // The stride (channels * width)
int i = 0; // A counter
uint32_t channels = 0; // The channels of the image (3 = RGA : 4 = RGBA)
uint32_t stride = 0; // The stride (channels * width)
size_t i = 0; // A counter
// This function loads in a TARGA (.TGA) file and returns its data to be
// used as a texture or what have you. This currently loads in a 16, 24

View file

@ -165,7 +165,7 @@ void VectorPath::realPercentageCalc()
{
float totalLen = getLength();
float len = 0;
for (int i = 1; i < pathNodes.size(); i++)
for (size_t i = 1; i < pathNodes.size(); i++)
{
Vector diff = pathNodes[i].value - pathNodes[i-1].value;
len += diff.getLength2D();
@ -188,7 +188,7 @@ float VectorPath::getSubSectionLength(int startIncl, int endIncl)
float VectorPath::getLength()
{
float len = 0;
for (int i = 1; i < pathNodes.size(); i++)
for (size_t i = 1; i < pathNodes.size(); i++)
{
Vector diff = pathNodes[i].value - pathNodes[i-1].value;
len += diff.getLength2D();
@ -205,7 +205,7 @@ void VectorPath::splice(const VectorPath &path, int sz)
{
std::vector<VectorPathNode> copy = pathNodes;
pathNodes.clear();
int i = 0;
size_t i = 0;
for (i = 0; i < path.pathNodes.size(); i++)
pathNodes.push_back(path.pathNodes[i]);
for (i = sz+1; i < copy.size(); i++)
@ -226,7 +226,7 @@ void VectorPath::prepend(const VectorPath &path)
{
std::vector<VectorPathNode> copy = pathNodes;
pathNodes.clear();
int i = 0;
size_t i = 0;
for (i = 0; i < path.pathNodes.size(); i++)
pathNodes.push_back(path.pathNodes[i]);
for (i = 0; i < copy.size(); i++)
@ -235,7 +235,7 @@ void VectorPath::prepend(const VectorPath &path)
void VectorPath::calculatePercentages()
{
for (int i = 0; i < pathNodes.size(); i++)
for (size_t i = 0; i < pathNodes.size(); i++)
{
pathNodes[i].percent = i/float(pathNodes.size());
}
@ -245,7 +245,7 @@ void VectorPath::append(const VectorPath &path)
{
std::vector<VectorPathNode> copy = pathNodes;
pathNodes.clear();
int i = 0;
size_t i = 0;
for (i = 0; i < copy.size(); i++)
pathNodes.push_back(copy[i]);
for (i = 0; i < path.pathNodes.size(); i++)
@ -256,7 +256,7 @@ void VectorPath::cut(int n)
{
std::vector<VectorPathNode> copy = pathNodes;
pathNodes.clear();
for (int i = 0; i < copy.size(); i+=n)
for (size_t i = 0; i < copy.size(); i+=n)
{
pathNodes.push_back(copy[i]);
}
@ -278,7 +278,7 @@ Vector VectorPath::getValue(float usePercent)
VectorPathNode *target = 0;
VectorPathNode *from = &pathNodes[0];
for (int i = 0; i < pathNodes.size(); ++i)
for (size_t i = 0; i < pathNodes.size(); ++i)
{
if (pathNodes[i].percent >= usePercent)
{

View file

@ -375,9 +375,9 @@ public:
void clear();
void addPathNode(Vector v, float p);
Vector getValue(float percent);
int getNumPathNodes() { return pathNodes.size(); }
size_t getNumPathNodes() { return pathNodes.size(); }
void resizePathNodes(int sz) { pathNodes.resize(sz); }
VectorPathNode *getPathNode(int i) { if (i<getNumPathNodes() && i >= 0) return &pathNodes[i]; return 0; }
VectorPathNode *getPathNode(size_t i) { if (i<getNumPathNodes()) return &pathNodes[i]; return 0; }
void cut(int n);
void splice(const VectorPath &path, int sz);
void prepend(const VectorPath &path);

View file

@ -76,6 +76,6 @@ inline unsigned int clz(uint32 x)
}; // end namespace bithacks
} // end namespace bithacks
#endif