1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-17 03:49:28 +00:00

Merge branch 'gccwarn' into controllerfixup

This commit is contained in:
Valentin Ochs 2017-01-17 11:15:47 +01:00
commit f9357e7fca
99 changed files with 1238 additions and 792 deletions

View file

@ -177,9 +177,9 @@ int getStringToInputCode(const std::string& s)
ActionInput::ActionInput()
{
for (int i = 0; i < INP_MSESIZE; i++) mse[i] = 0;
for (int i = 0; i < INP_KEYSIZE; i++) key[i] = 0;
for (int i = 0; i < INP_JOYSIZE; i++) joy[i] = 0;
for (int i = 0; i < INP_MSESIZE; i++) data.single.mse[i] = 0;
for (int i = 0; i < INP_KEYSIZE; i++) data.single.key[i] = 0;
for (int i = 0; i < INP_JOYSIZE; i++) data.single.joy[i] = 0;
}
std::string ActionInput::toString() const
@ -188,15 +188,15 @@ std::string ActionInput::toString() const
for (int i = 0; i < INP_MSESIZE; i++)
{
os << getInputCodeToString(mse[i]) << " ";
os << getInputCodeToString(data.single.mse[i]) << " ";
}
for (int i = 0; i < INP_KEYSIZE; i++)
{
os << getInputCodeToString(key[i]) << " ";
os << getInputCodeToString(data.single.key[i]) << " ";
}
for (int i = 0; i < INP_JOYSIZE; i++)
{
os << getInputCodeToString(joy[i]) << " ";
os << getInputCodeToString(data.single.joy[i]) << " ";
}
return os.str();
@ -209,17 +209,17 @@ void ActionInput::fromString(const std::string &read)
for (int i = 0; i < INP_MSESIZE; i++)
{
is >> str;
mse[i] = getStringToInputCode(str);
data.single.mse[i] = getStringToInputCode(str);
}
for (int i = 0; i < INP_KEYSIZE; i++)
{
is >> str;
key[i] = getStringToInputCode(str);
data.single.key[i] = getStringToInputCode(str);
}
for (int i = 0; i < INP_JOYSIZE; i++)
{
is >> str;
joy[i] = getStringToInputCode(str);
data.single.joy[i] = getStringToInputCode(str);
}
}

View file

@ -49,9 +49,9 @@ public:
int mse[INP_MSESIZE];
int key[INP_KEYSIZE];
int joy[INP_JOYSIZE];
};
} single;
int all[INP_COMBINED_SIZE];
};
} data;
std::string toString() const;
void fromString(const std::string &read);

View file

@ -113,7 +113,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;
@ -124,7 +124,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];
}

View file

@ -148,14 +148,14 @@ void ActionSet::importAction(ActionMapper *mapper, const std::string &name, int
if (!enabled) return;
if (!mapper) return;
for (int i = 0; i < inputSet.size(); i++)
for (size_t i = 0; i < inputSet.size(); i++)
{
const ActionInput *actionInput = &inputSet[i];
if (actionInput->name == name)
{
for (int i = 0; i < INP_COMBINED_SIZE; i++)
if (actionInput->all[i])
mapper->addAction(actionID, actionInput->all[i], sourceID);
if (actionInput->data.all[i])
mapper->addAction(actionID, actionInput->data.all[i], sourceID);
return;
}
}
@ -166,14 +166,14 @@ void ActionSet::importAction(ActionMapper *mapper, const std::string &name, Even
if (!enabled) return;
if (!mapper) return;
for (int i = 0; i < inputSet.size(); i++)
for (size_t i = 0; i < inputSet.size(); i++)
{
const ActionInput *actionInput = &inputSet[i];
if (actionInput->name == name)
{
for (int i = 0; i < INP_COMBINED_SIZE; i++)
if (actionInput->all[i])
mapper->addAction(event, actionInput->all[i], state);
if (actionInput->data.all[i])
mapper->addAction(event, actionInput->data.all[i], state);
return;
}
}
@ -196,8 +196,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

@ -20,8 +20,8 @@ void ActionButtonStatus::import(const ActionSet& as)
{
const ActionInput& inp = as.inputSet[i];
for(int j = 0; j < INP_COMBINED_SIZE; ++j)
if(unsigned(inp.all[j]) < ACTION_BUTTON_ENUM_SIZE)
found[inp.all[j]] = 1;
if(unsigned(inp.data.all[j]) < ACTION_BUTTON_ENUM_SIZE)
found[inp.data.all[j]] = 1;
}
toQuery.clear();

View file

@ -81,7 +81,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])
{
@ -132,7 +132,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

@ -50,7 +50,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] != ' ')
{
@ -64,7 +64,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;
@ -127,7 +127,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)
{
@ -149,7 +149,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;
@ -158,7 +158,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";
}
@ -169,13 +169,13 @@ std::string numToZeroString(int num, int zeroes)
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]);
}
@ -319,7 +319,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;
@ -340,7 +340,7 @@ char *readFile(const std::string& path, unsigned long *size_ret)
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)
{
@ -405,7 +405,7 @@ float lerp(const float &v1, const float &v2, float dt, int lerpType)
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;
}
@ -413,7 +413,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

