formating code
This commit is contained in:
parent
0dd0b73b2a
commit
94dbb1a1da
19 changed files with 54 additions and 58 deletions
|
@ -159,13 +159,13 @@ void Actor::walkForward() {
|
|||
Sector::ExitInfo ei;
|
||||
|
||||
g_engine->currScene()->findClosestSector(_pos, &currSector, &_pos);
|
||||
if (currSector == NULL) { // Shouldn't happen...
|
||||
if (!currSector) { // Shouldn't happen...
|
||||
_pos += forwardVec * dist;
|
||||
_walkedCur = true;
|
||||
return;
|
||||
}
|
||||
|
||||
while (currSector != NULL) {
|
||||
while (currSector) {
|
||||
prevSector = currSector;
|
||||
Vector3d puckVector = currSector->projectToPuckVector(forwardVec);
|
||||
puckVector /= puckVector.magnitude();
|
||||
|
@ -210,7 +210,7 @@ Vector3d Actor::puckVector() const {
|
|||
Vector3d forwardVec(-std::sin(yaw_rad), std::cos(yaw_rad), 0);
|
||||
|
||||
Sector *sector = g_engine->currScene()->findPointSector(_pos, 0x1000);
|
||||
if (sector == NULL)
|
||||
if (!sector)
|
||||
return forwardVec;
|
||||
else
|
||||
return sector->projectToPuckVector(forwardVec);
|
||||
|
@ -351,7 +351,7 @@ void Actor::sayLine(const char *msg, const char *msgId) {
|
|||
_lipSynch = g_resourceloader->loadLipSynch(soundLip.c_str());
|
||||
// If there's no lip synch file then load the mumble chore if it exists
|
||||
// (the mumble chore doesn't exist with the cat races announcer)
|
||||
if (_lipSynch == NULL && _mumbleChore != -1)
|
||||
if (!_lipSynch && _mumbleChore != -1)
|
||||
_mumbleCostume->playChoreLooping(_mumbleChore);
|
||||
|
||||
_talkAnim = -1;
|
||||
|
@ -398,15 +398,15 @@ void Actor::shutUp() {
|
|||
g_imuse->stopSound(_talkSoundName.c_str());
|
||||
_talkSoundName = "";
|
||||
}
|
||||
if (_lipSynch != NULL) {
|
||||
if ((_talkAnim != -1) && (_talkChore[_talkAnim] >= 0))
|
||||
if (_lipSynch) {
|
||||
if (_talkAnim != -1 && _talkChore[_talkAnim] >= 0)
|
||||
_talkCostume[_talkAnim]->stopChore(_talkChore[_talkAnim]);
|
||||
_lipSynch = NULL;
|
||||
} else if (_mumbleChore >= 0) {
|
||||
_mumbleCostume->stopChore(_mumbleChore);
|
||||
}
|
||||
|
||||
if (_sayLineText != NULL) {
|
||||
if (_sayLineText) {
|
||||
g_engine->killTextObject(_sayLineText);
|
||||
_sayLineText = NULL;
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ void Actor::popCostume() {
|
|||
newCost = NULL;
|
||||
else
|
||||
newCost = _costumeStack.back();
|
||||
if (newCost == NULL) {
|
||||
if (!newCost) {
|
||||
if (debugLevel == DEBUG_NORMAL || debugLevel == DEBUG_ALL)
|
||||
printf("Popped (freed) the last costume for an actor.\n");
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ void Actor::update() {
|
|||
_currTurnDir = 0;
|
||||
|
||||
// Update lip synching
|
||||
if (_lipSynch != NULL) {
|
||||
if (_lipSynch) {
|
||||
int posSound;
|
||||
|
||||
// While getPosIn60HzTicks will return "-1" to indicate that the
|
||||
|
|
|
@ -324,7 +324,7 @@ void DriverTinyGL::drawModelFace(const Model::Face *face, float *vertices, float
|
|||
for (int i = 0; i < face->_numVertices; i++) {
|
||||
tglNormal3fv(vertNormals + 3 * face->_vertices[i]);
|
||||
|
||||
if (face->_texVertices != NULL)
|
||||
if (face->_texVertices)
|
||||
tglTexCoord2fv(textureVerts + 2 * face->_texVertices[i]);
|
||||
|
||||
tglVertex3fv(vertices + 3 * face->_vertices[i]);
|
||||
|
@ -348,7 +348,7 @@ void DriverTinyGL::translateViewpoint() {
|
|||
void DriverTinyGL::drawHierachyNode(const Model::HierNode *node) {
|
||||
translateViewpoint(node->_animPos / node->_totalWeight, node->_animPitch / node->_totalWeight, node->_animYaw / node->_totalWeight, node->_animRoll / node->_totalWeight);
|
||||
if (node->_hierVisible) {
|
||||
if (node->_mesh != NULL && node->_meshVisible) {
|
||||
if (node->_mesh && node->_meshVisible) {
|
||||
tglPushMatrix();
|
||||
tglTranslatef(node->_pivot.x(), node->_pivot.y(), node->_pivot.z());
|
||||
node->_mesh->draw();
|
||||
|
@ -356,14 +356,14 @@ void DriverTinyGL::drawHierachyNode(const Model::HierNode *node) {
|
|||
tglPopMatrix();
|
||||
}
|
||||
|
||||
if (node->_child != NULL) {
|
||||
if (node->_child) {
|
||||
node->_child->draw();
|
||||
tglMatrixMode(TGL_MODELVIEW);
|
||||
}
|
||||
}
|
||||
translateViewpoint();
|
||||
|
||||
if (node->_sibling != NULL)
|
||||
if (node->_sibling)
|
||||
node->_sibling->draw();
|
||||
}
|
||||
|
||||
|
|
|
@ -117,9 +117,9 @@ void Bitmap::draw() const {
|
|||
}
|
||||
|
||||
Bitmap::~Bitmap() {
|
||||
if(_data != NULL) {
|
||||
if (_data) {
|
||||
for (int i = 0; i < _numImages; i++)
|
||||
if(_data[i])
|
||||
if (_data[i])
|
||||
delete[] _data[i];
|
||||
|
||||
delete[] _data;
|
||||
|
|
|
@ -197,7 +197,7 @@ void registerDefaults() {
|
|||
DO_OPTION(shortCmd, longCmd) \
|
||||
char *endptr = 0; \
|
||||
int intValue; intValue = (int)strtol(option, &endptr, 0); \
|
||||
if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);
|
||||
if (!endptr || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option);
|
||||
|
||||
// Use this for boolean options; this distinguishes between "-x" and "-X",
|
||||
// resp. between "--some-option" and "--no-some-option".
|
||||
|
|
|
@ -200,7 +200,7 @@ void BitmapComponent::setKey(int val) {
|
|||
/* In case you feel like drawing the missing bitmap anyway...
|
||||
// Assume that all objects the scene file forgot about are OBJSTATE_STATE class
|
||||
state = new ObjectState(0, ObjectState::OBJSTATE_STATE, bitmap, NULL, true);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
if (debugLevel == DEBUG_BITMAPS || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
|
||||
warning("Couldn't find bitmap %s in current scene\n", _filename.c_str());
|
||||
return;
|
||||
|
@ -242,7 +242,7 @@ void ModelComponent::init() {
|
|||
|
||||
// Get the default colormap if we haven't found
|
||||
// a valid colormap
|
||||
if (cmap == NULL) {
|
||||
if (!cmap) {
|
||||
if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
|
||||
warning("No colormap specified for %s, using %s\n", _filename.c_str(), DEFAULT_COLORMAP);
|
||||
|
||||
|
@ -942,8 +942,7 @@ void Costume::playChore(int num) {
|
|||
void Costume::setColormap(char *map) {
|
||||
// Sometimes setColormap is called on a null costume,
|
||||
// see where raoul is gone in hh.set
|
||||
// ??? this == null - aquadran
|
||||
if (this == NULL || !map)
|
||||
if (!map)
|
||||
return;
|
||||
_cmap = g_resourceloader->loadColormap(map);
|
||||
for (int i = 0; i < _numComponents; i++)
|
||||
|
|
|
@ -177,7 +177,7 @@ ImuseSndMgr::SoundDesc *ImuseSndMgr::openSound(const char *soundName, int volGro
|
|||
|
||||
if (strcasecmp(extension, "imu") == 0) {
|
||||
sound->blockRes = g_resourceloader->getFileBlock(soundName);
|
||||
if (sound->blockRes != NULL) {
|
||||
if (sound->blockRes) {
|
||||
ptr = (byte *)sound->blockRes->data();
|
||||
parseSoundHeader(ptr, sound, headerSize);
|
||||
sound->mcmpData = false;
|
||||
|
|
|
@ -303,7 +303,7 @@ static void FunctionName() {
|
|||
int curr_line = lua_currentline(lua_getparam(1));
|
||||
if (curr_line > 0)
|
||||
sprintf(buf + strlen(buf), " at line %d", curr_line);
|
||||
if (filename != NULL)
|
||||
if (filename)
|
||||
sprintf(buf + strlen(buf), " [in file %.100s]", filename);
|
||||
lua_pushstring(buf);
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ static void SetActorWalkChore() {
|
|||
act = check_actor(1);
|
||||
chore = check_int(2);
|
||||
costume = get_costume(act, 3, "SetActorWalkChore");
|
||||
if (costume == NULL) {
|
||||
if (!costume) {
|
||||
if (debugLevel == DEBUG_CHORES || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
|
||||
warning("SetActorWalkChore() could not find the requested costume, attempting to load...");
|
||||
act->pushCostume(lua_getstring(lua_getparam(3)));
|
||||
|
@ -858,7 +858,7 @@ static void SetActorWalkDominate() {
|
|||
|
||||
DEBUG_FUNCTION();
|
||||
act = check_actor(1);
|
||||
if (act == NULL) {
|
||||
if (!act) {
|
||||
lua_pushnil();
|
||||
return;
|
||||
}
|
||||
|
@ -1115,7 +1115,7 @@ static void ActorLookAt() {
|
|||
nullvector = true;
|
||||
if (lua_isnumber(y))
|
||||
rate = luaL_check_number(3);
|
||||
} else if ( lua_isnumber(x)) { // look at xyz
|
||||
} else if (lua_isnumber(x)) { // look at xyz
|
||||
float fX;
|
||||
float fY;
|
||||
float fZ;
|
||||
|
@ -1860,7 +1860,7 @@ static void GetCurrentSetup() {
|
|||
DEBUG_FUNCTION();
|
||||
name = luaL_check_string(1);
|
||||
scene = g_engine->findScene(name);
|
||||
if (scene == NULL) {
|
||||
if (!scene) {
|
||||
if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
|
||||
warning("GetCurrentSetup() Requested scene (%s) is not loaded!", name);
|
||||
lua_pushnil();
|
||||
|
@ -2357,7 +2357,7 @@ static void KillTextObject() {
|
|||
textObjectParm = check_textobject(1);
|
||||
|
||||
delText = TextObjectExists((char *) textObjectParm->name());
|
||||
if (delText != NULL)
|
||||
if (delText)
|
||||
g_engine->killTextObject(delText);
|
||||
}
|
||||
|
||||
|
@ -2505,7 +2505,7 @@ static void SetSpeechMode() {
|
|||
|
||||
DEBUG_FUNCTION();
|
||||
mode = check_int(1);
|
||||
if ((mode >= 1) && (mode <= 3))
|
||||
if (mode >= 1 && mode <= 3)
|
||||
g_engine->setSpeechMode(mode);
|
||||
}
|
||||
|
||||
|
@ -2959,7 +2959,7 @@ static void SubmitSaveGameData() {
|
|||
table = lua_getparam(1);
|
||||
|
||||
savedState = g_engine->savedState();
|
||||
if (savedState == NULL)
|
||||
if (!savedState)
|
||||
error("Cannot obtain saved game!");
|
||||
savedState->beginSection('SUBS');
|
||||
count = 0;
|
||||
|
@ -3828,7 +3828,7 @@ int bundle_dofile(const char *filename) {
|
|||
delete b;
|
||||
// Don't print warnings on Scripts\foo.lua,
|
||||
// d:\grimFandango\Scripts\foo.lua
|
||||
if (std::strstr(filename, "Scripts\\") == NULL && (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL))
|
||||
if (!std::strstr(filename, "Scripts\\") && (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL))
|
||||
warning("Cannot find script %s\n", filename);
|
||||
|
||||
return 2;
|
||||
|
|
|
@ -41,7 +41,7 @@ static int32 newsize(stringtable *tb) {
|
|||
|
||||
// count how many entries are really in use
|
||||
for (i = 0; i < size; i++)
|
||||
if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY)
|
||||
if (tb->hash[i] && tb->hash[i] != &EMPTY)
|
||||
realuse++;
|
||||
if (2 * (realuse + 1) <= size) // +1 is the new element
|
||||
return size; // don't need to grow, just rehash to clear EMPTYs
|
||||
|
@ -59,7 +59,7 @@ static void grow(stringtable *tb) {
|
|||
// rehash
|
||||
tb->nuse = 0;
|
||||
for (i = 0; i < tb->size; i++) {
|
||||
if (tb->hash[i] != NULL && tb->hash[i] != &EMPTY) {
|
||||
if (tb->hash[i] && tb->hash[i] != &EMPTY) {
|
||||
int32 h = tb->hash[i]->hash % ns;
|
||||
while (newhash[h])
|
||||
h = (h + 1) % ns;
|
||||
|
|
|
@ -253,11 +253,11 @@ Model::HierNode *Model::copyHierarchy() {
|
|||
std::memcpy(result, _rootHierNode, _numHierNodes * sizeof(HierNode));
|
||||
// Now adjust pointers
|
||||
for (int i = 0; i < _numHierNodes; i++) {
|
||||
if (result[i]._parent != NULL)
|
||||
if (result[i]._parent)
|
||||
result[i]._parent = result + (_rootHierNode[i]._parent - _rootHierNode);
|
||||
if (result[i]._child != NULL)
|
||||
if (result[i]._child)
|
||||
result[i]._child = result + (_rootHierNode[i]._child - _rootHierNode);
|
||||
if (result[i]._sibling != NULL)
|
||||
if (result[i]._sibling)
|
||||
result[i]._sibling = result + (_rootHierNode[i]._sibling - _rootHierNode);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -125,8 +125,8 @@ const char *Registry::get(const char *key, const char *defval) const {
|
|||
void Registry::set(const char *key, const char *val) {
|
||||
// Hack: Don't save these, so we can run in good_times mode
|
||||
// without new games being bogus.
|
||||
if (strstr(key, "GrimLastSet") || strstr(key, "GrimMannyState"))
|
||||
return;
|
||||
// if (strstr(key, "GrimLastSet") || strstr(key, "GrimMannyState"))
|
||||
// return;
|
||||
|
||||
_dirty = true;
|
||||
assert(val);
|
||||
|
|
|
@ -250,7 +250,7 @@ void Scene::findClosestSector(Vector3d p, Sector **sect, Vector3d *closestPt) {
|
|||
continue;
|
||||
Vector3d closestPt = sector->closestPoint(p);
|
||||
float thisDist = (closestPt - p).magnitude();
|
||||
if (resultSect == NULL || thisDist < minDist) {
|
||||
if (!resultSect || thisDist < minDist) {
|
||||
resultSect = sector;
|
||||
resultPt = closestPt;
|
||||
minDist = thisDist;
|
||||
|
|
|
@ -50,10 +50,10 @@ public:
|
|||
int _maxVolume;
|
||||
|
||||
void drawBackground() const {
|
||||
if (_currSetup->_bkgndZBm != NULL) // Some screens have no zbuffer mask (eg, Alley)
|
||||
if (_currSetup->_bkgndZBm) // Some screens have no zbuffer mask (eg, Alley)
|
||||
_currSetup->_bkgndZBm->draw();
|
||||
|
||||
if (_currSetup->_bkgndBm == NULL) {
|
||||
if (!_currSetup->_bkgndBm) {
|
||||
// This should fail softly, for some reason jumping to the signpost (sg) will load
|
||||
// the scene in such a way that the background isn't immediately available
|
||||
warning("Background hasn't loaded yet for setup %s in %s!", _currSetup->_name.c_str(), _name.c_str());
|
||||
|
@ -83,9 +83,6 @@ public:
|
|||
|
||||
// Sector access functions
|
||||
int getSectorCount() {
|
||||
// TODO: Find where this is called before we're initialized
|
||||
if (this == NULL)
|
||||
return 0;
|
||||
return _numSectors;
|
||||
}
|
||||
Sector *getSectorBase(int id) {
|
||||
|
|
|
@ -105,7 +105,7 @@ void Smush::deinit() {
|
|||
delete[] _externalBuffer;
|
||||
_externalBuffer = NULL;
|
||||
}
|
||||
if (_videoLooping && _startPos != NULL) {
|
||||
if (_videoLooping && _startPos) {
|
||||
delete[] _startPos->tmpBuf;
|
||||
delete[] _startPos;
|
||||
_startPos = NULL;
|
||||
|
@ -362,7 +362,7 @@ struct SavePos *zlibFile::getPos() {
|
|||
}
|
||||
|
||||
bool zlibFile::setPos(struct SavePos *pos) {
|
||||
if (pos == NULL) {
|
||||
if (!pos) {
|
||||
warning("Unable to rewind SMUSH movie (no position passed)!");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ void TextObject::setDefaults(TextObjectDefaults *defaults) {
|
|||
}
|
||||
|
||||
int TextObject::getBitmapWidth() {
|
||||
if (_bitmapWidthPtr == NULL)
|
||||
if (!_bitmapWidthPtr)
|
||||
return 0;
|
||||
|
||||
int width = 0;
|
||||
|
|
|
@ -174,11 +174,11 @@ void gl_enable_disable_light(GLContext *c, int light, int v) {
|
|||
l->prev = NULL;
|
||||
} else if (!v && l->enabled) {
|
||||
l->enabled = 0;
|
||||
if (l->prev == NULL)
|
||||
if (!l->prev)
|
||||
c->first_light = l->next;
|
||||
else
|
||||
l->prev->next=l->next;
|
||||
if (l->next != NULL)
|
||||
if (l->next)
|
||||
l->next->prev=l->prev;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ static void delete_list(GLContext *c, int list) {
|
|||
GLList *l;
|
||||
|
||||
l = find_list(c, list);
|
||||
assert(l != NULL);
|
||||
assert(l);
|
||||
|
||||
// free param buffer
|
||||
pb = l->first_op_buffer;
|
||||
while (pb != NULL) {
|
||||
while (pb) {
|
||||
pb1 = pb->next;
|
||||
gl_free(pb);
|
||||
pb = pb1;
|
||||
|
|
|
@ -84,7 +84,7 @@ void gl_add_select(GLContext *c, unsigned int zmin, unsigned int zmax) {
|
|||
int n, i;
|
||||
|
||||
if (!c->select_overflow) {
|
||||
if (c->select_hit == NULL) {
|
||||
if (!c->select_hit) {
|
||||
n = c->name_stack_size;
|
||||
if ((c->select_ptr-c->select_buffer + 3 + n) > c->select_size) {
|
||||
c->select_overflow = 1;
|
||||
|
|
|
@ -7,7 +7,7 @@ static GLTexture *find_texture(GLContext *c, int h) {
|
|||
GLTexture *t;
|
||||
|
||||
t = c->shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE];
|
||||
while (t != NULL) {
|
||||
while (t) {
|
||||
if (t->handle == h)
|
||||
return t;
|
||||
t = t->next;
|
||||
|
@ -32,7 +32,7 @@ static void free_texture(GLContext *c, int h) {
|
|||
|
||||
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
|
||||
im = &t->images[i];
|
||||
if (im->pixmap != NULL)
|
||||
if (im->pixmap)
|
||||
gl_free(im->pixmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,19 +31,19 @@ ZBuffer *ZB_open(int xsize, int ysize, int mode, void *frame_buffer) {
|
|||
size = zb->xsize * zb->ysize * sizeof(unsigned short);
|
||||
|
||||
zb->zbuf = (unsigned short *)gl_malloc(size);
|
||||
if (zb->zbuf == NULL)
|
||||
if (!zb->zbuf)
|
||||
goto error;
|
||||
|
||||
size = zb->xsize * zb->ysize * sizeof(unsigned int);
|
||||
|
||||
zb->zbuf2 = (unsigned int *)gl_malloc(size);
|
||||
if (zb->zbuf2 == NULL) {
|
||||
if (!zb->zbuf2) {
|
||||
gl_free(zb->zbuf);
|
||||
goto error;
|
||||
}
|
||||
if (frame_buffer == NULL) {
|
||||
if (!frame_buffer) {
|
||||
zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
|
||||
if (zb->pbuf == NULL) {
|
||||
if (!zb->pbuf) {
|
||||
gl_free(zb->zbuf);
|
||||
gl_free(zb->zbuf2);
|
||||
goto error;
|
||||
|
@ -95,7 +95,7 @@ void ZB_resize(ZBuffer *zb, void *frame_buffer, int xsize, int ysize) {
|
|||
if (zb->frame_buffer_allocated)
|
||||
gl_free(zb->pbuf);
|
||||
|
||||
if (frame_buffer == NULL) {
|
||||
if (!frame_buffer) {
|
||||
zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize);
|
||||
zb->frame_buffer_allocated = 1;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue