Merge pull request #457 from guillemj/master

Assorted segfault fixes
This commit is contained in:
Paweł Kołodziejski 2012-01-06 05:41:46 -08:00
commit 9d2203c8ea
2 changed files with 22 additions and 12 deletions

View File

@ -407,10 +407,18 @@ Model *Costume::getModel() {
}
void Costume::setChoreLastFrame(int num) {
if (num < 0 || num >= _numChores) {
Debug::warning(Debug::Chores, "Requested chore number %d is outside the range of chores (0-%d)", num, _numChores);
return;
}
_chores[num]->setLastFrame();
}
void Costume::setChoreLooping(int num, bool val) {
if (num < 0 || num >= _numChores) {
Debug::warning(Debug::Chores, "Requested chore number %d is outside the range of chores (0-%d)", num, _numChores);
return;
}
_chores[num]->setLooping(val);
}
@ -481,11 +489,9 @@ void Costume::stopChores() {
}
void Costume::fadeChoreIn(int chore, int msecs) {
if (chore >= _numChores) {
if (chore < 0 || chore >= _numChores) {
Debug::warning(Debug::Chores, "Requested chore number %d is outside the range of chores (0-%d)", chore, _numChores);
return;
}
if (chore < 0 || chore >= _numChores) {
Debug::warning(Debug::Chores, "Requested chore number %d is outside the range of chores (0-%d)", chore, _numChores);
return;
}
_chores[chore]->fadeIn(msecs);
if (Common::find(_playingChores.begin(), _playingChores.end(), _chores[chore]) == _playingChores.end())
@ -493,11 +499,9 @@ void Costume::fadeChoreIn(int chore, int msecs) {
}
void Costume::fadeChoreOut(int chore, int msecs) {
if (chore >= _numChores) {
if (chore < 0 || chore >= _numChores) {
Debug::warning(Debug::Chores, "Requested chore number %d is outside the range of chores (0-%d)", chore, _numChores);
return;
}
if (chore < 0 || chore >= _numChores) {
Debug::warning(Debug::Chores, "Requested chore number %d is outside the range of chores (0-%d)", chore, _numChores);
return;
}
_chores[chore]->fadeOut(msecs);
}
@ -511,6 +515,10 @@ int Costume::isChoring(const char *name, bool excludeLooping) {
}
int Costume::isChoring(int num, bool excludeLooping) {
if (num < 0 || num >= _numChores) {
Debug::warning(Debug::Chores, "Requested chore number %d is outside the range of chores (0-%d)", num, _numChores);
return -1;
}
if (_chores[num]->_playing && !(excludeLooping && _chores[num]->_looping))
return num;
else

View File

@ -294,9 +294,11 @@ void gl_shade_vertex(GLContext *c, GLVertex *v) {
// testing specular buffer code
// dot_spec= pow(dot_spec,m->shininess)
specbuf = specbuf_get_buffer(c, m->shininess_i, m->shininess);
idx = (int)(dot_spec * SPECULAR_BUFFER_SIZE);
if (idx > SPECULAR_BUFFER_SIZE)
tmp = dot_spec * SPECULAR_BUFFER_SIZE;
if (tmp > SPECULAR_BUFFER_SIZE)
idx = SPECULAR_BUFFER_SIZE;
else
idx = (int)tmp;
dot_spec = specbuf->buf[idx];
lR += dot_spec * l->specular.v[0] * m->specular.v[0];