change to Assert

This commit is contained in:
nehalmistry 2004-05-08 03:21:27 +00:00
parent 7bff651546
commit 8781072f3c
9 changed files with 92 additions and 92 deletions

View file

@ -154,7 +154,7 @@ global void ClearGroup(int num)
group = &Groups[num];
for (i = 0; i < group->NumUnits; ++i) {
group->Units[i]->GroupId &= ~(1 << num);
DebugCheck(group->Units[i]->Destroyed);
Assert(!group->Units[i]->Destroyed);
}
group->NumUnits = 0;
}
@ -171,7 +171,7 @@ global void AddToGroup(Unit** units, int nunits, int num)
UnitGroup* group;
int i;
DebugCheck(num > NUM_GROUPS);
Assert(num <= NUM_GROUPS);
group = &Groups[num];
for (i = 0; group->NumUnits < MaxSelectable && i < nunits; ++i) {
@ -189,7 +189,7 @@ global void AddToGroup(Unit** units, int nunits, int num)
*/
global void SetGroup(Unit** units, int nunits, int num)
{
DebugCheck(num > NUM_GROUPS || nunits > MaxSelectable);
Assert(num <= NUM_GROUPS && nunits <= MaxSelectable);
ClearGroup(num);
AddToGroup(units, nunits, num);
@ -206,7 +206,7 @@ global void RemoveUnitFromGroups(Unit* unit)
int num;
int i;
DebugCheck(unit->GroupId == 0); // unit doesn't belong to a group
Assert(unit->GroupId != 0); // unit doesn't belong to a group
for (num = 0; unit->GroupId; ++num, unit->GroupId >>= 1) {
if ((unit->GroupId & 1) != 1) {
@ -218,7 +218,7 @@ global void RemoveUnitFromGroups(Unit* unit)
;
}
DebugCheck(i >= group->NumUnits); // oops not found
Assert(i < group->NumUnits); // oops not found
// This is a clean way that will allow us to add a unit
// to a group easily, or make an easy array walk...

View file

@ -144,7 +144,7 @@ global CLFile* CLopen(const char* fn, long openflags)
strcpy(openstring,"wb");
} else {
DebugLevel0("Bad CLopen flags");
DebugCheck(1);
Assert(0);
return NULL;
}

View file

@ -490,7 +490,7 @@ global void GameMainLoop(void)
default:
// FIXME: assume that NumPlayers < (CYCLES_PER_SECOND - 7)
player = (GameCycle % CYCLES_PER_SECOND) - 7;
DebugCheck(player < 0);
Assert(player >= 0);
if (player < NumPlayers){
PlayersEachSecond(player);
}

View file

@ -109,7 +109,7 @@ global int PlayerRacesIndex(int race)
}
}
fprintf(stderr, "Invalid race: %d\n", race);
DebugCheck(1);
Assert(0);
return PlayerRaceNeutral;
}
@ -536,8 +536,8 @@ global void CreatePlayer(int type)
*/
global void PlayerSetSide(Player* player, int side)
{
DebugCheck(side < 0 || side >= PlayerRaces.Count);
DebugCheck(!PlayerRaces.Name[side]);
Assert(side >= 0 && side < PlayerRaces.Count);
Assert(PlayerRaces.Name[side]);
player->Race = side;
player->RaceName = PlayerRaces.Name[side];

View file

@ -126,12 +126,12 @@ local void ConvertMTXM(const unsigned short* mtxm,int width,int height
int h;
int w;
DebugCheck( UnitTypeOrcWall->_HitPoints>=256
|| UnitTypeHumanWall->_HitPoints>=256 );
Assert( UnitTypeOrcWall->_HitPoints < 256
&& UnitTypeHumanWall->_HitPoints < 256 );
if( map->Terrain<TilesetMax ) {
// FIXME: should use terrain name or better map->Tileset!!
//DebugCheck( map->Tileset->Table != Tilesets[map->Terrain]->Table );
//Assert( map->Tileset->Table == Tilesets[map->Terrain]->Table );
ctab=Tilesets[map->Terrain]->Table;
DebugLevel0Fn("FIXME: %s <-> %s\n" _C_ Tilesets[map->Terrain]->Class _C_
map->TerrainName);
@ -1376,7 +1376,7 @@ local void PudWriteHeader(gzFile f,char* type,int length)
{
unsigned char buf[4];
DebugCheck( strlen(type)!=4 );
Assert( strlen(type)==4 );
if( gzwrite(f,type,4)!=4 ) {
ExitFatal(-1);
}

View file

@ -66,7 +66,7 @@ local void CclSpellMissileLocation(lua_State* l, SpellActionMissileLocation* loc
int args;
int j;
DebugCheck(location == NULL);
Assert(location != NULL);
memset(location, 0, sizeof(*location));
if (!lua_istable(l, -1)) {
@ -867,8 +867,8 @@ local void SaveSpellCondition(CLFile* file, ConditionInfo* condition)
"only" /// CONDITION_ONLY
};
int i;
DebugCheck(!file);
DebugCheck(!condition);
Assert(file);
Assert(condition);
CLprintf(file, "( ");
//

View file

@ -92,7 +92,7 @@ global void UnSelectAll(void)
*/
local void HandleSuicideClick(Unit* unit)
{
DebugCheck(!unit->Type->ClicksToExplode);
Assert(unit->Type->ClicksToExplode);
if (GameObserve) {
return;
}
@ -122,7 +122,7 @@ global void ChangeSelectedUnits(Unit** units,int count)
int i;
int n;
DebugCheck(count > MaxSelectable);
Assert(count <= MaxSelectable);
if (count == 1 && units[0]->Type->ClicksToExplode &&
!units[0]->Type->Decoration) {
@ -173,7 +173,7 @@ global void ChangeTeamSelectedUnits(Player* player, Unit** units, int adjust, in
units[i]->TeamSelected |= 1 << player->Player;
}
}
DebugCheck(TeamNumSelected[player->Player] > MaxSelectable);
Assert(TeamNumSelected[player->Player] <= MaxSelectable);
break;
case 1:
for (n = 0; n < TeamNumSelected[player->Player]; ++n) {
@ -184,10 +184,10 @@ global void ChangeTeamSelectedUnits(Player* player, Unit** units, int adjust, in
}
}
}
DebugCheck(TeamNumSelected[player->Player] < 0);
Assert(TeamNumSelected[player->Player] >= 0);
break;
default:
DebugCheck(1);
Assert(0);
}
}
@ -257,7 +257,7 @@ global void UnSelectUnit(Unit* unit)
for (j = 0; TeamSelected[i][j] != unit; ++i) {
;
}
DebugCheck(j >= TeamNumSelected[i]);
Assert(j < TeamNumSelected[i]);
if (j < --TeamNumSelected[i]) {
@ -274,7 +274,7 @@ global void UnSelectUnit(Unit* unit)
for (i = 0; Selected[i] != unit; ++i) {
;
}
DebugCheck(i >= NumSelected);
Assert(i < NumSelected);
if (i < --NumSelected) {
Selected[i] = Selected[NumSelected];
@ -331,7 +331,7 @@ global int SelectUnitsByType(Unit* base)
int i;
const Viewport* vp;
DebugCheck(!TheUI.MouseViewport);
Assert(TheUI.MouseViewport);
DebugLevel3Fn(" %s\n" _C_ base->Type->Ident);
type = base->Type;
@ -495,7 +495,7 @@ global int SelectGroup(int group_number)
{
int nunits;
DebugCheck(group_number > NUM_GROUPS);
Assert(group_number <= NUM_GROUPS);
if (!(nunits = GetNumberUnitsOfGroup(group_number))) {
return 0;
@ -1099,7 +1099,7 @@ global void CleanSelections(void)
GroupId = 0;
NumSelected = 0;
DebugCheck(NoUnitP); // Code fails if none zero
Assert(!NoUnitP); // Code fails if none zero
free(Selected);
Selected = NULL;

View file

@ -110,8 +110,8 @@ global int CastDemolish(Unit* caster, const SpellType* spell __attribute__((unus
int n;
Unit* table[UnitMax];
DebugCheck(!caster);
DebugCheck(!action);
Assert(!caster);
Assert(!action);
//
// Allow error margins. (Lame, I know)
//
@ -187,10 +187,10 @@ global int CastSpawnPortal(Unit* caster, const SpellType* spell __attribute__((u
Unit* portal;
UnitType* ptype;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
DebugCheck(!action->Data.SpawnPortal.PortalType);
Assert(!caster);
Assert(!spell);
Assert(!action);
Assert(!action->Data.SpawnPortal.PortalType);
ptype = action->Data.SpawnPortal.PortalType;
@ -232,9 +232,9 @@ global int CastAreaAdjustVitals(Unit* caster, const SpellType* spell,
int hp;
int mana;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
Assert(!caster);
Assert(!spell);
Assert(!action);
// Get all the units around the unit
nunits = UnitCacheSelect(x - spell->Range,
y - spell->Range,
@ -297,9 +297,9 @@ global int CastAreaBombardment(Unit* caster, const SpellType* spell,
int i;
MissileType *missile;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
Assert(!caster);
Assert(!spell);
Assert(!action);
//assert(x in range, y in range);
mis = NULL;
@ -310,7 +310,7 @@ global int CastAreaBombardment(Unit* caster, const SpellType* spell,
offsetx = action->Data.AreaBombardment.StartOffsetX;
offsety = action->Data.AreaBombardment.StartOffsetY;
missile = action->Data.AreaBombardment.Missile;
DebugCheck(!missile);
Assert(!missile);
while (fields--) {
// FIXME: radius configurable...
do {
@ -398,10 +398,10 @@ global int CastSpawnMissile(Unit* caster, const SpellType* spell,
int dx;
int dy;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
DebugCheck(!action->Data.SpawnMissile.Missile);
Assert(!caster);
Assert(!spell);
Assert(!action);
Assert(!action->Data.SpawnMissile.Missile);
EvaluateMissileLocation(&action->Data.SpawnMissile.StartPoint,
caster, target, x, y, &sx, &sy);
@ -437,10 +437,10 @@ global int CastSpawnMissile(Unit* caster, const SpellType* spell,
global int CastAdjustBuffs(Unit* caster, const SpellType* spell,
const SpellActionType* action, Unit* target, int x, int y)
{
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
DebugCheck(!target);
Assert(!caster);
Assert(!spell);
Assert(!action);
Assert(!target);
if (action->Data.AdjustBuffs.HasteTicks != BUFF_NOT_AFFECTED) {
target->Haste = action->Data.AdjustBuffs.HasteTicks;
@ -482,10 +482,10 @@ global int CastAdjustVitals(Unit* caster, const SpellType* spell,
int mana;
int manacost;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
DebugCheck(!target);
Assert(!caster);
Assert(!spell);
Assert(!action);
Assert(!target);
hp = action->Data.AdjustVitals.HP;
mana = action->Data.AdjustVitals.Mana;
@ -522,7 +522,7 @@ global int CastAdjustVitals(Unit* caster, const SpellType* spell,
castcount = min(castcount, action->Data.AdjustVitals.MaxMultiCast);
}
DebugCheck(castcount < 0);
Assert(castcount < 0);
DebugLevel3Fn("Used to have %d hp and %d mana.\n" _C_
target->HP _C_ target->Mana);
@ -567,13 +567,13 @@ global int CastPolymorph(Unit* caster, const SpellType* spell,
int j;
UnitType* type;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
DebugCheck(!target);
Assert(!caster);
Assert(!spell);
Assert(!action);
Assert(!target);
type = action->Data.Polymorph.NewForm;
DebugCheck(!type);
Assert(!type);
x = x - type->TileWidth / 2;
y = y - type->TileHeight / 2;
@ -638,10 +638,10 @@ global int CastSummon(Unit* caster, const SpellType* spell,
Unit* unit;
UnitType* unittype;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!action);
DebugCheck(!action->Data.Summon.UnitType);
Assert(!caster);
Assert(!spell);
Assert(!action);
Assert(!action->Data.Summon.UnitType);
unittype = action->Data.Summon.UnitType;
ttl = action->Data.Summon.TTL;
@ -721,9 +721,9 @@ local Target* NewTarget(TargetType t, const Unit* unit, int x, int y)
target = (Target*)malloc(sizeof(*target));
DebugCheck(unit == NULL && t == TargetUnit);
DebugCheck(!(0 <= x && x < TheMap.Width) && t == TargetPosition);
DebugCheck(!(0 <= y && y < TheMap.Height) && t == TargetPosition);
Assert(unit == NULL && t == TargetUnit);
Assert(!(0 <= x && x < TheMap.Width) && t == TargetPosition);
Assert(!(0 <= y && y < TheMap.Height) && t == TargetPosition);
target->which_sort_of_target = t;
target->unit = (Unit*)unit;
@ -741,7 +741,7 @@ local Target* NewTarget(TargetType t, const Unit* unit, int x, int y)
*/
local Target* NewTargetUnit(const Unit* unit)
{
DebugCheck(!unit);
Assert(!unit);
return NewTarget(TargetUnit, unit, 0, 0);
}
@ -755,8 +755,8 @@ local Target* NewTargetUnit(const Unit* unit)
*/
local Target* NewTargetPosition(int x, int y)
{
DebugCheck(!(0 <= x && x < TheMap.Width));
DebugCheck(!(0 <= y && y < TheMap.Height));
Assert(!(0 <= x && x < TheMap.Width));
Assert(!(0 <= y && y < TheMap.Height));
return NewTarget(TargetPosition, NULL, x, y);
}
@ -884,8 +884,8 @@ local Target* SelectTargetUnitsOfAutoCast(const Unit* caster, const SpellType* s
int combat;
AutoCastInfo* autocast;
DebugCheck(!spell);
DebugCheck(!caster);
Assert(!spell);
Assert(!caster);
// Ai cast should be a lot better. Use autocast if not found.
if (caster->Player->AiEnabled && spell->AICast) {
@ -895,7 +895,7 @@ local Target* SelectTargetUnitsOfAutoCast(const Unit* caster, const SpellType* s
DebugLevel3Fn("You puny mortal, join the colective!\n");
autocast = spell->AutoCast;
}
DebugCheck(!autocast);
Assert(!autocast);
x = caster->X;
y = caster->Y;
range = spell->AutoCast->Range;
@ -976,7 +976,7 @@ local Target* SelectTargetUnitsOfAutoCast(const Unit* caster, const SpellType* s
default:
// Something is wrong
DebugLevel0Fn("Spell is screwed up, unknown target type\n");
DebugCheck(1);
Assert(1);
return NULL;
break;
}
@ -1009,7 +1009,7 @@ global SpellType* SpellTypeByIdent(const char* ident)
{
int i;
DebugCheck(!ident);
Assert(!ident);
for (i = 0; i < SpellTypeCount; ++i) {
if (strcmp(SpellTypeTable[i]->Ident, ident) == 0) {
return SpellTypeTable[i];
@ -1033,8 +1033,8 @@ global int SpellIsAvailable(const Player* player, int spellid)
{
int dependencyId;
DebugCheck(!player);
DebugCheck(!(0 <= spellid && spellid < SpellTypeCount));
Assert(!player);
Assert(!(0 <= spellid && spellid < SpellTypeCount));
dependencyId = SpellTypeTable[spellid]->DependencyId;
@ -1051,7 +1051,7 @@ global int SpellIsAvailable(const Player* player, int spellid)
*/
global int CanAutoCastSpell(const SpellType* spell)
{
DebugCheck(!spell);
Assert(!spell);
return spell->AutoCast ? 1 : 0;
}
@ -1071,10 +1071,10 @@ global int CanAutoCastSpell(const SpellType* spell)
global int CanCastSpell(const Unit* caster, const SpellType* spell,
const Unit* target, int x, int y)
{
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!SpellIsAvailable(caster->Player, spell->Slot));
DebugCheck(!(caster->Type->CanCastSpell && caster->Type->CanCastSpell[spell->Slot]));
Assert(!caster);
Assert(!spell);
Assert(!SpellIsAvailable(caster->Player, spell->Slot));
Assert(!(caster->Type->CanCastSpell && caster->Type->CanCastSpell[spell->Slot]));
if (spell->Target == TargetUnit && target == NULL) {
return 0;
@ -1094,11 +1094,11 @@ global int AutoCastSpell(Unit* caster, const SpellType* spell)
{
Target* target;
DebugCheck(!caster);
DebugCheck(!spell);
DebugCheck(!(0 <= spell->Slot && spell->Slot < SpellTypeCount));
DebugCheck(!(caster->Type->CanCastSpell));
DebugCheck(!(caster->Type->CanCastSpell[spell->Slot]));
Assert(!caster);
Assert(!spell);
Assert(!(0 <= spell->Slot && spell->Slot < SpellTypeCount));
Assert(!(caster->Type->CanCastSpell));
Assert(!(caster->Type->CanCastSpell[spell->Slot]));
// Check for mana, trivial optimization.
if (!SpellIsAvailable(caster->Player, spell->Slot)
@ -1135,11 +1135,11 @@ global int SpellCast(Unit* caster, const SpellType* spell, Unit* target,
int cont;
SpellActionType* act;
DebugCheck(!spell);
DebugCheck(!spell->Action);
DebugCheck(!spell->Action->CastFunction);
DebugCheck(!caster);
DebugCheck(!SpellIsAvailable(caster->Player, spell->Slot));
Assert(!spell);
Assert(!spell->Action);
Assert(!spell->Action->CastFunction);
Assert(!caster);
Assert(!SpellIsAvailable(caster->Player, spell->Slot));
caster->Invisible = 0;// unit is invisible until attacks // FIXME: Must be configurable
if (target) {
@ -1169,7 +1169,7 @@ global int SpellCast(Unit* caster, const SpellType* spell, Unit* target,
}
PlayGameSound(spell->SoundWhenCast.Sound, MaxSampleVolume);
while (act) {
DebugCheck(!act->CastFunction);
Assert(!act->CastFunction);
cont = cont & act->CastFunction(caster, spell, act, target, x, y);
act = act->Next;
}

View file

@ -961,7 +961,7 @@ global int main(int argc, char** argv)
kCFURLPOSIXPathStyle);
const char* pathPtr = CFStringGetCStringPtr(macPath,
CFStringGetSystemEncoding());
assert(pathPtr);
Assert(pathPtr);
StratagusLibPath = malloc(strlen(pathPtr) + 1);
strcpy(StratagusLibPath, pathPtr);
#endif