change to Assert

This commit is contained in:
nehalmistry 2004-05-08 03:13:07 +00:00
parent abdd1c2603
commit a10e66e23f
44 changed files with 204 additions and 204 deletions

View file

@ -95,7 +95,7 @@ local void DoActionAttackGeneric(Unit* unit,const Animation* attack)
global void AnimateActionAttack(Unit* unit)
{
if (unit->Type->Animations) {
DebugCheck(!unit->Type->Animations->Attack);
Assert(unit->Type->Animations->Attack);
DoActionAttackGeneric(unit, unit->Type->Animations->Attack);
}
}
@ -189,7 +189,7 @@ local int CheckForTargetInRange(Unit* unit)
if (goal) {
if (unit->SavedOrder.Action == UnitActionStill) {
// Save current command to continue it later.
DebugCheck(unit->Orders[0].Goal);
Assert(!unit->Orders[0].Goal);
unit->SavedOrder = unit->Orders[0];
}
RefsIncrease(goal);
@ -230,9 +230,9 @@ local int CheckForTargetInRange(Unit* unit)
}
}
DebugCheck(unit->Type->Vanishes || unit->Destroyed || unit->Removed);
DebugCheck(unit->Orders[0].Action != UnitActionAttack &&
unit->Orders[0].Action != UnitActionAttackGround);
Assert(!unit->Type->Vanishes && !unit->Destroyed && !unit->Removed);
Assert(unit->Orders[0].Action == UnitActionAttack ||
unit->Orders[0].Action == UnitActionAttackGround);
return 0;
}
@ -346,9 +346,9 @@ local void MoveToTarget(Unit* unit)
return;
}
DebugCheck(unit->Type->Vanishes || unit->Destroyed || unit->Removed);
DebugCheck(unit->Orders[0].Action != UnitActionAttack &&
unit->Orders[0].Action != UnitActionAttackGround);
Assert(!unit->Type->Vanishes && !unit->Destroyed && !unit->Removed);
Assert(unit->Orders[0].Action == UnitActionAttack ||
unit->Orders[0].Action == UnitActionAttackGround);
}
/**
@ -405,14 +405,14 @@ local void AttackTarget(Unit* unit)
// Return to old task?
if (unit->SavedOrder.Action != UnitActionStill) {
unit->SubAction = 0;
DebugCheck(unit->Orders[0].Goal != NoUnitP);
Assert(unit->Orders[0].Goal == NoUnitP);
unit->Orders[0] = unit->SavedOrder;
NewResetPath(unit);
// Must finish, if saved command finishes
unit->SavedOrder.Action = UnitActionStill;
// This isn't supported
DebugCheck(unit->SavedOrder.Goal != NoUnitP);
Assert(unit->SavedOrder.Goal == NoUnitP);
}
return;
}
@ -540,7 +540,7 @@ global void HandleActionAttack(Unit* unit)
//
// FIXME: should use a reachable place to reduce pathfinder time.
//
DebugCheck(unit->State != 0);
Assert(unit->State == 0);
//
// Look for target, if already in range. Attack if So
//

View file

@ -72,7 +72,7 @@ local int MoveToTransporter(Unit* unit)
NewResetPath(unit);
}
// New code has this as default.
DebugCheck(unit->Orders[0].Action != UnitActionBoard);
Assert(unit->Orders[0].Action == UnitActionBoard);
return i;
}

View file

@ -173,7 +173,7 @@ global void HandleActionBuild(Unit* unit)
//
// FIXME: got bug report about unit->Type==NULL in building
//
DebugCheck(!unit->Type || !unit->HP);
Assert(unit->Type && unit->HP);
if (!unit->Type || !unit->HP) {
return;
@ -235,7 +235,7 @@ global void HandleActionBuild(Unit* unit)
UnitClearOrders(temp);
ReleaseUnit(temp);
} else {
DebugCheck(1);
Assert(0);
}
}

View file

@ -80,8 +80,8 @@ global void HandleActionDie(Unit* unit)
unit->State = unit->Type->CorpseScript;
DebugCheck(unit->Type->TileWidth != unit->Type->CorpseType->TileWidth ||
unit->Type->TileHeight != unit->Type->CorpseType->TileHeight);
Assert(unit->Type->TileWidth == unit->Type->CorpseType->TileWidth &&
unit->Type->TileHeight == unit->Type->CorpseType->TileHeight);
// Update sight for new corpse
// We have to unmark BEFORE changing the type.

View file

@ -112,7 +112,7 @@ global void HandleActionFollow(Unit* unit)
if (!unit->SubAction) { // first entry
unit->SubAction = 1;
NewResetPath(unit);
DebugCheck(unit->State != 0);
Assert(unit->State == 0);
}
switch (DoActionMove(unit)) { // reached end-point?

View file

@ -266,7 +266,7 @@ global void HandleActionMove(Unit* unit)
unit->SubAction = 1;
NewResetPath(unit);
DebugCheck(unit->State != 0);
Assert(unit->State == 0);
}
// FIXME: (mr-russ) Make a reachable goal here with GoalReachable ...

View file

@ -69,7 +69,7 @@ global void HandleActionPatrol(Unit* unit)
if (DoActionMove(unit) < 0) { // reached end-point or stop
int tmp;
DebugCheck(unit->Orders[0].Action != UnitActionPatrol);
Assert(unit->Orders[0].Action == UnitActionPatrol);
//
// Swap the points.

View file

@ -92,7 +92,7 @@ local void RepairUnit(Unit* unit, Unit* goal)
//
// Calculate the repair costs.
//
DebugCheck(!goal->Stats->HitPoints);
Assert(goal->Stats->HitPoints);
//
// Check if enough resources are available
@ -160,7 +160,7 @@ local void RepairUnit(Unit* unit, Unit* goal)
local int AnimateActionRepair(Unit* unit)
{
if (unit->Type->Animations) {
DebugCheck(!unit->Type->Animations->Repair);
Assert(unit->Type->Animations->Repair);
DoActionRepairGeneric(unit, unit->Type->Animations->Repair);
}
@ -239,7 +239,7 @@ global void HandleActionRepair(Unit* unit)
}
// FIXME: Should be it already?
DebugCheck(unit->Orders[0].Action != UnitActionRepair);
Assert(unit->Orders[0].Action == UnitActionRepair);
}
break;

View file

@ -120,7 +120,7 @@ local int MoveToResource(Unit* unit)
}
} else {
goal = unit->Orders[0].Goal;
DebugCheck(!goal);
Assert(goal);
switch (DoActionMove(unit)) { // reached end-point?
case PF_UNREACHABLE:
return -1;
@ -150,8 +150,8 @@ local int StartGathering(Unit* unit)
ResourceInfo* resinfo;
resinfo = unit->Type->ResInfo[unit->CurrentResource];
DebugCheck(unit->IX);
DebugCheck(unit->IY);
Assert(!unit->IX);
Assert(!unit->IY);
if (resinfo->TerrainHarvester) {
// This shouldn't happend?
#if 0
@ -195,7 +195,7 @@ local int StartGathering(Unit* unit)
// FIXME: 0 can happen, if to near placed by map designer.
DebugLevel3Fn("%d\n" _C_ MapDistanceBetweenUnits(unit, goal));
DebugCheck(MapDistanceBetweenUnits(unit, goal) > 1);
Assert(MapDistanceBetweenUnits(unit, goal) <= 1);
//
// Update the heading of a harvesting unit to looks straight at the resource.
@ -256,7 +256,7 @@ local void AnimateActionHarvest(Unit* unit)
int flags;
if (unit->Type->Animations) {
DebugCheck(!unit->Type->Animations->Harvest[unit->CurrentResource]);
Assert(unit->Type->Animations->Harvest[unit->CurrentResource]);
flags = UnitShowAnimation(unit,
unit->Type->Animations->Harvest[unit->CurrentResource]);
if ((flags & AnimationSound) && (UnitVisible(unit, ThisPlayer) || ReplayRevealMap)) {
@ -279,7 +279,7 @@ local void LoseResource(Unit* unit, const Unit* source)
resinfo = unit->Type->ResInfo[unit->CurrentResource];
if (unit->Container) {
DebugCheck(resinfo->HarvestFromOutside);
Assert(!resinfo->HarvestFromOutside);
}
//
@ -310,7 +310,7 @@ local void LoseResource(Unit* unit, const Unit* source)
// Dump the unit outside and look for something to do.
//
if (unit->Container) {
DebugCheck(resinfo->HarvestFromOutside);
Assert(!resinfo->HarvestFromOutside);
DropOutOnSide(unit, LookingW, source->Type->TileWidth,
source->Type->TileHeight);
}
@ -358,7 +358,7 @@ local int GatherResource(Unit* unit)
}
if (unit->Data.ResWorker.DoneHarvesting) {
DebugCheck(!(resinfo->HarvestFromOutside || resinfo->TerrainHarvester));
Assert(resinfo->HarvestFromOutside || resinfo->TerrainHarvester);
return unit->Reset;
}
@ -408,8 +408,8 @@ local int GatherResource(Unit* unit)
source = unit->Container;
}
DebugCheck(!source);
DebugCheck(source->Value > 655350);
Assert(source);
Assert(source->Value <= 655350);
//
// Target is not dead, getting resources.
@ -501,7 +501,7 @@ local int StopGathering(Unit* unit)
source = unit->Container;
}
source->Data.Resource.Active--;
DebugCheck(source->Data.Resource.Active < 0);
Assert(source->Data.Resource.Active >= 0);
}
@ -518,7 +518,7 @@ local int StopGathering(Unit* unit)
if (!(depot = FindDeposit(unit, unit->X, unit->Y, 1000, unit->CurrentResource)) ||
!unit->Value) {
if (!(resinfo->HarvestFromOutside || resinfo->TerrainHarvester)) {
DebugCheck(!unit->Container);
Assert(unit->Container);
DropOutOnSide(unit, LookingW, source->Type->TileWidth,
source->Type->TileHeight);
}
@ -529,7 +529,7 @@ local int StopGathering(Unit* unit)
// should return 0, done below!
} else {
if (!(resinfo->HarvestFromOutside || resinfo->TerrainHarvester)) {
DebugCheck(!unit->Container);
Assert(unit->Container);
DropOutNearest(unit, depot->X + depot->Type->TileWidth / 2,
depot->Y + depot->Type->TileHeight / 2,
source->Type->TileWidth, source->Type->TileHeight);
@ -565,7 +565,7 @@ local int MoveToDepot(Unit* unit)
resinfo = unit->Type->ResInfo[unit->CurrentResource];
goal = unit->Orders[0].Goal;
DebugCheck(!goal);
Assert(goal);
switch (DoActionMove(unit)) { // reached end-point?
case PF_UNREACHABLE:
@ -592,7 +592,7 @@ local int MoveToDepot(Unit* unit)
return 0;
}
DebugCheck(unit->Wait != 1);
Assert(unit->Wait == 1);
//
// If resource depot is still under construction, wait!
@ -648,7 +648,7 @@ local int WaitInDepot(Unit* unit)
resinfo = unit->Type->ResInfo[unit->CurrentResource];
depot = ResourceDepositOnMap(unit->X, unit->Y, resinfo->ResourceId);
DebugCheck(!depot);
Assert(depot);
// Could be destroyed, but then we couldn't be in?
if (unit->Orders[0].Arg1 == (void*)-1) {

View file

@ -67,7 +67,7 @@ global void HandleActionReturnGoods(Unit* unit)
//
// Select target to return goods.
//
DebugCheck(!type->Harvester );
Assert(type->Harvester );
if ((!unit->CurrentResource) && (!unit->Value)) {
DebugLevel0("Unit can't return resources, it doesn't carry any.\n");
}

View file

@ -72,7 +72,7 @@ global void AnimateActionSpellCast(Unit* unit)
int flags;
if (unit->Type->Animations) {
DebugCheck(!unit->Type->Animations->Attack);
Assert(unit->Type->Animations->Attack);
flags = UnitShowAnimation(unit, unit->Type->Animations->Attack);
@ -161,7 +161,7 @@ local void SpellMoveToTarget(Unit* unit)
}
}
}
DebugCheck(unit->Type->Vanishes || unit->Destroyed);
Assert(!unit->Type->Vanishes && !unit->Destroyed);
}
/**

View file

@ -92,7 +92,7 @@ global void ActionStillGeneric(Unit* unit, int ground)
//
// Still animation
//
DebugCheck(!type->Animations || !type->Animations->Still);
Assert(type->Animations && type->Animations->Still);
UnitShowAnimation(unit, type->Animations->Still);
@ -157,7 +157,7 @@ global void ActionStillGeneric(Unit* unit, int ground)
if (CheckedCanMoveToMask(x, y, TypeMovementMask(type))) {
// FIXME: Don't use pathfinder for this, costs too much cpu.
unit->Orders[0].Action = UnitActionMove;
DebugCheck(unit->Orders[0].Goal);
Assert(!unit->Orders[0].Goal);
unit->Orders[0].Goal = NoUnitP;
unit->Orders[0].Range = 0;
unit->Orders[0].X = x;
@ -193,8 +193,8 @@ global void ActionStillGeneric(Unit* unit, int ground)
CommandAttack(unit, goal->X, goal->Y, NULL, FlushCommands);
DebugLevel3Fn(" %d Attacking in range %d\n" _C_
UnitNumber(unit) _C_ unit->SubAction);
DebugCheck(unit->SavedOrder.Action != UnitActionStill);
DebugCheck(unit->SavedOrder.Goal);
Assert(unit->SavedOrder.Action == UnitActionStill);
Assert(!unit->SavedOrder.Goal);
unit->SavedOrder.Action = UnitActionAttack;
unit->SavedOrder.Range = 0;
unit->SavedOrder.X = unit->X;

View file

@ -149,7 +149,7 @@ global int UnloadUnit(Unit* unit)
int x;
int y;
DebugCheck(!unit->Removed);
Assert(unit->Removed);
if (!FindUnloadPosition(unit->X, unit->Y, &x, &y, UnitMovementMask(unit))) {
return 0;
}
@ -312,7 +312,7 @@ local int MoveToDropZone(Unit* unit)
return 0;
}
DebugCheck(unit->Orders[0].Action != UnitActionUnload);
Assert(unit->Orders[0].Action == UnitActionUnload);
return 1;
}

View file

@ -79,8 +79,8 @@ global void HandleActionUpgradeTo(Unit* unit)
// don't have such unit now
player->UnitTypesCount[unit->Type->Slot]--;
DebugCheck(unit->Type->TileWidth != type->TileWidth ||
unit->Type->TileHeight != type->TileHeight);
Assert(unit->Type->TileWidth == type->TileWidth &&
unit->Type->TileHeight == type->TileHeight);
unit->Type = type;
unit->Stats = (UnitStats*)stats;
// and we have new one...

View file

@ -404,10 +404,10 @@ local void HandleUnitAction(Unit* unit)
unit->SubAction == 60) {
// FIXME: SUB_GATHER_RESOURCE ?
unit->Orders[0].Goal->Data.Resource.Active--;
DebugCheck(unit->Orders[0].Goal->Data.Resource.Active < 0);
Assert(unit->Orders[0].Goal->Data.Resource.Active >= 0);
}
// Still shouldn't have a reference
DebugCheck(unit->Orders[0].Action == UnitActionStill);
Assert(unit->Orders[0].Action != UnitActionStill);
RefsDecrease(unit->Orders->Goal);
}
if (unit->CurrentResource) {

View file

@ -187,7 +187,7 @@ global void CommandMoveOrder(Unit* unit, int src, int dst)
{
Order tmp;
int i;
DebugCheck(src == 0 || dst == 0 || src >= unit->OrderCount || dst >= unit->OrderCount);
Assert(src != 0 && dst != 0 && src < unit->OrderCount && dst < unit->OrderCount);
if (src == dst) {
return;
@ -537,7 +537,7 @@ global void CommandPatrolUnit(Unit* unit, int x, int y, int flush)
order->Y = y;
order->Range = 0;
order->Type = NULL;
DebugCheck(unit->X & ~0xFFFF || unit->Y & ~0xFFFF);
Assert(!(unit->X & ~0xFFFF) || !(unit->Y & ~0xFFFF));
// FIXME: BUG-ALERT: encode source into arg1 as two 16 bit values!
order->Arg1 = (void*)((unit->X << 16) | unit->Y);
}
@ -902,7 +902,7 @@ global void CommandTrainUnit(Unit* unit, UnitType* type,
ReleaseOrders(unit);
unit->Orders[1].Action = UnitActionTrain;
}
DebugCheck(unit->OrderCount != 1 || unit->OrderFlush != 1);
Assert(unit->OrderCount == 1 && unit->OrderFlush == 1);
unit->OrderCount = 2;
unit->Orders[1].Type = type;
@ -948,7 +948,7 @@ global void CommandCancelTraining(Unit* unit, int slot, const UnitType* type)
//
if (unit->Orders[0].Action == UnitActionTrain) {
n = unit->Data.Train.Count;
DebugCheck(n < 1);
Assert(n >= 1);
if (slot == -1) { // default last slot!
slot += n;
}
@ -1190,7 +1190,7 @@ global void CommandSpellCast(Unit* unit, int x, int y, Unit* dest,
DebugLevel0Fn(": %d casts %s at %d %d on %d\n" _C_
UnitNumber(unit) _C_ spell->Ident _C_ x _C_ y _C_ dest ? UnitNumber(dest) : 0);
DebugCheck(!unit->Type->CanCastSpell[spell->Slot]);
Assert(unit->Type->CanCastSpell[spell->Slot]);
//
// Check if unit is still valid? (NETWORK!)

View file

@ -1076,7 +1076,7 @@ local int AiRemoveFromBuilded2(PlayerAi* pai, const UnitType* type)
// Search the unit-type order.
//
for (queue = &pai->UnitTypeBuilded; (next = *queue); queue = &next->Next) {
DebugCheck(!next->Want);
Assert(next->Want);
if (type == next->Type && next->Made) {
--next->Made;
if (!--next->Want) {
@ -1121,7 +1121,7 @@ local void AiRemoveFromBuilded(PlayerAi* pai, const UnitType* type)
return;
}
DebugCheck(1);
Assert(0);
}
/**
@ -1172,7 +1172,7 @@ local void AiReduceMadeInBuilded(const PlayerAi* pai, const UnitType* type)
}
}
DebugCheck(1);
Assert(0);
}
/*----------------------------------------------------------------------------
@ -1254,7 +1254,7 @@ global void AiUnitKilled(Unit* unit)
DebugLevel1Fn("%d: %d(%s) killed\n" _C_
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident);
DebugCheck(unit->Player->Type == PlayerPerson);
Assert(unit->Player->Type != PlayerPerson);
// FIXME: must handle all orders...
switch (unit->Orders[0].Action) {
@ -1298,7 +1298,7 @@ global void AiWorkComplete(Unit* unit, Unit* what)
what->Player->Player _C_ what->Type->Ident _C_ what->X _C_ what->Y);
}
DebugCheck(what->Player->Type == PlayerPerson);
Assert(what->Player->Type != PlayerPerson);
AiRemoveFromBuilded(what->Player->Ai, what->Type);
}
@ -1315,7 +1315,7 @@ global void AiCanNotBuild(Unit* unit, const UnitType* what)
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
what->Ident _C_ unit->X _C_ unit->Y);
DebugCheck(unit->Player->Type == PlayerPerson);
Assert(unit->Player->Type != PlayerPerson);
AiReduceMadeInBuilded(unit->Player->Ai, what);
}
@ -1332,7 +1332,7 @@ global void AiCanNotReach(Unit* unit, const UnitType* what)
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
what->Ident _C_ unit->X _C_ unit->Y);
DebugCheck(unit->Player->Type == PlayerPerson);
Assert(unit->Player->Type != PlayerPerson);
AiReduceMadeInBuilded(unit->Player->Ai, what);
}
@ -1725,7 +1725,7 @@ local void HandleTransportRequests(AiTransportRequest* aitr)
return;
}
DebugCheck(zonepathlen < 3);
Assert(zonepathlen >= 3);
if (FindTransporterOnZone(zonepath[1], &DestZones,
aitr->Unit->X, aitr->Unit->Y, UnitTypeNaval, &transporter)) {
@ -1753,7 +1753,7 @@ global void AiNeedMoreSupply(Unit* unit, const UnitType* what __attribute__((unu
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
what->Ident _C_ unit->X _C_ unit->Y);
DebugCheck(unit->Player->Type == PlayerPerson);
Assert(unit->Player->Type != PlayerPerson);
((PlayerAi*)unit->Player->Ai)->NeedSupply = 1;
}
@ -1770,7 +1770,7 @@ global void AiTrainingComplete(Unit* unit, Unit* what)
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
what->Type->Ident _C_ unit->X _C_ unit->Y);
DebugCheck(unit->Player->Type == PlayerPerson);
Assert(unit->Player->Type != PlayerPerson);
AiRemoveFromBuilded(unit->Player->Ai, what->Type);
@ -1792,7 +1792,7 @@ global void AiUpgradeToComplete(Unit* unit __attribute__((unused)),
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
what->Ident _C_ unit->X _C_ unit->Y);
DebugCheck(unit->Player->Type == PlayerPerson);
Assert(unit->Player->Type != PlayerPerson);
}
/**
@ -1808,7 +1808,7 @@ global void AiResearchComplete(Unit* unit __attribute__((unused)),
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
what->Ident _C_ unit->X _C_ unit->Y);
DebugCheck(unit->Player->Type == PlayerPerson);
Assert(unit->Player->Type != PlayerPerson);
// FIXME: upgrading knights -> paladins, must rebuild lists!
}

View file

@ -314,7 +314,7 @@ local void AiRequestSupply(void)
AiBuildQueue* queue;
int counter[UnitTypeMax];
DebugCheck(!AiHelpers.UnitLimit);
Assert(AiHelpers.UnitLimit);
//
// Count the already made build requests.
@ -820,7 +820,7 @@ local int AiAssignHarvester(Unit* unit, int resource)
}
resinfo = unit->Type->ResInfo[resource];
DebugCheck(!resinfo);
Assert(resinfo);
if (resinfo->TerrainHarvester) {
//
// Code for terrain harvesters. Search for piece of terrain to mine.
@ -854,7 +854,7 @@ local int AiAssignHarvester(Unit* unit, int resource)
exploremask |= MapFieldSeaUnit;
break;
default:
DebugCheck(1);
Assert(0);
}
}
}

View file

@ -349,10 +349,10 @@ local int CclDefineAi(lua_State* l)
// Get name of function
lua_pushstring(l, "debug");
lua_gettable(l, LUA_GLOBALSINDEX);
DebugCheck(lua_isnil(l, -1));
Assert(!lua_isnil(l, -1));
lua_pushstring(l, "getinfo");
lua_gettable(l, -2);
DebugCheck(!lua_isfunction(l, -1));
Assert(lua_isfunction(l, -1));
lua_pushvalue(l, 4);
lua_call(l, 1, 1);
lua_pushstring(l, "name");
@ -848,7 +848,7 @@ local int CclAiWaitForce(lua_State* l)
#if 0
// Debuging
AiCleanForces();
DebugCheck(AiPlayer->Force[force].Completed);
Assert(!AiPlayer->Force[force].Completed);
#endif
lua_pushboolean(l, 1);
@ -1150,7 +1150,7 @@ local int DefaultResourceNumber(const char* name)
}
}
// Resource not found, should never happen
DebugCheck(1);
Assert(0);
return -1;
}
@ -1175,10 +1175,10 @@ local int CclDefineAiPlayer(lua_State* l)
i = LuaToNumber(l, j + 1);
++j;
DebugCheck(i < 0 || i > PlayerMax);
Assert(i >= 0 && i <= PlayerMax);
DebugLevel0Fn("%p %d\n" _C_ Players[i].Ai _C_ Players[i].AiEnabled );
// FIXME: lose this:
// DebugCheck(Players[i].Ai || !Players[i].AiEnabled);
// Assert(!Players[i].Ai && Players[i].AiEnabled);
ai = Players[i].Ai = calloc(1, sizeof(PlayerAi));
ai->Player = &Players[i];

View file

@ -159,7 +159,7 @@ global int GetTileNumber(int basic, int random, int filler)
while (++i < 16 && !TheMap.Tileset->Table[tile + i]) {
}
} while (i < 16 && n--);
DebugCheck(i == 16);
Assert(i != 16);
return tile + i;
}
if (filler) {
@ -185,7 +185,7 @@ global void EditTile(int x, int y, int tile)
{
MapField* mf;
DebugCheck(x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height);
Assert(x >= 0 && y >= 0 && x < TheMap.Width && y < TheMap.Height);
ChangeTile(x, y, GetTileNumber(tile, TileToolRandom, TileToolDecoration));
@ -371,7 +371,7 @@ local void CalculateMaxIconSize(void)
IconHeight = 0;
for (i = 0; i < MaxUnitIndex; ++i) {
type = UnitTypeByIdent(EditorUnitTypes[i]);
DebugCheck(!type || !type->Icon.Icon);
Assert(type && type->Icon.Icon);
icon = type->Icon.Icon;
if (IconWidth < icon->Width) {
IconWidth = icon->Width;
@ -742,13 +742,13 @@ local void DrawEditorPanel(void)
// Select / Units / Tiles
//
icon = IconByIdent(EditorSelectIcon);
DebugCheck(!icon);
Assert(icon);
DrawUnitIcon(Players, icon,
(ButtonUnderCursor == SelectButton ? IconActive : 0) |
(EditorState == EditorSelecting ? IconSelected : 0),
x, y);
icon = IconByIdent(EditorUnitsIcon);
DebugCheck(!icon);
Assert(icon);
DrawUnitIcon(Players, icon,
(ButtonUnderCursor == UnitButton ? IconActive : 0) |
(EditorState == EditorEditUnit ? IconSelected : 0),
@ -887,7 +887,7 @@ local void DrawEditorInfo(void)
}
}
DebugCheck(i == TheMap.Tileset->NumTiles);
Assert(i != TheMap.Tileset->NumTiles);
sprintf(buf, "%d %s %s", tile,
TheMap.Tileset->SolidTerrainTypes[TheMap.Tileset->Tiles[i].BaseTerrain].TerrainName,
@ -1251,7 +1251,7 @@ local void EditorCallbackButtonDown(unsigned button __attribute__ ((unused)))
Viewport* vp;
vp = GetViewport(CursorX, CursorY);
DebugCheck(!vp);
Assert(vp);
if ((MouseButtons & LeftButton) && TheUI.SelectedViewport != vp) {
// viewport changed
TheUI.SelectedViewport = vp;
@ -1789,7 +1789,7 @@ local void EditorCallbackMouse(int x, int y)
Viewport* vp;
vp = GetViewport(x, y);
DebugCheck(!vp);
Assert(vp);
if (TheUI.MouseViewport != vp) { // viewport changed
TheUI.MouseViewport = vp;
DebugLevel0Fn("active viewport changed to %d.\n" _C_

View file

@ -103,7 +103,7 @@ local unsigned QuadFromTile(int x, int y)
break;
}
}
DebugCheck(i == TheMap.Tileset->NumTiles);
Assert(i != TheMap.Tileset->NumTiles);
base = TheMap.Tileset->Tiles[i].BaseTerrain;
mix = TheMap.Tileset->Tiles[i].MixTerrain;
@ -147,7 +147,7 @@ local unsigned QuadFromTile(int x, int y)
return (mix << 24) | (base << 16) | (base << 8) | base;
}
DebugCheck(1);
Assert(0);
return base | (base << 8) | (base << 16) | (base << 24);
}
@ -282,7 +282,7 @@ local int TileFromQuad(unsigned fixed, unsigned quad)
i += 256;
}
}
DebugCheck(i >= TheMap.Tileset->NumTiles);
Assert(i < TheMap.Tileset->NumTiles);
return i;
}
} else {
@ -422,8 +422,8 @@ global void ChangeTile(int x, int y, int tile)
{
MapField *mf;
DebugCheck(x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height);
DebugCheck(tile < 0 || tile >= TheMap.Tileset->NumTiles);
Assert(x >= 0 && y >= 0 && x < TheMap.Width && y < TheMap.Height);
Assert(tile >= 0 && tile < TheMap.Tileset->NumTiles);
mf = &TheMap.Fields[y * TheMap.Width + x];
mf->Tile = mf->SeenTile = TheMap.Tileset->Table[tile];
@ -446,7 +446,7 @@ local void EditorChangeTile(int x, int y, int tile, int d)
{
MapField* mf;
DebugCheck(x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height);
Assert(x >= 0 && y >= 0 && x < TheMap.Width && y < TheMap.Height);
ChangeTile(x, y, tile);

View file

@ -163,7 +163,7 @@ global void PlayCampaign(const char* name)
GameResult = GameVictory;
filename = NextChapter();
DebugCheck(!filename);
Assert(filename);
SkipCurrentChapter = 1;
GameResult = GameNoResult;

View file

@ -915,7 +915,7 @@ local int GameStatsDrawFunc(int frame)
break;
}
}
DebugCheck(i == PlayerRaces.Count);
Assert(i != PlayerRaces.Count);
rank = ranks[0];
i = 0;

View file

@ -92,7 +92,7 @@ local char* SaveGlobal(lua_State *l, int is_root)
char *tmp;
int b;
// DebugCheck(is_root && lua_gettop(l));
// Assert(!is_root || !lua_gettop(l));
first = 1;
res = NULL;
if (is_root) {
@ -100,7 +100,7 @@ local char* SaveGlobal(lua_State *l, int is_root)
lua_gettable(l, LUA_GLOBALSINDEX);
}
sep = (is_root) ? "" : ", ";
DebugCheck(!lua_istable(l, -1));
Assert(lua_istable(l, -1));
lua_pushnil(l);
while (lua_next(l, -2)) {
type_key = lua_type(l, -2);
@ -213,7 +213,7 @@ local char* SaveGlobal(lua_State *l, int is_root)
free(tmp);
}
lua_pop(l, 1); // pop the table
// DebugCheck(is_root && lua_gettop(l));
// Assert(!is_root || !lua_gettop(l));
return res;
}

View file

@ -185,7 +185,7 @@ global void RevealMap(void)
*/
global void ViewportSetViewpoint(Viewport* vp, int x, int y, int offsetx, int offsety)
{
DebugCheck(!vp);
Assert(vp);
x = x * TileSizeX + offsetx;
y = y * TileSizeY + offsety;

View file

@ -250,14 +250,14 @@ global void MapUnmarkTileSight(const Player* player, int x, int y)
switch (v) {
case 255:
// FIXME: (mr-russ) Lookupsight is broken :(
DebugCheck(1);
Assert(0);
v = LookupSight(player, x, y);
DebugCheck(v < 254);
Assert(v >= 254);
break;
case 0: // Unexplored
case 1:
// We are at minimum, don't do anything shouldn't happen.
DebugCheck(1);
Assert(0);
break;
case 2:
// When there is NoFogOfWar units never get unmarked.
@ -290,7 +290,7 @@ global void MapMarkTileDetectCloak(const Player* player, int x, int y)
if (v == 0) {
UnitsOnTileMarkSeen(player, x, y, 1);
}
DebugCheck(v == 255);
Assert(v != 255);
++v;
TheMap.Fields[x + y * TheMap.Width].VisCloak[player->Player] = v;
}
@ -307,7 +307,7 @@ global void MapUnmarkTileDetectCloak(const Player* player, int x, int y)
unsigned char v;
v = TheMap.Fields[x + y * TheMap.Width].VisCloak[player->Player];
DebugCheck(v == 0);
Assert(v != 0);
if (v == 1) {
UnitsOnTileUnmarkSeen(player, x, y, 1);
}

View file

@ -110,7 +110,7 @@ global void LoadTileset(void)
fprintf(stderr, "Tileset `%s' not available\n", TheMap.TerrainName);
ExitFatal(-1);
}
DebugCheck(i != TheMap.Terrain);
Assert(i == TheMap.Terrain);
if (!Tilesets[i]->Table) {
char buf[1024];

View file

@ -518,7 +518,7 @@ local int CclLog(lua_State* l)
LuaError(l, "incorrect argument");
}
DebugCheck(!CurrentReplay);
Assert(CurrentReplay);
log = calloc(1, sizeof(LogEntry));
log->UnitNumber = -1;
@ -582,7 +582,7 @@ local int CclReplayLog(lua_State* l)
LuaError(l, "incorrect argument");
}
DebugCheck(CurrentReplay != NULL);
Assert(CurrentReplay == NULL);
replay = calloc(1, sizeof(FullReplay));
@ -790,7 +790,7 @@ local void DoNextReplay(void)
int num;
Unit* dunit;
DebugCheck(ReplayStep == 0);
Assert(ReplayStep != 0);
NextLogCycle = ReplayStep->GameCycle;
@ -807,7 +807,7 @@ local void DoNextReplay(void)
val = ReplayStep->Value;
num = ReplayStep->Num;
DebugCheck(unit != -1 && strcmp(ReplayStep->UnitIdent, UnitSlots[unit]->Type->Ident));
Assert(unit == -1 || !strcmp(ReplayStep->UnitIdent, UnitSlots[unit]->Type->Ident));
if (SyncRandSeed != ReplayStep->SyncRandSeed) {
#ifdef DEBUG
@ -817,7 +817,7 @@ local void DoNextReplay(void)
} else {
NotifyPlayer(ThisPlayer, NotifyYellow, 0, 0, "Replay got out of sync (%lu) !", GameCycle);
DebugLevel0("OUT OF SYNC %u != %u\n" _C_ SyncRandSeed _C_ ReplayStep->SyncRandSeed);
DebugCheck(1);
Assert(0);
// ReplayStep = 0;
// NextLogCycle = ~0UL;
// return;
@ -1493,7 +1493,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
DebugLevel3Fn(" %d cycle %lu\n" _C_ msgnr _C_ GameCycle);
unit = UnitSlots[unum];
DebugCheck(!unit);
Assert(unit);
//
// Check if unit is already killed?
//
@ -1502,7 +1502,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
return;
}
DebugCheck(!unit->Type);
Assert(unit->Type);
status = (msgnr & 0x80) >> 7;
@ -1528,7 +1528,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("follow", unit, status, -1, -1, dest, NULL, -1);
CommandFollow(unit, dest, status);
@ -1541,7 +1541,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("repair", unit, status, x, y, dest, NULL, -1);
CommandRepair(unit, x, y, dest, status);
@ -1550,7 +1550,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("attack", unit, status, x, y, dest, NULL, -1);
CommandAttack(unit, x, y, dest, status);
@ -1567,7 +1567,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("board", unit, status, x, y, dest, NULL, -1);
CommandBoard(unit, dest, status);
@ -1576,7 +1576,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("unload", unit, status, x, y, dest, NULL, -1);
CommandUnload(unit, x, y, dest, status);
@ -1598,7 +1598,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("resource", unit, status, -1, -1, dest, NULL, -1);
CommandResource(unit, dest, status);
@ -1607,7 +1607,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("return", unit, status, -1, -1, dest, NULL, -1);
CommandReturnGoods(unit, dest, status);
@ -1655,7 +1655,7 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
dest = NoUnitP;
if (dstnr != (unsigned short)0xFFFF) {
dest = UnitSlots[dstnr];
DebugCheck(!dest || !dest->Type);
Assert(dest && dest->Type);
}
CommandLog("spell-cast", unit, status, x, y, dest, NULL, id);
CommandSpellCast(unit, x, y, dest, SpellTypeTable[id], status);

View file

@ -214,7 +214,7 @@ global unsigned long NetResolveHost(const char* host)
he = gethostbyname(host);
if (he) {
addr = 0;
DebugCheck(he->h_length != 4);
Assert(he->h_length == 4);
memcpy(&addr, he->h_addr, he->h_length);
}
}

View file

@ -347,7 +347,7 @@ global void NetworkServerStartGame(void)
InitMessage message;
InitMessage statemsg;
DebugCheck(ServerSetupState.CompOpt[0] != 0);
Assert(ServerSetupState.CompOpt[0] == 0);
// save it first..
LocalSetupState = ServerSetupState;
@ -466,7 +466,7 @@ global void NetworkServerStartGame(void)
num[chosen] = num[--j];
} else {
DebugCheck(1 == 1);
Assert(0);
#if 0
// ARI: is this code path really executed? (initially h >= NetPlayers..)
// Above Debugcheck will catch it..

View file

@ -571,7 +571,7 @@ global void NetworkSendCommand(int command, const Unit* unit, int x, int y,
ncq->Data.Unit = htons(unit->Slot);
ncq->Data.X = htons(x);
ncq->Data.Y = htons(y);
DebugCheck( dest && type ); // Both together isn't allowed
Assert (!dest || !type); // Both together isn't allowed
if (dest) {
ncq->Data.Dest = htons(dest->Slot);
} else if (type) {
@ -644,7 +644,7 @@ global void NetworkSendSelection(Unit** units, int count)
unitcount = 0;
DebugLevel3("Time: %lu " _C_ ncq[0].Time);
for (i = 0; i <= (count / 4); ++i) {
DebugCheck(i > MaxNetworkCommands);
Assert(i <= MaxNetworkCommands);
header->Type[i] = MessageSelection;
selection = (NetworkSelection*)&packet.Command[i];
for (ref = 0; ref < 4 && unitcount < count; ++ref, ++unitcount) {
@ -703,7 +703,7 @@ local void NetworkProcessSelection(NetworkPacket* packet, int player)
units[unitcount++] = Units[ntohs(selection->Unit[j])];
}
}
DebugCheck(count != unitcount);
Assert(count == unitcount);
ChangeTeamSelectedUnits(&Players[player], units, adjust, count);
}
@ -1072,7 +1072,7 @@ local void ParseNetworkCommand(const NetworkCommandQueue* ncq)
break;
case MessageNone:
// Nothing to Do, This Message Should Never be Executed
DebugCheck(1);
Assert(0);
break;
default:
ParseCommand(ncq->Type, ntohs(ncq->Data.Unit),
@ -1206,7 +1206,7 @@ local void NetworkExecCommands(void)
if (ncq->Time != GameCycle) {
DebugLevel1Fn("cycle %lu idx %lu time %lu\n" _C_
GameCycle _C_ GameCycle & 0xFF _C_ ncq->Time);
DebugCheck(ncq->Time != GameCycle);
Assert(ncq->Time == GameCycle);
}
#endif
ParseNetworkCommand(ncq);

View file

@ -310,7 +310,7 @@ local int CostMoveTo(Unit* unit, int ex, int ey, int mask, int current_cost) {
goal = UnitCacheOnXY(ex, ey, unit->Type->UnitType);
if (!goal) {
// Shouldn't happen, mask says there is something on this tile
DebugCheck(1);
Assert(0);
return -1;
}
if (goal->Moving) {

View file

@ -207,7 +207,7 @@ global RegionId NewRegion(int iswater)
result = NextFreeRegion;
DebugCheck(NextFreeRegion >= MaxRegionNumber);
Assert(NextFreeRegion < MaxRegionNumber);
if (RegionMax <= result) {
RegionMax = result + 1;
@ -215,7 +215,7 @@ global RegionId NewRegion(int iswater)
++RegionCount;
DebugLevel3Fn("New region %d, iswater = %d\n" _C_ result _C_ iswater);
DebugCheck(Regions[result].TileCount);
Assert(!Regions[result].TileCount);
Regions[result].TileCount = 0;
Regions[result].IsWater = iswater;
@ -349,7 +349,7 @@ global void RegionSplitUsingTemp(RegionId reg, int nbarea, int updateConnections
while (minx <= seg->MaxX) {
initval = *tempptr;
DebugCheck(initval == 0);
Assert(initval != 0);
while ((maxx < seg->MaxX) && (tempptr[1] == initval)) {
tempptr++;
@ -407,7 +407,7 @@ global void RegionJoin(RegionId a, RegionId b)
RegionId* mapptr;
int i;
DebugCheck(Regions[a].IsWater != Regions[b].IsWater);
Assert(Regions[a].IsWater == Regions[b].IsWater);
if (a > b) {
tmp = a;
a = b;
@ -468,7 +468,7 @@ global void RegionSplit(RegionId regid, int updateConnections)
adef = Regions + regid;
DebugCheck(adef->TileCount <= 1);
Assert(adef->TileCount > 1);
RegionTempStorageAllocate();
@ -498,19 +498,19 @@ global void RegionSplit(RegionId regid, int updateConnections)
// Find two correct starting place for flood filling
if (adef->MaxX - adef->MinX > adef->MaxY - adef->MinY) {
RegionFindPointOnX(adef, adef->MinX, &x, &y);
DebugCheck(RegionTempStorage[x + TheMap.Width * y]);
Assert(!RegionTempStorage[x + TheMap.Width * y]);
CircularFillerInit(fillers, regid, x, y, 1);
RegionFindPointOnX(adef, adef->MaxX, &x, &y);
DebugCheck(RegionTempStorage[x + TheMap.Width * y]);
Assert(!RegionTempStorage[x + TheMap.Width * y]);
CircularFillerInit(fillers + 1, regid, x, y, 2);
} else {
RegionFindPointOnY(adef, adef->MinY, &x, &y);
DebugCheck(RegionTempStorage[x + TheMap.Width * y]);
Assert(!RegionTempStorage[x + TheMap.Width * y]);
CircularFillerInit(fillers, regid, x, y, 1);
RegionFindPointOnY(adef, adef->MaxY, &x, &y);
DebugCheck(RegionTempStorage[x + TheMap.Width * y]);
Assert(!RegionTempStorage[x + TheMap.Width * y]);
CircularFillerInit(fillers + 1, regid, x, y, 2);
}
@ -536,7 +536,7 @@ global void RegionSplit(RegionId regid, int updateConnections)
// Need to unmark ?
if (done < tileleft) {
DebugCheck(erodelevel < 3);
Assert(erodelevel >= 3);
RegionTempStorageUnmarkPoints(regid, erodelevel--);
@ -875,13 +875,13 @@ local void RegionFloodFill(int x0, int x1, int starty, int RegId, int IsWater)
int y;
int i;
DebugCheck(x0 > x1);
DebugCheck(IsWater != 0 && IsWater != 1);
Assert(x0 <= x1);
Assert(IsWater == 0 || IsWater == 1);
y = starty;
for (x = x0; x <= x1; ++x) {
DebugCheck(TileIsWater(x, y) != IsWater);
Assert(TileIsWater(x, y) == IsWater);
RegionAssignTile(RegId, x, y);
}
@ -906,8 +906,8 @@ local void RegionFloodFill(int x0, int x1, int starty, int RegId, int IsWater)
}
FindHExtent(x, y, &subx0, &subx1, IsWater);
DebugCheck(TileIsWater(subx0,y) != IsWater);
DebugCheck(TileIsWater(subx1,y) != IsWater);
Assert(TileIsWater(subx0,y) == IsWater);
Assert(TileIsWater(subx1,y) == IsWater);
RegionFloodFill(subx0, subx1, y, RegId, IsWater);
x = subx1;
@ -1057,7 +1057,7 @@ global void ZoneFindConnexion(int a, int b, int refx, int refy, int* rsltx, int*
}
}
DebugCheck(bestdst == -1);
Assert(bestdst != -1);
}
/**
@ -1074,7 +1074,7 @@ local void RefreshZones(void)
int j;
int zoneid;
DebugCheck(!RegionCount);
Assert(RegionCount);
regions_stack = malloc(RegionCount * sizeof(int));
for (i = 0; i < RegionMax; ++i) {
@ -1178,7 +1178,7 @@ global void MapSplitterEachCycle(void)
RegionId i;
RegionId j;
DebugCheck(!MapSplitterInitialised);
Assert(MapSplitterInitialised);
// Check for connection in regions
for (i = 0; i < RegionMax; ++i) {

View file

@ -236,10 +236,10 @@ global void RegionDebugWater(void)
for (x = 0; x < TheMap.Width; x++) {
reg = RegionMapping(x,y);
if (!TileMappable(x,y)) {
DebugCheck(reg != NoRegion);
Assert(reg == NoRegion);
} else {
DebugCheck(reg == NoRegion);
DebugCheck(TileIsWater(x,y) != Regions[reg].IsWater);
Assert(reg != NoRegion);
Assert(TileIsWater(x,y) == Regions[reg].IsWater);
}
}
}

View file

@ -202,7 +202,7 @@ global void RegionFindPointOnX(RegionDefinition * def,int x,int * vx,int * vy)
}
// Check one was found !
DebugCheck(besty == -1);
Assert(besty != -1);
*vx = bestx;
*vy = besty;
@ -255,7 +255,7 @@ global void RegionFindPointOnY(RegionDefinition * def,int y,int * vx,int * vy)
}
// Check one was found !
DebugCheck(besty == -1);
Assert(besty != -1);
*vx = bestx;
*vy = besty;
@ -593,7 +593,7 @@ global void RegionAddConnection(RegionId rega, RegionId regb,int value)
int j;
RegionDefinition * adef;
DebugCheck(rega == regb);
Assert(rega != regb);
adef = Regions + rega;
@ -615,7 +615,7 @@ global void RegionAddConnection(RegionId rega, RegionId regb,int value)
}
}
DebugCheck(value<=0);
Assert(value > 0);
adef->Connections = (int*)realloc(adef->Connections, sizeof(int) * (adef->ConnectionsNumber + 1));
adef->ConnectionsCount = (int*)realloc(adef->ConnectionsCount, sizeof(int) * (adef->ConnectionsNumber + 1));

View file

@ -412,7 +412,7 @@ global int ZoneSetFindPath(ZoneSet* src,ZoneSet* dst,int * path,int * pathlen)
}
}
DebugCheck(bestdst == -1);
Assert(bestdst != -1);
*pathlen = 0;
do {
// Add startzone
@ -422,7 +422,7 @@ global int ZoneSetFindPath(ZoneSet* src,ZoneSet* dst,int * path,int * pathlen)
}
startzone = zonenext[startzone];
DebugCheck(startzone == -1);
Assert(startzone != -1);
} while(1);
}

View file

@ -128,7 +128,7 @@ static void FLAC_metadata_callback(const FLAC__StreamDecoder *stream,
sample->SampleSize = metadata->data.stream_info.bits_per_sample;
if (!sample->Buffer) {
DebugCheck(!metadata->data.stream_info.total_samples);
Assert(metadata->data.stream_info.total_samples);
sample->Buffer = malloc(metadata->data.stream_info.total_samples * 4);
}
@ -166,8 +166,8 @@ static FLAC__StreamDecoderWriteStatus FLAC_write_callback(
sample = user;
data = sample->User;
DebugCheck(!sample->Buffer);
DebugCheck(frame->header.bits_per_sample != sample->SampleSize);
Assert(sample->Buffer);
Assert(frame->header.bits_per_sample == sample->SampleSize);
ssize = (frame->header.bits_per_sample / 8);
buf = malloc(frame->header.blocksize * sample->Channels * ssize);
@ -367,10 +367,10 @@ global Sample* LoadFlac(const char *name, int flags)
sample->Buffer = NULL;
sample->Type = &FlacSampleType;
DebugCheck(FLAC__stream_decoder_get_state(stream) !=
Assert(FLAC__stream_decoder_get_state(stream) ==
FLAC__STREAM_DECODER_SEARCH_FOR_METADATA);
FLAC__stream_decoder_process_until_end_of_stream(stream);
DebugCheck(FLAC__stream_decoder_get_state(stream) !=
Assert(FLAC__stream_decoder_get_state(stream) ==
FLAC__STREAM_DECODER_END_OF_STREAM);
FLAC__stream_decoder_finish(stream);

View file

@ -492,7 +492,7 @@ global Sample* LoadMp3(const char* name, int flags)
data->MadFile = f;
sample->User = data;
sample->Buffer = malloc(55000000);
DebugCheck(!sample->Buffer);
Assert(sample->Buffer);
sample->Len = 0;
sample->Pos = 0;

View file

@ -159,7 +159,7 @@ local int OggStreamRead(Sample* sample, void* buf, int len)
i = ov_read(&data->VorbisFile, sndbuf, n, 0, 2, 1,
&bitstream);
#endif
DebugCheck(i < 0);
Assert(i >= 0);
if (!i) {
// EOF
@ -334,7 +334,7 @@ global Sample* LoadOgg(const char* name,int flags)
i = ov_read(&data->VorbisFile, sndbuf, n, 0, 2, 1,
&bitstream);
#endif
DebugCheck(i < 0);
Assert(i >= 0);
if (!i) {
// EOF
@ -347,7 +347,7 @@ global Sample* LoadOgg(const char* name,int flags)
sample->Len += i;
}
DebugCheck(sample->Len != total);
Assert(sample->Len == total);
}
return sample;

View file

@ -111,7 +111,7 @@ global SoundId SoundIdForName(const char* name)
{
const SoundId* result;
DebugCheck(!name);
Assert(name);
if ((result = (const SoundId*)hash_find(SoundIdHash, (char*)name))) {
return *result;
@ -137,7 +137,7 @@ global SoundId MakeSound(const char* name, const char* file[], int nb)
SoundId id;
const SoundId* result;
DebugCheck(nb > 255);
Assert(nb <= 255);
if ((result = (const SoundId*)hash_find(SoundIdHash, (char*)name))) {
DebugLevel0Fn("re-register sound `%s'\n" _C_ name);

View file

@ -148,7 +148,7 @@ local void MixMusicToStereo32(int* buffer, int size)
short* buf;
if (PlayingMusic) {
DebugCheck(!MusicSample && !MusicSample->Type);
Assert(MusicSample && MusicSample->Type);
len = size * sizeof(*buf);
buf = alloca(len);
@ -221,7 +221,7 @@ local int MixSampleToStereo32(Sample* sample,int index,unsigned char volume,
DebugLevel3("Length %d\n" _C_ length);
DebugCheck(index & 1);
Assert(!(index & 1));
if (size >= sample->Len / 2 - index) {
size = sample->Len / 2 - index;

View file

@ -302,8 +302,8 @@ global Sample* LoadWav(const char* name, int flags)
CLclose(f);
ExitFatal(-1);
}
DebugCheck(wavfmt.Frequency != 44100 && wavfmt.Frequency != 22050 &&
wavfmt.Frequency != 11025);
Assert(wavfmt.Frequency == 44100 || wavfmt.Frequency == 22050 ||
wavfmt.Frequency == 11025);
data = malloc(sizeof(WavData));
data->WavFile = f;
@ -368,7 +368,7 @@ global Sample* LoadWav(const char* name, int flags)
rem -= read;
sample->Buffer = realloc(sample->Buffer, sample->Len + read * divide);
DebugCheck(!sample->Buffer);
Assert(sample->Buffer);
comp = CLread(data->WavFile, sndbuf, read);
if (!comp) {

View file

@ -157,7 +157,7 @@ global void LoadMissileSprite(MissileType* mtype)
FlipGraphic(mtype->Sprite);
// Correct the number of frames in graphic
DebugCheck(mtype->Sprite->NumFrames < mtype->SpriteFrames);
Assert(mtype->Sprite->NumFrames >= mtype->SpriteFrames);
mtype->Sprite->NumFrames = mtype->SpriteFrames;
// FIXME: Don't use NumFrames as number of frames.
}
@ -374,16 +374,16 @@ local void FreeMissile(Missile* missile)
// Note: removing the last missile works.
//
if (missile->Local) {
DebugCheck(*missile->MissileSlot != missile);
Assert(*missile->MissileSlot == missile);
temp = LocalMissiles[--NumLocalMissiles];
DebugCheck(*temp->MissileSlot != temp);
Assert(*temp->MissileSlot == temp);
temp->MissileSlot = missile->MissileSlot;
*missile->MissileSlot = temp;
LocalMissiles[NumLocalMissiles] = NULL;
} else {
DebugCheck(*missile->MissileSlot != missile);
Assert(*missile->MissileSlot == missile);
temp = GlobalMissiles[--NumGlobalMissiles];
DebugCheck(*temp->MissileSlot != temp);
Assert(*temp->MissileSlot == temp);
temp->MissileSlot = missile->MissileSlot;
*missile->MissileSlot = temp;
GlobalMissiles[NumGlobalMissiles] = NULL;
@ -423,7 +423,7 @@ local int CalculateDamageStats(const UnitStats* attacker_stats,
damage = max(basic_damage - goal_stats->Armor, 1) + piercing_damage;
damage -= SyncRand() % ((damage + 2) / 2);
DebugCheck(damage < 0);
Assert(damage >= 0);
DebugLevel3Fn("\nDamage done [%d] %d %d ->%d\n" _C_ goal_stats->Armor _C_
basic_damage _C_ piercing_damage _C_ damage);
@ -527,7 +527,7 @@ global void FireMissile(Unit* unit)
}
if (goal) {
DebugCheck(!goal->Type); // Target invalid?
Assert(goal->Type); // Target invalid?
//
// Moved out of attack range?
//
@ -756,13 +756,13 @@ local void MissileNewHeadingFromXY(Missile* missile, int dx, int dy)
missile->SpriteFrame *= missile->Type->NumDirections / 2 + 1;
nextdir = 128 / (missile->Type->NumDirections - 1);
DebugCheck(nextdir == 0);
Assert(nextdir != 0);
dir = ((DirectionToHeading(10 * dx, 10 * dy) + nextdir / 2) & 0xFF) / nextdir;
if (dir >= missile->Type->NumDirections) {
dir -= (missile->Type->NumDirections - 1) * 2;
}
DebugCheck(dir >= missile->Type->NumDirections);
DebugCheck(dir < -missile->Type->NumDirections + 1);
Assert(dir < missile->Type->NumDirections);
Assert(dir >= -missile->Type->NumDirections + 1);
missile->SpriteFrame = dir;
if (missile->SpriteFrame < 0) {
missile->SpriteFrame--;
@ -794,7 +794,7 @@ local int MissileInitMove(Missile* missile)
missile->State++;
return 0;
}
DebugCheck(missile->TotalStep == 0);
Assert(missile->TotalStep != 0);
missile->CurrentStep += missile->Type->Speed;
if (missile->CurrentStep >= missile->TotalStep) {
missile->X = missile->DX;
@ -822,8 +822,8 @@ local int PointToPointMissile(Missile* missile)
return 1;
}
DebugCheck(missile->Type == NULL);
DebugCheck(missile->TotalStep == 0);
Assert(missile->Type != NULL);
Assert(missile->TotalStep != 0);
xstep = (missile->DX - missile->SourceX) * 1024 / missile->TotalStep;
ystep = (missile->DY - missile->SourceY) * 1024 / missile->TotalStep;
missile->X = missile->SourceX + xstep * missile->CurrentStep / 1024;
@ -864,17 +864,17 @@ local int ParabolicMissile(Missile* missile)
if (MissileInitMove(missile) == 1) {
return 1;
}
DebugCheck(missile->Type == NULL);
Assert(missile->Type != NULL);
orig_x = missile->X;
orig_y = missile->Y;
xstep = missile->DX - missile->SourceX;
ystep = missile->DY - missile->SourceY;
DebugCheck(missile->TotalStep == 0);
Assert(missile->TotalStep != 0);
xstep = xstep * 1000 / missile->TotalStep;
ystep = ystep * 1000 / missile->TotalStep;
missile->X = missile->SourceX + xstep * missile->CurrentStep / 1000;
missile->Y = missile->SourceY + ystep * missile->CurrentStep / 1000;
DebugCheck(K == 0);
Assert(K != 0);
Z = missile->CurrentStep * (missile->TotalStep - missile->CurrentStep) / K;
// Until Z is used for drawing, modify X and Y.
missile->X += Z * ZprojToX / 64;
@ -905,7 +905,7 @@ local void MissileHitsGoal(const Missile* missile, Unit* goal, int splash)
if (missile->Damage) { // direct damage, spells mostly
HitUnit(missile->SourceUnit, goal, missile->Damage / splash);
} else {
DebugCheck(missile->SourceUnit == NULL);
Assert(missile->SourceUnit != NULL);
HitUnit(missile->SourceUnit, goal,
CalculateDamage(missile->SourceUnit->Stats, goal,
missile->SourceUnit->Bloodlust, 0) / splash);
@ -939,7 +939,7 @@ local void MissileHitsWall(const Missile* missile, int x, int y, int splash)
if (missile->Damage) { // direct damage, spells mostly
HitWall(x, y, missile->Damage / splash);
} else {
DebugCheck(missile->SourceUnit == NULL);
Assert(missile->SourceUnit != NULL);
HitWall(x, y,
CalculateDamageStats(missile->SourceUnit->Stats,
UnitTypeOrcWall->Stats, 0, 0) / splash);
@ -1030,7 +1030,7 @@ global void MissileHit(Missile* missile)
//
i = missile->Type->Range;
n = UnitCacheSelect(x - i + 1, y - i + 1, x + i, y + i, table);
DebugCheck(missile->SourceUnit == NULL);
Assert(missile->SourceUnit != NULL);
for (i = 0; i < n; ++i) {
goal = table[i];
//
@ -1260,7 +1260,7 @@ global MissileType* MissileBurningBuilding(int percent)
frame = tmp;
tmp = tmp->Next;
}
DebugCheck(frame == NULL);
Assert(frame != NULL);
return frame->Missile;
}
@ -1863,7 +1863,7 @@ global void MissileActionDeathCoil(Missile* missile)
missile->Wait = missile->Type->Sleep;
if (PointToPointMissile(missile)) {
source = missile->SourceUnit;
DebugCheck(source == NULL);
Assert(source != NULL);
if (source->Destroyed) {
return;
}

View file

@ -273,12 +273,12 @@ local int CclMissile(lua_State* l)
dy = LuaToNumber(l, -1);
lua_pop(l, 1);
} else if (!strcmp(value, "local")) {
DebugCheck(!type);
Assert(type);
missile = MakeLocalMissile(type, x, y, dx, dy);
missile->Local = 1;
--j;
} else if (!strcmp(value, "global")) {
DebugCheck(!type);
Assert(type);
missile = MakeMissile(type, x, y, dx, dy);
missile->X = x;
missile->Y = y;
@ -289,42 +289,42 @@ local int CclMissile(lua_State* l)
missile->Local = 0;
--j;
} else if (!strcmp(value, "frame")) {
DebugCheck(!missile);
Assert(missile);
missile->SpriteFrame = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "state")) {
DebugCheck(!missile);
Assert(missile);
missile->State = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "anim-wait")) {
DebugCheck(!missile);
Assert(missile);
missile->AnimWait = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "wait")) {
DebugCheck(!missile);
Assert(missile);
missile->Wait = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "delay")) {
DebugCheck(!missile);
Assert(missile);
missile->Delay = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "source")) {
DebugCheck(!missile);
Assert(missile);
value = LuaToString(l, j + 1);
missile->SourceUnit = UnitSlots[strtol(value + 1, 0, 16)];
RefsIncrease(missile->SourceUnit);
} else if (!strcmp(value, "target")) {
DebugCheck(!missile);
Assert(missile);
value = LuaToString(l, j + 1);
missile->TargetUnit = UnitSlots[strtol(value + 1, 0, 16)];
RefsIncrease(missile->TargetUnit);
} else if (!strcmp(value, "damage")) {
DebugCheck(!missile);
Assert(missile);
missile->Damage = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "ttl")) {
DebugCheck(!missile);
Assert(missile);
missile->TTL = LuaToNumber(l, j + 1);
} else if (!strcmp(value, "hidden")) {
DebugCheck(!missile);
Assert(missile);
missile->Hidden = 1;
--j;
} else if (!strcmp(value, "step")) {
DebugCheck(!missile);
Assert(missile);
if (!lua_istable(l, j + 1) || luaL_getn(l, j + 1) != 2) {
LuaError(l, "incorrect argument");
}