@ -103,7 +103,7 @@ typedef int CharTranslationTable[256]; // -1 entries are skipped
#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);
void initCharTranslationTables(const CharTranslationTable *ptab);
void stringToUpper(std::string &s);

View file

@ -148,7 +148,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;
@ -194,10 +194,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);
}
@ -265,15 +265,12 @@ 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))
if ( i < colorIndices.size() && j < colorIndices[i].size())
{
if ( i < colorIndices.size() && j < colorIndices[i].size())
{
c = colorIndices[i][j];
}
c = colorIndices[i][j];
}
return c;
}
@ -301,7 +298,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)
@ -323,7 +320,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

@ -66,7 +66,7 @@ public:
virtual void setAlign(Align align);
std::string getText();
int getWidthOnScreen();
Vector getColorIndex(int i, int j);
Vector getColorIndex(size_t i, size_t j);
void updateWordColoring();
void autoKern();
void setBitmapFontEffect(BitmapFontEffect bfe);
@ -87,8 +87,8 @@ protected:
void onUpdate(float dt);
float scrollDelay;
bool scrolling;
int currentScrollLine;
int currentScrollChar;
size_t currentScrollLine;
size_t currentScrollChar;
Align align;
float alignWidth;
void formatText();

View file

@ -89,7 +89,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();
@ -107,7 +107,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();
@ -574,7 +574,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");
@ -698,7 +698,9 @@ void Core::init()
if((SDL_Init(SDL_INIT_EVERYTHING))==-1)
{
exit_error("Failed to init SDL");
std::string msg("Failed to init SDL: ");
msg.append(SDL_GetError());
exit_error(msg);
}
loopDone = false;
@ -1222,7 +1224,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;
}
@ -1230,8 +1232,6 @@ void Core::resetTimer()
void Core::setMousePosition(const Vector &p)
{
Vector lp = core->mouse.position;
core->mouse.position = p;
float px = p.x + virtualOffX;
float py = p.y;
@ -1246,7 +1246,7 @@ void Core::setMousePosition(const Vector &p)
// 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];
@ -1335,7 +1335,7 @@ void Core::run(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];
@ -1796,11 +1796,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;
@ -1811,13 +1809,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 '_':
@ -2067,11 +2058,6 @@ void Core::print(int x, int y, const char *str, float sz)
default:
break;
}
if (isLower)
{
wasLower = true;
}
c++;
xx += 1.4f;
@ -2142,7 +2128,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];
@ -2239,7 +2225,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();
@ -2454,11 +2440,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 << "]";
@ -2477,7 +2463,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();
}
@ -2489,7 +2475,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();
}
@ -2645,8 +2631,8 @@ bool Core::saveScreenshot(const std::string &filename, bool png)
// saves an array of pixels as a TGA image
bool 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) {
@ -2712,8 +2698,8 @@ void Core::screenshot()
// saves an array of pixels as a TGA image (frees the image data passed in)
bool 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

@ -190,9 +190,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
@ -244,7 +244,7 @@ public:
void setFullscreen(bool full);
void enable2D(int pixelScaleX, int pixelScaleY);
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);
@ -435,9 +435,10 @@ public:
CoreSettings settings;
bool tgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
bool zgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
bool tgaSave(const char *filename, short unsigned int width, short unsigned int height, unsigned char pixelDepth, unsigned char *imageData);
bool zgaSave(const char *filename, short unsigned int width, short unsigned int height, unsigned char pixelDepth, unsigned char *imageData);
bool pngSave(const char *filename, unsigned width, unsigned height, unsigned char *data);
volatile int dbg_numThreadDecoders;
virtual void onBackgroundUpdate();

View file

@ -92,7 +92,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;
@ -134,7 +134,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;
@ -167,12 +167,12 @@ DebugButton::DebugButton(int buttonID, DebugButtonReceiver *receiver, int bgWidt
: RenderObject()
, label(0)
, buttonID(buttonID)
, highlight(0)
, receiver(receiver)
, activeAlpha(0.5f)
, activeColor(1,1,1)
, inactiveAlpha(0.5f)
, inactiveColor(0,0,0)
, highlight(0)
, receiver(receiver)
{
if (bgWidth == 0)
bgWidth = 150;

View file

@ -1378,7 +1378,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);
@ -1738,7 +1738,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

@ -234,7 +234,7 @@ void forEachFile(const std::string& inpath, std::string type, void callback(cons
dirent *file=0;
while ( (file=readdir(dir)) != NULL )
{
if (file->d_name && strlen(file->d_name) > 4)
if (strlen(file->d_name) > 4)
{
debugLog(file->d_name);
char *extension=strrchr(file->d_name,'.');

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];
}
@ -207,12 +207,14 @@ void ParticleManager::nextFree(int jump)
void ParticleManager::prevFree(int jump)
{
free -= jump;
if (free < 0)
free += size;
if(free < jump) {
free = free + size - jump;
} else {
free -= jump;
}
}
void ParticleManager::setFree(int free)
void ParticleManager::setFree(size_t free)
{
if (free != -1)
{
@ -363,7 +365,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();
@ -217,15 +217,15 @@ public:
void endParticle(Particle *p);
void setFree(int free);
void setFree(size_t free);
int getFree() { return free; }
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

@ -63,9 +63,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,9 +104,9 @@ 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)
if (x < xDivs && y < yDivs)
{
drawGrid[x][y].z = alpha;
}
@ -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

@ -32,7 +32,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;
@ -474,7 +474,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;
@ -561,7 +561,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;
@ -650,7 +650,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);
@ -787,7 +787,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];
@ -840,11 +840,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

@ -135,8 +135,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();
@ -217,13 +217,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()
@ -331,7 +331,7 @@ protected:
bool _static;
bool _fv, _fh;
int idx;
size_t idx;
RenderObject *parent;
StateData *stateData;
float decayRate;

View file

@ -63,7 +63,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.
@ -85,8 +85,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;
@ -107,9 +107,9 @@ void RenderObjectLayer::remove(RenderObject* r)
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])
@ -122,7 +122,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);
@ -132,12 +132,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;
@ -146,13 +146,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.
@ -170,9 +170,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])
@ -196,19 +196,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

@ -327,9 +327,9 @@ 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)
if (numUniforms == 0 || numUniforms == -1)
{
uniforms.clear();
return;
@ -385,7 +385,7 @@ int Shader::_getUniformIndex(const char *name)
void Shader::setInt(const char *name, int x, int y /* = 0 */, int z /* = 0 */, int w /* = 0 */)
{
#if BBGE_BUILD_SHADERS
if(!g_programObj || numUniforms <= 0)
if(!g_programObj || numUniforms == 0 || numUniforms == -1)
return;
int idx = _getUniformIndex(name);
if(unsigned(idx) >= uniforms.size())
@ -403,7 +403,7 @@ void Shader::setInt(const char *name, int x, int y /* = 0 */, int z /* = 0 */, i
void Shader::setFloat(const char *name, float x, float y /* = 0 */, float z /* = 0 */, float w /* = 0 */)
{
#if BBGE_BUILD_SHADERS
if(!g_programObj || numUniforms <= 0)
if(!g_programObj || numUniforms == 0 || numUniforms == -1)
return;
int idx = _getUniformIndex(name);
if(unsigned(idx) >= uniforms.size())

View file

@ -46,7 +46,7 @@ protected:
std::string vertFile, fragFile;
std::string vertSrc, fragSrc;
unsigned g_programObj;
int numUniforms;
unsigned 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

@ -92,7 +92,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);
@ -246,7 +246,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)
@ -416,7 +416,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)
{
@ -494,7 +494,7 @@ Animation* AnimationLayer::getCurrentAnimation()
{
if (currentAnimation == -1)
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?";
@ -512,7 +512,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;
@ -566,14 +566,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];
}
@ -613,9 +613,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)
{
@ -627,11 +627,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++)
@ -639,20 +639,20 @@ 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;
@ -660,9 +660,9 @@ int Animation::getSkeletalKeyframeIndex(SkeletalKeyframe *skey)
return -1;
}
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)
{
@ -674,8 +674,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 = -1;
for (size_t i = keyframes.size(); i-- > 0; )
{
if (t >= keyframes[i].t)
{
@ -687,15 +687,13 @@ SkeletalKeyframe *Animation::getPrevKeyframe(float t)
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 = -1;
for (size_t i = 0; i < keyframes.size(); i++)
{
if (t <= keyframes[i].t)
{
@ -708,8 +706,6 @@ SkeletalKeyframe *Animation::getNextKeyframe(float t)
return 0;
if (kf >= keyframes.size())
kf = keyframes.size()-1;
if (kf < 0)
kf = 0;
return &keyframes[kf];
}
@ -719,7 +715,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;
}
@ -747,9 +743,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];
}
@ -769,7 +765,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++)
{
@ -780,7 +776,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]);
}
@ -851,7 +847,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();
@ -862,7 +858,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] << " ";
}
@ -871,7 +867,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] << " ";
}
@ -891,7 +887,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());
@ -969,7 +965,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())
@ -985,12 +981,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 << " ";
}
@ -1013,9 +1009,9 @@ 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;
@ -1023,9 +1019,9 @@ int SkeletalSprite::getBoneIdx(Bone *b)
return -1;
}
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;
}
@ -1033,7 +1029,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];
@ -1044,9 +1040,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];
@ -1102,7 +1098,7 @@ void SkeletalSprite::prevAnimation()
{
stopAnimation();
animLayers[0].currentAnimation--;
if (animLayers[0].currentAnimation < 0)
if (animLayers[0].currentAnimation >= animations.size())
animLayers[0].currentAnimation = animations.size()-1;
}
@ -1117,7 +1113,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];
@ -1220,7 +1216,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();
}
@ -1445,7 +1441,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)
@ -1545,7 +1541,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;
@ -1619,7 +1615,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))
{
@ -1640,12 +1636,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;
@ -1653,7 +1649,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))
@ -1666,13 +1662,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;
@ -1708,7 +1704,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();
}
@ -1720,7 +1716,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];
@ -1772,7 +1768,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));
}
@ -1794,7 +1790,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();
}
@ -1821,7 +1817,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())
{
@ -1845,7 +1841,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;
@ -1854,7 +1850,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);
}
@ -1871,7 +1867,7 @@ void SkeletalSprite::setSelectedBone(int b)
void SkeletalSprite::selectPrevBone()
{
const int oldsel = selectedBone;
const size_t oldsel = selectedBone;
do
{
selectedBone++;
@ -1886,13 +1882,13 @@ void SkeletalSprite::selectPrevBone()
void SkeletalSprite::selectNextBone()
{
const int oldsel = selectedBone;
const size_t oldsel = selectedBone;
do
{
selectedBone--;
if(selectedBone == oldsel)
break;
if (selectedBone < 0)
if (selectedBone >= bones.size())
selectedBone = bones.size()-1;
}
while (!bones[selectedBone]->selectable);

View file

@ -60,7 +60,8 @@ public:
void destroy();
std::string gfx;
std::string name;
int boneIdx, pidx, rbp;
size_t boneIdx;
int pidx, rbp;
std::string prt;
std::vector<Vector> changeStrip;
@ -109,7 +110,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;
@ -127,7 +129,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;
@ -141,17 +143,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;
};
@ -200,7 +202,7 @@ public:
//HACK: should be a lerped float
InterpolatedVector timeMultiplier;
float animationLength;
int currentAnimation;
size_t currentAnimation;
bool animating;
@ -215,13 +217,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);
@ -235,7 +237,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();
@ -262,9 +264,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);
@ -277,7 +279,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

@ -1373,8 +1373,8 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
f = 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

@ -68,7 +68,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];
@ -111,7 +111,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())
@ -274,7 +274,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;

173
BBGE/Strings.cpp Normal file
View file

@ -0,0 +1,173 @@
/*
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 "Core.h"
typedef std::map<std::string, int> InputCodeMap;
InputCodeMap inputCodeMap;
void initInputCodeMap()
{
inputCodeMap["0"] = 0;
inputCodeMap["KEY_A"] = KEY_A;
inputCodeMap["KEY_B"] = KEY_B;
inputCodeMap["KEY_C"] = KEY_C;
inputCodeMap["KEY_D"] = KEY_D;
inputCodeMap["KEY_E"] = KEY_E;
inputCodeMap["KEY_F"] = KEY_F;
inputCodeMap["KEY_G"] = KEY_G;
inputCodeMap["KEY_H"] = KEY_H;
inputCodeMap["KEY_I"] = KEY_I;
inputCodeMap["KEY_J"] = KEY_J;
inputCodeMap["KEY_K"] = KEY_K;
inputCodeMap["KEY_L"] = KEY_L;
inputCodeMap["KEY_M"] = KEY_M;
inputCodeMap["KEY_N"] = KEY_N;
inputCodeMap["KEY_O"] = KEY_O;
inputCodeMap["KEY_P"] = KEY_P;
inputCodeMap["KEY_Q"] = KEY_Q;
inputCodeMap["KEY_R"] = KEY_R;
inputCodeMap["KEY_S"] = KEY_S;
inputCodeMap["KEY_T"] = KEY_T;
inputCodeMap["KEY_U"] = KEY_U;
inputCodeMap["KEY_V"] = KEY_V;
inputCodeMap["KEY_W"] = KEY_W;
inputCodeMap["KEY_X"] = KEY_X;
inputCodeMap["KEY_Y"] = KEY_Y;
inputCodeMap["KEY_Z"] = KEY_Z;
inputCodeMap["KEY_1"] = KEY_1;
inputCodeMap["KEY_2"] = KEY_2;
inputCodeMap["KEY_3"] = KEY_3;
inputCodeMap["KEY_4"] = KEY_4;
inputCodeMap["KEY_5"] = KEY_5;
inputCodeMap["KEY_6"] = KEY_6;
inputCodeMap["KEY_7"] = KEY_7;
inputCodeMap["KEY_8"] = KEY_8;
inputCodeMap["KEY_9"] = KEY_9;
inputCodeMap["KEY_0"] = KEY_0;
inputCodeMap["KEY_NUMPAD1"] = KEY_NUMPAD1;
inputCodeMap["KEY_NUMPAD2"] = KEY_NUMPAD2;
inputCodeMap["KEY_NUMPAD3"] = KEY_NUMPAD3;
inputCodeMap["KEY_NUMPAD4"] = KEY_NUMPAD4;
inputCodeMap["KEY_NUMPAD5"] = KEY_NUMPAD5;
inputCodeMap["KEY_NUMPAD6"] = KEY_NUMPAD6;
inputCodeMap["KEY_NUMPAD7"] = KEY_NUMPAD7;
inputCodeMap["KEY_NUMPAD8"] = KEY_NUMPAD8;
inputCodeMap["KEY_NUMPAD9"] = KEY_NUMPAD9;
inputCodeMap["KEY_NUMPAD0"] = KEY_NUMPAD0;
inputCodeMap["KEY_F1"] = KEY_F1;
inputCodeMap["KEY_F2"] = KEY_F2;
inputCodeMap["KEY_F3"] = KEY_F3;
inputCodeMap["KEY_F4"] = KEY_F4;
inputCodeMap["KEY_F5"] = KEY_F5;
inputCodeMap["KEY_F6"] = KEY_F6;
inputCodeMap["KEY_F7"] = KEY_F7;
inputCodeMap["KEY_F8"] = KEY_F8;
inputCodeMap["KEY_F9"] = KEY_F9;
inputCodeMap["KEY_F10"] = KEY_F10;
inputCodeMap["KEY_F11"] = KEY_F11;
inputCodeMap["KEY_F12"] = KEY_F12;
inputCodeMap["KEY_LEFT"] = KEY_LEFT;
inputCodeMap["KEY_RIGHT"] = KEY_RIGHT;
inputCodeMap["KEY_UP"] = KEY_UP;
inputCodeMap["KEY_DOWN"] = KEY_DOWN;
inputCodeMap["KEY_SPACE"] = KEY_SPACE;
inputCodeMap["KEY_LCONTROL"] = KEY_LCONTROL;
inputCodeMap["KEY_RCONTROL"] = KEY_RCONTROL;
inputCodeMap["KEY_LSHIFT"] = KEY_LSHIFT;
inputCodeMap["KEY_RSHIFT"] = KEY_RSHIFT;
inputCodeMap["KEY_LMETA"] = KEY_LMETA;
inputCodeMap["KEY_RMETA"] = KEY_RMETA;
inputCodeMap["KEY_LALT"] = KEY_LALT;
inputCodeMap["KEY_RALT"] = KEY_RALT;
inputCodeMap["KEY_RETURN"] = KEY_RETURN;
inputCodeMap["KEY_TAB"] = KEY_TAB;
inputCodeMap["KEY_ESCAPE"] = KEY_ESCAPE;
inputCodeMap["MOUSE_BUTTON_LEFT"] = ActionMapper::MOUSE_BUTTON_LEFT;
inputCodeMap["MOUSE_BUTTON_RIGHT"] = ActionMapper::MOUSE_BUTTON_RIGHT;
inputCodeMap["MOUSE_BUTTON_MIDDLE"] = ActionMapper::MOUSE_BUTTON_MIDDLE;
for (int i = 0; i < 17; i++)
{
std::ostringstream os;
os << "JOY_BUTTON_" << i;
inputCodeMap[os.str()] = ActionMapper::JOY1_BUTTON_0+i;
}
}
void clearInputCodeMap()
{
inputCodeMap.clear();
}
std::string getInputCodeToString(int key)
{
for (InputCodeMap::iterator i = inputCodeMap.begin(); i != inputCodeMap.end(); i++)
{
if ((*i).second == key)
{
return (*i).first;
}
}
return "";
}
// FIXME: Move stringbank to BBGE and move these strings into it. -- fg
std::string getInputCodeToUserString(int key)
{
for (InputCodeMap::iterator i = inputCodeMap.begin(); i != inputCodeMap.end(); i++)
{
if ((*i).second == key)
{
std::string use = (*i).first;
size_t idx = 0;
idx = use.find("KEY_");
if (idx != std::string::npos)
{
use = use.substr(4, use.size());
}
if (use == "MOUSE_BUTTON_LEFT")
use = "Left Mouse Button";
if (use == "MOUSE_BUTTON_RIGHT")
use = "Right Mouse Button";
if (use == "MOUSE_BUTTON_MIDDLE")
use = "Middle Mouse Button";
return use;
}
}
return "";
}
int getStringToInputCode(const std::string &string)
{
return inputCodeMap[string];
}

View file

@ -235,7 +235,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)
{
@ -249,7 +249,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

@ -147,7 +147,7 @@ int Texture::getPixelWidth()
if (!data)
return 0;
int smallestx = -1, largestx = -1;
size_t smallestx = -1, largestx = 0;
for (unsigned int x = 0; x < unsigned(w); x++)
{
for (unsigned int y = 0; y < unsigned(h); y++)
@ -155,9 +155,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;
}
}
@ -174,17 +174,17 @@ int Texture::getPixelHeight()
if (!data)
return 0;
int smallesty = -1, largesty = -1;
size_t smallesty = -1, 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;
}
}
@ -427,9 +427,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

@ -179,7 +179,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();
@ -202,7 +202,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();
@ -219,7 +219,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++)
@ -240,7 +240,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++)
@ -249,7 +249,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());
}
@ -259,7 +259,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++)
@ -270,7 +270,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]);
}
@ -292,7 +292,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