change DebugLevelX to DebugPrint
This commit is contained in:
parent
f88b181f04
commit
3394f7c959
90 changed files with 466 additions and 1204 deletions
|
@ -130,9 +130,6 @@ local Unit* CheckForDeadGoal(Unit* unit)
|
|||
unit->Orders[0].MinRange = 0;
|
||||
unit->Orders[0].Range = 0;
|
||||
|
||||
DebugLevel3Fn("attack target %d gone for %d(%s)\n" _C_
|
||||
UnitNumber(goal) _C_
|
||||
UnitNumber(unit) _C_ unit->Type->Name);
|
||||
RefsDecrease(goal);
|
||||
|
||||
unit->Orders[0].Goal = goal = NoUnitP;
|
||||
|
@ -199,8 +196,6 @@ local int CheckForTargetInRange(Unit* unit)
|
|||
unit->Orders[0].X = unit->Orders[0].Y = -1;
|
||||
unit->SubAction |= WEAK_TARGET; // weak target
|
||||
NewResetPath(unit);
|
||||
DebugLevel3Fn("%d in react range %d\n" _C_
|
||||
UnitNumber(unit) _C_ UnitNumber(goal));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -215,8 +210,6 @@ local int CheckForTargetInRange(Unit* unit)
|
|||
// Save current command to come back.
|
||||
unit->SavedOrder = unit->Orders[0];
|
||||
if ((goal = unit->SavedOrder.Goal)) {
|
||||
DebugLevel0Fn("Have goal to come back %d\n" _C_
|
||||
UnitNumber(goal));
|
||||
unit->SavedOrder.X = goal->X + goal->Type->TileWidth / 2;
|
||||
unit->SavedOrder.Y = goal->Y + goal->Type->TileHeight / 2;
|
||||
unit->SavedOrder.MinRange = 0;
|
||||
|
@ -249,7 +242,7 @@ local void MoveToTarget(Unit* unit)
|
|||
|
||||
if (!unit->Orders[0].Goal) {
|
||||
if (unit->Orders[0].X == -1 || unit->Orders[0].Y == -1) {
|
||||
DebugLevel0Fn("FIXME: Wrong goal position, check where set!\n");
|
||||
DebugPrint("FIXME: Wrong goal position, check where set!\n");
|
||||
unit->Orders[0].X = unit->Orders[0].Y = 0;
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +261,6 @@ local void MoveToTarget(Unit* unit)
|
|||
//
|
||||
// Nothing to do, we're on the way moving.
|
||||
//
|
||||
DebugLevel3Fn("Nothing to do.\n");
|
||||
return;
|
||||
}
|
||||
if (err == PF_REACHED) {
|
||||
|
@ -277,7 +269,7 @@ local void MoveToTarget(Unit* unit)
|
|||
//
|
||||
if (goal && MapDistanceBetweenUnits(unit, goal) <=
|
||||
unit->Stats->AttackRange) {
|
||||
DebugLevel3Fn("Reached another unit, now attacking it.\n");
|
||||
// Reached another unit, now attacking it
|
||||
unit->State = 0;
|
||||
if (unit->Stats->Speed) {
|
||||
UnitHeadingFromDeltaXY(unit,
|
||||
|
@ -294,7 +286,7 @@ local void MoveToTarget(Unit* unit)
|
|||
unit->Orders[0].Action == UnitActionAttackGround) &&
|
||||
MapDistanceToUnit(unit->Orders[0].X, unit->Orders[0].Y, unit) <=
|
||||
unit->Stats->AttackRange) {
|
||||
DebugLevel3Fn("Reached wall or ground, now attacking it.\n");
|
||||
// Reached wall or ground, now attacking it
|
||||
unit->State = 0;
|
||||
if (unit->Stats->Speed) {
|
||||
UnitHeadingFromDeltaXY(unit, unit->Orders[0].X - unit->X,
|
||||
|
@ -310,17 +302,10 @@ local void MoveToTarget(Unit* unit)
|
|||
//
|
||||
if (err == PF_UNREACHABLE) {
|
||||
unit->State = unit->SubAction = 0;
|
||||
DebugLevel3Fn("Target not reachable, unit: %d" _C_
|
||||
UnitNumber(unit));
|
||||
if (goal) {
|
||||
DebugLevel3(", target %d range %d\n" _C_ UnitNumber(goal) _C_
|
||||
unit->Orders[0].Range);
|
||||
} else {
|
||||
if (!goal) {
|
||||
//
|
||||
// When attack-moving we have to allow a bigger range
|
||||
//
|
||||
DebugLevel3(", (%d,%d) Tring with more range...\n" _C_
|
||||
unit->Orders[0].X _C_ unit->Orders[0].Y);
|
||||
if (unit->Orders[0].Range < TheMap.Width ||
|
||||
unit->Orders[0].Range < TheMap.Height) {
|
||||
// Try again with more range
|
||||
|
@ -333,7 +318,6 @@ local void MoveToTarget(Unit* unit)
|
|||
// Return to old task?
|
||||
//
|
||||
unit->State = unit->SubAction = 0;
|
||||
DebugLevel3Fn("Returning to old task.\n");
|
||||
if (unit->Orders[0].Goal) {
|
||||
RefsDecrease(unit->Orders->Goal);
|
||||
}
|
||||
|
@ -363,7 +347,7 @@ local void AttackTarget(Unit* unit)
|
|||
|
||||
if (!unit->Orders[0].Goal) {
|
||||
if (unit->Orders[0].X == -1 || unit->Orders[0].Y == -1) {
|
||||
DebugLevel0Fn("FIXME: Wrong goal position, check where set!\n");
|
||||
DebugPrint("FIXME: Wrong goal position, check where set!\n");
|
||||
unit->Orders[0].X = unit->Orders[0].Y = 0;
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +360,6 @@ local void AttackTarget(Unit* unit)
|
|||
goal = unit->Orders[0].Goal;
|
||||
if (!goal && (WallOnMap(unit->Orders[0].X, unit->Orders[0].Y) ||
|
||||
unit->Orders[0].Action == UnitActionAttackGround)) {
|
||||
DebugLevel3Fn("attack a wall or ground!!!!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -423,7 +406,7 @@ local void AttackTarget(Unit* unit)
|
|||
if (unit->SavedOrder.Action == UnitActionStill) {
|
||||
unit->SavedOrder = unit->Orders[0];
|
||||
if ((temp = unit->SavedOrder.Goal)) {
|
||||
DebugLevel0Fn("Have unit to come back %d?\n" _C_
|
||||
DebugPrint("Have unit to come back %d?\n" _C_
|
||||
UnitNumber(temp));
|
||||
unit->SavedOrder.X = temp->X + temp->Type->TileWidth / 2;
|
||||
unit->SavedOrder.Y = temp->Y + temp->Type->TileHeight / 2;
|
||||
|
@ -434,8 +417,6 @@ local void AttackTarget(Unit* unit)
|
|||
}
|
||||
|
||||
RefsIncrease(goal);
|
||||
DebugLevel3Fn("%d Unit in react range %d\n" _C_
|
||||
UnitNumber(unit) _C_ UnitNumber(goal));
|
||||
unit->Orders[0].Goal = goal;
|
||||
unit->Orders[0].X = unit->Orders[0].Y = -1;
|
||||
unit->Orders[0].MinRange = unit->Type->MinAttackRange;
|
||||
|
@ -457,7 +438,7 @@ local void AttackTarget(Unit* unit)
|
|||
// Save current order to come back or to continue it.
|
||||
unit->SavedOrder = unit->Orders[0];
|
||||
if ((goal = unit->SavedOrder.Goal)) {
|
||||
DebugLevel0Fn("Have goal to come back %d\n" _C_
|
||||
DebugPrint("Have goal to come back %d\n" _C_
|
||||
UnitNumber(goal));
|
||||
unit->SavedOrder.X = goal->X + goal->Type->TileWidth / 2;
|
||||
unit->SavedOrder.Y = goal->Y + goal->Type->TileHeight / 2;
|
||||
|
@ -482,7 +463,7 @@ local void AttackTarget(Unit* unit)
|
|||
// Save current order to come back or to continue it.
|
||||
unit->SavedOrder = unit->Orders[0];
|
||||
if ((temp = unit->SavedOrder.Goal)) {
|
||||
DebugLevel0Fn("Have goal to come back %d\n" _C_
|
||||
DebugPrint("Have goal to come back %d\n" _C_
|
||||
UnitNumber(temp));
|
||||
unit->SavedOrder.X = temp->X + temp->Type->TileWidth / 2;
|
||||
unit->SavedOrder.Y = temp->Y + temp->Type->TileHeight / 2;
|
||||
|
@ -527,9 +508,6 @@ local void AttackTarget(Unit* unit)
|
|||
*/
|
||||
global void HandleActionAttack(Unit* unit)
|
||||
{
|
||||
DebugLevel3Fn("Attack %d range %d\n" _C_ UnitNumber(unit) _C_
|
||||
unit->Orders->Range);
|
||||
|
||||
switch (unit->SubAction) {
|
||||
//
|
||||
// First entry
|
||||
|
@ -567,7 +545,7 @@ global void HandleActionAttack(Unit* unit)
|
|||
break;
|
||||
|
||||
case WEAK_TARGET:
|
||||
DebugLevel0("FIXME: wrong entry.\n");
|
||||
DebugPrint("FIXME: wrong entry.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,19 +94,18 @@ local int WaitForTransporter(Unit* unit)
|
|||
|
||||
if (!trans || !trans->Type->Transporter) {
|
||||
// FIXME: destination destroyed??
|
||||
DebugLevel2Fn("TRANSPORTER NOT REACHED %d,%d\n" _C_ unit->X _C_ unit->Y);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!UnitVisibleAsGoal(trans, unit->Player)) {
|
||||
DebugLevel0Fn("Transporter Gone\n");
|
||||
DebugPrint("Transporter Gone\n");
|
||||
RefsDecrease(trans);
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (MapDistanceBetweenUnits(unit,trans) == 1) {
|
||||
DebugLevel3Fn("Enter transporter\n");
|
||||
// enter transporter
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -114,7 +113,6 @@ local int WaitForTransporter(Unit* unit)
|
|||
// FIXME: any enemies in range attack them, while waiting.
|
||||
//
|
||||
|
||||
DebugLevel3Fn("TRANSPORTER NOT REACHED %d,%d\n" _C_ unit->X _C_ unit->Y);
|
||||
// n0b0dy: This means we have to search with a smaller range.
|
||||
// It happens only when you reach the shore,and the transporter
|
||||
// is not there. The unit searches with a big range, so it thinks
|
||||
|
@ -143,7 +141,7 @@ local void EnterTransporter(Unit* unit)
|
|||
|
||||
transporter = unit->Orders[0].Goal;
|
||||
if (!UnitVisibleAsGoal(transporter, unit->Player)) {
|
||||
DebugLevel0Fn("Transporter gone\n");
|
||||
DebugPrint("Transporter gone\n");
|
||||
RefsDecrease(transporter);
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
return;
|
||||
|
@ -172,7 +170,7 @@ local void EnterTransporter(Unit* unit)
|
|||
}
|
||||
return;
|
||||
}
|
||||
DebugLevel0Fn("No free slot in transporter\n");
|
||||
DebugPrint("No free slot in transporter\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,16 +185,12 @@ global void HandleActionBoard(Unit* unit)
|
|||
int i;
|
||||
Unit* goal;
|
||||
|
||||
DebugLevel3Fn("%p(%d) SubAction %d\n" _C_
|
||||
unit _C_ UnitNumber(unit) _C_ unit->SubAction);
|
||||
|
||||
switch (unit->SubAction) {
|
||||
//
|
||||
// Wait for transporter
|
||||
//
|
||||
case 201:
|
||||
// FIXME: show still animations
|
||||
DebugLevel3Fn("Waiting\n");
|
||||
if (WaitForTransporter(unit)) {
|
||||
unit->SubAction = 202;
|
||||
}
|
||||
|
|
|
@ -130,7 +130,6 @@ global void HandleActionBuild(Unit* unit)
|
|||
return;
|
||||
|
||||
case PF_REACHED:
|
||||
DebugLevel3Fn("reached %d,%d\n" _C_ unit->X _C_ unit->Y);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -317,7 +316,7 @@ global void HandleActionBuilded(Unit* unit)
|
|||
// Check if construction should be canceled...
|
||||
//
|
||||
if (unit->Data.Builded.Cancel || unit->Data.Builded.Progress < 0) {
|
||||
DebugLevel0Fn("%s canceled.\n" _C_ unit->Type->Name);
|
||||
DebugPrint("%s canceled.\n" _C_ unit->Type->Name);
|
||||
// Drop out unit
|
||||
if ((worker = unit->Data.Builded.Worker)) {
|
||||
worker->Orders[0].Action = UnitActionStill;
|
||||
|
@ -340,7 +339,7 @@ global void HandleActionBuilded(Unit* unit)
|
|||
//
|
||||
if (unit->Data.Builded.Progress >= unit->Stats->Costs[TimeCost] * 600 ||
|
||||
unit->HP >= unit->Stats->HitPoints) {
|
||||
DebugLevel0Fn("Building ready.\n");
|
||||
DebugPrint("Building ready.\n");
|
||||
if (unit->HP > unit->Stats->HitPoints) {
|
||||
unit->HP = unit->Stats->HitPoints;
|
||||
}
|
||||
|
|
|
@ -69,8 +69,6 @@ global void HandleActionDie(Unit* unit)
|
|||
// Die sequence terminated, generate corpse.
|
||||
//
|
||||
if (unit->Reset) {
|
||||
DebugLevel3("Die complete %d\n" _C_ UnitNumber(unit));
|
||||
|
||||
if (!unit->Type->CorpseType) {
|
||||
// Unmark corpse sight, if it has any
|
||||
MapUnmarkUnitSight(unit);
|
||||
|
@ -94,7 +92,7 @@ global void HandleActionDie(Unit* unit)
|
|||
CommandStopUnit(unit); // This clears all order queues
|
||||
#ifdef DEBUG
|
||||
if (unit->Orders[0].Action != UnitActionDie) {
|
||||
DebugLevel0Fn("Reset to die is really needed\n");
|
||||
DebugPrint("Reset to die is really needed\n");
|
||||
}
|
||||
#endif
|
||||
unit->Orders[0].Action = UnitActionDie;
|
||||
|
|
|
@ -67,7 +67,7 @@ global void HandleActionFollow(Unit* unit)
|
|||
if (unit->SubAction == 128) {
|
||||
goal = unit->Orders[0].Goal;
|
||||
if (!goal || !UnitVisibleAsGoal(goal, unit->Player)) {
|
||||
DebugLevel0Fn("Goal gone\n");
|
||||
DebugPrint("Goal gone\n");
|
||||
if (goal) {
|
||||
RefsDecrease(goal);
|
||||
}
|
||||
|
@ -166,14 +166,14 @@ global void HandleActionFollow(Unit* unit)
|
|||
!unit->Type->CanAttack) ||
|
||||
(dest->NewOrder.Action == UnitActionBoard &&
|
||||
unit->Type->UnitType != UnitTypeLand)) {
|
||||
DebugLevel0Fn("Wrong order for unit\n");
|
||||
DebugPrint("Wrong order for unit\n");
|
||||
unit->Orders->Action = UnitActionStill;
|
||||
unit->Orders->Goal = NoUnitP;
|
||||
} else {
|
||||
if (dest->NewOrder.Goal) {
|
||||
if (dest->NewOrder.Goal->Destroyed) {
|
||||
// FIXME: perhaps we should use another dest?
|
||||
DebugLevel0Fn("Destroyed unit in teleport unit\n");
|
||||
DebugPrint("Destroyed unit in teleport unit\n");
|
||||
RefsDecrease(dest);
|
||||
dest->NewOrder.Goal = NoUnitP;
|
||||
dest->NewOrder.Action = UnitActionStill;
|
||||
|
@ -215,7 +215,7 @@ global void HandleActionFollow(Unit* unit)
|
|||
// Target destroyed?
|
||||
//
|
||||
if ((goal = unit->Orders[0].Goal) && !UnitVisibleAsGoal(goal, unit->Player)) {
|
||||
DebugLevel0Fn("Goal gone\n");
|
||||
DebugPrint("Goal gone\n");
|
||||
unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
|
||||
unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
|
@ -236,7 +236,6 @@ global void HandleActionFollow(Unit* unit)
|
|||
goal->Orders[0].Action == UnitActionStill)) {
|
||||
goal = AttackUnitsInReactRange(unit);
|
||||
if (goal) {
|
||||
DebugLevel2Fn("Follow attack %d\n" _C_ UnitNumber(goal));
|
||||
CommandAttack(unit, goal->X, goal->Y, NULL, FlushCommands);
|
||||
// Save current command to come back.
|
||||
unit->SavedOrder = unit->Orders[0];
|
||||
|
|
|
@ -186,11 +186,6 @@ local int ActionMoveGeneric(Unit* unit, const Animation* anim)
|
|||
d = 0;
|
||||
}
|
||||
|
||||
DebugLevel3Fn(": %d,%d State %2d " _C_ xd _C_ yd _C_ unit->State);
|
||||
DebugLevel3("Walk %d Frame %2d Wait %3d Heading %d %d,%d\n" _C_
|
||||
anim[state].Pixel _C_ anim[state].Frame _C_ anim[state].Sleep _C_
|
||||
unit->Direction _C_ unit->IX _C_ unit->IY);
|
||||
|
||||
//
|
||||
// Next animation.
|
||||
//
|
||||
|
@ -235,11 +230,10 @@ local int ActionMoveGeneric(Unit* unit, const Animation* anim)
|
|||
global int DoActionMove(Unit* unit)
|
||||
{
|
||||
if (unit->Type->Animations && unit->Type->Animations->Move) {
|
||||
DebugLevel3("%s: %p\n" _C_ unit->Type->Ident _C_ unit->Type->Animations);
|
||||
return ActionMoveGeneric(unit, unit->Type->Animations->Move);
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Warning tried to move an object, which can't move\n");
|
||||
DebugPrint("Warning tried to move an object, which can't move\n");
|
||||
|
||||
return PF_UNREACHABLE;
|
||||
}
|
||||
|
@ -258,10 +252,6 @@ global void HandleActionMove(Unit* unit)
|
|||
{
|
||||
Unit* goal;
|
||||
|
||||
DebugLevel3Fn("%d: %d %d,%d \n" _C_ UnitNumber(unit) _C_
|
||||
unit->Orders[0].Goal ? UnitNumber(unit->Orders[0].Goal) : -1 _C_
|
||||
unit->Orders[0].X _C_ unit->Orders[0].Y);
|
||||
|
||||
if (!unit->SubAction) { // first entry
|
||||
unit->SubAction = 1;
|
||||
NewResetPath(unit);
|
||||
|
@ -303,7 +293,7 @@ global void HandleActionMove(Unit* unit)
|
|||
// Target destroyed?
|
||||
//
|
||||
if ((goal = unit->Orders[0].Goal) && goal->Destroyed) {
|
||||
DebugLevel0Fn("Goal dead\n");
|
||||
DebugPrint("Goal dead\n");
|
||||
unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
|
||||
unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
|
|
|
@ -91,14 +91,14 @@ global void HandleActionPatrol(Unit* unit)
|
|||
if (unit->Type->CanAttack && unit->Stats->Speed) {
|
||||
goal = AttackUnitsInReactRange(unit);
|
||||
if (goal) {
|
||||
DebugLevel0Fn("Patrol attack %d\n" _C_ UnitNumber(goal));
|
||||
DebugPrint("Patrol attack %d\n" _C_ UnitNumber(goal));
|
||||
CommandAttack(unit, goal->X, goal->Y, NULL, FlushCommands);
|
||||
// Save current command to come back.
|
||||
unit->SavedOrder = unit->Orders[0];
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
unit->SubAction = 0;
|
||||
DebugLevel0Fn("Wait %d\n" _C_ unit->Wait);
|
||||
DebugPrint("Wait %d\n" _C_ unit->Wait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,6 @@ local void RepairUnit(Unit* unit, Unit* goal)
|
|||
animlength += anim->Sleep;
|
||||
}
|
||||
|
||||
DebugLevel3("Repair animation is %d cycles long\n" _C_ animlength);
|
||||
// FIXME: implement this below:
|
||||
#if 0
|
||||
unit->Data.Builded.Worker->Type->BuilderSpeedFactor;
|
||||
|
@ -201,7 +200,7 @@ global void HandleActionRepair(Unit* unit)
|
|||
// Check if goal is correct unit.
|
||||
if (goal) {
|
||||
if (!UnitVisibleAsGoal(goal, unit->Player)) {
|
||||
DebugLevel0Fn("repair target gone. Booohooo\n");
|
||||
DebugPrint("repair target gone.\n");
|
||||
unit->Orders[0].X = goal->X;
|
||||
unit->Orders[0].Y = goal->Y;
|
||||
RefsDecrease(goal);
|
||||
|
@ -258,7 +257,7 @@ global void HandleActionRepair(Unit* unit)
|
|||
// FIXME: should I do a function for this?
|
||||
if (goal) {
|
||||
if (!UnitVisibleAsGoal(goal, unit->Player)) {
|
||||
DebugLevel0Fn("repair goal is gone\n");
|
||||
DebugPrint("repair goal is gone\n");
|
||||
unit->Orders[0].X = goal->X;
|
||||
unit->Orders[0].Y = goal->Y;
|
||||
RefsDecrease(goal);
|
||||
|
|
|
@ -86,10 +86,9 @@ local int MoveToResource(Unit* unit)
|
|||
if ((!ForestOnMap(x, y)) && (!unit->IX) && (!unit->IY)) {
|
||||
if (!FindTerrainType(UnitMovementMask(unit), MapFieldForest, 0, 16,
|
||||
unit->Player, unit->Orders->X, unit->Orders->Y, &x, &y)) {
|
||||
DebugLevel3Fn("No wood in range\n");
|
||||
// no wood in range
|
||||
return -1;
|
||||
} else {
|
||||
DebugLevel3Fn("%d,%d -> %d,%d\n" _C_ unit->X _C_ unit->Y _C_ x _C_ y);
|
||||
unit->Orders->X = x;
|
||||
unit->Orders->Y = y;
|
||||
NewResetPath(unit);
|
||||
|
@ -102,7 +101,7 @@ local int MoveToResource(Unit* unit)
|
|||
unit->Orders->X = x;
|
||||
unit->Orders->Y = y;
|
||||
NewResetPath(unit);
|
||||
DebugLevel0Fn("Found a better place to harvest %d,%d\n" _C_ x _C_ y);
|
||||
DebugPrint("Found a better place to harvest %d,%d\n" _C_ x _C_ y);
|
||||
// FIXME: can't this overflow? It really shouldn't, since
|
||||
// x and y are really supossed to be reachable, checked thorugh a flood fill.
|
||||
// I don't know, sometimes stuff happens.
|
||||
|
@ -177,7 +176,6 @@ local int StartGathering(Unit* unit)
|
|||
// Target is dead, stop getting resources.
|
||||
//
|
||||
if (!UnitVisibleAsGoal(goal, unit->Player)) {
|
||||
DebugLevel3Fn("Destroyed resource goal, stop gathering.\n");
|
||||
RefsDecrease(goal);
|
||||
// Find an alternative, but don't look too far.
|
||||
unit->Orders[0].X = unit->Orders[0].Y = -1;
|
||||
|
@ -194,7 +192,6 @@ local int StartGathering(Unit* unit)
|
|||
}
|
||||
|
||||
// FIXME: 0 can happen, if to near placed by map designer.
|
||||
DebugLevel3Fn("%d\n" _C_ MapDistanceBetweenUnits(unit, goal));
|
||||
Assert(MapDistanceBetweenUnits(unit, goal) <= 1);
|
||||
|
||||
//
|
||||
|
@ -211,8 +208,6 @@ local int StartGathering(Unit* unit)
|
|||
//
|
||||
if ((goal->Type->MaxOnBoard && goal->Data.Resource.Active >= goal->Type->MaxOnBoard) ||
|
||||
goal->Orders[0].Action == UnitActionBuilded) {
|
||||
DebugLevel3Fn("Waiting at the resource with %d people inside.\n" _C_
|
||||
goal->Data.Resource.Active);
|
||||
// FIXME: Determine somehow when the resource will be free to use
|
||||
// FIXME: Could we somehow find another resource? Think minerals
|
||||
// FIXME: We should add a flag for that, and a limited range.
|
||||
|
@ -302,7 +297,7 @@ local void LoseResource(Unit* unit, const Unit* source)
|
|||
unit->SubAction = SUB_MOVE_TO_DEPOT;
|
||||
unit->Wait = unit->Reset = 1;
|
||||
unit->State = 0;
|
||||
DebugLevel0Fn("Sent unit %d to depot\n" _C_ unit->Slot);
|
||||
DebugPrint("Sent unit %d to depot\n" _C_ unit->Slot);
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
@ -317,13 +312,13 @@ local void LoseResource(Unit* unit, const Unit* source)
|
|||
unit->Orders[0].X = unit->Orders[0].Y = -1;
|
||||
if ((unit->Orders[0].Goal = FindResource(unit, unit->X, unit->Y,
|
||||
10, unit->CurrentResource))) {
|
||||
DebugLevel0Fn("Unit %d found another resource.\n" _C_ unit->Slot);
|
||||
DebugPrint("Unit %d found another resource.\n" _C_ unit->Slot);
|
||||
unit->SubAction = SUB_START_RESOURCE;
|
||||
unit->Wait = unit->Reset = 1;
|
||||
unit->State = 0;
|
||||
RefsIncrease(unit->Orders[0].Goal);
|
||||
} else {
|
||||
DebugLevel0Fn("Unit %d just sits around confused.\n" _C_ unit->Slot);
|
||||
DebugPrint("Unit %d just sits around confused.\n" _C_ unit->Slot);
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->SubAction = 0;
|
||||
unit->Wait = unit->Reset = 1;
|
||||
|
@ -364,7 +359,6 @@ local int GatherResource(Unit* unit)
|
|||
|
||||
// Target gone?
|
||||
if (resinfo->TerrainHarvester && !ForestOnMap(unit->Orders->X, unit->Orders->Y)) {
|
||||
DebugLevel3Fn("Wood gone for unit %d.\n" _C_ unit->Slot);
|
||||
if (unit->Reset) {
|
||||
// Action now breakable, move to resource again.
|
||||
unit->SubAction = SUB_MOVE_TO_RESOURCE;
|
||||
|
@ -394,11 +388,9 @@ local int GatherResource(Unit* unit)
|
|||
}
|
||||
|
||||
if (resinfo->TerrainHarvester) {
|
||||
DebugLevel3Fn("Harvested another %d resources.\n" _C_ addload);
|
||||
unit->Value += addload;
|
||||
|
||||
if (addload && unit->Value == resinfo->ResourceCapacity) {
|
||||
DebugLevel3("Removed wood.\n");
|
||||
MapRemoveWood(unit->Orders->X, unit->Orders->Y);
|
||||
}
|
||||
} else {
|
||||
|
@ -420,7 +412,6 @@ local int GatherResource(Unit* unit)
|
|||
addload = source->Value;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Harvested another %d resources.\n" _C_ addload);
|
||||
unit->Value += addload;
|
||||
source->Value -= addload;
|
||||
}
|
||||
|
@ -430,7 +421,7 @@ local int GatherResource(Unit* unit)
|
|||
// FIXME: implement depleted resources.
|
||||
//
|
||||
if ((!UnitVisibleAsGoal(source, unit->Player)) || (source->Value == 0)) {
|
||||
DebugLevel0Fn("Resource is destroyed for unit %d\n" _C_ unit->Slot);
|
||||
DebugPrint("Resource is destroyed for unit %d\n" _C_ unit->Slot);
|
||||
uins = source->UnitInside;
|
||||
//
|
||||
// Improved version of DropOutAll that makes workers go to the depot.
|
||||
|
@ -455,7 +446,6 @@ local int GatherResource(Unit* unit)
|
|||
if (resinfo->TerrainHarvester) {
|
||||
if (unit->Value == resinfo->ResourceCapacity) {
|
||||
// Mark as complete.
|
||||
DebugLevel3Fn("Done Harvesting, waiting for reset.\n");
|
||||
unit->Data.ResWorker.DoneHarvesting = 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -464,7 +454,6 @@ local int GatherResource(Unit* unit)
|
|||
if (resinfo->HarvestFromOutside && !resinfo->TerrainHarvester) {
|
||||
if ((unit->Value == resinfo->ResourceCapacity) || (source == NULL)) {
|
||||
// Mark as complete.
|
||||
DebugLevel3Fn("Done Harvesting, waiting for reset %X.\n" _C_ (unsigned)source);
|
||||
unit->Data.ResWorker.DoneHarvesting = 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -509,11 +498,11 @@ local int StopGathering(Unit* unit)
|
|||
// FIXME: is this the best way?
|
||||
unit->Orders[0].Arg1 = (void*)((unit->X << 16) | unit->Y);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!unit->Value) {
|
||||
DebugLevel0Fn("Unit %d is empty???\n" _C_ unit->Slot);
|
||||
} else {
|
||||
DebugLevel3Fn("Unit %d is fine, search for a depot.\n" _C_ unit->Slot);
|
||||
DebugPrint("Unit %d is empty???\n" _C_ unit->Slot);
|
||||
}
|
||||
#endif
|
||||
// Find and send to resource deposit.
|
||||
if (!(depot = FindDeposit(unit, unit->X, unit->Y, 1000, unit->CurrentResource)) ||
|
||||
!unit->Value) {
|
||||
|
@ -522,7 +511,7 @@ local int StopGathering(Unit* unit)
|
|||
DropOutOnSide(unit, LookingW, source->Type->TileWidth,
|
||||
source->Type->TileHeight);
|
||||
}
|
||||
DebugLevel0Fn("Can't find a resource deposit for unit %d.\n" _C_ unit->Slot);
|
||||
DebugPrint("Can't find a resource deposit for unit %d.\n" _C_ unit->Slot);
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
unit->SubAction = 0;
|
||||
|
@ -583,7 +572,7 @@ local int MoveToDepot(Unit* unit)
|
|||
// Target is dead, stop getting resources.
|
||||
//
|
||||
if (!UnitVisibleAsGoal(goal, unit->Player)) {
|
||||
DebugLevel0Fn("Destroyed depot\n");
|
||||
DebugPrint("Destroyed depot\n");
|
||||
RefsDecrease(goal);
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
// FIXME: perhaps we should choose an alternative
|
||||
|
@ -599,7 +588,6 @@ local int MoveToDepot(Unit* unit)
|
|||
//
|
||||
if (goal->Orders[0].Action == UnitActionBuilded) {
|
||||
unit->Wait = 10;
|
||||
DebugLevel3Fn("Invalid resource depot. WAIT!!! \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -680,7 +668,7 @@ local int WaitInDepot(Unit* unit)
|
|||
unit->Orders[0].Range = 1;
|
||||
unit->Orders[0].X = unit->Orders[0].Y = -1;
|
||||
} else {
|
||||
DebugLevel0Fn("Unit %d Resource gone. Sit and play dumb.\n" _C_ unit->Slot);
|
||||
DebugPrint("Unit %d Resource gone. Sit and play dumb.\n" _C_ unit->Slot);
|
||||
DropOutOnSide(unit, LookingW, depot->Type->TileWidth, depot->Type->TileHeight);
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->SubAction = 0;
|
||||
|
@ -698,7 +686,7 @@ local int WaitInDepot(Unit* unit)
|
|||
*/
|
||||
void ResourceGiveUp(Unit* unit)
|
||||
{
|
||||
DebugLevel0Fn("Unit %d gave up on resource gathering.\n" _C_ unit->Slot);
|
||||
DebugPrint("Unit %d gave up on resource gathering.\n" _C_ unit->Slot);
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->Wait = 1;
|
||||
unit->Reset = 1;
|
||||
|
@ -728,12 +716,6 @@ global void HandleActionResource(Unit* unit)
|
|||
int ret;
|
||||
int newres;
|
||||
|
||||
DebugLevel3Fn("%s(%d) SubAction %d TTH %d res %s goal %ul\n" _C_
|
||||
unit->Type->Ident _C_ UnitNumber(unit) _C_ unit->SubAction _C_
|
||||
unit->Data.ResWorker.TimeToHarvest _C_
|
||||
DefaultResourceNames[unit->CurrentResource] _C_
|
||||
(unsigned int)unit->Orders->Goal);
|
||||
|
||||
// Let's start mining.
|
||||
if (unit->SubAction == SUB_START_RESOURCE) {
|
||||
if (unit->Orders->Goal) {
|
||||
|
@ -747,7 +729,6 @@ global void HandleActionResource(Unit* unit)
|
|||
}
|
||||
if ((unit->CurrentResource = newres)) {
|
||||
NewResetPath(unit);
|
||||
DebugLevel3Fn("Started mining. reset path.\n");
|
||||
unit->SubAction = SUB_MOVE_TO_RESOURCE;
|
||||
} else {
|
||||
unit->Value = 0;
|
||||
|
|
|
@ -69,21 +69,18 @@ global void HandleActionReturnGoods(Unit* unit)
|
|||
//
|
||||
Assert(type->Harvester );
|
||||
if ((!unit->CurrentResource) && (!unit->Value)) {
|
||||
DebugLevel0("Unit can't return resources, it doesn't carry any.\n");
|
||||
DebugPrint("Unit can't return resources, it doesn't carry any.\n");
|
||||
}
|
||||
if (!unit->Orders[0].Goal) {
|
||||
if (!(destu = FindDeposit(unit, unit->X, unit->Y, 1000,
|
||||
unit->CurrentResource))) {
|
||||
DebugLevel3Fn("No deposit -> can't return\n");
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
return;
|
||||
}
|
||||
unit->Orders[0].Goal = destu;
|
||||
RefsIncrease(destu);
|
||||
}
|
||||
DebugLevel3("Return to %d=%d,%d\n" _C_
|
||||
UnitNumber(unit->Orders[0].Goal) _C_
|
||||
unit->Orders[0].X _C_ unit->Orders[0].Y);
|
||||
|
||||
unit->Orders[0].Action = UnitActionResource;
|
||||
// Somewhere on the way the loaded worker could have change Arg1
|
||||
// Bummer, go get the closest resource to the depot
|
||||
|
|
|
@ -146,7 +146,7 @@ local void SpellMoveToTarget(Unit* unit)
|
|||
// on the caster anyway.
|
||||
//
|
||||
if ((spell = unit->Orders[0].Arg1)->Target == TargetSelf) {
|
||||
DebugLevel0Fn("Increase range for spellcast.");
|
||||
DebugPrint("Increase range for spellcast.");
|
||||
unit->Orders->Range++;
|
||||
} else {
|
||||
//
|
||||
|
@ -174,10 +174,6 @@ global void HandleActionSpellCast(Unit* unit)
|
|||
int flags;
|
||||
const SpellType* spell;
|
||||
|
||||
DebugLevel3Fn("%d %d,%d+%d\n" _C_
|
||||
UnitNumber(unit) _C_ unit->Orders[0].X _C_ unit->Orders[0].Y _C_
|
||||
unit->Orders[0].Range);
|
||||
|
||||
switch (unit->SubAction) {
|
||||
case 0:
|
||||
//
|
||||
|
@ -201,7 +197,7 @@ global void HandleActionSpellCast(Unit* unit)
|
|||
}
|
||||
|
||||
if (unit->Player->AiEnabled) {
|
||||
DebugLevel0Fn("FIXME: need we an AI callback?\n");
|
||||
DebugPrint("FIXME: do we need an AI callback?\n");
|
||||
}
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->SubAction = 0;
|
||||
|
|
|
@ -63,8 +63,6 @@ global void ActionStillGeneric(Unit* unit, int ground)
|
|||
Unit* goal;
|
||||
int i;
|
||||
|
||||
DebugLevel3Fn(" %d\n" _C_ UnitNumber(unit));
|
||||
|
||||
//
|
||||
// If unit is not bunkered and removed, wait
|
||||
//
|
||||
|
@ -191,8 +189,6 @@ global void ActionStillGeneric(Unit* unit, int ground)
|
|||
if ((goal = AttackUnitsInReactRange(unit))) {
|
||||
// Weak goal, can choose other unit, come back after attack
|
||||
CommandAttack(unit, goal->X, goal->Y, NULL, FlushCommands);
|
||||
DebugLevel3Fn(" %d Attacking in range %d\n" _C_
|
||||
UnitNumber(unit) _C_ unit->SubAction);
|
||||
Assert(unit->SavedOrder.Action == UnitActionStill);
|
||||
Assert(!unit->SavedOrder.Goal);
|
||||
unit->SavedOrder.Action = UnitActionAttack;
|
||||
|
@ -202,7 +198,6 @@ global void ActionStillGeneric(Unit* unit, int ground)
|
|||
unit->SavedOrder.Goal = NoUnitP;
|
||||
}
|
||||
} else if ((goal = AttackUnitsInRange(unit))) {
|
||||
DebugLevel3Fn(" %d #%d\n" _C_ UnitNumber(goal) _C_ goal->Refs);
|
||||
//
|
||||
// Old goal destroyed.
|
||||
//
|
||||
|
|
|
@ -178,7 +178,7 @@ global void HandleActionTrain(Unit* unit)
|
|||
}
|
||||
|
||||
if (!CanHandleOrder(nunit, &unit->NewOrder)) {
|
||||
DebugLevel0Fn("Wrong order for unit\n");
|
||||
DebugPrint("Wrong order for unit\n");
|
||||
#if 0
|
||||
nunit->Orders[0].Action = UnitActionStandStill;
|
||||
#endif
|
||||
|
@ -193,7 +193,7 @@ global void HandleActionTrain(Unit* unit)
|
|||
if (unit->NewOrder.Goal) {
|
||||
if (unit->NewOrder.Goal->Destroyed) {
|
||||
// FIXME: perhaps we should use another goal?
|
||||
DebugLevel0Fn("Destroyed unit in train unit\n");
|
||||
DebugPrint("Destroyed unit in train unit\n");
|
||||
RefsDecrease(unit->NewOrder.Goal);
|
||||
unit->NewOrder.Goal = NoUnitP;
|
||||
unit->NewOrder.Action = UnitActionStill;
|
||||
|
|
|
@ -232,7 +232,7 @@ local int ClosestFreeCoast(int x, int y, int* resx, int* resy)
|
|||
}
|
||||
++addy;
|
||||
}
|
||||
DebugLevel0Fn("Try clicking closer to an actual coast.\n");
|
||||
DebugPrint("Try clicking closer to an actual coast.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -300,11 +300,8 @@ local int ClosestFreeDropZone(Unit* transporter, int x, int y, int* resx, int* r
|
|||
*/
|
||||
local int MoveToDropZone(Unit* unit)
|
||||
{
|
||||
DebugLevel3Fn("%p\n" _C_ unit->Orders[0].Goal);
|
||||
|
||||
switch (DoActionMove(unit)) { // reached end-point?
|
||||
case PF_UNREACHABLE:
|
||||
DebugLevel2Fn("CAN'T REACH DROPZONE\n");
|
||||
return -1;
|
||||
case PF_REACHED:
|
||||
break;
|
||||
|
@ -333,11 +330,10 @@ local void LeaveTransporter(Unit* unit)
|
|||
// Goal is the specific unit unit that you want to unload.
|
||||
// This can be NULL, in case you want to unload everything.
|
||||
//
|
||||
DebugLevel3Fn("Goal %p\n" _C_ goal);
|
||||
if (goal) {
|
||||
unit->Orders[0].Goal = NoUnitP;
|
||||
if (goal->Destroyed) {
|
||||
DebugLevel0Fn("destroyed unit unloading?\n");
|
||||
DebugPrint("destroyed unit unloading?\n");
|
||||
RefsDecrease(goal);
|
||||
return;
|
||||
}
|
||||
|
@ -396,9 +392,6 @@ global void HandleActionUnload(Unit* unit)
|
|||
int x;
|
||||
int y;
|
||||
|
||||
DebugLevel3Fn("%p(%d) SubAction %d\n" _C_
|
||||
unit _C_ UnitNumber(unit) _C_ unit->SubAction);
|
||||
|
||||
switch (unit->SubAction) {
|
||||
//
|
||||
// Move the transporter
|
||||
|
|
|
@ -61,8 +61,6 @@ global void HandleActionUpgradeTo(Unit* unit)
|
|||
UnitType* type;
|
||||
const UnitStats* stats;
|
||||
|
||||
DebugLevel3Fn(" %d\n" _C_ UnitNumber(unit));
|
||||
|
||||
player = unit->Player;
|
||||
if (!unit->SubAction) { // first entry
|
||||
unit->Data.UpgradeTo.Ticks = 0;
|
||||
|
|
|
@ -85,12 +85,6 @@ global int UnitShowAnimation(Unit* unit, const Animation* animation)
|
|||
UnitUpdateHeading(unit); // FIXME: remove this!!
|
||||
}
|
||||
|
||||
DebugLevel3Fn("State %2d " _C_ state);
|
||||
DebugLevel3("Flags %2d Pixel %2d Frame %2d Wait %3d " _C_
|
||||
animation[state].Flags _C_ animation[state].Pixel _C_
|
||||
animation[state].Frame _C_ animation[state].Sleep);
|
||||
DebugLevel3("Heading %d +%d,%d\n" _C_ unit->Direction _C_ unit->IX _C_ unit->IY);
|
||||
|
||||
if (unit->Frame < 0) {
|
||||
unit->Frame -= animation[state].Frame;
|
||||
} else {
|
||||
|
@ -130,8 +124,8 @@ global int UnitShowAnimation(Unit* unit, const Animation* animation)
|
|||
*/
|
||||
local void HandleActionNone(Unit* unit __attribute__((unused)))
|
||||
{
|
||||
DebugLevel1Fn("FIXME: Should not happen!\n");
|
||||
DebugLevel1Fn("FIXME: Unit (%d) %s has action none.!\n" _C_
|
||||
DebugPrint("FIXME: Should not happen!\n");
|
||||
DebugPrint("FIXME: Unit (%d) %s has action none.!\n" _C_
|
||||
UnitNumber(unit) _C_ unit->Type->Ident);
|
||||
}
|
||||
|
||||
|
@ -142,8 +136,8 @@ local void HandleActionNone(Unit* unit __attribute__((unused)))
|
|||
*/
|
||||
local void HandleActionNotWritten(Unit* unit __attribute__((unused)))
|
||||
{
|
||||
DebugLevel1Fn("FIXME: Not written!\n");
|
||||
DebugLevel1Fn("FIXME: Unit (%d) %s has action %d.!\n" _C_
|
||||
DebugPrint("FIXME: Not written!\n");
|
||||
DebugPrint("FIXME: Unit (%d) %s has action %d.!\n" _C_
|
||||
UnitNumber(unit) _C_ unit->Type->Ident _C_ unit->Orders[0].Action);
|
||||
}
|
||||
|
||||
|
@ -317,7 +311,7 @@ local void HandleBuffs(Unit* unit, int amount)
|
|||
// Look if the time to live is over.
|
||||
//
|
||||
if (unit->TTL && unit->TTL < (GameCycle - unit->HP)) {
|
||||
DebugLevel0Fn("Unit must die %lu %lu!\n" _C_ unit->TTL _C_ GameCycle);
|
||||
DebugPrint("Unit must die %lu %lu!\n" _C_ unit->TTL _C_ GameCycle);
|
||||
//
|
||||
// Hit unit does some funky stuff...
|
||||
//
|
||||
|
@ -390,7 +384,7 @@ local void HandleUnitAction(Unit* unit)
|
|||
(unit->Orders[0].Action == UnitActionStill || unit->OrderFlush)) {
|
||||
|
||||
if (unit->Removed) { // FIXME: johns I see this as an error
|
||||
DebugLevel0Fn("Flushing removed unit\n");
|
||||
DebugPrint("Flushing removed unit\n");
|
||||
// This happens, if building with ALT+SHIFT.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ global void CommandMove(Unit* unit, int x, int y, int flush)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
DebugLevel0Fn("Internal movement error\n");
|
||||
DebugPrint("Internal movement error\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -396,7 +396,7 @@ global void CommandAttack(Unit* unit, int x, int y, Unit* attack, int flush)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
DebugLevel0Fn("Internal movement error\n");
|
||||
DebugPrint("Internal movement error\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -467,7 +467,7 @@ global void CommandAttackGround(Unit* unit, int x, int y, int flush)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
DebugLevel0Fn("Internal movement error\n");
|
||||
DebugPrint("Internal movement error\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -493,7 +493,7 @@ global void CommandAttackGround(Unit* unit, int x, int y, int flush)
|
|||
order->Type = NULL;
|
||||
order->Arg1 = NULL;
|
||||
|
||||
DebugLevel0("FIXME this next\n");
|
||||
DebugPrint("FIXME this next\n");
|
||||
}
|
||||
ClearSavedAction(unit);
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ global void CommandPatrolUnit(Unit* unit, int x, int y, int flush)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
DebugLevel0Fn("Internal movement error\n");
|
||||
DebugPrint("Internal movement error\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -716,7 +716,7 @@ global void CommandDismiss(Unit* unit)
|
|||
if (unit->Orders[0].Action == UnitActionBuilded) {
|
||||
unit->Data.Builded.Cancel = 1;
|
||||
} else {
|
||||
DebugLevel0("Suicide unit ... \n");
|
||||
DebugPrint("Suicide unit ... \n");
|
||||
LetUnitDie(unit);
|
||||
}
|
||||
ClearSavedAction(unit);
|
||||
|
@ -751,24 +751,22 @@ global void CommandResourceLoc(Unit* unit, int x, int y, int flush)
|
|||
order->Action = UnitActionResource;
|
||||
|
||||
// Find the closest piece of wood next to a tile where the unit can move
|
||||
DebugLevel3("Want to harvest from %d,%d.\n" _C_ x _C_ y);
|
||||
if (!FindTerrainType(0, (unit->Type->MovementMask), 1, 20,
|
||||
unit->Player, x, y, &nx, &ny)) {
|
||||
DebugLevel0Fn("FIXME: Give up???\n");
|
||||
DebugPrint("FIXME: Give up???\n");
|
||||
}
|
||||
|
||||
// Max Value > 1
|
||||
if ((abs(nx - x) | abs(ny - y)) > 1) {
|
||||
DebugLevel3("Closest tile reachable is at %d,%d.\n" _C_ x _C_ y);
|
||||
if (!FindTerrainType(0, MapFieldForest, 0, 20, unit->Player,
|
||||
nx, ny, &nx, &ny)) {
|
||||
DebugLevel0Fn("FIXME: Give up???\n");
|
||||
DebugPrint("FIXME: Give up???\n");
|
||||
}
|
||||
} else {
|
||||
// The destination is next to a reacahble tile.
|
||||
nx = x;
|
||||
ny = y;
|
||||
}
|
||||
DebugLevel3("So the final destination is %d,%d.\n" _C_ nx _C_ ny);
|
||||
order->X = nx;
|
||||
order->Y = ny;
|
||||
|
||||
|
@ -897,7 +895,7 @@ global void CommandTrainUnit(Unit* unit, UnitType* type,
|
|||
//
|
||||
if (unit->Orders[0].Action != UnitActionTrain) {
|
||||
if (unit->OrderCount == 2 && unit->Orders[1].Action == UnitActionTrain) {
|
||||
DebugLevel0Fn("FIXME: not supported. Unit queue full!\n");
|
||||
DebugPrint("FIXME: not supported. Unit queue full!\n");
|
||||
return;
|
||||
} else {
|
||||
ReleaseOrders(unit);
|
||||
|
@ -915,7 +913,7 @@ global void CommandTrainUnit(Unit* unit, UnitType* type,
|
|||
// Training slots are all already full. (NETWORK!)
|
||||
//
|
||||
if (!EnableTrainingQueue || unit->Data.Train.Count >= MAX_UNIT_TRAIN) {
|
||||
DebugLevel0Fn("Unit queue full!\n");
|
||||
DebugPrint("Unit queue full!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -939,7 +937,7 @@ global void CommandCancelTraining(Unit* unit, int slot, const UnitType* type)
|
|||
int i;
|
||||
int n;
|
||||
|
||||
DebugLevel0Fn("Cancel %d type: %s\n" _C_ slot _C_
|
||||
DebugPrint("Cancel %d type: %s\n" _C_ slot _C_
|
||||
type ? type->Ident : "-any-");
|
||||
|
||||
ClearSavedAction(unit);
|
||||
|
@ -961,7 +959,7 @@ global void CommandCancelTraining(Unit* unit, int slot, const UnitType* type)
|
|||
return;
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Cancel training\n");
|
||||
DebugPrint ("Cancel training\n");
|
||||
|
||||
PlayerAddCostsFactor(unit->Player,
|
||||
unit->Data.Train.What[slot]->Stats[unit->Player->Player].Costs,
|
||||
|
@ -978,7 +976,7 @@ global void CommandCancelTraining(Unit* unit, int slot, const UnitType* type)
|
|||
}
|
||||
unit->Data.Train.Count = n;
|
||||
} else {
|
||||
DebugLevel0Fn("Last slot\n");
|
||||
DebugPrint("Last slot\n");
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->SubAction = 0;
|
||||
unit->Wait = unit->Reset = 1;
|
||||
|
@ -1016,7 +1014,7 @@ global void CommandUpgradeTo(Unit* unit, UnitType* type, int flush)
|
|||
}
|
||||
|
||||
if (!flush) {
|
||||
DebugLevel0Fn("FIXME: must support order queing!!");
|
||||
DebugPrint("FIXME: must support order queing!!");
|
||||
}
|
||||
if (!(order = GetNextOrder(unit, flush))) {
|
||||
return;
|
||||
|
@ -1095,7 +1093,7 @@ global void CommandResearch(Unit* unit, Upgrade* what, int flush)
|
|||
}
|
||||
|
||||
if (!flush) {
|
||||
DebugLevel0Fn("FIXME: must support order queing!!");
|
||||
DebugPrint("FIXME: must support order queing!!");
|
||||
} else {
|
||||
if (unit->Orders[0].Action == UnitActionResearch) {
|
||||
const Upgrade* upgrade;
|
||||
|
@ -1184,12 +1182,12 @@ global void CommandSpellCast(Unit* unit, int x, int y, Unit* dest,
|
|||
|
||||
#ifdef DEBUG
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
DebugLevel0("Internal movement error\n");
|
||||
DebugPrint("Internal movement error\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
DebugLevel0Fn(": %d casts %s at %d %d on %d\n" _C_
|
||||
DebugPrint(": %d casts %s at %d %d on %d\n" _C_
|
||||
UnitNumber(unit) _C_ spell->Ident _C_ x _C_ y _C_ dest ? UnitNumber(dest) : 0);
|
||||
Assert(unit->Type->CanCastSpell[spell->Slot]);
|
||||
|
||||
|
@ -1244,9 +1242,6 @@ global void CommandSpellCast(Unit* unit, int x, int y, Unit* dest,
|
|||
*/
|
||||
global void CommandAutoSpellCast(Unit* unit, int spellid, int on)
|
||||
{
|
||||
DebugLevel3Fn(": %d auto-spell-casts %s\n" _C_
|
||||
UnitNumber(unit) _C_ spell->Ident);
|
||||
|
||||
//
|
||||
// Check if unit is still valid? (NETWORK!)
|
||||
//
|
||||
|
|
|
@ -222,8 +222,6 @@ local void AiCheckUnits(void)
|
|||
//
|
||||
for (queue = AiPlayer->UnitTypeBuilded; queue; queue = queue->Next) {
|
||||
counter[queue->Type->Slot] += queue->Want;
|
||||
DebugLevel3Fn("Already in build queue: %s %d/%d\n" _C_
|
||||
queue->Type->Ident _C_ queue->Made _C_ queue->Want);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -233,8 +231,6 @@ local void AiCheckUnits(void)
|
|||
for (i = 0; i < n; ++i) {
|
||||
if (!AiPlayer->Player->Units[i]->Active) {
|
||||
counter[AiPlayer->Player->Units[i]->Type->Slot]--;
|
||||
DebugLevel3Fn("Removing non active unit: %s\n" _C_
|
||||
AiPlayer->Player->Units[i]->Type->Ident);
|
||||
}
|
||||
}
|
||||
unit_types_count = AiPlayer->Player->UnitTypesCount;
|
||||
|
@ -252,16 +248,12 @@ local void AiCheckUnits(void)
|
|||
//
|
||||
e = unit_types_count[t];
|
||||
if (t < AiHelpers.EquivCount && AiHelpers.Equiv[t]) {
|
||||
DebugLevel3Fn("Equivalence for %s\n" _C_
|
||||
AiPlayer->UnitTypeRequests[i].Table[0]->Ident);
|
||||
for (j = 0; j < AiHelpers.Equiv[t]->Count; ++j) {
|
||||
e += unit_types_count[AiHelpers.Equiv[t]->Table[j]->Slot];
|
||||
}
|
||||
}
|
||||
|
||||
if (x > e + counter[t]) { // Request it.
|
||||
DebugLevel3Fn("Need %s *%d\n" _C_
|
||||
AiPlayer->UnitTypeRequests[i].Table[0]->Ident _C_ x);
|
||||
AiAddUnitTypeRequest(AiPlayer->UnitTypeRequests[i].Table[0],
|
||||
x - e - counter[t]);
|
||||
counter[t] += x - e - counter[t];
|
||||
|
@ -296,8 +288,6 @@ local void AiCheckUnits(void)
|
|||
t = aiut->Type->Slot;
|
||||
x = aiut->Want;
|
||||
if (x > unit_types_count[t] + counter[t] - attacking[t]) { // Request it.
|
||||
DebugLevel2Fn("Force %d need %s * %d\n" _C_ i _C_ aiut->Type->
|
||||
Ident _C_ x);
|
||||
AiAddUnitTypeRequest(aiut->Type,
|
||||
x - (unit_types_count[t] + counter[t] - attacking[t]));
|
||||
counter[t] += x - (unit_types_count[t] + counter[t] - attacking[t]);
|
||||
|
@ -320,8 +310,6 @@ local void AiCheckUnits(void)
|
|||
//
|
||||
e = unit_types_count[t];
|
||||
if (t < AiHelpers.EquivCount && AiHelpers.Equiv[t]) {
|
||||
DebugLevel3Fn("Equivalence for %s\n" _C_ AiPlayer->UpgradeToRequests[i]->
|
||||
Ident);
|
||||
for (j = 0; j < AiHelpers.Equiv[t]->Count; ++j) {
|
||||
e += unit_types_count[AiHelpers.Equiv[t]->Table[j]->Slot];
|
||||
}
|
||||
|
@ -339,10 +327,6 @@ local void AiCheckUnits(void)
|
|||
//
|
||||
n = AiPlayer->ResearchRequestsCount;
|
||||
for (i = 0; i < n; ++i) {
|
||||
DebugLevel3Fn("%s - %c\n" _C_
|
||||
AiPlayer->ResearchRequests[i]->Ident _C_
|
||||
UpgradeIdAllowed(AiPlayer->Player,
|
||||
AiPlayer->ResearchRequests[i] - Upgrades));
|
||||
if (UpgradeIdAllowed(AiPlayer->Player,
|
||||
AiPlayer->ResearchRequests[i] - Upgrades) == 'A') {
|
||||
AiAddResearchRequest(AiPlayer->ResearchRequests[i]);
|
||||
|
@ -614,7 +598,6 @@ local void SaveAiType(CLFile* file, const AiType* aitype)
|
|||
if (aitype->Next) {
|
||||
SaveAiType(file, aitype->Next);
|
||||
}
|
||||
DebugLevel3Fn("%s,%s,%s\n" _C_ aitype->Name _C_ aitype->Race _C_ aitype->Class);
|
||||
CLprintf(file, "DefineAi(\"%s\", \"%s\", \"%s\", %s)\n\n",
|
||||
aitype->Name, aitype->Race ? aitype->Race : "*",
|
||||
aitype->Class, aitype->FunctionName);
|
||||
|
@ -829,7 +812,7 @@ global void SaveAi(CLFile* file)
|
|||
#endif
|
||||
SaveAiPlayers(file);
|
||||
|
||||
DebugLevel0Fn("FIXME: Saving lua function definition isn't supported\n");
|
||||
DebugPrint("FIXME: Saving lua function definition isn't supported\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -843,7 +826,7 @@ global void AiInit(Player* player)
|
|||
AiType* ait;
|
||||
char* ainame;
|
||||
|
||||
DebugLevel0Fn("%d - %s -" _C_ player->Player _C_ player->Name);
|
||||
DebugPrint("%d - %s -" _C_ player->Player _C_ player->Name);
|
||||
|
||||
pai = calloc(1, sizeof (PlayerAi));
|
||||
if (!pai) {
|
||||
|
@ -854,15 +837,15 @@ global void AiInit(Player* player)
|
|||
ait = AiTypes;
|
||||
|
||||
ainame = AiTypeWcNames[player->AiNum];
|
||||
DebugLevel0(" looking for class %s\n" _C_ ainame);
|
||||
DebugPrint(" looking for class %s\n" _C_ ainame);
|
||||
|
||||
//
|
||||
// Search correct AI type.
|
||||
//
|
||||
if (!ait) {
|
||||
DebugLevel0Fn
|
||||
DebugPrint
|
||||
("AI: Got no scripts at all! You need at least one dummy fallback script.\n");
|
||||
DebugLevel0Fn("AI: Look at the (define-ai) documentation.\n");
|
||||
DebugPrint("AI: Look at the (define-ai) documentation.\n");
|
||||
exit(0);
|
||||
}
|
||||
for (;;) {
|
||||
|
@ -891,14 +874,14 @@ global void AiInit(Player* player)
|
|||
break;
|
||||
}
|
||||
if (!ait) {
|
||||
DebugLevel0Fn("AI: Found no matching ai scripts at all!\n");
|
||||
DebugPrint("AI: Found no matching ai scripts at all!\n");
|
||||
exit(0);
|
||||
}
|
||||
if (!ainame) {
|
||||
DebugLevel0Fn("AI: not found!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
|
||||
DebugLevel0Fn("AI: Using fallback:\n");
|
||||
DebugPrint("AI: not found!!!!!!!!!!\n");
|
||||
DebugPrint("AI: Using fallback:\n");
|
||||
}
|
||||
DebugLevel0Fn("AI: %s:%s with %s:%s\n" _C_ player->RaceName _C_ ait->Race
|
||||
DebugPrint("AI: %s:%s with %s:%s\n" _C_ player->RaceName _C_ ait->Race
|
||||
_C_ ainame _C_ ait->Class);
|
||||
|
||||
pai->AiType = ait;
|
||||
|
@ -990,7 +973,6 @@ global void CleanAi(void)
|
|||
// Free AiTypes.
|
||||
//
|
||||
for (aitype = AiTypes; aitype; aitype = temp) {
|
||||
DebugLevel3Fn("%s,%s,%s\n" _C_ aitype->Name _C_ aitype->Race _C_ aitype->Class);
|
||||
free(aitype->Name);
|
||||
free(aitype->Race);
|
||||
free(aitype->Class);
|
||||
|
@ -1116,7 +1098,7 @@ local void AiRemoveFromBuilded(PlayerAi* pai, const UnitType* type)
|
|||
}
|
||||
|
||||
if (pai->Player == ThisPlayer) {
|
||||
DebugLevel0Fn
|
||||
DebugPrint
|
||||
("My guess is that you built something under ai me. naughty boy!\n");
|
||||
return;
|
||||
}
|
||||
|
@ -1191,7 +1173,7 @@ global void AiHelpMe(const Unit* attacker, Unit* defender)
|
|||
AiUnit* aiunit;
|
||||
int force;
|
||||
|
||||
DebugLevel0Fn("%d: %d(%s) attacked at %d,%d\n" _C_
|
||||
DebugPrint("%d: %d(%s) attacked at %d,%d\n" _C_
|
||||
defender->Player->Player _C_ UnitNumber(defender) _C_
|
||||
defender->Type->Ident _C_ defender->X _C_ defender->Y);
|
||||
|
||||
|
@ -1224,7 +1206,6 @@ global void AiHelpMe(const Unit* attacker, Unit* defender)
|
|||
}
|
||||
}
|
||||
|
||||
DebugLevel2Fn("Sending force 0 and 1 to defend\n");
|
||||
//
|
||||
// Send force 0 defending, also send force 1 if this is home.
|
||||
//
|
||||
|
@ -1251,7 +1232,7 @@ global void AiHelpMe(const Unit* attacker, Unit* defender)
|
|||
*/
|
||||
global void AiUnitKilled(Unit* unit)
|
||||
{
|
||||
DebugLevel1Fn("%d: %d(%s) killed\n" _C_
|
||||
DebugPrint("%d: %d(%s) killed\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident);
|
||||
|
||||
Assert(unit->Player->Type != PlayerPerson);
|
||||
|
@ -1263,18 +1244,18 @@ global void AiUnitKilled(Unit* unit)
|
|||
case UnitActionMove:
|
||||
break;
|
||||
case UnitActionBuilded:
|
||||
DebugLevel1Fn("%d: %d(%s) killed, under construction!\n" _C_
|
||||
DebugPrint("%d: %d(%s) killed, under construction!\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident);
|
||||
AiReduceMadeInBuilded(unit->Player->Ai, unit->Type);
|
||||
break;
|
||||
case UnitActionBuild:
|
||||
DebugLevel1Fn("%d: %d(%s) killed, with order %s!\n" _C_
|
||||
DebugPrint("%d: %d(%s) killed, with order %s!\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_
|
||||
unit->Type->Ident _C_ unit->Orders[0].Type->Ident);
|
||||
AiReduceMadeInBuilded(unit->Player->Ai, unit->Orders[0].Type);
|
||||
break;
|
||||
default:
|
||||
DebugLevel1Fn("FIXME: %d: %d(%s) killed, with order %d!\n" _C_
|
||||
DebugPrint("FIXME: %d: %d(%s) killed, with order %d!\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_
|
||||
unit->Type->Ident _C_ unit->Orders[0].Action);
|
||||
break;
|
||||
|
@ -1290,11 +1271,11 @@ global void AiUnitKilled(Unit* unit)
|
|||
global void AiWorkComplete(Unit* unit, Unit* what)
|
||||
{
|
||||
if (unit) {
|
||||
DebugLevel1Fn("%d: %d(%s) build %s at %d,%d completed\n" _C_
|
||||
DebugPrint("%d: %d(%s) build %s at %d,%d completed\n" _C_
|
||||
what->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
|
||||
what->Type->Ident _C_ unit->X _C_ unit->Y);
|
||||
} else {
|
||||
DebugLevel1Fn("%d: building %s at %d,%d completed\n" _C_
|
||||
DebugPrint("%d: building %s at %d,%d completed\n" _C_
|
||||
what->Player->Player _C_ what->Type->Ident _C_ what->X _C_ what->Y);
|
||||
}
|
||||
|
||||
|
@ -1311,7 +1292,7 @@ global void AiWorkComplete(Unit* unit, Unit* what)
|
|||
*/
|
||||
global void AiCanNotBuild(Unit* unit, const UnitType* what)
|
||||
{
|
||||
DebugLevel0Fn("%d: %d(%s) Can't build %s at %d,%d\n" _C_
|
||||
DebugPrint("%d: %d(%s) Can't build %s at %d,%d\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
|
||||
what->Ident _C_ unit->X _C_ unit->Y);
|
||||
|
||||
|
@ -1328,10 +1309,6 @@ global void AiCanNotBuild(Unit* unit, const UnitType* what)
|
|||
*/
|
||||
global void AiCanNotReach(Unit* unit, const UnitType* what)
|
||||
{
|
||||
DebugLevel3Fn("%d: %d(%s) Can't reach %s at %d,%d\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
|
||||
what->Ident _C_ unit->X _C_ unit->Y);
|
||||
|
||||
Assert(unit->Player->Type != PlayerPerson);
|
||||
|
||||
AiReduceMadeInBuilded(unit->Player->Ai, what);
|
||||
|
@ -1606,8 +1583,6 @@ global void AiCanNotMove(Unit* unit)
|
|||
int minrange;
|
||||
int maxrange;
|
||||
|
||||
DebugLevel3Fn("%s at %d %d\n" _C_ unit->Type->Ident _C_ unit->X _C_ unit->Y);
|
||||
|
||||
AiPlayer = unit->Player->Ai;
|
||||
|
||||
if (unit->Orders[0].Goal) {
|
||||
|
@ -1632,7 +1607,6 @@ global void AiCanNotMove(Unit* unit)
|
|||
if (PlaceReachable(unit, gx, gy, gw, gh, minrange, maxrange) ||
|
||||
unit->Type->UnitType == UnitTypeFly) {
|
||||
// Path probably closed by unit here
|
||||
DebugLevel3Fn("Place reacheable, move unit in the way.\n");
|
||||
AiMoveUnitInTheWay(unit);
|
||||
return;
|
||||
}
|
||||
|
@ -1721,7 +1695,6 @@ local void HandleTransportRequests(AiTransportRequest* aitr)
|
|||
}
|
||||
|
||||
if (!ZoneSetFindPath(&UnitZones, &DestZones, zonepath, &zonepathlen)) {
|
||||
DebugLevel3Fn("no way over there.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1733,7 +1706,7 @@ local void HandleTransportRequests(AiTransportRequest* aitr)
|
|||
HelpWithTransporter(aitr->Unit, transporter, zonepath[1], zonepath[2]);
|
||||
CommandAnyOrder(aitr->Unit, &aitr->Order, 0);
|
||||
} else {
|
||||
DebugLevel2Fn("All transporters are busy, waits.\n");
|
||||
DebugPrint("All transporters are busy, waits.\n");
|
||||
}
|
||||
} else {
|
||||
// FIXME : Find or build transporter builder in the zone
|
||||
|
@ -1749,10 +1722,6 @@ local void HandleTransportRequests(AiTransportRequest* aitr)
|
|||
*/
|
||||
global void AiNeedMoreSupply(Unit* unit, const UnitType* what __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("%d: %d(%s) need more farms %s at %d,%d\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
|
||||
what->Ident _C_ unit->X _C_ unit->Y);
|
||||
|
||||
Assert(unit->Player->Type != PlayerPerson);
|
||||
|
||||
((PlayerAi*)unit->Player->Ai)->NeedSupply = 1;
|
||||
|
@ -1766,7 +1735,7 @@ global void AiNeedMoreSupply(Unit* unit, const UnitType* what __attribute__((unu
|
|||
*/
|
||||
global void AiTrainingComplete(Unit* unit, Unit* what)
|
||||
{
|
||||
DebugLevel1Fn("%d: %d(%s) training %s at %d,%d completed\n" _C_
|
||||
DebugPrint("%d: %d(%s) training %s at %d,%d completed\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
|
||||
what->Type->Ident _C_ unit->X _C_ unit->Y);
|
||||
|
||||
|
@ -1788,7 +1757,7 @@ global void AiTrainingComplete(Unit* unit, Unit* what)
|
|||
global void AiUpgradeToComplete(Unit* unit __attribute__((unused)),
|
||||
const UnitType* what __attribute__((unused)))
|
||||
{
|
||||
DebugLevel1Fn("%d: %d(%s) upgrade-to %s at %d,%d completed\n" _C_
|
||||
DebugPrint("%d: %d(%s) upgrade-to %s at %d,%d completed\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
|
||||
what->Ident _C_ unit->X _C_ unit->Y);
|
||||
|
||||
|
@ -1804,7 +1773,7 @@ global void AiUpgradeToComplete(Unit* unit __attribute__((unused)),
|
|||
global void AiResearchComplete(Unit* unit __attribute__((unused)),
|
||||
const Upgrade* what __attribute__((unused)))
|
||||
{
|
||||
DebugLevel1Fn("%d: %d(%s) research %s at %d,%d completed\n" _C_
|
||||
DebugPrint("%d: %d(%s) research %s at %d,%d completed\n" _C_
|
||||
unit->Player->Player _C_ UnitNumber(unit) _C_ unit->Type->Ident _C_
|
||||
what->Ident _C_ unit->X _C_ unit->Y);
|
||||
|
||||
|
@ -1858,8 +1827,6 @@ global void AiEachSecond(Player* player)
|
|||
long sx;
|
||||
#endif
|
||||
|
||||
DebugLevel3Fn("%d:\n" _C_ player->Player);
|
||||
|
||||
AiPlayer = player->Ai;
|
||||
#ifdef DEBUG
|
||||
if (!AiPlayer) {
|
||||
|
|
|
@ -226,9 +226,6 @@ local int AiFindBuildingPlace2(const Unit * worker, const UnitType * type,
|
|||
continue;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Checking to build %s(%s) at %d,%d\n" _C_
|
||||
type->Ident _C_ type->Name _C_ x _C_ y);
|
||||
|
||||
//
|
||||
// Look if we can build here.
|
||||
//
|
||||
|
@ -237,7 +234,6 @@ local int AiFindBuildingPlace2(const Unit * worker, const UnitType * type,
|
|||
*dx = x;
|
||||
*dy = y;
|
||||
free(points);
|
||||
DebugLevel3Fn("Found a building place!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -579,9 +575,9 @@ global int AiFindBuildingPlace(const Unit* worker, const UnitType* type, int* dx
|
|||
//
|
||||
// Find a good place for a new hall
|
||||
//
|
||||
DebugLevel0Fn("Want to build a %s(%s)\n" _C_ type->Ident _C_ type->Name);
|
||||
DebugPrint("Want to build a %s(%s)\n" _C_ type->Ident _C_ type->Name);
|
||||
if (type->CanStore[GoldCost] && AiFindHallPlace(worker, type, dx, dy)) {
|
||||
DebugLevel0Fn("Found place for town hall (%s,%s)\n" _C_ type->Ident _C_ type->
|
||||
DebugPrint("Found place for town hall (%s,%s)\n" _C_ type->Ident _C_ type->
|
||||
Name);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -181,11 +181,6 @@ global int AiFindAvailableUnitTypeEquiv(const UnitType* unittype, int* usableTyp
|
|||
}
|
||||
}
|
||||
}
|
||||
DebugLevel3Fn("prefered order for %s is " _C_ unittype->Ident);
|
||||
for (i = 0; i < usableTypesCount; ++i) {
|
||||
DebugLevel3(" %s" _C_ UnitTypes[usableTypes[i]]->Ident);
|
||||
}
|
||||
DebugLevel3("\n");
|
||||
|
||||
return usableTypesCount;
|
||||
}
|
||||
|
@ -240,7 +235,6 @@ local void AiCleanForce(int force)
|
|||
aitype = AiPlayer->Force[force].UnitTypes;
|
||||
while (aitype) {
|
||||
if (aitype->Want > counter[aitype->Type->Slot]) {
|
||||
DebugLevel3Fn("%d: missing %s.\n" _C_ force _C_ aitype->Type->Ident);
|
||||
AiPlayer->Force[force].Completed = 0;
|
||||
}
|
||||
counter[aitype->Type->Slot] -= aitype->Want;
|
||||
|
@ -254,7 +248,6 @@ local void AiCleanForce(int force)
|
|||
prev = &AiPlayer->Force[force].Units;
|
||||
while ((aiunit = *prev)) {
|
||||
if (counter[aiunit->Unit->Type->Slot] > 0) {
|
||||
DebugLevel3Fn("Release unit %s\n" _C_ aiunit->Unit->Type->Ident);
|
||||
counter[UnitTypeEquivs[aiunit->Unit->Type->Slot]]--;
|
||||
RefsDecrease(aiunit->Unit);
|
||||
*prev = aiunit->Next;
|
||||
|
@ -264,8 +257,6 @@ local void AiCleanForce(int force)
|
|||
prev = &aiunit->Next;
|
||||
}
|
||||
}
|
||||
|
||||
DebugLevel3Fn("%d complete %d\n" _C_ force _C_ AiPlayer->Force[force].Completed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -459,7 +450,7 @@ global void AiAttackWithForce(int force)
|
|||
while (AiPlayer->Force[f].Attacking) {
|
||||
++f;
|
||||
if (f == AI_MAX_ATTACKING_FORCES) {
|
||||
DebugLevel0Fn("No free attacking forces\n");
|
||||
DebugPrint("No free attacking forces\n");
|
||||
f = force;
|
||||
break;
|
||||
}
|
||||
|
@ -492,7 +483,6 @@ global void AiAttackWithForce(int force)
|
|||
AiPlayer->Force[force].Attacking = 0;
|
||||
if ((aiunit = AiPlayer->Force[force].Units)) {
|
||||
AiPlayer->Force[force].Attacking = 1;
|
||||
DebugLevel3Fn("FORCE %d started (AiAttackWithForce)\n" _C_ force);
|
||||
|
||||
enemy = NoUnitP;
|
||||
while (aiunit && !enemy) {
|
||||
|
@ -503,10 +493,10 @@ global void AiAttackWithForce(int force)
|
|||
}
|
||||
|
||||
if (!enemy) {
|
||||
DebugLevel0Fn("Need to plan an attack with transporter\n");
|
||||
DebugPrint("Need to plan an attack with transporter\n");
|
||||
if (!AiPlayer->Force[force].State &&
|
||||
!AiPlanAttack(&AiPlayer->Force[force])) {
|
||||
DebugLevel0Fn("Can't transport, look for walls\n");
|
||||
DebugPrint("Can't transport, look for walls\n");
|
||||
if (!AiFindWall(&AiPlayer->Force[force])) {
|
||||
AiPlayer->Force[force].Attacking = 0;
|
||||
}
|
||||
|
@ -551,16 +541,10 @@ local void AiForceAttacks(AiForce* force)
|
|||
}
|
||||
// Must mark the attack as terminated
|
||||
if (!aiunit) {
|
||||
DebugLevel3Fn("FORCE stopped ( AiForceAttacks, unitactionstill )\n");
|
||||
DebugLevel3Fn("force target was %d %d\n" _C_ force->GoalX _C_ force->GoalY);
|
||||
DebugLevel3Fn("unit pos was %d %d\n" _C_ force->Units->Unit->X _C_ force->
|
||||
Units->Unit->Y);
|
||||
|
||||
force->Attacking = 0;
|
||||
// AiAttackWithForce(force-AiPlayer->Force);
|
||||
}
|
||||
} else {
|
||||
DebugLevel3Fn("FORCE stopped ( AiAttackWithForce, no unit )\n");
|
||||
force->Attacking = 0;
|
||||
}
|
||||
}
|
||||
|
@ -594,7 +578,7 @@ global void AiForceManager(void)
|
|||
aiunit = aiunit->Next;
|
||||
}
|
||||
if (!aiunit) { // No enemies go home.
|
||||
DebugLevel0Fn("FIXME: not written, should send force home\n");
|
||||
DebugPrint("FIXME: not written, should send force home\n");
|
||||
AiPlayer->Force[force].Defending = 0;
|
||||
AiPlayer->Force[force].Attacking = 0;
|
||||
}
|
||||
|
|
|
@ -80,9 +80,6 @@ global void AiCheckMagic(void)
|
|||
success = // Follow on next line (AutoCastSpell).
|
||||
#endif
|
||||
AutoCastSpell(unit, SpellTypeTable[j]);
|
||||
DebugLevel3Fn("Mage '%s' cast '%s' : %s\n" _C_
|
||||
unit->Type->Ident _C_
|
||||
SpellTypeTable[j]->Ident _C_ success ? "success" : "fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ local void AiMarkWaterTransporter(const Unit * unit, unsigned char *matrix)
|
|||
w = TheMap.Width + 2;
|
||||
matrix += w + w + 2;
|
||||
if (matrix[x + y * w]) { // already marked
|
||||
DebugLevel0("Done\n");
|
||||
DebugPrint("Done\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ local int AiFindTarget(const Unit* unit, unsigned char* matrix, int* dx, int* dy
|
|||
if (state != OnWater) {
|
||||
if (*m) { // already checked
|
||||
if (state == OnLand && *m == 66) { // tansporter?
|
||||
DebugLevel0Fn("->Water\n");
|
||||
DebugPrint("->Water\n");
|
||||
*m = 6;
|
||||
points[wp].X = x; // push the point
|
||||
points[wp].Y = y;
|
||||
|
@ -294,7 +294,7 @@ local int AiFindTarget(const Unit* unit, unsigned char* matrix, int* dx, int* dy
|
|||
// FIXME: the move code didn't likes a shore building as
|
||||
// target
|
||||
if (EnemyOnMapTile(unit, x, y)) {
|
||||
DebugLevel0Fn("Target found %d,%d-%d\n" _C_ x _C_ y _C_ state);
|
||||
DebugPrint("Target found %d,%d-%d\n" _C_ x _C_ y _C_ state);
|
||||
*dx = x;
|
||||
*dy = y;
|
||||
*ds = state;
|
||||
|
@ -328,7 +328,7 @@ local int AiFindTarget(const Unit* unit, unsigned char* matrix, int* dx, int* dy
|
|||
continue;
|
||||
}
|
||||
if (CanMoveToMask(x, y, mask)) { // reachable
|
||||
DebugLevel0Fn("->Land\n");
|
||||
DebugPrint("->Land\n");
|
||||
*m = 1;
|
||||
points[wp].X = x; // push the point
|
||||
points[wp].Y = y;
|
||||
|
@ -444,7 +444,7 @@ global int AiFindWall(AiForce* force)
|
|||
// Check for a wall
|
||||
//
|
||||
if (WallOnMap(x, y)) {
|
||||
DebugLevel0Fn("Wall found %d,%d\n" _C_ x _C_ y);
|
||||
DebugPrint("Wall found %d,%d\n" _C_ x _C_ y);
|
||||
destx = x;
|
||||
desty = y;
|
||||
break;
|
||||
|
@ -514,7 +514,7 @@ global int AiPlanAttack(AiForce* force)
|
|||
int state;
|
||||
Unit* transporter;
|
||||
|
||||
DebugLevel0Fn("Planning for force #%d of player #%d\n" _C_
|
||||
DebugPrint("Planning for force #%d of player #%d\n" _C_
|
||||
force - AiPlayer->Force _C_ AiPlayer->Player->Player);
|
||||
|
||||
watermatrix = CreateMatrix();
|
||||
|
@ -527,7 +527,7 @@ global int AiPlanAttack(AiForce* force)
|
|||
state = 1;
|
||||
while (aiunit) {
|
||||
if (aiunit->Unit->Type->Transporter) {
|
||||
DebugLevel0Fn("Transporter #%d\n" _C_ UnitNumber(aiunit->Unit));
|
||||
DebugPrint("Transporter #%d\n" _C_ UnitNumber(aiunit->Unit));
|
||||
AiMarkWaterTransporter(aiunit->Unit, watermatrix);
|
||||
state = 0;
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ global int AiPlanAttack(AiForce* force)
|
|||
|
||||
unit = AiPlayer->Player->Units[i];
|
||||
if (unit->Type->Transporter && UnitIdle(unit)) {
|
||||
DebugLevel0Fn("Assign any transporter\n");
|
||||
DebugPrint("Assign any transporter\n");
|
||||
AiMarkWaterTransporter(unit, watermatrix);
|
||||
// FIXME: can be the wrong transporter.
|
||||
transporter = unit;
|
||||
|
@ -554,7 +554,7 @@ global int AiPlanAttack(AiForce* force)
|
|||
}
|
||||
|
||||
if (state) { // Absolute no transporter
|
||||
DebugLevel0Fn("No transporter available\n");
|
||||
DebugPrint("No transporter available\n");
|
||||
// FIXME: should tell the resource manager we need a transporter!
|
||||
return 0;
|
||||
}
|
||||
|
@ -565,14 +565,14 @@ global int AiPlanAttack(AiForce* force)
|
|||
aiunit = force->Units;
|
||||
while (aiunit) {
|
||||
if (aiunit->Unit->Type->UnitType == UnitTypeLand) {
|
||||
DebugLevel0Fn("Landunit %d\n" _C_ UnitNumber(aiunit->Unit));
|
||||
DebugPrint("Landunit %d\n" _C_ UnitNumber(aiunit->Unit));
|
||||
break;
|
||||
}
|
||||
aiunit = aiunit->Next;
|
||||
}
|
||||
|
||||
if (!aiunit) {
|
||||
DebugLevel0Fn("No land unit in force\n");
|
||||
DebugPrint("No land unit in force\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -587,7 +587,7 @@ global int AiPlanAttack(AiForce* force)
|
|||
RefsIncrease(transporter);
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Can attack\n");
|
||||
DebugPrint("Can attack\n");
|
||||
force->GoalX = x;
|
||||
force->GoalY = y;
|
||||
force->MustTransport = state == 2;
|
||||
|
|
|
@ -129,25 +129,21 @@ local int AiCheckSupply(const PlayerAi* pai, const UnitType* type)
|
|||
int remaining;
|
||||
const AiBuildQueue* queue;
|
||||
|
||||
DebugLevel3Fn(" for player %d\n" _C_ pai->Player->Player);
|
||||
//
|
||||
// Count food supplies under construction.
|
||||
//
|
||||
remaining = 0;
|
||||
for (queue = pai->UnitTypeBuilded; queue; queue = queue->Next) {
|
||||
if (queue->Type->Supply) {
|
||||
DebugLevel3Fn("Builded %d remain %d\n" _C_ queue->Made _C_ remaining);
|
||||
remaining += queue->Made * queue->Type->Supply;
|
||||
}
|
||||
}
|
||||
DebugLevel3Fn("Remain %d" _C_ remaining);
|
||||
|
||||
//
|
||||
// We are already out of food.
|
||||
//
|
||||
remaining += pai->Player->Supply - pai->Player->Demand - type->Demand;
|
||||
DebugLevel3Fn("-Demand %d\n" _C_ remaining);
|
||||
if (remaining < 0) {
|
||||
DebugLevel3Fn(" player %d needs more food\n" _C_ pai->Player->Player);
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
|
@ -155,9 +151,7 @@ local int AiCheckSupply(const PlayerAi* pai, const UnitType* type)
|
|||
//
|
||||
for (queue = pai->UnitTypeBuilded; queue; queue = queue->Next) {
|
||||
if (!queue->Type->Building) {
|
||||
DebugLevel3Fn("Trained %d remain %d\n" _C_ queue->Made _C_ remaining);
|
||||
if ((remaining -= queue->Made * queue->Type->Demand) < 0) {
|
||||
DebugLevel3Fn(" player %d needs more food\n" _C_ pai->Player->Player);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -199,8 +193,6 @@ global int EnemyUnitsInDistance(const Unit* unit, unsigned range)
|
|||
int e;
|
||||
const Player* player;
|
||||
|
||||
DebugLevel3Fn("(%d)%s\n" _C_ UnitNumber(unit) _C_ unit->Type->Ident);
|
||||
|
||||
//
|
||||
// Select all units in range.
|
||||
//
|
||||
|
@ -258,8 +250,6 @@ local int AiBuildBuilding(const UnitType* type, UnitType* building)
|
|||
int x;
|
||||
int y;
|
||||
|
||||
DebugLevel3Fn("%s can made %s\n" _C_ type->Ident _C_ building->Ident);
|
||||
|
||||
#ifdef DEBUG
|
||||
unit = NoUnitP;
|
||||
#endif
|
||||
|
@ -283,7 +273,6 @@ local int AiBuildBuilding(const UnitType* type, UnitType* building)
|
|||
for (i = 0; i < num; ++i) {
|
||||
|
||||
unit = table[i];
|
||||
DebugLevel3Fn("Have an unit to build %d :)\n" _C_ UnitNumber(unit));
|
||||
|
||||
//
|
||||
// Find place on that could be build.
|
||||
|
@ -292,8 +281,6 @@ local int AiBuildBuilding(const UnitType* type, UnitType* building)
|
|||
continue;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Have a building place %d,%d for %s:)\n" _C_ x _C_ y _C_ building->Name);
|
||||
|
||||
CommandBuildBuilding(unit, x, y, building, FlushCommands);
|
||||
|
||||
return 1;
|
||||
|
@ -334,16 +321,13 @@ local void AiRequestSupply(void)
|
|||
return;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Must build: %s\n" _C_ type->Ident);
|
||||
//
|
||||
// Check if resources available.
|
||||
//
|
||||
if ((c = AiCheckUnitTypeCosts(type))) {
|
||||
DebugLevel3("- no resources\n");
|
||||
AiPlayer->NeededMask |= c;
|
||||
return;
|
||||
} else {
|
||||
DebugLevel3("- enough resources\n");
|
||||
if (AiMakeUnit(type)) {
|
||||
queue = malloc(sizeof (*AiPlayer->UnitTypeBuilded));
|
||||
queue->Next = AiPlayer->UnitTypeBuilded;
|
||||
|
@ -374,8 +358,6 @@ local int AiTrainUnit(const UnitType* type, UnitType* what)
|
|||
int i;
|
||||
int num;
|
||||
|
||||
DebugLevel3Fn("%s can made %s\n" _C_ type->Ident _C_ what->Ident);
|
||||
|
||||
#ifdef DEBUG
|
||||
unit = NoUnitP;
|
||||
#endif
|
||||
|
@ -392,9 +374,7 @@ local int AiTrainUnit(const UnitType* type, UnitType* what)
|
|||
}
|
||||
|
||||
for (i = 0; i < num; ++i) {
|
||||
|
||||
unit = table[i];
|
||||
DebugLevel3Fn("Have an unit to train %d :)\n" _C_ UnitNumber(unit));
|
||||
|
||||
CommandTrainUnit(unit, what, FlushCommands);
|
||||
|
||||
|
@ -419,7 +399,7 @@ global int AiCountUnitBuilders(UnitType* type)
|
|||
const AiUnitTypeTable* table;
|
||||
|
||||
if (UnitIdAllowed(AiPlayer->Player, type->Slot) == 0) {
|
||||
DebugLevel0Fn("Can't build `%s' now\n" _C_ type->Ident);
|
||||
DebugPrint("Can't build `%s' now\n" _C_ type->Ident);
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
|
@ -433,12 +413,12 @@ global int AiCountUnitBuilders(UnitType* type)
|
|||
tablep = AiHelpers.Train;
|
||||
}
|
||||
if (type->Slot > n) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
return 0;
|
||||
}
|
||||
table = tablep[type->Slot];
|
||||
if (!table) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
return 0;
|
||||
}
|
||||
n = table->Count;
|
||||
|
@ -475,8 +455,6 @@ local int AiMakeUnit(UnitType* type)
|
|||
int usableTypesCount;
|
||||
int currentType;
|
||||
|
||||
DebugLevel3Fn(":%s\n" _C_ type->Name);
|
||||
|
||||
// Find equivalents unittypes.
|
||||
usableTypesCount = AiFindAvailableUnitTypeEquiv(type, usableTypes);
|
||||
|
||||
|
@ -496,12 +474,12 @@ local int AiMakeUnit(UnitType* type)
|
|||
tablep = AiHelpers.Train;
|
||||
}
|
||||
if (type->Slot > n) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
continue;
|
||||
}
|
||||
table = tablep[type->Slot];
|
||||
if (!table) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
continue;
|
||||
}
|
||||
n = table->Count;
|
||||
|
@ -512,7 +490,6 @@ local int AiMakeUnit(UnitType* type)
|
|||
// The type for builder/trainer is available
|
||||
//
|
||||
if (unit_count[table->Table[i]->Slot]) {
|
||||
DebugLevel3("Found a builder for a %s.\n" _C_ type->ident);
|
||||
if (type->Building) {
|
||||
if (AiBuildBuilding(table->Table[i], type)) {
|
||||
return 1;
|
||||
|
@ -546,8 +523,6 @@ local int AiResearchUpgrade(const UnitType* type, Upgrade* what)
|
|||
int i;
|
||||
int num;
|
||||
|
||||
DebugLevel3Fn("%s can research %s\n" _C_ type->Ident _C_ what->Ident);
|
||||
|
||||
#ifdef DEBUG
|
||||
unit = NoUnitP;
|
||||
#endif
|
||||
|
@ -562,9 +537,7 @@ local int AiResearchUpgrade(const UnitType* type, Upgrade* what)
|
|||
}
|
||||
|
||||
for (i = 0; i < num; ++i) {
|
||||
|
||||
unit = table[i];
|
||||
DebugLevel3Fn("Have an unit to research %d :)\n" _C_ UnitNumber(unit));
|
||||
|
||||
CommandResearch(unit, what, FlushCommands);
|
||||
|
||||
|
@ -601,12 +574,12 @@ global void AiAddResearchRequest(Upgrade* upgrade)
|
|||
tablep = AiHelpers.Research;
|
||||
|
||||
if (upgrade - Upgrades > n) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ upgrade->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ upgrade->Ident);
|
||||
return;
|
||||
}
|
||||
table = tablep[upgrade - Upgrades];
|
||||
if (!table) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ upgrade->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ upgrade->Ident);
|
||||
return;
|
||||
}
|
||||
n = table->Count;
|
||||
|
@ -644,8 +617,6 @@ local int AiUpgradeTo(const UnitType* type, UnitType* what)
|
|||
int i;
|
||||
int num;
|
||||
|
||||
DebugLevel3Fn("%s can upgrade-to %s\n" _C_ type->Ident _C_ what->Ident);
|
||||
|
||||
#ifdef DEBUG
|
||||
unit = NoUnitP;
|
||||
#endif
|
||||
|
@ -660,9 +631,7 @@ local int AiUpgradeTo(const UnitType* type, UnitType* what)
|
|||
}
|
||||
|
||||
for (i = 0; i < num; ++i) {
|
||||
|
||||
unit = table[i];
|
||||
DebugLevel3Fn("Have an unit to upgrade-to %d :)\n" _C_ UnitNumber(unit));
|
||||
|
||||
CommandUpgradeTo(unit, what, FlushCommands);
|
||||
|
||||
|
@ -699,12 +668,12 @@ global void AiAddUpgradeToRequest(UnitType* type)
|
|||
tablep = AiHelpers.Upgrade;
|
||||
|
||||
if (type->Slot > n) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
return;
|
||||
}
|
||||
table = tablep[type->Slot];
|
||||
if (!table) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
return;
|
||||
}
|
||||
n = table->Count;
|
||||
|
@ -733,13 +702,8 @@ local void AiCheckingWork(void)
|
|||
UnitType *type;
|
||||
AiBuildQueue *queue;
|
||||
|
||||
DebugLevel3Fn("%d:%d %d %d\n" _C_ AiPlayer->Player->Player _C_
|
||||
AiPlayer->Player->Resources[1] _C_
|
||||
AiPlayer->Player->Resources[2] _C_ AiPlayer->Player->Resources[3]);
|
||||
|
||||
// Suppy has the highest priority
|
||||
if (AiPlayer->NeedSupply) {
|
||||
DebugLevel3Fn("player %d needs food.\n" _C_ AiPlayer->Player->Player);
|
||||
if (!(AiPlayer->UnitTypeBuilded && AiPlayer->UnitTypeBuilded->Type->Supply)) {
|
||||
AiPlayer->NeedSupply = 0;
|
||||
AiRequestSupply();
|
||||
|
@ -751,7 +715,6 @@ local void AiCheckingWork(void)
|
|||
for (queue = AiPlayer->UnitTypeBuilded; queue; queue = queue->Next) {
|
||||
if (queue->Want > queue->Made) {
|
||||
type = queue->Type;
|
||||
DebugLevel3Fn("Must build: %s\n" _C_ type->Ident);
|
||||
|
||||
//
|
||||
// FIXME: must check if requirements are fulfilled.
|
||||
|
@ -768,21 +731,18 @@ local void AiCheckingWork(void)
|
|||
// Check limits, AI should be broken if reached.
|
||||
//
|
||||
if (PlayerCheckLimits(AiPlayer->Player, type) < 0) {
|
||||
DebugLevel3Fn("Unit limits reached, or Need Supply\n");
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// Check if resources available.
|
||||
//
|
||||
if ((c = AiCheckUnitTypeCosts(type))) {
|
||||
DebugLevel3("- no resources\n");
|
||||
AiPlayer->NeededMask |= c;
|
||||
//
|
||||
// NOTE: we can continue and build things with lesser
|
||||
// resource or other resource need!
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel3("- enough resources\n");
|
||||
if (AiMakeUnit(type)) {
|
||||
++queue->Made;
|
||||
}
|
||||
|
@ -964,21 +924,7 @@ local void AiCollectResources(void)
|
|||
total = 0;
|
||||
for (c = 0; c < MaxCosts; ++c) {
|
||||
total += num_units_assigned[c] + num_units_with_resource[c];
|
||||
DebugLevel3Fn("Assigned %d = %d\n" _C_ c _C_ num_units_assigned[c]);
|
||||
DebugLevel3Fn("Resource %d = %d\n" _C_ c _C_ num_units_with_resource[c]);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
DebugLevel3Fn("Unassigned %d of total %d\n" _C_ num_units_unassigned[c] _C_ total);
|
||||
if (AiPlayer->Player == ThisPlayer) {
|
||||
DebugLevel3Fn("Percent Assignment:");
|
||||
for (c = 0; c < MaxCosts; ++c) {
|
||||
if (percent[c]) {
|
||||
DebugLevel3(" %s:%d%%" _C_ DefaultResourceNames[c] _C_ percent[c]);
|
||||
}
|
||||
}
|
||||
DebugLevel3("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Turn percent values into harvester numbers.
|
||||
|
@ -1140,8 +1086,6 @@ local int AiRepairBuilding(const UnitType* type, Unit* building)
|
|||
int k;
|
||||
int num;
|
||||
|
||||
DebugLevel3Fn("%s can repair %s\n" _C_ type->Ident _C_ building->Type->Ident);
|
||||
|
||||
#ifdef DEBUG
|
||||
unit = NoUnitP;
|
||||
#endif
|
||||
|
@ -1208,7 +1152,6 @@ local int AiRepairBuilding(const UnitType* type, Unit* building)
|
|||
for (k = i = j; i < num && i < j + 3; ++i) {
|
||||
|
||||
unit = table[i];
|
||||
DebugLevel2Fn("Have an unit to repair %d :)\n" _C_ UnitNumber(unit));
|
||||
|
||||
if (UnitReachable(unit, building, unit->Type->RepairRange)) {
|
||||
CommandRepair(unit, 0, 0, building, FlushCommands);
|
||||
|
@ -1240,12 +1183,12 @@ local int AiRepairUnit(Unit* unit)
|
|||
tablep = AiHelpers.Repair;
|
||||
type = unit->Type;
|
||||
if (type->Slot > n) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
return 0;
|
||||
}
|
||||
table = tablep[type->Slot];
|
||||
if (!table) { // Oops not known.
|
||||
DebugLevel0Fn("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
DebugPrint("Nothing known about `%s'\n" _C_ type->Ident);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1300,9 +1243,6 @@ local void AiCheckRepair(void)
|
|||
&& unit->HP < unit->Stats->HitPoints
|
||||
&& unit->Attacked + 5 * CYCLES_PER_SECOND < GameCycle) {
|
||||
|
||||
DebugLevel3Fn("Have building to repair %d(%s)\n" _C_
|
||||
UnitNumber(unit) _C_ unit->Type->Ident);
|
||||
|
||||
//
|
||||
// FIXME: Repair only buildings under control
|
||||
//
|
||||
|
@ -1344,8 +1284,6 @@ global void AiAddUnitTypeRequest(UnitType* type, int count)
|
|||
{
|
||||
AiBuildQueue** queue;
|
||||
|
||||
DebugLevel3Fn("%s %d\n" _C_ type->Ident _C_ count);
|
||||
|
||||
//
|
||||
// Find end of the list.
|
||||
//
|
||||
|
@ -1395,7 +1333,6 @@ global void AiResourceManager(void)
|
|||
// Look if we can build a farm in advance.
|
||||
//
|
||||
if (!AiPlayer->NeedSupply && AiPlayer->Player->Supply == AiPlayer->Player->Demand) {
|
||||
DebugLevel3Fn("Farm in advance request\n");
|
||||
AiRequestSupply();
|
||||
}
|
||||
//
|
||||
|
|
|
@ -193,7 +193,6 @@ local int CclDefineAiHelper(lua_State* l)
|
|||
if (!base) {
|
||||
LuaError(l, "unknown unittype: %s" _C_ value);
|
||||
}
|
||||
DebugLevel3Fn("%s\n" _C_ base->Name);
|
||||
|
||||
//
|
||||
// Get the unit types, which could be produced
|
||||
|
@ -207,20 +206,17 @@ local int CclDefineAiHelper(lua_State* l)
|
|||
if (!upgrade) {
|
||||
LuaError(l, "unknown upgrade: %s" _C_ value);
|
||||
}
|
||||
DebugLevel3Fn("> %s\n" _C_ upgrade->Ident);
|
||||
} else if (what == 4) {
|
||||
if (!strcmp("food", value)) {
|
||||
cost = 0;
|
||||
} else {
|
||||
LuaError(l, "unknown limit: %s" _C_ value);
|
||||
}
|
||||
DebugLevel3Fn("> %s\n" _C_ str);
|
||||
} else {
|
||||
type = UnitTypeByIdent(value);
|
||||
if (!type) {
|
||||
LuaError(l, "unknown unittype: %s" _C_ value);
|
||||
}
|
||||
DebugLevel3Fn("> %s\n" _C_ type->Name);
|
||||
}
|
||||
|
||||
switch (what) {
|
||||
|
@ -295,13 +291,11 @@ local int CclDefineAi(lua_State* l)
|
|||
// AI Name
|
||||
//
|
||||
aitype->Name = strdup(LuaToString(l, 1));
|
||||
DebugLevel3Fn("%s\n" _C_ aitype->Name);
|
||||
|
||||
#ifdef DEBUG
|
||||
for (ait = AiTypes->Next; ait; ait = ait->Next) {
|
||||
if (!strcmp(aitype->Name, ait->Name)) {
|
||||
DebugLevel0Fn("Warning two or more AI's with the same name '%s'\n" _C_ ait->
|
||||
Name);
|
||||
DebugPrint("Warning two or more AI's with the same name '%s'\n" _C_ ait->Name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -310,7 +304,6 @@ local int CclDefineAi(lua_State* l)
|
|||
// AI Race
|
||||
//
|
||||
value = LuaToString(l, 2);
|
||||
DebugLevel3Fn("%s\n" _C_ value);
|
||||
if (*value != '*') {
|
||||
aitype->Race = strdup(value);
|
||||
} else {
|
||||
|
@ -321,7 +314,6 @@ local int CclDefineAi(lua_State* l)
|
|||
// AI Class
|
||||
//
|
||||
aitype->Class = strdup(LuaToString(l, 3));
|
||||
DebugLevel3Fn("%s\n" _C_ aitype->Class);
|
||||
|
||||
//
|
||||
// AI Script
|
||||
|
@ -657,7 +649,6 @@ local int CclAiWait(lua_State* l)
|
|||
// Look if we have equivalent unit-types.
|
||||
//
|
||||
if (type->Slot < AiHelpers.EquivCount && AiHelpers.Equiv[type->Slot]) {
|
||||
DebugLevel3Fn("Equivalence for %s\n" _C_ type->Ident);
|
||||
for (j = 0; j < AiHelpers.Equiv[type->Slot]->Count; ++j) {
|
||||
if (unit_types_count[AiHelpers.Equiv[type->Slot]->Table[j]->Slot]) {
|
||||
lua_pushboolean(l, 0);
|
||||
|
@ -672,7 +663,7 @@ local int CclAiWait(lua_State* l)
|
|||
lua_pushboolean(l, 1);
|
||||
return 1;
|
||||
}
|
||||
DebugLevel0Fn("Broken? waiting on %s which wasn't requested.\n" _C_ type->Ident);
|
||||
DebugPrint("Broken? waiting on %s which wasn't requested.\n" _C_ type->Ident);
|
||||
lua_pushboolean(l, 0);
|
||||
return 1;
|
||||
}
|
||||
|
@ -686,7 +677,6 @@ local int CclAiWait(lua_State* l)
|
|||
}
|
||||
}
|
||||
// units available?
|
||||
DebugLevel3Fn("%d,%d\n" _C_ n _C_ autt->Count);
|
||||
|
||||
if (n >= autt->Count) {
|
||||
lua_pushboolean(l, 0);
|
||||
|
@ -844,7 +834,7 @@ local int CclAiWaitForce(lua_State* l)
|
|||
lua_pushboolean(l, 0);
|
||||
return 1;
|
||||
}
|
||||
DebugLevel3Fn("Wait force %d\n" _C_ force);
|
||||
|
||||
#if 0
|
||||
// Debuging
|
||||
AiCleanForces();
|
||||
|
@ -890,7 +880,7 @@ local int CclAiSleep(lua_State* l)
|
|||
if (lua_gettop(l) != 1) {
|
||||
LuaError(l, "incorrect argument");
|
||||
}
|
||||
DebugLevel3Fn("%lu %d\n" _C_ GameCycle _C_ AiPlayer->SleepCycles);
|
||||
|
||||
if (AiPlayer->SleepCycles) {
|
||||
if (AiPlayer->SleepCycles < GameCycle) {
|
||||
AiPlayer->SleepCycles = 0;
|
||||
|
@ -1176,7 +1166,7 @@ local int CclDefineAiPlayer(lua_State* l)
|
|||
++j;
|
||||
|
||||
Assert(i >= 0 && i <= PlayerMax);
|
||||
DebugLevel0Fn("%p %d\n" _C_ Players[i].Ai _C_ Players[i].AiEnabled );
|
||||
DebugPrint("%p %d\n" _C_ Players[i].Ai _C_ Players[i].AiEnabled );
|
||||
// FIXME: lose this:
|
||||
// Assert(!Players[i].Ai && Players[i].AiEnabled);
|
||||
|
||||
|
|
|
@ -1028,8 +1028,6 @@ global void EditorUpdateDisplay(void)
|
|||
*/
|
||||
local void EditorCallbackButtonUp(unsigned button)
|
||||
{
|
||||
DebugLevel3Fn("Pressed %8x %8x\n" _C_ MouseButtons _C_ dummy);
|
||||
|
||||
if (GameCursor == TheUI.Scroll.Cursor) {
|
||||
// Move map.
|
||||
GameCursor = TheUI.Point.Cursor; // Reset
|
||||
|
@ -1054,8 +1052,6 @@ local void EditorCallbackButtonUp(unsigned button)
|
|||
*/
|
||||
local void EditorCallbackButtonDown(unsigned button __attribute__ ((unused)))
|
||||
{
|
||||
DebugLevel3Fn("%x %x\n" _C_ button _C_ MouseButtons);
|
||||
|
||||
//
|
||||
// Click on menu button
|
||||
//
|
||||
|
@ -1287,7 +1283,6 @@ local void EditorCallbackButtonDown(unsigned button __attribute__ ((unused)))
|
|||
CursorStartX = CursorX;
|
||||
CursorStartY = CursorY;
|
||||
GameCursor = TheUI.Scroll.Cursor;
|
||||
DebugLevel3("Cursor middle down %d,%d\n" _C_ CursorX _C_ CursorY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1339,7 +1334,6 @@ local void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
|||
case 'r':
|
||||
case 'R': // CTRL+R Randomize map
|
||||
if (KeyModifiers & ModifierControl) {
|
||||
DebugLevel3Fn("Randomizing map...\n");
|
||||
EditorCreateRandomMap();
|
||||
}
|
||||
break;
|
||||
|
@ -1408,7 +1402,6 @@ local void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel3("Key %d\n" _C_ key);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
@ -1454,8 +1447,6 @@ local void EditorCallbackKeyUp(unsigned key, unsigned keychar)
|
|||
local void EditorCallbackKey3(unsigned dummy1 __attribute__((unused)),
|
||||
unsigned dummy2 __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("Repeated %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_
|
||||
dummy2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1474,8 +1465,6 @@ local void EditorCallbackMouse(int x, int y)
|
|||
enum _cursor_on_ OldCursorOn;
|
||||
char buf[256];
|
||||
|
||||
DebugLevel3Fn("Moved %d,%d\n" _C_ x _C_ y);
|
||||
|
||||
HandleCursorMove(&x, &y); // Reduce to screen
|
||||
|
||||
//
|
||||
|
@ -1792,7 +1781,7 @@ local void EditorCallbackMouse(int x, int y)
|
|||
Assert(vp);
|
||||
if (TheUI.MouseViewport != vp) { // viewport changed
|
||||
TheUI.MouseViewport = vp;
|
||||
DebugLevel0Fn("active viewport changed to %d.\n" _C_
|
||||
DebugPrint("active viewport changed to %d.\n" _C_
|
||||
TheUI.Viewports - vp);
|
||||
}
|
||||
CursorOn = CursorOnMap;
|
||||
|
@ -1828,7 +1817,6 @@ local void EditorCallbackMouse(int x, int y)
|
|||
*/
|
||||
local void EditorCallbackExit(void)
|
||||
{
|
||||
DebugLevel3Fn("Exit\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1936,7 +1924,7 @@ local void CreateEditor(void)
|
|||
}
|
||||
#endif
|
||||
} else if (Players[i].StartX | Players[i].StartY) {
|
||||
DebugLevel0Fn("Player nobody has a start position\n");
|
||||
DebugPrint("Player nobody has a start position\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,8 +108,6 @@ local unsigned QuadFromTile(int x, int y)
|
|||
base = TheMap.Tileset->Tiles[i].BaseTerrain;
|
||||
mix = TheMap.Tileset->Tiles[i].MixTerrain;
|
||||
|
||||
DebugLevel3Fn("Tile %d:%04x %d,%d\n" _C_ tile _C_ i _C_ quad _C_ mix);
|
||||
|
||||
if (!mix) { // a solid tile
|
||||
return base | (base << 8) | (base << 16) | (base << 24);
|
||||
}
|
||||
|
@ -168,8 +166,6 @@ local int FindTilePath(int base, int goal, int length, char* marks, int* tile)
|
|||
int j;
|
||||
int n;
|
||||
|
||||
DebugLevel3Fn("base %X goal %X\n" _C_ base _C_ goal);
|
||||
|
||||
//
|
||||
// Find any mixed tile
|
||||
//
|
||||
|
@ -242,8 +238,6 @@ local int TileFromQuad(unsigned fixed, unsigned quad)
|
|||
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||
char table[16] = { 0, 7, 3, 11, 1, 9, 5, 13, 0, 8, 4, 12, 2, 10, 6, 0 };
|
||||
|
||||
DebugLevel3Fn("%x %x\n" _C_ fixed _C_ quad);
|
||||
|
||||
//
|
||||
// Get tile type from fixed.
|
||||
//
|
||||
|
@ -339,8 +333,6 @@ local int TileFromQuad(unsigned fixed, unsigned quad)
|
|||
}
|
||||
}
|
||||
|
||||
DebugLevel3Fn("type1 %x type2 %x\n" _C_ type1 _C_ type2);
|
||||
|
||||
//
|
||||
// Need a mixed tile
|
||||
//
|
||||
|
@ -368,7 +360,6 @@ local int TileFromQuad(unsigned fixed, unsigned quad)
|
|||
if (i >= TheMap.Tileset->NumTiles) {
|
||||
char* marks;
|
||||
|
||||
DebugLevel3Fn("No good mix found\n");
|
||||
//
|
||||
// Find the best tile path.
|
||||
//
|
||||
|
@ -376,7 +367,7 @@ local int TileFromQuad(unsigned fixed, unsigned quad)
|
|||
memset(marks, 0, TheMap.Tileset->NumTerrainTypes);
|
||||
marks[type1] = type1;
|
||||
if (FindTilePath(type1, type2, 0, marks, &i) == INT_MAX) {
|
||||
DebugLevel0Fn("Huch, no mix found!!!!!!!!!!!\n");
|
||||
DebugPrint("Huch, no mix found!!!!!!!!!!!\n");
|
||||
goto find_solid;
|
||||
}
|
||||
if (type1 == TheMap.Tileset->Tiles[i].MixTerrain) {
|
||||
|
@ -403,9 +394,6 @@ local int TileFromQuad(unsigned fixed, unsigned quad)
|
|||
direction |= 1;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("%08x %x %x %d\n" _C_ quad _C_ type1 _C_ type2 _C_
|
||||
direction);
|
||||
|
||||
return base | (table[direction] << 4);
|
||||
}
|
||||
|
||||
|
@ -482,8 +470,6 @@ local void EditorTileChanged2(int x, int y, int d)
|
|||
MapField* mf;
|
||||
|
||||
quad = QuadFromTile(x, y);
|
||||
DebugLevel3Fn("%d,%d %08x %d\n" _C_ x _C_ y _C_ quad _C_
|
||||
TheMap.Fields[y * TheMap.Width + x].Tile);
|
||||
|
||||
//
|
||||
// Change the surrounding
|
||||
|
@ -520,9 +506,7 @@ local void EditorTileChanged2(int x, int y, int d)
|
|||
q2 = QuadFromTile(x, y - 1);
|
||||
u = (q2 & TH_QUAD_M) | ((quad >> 16) & BH_QUAD_M);
|
||||
if (u != q2) {
|
||||
DebugLevel3Fn("U+ %08x -> %08x\n" _C_ q2 _C_ u);
|
||||
tile = TileFromQuad(u & BH_QUAD_M, u);
|
||||
DebugLevel3Fn("= %08x\n" _C_ tile);
|
||||
EditorChangeTile(x, y - 1, tile, d&~DIR_DOWN);
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +517,6 @@ local void EditorTileChanged2(int x, int y, int d)
|
|||
q2 = QuadFromTile(x, y + 1);
|
||||
u = (q2 & BH_QUAD_M) | ((quad << 16) & TH_QUAD_M);
|
||||
if (u != q2) {
|
||||
DebugLevel3Fn("D+ %08x -> %08x\n" _C_ q2 _C_ u);
|
||||
tile = TileFromQuad(u & TH_QUAD_M, u);
|
||||
EditorChangeTile(x, y + 1, tile, d&~DIR_UP);
|
||||
}
|
||||
|
@ -545,7 +528,6 @@ local void EditorTileChanged2(int x, int y, int d)
|
|||
q2 = QuadFromTile(x - 1, y);
|
||||
u = (q2 & LH_QUAD_M) | ((quad >> 8) & RH_QUAD_M);
|
||||
if (u != q2) {
|
||||
DebugLevel3Fn("L+ %08x -> %08x\n" _C_ q2 _C_ u);
|
||||
tile = TileFromQuad(u & RH_QUAD_M, u);
|
||||
EditorChangeTile(x - 1, y, tile, d&~DIR_RIGHT);
|
||||
}
|
||||
|
@ -557,7 +539,6 @@ local void EditorTileChanged2(int x, int y, int d)
|
|||
q2 = QuadFromTile(x + 1, y);
|
||||
u = (q2 & RH_QUAD_M) | ((quad << 8) & LH_QUAD_M);
|
||||
if (u != q2) {
|
||||
DebugLevel3Fn("R+ %08x -> %08x\n" _C_ q2 _C_ u);
|
||||
tile = TileFromQuad(u & LH_QUAD_M, u);
|
||||
EditorChangeTile(x + 1, y, tile, d&~DIR_LEFT);
|
||||
}
|
||||
|
|
|
@ -411,7 +411,7 @@ local int CclDefineCampaign(lua_State* l)
|
|||
ParseShowPicture(l, chapter);
|
||||
lua_pop(l, 1);
|
||||
} else if (!strcmp(value, "play-movie")) {
|
||||
DebugLevel0Fn("FIXME: not supported\n");
|
||||
DebugPrint("FIXME: not supported\n");
|
||||
} else if (!strcmp(value, "play-level")) {
|
||||
chapter->Type = ChapterPlayLevel;
|
||||
lua_rawgeti(l, j + 1, k + 1);
|
||||
|
@ -623,7 +623,7 @@ global void CleanCampaign(void)
|
|||
int i;
|
||||
|
||||
// FIXME: Can't clean campaign needed for continue.
|
||||
DebugLevel0Fn("FIXME: Cleaning campaign not written\n");
|
||||
DebugPrint("FIXME: Cleaning campaign not written\n");
|
||||
|
||||
if (GameIntro.Title) {
|
||||
free(GameIntro.Title);
|
||||
|
|
|
@ -90,8 +90,6 @@ local int LcmPreventRecurse; /// prevent recursion through LoadGameMap
|
|||
local void LoadStratagusMap(const char* filename,
|
||||
WorldMap* map __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("%p \n" _C_ map);
|
||||
|
||||
if (LcmPreventRecurse) {
|
||||
fprintf(stderr,"recursive use of load Stratagus map!\n");
|
||||
ExitFatal(-1);
|
||||
|
@ -343,7 +341,7 @@ global void CreateGame(char* filename, WorldMap* map)
|
|||
InitSyncRand();
|
||||
|
||||
if (IsNetworkGame()) { // Prepare network play
|
||||
DebugLevel0Fn("Client setup: Calling InitNetwork2\n");
|
||||
DebugPrint("Client setup: Calling InitNetwork2\n");
|
||||
InitNetwork2();
|
||||
} else {
|
||||
if (LocalPlayerName && strcmp(LocalPlayerName, "Anonymous")) {
|
||||
|
|
|
@ -200,7 +200,6 @@ local void IntroCallbackMouse(int x, int y)
|
|||
*/
|
||||
local void IntroCallbackExit(void)
|
||||
{
|
||||
DebugLevel3Fn("Exit\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -253,7 +253,6 @@ local int CclIfUnit(lua_State* l)
|
|||
}
|
||||
} else {
|
||||
for (; plynr < pn; ++plynr) {
|
||||
DebugLevel3Fn("Player%d, %d == %s\n" _C_ plynr _C_ q _C_ unittype->Ident);
|
||||
if (compare(Players[plynr].UnitTypesCount[unittype->Slot], q)) {
|
||||
lua_pushboolean(l, 1);
|
||||
return 1;
|
||||
|
@ -397,7 +396,6 @@ local int CclIfNearUnit(lua_State* l)
|
|||
// Get all unit types 'near'.
|
||||
//
|
||||
n = FindUnitsByType(ut2, table);
|
||||
DebugLevel3Fn("%s: %d\n" _C_ ut2->Ident _C_ n);
|
||||
for (i = 0; i < n; ++i) {
|
||||
Unit* unit;
|
||||
Unit* around[UnitMax];
|
||||
|
@ -419,7 +417,6 @@ local int CclIfNearUnit(lua_State* l)
|
|||
unit->X + unit->Type->TileWidth + 2,
|
||||
unit->Y + unit->Type->TileHeight + 2, around);
|
||||
}
|
||||
DebugLevel3Fn("Units around %d: %d\n" _C_ UnitNumber(unit) _C_ an);
|
||||
//
|
||||
// Count the requested units
|
||||
//
|
||||
|
@ -495,7 +492,6 @@ local int CclIfRescuedNearUnit(lua_State* l)
|
|||
// Get all unit types 'near'.
|
||||
//
|
||||
n = FindUnitsByType(ut2, table);
|
||||
DebugLevel3Fn("%s: %d\n" _C_ ut2->Ident _C_ n);
|
||||
for (i = 0; i < n; ++i) {
|
||||
Unit* unit;
|
||||
Unit* around[UnitMax];
|
||||
|
@ -517,7 +513,6 @@ local int CclIfRescuedNearUnit(lua_State* l)
|
|||
unit->X + unit->Type->TileWidth + 2,
|
||||
unit->Y + unit->Type->TileHeight + 2, around);
|
||||
}
|
||||
DebugLevel3Fn("Units around %d: %d\n" _C_ UnitNumber(unit) _C_ an);
|
||||
//
|
||||
// Count the requested units
|
||||
//
|
||||
|
@ -605,7 +600,6 @@ local int CclIfOpponents(lua_State* l)
|
|||
++n;
|
||||
}
|
||||
}
|
||||
DebugLevel3Fn("Opponents of %d = %d\n" _C_ plynr _C_ n);
|
||||
if (compare(n, q)) {
|
||||
lua_pushboolean(l, 1);
|
||||
return 1;
|
||||
|
|
|
@ -112,8 +112,7 @@ typedef struct _missile_type_ MissileType;
|
|||
/**
|
||||
** This simulates vararg macros.
|
||||
** Example:
|
||||
** DebugLevel0("Test %d\n" _C_ 1);
|
||||
** DebugLevel0("Test %d %d\n" _C_ 1 _C_ 2);
|
||||
** DebugPrint("Test %d %d\n" _C_ 1 _C_ 2);
|
||||
*/
|
||||
#define _C_ , ///< Debug , to simulate vararg macros
|
||||
|
||||
|
@ -132,67 +131,17 @@ typedef struct _missile_type_ MissileType;
|
|||
abort(); }} while (0)
|
||||
|
||||
/**
|
||||
** Print debug information of level 0.
|
||||
** Print debug information with function name.
|
||||
*/
|
||||
#define DebugLevel0(args) \
|
||||
do { fprintf(stdout, args); } while (0)
|
||||
|
||||
/**
|
||||
** Print debug information of level 1.
|
||||
*/
|
||||
#define DebugLevel1(args)\
|
||||
do { fprintf(stdout, args); } while (0)
|
||||
|
||||
/**
|
||||
** Print debug information of level 2.
|
||||
*/
|
||||
#define DebugLevel2(args)\
|
||||
do { fprintf(stdout, args); } while (0)
|
||||
|
||||
/**
|
||||
** Print debug information of level 3. (normal = disable)
|
||||
*/
|
||||
#define DebugLevel3(args) \
|
||||
/* TURNED OFF: do { fprintf(stdout, args); } while (0) */
|
||||
|
||||
/**
|
||||
** Print debug information of level 0 with function name.
|
||||
*/
|
||||
#define DebugLevel0Fn(args) \
|
||||
#define DebugPrint(args) \
|
||||
do { PrintFunction(); fprintf(stdout, args); } while (0)
|
||||
|
||||
/**
|
||||
** Print debug information of level 1 with function name.
|
||||
*/
|
||||
#define DebugLevel1Fn(args) \
|
||||
do { PrintFunction(); fprintf(stdout, args); } while (0)
|
||||
|
||||
/**
|
||||
** Print debug information of level 2 with function name.
|
||||
*/
|
||||
#define DebugLevel2Fn(args) \
|
||||
do { PrintFunction(); fprintf(stdout, args); } while (0)
|
||||
|
||||
/**
|
||||
** Print debug information of level 3 with function name.
|
||||
*/
|
||||
#define DebugLevel3Fn(args) \
|
||||
/* TURNED OFF: do { fprintf(stdout, __FUNCTION__ ": " args); } while (0) */
|
||||
|
||||
#else // }{ DEBUG
|
||||
|
||||
#define Assert(cond) /* disabled */
|
||||
#define Assert(cond) /* disabled */
|
||||
#define DebugPrint(args) /* disabled */
|
||||
|
||||
#define DebugLevel0(args) /* disabled */
|
||||
#define DebugLevel1(args) /* disabled */
|
||||
#define DebugLevel2(args) /* disabled */
|
||||
#define DebugLevel3(args) /* disabled */
|
||||
#define DebugLevel0Fn(args) /* disabled */
|
||||
#define DebugLevel1Fn(args) /* disabled */
|
||||
#define DebugLevel2Fn(args) /* disabled */
|
||||
#define DebugLevel3Fn(args) /* disabled */
|
||||
|
||||
#endif // } !DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef REFS_DEBUG // {
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ global void MapMarkTileSight(const Player* player, int x, int y)
|
|||
}
|
||||
return;
|
||||
case 255: // Overflow
|
||||
DebugLevel0Fn("Visible overflow (Player): %d\n" _C_ player->Player);
|
||||
DebugPrint("Visible overflow (Player): %d\n" _C_ player->Player);
|
||||
break;
|
||||
default: // seen -> seen
|
||||
++v;
|
||||
|
@ -340,7 +340,7 @@ global void MapSight(const Player* player, int x, int y, int w, int h, int range
|
|||
|
||||
// Mark as seen
|
||||
if (!range) {
|
||||
DebugLevel0Fn("Zero sight range\n");
|
||||
DebugPrint("Zero sight range\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ global void UpdateFogOfWarChange(void)
|
|||
int y;
|
||||
int w;
|
||||
|
||||
DebugLevel0Fn("\n");
|
||||
DebugPrint("\n");
|
||||
//
|
||||
// Mark all explored fields as visible again.
|
||||
//
|
||||
|
|
|
@ -379,7 +379,7 @@ global void RegenerateForest(void)
|
|||
tmp->Value >= ForestRegeneration &&
|
||||
!(tmp->Flags & (MapFieldWall | MapFieldUnpassable |
|
||||
MapFieldLandUnit | MapFieldBuilding))) {
|
||||
DebugLevel0("Real place wood\n");
|
||||
DebugPrint("Real place wood\n");
|
||||
tmp->Tile = TheMap.Tileset->TopOneTree;
|
||||
tmp->Value = 0;
|
||||
tmp->Flags |= MapFieldForest | MapFieldUnpassable;
|
||||
|
|
|
@ -114,7 +114,7 @@ global void CreateMinimap(void)
|
|||
MinimapX = (TheUI.MinimapW - (TheMap.Width * MinimapScaleX) / MINIMAP_FAC) / 2;
|
||||
MinimapY = (TheUI.MinimapH - (TheMap.Height * MinimapScaleY) / MINIMAP_FAC) / 2;
|
||||
|
||||
DebugLevel0Fn("MinimapScale %d %d (%d %d), X off %d, Y off %d\n" _C_
|
||||
DebugPrint("MinimapScale %d %d (%d %d), X off %d, Y off %d\n" _C_
|
||||
MinimapScaleX / MINIMAP_FAC _C_ MinimapScaleY / MINIMAP_FAC _C_
|
||||
MinimapScaleX _C_ MinimapScaleY _C_
|
||||
MinimapX _C_ MinimapY);
|
||||
|
|
|
@ -648,9 +648,9 @@ local int CclDefineTileset(lua_State* l)
|
|||
}
|
||||
DefineTilesetParseSlot(l, tileset, j + 1);
|
||||
} else if (!strcmp(value, "animations")) {
|
||||
DebugLevel0Fn("Animations not supported.\n");
|
||||
DebugPrint("Animations not supported.\n");
|
||||
} else if (!strcmp(value, "objects")) {
|
||||
DebugLevel0Fn("Objects not supported.\n");
|
||||
DebugPrint("Objects not supported.\n");
|
||||
} else if (!strcmp(value, "item-mapping")) {
|
||||
if (!lua_istable(l, j + 1)) {
|
||||
LuaError(l, "incorrect argument");
|
||||
|
|
|
@ -137,8 +137,6 @@ global void LoadTileset(void)
|
|||
|
||||
TheMap.TileCount = n =
|
||||
tiles_per_row * (TheMap.TileGraphic->Height / TileSizeY);
|
||||
DebugLevel2Fn(" %d Tiles in file %s, %d per row\n" _C_ TheMap.
|
||||
TileCount _C_ TheMap.Tileset->ImageFile _C_ tiles_per_row);
|
||||
|
||||
if (n > MaxTilesInTileset) {
|
||||
fprintf(stderr,
|
||||
|
|
|
@ -816,7 +816,7 @@ local void DoNextReplay(void)
|
|||
NotifyPlayer(ThisPlayer, NotifyYellow, 0, 0, "No sync info for this replay !");
|
||||
} 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);
|
||||
DebugPrint("OUT OF SYNC %u != %u\n" _C_ SyncRandSeed _C_ ReplayStep->SyncRandSeed);
|
||||
Assert(0);
|
||||
// ReplayStep = 0;
|
||||
// NextLogCycle = ~0UL;
|
||||
|
@ -887,7 +887,7 @@ local void DoNextReplay(void)
|
|||
} else if (!strcmp(val, "crazy")) {
|
||||
state = DiplomacyCrazy;
|
||||
} else {
|
||||
DebugLevel0Fn("Invalid diplomacy command: %s" _C_ val);
|
||||
DebugPrint("Invalid diplomacy command: %s" _C_ val);
|
||||
state = -1;
|
||||
}
|
||||
SendCommandDiplomacy(posx, state, posy);
|
||||
|
@ -895,7 +895,7 @@ local void DoNextReplay(void)
|
|||
int state;
|
||||
state = atoi(val);
|
||||
if (state != 0 && state != 1) {
|
||||
DebugLevel0Fn("Invalid shared vision command: %s" _C_ val);
|
||||
DebugPrint("Invalid shared vision command: %s" _C_ val);
|
||||
state = 0;
|
||||
}
|
||||
SendCommandSharedVision(posx, state, posy);
|
||||
|
@ -908,7 +908,7 @@ local void DoNextReplay(void)
|
|||
} else if (!strcmp(action, "quit")) {
|
||||
CommandQuit(posx);
|
||||
} else {
|
||||
DebugLevel0Fn("Invalid action: %s" _C_ action);
|
||||
DebugPrint("Invalid action: %s" _C_ action);
|
||||
}
|
||||
|
||||
ReplayStep = ReplayStep->Next;
|
||||
|
@ -1490,15 +1490,13 @@ global void ParseCommand(unsigned char msgnr, UnitRef unum,
|
|||
int id;
|
||||
int status;
|
||||
|
||||
DebugLevel3Fn(" %d cycle %lu\n" _C_ msgnr _C_ GameCycle);
|
||||
|
||||
unit = UnitSlots[unum];
|
||||
Assert(unit);
|
||||
//
|
||||
// Check if unit is already killed?
|
||||
//
|
||||
if (unit->Destroyed) {
|
||||
DebugLevel0Fn(" destroyed unit skipping %d\n" _C_ UnitNumber(unit));
|
||||
DebugPrint(" destroyed unit skipping %d\n" _C_ UnitNumber(unit));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1681,8 +1679,6 @@ global void ParseExtendedCommand(unsigned char type, int status,
|
|||
unsigned char arg1, unsigned short arg2, unsigned short arg3,
|
||||
unsigned short arg4)
|
||||
{
|
||||
DebugLevel3Fn(" %d cycle %lu\n" _C_ type _C_ GameCycle);
|
||||
|
||||
// Note: destroyed units are handled by the action routines.
|
||||
|
||||
switch (type) {
|
||||
|
@ -1718,7 +1714,7 @@ global void ParseExtendedCommand(unsigned char type, int status,
|
|||
CommandSharedVision(arg2, arg3, arg4);
|
||||
break;
|
||||
default:
|
||||
DebugLevel0Fn("Unknown extended message %u/%s %u %u %u %u\n" _C_
|
||||
DebugPrint("Unknown extended message %u/%s %u %u %u %u\n" _C_
|
||||
type _C_ status ? "flush" : "-" _C_
|
||||
arg1 _C_ arg2 _C_ arg3 _C_ arg4);
|
||||
break;
|
||||
|
|
|
@ -251,7 +251,7 @@ global int NetSocketAddr(const Socket sock)
|
|||
wsError = WSAIoctl(sock, SIO_GET_INTERFACE_LIST, NULL, 0, &localAddr,
|
||||
sizeof(localAddr), &bytesReturned, NULL, NULL);
|
||||
if (wsError == SOCKET_ERROR) {
|
||||
DebugLevel0Fn("SIOCGIFCONF:WSAIoctl(SIO_GET_INTERFACE_LIST) - errno %d\n" _C_
|
||||
DebugPrint("SIOCGIFCONF:WSAIoctl(SIO_GET_INTERFACE_LIST) - errno %d\n" _C_
|
||||
WSAGetLastError());
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ global int NetSocketAddr(const Socket sock)
|
|||
ifc.ifc_len = sizeof(buf);
|
||||
ifc.ifc_buf = buf;
|
||||
if (ioctl(sock, SIOCGIFCONF, (char*)&ifc) < 0) {
|
||||
DebugLevel0Fn("SIOCGIFCONF - errno %d\n" _C_ errno);
|
||||
DebugPrint("SIOCGIFCONF - errno %d\n" _C_ errno);
|
||||
return 0;
|
||||
}
|
||||
// with some inspiration from routed..
|
||||
|
@ -309,7 +309,7 @@ global int NetSocketAddr(const Socket sock)
|
|||
ifr = (struct ifreq*)cp;
|
||||
ifreq = *ifr;
|
||||
if (ioctl(sock, SIOCGIFFLAGS, (char*)&ifreq) < 0) {
|
||||
DebugLevel0Fn("%s: SIOCGIFFLAGS - errno %d\n" _C_
|
||||
DebugPrint("%s: SIOCGIFFLAGS - errno %d\n" _C_
|
||||
ifr->ifr_name _C_ errno);
|
||||
continue;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ global int NetSocketAddr(const Socket sock)
|
|||
NetLocalAddrs[nif] = sap->sin_addr.s_addr;
|
||||
if (ifreq.ifr_flags & IFF_POINTOPOINT) {
|
||||
if (ioctl(sock, SIOCGIFDSTADDR, (char*)&ifreq) < 0) {
|
||||
DebugLevel0Fn("%s: SIOCGIFDSTADDR - errno %d\n" _C_
|
||||
DebugPrint("%s: SIOCGIFDSTADDR - errno %d\n" _C_
|
||||
ifr->ifr_name _C_ errno);
|
||||
// failed to obtain dst addr - ignore
|
||||
continue;
|
||||
|
@ -350,8 +350,6 @@ global int NetSocketAddr(const Socket sock)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
DebugLevel3Fn("FOUND INTERFACE %s: %d.%d.%d.%d\n" _C_
|
||||
ifr->ifr_name _C_ NIPQUAD(ntohl(NetLocalAddrs[nif])));
|
||||
++nif;
|
||||
if (nif == MAX_LOC_IP) {
|
||||
break;
|
||||
|
@ -383,7 +381,6 @@ global Socket NetOpenUDP(int port)
|
|||
|
||||
// open the socket
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
DebugLevel3Fn(" socket %d\n" _C_ sockfd);
|
||||
if (sockfd == INVALID_SOCKET) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -401,7 +398,6 @@ global Socket NetOpenUDP(int port)
|
|||
NetCloseUDP(sockfd);
|
||||
return -1;
|
||||
}
|
||||
DebugLevel3Fn(" bind ok\n");
|
||||
NetLastHost = sock_addr.sin_addr.s_addr;
|
||||
NetLastPort = sock_addr.sin_port;
|
||||
}
|
||||
|
@ -420,7 +416,6 @@ global Socket NetOpenTCP(int port)
|
|||
Socket sockfd;
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
DebugLevel3Fn(" socket %d\n" _C_ sockfd);
|
||||
if (sockfd == INVALID_SOCKET) {
|
||||
return (Socket)-1;
|
||||
}
|
||||
|
@ -442,7 +437,6 @@ global Socket NetOpenTCP(int port)
|
|||
NetCloseTCP(sockfd);
|
||||
return (Socket)-1;
|
||||
}
|
||||
DebugLevel3Fn(" bind ok\n");
|
||||
NetLastHost = sock_addr.sin_addr.s_addr;
|
||||
NetLastPort = sock_addr.sin_port;
|
||||
}
|
||||
|
@ -551,8 +545,6 @@ global int NetRecvUDP(Socket sockfd, void* buf, int len)
|
|||
|
||||
NetLastHost = sock_addr.sin_addr.s_addr;
|
||||
NetLastPort = sock_addr.sin_port;
|
||||
DebugLevel3Fn(" %d.%d.%d.%d:%d\n" _C_
|
||||
NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
|
||||
return l;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ local void NetworkSendRateLimitedClientMessage(InitMessage* msg, unsigned long m
|
|||
n = NetworkSendICMessage(NetworkServerIP, htons(NetworkServerPort),
|
||||
msg);
|
||||
if (!NetStateMsgCnt) {
|
||||
DebugLevel1Fn
|
||||
DebugPrint
|
||||
("Sending Init Message (%s:%d): %d:%d(%d) %d.%d.%d.%d:%d\n" _C_
|
||||
ncconstatenames[NetLocalState] _C_ NetStateMsgCnt _C_
|
||||
msg->Type _C_ msg->SubType _C_ n _C_
|
||||
|
@ -216,7 +216,7 @@ global int NetworkSetupServerAddress(const char* serveraddr)
|
|||
}
|
||||
NetworkServerIP = addr;
|
||||
|
||||
DebugLevel1Fn("SELECTED SERVER: %s (%d.%d.%d.%d)\n" _C_ serveraddr _C_
|
||||
DebugPrint("SELECTED SERVER: %s (%d.%d.%d.%d)\n" _C_ serveraddr _C_
|
||||
NIPQUAD(ntohl(addr)));
|
||||
|
||||
sprintf(NetServerText, "%d.%d.%d.%d", NIPQUAD(ntohl(addr)));
|
||||
|
@ -271,7 +271,6 @@ global void NetworkInitServerConnect(void)
|
|||
|
||||
NetConnectRunning = 1;
|
||||
|
||||
DebugLevel3Fn("Waiting for %d client(s)\n" _C_ NetPlayers - 1);
|
||||
// Cannot use NetPlayers here, as map change might modify the number!!
|
||||
for (i = 0; i < PlayerMax; ++i) {
|
||||
NetStates[i].State = ccs_unused;
|
||||
|
@ -303,7 +302,7 @@ global void NetworkExitServerConnect(void)
|
|||
if (Hosts[h].PlyNr) {
|
||||
for (i = 0; i < 5; ++i) {
|
||||
n = NetworkSendICMessage(Hosts[h].Host, Hosts[h].Port, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message ServerQuit: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message ServerQuit: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(Hosts[h].Host)) _C_ ntohs(Hosts[h].Port));
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +356,7 @@ global void NetworkServerStartGame(void)
|
|||
if (MenuMapInfo->PlayerType[i] == PlayerPerson) {
|
||||
rev[i] = h;
|
||||
num[h++] = i;
|
||||
DebugLevel0Fn("Slot %d is available for an interactive player (%d)\n" _C_
|
||||
DebugPrint("Slot %d is available for an interactive player (%d)\n" _C_
|
||||
i _C_ rev[i]);
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +365,7 @@ global void NetworkServerStartGame(void)
|
|||
for (i = 0; i < PlayerMax; ++i) {
|
||||
if (MenuMapInfo->PlayerType[i] == PlayerComputer) {
|
||||
rev[i] = n++;
|
||||
DebugLevel0Fn("Slot %d is available for an ai computer player (%d)\n" _C_
|
||||
DebugPrint("Slot %d is available for an ai computer player (%d)\n" _C_
|
||||
i _C_ rev[i]);
|
||||
}
|
||||
}
|
||||
|
@ -407,7 +406,7 @@ global void NetworkServerStartGame(void)
|
|||
if (Hosts[i].PlyNr == 0) {
|
||||
for (j = i + 1; j < PlayerMax - 1; ++j) {
|
||||
if (Hosts[j].PlyNr) {
|
||||
DebugLevel0Fn("Compact: Hosts %d -> Hosts %d\n" _C_ j _C_ i);
|
||||
DebugPrint("Compact: Hosts %d -> Hosts %d\n" _C_ j _C_ i);
|
||||
Hosts[i] = Hosts[j];
|
||||
Hosts[j].PlyNr = 0;
|
||||
Hosts[j].Host = Hosts[j].Port = 0;
|
||||
|
@ -461,7 +460,7 @@ global void NetworkServerStartGame(void)
|
|||
}
|
||||
org[i] = n;
|
||||
}
|
||||
DebugLevel0Fn("Assigning player %d to slot %d (%d)\n" _C_
|
||||
DebugPrint("Assigning player %d to slot %d (%d)\n" _C_
|
||||
i _C_ n _C_ org[i]);
|
||||
|
||||
num[chosen] = num[--j];
|
||||
|
@ -471,7 +470,7 @@ global void NetworkServerStartGame(void)
|
|||
// ARI: is this code path really executed? (initially h >= NetPlayers..)
|
||||
// Above Debugcheck will catch it..
|
||||
Hosts[i].PlyNr = num[0];
|
||||
DebugLevel0Fn("Hosts[%d].PlyNr = %i\n" _C_ i _C_ num[0]);
|
||||
DebugPrint("Hosts[%d].PlyNr = %i\n" _C_ i _C_ num[0]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +522,7 @@ global void NetworkServerStartGame(void)
|
|||
statemsg.MapUID = htonl(MenuMapInfo->MapUID);
|
||||
|
||||
msg = (InitMessage*)buf;
|
||||
DebugLevel1Fn("Ready, sending InitConfig to %d host(s)\n" _C_ HostsCount);
|
||||
DebugPrint("Ready, sending InitConfig to %d host(s)\n" _C_ HostsCount);
|
||||
//
|
||||
// Send all clients host:ports to all clients.
|
||||
//
|
||||
|
@ -540,7 +539,7 @@ breakout:
|
|||
port = message.u.Hosts[i].Port;
|
||||
message.u.Hosts[i].Host = message.u.Hosts[i].Port = 0;
|
||||
n = NetworkSendICMessage(host, port, &message);
|
||||
DebugLevel0Fn("Sending InitConfig Message Config (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitConfig Message Config (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(host)) _C_ ntohs(port));
|
||||
message.u.Hosts[i].Host = host;
|
||||
message.u.Hosts[i].Port = port;
|
||||
|
@ -548,7 +547,7 @@ breakout:
|
|||
host = message.u.Hosts[i].Host;
|
||||
port = message.u.Hosts[i].Port;
|
||||
n = NetworkSendICMessage(host, port, &statemsg);
|
||||
DebugLevel0Fn("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(host)) _C_ ntohs(port));
|
||||
}
|
||||
}
|
||||
|
@ -556,7 +555,7 @@ breakout:
|
|||
// Wait for acknowledge
|
||||
while (j && NetSocketReady(NetworkFildes, 1000)) {
|
||||
if ((n = NetRecvUDP(NetworkFildes, &buf, sizeof(buf))) < 0) {
|
||||
DebugLevel0Fn("*Receive ack failed: (%d) from %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("*Receive ack failed: (%d) from %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
continue;
|
||||
}
|
||||
|
@ -565,7 +564,7 @@ breakout:
|
|||
switch (msg->SubType) {
|
||||
|
||||
case ICMConfig:
|
||||
DebugLevel0Fn("Got ack for InitConfig: (%d) from %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Got ack for InitConfig: (%d) from %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
|
||||
for (i = 0; i < HostsCount; ++i) {
|
||||
|
@ -579,7 +578,7 @@ breakout:
|
|||
break;
|
||||
|
||||
case ICMGo:
|
||||
DebugLevel0Fn("Got ack for InitState: (%d) from %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Got ack for InitState: (%d) from %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
|
||||
for (i = 0; i < HostsCount; ++i) {
|
||||
|
@ -587,7 +586,7 @@ breakout:
|
|||
if (num[Hosts[i].PlyNr] == 2) {
|
||||
num[Hosts[i].PlyNr] = 0;
|
||||
--j;
|
||||
DebugLevel0Fn("Removing host %d from waiting list\n" _C_ j);
|
||||
DebugPrint("Removing host %d from waiting list\n" _C_ j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -595,16 +594,16 @@ breakout:
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Server: Config ACK: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("Server: Config ACK: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
DebugLevel0Fn("Unexpected Message Type %d while waiting for Config ACK\n" _C_ msg->Type);
|
||||
DebugPrint("Unexpected Message Type %d while waiting for Config ACK\n" _C_ msg->Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DebugLevel0Fn("DONE: All configs acked - Now starting..\n");
|
||||
DebugPrint("DONE: All configs acked - Now starting..\n");
|
||||
|
||||
// Give clients a quick-start kick..
|
||||
message.SubType = ICMGo;
|
||||
|
@ -615,7 +614,7 @@ breakout:
|
|||
host = message.u.Hosts[i].Host;
|
||||
port = message.u.Hosts[i].Port;
|
||||
n = NetworkSendICMessage(host, port, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message Go: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message Go: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(host)) _C_ ntohs(port));
|
||||
}
|
||||
}
|
||||
|
@ -663,7 +662,7 @@ changed:
|
|||
// Server is ignoring us - break out!
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_detaching: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_detaching: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
break;
|
||||
case ccs_connecting: // connect to server
|
||||
|
@ -677,7 +676,7 @@ changed:
|
|||
} else {
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_connecting: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_connecting: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
break;
|
||||
case ccs_connected:
|
||||
|
@ -688,7 +687,7 @@ changed:
|
|||
} else {
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_connected: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_connected: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
break;
|
||||
case ccs_synced:
|
||||
|
@ -711,7 +710,7 @@ changed:
|
|||
} else {
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_changed: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_changed: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
break;
|
||||
case ccs_async:
|
||||
|
@ -722,7 +721,7 @@ changed:
|
|||
} else {
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_async: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_async: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
break;
|
||||
case ccs_mapinfo:
|
||||
|
@ -734,7 +733,7 @@ changed:
|
|||
} else {
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_mapinfo: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_mapinfo: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
case ccs_badmap:
|
||||
if (NetStateMsgCnt < 20) { // 20 retries
|
||||
|
@ -749,7 +748,7 @@ changed:
|
|||
} else {
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_badmap: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_badmap: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
break;
|
||||
case ccs_goahead:
|
||||
|
@ -760,7 +759,7 @@ changed:
|
|||
} else {
|
||||
NetLocalState = ccs_unreachable;
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
DebugLevel0Fn("ccs_goahead: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
DebugPrint("ccs_goahead: Above message limit %d\n" _C_ NetStateMsgCnt);
|
||||
}
|
||||
case ccs_started:
|
||||
if (NetStateMsgCnt < 20) { // 20 retries
|
||||
|
@ -768,7 +767,6 @@ changed:
|
|||
message.SubType = ICMGo;
|
||||
NetworkSendRateLimitedClientMessage(&message, 250);
|
||||
} else {
|
||||
DebugLevel3Fn("ccs_started: Final state enough ICMGo sent - starting\n");
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
}
|
||||
break;
|
||||
|
@ -786,7 +784,7 @@ local void KickDeadClient(int c)
|
|||
{
|
||||
int n;
|
||||
|
||||
DebugLevel0Fn("kicking client %d\n" _C_ Hosts[c].PlyNr);
|
||||
DebugPrint("kicking client %d\n" _C_ Hosts[c].PlyNr);
|
||||
NetStates[c].State = ccs_unused;
|
||||
Hosts[c].Host = 0;
|
||||
Hosts[c].Port = 0;
|
||||
|
@ -831,7 +829,7 @@ global void NetworkProcessServerRequest(void)
|
|||
message.SubType = ICMAYT; // Probe for the client
|
||||
message.MapUID = 0L;
|
||||
n = NetworkSendICMessage(Hosts[i].Host, Hosts[i].Port, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message AreYouThere: (%d) to %d.%d.%d.%d:%d (%ld:%ld)\n" _C_
|
||||
DebugPrint("Sending InitReply Message AreYouThere: (%d) to %d.%d.%d.%d:%d (%ld:%ld)\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(Hosts[i].Host)) _C_ ntohs(Hosts[i].Port) _C_
|
||||
FrameCounter _C_ ServerSetupState.LastFrame[i]);
|
||||
}
|
||||
|
@ -849,7 +847,7 @@ global void NetworkProcessServerRequest(void)
|
|||
local void ClientParseDisconnected(
|
||||
const InitMessage* msg __attribute__((unused)))
|
||||
{
|
||||
DebugLevel0Fn("ccs_disconnected: Server sending GoodBye dups %d\n" _C_
|
||||
DebugPrint("ccs_disconnected: Server sending GoodBye dups %d\n" _C_
|
||||
msg->SubType);
|
||||
}
|
||||
#endif
|
||||
|
@ -864,13 +862,12 @@ local void ClientParseDetaching(const InitMessage* msg)
|
|||
switch(msg->SubType) {
|
||||
|
||||
case ICMGoodBye: // Server has let us go
|
||||
DebugLevel3Fn("ccs_detaching: Server GoodBye subtype %d received - byebye\n" _C_ msg->SubType);
|
||||
NetLocalState = ccs_disconnected;
|
||||
NetStateMsgCnt = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_detaching: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_detaching: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -943,7 +940,7 @@ local void ClientParseConnecting(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_connecting: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_connecting: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -981,11 +978,10 @@ local void ClientParseConnected(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
case ICMWelcome: // Server has accepted us (dup)
|
||||
DebugLevel3Fn("ccs_connected: DUP Welcome subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_connected: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_connected: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1000,7 +996,6 @@ local void ClientParseMapInfo(const InitMessage* msg)
|
|||
switch(msg->SubType) {
|
||||
|
||||
case ICMState: // Server has sent us first state info
|
||||
DebugLevel3Fn("ccs_mapinfo: Initial State subtype %d received - going sync\n" _C_ msg->SubType);
|
||||
ServerSetupState = msg->u.State;
|
||||
NetClientUpdateState();
|
||||
NetLocalState = ccs_synced;
|
||||
|
@ -1008,7 +1003,7 @@ local void ClientParseMapInfo(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_mapinfo: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_mapinfo: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1020,6 @@ local void ClientParseSynced(const InitMessage* msg)
|
|||
switch(msg->SubType) {
|
||||
|
||||
case ICMState: // Server has sent us new state info
|
||||
DebugLevel3Fn("ccs_synced: New State subtype %d received - resynching\n" _C_ msg->SubType);
|
||||
ServerSetupState = msg->u.State;
|
||||
NetClientUpdateState();
|
||||
NetLocalState = ccs_async;
|
||||
|
@ -1033,7 +1027,7 @@ local void ClientParseSynced(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
case ICMConfig: // Server gives the go ahead.. - start game
|
||||
DebugLevel0Fn("ccs_synced: Config subtype %d received - starting\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_synced: Config subtype %d received - starting\n" _C_ msg->SubType);
|
||||
HostsCount = 0;
|
||||
for (i = 0; i < msg->HostsCount - 1; ++i) {
|
||||
if (msg->u.Hosts[i].Host || msg->u.Hosts[i].Port) {
|
||||
|
@ -1042,12 +1036,12 @@ local void ClientParseSynced(const InitMessage* msg)
|
|||
Hosts[HostsCount].PlyNr = ntohs(msg->u.Hosts[i].PlyNr);
|
||||
memcpy(Hosts[HostsCount].PlyName, msg->u.Hosts[i].PlyName, 16);
|
||||
HostsCount++;
|
||||
DebugLevel0Fn("Client %d = %d.%d.%d.%d:%d [%s]\n" _C_
|
||||
DebugPrint("Client %d = %d.%d.%d.%d:%d [%s]\n" _C_
|
||||
ntohs(ntohs(msg->u.Hosts[i].PlyNr)) _C_ NIPQUAD(ntohl(msg->u.Hosts[i].Host)) _C_
|
||||
ntohs(msg->u.Hosts[i].Port) _C_ msg->u.Hosts[i].PlyName);
|
||||
} else { // Own client
|
||||
NetLocalPlayerNumber = ntohs(msg->u.Hosts[i].PlyNr);
|
||||
DebugLevel0Fn("SELF %d [%s]\n" _C_ ntohs(msg->u.Hosts[i].PlyNr) _C_
|
||||
DebugPrint("SELF %d [%s]\n" _C_ ntohs(msg->u.Hosts[i].PlyNr) _C_
|
||||
msg->u.Hosts[i].PlyName);
|
||||
}
|
||||
}
|
||||
|
@ -1058,7 +1052,7 @@ local void ClientParseSynced(const InitMessage* msg)
|
|||
memcpy(Hosts[HostsCount].PlyName, msg->u.Hosts[i].PlyName, 16);
|
||||
++HostsCount;
|
||||
NetPlayers = HostsCount + 1;
|
||||
DebugLevel0Fn("Server %d = %d.%d.%d.%d:%d [%s]\n" _C_
|
||||
DebugPrint("Server %d = %d.%d.%d.%d:%d [%s]\n" _C_
|
||||
ntohs(msg->u.Hosts[i].PlyNr) _C_ NIPQUAD(ntohl(NetLastHost)) _C_
|
||||
ntohs(NetLastPort) _C_ msg->u.Hosts[i].PlyName);
|
||||
|
||||
|
@ -1073,7 +1067,7 @@ local void ClientParseSynced(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_synced: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_synced: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1097,7 +1091,6 @@ local void ClientParseAsync(const InitMessage* msg)
|
|||
Hosts[i].PlyNr = ntohs(msg->u.Hosts[i].PlyNr);
|
||||
if (Hosts[i].PlyNr) {
|
||||
memcpy(Hosts[i].PlyName, msg->u.Hosts[i].PlyName, 16);
|
||||
DebugLevel3Fn("Other client %d: %s\n" _C_ Hosts[i].PlyNr _C_ Hosts[i].PlyName);
|
||||
}
|
||||
} else {
|
||||
Hosts[i].PlyNr = ntohs(msg->u.Hosts[i].PlyNr);
|
||||
|
@ -1110,7 +1103,7 @@ local void ClientParseAsync(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_async: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_async: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1125,18 +1118,17 @@ local void ClientParseGoAhead(const InitMessage* msg)
|
|||
switch(msg->SubType) {
|
||||
|
||||
case ICMConfig: // Server go ahead dup - ignore..
|
||||
DebugLevel3Fn("ccs_goahead: DUP Config subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
|
||||
case ICMState: // Server has sent final state info
|
||||
DebugLevel0Fn("ccs_goahead: Final State subtype %d received - starting\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_goahead: Final State subtype %d received - starting\n" _C_ msg->SubType);
|
||||
ServerSetupState = msg->u.State;
|
||||
NetLocalState = ccs_started;
|
||||
NetStateMsgCnt = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_goahead: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_goahead: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1155,7 +1147,7 @@ local void ClientParseStarted(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("ccs_started: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
DebugPrint("ccs_started: Unhandled subtype %d\n" _C_ msg->SubType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1220,7 +1212,7 @@ local void ServerParseHello(int h, const InitMessage* msg)
|
|||
Hosts[h].Port = NetLastPort;
|
||||
Hosts[h].PlyNr = h;
|
||||
memcpy(Hosts[h].PlyName, msg->u.Hosts[0].PlyName, 16);
|
||||
DebugLevel0Fn("New client %d.%d.%d.%d:%d [%s]\n" _C_
|
||||
DebugPrint("New client %d.%d.%d.%d:%d [%s]\n" _C_
|
||||
NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort) _C_ Hosts[h].PlyName);
|
||||
NetStates[h].State = ccs_connecting;
|
||||
NetStates[h].MsgCnt = 0;
|
||||
|
@ -1229,7 +1221,7 @@ local void ServerParseHello(int h, const InitMessage* msg)
|
|||
message.SubType = ICMGameFull; // Game is full - reject connnection
|
||||
message.MapUID = 0L;
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message GameFull: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message GameFull: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
return;
|
||||
}
|
||||
|
@ -1256,7 +1248,7 @@ local void ServerParseHello(int h, const InitMessage* msg)
|
|||
}
|
||||
}
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message Welcome: (%d) [PlyNr: %d] to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message Welcome: (%d) [PlyNr: %d] to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ h _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
NetStates[h].MsgCnt++;
|
||||
if (NetStates[h].MsgCnt > 48) {
|
||||
|
@ -1308,7 +1300,7 @@ local void ServerParseResync(const int h)
|
|||
}
|
||||
}
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message Resync: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message Resync: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
NetStates[h].MsgCnt++;
|
||||
if (NetStates[h].MsgCnt > 50) {
|
||||
|
@ -1318,7 +1310,7 @@ local void ServerParseResync(const int h)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Server: ICMResync: Unhandled state %d Host %d\n" _C_
|
||||
DebugPrint("Server: ICMResync: Unhandled state %d Host %d\n" _C_
|
||||
NetStates[h].State _C_ h);
|
||||
break;
|
||||
}
|
||||
|
@ -1353,7 +1345,7 @@ local void ServerParseWaiting(const int h)
|
|||
memcpy(message.u.MapPath, MenuMapFullPath + pathlen, 256);
|
||||
message.MapUID = htonl(MenuMapInfo->MapUID);
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message Map: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message Map: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
NetStates[h].MsgCnt++;
|
||||
if (NetStates[h].MsgCnt > 50) {
|
||||
|
@ -1387,7 +1379,7 @@ local void ServerParseWaiting(const int h)
|
|||
message.u.State = ServerSetupState;
|
||||
message.MapUID = htonl(MenuMapInfo->MapUID);
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
NetStates[h].MsgCnt++;
|
||||
if (NetStates[h].MsgCnt > 50) {
|
||||
|
@ -1397,7 +1389,7 @@ local void ServerParseWaiting(const int h)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Server: ICMWaiting: Unhandled state %d Host %d\n" _C_
|
||||
DebugPrint("Server: ICMWaiting: Unhandled state %d Host %d\n" _C_
|
||||
NetStates[h].State _C_ h);
|
||||
break;
|
||||
}
|
||||
|
@ -1428,7 +1420,7 @@ local void ServerParseMap(const int h)
|
|||
message.u.State = ServerSetupState;
|
||||
message.MapUID = htonl(MenuMapInfo->MapUID);
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
NetStates[h].MsgCnt++;
|
||||
if (NetStates[h].MsgCnt > 50) {
|
||||
|
@ -1437,7 +1429,7 @@ local void ServerParseMap(const int h)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
DebugLevel0Fn("Server: ICMMap: Unhandled state %d Host %d\n" _C_
|
||||
DebugPrint("Server: ICMMap: Unhandled state %d Host %d\n" _C_
|
||||
NetStates[h].State _C_ h);
|
||||
break;
|
||||
}
|
||||
|
@ -1467,8 +1459,6 @@ local void ServerParseState(const int h, const InitMessage* msg)
|
|||
// Use information supplied by the client:
|
||||
ServerSetupState.Ready[h] = msg->u.State.Ready[h];
|
||||
ServerSetupState.Race[h] = msg->u.State.Race[h];
|
||||
DebugLevel3Fn("Server: ICMState: Client[%d]: Ready: %d Race: %d\n" _C_
|
||||
h _C_ ServerSetupState.Ready[h] _C_ ServerSetupState.Race[h]);
|
||||
// Add additional info usage here!
|
||||
|
||||
// Resync other clients (and us..)
|
||||
|
@ -1487,7 +1477,7 @@ local void ServerParseState(const int h, const InitMessage* msg)
|
|||
message.u.State = ServerSetupState;
|
||||
message.MapUID = htonl(MenuMapInfo->MapUID);
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message State: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
NetStates[h].MsgCnt++;
|
||||
if (NetStates[h].MsgCnt > 50) {
|
||||
|
@ -1496,7 +1486,7 @@ local void ServerParseState(const int h, const InitMessage* msg)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
DebugLevel0Fn("Server: ICMState: Unhandled state %d Host %d\n" _C_
|
||||
DebugPrint("Server: ICMState: Unhandled state %d Host %d\n" _C_
|
||||
NetStates[h].State _C_ h);
|
||||
break;
|
||||
}
|
||||
|
@ -1525,7 +1515,7 @@ local void ServerParseGoodBye(const int h)
|
|||
message.Type = MessageInitReply;
|
||||
message.SubType = ICMGoodBye;
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message GoodBye: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message GoodBye: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
NetStates[h].MsgCnt++;
|
||||
if (NetStates[h].MsgCnt > 10) {
|
||||
|
@ -1549,7 +1539,7 @@ local void ServerParseSeeYou(const int h)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Server: ICMSeeYou: Unhandled state %d Host %d\n" _C_
|
||||
DebugPrint("Server: ICMSeeYou: Unhandled state %d Host %d\n" _C_
|
||||
NetStates[h].State _C_ h);
|
||||
break;
|
||||
}
|
||||
|
@ -1591,7 +1581,7 @@ local int CheckVersions(const InitMessage* msg)
|
|||
message.SubType = ICMEngineMismatch; // Stratagus engine version doesn't match
|
||||
message.MapUID = 0L;
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message EngineMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message EngineMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
return -1;
|
||||
}
|
||||
|
@ -1609,7 +1599,7 @@ local int CheckVersions(const InitMessage* msg)
|
|||
message.SubType = ICMProtocolMismatch; // Network protocol version doesn't match
|
||||
message.MapUID = 0L;
|
||||
n = NetworkSendICMessage(NetLastHost, NetLastPort, &message);
|
||||
DebugLevel0Fn("Sending InitReply Message ProtocolMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Sending InitReply Message ProtocolMismatch: (%d) to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
return -1;
|
||||
}
|
||||
|
@ -1624,7 +1614,7 @@ local int CheckVersions(const InitMessage* msg)
|
|||
*/
|
||||
local void NetworkParseMenuPacket(const InitMessage* msg)
|
||||
{
|
||||
DebugLevel0Fn("Received %s Init Message %d:%d from %d.%d.%d.%d:%d (%ld)\n" _C_
|
||||
DebugPrint("Received %s Init Message %d:%d from %d.%d.%d.%d:%d (%ld)\n" _C_
|
||||
icmsgsubtypenames[msg->SubType] _C_ msg->Type _C_ msg->SubType _C_ NIPQUAD(ntohl(NetLastHost)) _C_
|
||||
ntohs(NetLastPort) _C_ FrameCounter);
|
||||
|
||||
|
@ -1685,7 +1675,7 @@ local void NetworkParseMenuPacket(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Client: Unhandled state %d\n" _C_ NetLocalState);
|
||||
DebugPrint("Client: Unhandled state %d\n" _C_ NetLocalState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1735,7 +1725,7 @@ local void NetworkParseMenuPacket(const InitMessage* msg)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Server: Unhandled subtype %d from host %d\n" _C_ msg->SubType _C_ i);
|
||||
DebugPrint("Server: Unhandled subtype %d from host %d\n" _C_ msg->SubType _C_ i);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1767,7 +1757,6 @@ global int NetworkParseSetupEvent(const char* buf, int size)
|
|||
// has been started by the server, so do the same for the client.
|
||||
NetConnectRunning = 0; // End the menu..
|
||||
}
|
||||
DebugLevel3Fn("Wrong message\n");
|
||||
return 0;
|
||||
}
|
||||
if (InterfaceState == IfaceStateMenu) {
|
||||
|
|
|
@ -312,8 +312,6 @@ global void NetworkBroadcast(const void* buf, int len)
|
|||
int n;
|
||||
|
||||
n = NetSendUDP(NetworkFildes, Hosts[i].Host, Hosts[i].Port, buf, len);
|
||||
DebugLevel3Fn("Sending %d to %d.%d.%d.%d:%d\n" _C_
|
||||
n _C_ NIPQUAD(ntohl(Hosts[i].Host)) _C_ ntohs(Hosts[i].Port));
|
||||
}
|
||||
#ifdef PACKET_LOSS
|
||||
}
|
||||
|
@ -335,21 +333,16 @@ local void NetworkSendPacket(const NetworkCommandQueue* ncq)
|
|||
++NetworkSendPackets;
|
||||
#endif
|
||||
|
||||
DebugLevel3Fn("In cycle %lu sending: " _C_ GameCycle);
|
||||
|
||||
//
|
||||
// Build packet of Up to MaxNetworkCommands messages.
|
||||
//
|
||||
numcommands = 0;
|
||||
packet.Header.Cycle = ncq[0].Time & 0xFF;
|
||||
DebugLevel3("Time: %lu " _C_ ncq[0].Time);
|
||||
for (i = 0; i < MaxNetworkCommands && ncq[i].Type != MessageNone; ++i) {
|
||||
DebugLevel3("T:%d, Com: %d " _C_ ncq[i].Type _C_ i);
|
||||
packet.Header.Type[i] = ncq[i].Type;
|
||||
packet.Command[i] = ncq[i].Data;
|
||||
++numcommands;
|
||||
}
|
||||
DebugLevel3("\n");
|
||||
|
||||
for (; i < MaxNetworkCommands; ++i) {
|
||||
packet.Header.Type[i] = MessageNone;
|
||||
|
@ -379,10 +372,7 @@ global void InitNetwork1(void)
|
|||
int i;
|
||||
int port;
|
||||
|
||||
DebugLevel0Fn("\n");
|
||||
|
||||
DebugLevel3Fn("Packet %d\n" _C_ sizeof(NetworkCommand));
|
||||
DebugLevel3Fn("Packet %d\n" _C_ sizeof(NetworkChat));
|
||||
DebugPrint("\n");
|
||||
|
||||
NetworkFildes = -1;
|
||||
NetworkInSync = 1;
|
||||
|
@ -422,9 +412,9 @@ global void InitNetwork1(void)
|
|||
#else
|
||||
NetworkNumInterfaces = NetSocketAddr(NetworkFildes);
|
||||
if (NetworkNumInterfaces) {
|
||||
DebugLevel0Fn("Num IP: %d\n" _C_ NetworkNumInterfaces);
|
||||
DebugPrint("Num IP: %d\n" _C_ NetworkNumInterfaces);
|
||||
for (i = 0; i < NetworkNumInterfaces; ++i) {
|
||||
DebugLevel0Fn("IP: %d.%d.%d.%d\n" _C_ NIPQUAD(ntohl(NetLocalAddrs[i])));
|
||||
DebugPrint("IP: %d.%d.%d.%d\n" _C_ NIPQUAD(ntohl(NetLocalAddrs[i])));
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "NETWORK: Not connected to any external IPV4-network, aborting\n");
|
||||
|
@ -438,10 +428,10 @@ global void InitNetwork1(void)
|
|||
char buf[128];
|
||||
|
||||
gethostname(buf, sizeof(buf));
|
||||
DebugLevel0Fn("%s\n" _C_ buf);
|
||||
DebugPrint("%s\n" _C_ buf);
|
||||
MyHost = NetResolveHost(buf);
|
||||
MyPort = NetLastPort;
|
||||
DebugLevel0Fn("My host:port %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("My host:port %d.%d.%d.%d:%d\n" _C_
|
||||
NIPQUAD(ntohl(MyHost)) _C_ ntohs(MyPort));
|
||||
}
|
||||
#endif
|
||||
|
@ -459,10 +449,10 @@ global void ExitNetwork1(void)
|
|||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
DebugLevel0("Received: %d packets, %d early, %d late, %d dups, %d lost.\n" _C_
|
||||
DebugPrint("Received: %d packets, %d early, %d late, %d dups, %d lost.\n" _C_
|
||||
NetworkReceivedPackets _C_ NetworkReceivedEarly _C_ NetworkReceivedLate _C_
|
||||
NetworkReceivedDups _C_ NetworkReceivedLost);
|
||||
DebugLevel0("Send: %d packets, %d resend\n" _C_
|
||||
DebugPrint("Send: %d packets, %d resend\n" _C_
|
||||
NetworkSendPackets _C_ NetworkSendResend);
|
||||
#endif
|
||||
NetCloseUDP(NetworkFildes);
|
||||
|
@ -485,7 +475,7 @@ global void InitNetwork2(void)
|
|||
|
||||
NetworkConnectSetupGame();
|
||||
|
||||
DebugLevel0Fn("Lag %d, Updates %d, Hosts %d\n" _C_
|
||||
DebugPrint("Lag %d, Updates %d, Hosts %d\n" _C_
|
||||
NetworkLag _C_ NetworkUpdates _C_ HostsCount);
|
||||
|
||||
//
|
||||
|
@ -534,10 +524,6 @@ global void NetworkSendCommand(int command, const Unit* unit, int x, int y,
|
|||
NetworkCommandQueue* ncq;
|
||||
NetworkCommandQueue* check;
|
||||
|
||||
DebugLevel3Fn("%d,%d,(%d,%d),%d,%s,%s\n" _C_
|
||||
command _C_ unit->Slot _C_ x _C_ y _C_ dest ? dest->Slot : -1 _C_
|
||||
type ? type->Ident : "-" _C_ status ? "flush" : "append");
|
||||
|
||||
// Check for duplicate command in queue
|
||||
check = (NetworkCommandQueue*)CommandsIn->first->next;
|
||||
while (check) {
|
||||
|
@ -546,13 +532,10 @@ global void NetworkSendCommand(int command, const Unit* unit, int x, int y,
|
|||
check->Data.X == htons(x) &&
|
||||
check->Data.Y == htons(y)) {
|
||||
if (dest && check->Data.Dest == htons(dest->Slot)) {
|
||||
DebugLevel3Fn("Removed Repeat Command\n");
|
||||
return;
|
||||
} else if (type && check->Data.Dest == htons(type->Slot)) {
|
||||
DebugLevel3Fn("Removed Repeat Command\n");
|
||||
return;
|
||||
} else if (check->Data.Dest == 0xFFFF) {
|
||||
DebugLevel3Fn("Removed Repeat Command\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -641,7 +624,6 @@ global void NetworkSendSelection(Unit** units, int count)
|
|||
header->Add = 0;
|
||||
header->Remove = 0;
|
||||
unitcount = 0;
|
||||
DebugLevel3("Time: %lu " _C_ ncq[0].Time);
|
||||
for (i = 0; i <= (count / 4); ++i) {
|
||||
Assert(i <= MaxNetworkCommands);
|
||||
header->Type[i] = MessageSelection;
|
||||
|
@ -650,7 +632,6 @@ global void NetworkSendSelection(Unit** units, int count)
|
|||
selection->Unit[ref] = htons(UnitNumber(units[unitcount]));
|
||||
}
|
||||
}
|
||||
DebugLevel3("\n");
|
||||
|
||||
unitcount = i;
|
||||
|
||||
|
@ -665,8 +646,6 @@ global void NetworkSendSelection(Unit** units, int count)
|
|||
if (Players[Hosts[i].PlyNr].Team == ThisPlayer->Team) {
|
||||
ref = NetSendUDP(NetworkFildes, Hosts[i].Host, Hosts[i].Port,
|
||||
&packet, sizeof(NetworkPacketHeader) + sizeof(NetworkSelection) * unitcount);
|
||||
DebugLevel3Fn("Sending %d to %d.%d.%d.%d:%d\n" _C_
|
||||
ref _C_ NIPQUAD(ntohl(Hosts[i].Host)) _C_ ntohs(Hosts[i].Port));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -761,7 +740,7 @@ global void NetworkEvent(void)
|
|||
//
|
||||
// Server or client gone?
|
||||
//
|
||||
DebugLevel0("Server/Client gone?\n");
|
||||
DebugPrint("Server/Client gone?\n");
|
||||
// just hope for an automatic recover right now..
|
||||
NetworkInSync = 0;
|
||||
return;
|
||||
|
@ -790,7 +769,7 @@ global void NetworkEvent(void)
|
|||
}
|
||||
// Typecast to fix Broken GCC!! AH
|
||||
if (i != (int)(sizeof(NetworkPacketHeader) + sizeof(NetworkCommand) * commands)) {
|
||||
DebugLevel0Fn("Bad packet read:%d, expected:%d\n" _C_
|
||||
DebugPrint("Bad packet read:%d, expected:%d\n" _C_
|
||||
i _C_ (int)(sizeof(NetworkPacketHeader) + sizeof(NetworkCommand) * commands));
|
||||
return;
|
||||
}
|
||||
|
@ -802,7 +781,7 @@ global void NetworkEvent(void)
|
|||
}
|
||||
}
|
||||
if (i == HostsCount) {
|
||||
DebugLevel0Fn("Not a host in play: %d.%d.%d.%d:%d\n" _C_
|
||||
DebugPrint("Not a host in play: %d.%d.%d.%d:%d\n" _C_
|
||||
NIPQUAD(ntohl(NetLastHost)) _C_ ntohs(NetLastPort));
|
||||
return;
|
||||
}
|
||||
|
@ -836,14 +815,12 @@ global void NetworkEvent(void)
|
|||
// Destination cycle (time to execute).
|
||||
n = ((GameCycle + 128) & ~0xFF) | packet->Header.Cycle;
|
||||
if (n > GameCycle + 128) {
|
||||
DebugLevel3Fn("+128 needed!\n");
|
||||
n -= 0x100;
|
||||
}
|
||||
|
||||
// FIXME: not neccessary to send this packet multiple times!!!!
|
||||
// other side sends re-send until it gets an answer.
|
||||
|
||||
DebugLevel3Fn("Resend for %lu got\n" _C_ n);
|
||||
if (n != NetworkIn[n & 0xFF][ThisPlayer->Player][0].Time) {
|
||||
// Asking for a cycle we haven't gotten to yet, ignore for now
|
||||
return;
|
||||
|
@ -877,16 +854,9 @@ global void NetworkEvent(void)
|
|||
// Destination cycle (time to execute).
|
||||
n = ((GameCycle + 128) & ~0xFF) | packet->Header.Cycle;
|
||||
if (n > GameCycle + 128) {
|
||||
DebugLevel3Fn("+128 needed!\n");
|
||||
n -= 0x100;
|
||||
}
|
||||
|
||||
if (NetworkIn[packet->Header.Cycle][player][0].Time != n) {
|
||||
DebugLevel3Fn("Command %3d for %8d(%02X) got\n" _C_
|
||||
packet->Header.Type[i] _C_ n _C_
|
||||
packet->Header.Cycle);
|
||||
}
|
||||
|
||||
// Receive statistic
|
||||
if (n > NetworkStatus[player]) {
|
||||
NetworkStatus[player] = n;
|
||||
|
@ -947,14 +917,12 @@ global void NetworkEvent(void)
|
|||
if (!NetworkInSync) {
|
||||
NetworkInSync = 1;
|
||||
n = (GameCycle / NetworkUpdates) * NetworkUpdates + NetworkUpdates;
|
||||
DebugLevel3Fn("wait for %d - " _C_ n);
|
||||
for (player = 0; player < HostsCount; ++player) {
|
||||
if (NetworkIn[n & 0xFF][Hosts[player].PlyNr][0].Time != n) {
|
||||
NetworkInSync = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DebugLevel3("%lu in sync %d\n" _C_ GameCycle _C_ NetworkInSync);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1033,7 +1001,7 @@ local void ParseNetworkCommand(const NetworkCommandQueue* ncq)
|
|||
ntohs(ncq->Data.Unit) != NetworkSyncHashs[GameCycle & 0xFF]) {
|
||||
|
||||
SetMessage("Network out of sync");
|
||||
DebugLevel0Fn("\nNetwork out of sync %x!=%x! %d!=%d!\n\n" _C_
|
||||
DebugPrint("\nNetwork out of sync %x!=%x! %d!=%d!\n\n" _C_
|
||||
ply _C_ NetworkSyncSeeds[GameCycle & 0xFF] _C_
|
||||
ntohs(ncq->Data.Unit) _C_ NetworkSyncHashs[GameCycle & 0xFF]);
|
||||
}
|
||||
|
@ -1105,10 +1073,6 @@ local void NetworkResendCommands(void)
|
|||
packet.Header.Cycle =
|
||||
(GameCycle / NetworkUpdates) * NetworkUpdates + NetworkUpdates;
|
||||
|
||||
DebugLevel3Fn("In cycle %lu for cycle %lu(%x):" _C_ GameCycle _C_
|
||||
(GameCycle / NetworkUpdates) * NetworkUpdates + NetworkUpdates _C_
|
||||
packet.Header.Cycle);
|
||||
|
||||
// if (0 || !(rand() & 15))
|
||||
NetworkBroadcast(&packet, sizeof(NetworkPacketHeader) + sizeof(NetworkCommand));
|
||||
}
|
||||
|
@ -1136,19 +1100,16 @@ local void NetworkSendCommands(void)
|
|||
ncq[0].Data.Y = htons(SyncRandSeed&0xFFFF);
|
||||
ncq[0].Time = GameCycle + NetworkLag;
|
||||
numcommands = 1;
|
||||
DebugLevel3Fn("Empty Commands\n");
|
||||
} else {
|
||||
while( (!dl_empty(CommandsIn) || !dl_empty(MsgCommandsIn)) &&
|
||||
numcommands < MaxNetworkCommands) {
|
||||
DebugLevel3Fn("command in remove\n");
|
||||
if (!dl_empty(CommandsIn)) {
|
||||
incommand = (NetworkCommandQueue*)CommandsIn->last;
|
||||
DebugLevel3Fn("Send Command: %lu T:%d\n" _C_ incommand->Time _C_ incommand->Type);
|
||||
#ifdef DEBUG
|
||||
if (incommand->Type != MessageExtendedCommand) {
|
||||
// FIXME: we can send destoyed units over network :(
|
||||
if (UnitSlots[ntohs(ncq->Data.Unit)]->Destroyed) {
|
||||
DebugLevel0Fn("Sending destroyed unit %d over network!!!!!!\n" _C_
|
||||
DebugPrint("Sending destroyed unit %d over network!!!!!!\n" _C_
|
||||
ntohs(incommand->Data.Unit));
|
||||
}
|
||||
}
|
||||
|
@ -1168,7 +1129,6 @@ local void NetworkSendCommands(void)
|
|||
ncq[numcommands].Type = MessageNone;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("sending for %lu \n" _C_ ncq[0]->Time);
|
||||
NetworkSendPacket(ncq);
|
||||
|
||||
NetworkSyncSeeds[(GameCycle + NetworkLag) & 0xFF] = SyncRandSeed;
|
||||
|
@ -1198,12 +1158,8 @@ local void NetworkExecCommands(void)
|
|||
}
|
||||
if (ncq->Time) {
|
||||
#ifdef DEBUG
|
||||
if (ncq->Type != MessageSync) {
|
||||
DebugLevel3Fn("execute net C:%lu,P:%d,T:%d\n" _C_
|
||||
ncq->Time _C_ i _C_ ncq->Type);
|
||||
}
|
||||
if (ncq->Time != GameCycle) {
|
||||
DebugLevel1Fn("cycle %lu idx %lu time %lu\n" _C_
|
||||
DebugPrint("cycle %lu idx %lu time %lu\n" _C_
|
||||
GameCycle _C_ GameCycle & 0xFF _C_ ncq->Time);
|
||||
Assert(ncq->Time == GameCycle);
|
||||
}
|
||||
|
@ -1229,14 +1185,11 @@ local void NetworkSyncCommands(void)
|
|||
NetworkInSync = 1;
|
||||
n = GameCycle + NetworkUpdates;
|
||||
for (i = 0; i < HostsCount; ++i) {
|
||||
DebugLevel3Fn("sync %d\n" _C_ Hosts[i].PlyNr);
|
||||
ncq = NetworkIn[n & 0xFF][Hosts[i].PlyNr];
|
||||
DebugLevel3Fn("sync %d==%d\n" _C_ ncq[0].Time _C_ n);
|
||||
if (ncq[0].Time != n) {
|
||||
NetworkInSync = 0;
|
||||
NetworkDelay = FrameCounter + NetworkUpdates;
|
||||
// FIXME: should send a resend request.
|
||||
DebugLevel3Fn("%lu not in sync %d\n" _C_ GameCycle _C_ n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1252,8 +1205,6 @@ global void NetworkCommands(void)
|
|||
// Send messages to all clients (other players)
|
||||
//
|
||||
if (!(GameCycle % NetworkUpdates)) {
|
||||
DebugLevel3Fn("Update %lu\n" _C_ GameCycle);
|
||||
|
||||
NetworkSendCommands();
|
||||
NetworkExecCommands();
|
||||
NetworkSyncCommands();
|
||||
|
|
|
@ -535,10 +535,6 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
}
|
||||
#endif
|
||||
|
||||
DebugLevel3Fn("%d %d,%d->%d,%d\n" _C_
|
||||
UnitNumber(unit) _C_
|
||||
unit->X _C_ unit->Y _C_ x _C_ y);
|
||||
|
||||
if (abs(gx - unit->X) <= 1 && abs(gy - unit->Y) <= 1 && maxrange == 0) {
|
||||
// Simplest case, move to adj cell
|
||||
if (gx == unit->X && gy == unit->Y) {
|
||||
|
@ -602,7 +598,6 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
if( AStarMatrix[o].InGoal==1 ) {
|
||||
ex=x;
|
||||
ey=y;
|
||||
DebugLevel3Fn("a star goal reached\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -613,12 +608,11 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
//
|
||||
// Select a "good" point from the open set.
|
||||
// Nearest point to goal.
|
||||
DebugLevel0Fn("%d way too long\n" _C_ UnitNumber(unit));
|
||||
DebugPrint("%d way too long\n" _C_ UnitNumber(unit));
|
||||
AStarCleanUp(num_in_close);
|
||||
return PF_FAILED;
|
||||
}
|
||||
|
||||
DebugLevel3("Best point in Open Set: %d %d (%d)\n" _C_ x _C_ y _C_ OpenSetSize);
|
||||
//
|
||||
// Generate successors of this node.
|
||||
|
||||
|
@ -664,7 +658,6 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
AStarMatrix[eo].Direction=i;
|
||||
if( AStarAddNode(ex,ey,eo,AStarMatrix[eo].CostFromStart+AStarCosts(ex,ey,gx,gy)) == PF_FAILED ) {
|
||||
AStarCleanUp(num_in_close);
|
||||
DebugLevel3Fn("Tiles Visited: %d\n" _C_ (TheMap.Height*TheMap.Width)-counter);
|
||||
return PF_FAILED;
|
||||
}
|
||||
// we add the point to the close set
|
||||
|
@ -683,7 +676,6 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
AStarMatrix[eo].CostFromStart+
|
||||
AStarCosts(ex,ey,gx,gy)) == PF_FAILED ) {
|
||||
AStarCleanUp(num_in_close);
|
||||
DebugLevel3Fn("Tiles Visited: %d\n" _C_ (TheMap.Height*TheMap.Width)-counter);
|
||||
return PF_FAILED;
|
||||
}
|
||||
} else {
|
||||
|
@ -694,8 +686,6 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
}
|
||||
}
|
||||
if( OpenSetSize<=0 ) { // no new nodes generated
|
||||
DebugLevel3Fn("%d unreachable\n" _C_ UnitNumber(unit));
|
||||
DebugLevel3Fn("Tiles Visited: %d\n" _C_ (TheMap.Height*TheMap.Width)-counter);
|
||||
AStarCleanUp(num_in_close);
|
||||
return PF_UNREACHABLE;
|
||||
}
|
||||
|
@ -729,7 +719,6 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
while( (ex!=x || ey!=y) && path!=NULL ) {
|
||||
eo=ey*TheMap.Width+ex;
|
||||
i=AStarMatrix[eo].Direction;
|
||||
DebugLevel3("%d %d %d %d (%d,%d)\n" _C_ x _C_ y _C_ ex _C_ ey _C_ Heading2X[i] _C_ Heading2Y[i]);
|
||||
ex-=Heading2X[i];
|
||||
ey-=Heading2Y[i];
|
||||
--gx;
|
||||
|
@ -740,7 +729,6 @@ global int AStarFindPath(Unit* unit, int gx, int gy, int gw, int gh, int minrang
|
|||
|
||||
// let's clean up the matrix now
|
||||
AStarCleanUp(num_in_close);
|
||||
DebugLevel3Fn("Tiles Visited: %d\n" _C_ (TheMap.Height*TheMap.Width)-counter);
|
||||
return path_length;
|
||||
}
|
||||
|
||||
|
|
|
@ -387,8 +387,6 @@ global int PlaceReachable(Unit* src, int x, int y, int w, int h, int minrange __
|
|||
static unsigned long LastGameCycle;
|
||||
static unsigned mask;
|
||||
|
||||
DebugLevel3Fn("%p -> %d,%d\n" _C_ src _C_ x _C_ y);
|
||||
|
||||
//
|
||||
// Setup movement.
|
||||
//
|
||||
|
@ -426,19 +424,13 @@ global int UnitReachable(Unit* src, Unit* dst, int range)
|
|||
{
|
||||
int depth;
|
||||
|
||||
DebugLevel3Fn("%d(%d,%d,%s)->%d(%d,%d,%s)+%d "
|
||||
_C_ UnitNumber(src) _C_ src->X _C_ src->Y _C_ src->Type->Ident
|
||||
_C_ UnitNumber(dst) _C_ dst->X _C_ dst->Y _C_ dst->Type->Ident _C_ range);
|
||||
|
||||
//
|
||||
// Find a path to the goal.
|
||||
//
|
||||
depth=PlaceReachable(src, dst->X, dst->Y, dst->Type->TileWidth, dst->Type->TileHeight, 0, range);
|
||||
if (depth <= 0) {
|
||||
DebugLevel3("NO WAY\n");
|
||||
return 0;
|
||||
}
|
||||
DebugLevel3("OK\n");
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
|
|
@ -214,7 +214,6 @@ global RegionId NewRegion(int iswater)
|
|||
}
|
||||
++RegionCount;
|
||||
|
||||
DebugLevel3Fn("New region %d, iswater = %d\n" _C_ result _C_ iswater);
|
||||
Assert(!Regions[result].TileCount);
|
||||
|
||||
Regions[result].TileCount = 0;
|
||||
|
@ -570,8 +569,6 @@ global void RegionCheckConnex(RegionId reg)
|
|||
int tilesleft;
|
||||
RegionSegment* seg;
|
||||
|
||||
DebugLevel3Fn("Region %d checked for splitting\n" _C_ reg);
|
||||
|
||||
RegionTempStorageAllocate();
|
||||
|
||||
RegionTempStorageFillRegion(Regions + reg, 0);
|
||||
|
@ -600,7 +597,6 @@ global void RegionCheckConnex(RegionId reg)
|
|||
|
||||
if (nbarea > 1) {
|
||||
// RegionDebugAllConnexions();
|
||||
DebugLevel3Fn("Region %d must be splitted into %d...\n" _C_ reg _C_ nbarea);
|
||||
Regions[reg].Dirty += 10;
|
||||
RegionSplitUsingTemp(reg, nbarea, 1);
|
||||
ZoneNeedRefresh = 1;
|
||||
|
@ -668,7 +664,6 @@ local void MapSplitterTileOccuped(int x, int y) {
|
|||
return;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Region %d should be checked\n" _C_ reg);
|
||||
// Here we'll need to flood fill the region to be sure...
|
||||
Regions[reg].NeedConnectTest = 1;
|
||||
}
|
||||
|
@ -703,8 +698,6 @@ global void MapSplitterTilesCleared(int x0, int y0, int x1, int y1) {
|
|||
for (y = y0; y <= y1; ++y) {
|
||||
for (x = x0; x <= x1; ++x) {
|
||||
if (RegionMapping(x, y) != NoRegion) {
|
||||
DebugLevel3Fn("Clearing an already clear tile %d %d -- applying ugly hack\n" _C_ x _C_ y);
|
||||
|
||||
for (y = y0; y <= y1; ++y) {
|
||||
for (x = x0; x <= x1; ++x) {
|
||||
if (RegionMapping(x, y) == NoRegion) {
|
||||
|
@ -955,7 +948,6 @@ global void InitaliseMapping(void)
|
|||
}
|
||||
|
||||
CurrentIsWater = TileIsWater(x, y);
|
||||
DebugLevel3Fn("CurrentIsWater %d at %d %d\n" _C_ CurrentIsWater _C_ x _C_ y);
|
||||
FindHExtent(x, y, &x0, &x1, CurrentIsWater);
|
||||
|
||||
RegionFloodFill(x0, x1, y, NewRegion(CurrentIsWater), CurrentIsWater);
|
||||
|
@ -964,7 +956,6 @@ global void InitaliseMapping(void)
|
|||
}
|
||||
UpdateConnections();
|
||||
|
||||
DebugLevel3Fn( "Map FloodFill done\n");
|
||||
RegionDebugAllConnexions();
|
||||
RegionDebugWater();
|
||||
|
||||
|
@ -980,7 +971,6 @@ global void InitaliseMapping(void)
|
|||
if ((Regions[i].TileCount > 1024) ||
|
||||
(Regions[i].TileCount > 64 &&
|
||||
(x > y ? x : y) * (x > y ? x : y) > 3 * Regions[i].TileCount)) {
|
||||
DebugLevel3Fn( "Split %d\n" _C_ i);
|
||||
RegionSplit(i, 1);
|
||||
// RegionDebugAllConnexions();
|
||||
found = 1;
|
||||
|
@ -1150,7 +1140,6 @@ global void MapSplitterInit(void)
|
|||
RefreshZones();
|
||||
ZoneNeedRefresh = 0;
|
||||
|
||||
DebugLevel3Fn("Mapping initialised\n");
|
||||
RegionDebugAllConnexions();
|
||||
}
|
||||
|
||||
|
@ -1193,8 +1182,6 @@ global void MapSplitterEachCycle(void)
|
|||
for (i = 0; i < RegionMax; ++i) {
|
||||
if (Regions[i].Dirty && ShouldBreakRegion(Regions[i].MinX,Regions[i].MinY,
|
||||
Regions[i].MaxX,Regions[i].MaxY,Regions[i].TileCount,1)) {
|
||||
DebugLevel3Fn("Splitting region %d\n" _C_ i);
|
||||
|
||||
|
||||
RegionSplit(i, 1);
|
||||
|
||||
|
@ -1238,7 +1225,6 @@ global void MapSplitterEachCycle(void)
|
|||
|
||||
if (!ShouldBreakRegion(x0, y0, x1, y1,
|
||||
Regions[i].TileCount + Regions[j].TileCount, 1)) {
|
||||
DebugLevel3Fn("Joining regions %d - %d\n" _C_ i _C_ j);
|
||||
RegionJoin(i, j);
|
||||
// RegionDebugAllConnexions();
|
||||
if (!Regions[i].TileCount) {
|
||||
|
|
|
@ -201,8 +201,6 @@ global void MapSplitterDebug(void)
|
|||
}
|
||||
}
|
||||
|
||||
DebugLevel2Fn("Total assigned tiles : %d\n" _C_ total);
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < RegionMax; i++) {
|
||||
seg = Regions[i].FirstSegment;
|
||||
|
@ -219,8 +217,6 @@ global void MapSplitterDebug(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
DebugLevel2Fn("Total segment defined tiles : %d\n" _C_ total);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,12 +254,12 @@ local void RegionDebugConnexion(RegionId reg)
|
|||
int Connections[MaxRegionNumber];
|
||||
int ConnectionsCount[MaxRegionNumber];
|
||||
int ConnectionNb;
|
||||
RegionDefinition * adef;
|
||||
// RegionDefinition * adef;
|
||||
|
||||
int tx,ty;
|
||||
int x,y;
|
||||
int i,j;
|
||||
int found;
|
||||
// int found;
|
||||
|
||||
seg = Regions[reg].FirstSegment;
|
||||
ConnectionNb = 0;
|
||||
|
@ -301,23 +297,14 @@ local void RegionDebugConnexion(RegionId reg)
|
|||
|
||||
seg = seg->Next;
|
||||
}
|
||||
|
||||
/*
|
||||
adef = Regions + reg;
|
||||
// OK, compare to existing stats
|
||||
for (i = 0; i < ConnectionNb; i++) {
|
||||
found = 0;
|
||||
for (j = 0; j < adef->ConnectionsNumber; j++) {
|
||||
if (Connections[i] == adef->Connections[j]) {
|
||||
|
||||
if (found) {
|
||||
DebugLevel2Fn("Region %d : Connection number to %d is given twice\n" _C_ reg _C_ Connections[i]);
|
||||
}
|
||||
|
||||
found = 1;
|
||||
if (ConnectionsCount[i] != adef->ConnectionsCount[j]) {
|
||||
DebugLevel2Fn("Region %d : Connection number to %d is wrong ( %d instead of %d )\n"
|
||||
_C_ reg _C_ Connections[i] _C_ adef->ConnectionsCount[j] _C_ ConnectionsCount[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
|
@ -336,6 +323,7 @@ local void RegionDebugConnexion(RegionId reg)
|
|||
DebugLevel2Fn("Region %d : Connection to %d does not exists\n" _C_ reg _C_ Connections[i]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -398,7 +398,6 @@ global int ZoneSetFindPath(ZoneSet* src,ZoneSet* dst,int * path,int * pathlen)
|
|||
}
|
||||
curdst++;
|
||||
if (!shouldcontinue) {
|
||||
DebugLevel3Fn("No path between zones.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,8 +81,6 @@ local enum mad_flow MAD_read(void* user, struct mad_stream* stream)
|
|||
MadData *data;
|
||||
int i;
|
||||
|
||||
DebugLevel3Fn("Read callback\n");
|
||||
|
||||
sample = user;
|
||||
data = sample->User;
|
||||
|
||||
|
@ -96,8 +94,6 @@ local enum mad_flow MAD_read(void* user, struct mad_stream* stream)
|
|||
return MAD_FLOW_STOP;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("%d bytes\n" _C_ l + i);
|
||||
|
||||
data->BufferLen += i;
|
||||
mad_stream_buffer(stream, data->Buffer, data->BufferLen);
|
||||
|
||||
|
@ -126,8 +122,6 @@ local enum mad_flow MAD_write(void* user,
|
|||
int s;
|
||||
int comp;
|
||||
|
||||
DebugLevel3Fn("%d channels %d samples\n" _C_ channels _C_ n);
|
||||
|
||||
sample = user;
|
||||
|
||||
n = pcm->length;
|
||||
|
@ -205,12 +199,12 @@ local int MadRead(Sample *sample, unsigned char* buf, int len)
|
|||
|
||||
decoder = &((MadData*)sample->User)->MadDecoder;
|
||||
|
||||
DebugLevel0Fn("%p %p %d\n" _C_ decoder _C_ buf _C_ len);
|
||||
DebugPrint("%p %p %d\n" _C_ decoder _C_ buf _C_ len);
|
||||
|
||||
stream = &decoder->sync->stream;
|
||||
frame = &decoder->sync->frame;
|
||||
synth = &decoder->sync->synth;
|
||||
DebugLevel0Fn("Error: %d\n" _C_ stream->error);
|
||||
DebugPrint("Error: %d\n" _C_ stream->error);
|
||||
|
||||
MAD_read(sample, stream);
|
||||
|
||||
|
@ -225,7 +219,7 @@ local int MadRead(Sample *sample, unsigned char* buf, int len)
|
|||
return 0;
|
||||
|
||||
do {
|
||||
DebugLevel0Fn("Read stream\n");
|
||||
DebugPrint("Read stream\n");
|
||||
switch (MAD_read(decoder->cb_data, stream)) {
|
||||
case MAD_FLOW_STOP:
|
||||
return 0;
|
||||
|
@ -296,7 +290,7 @@ local int Mp3ReadStream(Sample* sample, void* buf, int len)
|
|||
int divide;
|
||||
char sndbuf[SOUND_BUFFER_SIZE];
|
||||
|
||||
DebugLevel0Fn("%p %d\n" _C_ buf _C_ len);
|
||||
DebugPrint("%p %d\n" _C_ buf _C_ len);
|
||||
|
||||
data = sample->User;
|
||||
|
||||
|
@ -435,8 +429,6 @@ global Sample* LoadMp3(const char* name, int flags)
|
|||
|
||||
CLseek(f, 0, SEEK_SET);
|
||||
|
||||
DebugLevel2Fn("Have mp3 file %s\n" _C_ name);
|
||||
|
||||
data = malloc(sizeof(MadData));
|
||||
data->MadFile = f;
|
||||
data->BufferLen = 0;
|
||||
|
@ -486,7 +478,7 @@ global Sample* LoadMp3(const char* name, int flags)
|
|||
|
||||
sample->Type = &Mp3SampleType;
|
||||
|
||||
DebugLevel0Fn(" %d\n" _C_ sample->Len);
|
||||
DebugPrint(" %d\n" _C_ sample->Len);
|
||||
}
|
||||
|
||||
return sample;
|
||||
|
|
|
@ -227,7 +227,7 @@ global int PlayMusic(const char* name)
|
|||
if ((sample = LoadOgg(name, PlayAudioStream))) {
|
||||
if ((sample->Channels != 1 && sample->Channels != 2) ||
|
||||
sample->SampleSize != 16) {
|
||||
DebugLevel0Fn("Not supported music format\n");
|
||||
DebugPrint("Not supported music format\n");
|
||||
SoundFree(sample);
|
||||
return 0;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ global int PlayMusic(const char* name)
|
|||
if ((sample = LoadMp3(name, PlayAudioStream))) {
|
||||
// if (sample->Channels != 2 || sample->SampleSize != 16
|
||||
// || sample->Frequency != SoundFrequency) {
|
||||
// DebugLevel0Fn("Not supported music format\n");
|
||||
// DebugPrint("Not supported music format\n");
|
||||
// SoundFree(sample);
|
||||
// return;
|
||||
// }
|
||||
|
@ -256,7 +256,7 @@ global int PlayMusic(const char* name)
|
|||
/*
|
||||
if (sample->Channels != 2 || sample->SampleSize != 16
|
||||
|| sample->Frequency != SoundFrequency) {
|
||||
DebugLevel0Fn("Not supported music format\n");
|
||||
DebugPrint("Not supported music format\n");
|
||||
SoundFree(sample);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -278,8 +278,6 @@ global Sample* LoadOgg(const char* name,int flags)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
DebugLevel2Fn("Loading ogg file: %s\n" _C_ name);
|
||||
|
||||
data = malloc(sizeof(OggData));
|
||||
|
||||
CLseek(f, 0, SEEK_SET);
|
||||
|
@ -373,12 +371,8 @@ local size_t AVI_OGG_read(void* ptr, size_t size, size_t nmemb, void* user)
|
|||
size_t length;
|
||||
unsigned char* frame;
|
||||
|
||||
DebugLevel3Fn("%p: %p %d*%d\n" _C_ user _C_ ptr _C_ size _C_ nmemb);
|
||||
|
||||
avi = user;
|
||||
if (avi->AudioRemain) { // Bytes remaining
|
||||
DebugLevel3Fn("Remain %d %d\n" _C_ avi->AudioRemain _C_
|
||||
avi->AudioBuffer->Length - avi->AudioRemain);
|
||||
length = avi->AudioRemain;
|
||||
if (length > nmemb * size) {
|
||||
length = nmemb * size;
|
||||
|
@ -391,7 +385,6 @@ local size_t AVI_OGG_read(void* ptr, size_t size, size_t nmemb, void* user)
|
|||
}
|
||||
|
||||
length = AviReadNextAudioFrame(avi, &frame);
|
||||
DebugLevel3Fn("Bytes %d - %d\n" _C_ length _C_ avi->AudioBuffer->Length);
|
||||
if ((int)length < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -131,18 +131,14 @@ local int CclMakeSound(lua_State* l)
|
|||
// only one file
|
||||
c_file = LuaToString(l, 2);
|
||||
id = MakeSound(c_name, &c_file, 1);
|
||||
DebugLevel3("Making sound `%s' from `%s' with id %p\n" _C_ c_name _C_
|
||||
c_file _C_ id);
|
||||
} else if (lua_istable(l, 2)) {
|
||||
// several files
|
||||
DebugLevel3("Making sound `%s'\n" _C_ c_name);
|
||||
args = luaL_getn(l, 2);
|
||||
c_files = malloc(args * sizeof(char*));
|
||||
for (j = 0; j < args; ++j) {
|
||||
lua_rawgeti(l, 2, j + 1);
|
||||
c_files[j] = strdup(LuaToString(l, -1));
|
||||
lua_pop(l, 1);
|
||||
DebugLevel3("\tComponent %d: `%s'\n" _C_ i _C_ c_files[j]);
|
||||
}
|
||||
// FIXME: check size before casting
|
||||
id = MakeSound(c_name, (const char**)c_files, (unsigned char)args);
|
||||
|
@ -663,7 +659,6 @@ local int CclSetSoundRange(lua_State* l) {
|
|||
} else {
|
||||
theRange = (unsigned char)tmp;
|
||||
}
|
||||
DebugLevel3("Range: %u (%d)\n" _C_ TheRange _C_ tmp);
|
||||
lua_pushvalue(l, 1);
|
||||
id = CclGetSoundId(l);
|
||||
SetSoundRange(id, theRange);
|
||||
|
|
|
@ -69,7 +69,7 @@ global int InitSdlSound(const char* dev __attribute__((unused)), int freq,
|
|||
} else if (size == 16) {
|
||||
wanted.format = AUDIO_S16SYS;
|
||||
} else {
|
||||
DebugLevel0Fn("Unexpected sample size %d\n" _C_ size);
|
||||
DebugPrint("Unexpected sample size %d\n" _C_ size);
|
||||
wanted.format = AUDIO_S16SYS;
|
||||
}
|
||||
wanted.channels = 2;
|
||||
|
|
|
@ -112,7 +112,7 @@ local void InsertSoundRequest(const Unit* unit, unsigned id,
|
|||
//FIXME: valid only in a shared memory context...
|
||||
if (!SoundOff && sound != NO_SOUND) {
|
||||
if (SoundRequests[NextSoundRequestIn].Used) {
|
||||
DebugLevel0("***** NO FREE SLOT IN SOUND FIFO *****\n");
|
||||
DebugPrint("***** NO FREE SLOT IN SOUND FIFO *****\n");
|
||||
} else {
|
||||
SoundRequests[NextSoundRequestIn].Used = 1;
|
||||
SoundRequests[NextSoundRequestIn].Source.Base = unit;
|
||||
|
@ -123,9 +123,6 @@ local void InsertSoundRequest(const Unit* unit, unsigned id,
|
|||
SoundRequests[NextSoundRequestIn].Selection = selection ? 1 : 0;
|
||||
SoundRequests[NextSoundRequestIn].IsVolume = volume ? 1 : 0;
|
||||
SoundRequests[NextSoundRequestIn].Stereo = stereo;
|
||||
DebugLevel3("Source[%p,%s]: registering request %p at slot %d=%d\n" _C_
|
||||
unit _C_ unit ? unit->Type->Ident : "" _C_
|
||||
sound _C_ NextSoundRequestIn _C_ power);
|
||||
|
||||
++NextSoundRequestIn;
|
||||
if (NextSoundRequestIn >= MAX_SOUND_REQUESTS) {
|
||||
|
@ -230,7 +227,6 @@ global void PlayMissileSound(const Missile* missile, SoundId sound)
|
|||
*/
|
||||
global void PlayGameSound(SoundId sound, unsigned char volume)
|
||||
{
|
||||
DebugLevel3("Playing %p at volume %u\n" _C_ sound _C_ volume);
|
||||
InsertSoundRequest(NULL, 0, volume, sound, 0, 0, 1, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ global SoundId SoundIdForName(const char* name)
|
|||
if ((result = (const SoundId*)hash_find(SoundIdHash, (char*)name))) {
|
||||
return *result;
|
||||
}
|
||||
DebugLevel0("Can't find sound `%s' in sound table\n" _C_ name);
|
||||
DebugPrint("Can't find sound `%s' in sound table\n" _C_ name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ global SoundId MakeSound(const char* name, const char* file[], int nb)
|
|||
Assert(nb <= 255);
|
||||
|
||||
if ((result = (const SoundId*)hash_find(SoundIdHash, (char*)name))) {
|
||||
DebugLevel0Fn("re-register sound `%s'\n" _C_ name);
|
||||
DebugPrint("re-register sound `%s'\n" _C_ name);
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ global SoundId MakeSoundGroup(const char* name, SoundId first, SoundId second)
|
|||
const SoundId* result;
|
||||
|
||||
if ((result = (const SoundId*)hash_find(SoundIdHash, (char*)name))) {
|
||||
DebugLevel0Fn("re-register sound `%s'\n" _C_ name);
|
||||
DebugPrint("re-register sound `%s'\n" _C_ name);
|
||||
return *result;
|
||||
}
|
||||
|
||||
|
|
|
@ -215,8 +215,6 @@ local int MixSampleToStereo32(Sample* sample,int index,unsigned char volume,
|
|||
right = 128;
|
||||
}
|
||||
|
||||
DebugLevel3("Length %d\n" _C_ length);
|
||||
|
||||
Assert(!(index & 1));
|
||||
|
||||
if (size >= sample->Len / 2 - index) {
|
||||
|
@ -353,9 +351,6 @@ local void RegisterSource(SoundRequest* sr, int channel)
|
|||
|
||||
i = channel;
|
||||
p = sr;
|
||||
DebugLevel3Fn("FIXME: must write %p -> %d\n" _C_ sr _C_ channel);
|
||||
|
||||
DebugLevel3("Registering %p (channel %d)\n" _C_ sr->Source.Base _C_ channel);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -365,10 +360,6 @@ local void UnRegisterSource(int channel) {
|
|||
int i;
|
||||
|
||||
i = channel;
|
||||
DebugLevel3Fn("FIXME: must write %d\n" _C_ channel);
|
||||
|
||||
DebugLevel3("Removing %p (channel %d)\n" _C_
|
||||
Channels[channel].Source.Base _C_ channel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,7 +383,6 @@ local unsigned char VolumeForDistance(unsigned short d, unsigned char range) {
|
|||
d -= ViewPointOffset;
|
||||
d_tmp = d * MAX_SOUND_RANGE;
|
||||
range_tmp = DistanceSilent * range;
|
||||
DebugLevel3("Distance: %d, Range: %d\n" _C_ d_tmp _C_ range_tmp);
|
||||
if (d_tmp > range_tmp) {
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -452,17 +442,14 @@ local Sample* ChooseSample(SoundRequest* sr)
|
|||
if (SelectionHandler.Source.Base == sr->Source.Base
|
||||
&& SelectionHandler.Source.Id == sr->Source.Id) {
|
||||
if (SelectionHandler.Sound == theSound->Sound.TwoGroups->First) {
|
||||
DebugLevel3("First group\n");
|
||||
result = SimpleChooseSample(SelectionHandler.Sound);
|
||||
SelectionHandler.HowMany++;
|
||||
if (SelectionHandler.HowMany >= 3) {
|
||||
SelectionHandler.HowMany = 0;
|
||||
SelectionHandler.Sound = (ServerSoundId)theSound->Sound.TwoGroups->Second;
|
||||
DebugLevel3("Switching to second group\n");
|
||||
}
|
||||
} else {
|
||||
//FIXME: checks for error
|
||||
DebugLevel3("Second group\n");
|
||||
// check wether the second group is really a group
|
||||
if (SelectionHandler.Sound->Number > 1) {
|
||||
result = SelectionHandler.Sound->Sound.OneGroup[SelectionHandler.HowMany];
|
||||
|
@ -470,13 +457,11 @@ local Sample* ChooseSample(SoundRequest* sr)
|
|||
if(SelectionHandler.HowMany >= SelectionHandler.Sound->Number) {
|
||||
SelectionHandler.HowMany = 0;
|
||||
SelectionHandler.Sound = (ServerSoundId)theSound->Sound.TwoGroups->First;
|
||||
DebugLevel3("Switching to first group\n");
|
||||
}
|
||||
} else {
|
||||
result = SelectionHandler.Sound->Sound.OneSound;
|
||||
SelectionHandler.HowMany = 0;
|
||||
SelectionHandler.Sound = (ServerSoundId)theSound->Sound.TwoGroups->First;
|
||||
DebugLevel3("Switching to first group\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -532,7 +517,7 @@ local int FillOneChannel(SoundRequest* sr)
|
|||
NextFreeChannel = next_free;
|
||||
} else {
|
||||
// should not happen
|
||||
DebugLevel0("***** NO FREE CHANNEL *****\n");
|
||||
DebugPrint("***** NO FREE CHANNEL *****\n");
|
||||
}
|
||||
return old_free;
|
||||
}
|
||||
|
@ -552,22 +537,17 @@ local void FillChannels(int free_channels,int* discarded,int* started)
|
|||
*started = 0;
|
||||
while (free_channels && sr->Used) {
|
||||
if (KeepRequest(sr)) {
|
||||
DebugLevel3("Source [%p]: start playing request %p at slot %d\n" _C_
|
||||
sr->Source.Base _C_ sr->Sound _C_ NextSoundRequestOut);
|
||||
channel = FillOneChannel(sr);
|
||||
if (sr->Source.Base) {
|
||||
//Register only sound with a valid origin
|
||||
RegisterSource(sr, channel);
|
||||
}
|
||||
--free_channels;
|
||||
DebugLevel3("Free channels: %d\n" _C_ free_channels);
|
||||
sr->Used = 0;
|
||||
++NextSoundRequestOut;
|
||||
(*started)++;
|
||||
} else {
|
||||
// Discarding request (for whatever reason)
|
||||
DebugLevel3("Discarding resquest %p from %p at slot %d\n" _C_
|
||||
sr->Sound _C_ sr->Source.Base _C_ NextSoundRequestOut);
|
||||
sr->Used = 0;
|
||||
++NextSoundRequestOut;
|
||||
(*discarded)++;
|
||||
|
@ -606,8 +586,6 @@ local int MixChannelsToStereo32(int* buffer,int size)
|
|||
if (Channels[channel].Point >= Channels[channel].Sample->Len / 2) {
|
||||
// free channel as soon as possible (before playing)
|
||||
// useful in multithreading
|
||||
DebugLevel3("End playing request from %p\n" _C_
|
||||
Channels[channel].Source.Base);
|
||||
FreeOneChannel(channel);
|
||||
++new_free_channels;
|
||||
}
|
||||
|
@ -752,7 +730,6 @@ global SoundId RegisterSound(const char* files[], unsigned number)
|
|||
if (number > 1) { // load a sound group
|
||||
id->Sound.OneGroup = malloc(sizeof(Sample*) * number);
|
||||
for (i = 0; i < number; ++i) {
|
||||
DebugLevel3("Registering `%s'\n" _C_ files[i]);
|
||||
id->Sound.OneGroup[i] = LoadSample(files[i]);
|
||||
if (!id->Sound.OneGroup[i]) {
|
||||
free(id->Sound.OneGroup);
|
||||
|
@ -762,7 +739,6 @@ global SoundId RegisterSound(const char* files[], unsigned number)
|
|||
}
|
||||
id->Number = number;
|
||||
} else { // load an unique sound
|
||||
DebugLevel3("Registering `%s'\n" _C_ files[0]);
|
||||
id->Sound.OneSound = LoadSample(files[0]);
|
||||
if (!id->Sound.OneSound) {
|
||||
free(id);
|
||||
|
@ -809,7 +785,6 @@ global void SetSoundRange(SoundId sound, unsigned char range)
|
|||
{
|
||||
if (sound != NO_SOUND) {
|
||||
((ServerSoundId) sound)->Range = range;
|
||||
DebugLevel3("Setting sound <%p> to range %u\n" _C_ sound _C_ range);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -862,8 +837,6 @@ global void FillAudio(void* udata __attribute__((unused)), Uint8* stream, int le
|
|||
#if SoundSampleSize == 16
|
||||
len >>= 1;
|
||||
#endif
|
||||
DebugLevel3Fn("%d\n" _C_ len);
|
||||
|
||||
MixIntoBuffer(stream, len);
|
||||
}
|
||||
|
||||
|
@ -894,7 +867,7 @@ global int InitSound(void)
|
|||
|
||||
// initialize unit to channel hash table
|
||||
// WARNING: creation is only valid for a hash table using pointers as key
|
||||
DebugLevel0Fn("FIXME: must write non GLIB hash functions\n");
|
||||
DebugPrint("FIXME: must write non GLIB hash functions\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -911,9 +884,7 @@ global int InitSoundServer(void)
|
|||
MapHeight = (TheUI.MapArea.EndY - TheUI.MapArea.Y + TileSizeY) / TileSizeY;
|
||||
//FIXME: Valid only in shared memory context!
|
||||
DistanceSilent = 3 * ((MapWidth > MapHeight) ? MapWidth : MapHeight);
|
||||
DebugLevel2("Distance Silent: %d\n" _C_ DistanceSilent);
|
||||
ViewPointOffset = ((MapWidth / 2 > MapHeight / 2) ? MapWidth / 2 : MapHeight / 2);
|
||||
DebugLevel2("ViewPointOffset: %d\n" _C_ ViewPointOffset);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ local void RemapSounds(void)
|
|||
SoundIdForName("warthog annoyed"));
|
||||
break;
|
||||
default:
|
||||
DebugLevel2("Unknown Terrain %d\n" _C_ TheMap.Terrain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -216,18 +216,13 @@ global Sample* LoadWav(const char* name, int flags)
|
|||
chunk.Magic = ConvertLE32(chunk.Magic);
|
||||
chunk.Length = ConvertLE32(chunk.Length);
|
||||
|
||||
DebugLevel3("Magic: $%x\n" _C_ chunk.Magic);
|
||||
DebugLevel3("Length: %d\n" _C_ chunk.Length);
|
||||
if (chunk.Magic != RIFF) {
|
||||
CLclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Loading wav file: %s\n" _C_ name);
|
||||
|
||||
CLread(f, &t, sizeof(t));
|
||||
t = ConvertLE32(t);
|
||||
DebugLevel3("Magic: $%lx\n" _C_ t);
|
||||
if (t != WAVE) {
|
||||
printf("Wrong magic %x (not %x)\n", t, WAVE);
|
||||
CLclose(f);
|
||||
|
@ -247,21 +242,12 @@ global Sample* LoadWav(const char* name, int flags)
|
|||
wavfmt.SampleSize = ConvertLE16(wavfmt.SampleSize);
|
||||
wavfmt.BitsPerSample = ConvertLE16(wavfmt.BitsPerSample);
|
||||
|
||||
DebugLevel3("Magic: $%x\n" _C_ wavfmt.FMTchunk);
|
||||
DebugLevel3("Length: %d\n" _C_ wavfmt.FMTlength);
|
||||
if (wavfmt.FMTchunk != FMT) {
|
||||
printf("Wrong magic %x (not %x)\n", wavfmt.FMTchunk, FMT);
|
||||
CLclose(f);
|
||||
ExitFatal(-1);
|
||||
}
|
||||
if (wavfmt.FMTlength != 16 && wavfmt.FMTlength != 18) {
|
||||
DebugLevel2("Encoding\t%d\t" _C_ wavfmt.Encoding);
|
||||
DebugLevel2("Channels\t%d\t" _C_ wavfmt.Channels);
|
||||
DebugLevel2("Frequency\t%d\n" _C_ wavfmt.Frequency);
|
||||
DebugLevel2("Byterate\t%d\t" _C_ wavfmt.ByteRate);
|
||||
DebugLevel2("SampleSize\t%d\t" _C_ wavfmt.SampleSize);
|
||||
DebugLevel2("BitsPerSample\t%d\n" _C_ wavfmt.BitsPerSample);
|
||||
|
||||
printf("Wrong length %d (not %d)\n", wavfmt.FMTlength, 16);
|
||||
CLclose(f);
|
||||
ExitFatal(-1);
|
||||
|
@ -272,12 +258,6 @@ global Sample* LoadWav(const char* name, int flags)
|
|||
abort();
|
||||
}
|
||||
}
|
||||
DebugLevel3("Encoding\t%d\t" _C_ wavfmt.Encoding);
|
||||
DebugLevel3("Channels\t%d\t" _C_ wavfmt.Channels);
|
||||
DebugLevel3("Frequency\t%d\n" _C_ wavfmt.Frequency);
|
||||
DebugLevel3("Byterate\t%d\t" _C_ wavfmt.ByteRate);
|
||||
DebugLevel3("SampleSize\t%d\t" _C_ wavfmt.SampleSize);
|
||||
DebugLevel3("BitsPerSample\t%d\n" _C_ wavfmt.BitsPerSample);
|
||||
|
||||
//
|
||||
// Check if supported
|
||||
|
|
|
@ -211,7 +211,7 @@ global Construction* ConstructionByIdent(const char* ident)
|
|||
++cop;
|
||||
}
|
||||
}
|
||||
DebugLevel0Fn("Construction `%s' not found.\n" _C_ ident);
|
||||
DebugPrint("Construction `%s' not found.\n" _C_ ident);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ global CLFile* CLopen(const char* fn, long openflags)
|
|||
} else if (openflags & CL_OPEN_WRITE) {
|
||||
strcpy(openstring,"wb");
|
||||
} else {
|
||||
DebugLevel0("Bad CLopen flags");
|
||||
DebugPrint("Bad CLopen flags");
|
||||
Assert(0);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ global int CLprintf(CLFile* file, char* format, ...)
|
|||
if (n > -1) { /* glibc 2.1 */
|
||||
size = n + 1; /* precisely what is needed */
|
||||
} else { /* glibc 2.0 */
|
||||
DebugLevel0Fn("Something could be wrong in CLprintf.\n");
|
||||
DebugPrint("Something could be wrong in CLprintf.\n");
|
||||
size *= 2; /* twice the old size */
|
||||
}
|
||||
if ((p = realloc(p, size)) == NULL) {
|
||||
|
@ -480,7 +480,6 @@ global char* LibraryFileName(const char* file, char* buffer)
|
|||
// Try in map directory
|
||||
//
|
||||
if (*CurrentMapPath) {
|
||||
DebugLevel3Fn("Map path: %s\n" _C_ CurrentMapPath);
|
||||
if (*CurrentMapPath == '.' || *CurrentMapPath == '/') {
|
||||
strcpy(buffer, CurrentMapPath);
|
||||
if ((s = strrchr(buffer, '/'))) {
|
||||
|
@ -581,7 +580,7 @@ global char* LibraryFileName(const char* file, char* buffer)
|
|||
return buffer;
|
||||
}
|
||||
#endif
|
||||
DebugLevel0Fn("File `%s' not found\n" _C_ file);
|
||||
DebugPrint("File `%s' not found\n" _C_ file);
|
||||
|
||||
strcpy(buffer, file);
|
||||
return buffer;
|
||||
|
|
|
@ -314,9 +314,6 @@ global Missile* MakeMissile(MissileType* mtype, int sx, int sy, int dx, int dy)
|
|||
{
|
||||
Missile* missile;
|
||||
|
||||
DebugLevel3Fn("type %d(%s) at %d,%d to %d,%d\n" _C_
|
||||
mtype - MissileTypes _C_ mtype->Ident _C_ sx _C_ sy _C_ dx _C_ dy);
|
||||
|
||||
if (!(missile = NewGlobalMissile())) {
|
||||
return missile;
|
||||
}
|
||||
|
@ -339,9 +336,6 @@ global Missile* MakeLocalMissile(MissileType* mtype, int sx, int sy, int dx, int
|
|||
{
|
||||
Missile* missile;
|
||||
|
||||
DebugLevel3Fn("type %d(%s) at %d,%d to %d,%d\n" _C_
|
||||
mtype - MissileTypes _C_ mtype->Ident _C_ sx _C_ sy _C_ dx _C_ dy);
|
||||
|
||||
if (!(missile = NewLocalMissile())) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -418,7 +412,6 @@ local int CalculateDamageStats(const UnitStats* attacker_stats,
|
|||
if (bloodlust) {
|
||||
basic_damage *= 2;
|
||||
piercing_damage *= 2;
|
||||
DebugLevel3Fn("bloodlust\n");
|
||||
}
|
||||
|
||||
damage = (basic_damage - goal_stats->Armor) > 1 ?
|
||||
|
@ -427,9 +420,6 @@ local int CalculateDamageStats(const UnitStats* attacker_stats,
|
|||
damage -= SyncRand() % ((damage + 2) / 2);
|
||||
Assert(damage >= 0);
|
||||
|
||||
DebugLevel3Fn("\nDamage done [%d] %d %d ->%d\n" _C_ goal_stats->Armor _C_
|
||||
basic_damage _C_ piercing_damage _C_ damage);
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
|
@ -472,15 +462,13 @@ global void FireMissile(Unit* unit)
|
|||
// Better let the caller/action handle this.
|
||||
|
||||
if (goal->Destroyed) {
|
||||
DebugLevel0Fn("destroyed unit\n");
|
||||
DebugPrint("destroyed unit\n");
|
||||
return;
|
||||
}
|
||||
if (goal->Removed) {
|
||||
DebugLevel3Fn("Missile-none hits removed unit!\n");
|
||||
return;
|
||||
}
|
||||
if (!goal->HP || goal->Orders[0].Action == UnitActionDie) {
|
||||
DebugLevel3Fn("Missile hits dead unit!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -509,7 +497,7 @@ global void FireMissile(Unit* unit)
|
|||
return;
|
||||
}
|
||||
|
||||
DebugLevel1Fn("Missile-none hits no unit, shouldn't happen!\n");
|
||||
DebugPrint("Missile-none hits no unit, shouldn't happen!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -534,7 +522,7 @@ global void FireMissile(Unit* unit)
|
|||
// Moved out of attack range?
|
||||
//
|
||||
if (MapDistanceBetweenUnits(unit, goal) < unit->Type->MinAttackRange) {
|
||||
DebugLevel0Fn("Missile target too near %d,%d\n" _C_
|
||||
DebugPrint("Missile target too near %d,%d\n" _C_
|
||||
MapDistanceBetweenUnits(unit,goal) _C_ unit->Type->MinAttackRange);
|
||||
// FIXME: do something other?
|
||||
return;
|
||||
|
@ -546,7 +534,6 @@ global void FireMissile(Unit* unit)
|
|||
} else {
|
||||
NearestOfUnit(goal, unit->X, unit->Y, &dx, &dy);
|
||||
}
|
||||
DebugLevel3Fn("Fire to unit at %d,%d\n" _C_ dx _C_ dy);
|
||||
} else {
|
||||
dx = unit->Orders[0].X;
|
||||
dy = unit->Orders[0].Y;
|
||||
|
@ -611,8 +598,6 @@ local int MissileVisibleInViewport(const Viewport* vp, const Missile* missile)
|
|||
if (!AnyMapAreaVisibleInViewport(vp, min_x, min_y, max_x, max_y)) {
|
||||
return 0;
|
||||
}
|
||||
DebugLevel3Fn("Missile bounding box %d %d %d %d\n" _C_ min_x _C_ max_x _C_
|
||||
min_y _C_ max_y);
|
||||
|
||||
for (x = min_x; x <= max_x; ++x) {
|
||||
for ( y = min_y; y <= max_y; ++y) {
|
||||
|
@ -928,7 +913,6 @@ local void MissileHitsGoal(const Missile* missile, Unit* goal, int splash)
|
|||
local void MissileHitsWall(const Missile* missile, int x, int y, int splash)
|
||||
{
|
||||
if (WallOnMap(x, y)) {
|
||||
DebugLevel3Fn("Missile on wall?\n");
|
||||
if (HumanWallOnMap(x, y)) {
|
||||
if (missile->Damage) { // direct damage, spells mostly
|
||||
HitWall(x, y, missile->Damage / splash);
|
||||
|
@ -993,7 +977,6 @@ global void MissileHit(Missile* missile)
|
|||
}
|
||||
|
||||
if (!missile->SourceUnit) { // no owner - green-cross ...
|
||||
DebugLevel3Fn("Missile has no owner!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1002,7 +985,7 @@ global void MissileHit(Missile* missile)
|
|||
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
// FIXME: this should handled by caller?
|
||||
DebugLevel0Fn("Missile gone outside of map!\n");
|
||||
DebugPrint("Missile gone outside of map!\n");
|
||||
return; // outside the map.
|
||||
}
|
||||
|
||||
|
@ -1124,8 +1107,7 @@ local int NextMissileFrame(Missile* missile, char sign, char LongAnimation)
|
|||
if (neg) {
|
||||
missile->SpriteFrame = -missile->SpriteFrame - 1;
|
||||
}
|
||||
DebugLevel3Fn("Frame %d of %d\n" _C_
|
||||
missile->SpriteFrame _C_ missile->Type->SpriteFrames);
|
||||
|
||||
return AnimationIsFinished;
|
||||
}
|
||||
|
||||
|
@ -1183,8 +1165,6 @@ local void MissilesActionLoop(Missile** missiles)
|
|||
// NOTE: missiles[??] could be modified!!! Yes (freed)
|
||||
//
|
||||
while ((missile = *missiles)) {
|
||||
DebugLevel3Fn("Missile %s ttl %d at %d, %d\n" _C_ missile->Type->Ident
|
||||
_C_ missile->TTL _C_ missile->X _C_ missile->Y);
|
||||
if (missile->Delay && missile->Delay--) {
|
||||
++missiles;
|
||||
continue; // delay start of missile
|
||||
|
@ -1239,8 +1219,6 @@ global int ViewPointDistanceToMissile(const Missile* missile)
|
|||
x = (missile->X + missile->Type->Width / 2) / TileSizeX;
|
||||
y = (missile->Y + missile->Type->Height / 2) / TileSizeY; // pixel -> tile
|
||||
|
||||
DebugLevel3Fn("Missile %p at %d %d\n" _C_ missile _C_ x _C_ y);
|
||||
|
||||
return ViewPointDistance(x, y);
|
||||
}
|
||||
|
||||
|
@ -1541,7 +1519,6 @@ void MissileActionPointToPointBounce(Missile* missile)
|
|||
missile->SourceY = missile->Y;
|
||||
PointToPointMissile(missile);
|
||||
//missile->State++;
|
||||
DebugLevel3("HIT %d!\n" _C_ missile->State);
|
||||
MissileHit(missile);
|
||||
// FIXME: hits to left and right
|
||||
// FIXME: reduce damage effects on later impacts
|
||||
|
@ -1748,7 +1725,7 @@ global void MissileActionLandMine(Missile* missile)
|
|||
if (table[i]->Type->UnitType != UnitTypeFly &&
|
||||
table[i]->HP &&
|
||||
!(table[i] == missile->SourceUnit && !missile->Type->CanHitOwner)) {
|
||||
DebugLevel0("Landmine explosion at %d,%d.\n" _C_ x _C_ y);
|
||||
DebugPrint("Landmine explosion at %d,%d.\n" _C_ x _C_ y);
|
||||
MissileHit(missile);
|
||||
missile->TTL = 0;
|
||||
return;
|
||||
|
@ -1812,7 +1789,6 @@ global void MissileActionWhirlwind(Missile* missile)
|
|||
if (!(missile->TTL % (CYCLES_PER_SECOND/10))) {
|
||||
// we should parameter this
|
||||
n = SelectUnits(x - 1, y - 1, x + 1, y + 1, table);
|
||||
DebugLevel3Fn("Damage on %d,%d-%d,%d = %d\n" _C_ x-1 _C_ y-1 _C_ x+1 _C_ y+1 _C_ n);
|
||||
for (i = 0; i < n; ++i) {
|
||||
if( (table[i]->X != x || table[i]->Y != y) && table[i]->HP) {
|
||||
// should be in missile
|
||||
|
@ -1820,7 +1796,7 @@ global void MissileActionWhirlwind(Missile* missile)
|
|||
}
|
||||
}
|
||||
}
|
||||
DebugLevel0Fn( "Whirlwind: %d, %d, TTL: %d state: %d\n" _C_
|
||||
DebugPrint( "Whirlwind: %d, %d, TTL: %d state: %d\n" _C_
|
||||
missile->X _C_ missile->Y _C_ missile->TTL _C_ missile->State);
|
||||
#else
|
||||
if (!(missile->TTL % CYCLES_PER_SECOND / 10)) {
|
||||
|
@ -1845,7 +1821,7 @@ global void MissileActionWhirlwind(Missile* missile)
|
|||
missile->SourceX = missile->X;
|
||||
missile->SourceY = missile->Y;
|
||||
missile->State = 0;
|
||||
DebugLevel0Fn( "Whirlwind new direction: %d, %d, TTL: %d\n" _C_
|
||||
DebugPrint( "Whirlwind new direction: %d, %d, TTL: %d\n" _C_
|
||||
missile->DX _C_ missile->DY _C_ missile->TTL );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ global void SavePlayers(CLFile* file)
|
|||
CLprintf(file, "})\n\n");
|
||||
}
|
||||
|
||||
DebugLevel0Fn("FIXME: must save unit-stats?\n");
|
||||
DebugPrint("FIXME: must save unit-stats?\n");
|
||||
|
||||
//
|
||||
// Dump local variables
|
||||
|
@ -365,8 +365,6 @@ global void CreatePlayer(int type)
|
|||
int i;
|
||||
Player* player;
|
||||
|
||||
DebugLevel3("Player %d, type %d\n" _C_ NumPlayers _C_ type);
|
||||
|
||||
if (NumPlayers == PlayerMax) { // already done for bigmaps!
|
||||
return;
|
||||
}
|
||||
|
@ -378,7 +376,7 @@ global void CreatePlayer(int type)
|
|||
// FIXME: ARI: is this needed for 'PlayerNobody' ??
|
||||
// FIXME: A: Johns: currently we need no init for the nobody player.
|
||||
if (!(player->Units = (Unit**)calloc(UnitMax, sizeof(Unit*)))) {
|
||||
DebugLevel0("Not enough memory to create player %d.\n" _C_ NumPlayers);
|
||||
DebugPrint("Not enough memory to create player %d.\n" _C_ NumPlayers);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -401,7 +399,7 @@ global void CreatePlayer(int type)
|
|||
static int already_warned;
|
||||
|
||||
if (!already_warned) {
|
||||
DebugLevel0("Too many players\n");
|
||||
DebugPrint("Too many players\n");
|
||||
already_warned = 1;
|
||||
}
|
||||
return;
|
||||
|
@ -652,10 +650,6 @@ global int PlayerCheckCosts(const Player* player, const int* costs)
|
|||
NotifyPlayer(player, NotifyYellow, 0, 0, "Not enough %s...%s more %s.",
|
||||
DefaultResourceNames[i], DefaultActions[i], DefaultResourceNames[i]);
|
||||
|
||||
if (player->AiEnabled) {
|
||||
DebugLevel3("Ai: Not enough %s...%s more %s." _C_
|
||||
DefaultResourceNames[i] _C_ DefaultActions[i] _C_ DefaultResourceNames[i]);
|
||||
}
|
||||
err |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
@ -715,7 +709,6 @@ global void PlayerAddCostsFactor(Player* player, const int* costs, int factor)
|
|||
int i;
|
||||
|
||||
for (i = 1; i < MaxCosts; ++i) {
|
||||
DebugLevel3("%d %d\n" _C_ i _C_ costs[i] * factor / 100);
|
||||
player->Resources[i] += costs[i] * factor / 100;
|
||||
}
|
||||
}
|
||||
|
@ -896,37 +889,37 @@ global void DebugPlayers(void)
|
|||
"yellow"
|
||||
};
|
||||
|
||||
DebugLevel0("Nr Color I Name Type Race Ai\n");
|
||||
DebugLevel0("-- -------- - -------- ------------ ------- -- ---\n");
|
||||
DebugPrint("Nr Color I Name Type Race Ai\n");
|
||||
DebugPrint("-- -------- - -------- ------------ ------- -- ---\n");
|
||||
for (i = 0; i < PlayerMax; ++i) {
|
||||
if (Players[i].Type == PlayerNobody) {
|
||||
continue;
|
||||
}
|
||||
DebugLevel0("%2d: %8.8s %c %-8.8s " _C_ i _C_ colors[i] _C_
|
||||
DebugPrint("%2d: %8.8s %c %-8.8s " _C_ i _C_ colors[i] _C_
|
||||
ThisPlayer == &Players[i] ? '*' :
|
||||
Players[i].AiEnabled ? '+' : ' ' _C_
|
||||
Players[i].Name);
|
||||
switch (Players[i].Type) {
|
||||
case 0: DebugLevel0("Don't know 0 "); break;
|
||||
case 1: DebugLevel0("Don't know 1 "); break;
|
||||
case 2: DebugLevel0("neutral "); break;
|
||||
case 3: DebugLevel0("nobody "); break;
|
||||
case 4: DebugLevel0("computer "); break;
|
||||
case 5: DebugLevel0("person "); break;
|
||||
case 6: DebugLevel0("rescue pas. "); break;
|
||||
case 7: DebugLevel0("rescue akt. "); break;
|
||||
case 0: DebugPrint("Don't know 0 "); break;
|
||||
case 1: DebugPrint("Don't know 1 "); break;
|
||||
case 2: DebugPrint("neutral "); break;
|
||||
case 3: DebugPrint("nobody "); break;
|
||||
case 4: DebugPrint("computer "); break;
|
||||
case 5: DebugPrint("person "); break;
|
||||
case 6: DebugPrint("rescue pas. "); break;
|
||||
case 7: DebugPrint("rescue akt. "); break;
|
||||
}
|
||||
k = PlayerRacesIndex(Players[i].Race);
|
||||
DebugLevel0("%9s" _C_ PlayerRaces.Name[k]);
|
||||
DebugLevel0("%2d " _C_ Players[i].AiNum);
|
||||
DebugPrint("%9s" _C_ PlayerRaces.Name[k]);
|
||||
DebugPrint("%2d " _C_ Players[i].AiNum);
|
||||
switch (Players[i].AiNum) {
|
||||
case PlayerAiLand: DebugLevel0("(land)"); break;
|
||||
case PlayerAiPassive: DebugLevel0("(passive)"); break;
|
||||
case PlayerAiAir: DebugLevel0("(air)"); break;
|
||||
case PlayerAiSea: DebugLevel0("(sea)"); break;
|
||||
default: DebugLevel0("?unknown?"); break;
|
||||
case PlayerAiLand: DebugPrint("(land)"); break;
|
||||
case PlayerAiPassive: DebugPrint("(passive)"); break;
|
||||
case PlayerAiAir: DebugPrint("(air)"); break;
|
||||
case PlayerAiSea: DebugPrint("(sea)"); break;
|
||||
default: DebugPrint("?unknown?"); break;
|
||||
}
|
||||
DebugLevel0("\n");
|
||||
DebugPrint("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -133,10 +133,10 @@ local void ConvertMTXM(const unsigned short* mtxm,int width,int height
|
|||
// FIXME: should use terrain name or better map->Tileset!!
|
||||
//Assert( map->Tileset->Table == Tilesets[map->Terrain]->Table );
|
||||
ctab=Tilesets[map->Terrain]->Table;
|
||||
DebugLevel0Fn("FIXME: %s <-> %s\n" _C_ Tilesets[map->Terrain]->Class _C_
|
||||
DebugPrint("FIXME: %s <-> %s\n" _C_ Tilesets[map->Terrain]->Class _C_
|
||||
map->TerrainName);
|
||||
} else {
|
||||
DebugLevel1("Unknown terrain!\n");
|
||||
DebugPrint("Unknown terrain!\n");
|
||||
// FIXME: don't use TilesetSummer
|
||||
ctab=Tilesets[TilesetSummer]->Table;
|
||||
}
|
||||
|
@ -194,13 +194,13 @@ local void ConvertSQM(const unsigned short* sqm,int width,int height
|
|||
}
|
||||
if( v&MapMoveWallO ) {
|
||||
if( !map->Fields[i].Flags&MapFieldWall ) {
|
||||
DebugLevel0("Should already be wall %d\n" _C_ i);
|
||||
DebugPrint("Should already be wall %d\n" _C_ i);
|
||||
map->Fields[i].Flags|=MapFieldWall;
|
||||
}
|
||||
}
|
||||
if( v&MapMoveHuman ) {
|
||||
if( !map->Fields[i].Flags&MapFieldWall ) {
|
||||
DebugLevel0("Should already be wall %d\n" _C_ i);
|
||||
DebugPrint("Should already be wall %d\n" _C_ i);
|
||||
map->Fields[i].Flags|=MapFieldWall;
|
||||
}
|
||||
map->Fields[i].Flags|=MapFieldHuman;
|
||||
|
@ -227,7 +227,7 @@ local void ConvertSQM(const unsigned short* sqm,int width,int height
|
|||
map->Fields[i].Flags|=MapFieldBuilding;
|
||||
}
|
||||
if( v&0x20 ) {
|
||||
DebugLevel0("SQM: contains unknown action %#04X\n" _C_ v);
|
||||
DebugPrint("SQM: contains unknown action %#04X\n" _C_ v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ local void ConvertREGM(const unsigned short* regm,int width,int height
|
|||
if( v==MapActionIsland ) { // island no transporter
|
||||
// FIXME: don't know what todo here
|
||||
//map->Fields[i].Flags|=MapFieldWall;
|
||||
DebugLevel0Fn("%d,%d %d\n" _C_ w _C_ h _C_ v);
|
||||
DebugPrint("%d,%d %d\n" _C_ w _C_ h _C_ v);
|
||||
continue;
|
||||
}
|
||||
v&=~0xFF; // low byte is region
|
||||
|
@ -278,7 +278,7 @@ local void ConvertREGM(const unsigned short* regm,int width,int height
|
|||
if( v==MapActionLand ) { // land
|
||||
continue;
|
||||
}
|
||||
DebugLevel0("REGM: contains unknown action %#04X at %d,%d\n"
|
||||
DebugPrint("REGM: contains unknown action %#04X at %d,%d\n"
|
||||
_C_ v _C_ w _C_ h);
|
||||
}
|
||||
}
|
||||
|
@ -396,8 +396,6 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
// Parse all sections.
|
||||
//
|
||||
while( PudReadHeader(input,header,&length) ) {
|
||||
DebugLevel3("\tSection: %4.4s\n" _C_ header);
|
||||
|
||||
info->MapUID += ChksumArea(header, 4);
|
||||
|
||||
//
|
||||
|
@ -408,12 +406,11 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
int v;
|
||||
|
||||
v=PudReadWord(input);
|
||||
DebugLevel3("\tVER: %d.%d\n" _C_ (v&0xF0)>>4 _C_ v&0xF);
|
||||
buf[0] = v & 0xFF;
|
||||
info->MapUID += ChksumArea(buf, 1);
|
||||
continue;
|
||||
}
|
||||
DebugLevel1("Wrong version length\n");
|
||||
DebugPrint("Wrong version length\n");
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -446,7 +443,7 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong player length\n");
|
||||
DebugPrint("Wrong player length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,7 +470,7 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
info->MapUID += ChksumArea(buf, 1);
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong terrain type length\n");
|
||||
DebugPrint("Wrong terrain type length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,7 +583,7 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong side length\n");
|
||||
DebugPrint("Wrong side length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -607,7 +604,7 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong starting gold length\n");
|
||||
DebugPrint("Wrong starting gold length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -628,7 +625,7 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong starting lumber length\n");
|
||||
DebugPrint("Wrong starting lumber length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -649,7 +646,7 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong starting oil length\n");
|
||||
DebugPrint("Wrong starting oil length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,7 +668,7 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong AI player length\n");
|
||||
DebugPrint("Wrong AI player length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -785,8 +782,6 @@ global MapInfo* GetPudInfo(const char* pud)
|
|||
continue;
|
||||
}
|
||||
|
||||
DebugLevel2("Unsupported Section: %4.4s\n" _C_ header);
|
||||
|
||||
CLseek(input,length,SEEK_CUR);
|
||||
}
|
||||
|
||||
|
@ -843,8 +838,6 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
// Parse all sections.
|
||||
//
|
||||
while( PudReadHeader(input,header,&length) ) {
|
||||
DebugLevel3("\tSection: %4.4s\n" _C_ header);
|
||||
|
||||
//
|
||||
// PUD version
|
||||
//
|
||||
|
@ -853,10 +846,10 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
unsigned int v;
|
||||
|
||||
v=PudReadWord(input);
|
||||
DebugLevel1("\tVER: %d.%d\n" _C_ (v&0xF0)>>4 _C_ v&0xF);
|
||||
DebugPrint("\tVER: %d.%d\n" _C_ (v&0xF0)>>4 _C_ v&0xF);
|
||||
continue;
|
||||
}
|
||||
DebugLevel1("Wrong version length\n");
|
||||
DebugPrint("Wrong version length\n");
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -867,7 +860,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
perror("CLread()");
|
||||
ExitFatal(-1);
|
||||
}
|
||||
DebugLevel1("\tDESC: %s\n" _C_ buf);
|
||||
DebugPrint("\tDESC: %s\n" _C_ buf);
|
||||
strncpy(map->Description,buf,sizeof(map->Description));
|
||||
map->Description[sizeof(map->Description)-1]='\0';
|
||||
continue;
|
||||
|
@ -905,7 +898,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong player length\n");
|
||||
DebugPrint("Wrong player length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -937,7 +930,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
LoadTileset();
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong terrain type length\n");
|
||||
DebugPrint("Wrong terrain type length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,8 +943,6 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
width=PudReadWord(input);
|
||||
height=PudReadWord(input);
|
||||
|
||||
DebugLevel2("\tMap %d x %d\n" _C_ width _C_ height);
|
||||
|
||||
if( !map->Fields ) {
|
||||
map->Width=width;
|
||||
map->Height=height;
|
||||
|
@ -969,7 +960,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
InitUnitCache();
|
||||
// FIXME: this should be CreateMap or InitMap?
|
||||
} else { // FIXME: should do some checks here!
|
||||
DebugLevel0Fn("Warning: Fields already allocated\n");
|
||||
DebugPrint("Warning: Fields already allocated\n");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -982,7 +973,6 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
|
||||
length-=2;
|
||||
if( PudReadWord(input) ) {
|
||||
DebugLevel3("\tUsing default data\n");
|
||||
CLseek(input,length,SEEK_CUR);
|
||||
} else {
|
||||
if( length<(long)sizeof(buf) ) {
|
||||
|
@ -1028,7 +1018,6 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
|
||||
length-=2;
|
||||
if( PudReadWord(input) ) {
|
||||
DebugLevel3("\tUsing default data\n");
|
||||
CLseek(input,length,SEEK_CUR);
|
||||
} else {
|
||||
if( length<(long)sizeof(buf) ) {
|
||||
|
@ -1065,7 +1054,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong side length\n");
|
||||
DebugPrint("Wrong side length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1083,7 +1072,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong starting gold length\n");
|
||||
DebugPrint("Wrong starting gold length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1101,7 +1090,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong starting lumber length\n");
|
||||
DebugPrint("Wrong starting lumber length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1108,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong starting oil length\n");
|
||||
DebugPrint("Wrong starting oil length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1139,7 +1128,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
}
|
||||
continue;
|
||||
} else {
|
||||
DebugLevel1("Wrong AI player length\n");
|
||||
DebugPrint("Wrong AI player length\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1158,7 +1147,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
unsigned short* mtxm;
|
||||
|
||||
if( length!=(uint32_t)width*height*2 ) {
|
||||
DebugLevel1("wrong length of MTXM section %u\n" _C_ length);
|
||||
DebugPrint("wrong length of MTXM section %u\n" _C_ length);
|
||||
ExitFatal(-1);
|
||||
}
|
||||
if( !(mtxm=malloc(length)) ) {
|
||||
|
@ -1183,7 +1172,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
unsigned short* sqm;
|
||||
|
||||
if( length!=(uint32_t)width*height*sizeof(short) ) {
|
||||
DebugLevel1("wrong length of SQM section %u\n" _C_ length);
|
||||
DebugPrint("wrong length of SQM section %u\n" _C_ length);
|
||||
ExitFatal(-1);
|
||||
}
|
||||
if( !(sqm=malloc(length)) ) {
|
||||
|
@ -1208,7 +1197,7 @@ global void LoadPud(const char* pud,WorldMap* map)
|
|||
unsigned short* regm;
|
||||
|
||||
if( length!=(uint32_t)width*height*sizeof(short) ) {
|
||||
DebugLevel1("wrong length of REGM section %u\n" _C_ length);
|
||||
DebugPrint("wrong length of REGM section %u\n" _C_ length);
|
||||
ExitFatal(-1);
|
||||
}
|
||||
if( !(regm=malloc(length)) ) {
|
||||
|
@ -1292,7 +1281,7 @@ pawn:
|
|||
,UnitTypeByWcNum(t),&Players[o]);
|
||||
if( unit->Type->GivesResource ) {
|
||||
if (!v) {
|
||||
DebugLevel0Fn("empty resource IN PUD.\n");
|
||||
DebugPrint("empty resource IN PUD.\n");
|
||||
v = 10;
|
||||
}
|
||||
unit->Value=v*2500;
|
||||
|
@ -1313,19 +1302,11 @@ pawn:
|
|||
continue;
|
||||
}
|
||||
|
||||
DebugLevel2("Unsupported Section: %4.4s\n" _C_ header);
|
||||
|
||||
CLseek(input,length,SEEK_CUR);
|
||||
}
|
||||
|
||||
CLclose(input);
|
||||
|
||||
DebugLevel3("Memory for pud %d\n"
|
||||
_C_ width*height*sizeof(*map->Fields)
|
||||
// FIXME: remove this
|
||||
+width*height*sizeof(short)
|
||||
+width*height*sizeof(short) );
|
||||
|
||||
MapOffsetX+=width;
|
||||
if( MapOffsetX>=map->Width ) {
|
||||
MapOffsetX=0;
|
||||
|
@ -1699,7 +1680,7 @@ global int SavePud(const char* pud,const WorldMap* map)
|
|||
global int SavePud(const char* pud __attribute__((unused)),
|
||||
const WorldMap* map __attribute__((unused)))
|
||||
{
|
||||
DebugLevel0Fn("Only supported with ZLIB\n");
|
||||
DebugPrint("Only supported with ZLIB\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -232,7 +232,7 @@ local int CclLoad(lua_State* l)
|
|||
}
|
||||
LibraryFileName(LuaToString(l, 1), buf);
|
||||
if (LuaLoadFile(buf) == -1) {
|
||||
DebugLevel0Fn("Load failed: %s" _C_ LuaToString(l, 1));
|
||||
DebugPrint("Load failed: %s" _C_ LuaToString(l, 1));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ local int CclSaveGame(lua_State* l)
|
|||
if (!strcasestr(LuaToString(l, -1), ".pud")) {
|
||||
LibraryFileName(LuaToString(l, -1), buf);
|
||||
if (LuaLoadFile(buf) == -1) {
|
||||
DebugLevel0Fn("Load failed: %s" _C_ value);
|
||||
DebugPrint("Load failed: %s" _C_ value);
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(value, "SyncHash")) {
|
||||
|
@ -320,12 +320,12 @@ global int LuaToBoolean(lua_State* l, int narg)
|
|||
*/
|
||||
global void CclGarbageCollect(int fast)
|
||||
{
|
||||
DebugLevel0Fn("Garbage collect (before): %d/%d\n" _C_
|
||||
DebugPrint("Garbage collect (before): %d/%d\n" _C_
|
||||
lua_getgccount(Lua) _C_ lua_getgcthreshold(Lua));
|
||||
|
||||
lua_setgcthreshold(Lua, 0);
|
||||
|
||||
DebugLevel0Fn("Garbage collect (after): %d/%d\n" _C_
|
||||
DebugPrint("Garbage collect (after): %d/%d\n" _C_
|
||||
lua_getgccount(Lua) _C_ lua_getgcthreshold(Lua));
|
||||
}
|
||||
|
||||
|
@ -944,10 +944,10 @@ local int CclGetCompileFeature(lua_State* l)
|
|||
|
||||
str = LuaToString(l, 1);
|
||||
if (strstr(CompileOptions, str)) {
|
||||
DebugLevel0Fn("I have %s\n" _C_ str);
|
||||
DebugPrint("I have %s\n" _C_ str);
|
||||
lua_pushboolean(l, 1);
|
||||
} else {
|
||||
DebugLevel0Fn("I don't have %s\n" _C_ str);
|
||||
DebugPrint("I don't have %s\n" _C_ str);
|
||||
lua_pushboolean(l, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ local int CclDefineMissileType(lua_State* l)
|
|||
NoWarningMissileType = i;
|
||||
#endif
|
||||
if (mtype) {
|
||||
DebugLevel0Fn("Redefining missile-type `%s'\n" _C_ str);
|
||||
DebugPrint("Redefining missile-type `%s'\n" _C_ str);
|
||||
free(str);
|
||||
} else {
|
||||
mtype = NewMissileTypeSlot(str); // str consumed!
|
||||
|
@ -229,7 +229,7 @@ local int CclMissile(lua_State* l)
|
|||
int args;
|
||||
int j;
|
||||
|
||||
DebugLevel0Fn("FIXME: not finished\n");
|
||||
DebugPrint("FIXME: not finished\n");
|
||||
|
||||
missile = NULL;
|
||||
type = NULL;
|
||||
|
|
|
@ -91,7 +91,7 @@ local int CclPlayer(lua_State* l)
|
|||
}
|
||||
player->Player = i;
|
||||
if (!(player->Units = (Unit**)calloc(UnitMax, sizeof(Unit*)))) {
|
||||
DebugLevel0("Not enough memory to create player %d.\n" _C_ i);
|
||||
DebugPrint("Not enough memory to create player %d.\n" _C_ i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ local void CclSpellAction(lua_State* l, SpellActionType* spellaction)
|
|||
value = LuaToString(l, -1);
|
||||
spellaction->Data.SpawnMissile.Missile = MissileTypeByIdent(value);
|
||||
if (spellaction->Data.SpawnMissile.Missile == NULL) {
|
||||
DebugLevel0Fn("in spawn-missile : missile %s does not exist\n" _C_ value);
|
||||
DebugPrint("in spawn-missile : missile %s does not exist\n" _C_ value);
|
||||
}
|
||||
lua_pop(l, 1);
|
||||
} else {
|
||||
|
@ -233,7 +233,7 @@ local void CclSpellAction(lua_State* l, SpellActionType* spellaction)
|
|||
value = LuaToString(l, -1);
|
||||
spellaction->Data.AreaBombardment.Missile = MissileTypeByIdent(value);
|
||||
if (spellaction->Data.AreaBombardment.Missile == NULL) {
|
||||
DebugLevel0Fn("in area-bombardement : missile %s does not exist\n" _C_ value);
|
||||
DebugPrint("in area-bombardement : missile %s does not exist\n" _C_ value);
|
||||
}
|
||||
lua_pop(l, 1);
|
||||
} else {
|
||||
|
@ -313,7 +313,7 @@ local void CclSpellAction(lua_State* l, SpellActionType* spellaction)
|
|||
spellaction->Data.Summon.UnitType = UnitTypeByIdent(value);
|
||||
if (!spellaction->Data.Summon.UnitType) {
|
||||
spellaction->Data.Summon.UnitType = 0;
|
||||
DebugLevel0("unit type \"%s\" not found for summon spell.\n" _C_ value);
|
||||
DebugPrint("unit type \"%s\" not found for summon spell.\n" _C_ value);
|
||||
}
|
||||
} else if (!strcmp(value, "time-to-live")) {
|
||||
lua_rawgeti(l, -1, j + 1);
|
||||
|
@ -344,7 +344,7 @@ local void CclSpellAction(lua_State* l, SpellActionType* spellaction)
|
|||
spellaction->Data.SpawnPortal.PortalType = UnitTypeByIdent(value);
|
||||
if (!spellaction->Data.SpawnPortal.PortalType) {
|
||||
spellaction->Data.SpawnPortal.PortalType = 0;
|
||||
DebugLevel0("unit type \"%s\" not found for spawn-portal.\n" _C_ value);
|
||||
DebugPrint("unit type \"%s\" not found for spawn-portal.\n" _C_ value);
|
||||
}
|
||||
} else {
|
||||
LuaError(l, "Unsupported spawn-portal tag: %s" _C_ value);
|
||||
|
@ -368,7 +368,7 @@ local void CclSpellAction(lua_State* l, SpellActionType* spellaction)
|
|||
spellaction->Data.Polymorph.NewForm = UnitTypeByIdent(value);
|
||||
if (!spellaction->Data.Polymorph.NewForm) {
|
||||
spellaction->Data.Polymorph.NewForm= 0;
|
||||
DebugLevel0("unit type \"%s\" not found for polymorph spell.\n" _C_ value);
|
||||
DebugPrint("unit type \"%s\" not found for polymorph spell.\n" _C_ value);
|
||||
}
|
||||
// FIXME: temp polymorphs? hard to do.
|
||||
} else if (!strcmp(value, "player-neutral")) {
|
||||
|
@ -609,7 +609,7 @@ local int CclDefineSpell(lua_State* l)
|
|||
identname = LuaToString(l, 1);
|
||||
spell = SpellTypeByIdent(identname);
|
||||
if (spell != NULL) {
|
||||
DebugLevel0Fn("Redefining spell-type `%s'\n" _C_ identname);
|
||||
DebugPrint("Redefining spell-type `%s'\n" _C_ identname);
|
||||
} else {
|
||||
SpellTypeTable = realloc(SpellTypeTable, (1 + SpellTypeCount) * sizeof(SpellType*));
|
||||
spell = SpellTypeTable[SpellTypeCount] = malloc(sizeof(SpellType));
|
||||
|
|
|
@ -202,12 +202,12 @@ global void ChangeTeamSelectedUnits(Player* player, Unit** units, int adjust, in
|
|||
global int SelectUnit(Unit* unit)
|
||||
{
|
||||
if (unit->Type->Revealer) { // Revealers cannot be selected
|
||||
DebugLevel0Fn("Selecting revealer?\n");
|
||||
DebugPrint("Selecting revealer?\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (unit->Removed) { // Removed cannot be selected
|
||||
DebugLevel0Fn("Selecting removed?\n");
|
||||
DebugPrint("Selecting removed?\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,6 @@ global int SelectUnitsByType(Unit* base)
|
|||
const Viewport* vp;
|
||||
|
||||
Assert(TheUI.MouseViewport);
|
||||
DebugLevel3Fn(" %s\n" _C_ base->Type->Ident);
|
||||
|
||||
type = base->Type;
|
||||
|
||||
|
@ -431,7 +430,6 @@ global int ToggleUnitsByType(Unit* base)
|
|||
int i;
|
||||
|
||||
type = base->Type;
|
||||
DebugLevel2Fn(" %s FIXME: toggle not written.\n" _C_ type->Ident);
|
||||
|
||||
// select all visible units.
|
||||
// StephanR: should be (MapX,MapY,MapX+MapWidth-1,MapY+MapHeight-1) ???
|
||||
|
@ -716,8 +714,6 @@ global int SelectUnitsInRectangle (int sx0, int sy0, int sx1, int sy1)
|
|||
int tx1;
|
||||
int ty1;
|
||||
|
||||
DebugLevel3Fn(" (%d,%d,%d,%d)\n" _C_ sx0 _C_ sy0 _C_ sx1 _C_ sy1);
|
||||
|
||||
tx0 = sx0 / TileSizeX;
|
||||
ty0 = sy0 / TileSizeY;
|
||||
tx1 = sx1 / TileSizeX;
|
||||
|
|
|
@ -153,7 +153,6 @@ global int CastDemolish(Unit* caster, const SpellType* spell __attribute__((unus
|
|||
if (action->Data.Demolish.Damage) {
|
||||
n = UnitCacheSelect(xmin, ymin, xmax, ymax, table);
|
||||
for (i = 0; i < n; ++i) {
|
||||
DebugLevel3("Hit an unit at %d %d?\n" _C_ table[i]->X _C_ table[i]->Y);
|
||||
if (table[i]->Type->UnitType != UnitTypeFly && table[i]->HP &&
|
||||
MapDistanceToUnit(x, y, table[i]) <= action->Data.Demolish.Range) {
|
||||
// Don't hit flying units!
|
||||
|
@ -204,7 +203,7 @@ global int CastSpawnPortal(Unit* caster, const SpellType* spell __attribute__((u
|
|||
|
||||
ptype = action->Data.SpawnPortal.PortalType;
|
||||
|
||||
DebugLevel0Fn("Spawning a portal exit.\n");
|
||||
DebugPrint("Spawning a portal exit.\n");
|
||||
portal = caster->Goal;
|
||||
if (portal) {
|
||||
// FIXME: if cop is already defined --> move it, but it doesn't work?
|
||||
|
@ -508,9 +507,6 @@ global int CastAdjustVitals(Unit* caster, const SpellType* spell,
|
|||
castcount = min(castcount, action->Data.AdjustVitals.MaxMultiCast);
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Used to have %d hp and %d mana.\n" _C_
|
||||
target->HP _C_ target->Mana);
|
||||
|
||||
caster->Mana -= castcount * manacost;
|
||||
if (hp < 0) {
|
||||
HitUnit(caster, target, -(castcount * hp));
|
||||
|
@ -528,8 +524,6 @@ global int CastAdjustVitals(Unit* caster, const SpellType* spell,
|
|||
target->Mana = target->Type->_MaxMana;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Unit now has %d hp and %d mana.\n" _C_
|
||||
target->HP _C_ target->Mana);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -642,7 +636,7 @@ global int CastSummon(Unit* caster, const SpellType* spell,
|
|||
}
|
||||
|
||||
if (cansummon) {
|
||||
DebugLevel0("Summoning a %s\n" _C_ unittype->Name);
|
||||
DebugPrint("Summoning a %s\n" _C_ unittype->Name);
|
||||
|
||||
//
|
||||
// Create units.
|
||||
|
@ -661,7 +655,7 @@ global int CastSummon(Unit* caster, const SpellType* spell,
|
|||
// Revealers are always removed, since they don't have graphics
|
||||
//
|
||||
if (target->Type->Revealer) {
|
||||
DebugLevel0Fn("summoned unit is a revealer, removed.\n");
|
||||
DebugPrint("summoned unit is a revealer, removed.\n");
|
||||
target->Removed = 1;
|
||||
target->CurrentSightRange = target->Stats->SightRange;
|
||||
MapMarkUnitSight(target);
|
||||
|
@ -852,10 +846,8 @@ local Target* SelectTargetUnitsOfAutoCast(const Unit* caster, const SpellType* s
|
|||
|
||||
// Ai cast should be a lot better. Use autocast if not found.
|
||||
if (caster->Player->AiEnabled && spell->AICast) {
|
||||
DebugLevel3Fn("The borg uses AI autocast XP.\n");
|
||||
autocast = spell->AICast;
|
||||
} else {
|
||||
DebugLevel3Fn("You puny mortal, join the colective!\n");
|
||||
autocast = spell->AutoCast;
|
||||
}
|
||||
Assert(autocast);
|
||||
|
@ -938,7 +930,7 @@ local Target* SelectTargetUnitsOfAutoCast(const Unit* caster, const SpellType* s
|
|||
break;
|
||||
default:
|
||||
// Something is wrong
|
||||
DebugLevel0Fn("Spell is screwed up, unknown target type\n");
|
||||
DebugPrint("Spell is screwed up, unknown target type\n");
|
||||
Assert(0);
|
||||
return NULL;
|
||||
break;
|
||||
|
@ -1094,7 +1086,7 @@ global int SpellCast(Unit* caster, const SpellType* spell, Unit* target,
|
|||
y = caster->Y;
|
||||
target = caster;
|
||||
}
|
||||
DebugLevel0Fn("Spell cast: (%s), %s -> %s (%d,%d)\n" _C_ spell->Ident _C_
|
||||
DebugPrint("Spell cast: (%s), %s -> %s (%d,%d)\n" _C_ spell->Ident _C_
|
||||
caster->Type->Name _C_ target ? target->Type->Name : "none" _C_ x _C_ y);
|
||||
if (CanCastSpell(caster, spell, target, x, y)) {
|
||||
act = spell->Action;
|
||||
|
@ -1143,7 +1135,7 @@ void CleanSpells(void)
|
|||
SpellActionType *act;
|
||||
SpellActionType *nextact;
|
||||
|
||||
DebugLevel0("Cleaning spells.\n");
|
||||
DebugPrint("Cleaning spells.\n");
|
||||
for (i = 0; i < SpellTypeCount; ++i) {
|
||||
spell = SpellTypeTable[i];
|
||||
free(spell->Ident);
|
||||
|
|
|
@ -436,7 +436,6 @@ local int WaitMouseY; /// Mouse Y position
|
|||
*/
|
||||
local void WaitCallbackKey(unsigned dummy __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("Pressed %8x %8x\n" _C_ MouseButtons _C_ dummy);
|
||||
WaitNoEvent = 0;
|
||||
}
|
||||
|
||||
|
@ -445,7 +444,6 @@ local void WaitCallbackKey(unsigned dummy __attribute__((unused)))
|
|||
*/
|
||||
local void WaitCallbackKey1(unsigned dummy __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("Released %8x %8x\n" _C_ MouseButtons _C_ dummy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -454,7 +452,6 @@ local void WaitCallbackKey1(unsigned dummy __attribute__((unused)))
|
|||
local void WaitCallbackKey2(unsigned dummy1 __attribute__((unused)),
|
||||
unsigned dummy2 __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("Pressed %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
|
||||
WaitNoEvent = 0;
|
||||
}
|
||||
|
||||
|
@ -464,7 +461,6 @@ local void WaitCallbackKey2(unsigned dummy1 __attribute__((unused)),
|
|||
local void WaitCallbackKey3(unsigned dummy1 __attribute__((unused)),
|
||||
unsigned dummy2 __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("Released %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -473,7 +469,6 @@ local void WaitCallbackKey3(unsigned dummy1 __attribute__((unused)),
|
|||
local void WaitCallbackKey4(unsigned dummy1 __attribute__((unused)),
|
||||
unsigned dummy2 __attribute__((unused)))
|
||||
{
|
||||
DebugLevel3Fn("Repeated %8x %8x %8x\n" _C_ MouseButtons _C_ dummy1 _C_ dummy2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -490,7 +485,6 @@ local void WaitCallbackMouse(int x, int y)
|
|||
*/
|
||||
local void WaitCallbackExit(void)
|
||||
{
|
||||
DebugLevel3Fn("Exit\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -586,7 +580,7 @@ global void ShowLoadProgress(const char* fmt, ...)
|
|||
InvalidateArea(5, VideoHeight - 18, VideoWidth - 10, 18);
|
||||
RealizeVideoMemory();
|
||||
} else {
|
||||
DebugLevel0Fn("!!!!%s\n" _C_ temp);
|
||||
DebugPrint("!!!!%s\n" _C_ temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,7 +639,7 @@ global void MenuLoop(char* filename, WorldMap* map)
|
|||
// Don't leak when called multiple times
|
||||
// - FIXME: not the ideal place for this..
|
||||
//
|
||||
DebugLevel0Fn("Freeing map info, wrong place\n");
|
||||
DebugPrint("Freeing map info, wrong place\n");
|
||||
FreeMapInfo(map->Info);
|
||||
map->Info = NULL;
|
||||
|
||||
|
@ -688,7 +682,7 @@ global void MenuLoop(char* filename, WorldMap* map)
|
|||
}
|
||||
|
||||
EnableRedraw = RedrawEverything;
|
||||
DebugLevel0Fn("Menu start: NetPlayers %d\n" _C_ NetPlayers);
|
||||
DebugPrint("Menu start: NetPlayers %d\n" _C_ NetPlayers);
|
||||
filename = CurrentMapPath;
|
||||
} else {
|
||||
if (EditorRunning) {
|
||||
|
@ -730,7 +724,7 @@ global void MenuLoop(char* filename, WorldMap* map)
|
|||
PreMenuSetup();
|
||||
|
||||
filename = NextChapter();
|
||||
DebugLevel0Fn("Next chapter %s\n" _C_ filename);
|
||||
DebugPrint("Next chapter %s\n" _C_ filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,7 +811,7 @@ global void Exit(int err)
|
|||
|
||||
ExitNetwork1();
|
||||
#ifdef DEBUG
|
||||
DebugLevel0("Frames %lu, Slow frames %d = %ld%%\n" _C_
|
||||
DebugPrint("Frames %lu, Slow frames %d = %ld%%\n" _C_
|
||||
FrameCounter _C_ SlowFrameCounter _C_
|
||||
(SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1));
|
||||
CclUnits(Lua);
|
||||
|
|
|
@ -127,7 +127,7 @@ int AddButton(int pos, int level, const char* icon_ident,
|
|||
ba->Value = SpellTypeByIdent(value)->Slot;
|
||||
#ifdef DEBUG
|
||||
if (ba->Value < 0) {
|
||||
DebugLevel0("Spell %s does not exist?\n" _C_ value);
|
||||
DebugPrint("Spell %s does not exist?\n" _C_ value);
|
||||
Assert(ba->Value >= 0);
|
||||
}
|
||||
#endif
|
||||
|
@ -360,12 +360,6 @@ global void DrawButtonPanel(void)
|
|||
case ButtonUpgradeTo:
|
||||
// FIXME: store pointer in button table!
|
||||
stats = &UnitTypes[v]->Stats[player->Player];
|
||||
DebugLevel3("Upgrade to %s %d %d %d %d %d\n" _C_
|
||||
UnitTypes[v].Ident _C_ UnitTypes[v].Demand _C_
|
||||
UnitTypes[v]._Costs[GoldCost] _C_
|
||||
UnitTypes[v]._Costs[WoodCost] _C_
|
||||
stats->Costs[GoldCost] _C_
|
||||
stats->Costs[WoodCost]);
|
||||
|
||||
SetCosts(0, UnitTypes[v]->Demand, stats->Costs);
|
||||
break;
|
||||
|
@ -441,7 +435,6 @@ local void UpdateButtonPanelMultipleUnits(void)
|
|||
int allow;
|
||||
|
||||
allow = 0;
|
||||
DebugLevel3("%d: %p\n" _C_ z _C_ UnitButtonTable[z]->Allowed);
|
||||
if (UnitButtonTable[z]->Allowed) {
|
||||
// there is check function -- call it
|
||||
if (UnitButtonTable[z]->Allowed(NULL, UnitButtonTable[z])) {
|
||||
|
@ -516,8 +509,6 @@ global void UpdateButtonPanel(void)
|
|||
int z;
|
||||
int allow;
|
||||
|
||||
DebugLevel3Fn("update buttons\n");
|
||||
|
||||
CurrentButtons = NULL;
|
||||
|
||||
// no unit selected
|
||||
|
@ -668,7 +659,7 @@ global void UpdateButtonPanel(void)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Unsupported button-action %d\n" _C_
|
||||
DebugPrint("Unsupported button-action %d\n" _C_
|
||||
buttonaction->Action);
|
||||
break;
|
||||
}
|
||||
|
@ -693,8 +684,6 @@ global void DoButtonButtonClicked(int button)
|
|||
int i;
|
||||
UnitType* type;
|
||||
|
||||
DebugLevel3Fn("Button clicked %d\n" _C_ button);
|
||||
|
||||
// no buttons
|
||||
if (!CurrentButtons) {
|
||||
return;
|
||||
|
@ -713,8 +702,6 @@ global void DoButtonButtonClicked(int button)
|
|||
//
|
||||
// Handle action on button.
|
||||
//
|
||||
DebugLevel3Fn("Button clicked %d=%d\n" _C_ button _C_
|
||||
CurrentButtons[button].Action);
|
||||
switch (CurrentButtons[button].Action) {
|
||||
case ButtonUnload:
|
||||
//
|
||||
|
@ -868,8 +855,6 @@ global void DoButtonButtonClicked(int button)
|
|||
// FIXME: store pointer in button table!
|
||||
type = UnitTypes[CurrentButtons[button].Value];
|
||||
if (!PlayerCheckUnitType(Selected[0]->Player, type)) {
|
||||
DebugLevel3("Upgrade to %s %d %d\n" _C_ type->Ident _C_
|
||||
type->_Costs[GoldCost] _C_ type->_Costs[WoodCost]);
|
||||
//PlayerSubUnitType(player,type);
|
||||
SendCommandUpgradeTo(Selected[0],type,
|
||||
!(KeyModifiers & ModifierShift));
|
||||
|
@ -888,7 +873,7 @@ global void DoButtonButtonClicked(int button)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
DebugLevel1Fn("Unknown action %d\n" _C_
|
||||
DebugPrint("Unknown action %d\n" _C_
|
||||
CurrentButtons[button].Action);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ local void AddIcon(const char* ident, const char* tileset,
|
|||
}
|
||||
ptr = (IconFile**)hash_find(IconHash, str);
|
||||
if (ptr && *ptr) {
|
||||
DebugLevel0Fn("FIXME: Icon already defined `%s,%s'\n" _C_
|
||||
DebugPrint("FIXME: Icon already defined `%s,%s'\n" _C_
|
||||
ident _C_ tileset);
|
||||
// This is more a config error
|
||||
free(str);
|
||||
|
@ -209,7 +209,7 @@ global void LoadIcons(void)
|
|||
}
|
||||
icon->Sprite = icon->File->Sprite;
|
||||
if (icon->Index >= (unsigned)icon->Sprite->NumFrames) {
|
||||
DebugLevel0Fn("Invalid icon index: %s - %d\n" _C_
|
||||
DebugPrint("Invalid icon index: %s - %d\n" _C_
|
||||
icon->Ident _C_ icon->Index);
|
||||
icon->Index = 0;
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ global Icon* IconByIdent(const char* ident)
|
|||
return *icon;
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Icon %s not found\n" _C_ ident);
|
||||
DebugPrint("Icon %s not found\n" _C_ ident);
|
||||
return NoIcon;
|
||||
}
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ local void UiFindIdleWorker(void)
|
|||
*/
|
||||
local void UiToggleGrabMouse(void)
|
||||
{
|
||||
DebugLevel0Fn("%x\n" _C_ KeyModifiers);
|
||||
DebugPrint("%x\n" _C_ KeyModifiers);
|
||||
ToggleGrabMouse(0);
|
||||
SetStatusLine("Grab mouse toggled.");
|
||||
}
|
||||
|
@ -902,7 +902,6 @@ local int CommandKey(int key)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel3("Key %d\n" _C_ key);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
@ -937,7 +936,7 @@ global int HandleCheats(const char* input)
|
|||
lua_pushstring(Lua, "HandleCheats");
|
||||
lua_gettable(Lua, LUA_GLOBALSINDEX);
|
||||
if (!lua_isfunction(Lua, -1)) {
|
||||
DebugLevel0Fn("No HandleCheats function in lua.\n");
|
||||
DebugPrint("No HandleCheats function in lua.\n");
|
||||
return 0;
|
||||
}
|
||||
lua_pushstring(Lua, input);
|
||||
|
@ -1027,7 +1026,6 @@ local int InputKey(int key)
|
|||
ClearStatusLine();
|
||||
return 1;
|
||||
case '\b':
|
||||
DebugLevel3("Key <-\n");
|
||||
if (InputIndex) {
|
||||
if (Input[InputIndex - 1] == '~') {
|
||||
Input[--InputIndex] = '\0';
|
||||
|
@ -1065,7 +1063,6 @@ local int InputKey(int key)
|
|||
if (key >= ' ' && key <= 256) {
|
||||
if ((key == '~' && InputIndex < (int)sizeof(Input) - 2) ||
|
||||
InputIndex < (int)sizeof(Input) - 1) {
|
||||
DebugLevel3("Key %c\n" _C_ key);
|
||||
Input[InputIndex++] = key;
|
||||
Input[InputIndex] = '\0';
|
||||
if (key == '~') {
|
||||
|
|
|
@ -242,7 +242,7 @@ local void DrawUnitInfo(const Unit* unit)
|
|||
stats = unit->Stats;
|
||||
#ifdef DEBUG
|
||||
if (!type) {
|
||||
DebugLevel1Fn(" FIXME: free unit selected\n");
|
||||
DebugPrint(" FIXME: free unit selected\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1505,7 +1505,6 @@ normkey:
|
|||
}
|
||||
++mi;
|
||||
}
|
||||
DebugLevel3("Key %d\n" _C_ key);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -2767,10 +2767,10 @@ local void CampaignGameMenu(void)
|
|||
Invalidate();
|
||||
|
||||
menu = FindMenu("menu-campaign-select");
|
||||
DebugLevel0Fn("%d campaigns available\n" _C_ NumCampaigns);
|
||||
DebugPrint("%d campaigns available\n" _C_ NumCampaigns);
|
||||
#ifdef DEBUG
|
||||
for (i = 0; i < NumCampaigns; ++i) {
|
||||
DebugLevel0Fn("Campaign %d: %16.16s: %s\n" _C_ i _C_
|
||||
DebugPrint("Campaign %d: %16.16s: %s\n" _C_ i _C_
|
||||
Campaigns[i].Ident _C_
|
||||
Campaigns[i].Name);
|
||||
}
|
||||
|
@ -3086,7 +3086,7 @@ local void TerminateNetConnect(void)
|
|||
break;
|
||||
}
|
||||
|
||||
DebugLevel1Fn("NetLocalState %d\n" _C_ NetLocalState);
|
||||
DebugPrint("NetLocalState %d\n" _C_ NetLocalState);
|
||||
NetConnectRunning = 2;
|
||||
GuiGameStarted = 0;
|
||||
ProcessMenu("menu-net-multi-client", 1);
|
||||
|
@ -3185,7 +3185,7 @@ local void MultiPlayerGameMenu(void)
|
|||
ProcessMenu("menu-multi-net-type-menu", 1);
|
||||
|
||||
|
||||
DebugLevel0Fn("GuiGameStarted: %d\n" _C_ GuiGameStarted);
|
||||
DebugPrint("GuiGameStarted: %d\n" _C_ GuiGameStarted);
|
||||
if (GuiGameStarted) {
|
||||
GameMenuReturn();
|
||||
}
|
||||
|
@ -3246,7 +3246,7 @@ local void ScenSelectInit(Menuitem *mi)
|
|||
mi->menu->Items[9].flags =
|
||||
*ScenSelectDisplayPath ? 0 : MenuButtonDisabled;
|
||||
mi->menu->Items[9].d.button.text = ScenSelectDisplayPath;
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3360,7 +3360,6 @@ local int ScenSelectRDFilter(char *pathbuf, FileList *fl)
|
|||
if (curopt == 0) {
|
||||
// info = GetCmInfo(pathbuf);
|
||||
info = NULL;
|
||||
DebugLevel3Fn("GetCmInfo(%s) : %p\n" _C_ pathbuf _C_ info);
|
||||
fl->type = 1;
|
||||
fl->name = strdup(np);
|
||||
fl->xdata = info;
|
||||
|
@ -3368,7 +3367,6 @@ local int ScenSelectRDFilter(char *pathbuf, FileList *fl)
|
|||
} else if (curopt == 1) {
|
||||
info = GetPudInfo(pathbuf);
|
||||
if (info) {
|
||||
DebugLevel3Fn("GetPudInfo(%s) : %p\n" _C_ pathbuf _C_ info);
|
||||
sz = szl[menu->Items[8].d.pulldown.curopt];
|
||||
if (sz < 0 || (info->MapWidth == sz && info->MapHeight == sz)) {
|
||||
fl->type = 1;
|
||||
|
@ -3758,7 +3756,7 @@ local void ScenSelectCancel(void)
|
|||
//
|
||||
// Use last selected map.
|
||||
//
|
||||
DebugLevel0Fn("Map path: %s\n" _C_ CurrentMapPath);
|
||||
DebugPrint("Map path: %s\n" _C_ CurrentMapPath);
|
||||
strcpy(ScenSelectPath, StratagusLibPath);
|
||||
if (*ScenSelectPath) {
|
||||
strcat(ScenSelectPath, "/");
|
||||
|
@ -3775,7 +3773,7 @@ local void ScenSelectCancel(void)
|
|||
*ScenSelectDisplayPath = '\0';
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
*/
|
||||
CurrentMenu->Items[9].d.button.text = NULL;
|
||||
|
||||
|
@ -3844,7 +3842,7 @@ local void GameSetupInit(Menuitem *mi __attribute__ ((unused)))
|
|||
strcpy(CurrentMapPath, DefaultMap);
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Map path: %s\n" _C_ CurrentMapPath);
|
||||
DebugPrint("Map path: %s\n" _C_ CurrentMapPath);
|
||||
strcpy(ScenSelectPath, StratagusLibPath);
|
||||
if (*ScenSelectPath) {
|
||||
strcat(ScenSelectPath, "/");
|
||||
|
@ -3860,7 +3858,7 @@ local void GameSetupInit(Menuitem *mi __attribute__ ((unused)))
|
|||
} else {
|
||||
*ScenSelectDisplayPath = '\0';
|
||||
}
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
|
||||
GetInfoFromSelectPath();
|
||||
|
||||
|
@ -4025,7 +4023,7 @@ local void CustomGameOPSAction(Menuitem *mi __attribute__((unused)), int i)
|
|||
local void MultiGameFWSAction(Menuitem *mi, int i)
|
||||
{
|
||||
if (!mi || mi->d.pulldown.curopt == i) {
|
||||
DebugLevel0Fn("Update fow %d\n" _C_ i);
|
||||
DebugPrint("Update fow %d\n" _C_ i);
|
||||
switch (i) {
|
||||
case 0:
|
||||
TheMap.NoFogOfWar = 0;
|
||||
|
@ -4120,7 +4118,7 @@ local void NetworkGamePrepareGameSettings(void)
|
|||
|
||||
Assert(MenuMapInfo);
|
||||
|
||||
DebugLevel0Fn("NetPlayers = %d\n" _C_ NetPlayers);
|
||||
DebugPrint("NetPlayers = %d\n" _C_ NetPlayers);
|
||||
|
||||
GameSettings.NetGameType=SettingsMultiPlayerGame;
|
||||
|
||||
|
@ -4141,7 +4139,6 @@ local void NetworkGamePrepareGameSettings(void)
|
|||
// Make a list of the available player slots.
|
||||
for (c = h = i = 0; i < PlayerMax; i++) {
|
||||
if (MenuMapInfo->PlayerType[i] == PlayerPerson) {
|
||||
DebugLevel3Fn("Player slot %i is available for a person\n" _C_ i);
|
||||
num[h++] = i;
|
||||
}
|
||||
if (MenuMapInfo->PlayerType[i] == PlayerComputer) {
|
||||
|
@ -4152,7 +4149,6 @@ local void NetworkGamePrepareGameSettings(void)
|
|||
switch(ServerSetupState.CompOpt[num[i]]) {
|
||||
case 0:
|
||||
GameSettings.Presets[num[i]].Type = PlayerPerson;
|
||||
DebugLevel3Fn("Settings[%d].Type == Person\n" _C_ num[i]);
|
||||
for (n = 0, v = 0; n < PlayerRaces.Count; ++n) {
|
||||
if (PlayerRaces.Visible[n]) {
|
||||
++v;
|
||||
|
@ -4173,11 +4169,9 @@ local void NetworkGamePrepareGameSettings(void)
|
|||
break;
|
||||
case 1:
|
||||
GameSettings.Presets[num[i]].Type = PlayerComputer;
|
||||
DebugLevel3Fn("Settings[%d].Type == Computer\n" _C_ num[i]);
|
||||
break;
|
||||
case 2:
|
||||
GameSettings.Presets[num[i]].Type = PlayerNobody;
|
||||
DebugLevel3Fn("Settings[%d].Type == Closed\n" _C_ num[i]);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -4185,7 +4179,7 @@ local void NetworkGamePrepareGameSettings(void)
|
|||
for (i = 0; i < c; i++) {
|
||||
if (ServerSetupState.CompOpt[comp[i]] == 2) { // closed..
|
||||
GameSettings.Presets[comp[i]].Type = PlayerNobody;
|
||||
DebugLevel0Fn("Settings[%d].Type == Closed\n" _C_ comp[i]);
|
||||
DebugPrint("Settings[%d].Type == Closed\n" _C_ comp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4219,8 +4213,6 @@ local void MultiGamePlayerSelectorsUpdate(int initial)
|
|||
// Use lag gem as KICK button
|
||||
// Notify clients about MAP change: (initial = 1...)
|
||||
|
||||
DebugLevel3Fn("initial = %d\n" _C_ initial);
|
||||
|
||||
// Calculate available slots from pudinfo
|
||||
for (c = h = i = 0; i < PlayerMax; i++) {
|
||||
if (MenuMapInfo->PlayerType[i] == PlayerPerson) {
|
||||
|
@ -4320,7 +4312,7 @@ local void MultiGamePlayerSelectorsUpdate(int initial)
|
|||
// Tell connect state machines how many interactive players we can have
|
||||
NetPlayers = avail;
|
||||
// Check if all players are ready.
|
||||
DebugLevel0Fn("READY to START: AVAIL = %d, READY = %d\n" _C_ avail
|
||||
DebugPrint("READY to START: AVAIL = %d, READY = %d\n" _C_ avail
|
||||
_C_ ready);
|
||||
|
||||
// Disable the select scenario after players have joined.
|
||||
|
@ -4378,8 +4370,6 @@ local void MultiClientUpdate(int initial)
|
|||
memset(&LocalSetupState, 0, sizeof(ServerSetup));
|
||||
}
|
||||
for (i = 1; i < PlayerMax - 1; i++) {
|
||||
DebugLevel3Fn("%d: %d %d\n" _C_ i _C_ Hosts[i].PlyNr
|
||||
_C_ NetLocalHostsSlot);
|
||||
//
|
||||
// Johns: This works only if initial. Hosts[i].PlyNr is later lost.
|
||||
//
|
||||
|
@ -4465,7 +4455,6 @@ local void MultiGameSetupInit(Menuitem *mi)
|
|||
ServerSetupState.CompOpt[i] = 1;
|
||||
}
|
||||
MultiGamePlayerSelectorsUpdate(1);
|
||||
DebugLevel3Fn("h = %d, NetPlayers = %d\n" _C_ h _C_ NetPlayers);
|
||||
|
||||
if (MetaServerInUse) {
|
||||
ChangeGameServer();
|
||||
|
@ -4558,7 +4547,6 @@ local void NetMultiPlayerDrawFunc(Menuitem *mi)
|
|||
|
||||
GetDefaultTextColors(&nc, &rc);
|
||||
SetDefaultTextColors(rc, rc);
|
||||
DebugLevel3Fn("Hosts[%d].PlyName = %s\n" _C_ i _C_ Hosts[i].PlyName);
|
||||
VideoDrawText(TheUI.Offset640X + mi->xofs, TheUI.Offset480Y + mi->yofs, GameFont, Hosts[i].PlyName);
|
||||
|
||||
SetDefaultTextColors(nc, rc);
|
||||
|
@ -4613,7 +4601,6 @@ local void MultiClientGemAction(Menuitem *mi)
|
|||
int i;
|
||||
|
||||
i = mi - mi->menu->Items - CLIENT_PLAYER_READY + 1;
|
||||
DebugLevel3Fn("i = %d, NetLocalHostsSlot = %d\n" _C_ i _C_ NetLocalHostsSlot);
|
||||
if (i == NetLocalHostsSlot) {
|
||||
LocalSetupState.Ready[i] = !LocalSetupState.Ready[i];
|
||||
if (LocalSetupState.Ready[i]) {
|
||||
|
@ -4755,7 +4742,7 @@ global void NetClientUpdateState(void)
|
|||
ServerSetupState.GaTOpt;
|
||||
|
||||
MultiClientUpdate(0);
|
||||
DebugLevel1Fn("MultiClientMenuRedraw\n");
|
||||
DebugPrint("MultiClientMenuRedraw\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4997,7 +4984,7 @@ local void EditorMainLoadInit(Menuitem *mi)
|
|||
mi->menu->Items[5].flags =
|
||||
*ScenSelectDisplayPath ? 0 : MenuButtonDisabled;
|
||||
mi->menu->Items[5].d.button.text = ScenSelectDisplayPath;
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5194,7 +5181,7 @@ local void EditorMainLoadCancel(void)
|
|||
//
|
||||
// Use last selected map.
|
||||
//
|
||||
DebugLevel0Fn("Map path: %s\n" _C_ CurrentMapPath);
|
||||
DebugPrint("Map path: %s\n" _C_ CurrentMapPath);
|
||||
strcpy(ScenSelectPath, StratagusLibPath);
|
||||
if (*ScenSelectPath) {
|
||||
strcat(ScenSelectPath, "/");
|
||||
|
@ -5211,7 +5198,7 @@ local void EditorMainLoadCancel(void)
|
|||
*ScenSelectDisplayPath = '\0';
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
|
||||
CurrentMenu->Items[5].d.button.text = NULL;
|
||||
|
||||
|
@ -5460,7 +5447,7 @@ local void EditorLoadCancel(void)
|
|||
//
|
||||
// Use last selected map.
|
||||
//
|
||||
DebugLevel0Fn("Map path: %s\n" _C_ CurrentMapPath);
|
||||
DebugPrint("Map path: %s\n" _C_ CurrentMapPath);
|
||||
strcpy(ScenSelectPath, StratagusLibPath);
|
||||
if (*ScenSelectPath) {
|
||||
strcat(ScenSelectPath, "/");
|
||||
|
@ -5477,7 +5464,7 @@ local void EditorLoadCancel(void)
|
|||
*ScenSelectDisplayPath = '\0';
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
|
||||
CurrentMenu->Items[5].d.button.text = NULL;
|
||||
|
||||
|
@ -5622,7 +5609,7 @@ local int PlayerAiFcToMenu(int num)
|
|||
} else if (num == PlayerAiAir) {
|
||||
return 3;
|
||||
}
|
||||
DebugLevel0Fn("Invalid Ai number: %d\n" _C_ num);
|
||||
DebugPrint("Invalid Ai number: %d\n" _C_ num);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -5642,7 +5629,7 @@ local int PlayerAiMenuToFc(int num)
|
|||
} else if (num == 3) {
|
||||
return PlayerAiAir;
|
||||
}
|
||||
DebugLevel0Fn("Invalid Ai number: %d\n" _C_ num);
|
||||
DebugPrint("Invalid Ai number: %d\n" _C_ num);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -6313,7 +6300,7 @@ local void ReplayGameInit(Menuitem *mi)
|
|||
*ScenSelectDisplayPath ? 0 : MenuButtonDisabled;
|
||||
mi->menu->Items[5].d.button.text = ScenSelectDisplayPath;
|
||||
mi->menu->Items[6].d.gem.state = MI_GSTATE_UNCHECKED;
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6655,7 +6642,7 @@ local void ReplayGameCancel(void)
|
|||
//
|
||||
// Use last selected map.
|
||||
//
|
||||
DebugLevel0Fn("Map path: %s\n" _C_ CurrentMapPath);
|
||||
DebugPrint("Map path: %s\n" _C_ CurrentMapPath);
|
||||
strcpy(ScenSelectPath, StratagusLibPath);
|
||||
if (*ScenSelectPath) {
|
||||
strcat(ScenSelectPath, "/");
|
||||
|
@ -6672,7 +6659,7 @@ local void ReplayGameCancel(void)
|
|||
*ScenSelectDisplayPath = '\0';
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Start path: %s\n" _C_ ScenSelectPath);
|
||||
DebugPrint("Start path: %s\n" _C_ ScenSelectPath);
|
||||
|
||||
CurrentMenu->Items[5].d.button.text = NULL;
|
||||
|
||||
|
|
|
@ -172,7 +172,6 @@ global void DoRightButton(int sx, int sy)
|
|||
}
|
||||
type = unit->Type;
|
||||
action = type->MouseAction;
|
||||
DebugLevel3Fn("Mouse action %d\n" _C_ action);
|
||||
|
||||
//
|
||||
// Control + right click on unit is follow anything.
|
||||
|
@ -189,11 +188,11 @@ global void DoRightButton(int sx, int sy)
|
|||
if (dest && dest->Type->Transporter && dest->Player == unit->Player &&
|
||||
unit->Type->UnitType == UnitTypeLand) {
|
||||
dest->Blink = 4;
|
||||
DebugLevel0Fn("Board transporter\n");
|
||||
DebugPrint("Board transporter\n");
|
||||
// Let the transporter move to the unit. And QUEUE!!!
|
||||
// Don't do it for buildings.
|
||||
if (!dest->Type->Building) {
|
||||
DebugLevel0Fn("Send command follow");
|
||||
DebugPrint("Send command follow");
|
||||
SendCommandFollow(dest, unit, 0);
|
||||
}
|
||||
SendCommandBoard(unit, -1, -1, dest, flush);
|
||||
|
@ -211,7 +210,6 @@ global void DoRightButton(int sx, int sy)
|
|||
dest->Type->CanStore[unit->CurrentResource] &&
|
||||
dest->Player == unit->Player) {
|
||||
dest->Blink = 4;
|
||||
DebugLevel3Fn("Return to deposit.\n");
|
||||
SendCommandReturnGoods(unit, dest, flush);
|
||||
continue;
|
||||
}
|
||||
|
@ -235,7 +233,6 @@ global void DoRightButton(int sx, int sy)
|
|||
ForestOnMap(x, y) &&
|
||||
((unit->CurrentResource != res) ||
|
||||
(unit->Value < unit->Type->ResInfo[res]->ResourceCapacity))) {
|
||||
DebugLevel3("Sent worker to cut wood.\n");
|
||||
SendCommandResourceLoc(unit, x, y,flush);
|
||||
break;
|
||||
}
|
||||
|
@ -291,16 +288,13 @@ global void DoRightButton(int sx, int sy)
|
|||
}
|
||||
|
||||
if (WallOnMap(x, y)) {
|
||||
DebugLevel3("WALL ON TILE\n");
|
||||
if (unit->Player->Race == PlayerRaceHuman &&
|
||||
OrcWallOnMap(x, y)) {
|
||||
DebugLevel3("HUMAN ATTACKS ORC\n");
|
||||
SendCommandAttack(unit, x, y, NoUnitP, flush);
|
||||
continue;
|
||||
}
|
||||
if (unit->Player->Race == PlayerRaceOrc &&
|
||||
HumanWallOnMap(x, y)) {
|
||||
DebugLevel3("ORC ATTACKS HUMAN\n");
|
||||
SendCommandAttack(unit, x, y, NoUnitP, flush);
|
||||
continue;
|
||||
}
|
||||
|
@ -349,16 +343,13 @@ global void DoRightButton(int sx, int sy)
|
|||
if (type->Building) {
|
||||
if (dest && dest->Type->GivesResource && dest->Type->CanHarvest) {
|
||||
dest->Blink = 4;
|
||||
DebugLevel3("Set rally point to a resource.\n");
|
||||
SendCommandResource(unit, dest, flush);
|
||||
continue;
|
||||
}
|
||||
if (IsMapFieldExplored(unit->Player, x, y) && ForestOnMap(x, y)) {
|
||||
DebugLevel3("Set rally point to a forest.\n");
|
||||
SendCommandResourceLoc(unit, x, y, flush);
|
||||
continue;
|
||||
}
|
||||
DebugLevel3("Set rally point to a location.\n");
|
||||
SendCommandMove(unit, x, y, flush);
|
||||
continue;
|
||||
}
|
||||
|
@ -379,8 +370,6 @@ local void HandleMouseOn(int x, int y)
|
|||
|
||||
MouseScrollState = ScrollNone;
|
||||
|
||||
DebugLevel3Fn("%d, %d\n" _C_ x _C_ y);
|
||||
|
||||
//
|
||||
// Handle buttons
|
||||
//
|
||||
|
@ -550,13 +539,12 @@ local void HandleMouseOn(int x, int y)
|
|||
y >= TheUI.MapArea.Y && y <= TheUI.MapArea.EndY) {
|
||||
Viewport* vp;
|
||||
|
||||
DebugLevel3Fn("viewport %d, %d\n" _C_ x _C_ y);
|
||||
vp = GetViewport(x, y);
|
||||
Assert(vp);
|
||||
// viewport changed
|
||||
if (TheUI.MouseViewport != vp) {
|
||||
TheUI.MouseViewport = vp;
|
||||
DebugLevel0Fn("current viewport changed to %d.\n" _C_
|
||||
DebugPrint("current viewport changed to %d.\n" _C_
|
||||
vp - TheUI.Viewports);
|
||||
}
|
||||
|
||||
|
@ -703,7 +691,6 @@ global void UIHandleMouseMove(int x, int y)
|
|||
UnitUnderCursor = NULL;
|
||||
GameCursor = TheUI.Point.Cursor; // Reset
|
||||
HandleMouseOn(x, y);
|
||||
DebugLevel3("MouseOn %d\n" _C_ CursorOn);
|
||||
|
||||
// Restrict mouse to minimap when dragging
|
||||
if (OldCursorOn == CursorOnMinimap && CursorOn != CursorOnMinimap &&
|
||||
|
@ -832,7 +819,7 @@ local int SendRepair(int sx, int sy)
|
|||
SendCommandRepair(unit, x, y, dest, !(KeyModifiers & ModifierShift));
|
||||
ret = 1;
|
||||
} else {
|
||||
DebugLevel0Fn("Non-worker repairs\n");
|
||||
DebugPrint("Non-worker repairs\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -874,7 +861,6 @@ local int SendMove(int sx, int sy)
|
|||
unit = Selected[i];
|
||||
if (transporter && unit->Type->UnitType == UnitTypeLand) {
|
||||
transporter->Blink = 4;
|
||||
DebugLevel3Fn("Board transporter\n");
|
||||
SendCommandFollow(transporter, unit, 0);
|
||||
SendCommandBoard(unit, -1, -1, transporter, flush);
|
||||
ret = 1;
|
||||
|
@ -916,7 +902,6 @@ local int SendAttack(int sx, int sy)
|
|||
unit = Selected[i];
|
||||
if (unit->Type->CanAttack || unit->Type->Building) {
|
||||
if ((dest = UnitUnderCursor) && CanTarget(unit->Type, dest->Type)) {
|
||||
DebugLevel3Fn("Attacking %p\n" _C_ dest);
|
||||
dest->Blink = 4;
|
||||
} else {
|
||||
dest = NoUnitP;
|
||||
|
@ -1017,7 +1002,6 @@ local int SendResource(int sx, int sy)
|
|||
dest->Type->CanHarvest &&
|
||||
(dest->Player == unit->Player ||
|
||||
(dest->Player->Player == PlayerMax - 1))) {
|
||||
DebugLevel3("RESOURCE\n");
|
||||
dest->Blink = 4;
|
||||
SendCommandResource(Selected[i],dest, !(KeyModifiers & ModifierShift));
|
||||
ret = 1;
|
||||
|
@ -1031,7 +1015,6 @@ local int SendResource(int sx, int sy)
|
|||
Selected[i]->Value < unit->Type->ResInfo[res]->ResourceCapacity &&
|
||||
((unit->CurrentResource != res) ||
|
||||
(unit->Value < unit->Type->ResInfo[res]->ResourceCapacity))) {
|
||||
DebugLevel3("RESOURCE\n");
|
||||
SendCommandResourceLoc(unit, x, y,
|
||||
!(KeyModifiers & ModifierShift));
|
||||
ret = 1;
|
||||
|
@ -1046,18 +1029,15 @@ local int SendResource(int sx, int sy)
|
|||
if (unit->Type->Building) {
|
||||
if (dest && dest->Type->GivesResource && dest->Type->CanHarvest) {
|
||||
dest->Blink = 4;
|
||||
DebugLevel3("Set rally point to a resource.\n");
|
||||
SendCommandResource(unit, dest, !(KeyModifiers & ModifierShift));
|
||||
ret = 1;
|
||||
continue;
|
||||
}
|
||||
if (IsMapFieldExplored(unit->Player, x, y) && ForestOnMap(x, y)) {
|
||||
DebugLevel3("Set rally point to a forest.\n");
|
||||
SendCommandResourceLoc(unit, x, y, !(KeyModifiers & ModifierShift));
|
||||
ret = 1;
|
||||
continue;
|
||||
}
|
||||
DebugLevel3("Set rally point to a location.\n");
|
||||
SendCommandMove(unit, x, y, !(KeyModifiers & ModifierShift));
|
||||
ret = 1;
|
||||
continue;
|
||||
|
@ -1114,7 +1094,6 @@ local int SendSpellCast(int sx, int sy)
|
|||
|
||||
dest = UnitUnderCursor;
|
||||
|
||||
DebugLevel3Fn("SpellCast on: %p (%d,%d)\n" _C_ dest _C_ x _C_ y);
|
||||
/* NOTE: Vladi:
|
||||
This is a high-level function, it sends target spot and unit
|
||||
(if exists). All checks are performed at spell cast handle
|
||||
|
@ -1123,7 +1102,7 @@ local int SendSpellCast(int sx, int sy)
|
|||
for (i = 0; i < NumSelected; ++i) {
|
||||
unit = Selected[i];
|
||||
if (!unit->Type->CanCastSpell) {
|
||||
DebugLevel0Fn("but unit %d(%s) can't cast spells?\n" _C_
|
||||
DebugPrint("but unit %d(%s) can't cast spells?\n" _C_
|
||||
unit->Slow _C_ unit->Type->Name);
|
||||
// this unit cannot cast spell
|
||||
continue;
|
||||
|
@ -1185,7 +1164,7 @@ local void SendCommand(int sx, int sy)
|
|||
ret = SendSpellCast(sx, sy);
|
||||
break;
|
||||
default:
|
||||
DebugLevel1("Unsupported send action %d\n" _C_ CursorAction);
|
||||
DebugPrint("Unsupported send action %d\n" _C_ CursorAction);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1383,7 @@ global void UIHandleButtonDown(unsigned button)
|
|||
if ((MouseButtons & LeftButton) &&
|
||||
TheUI.SelectedViewport != TheUI.MouseViewport) {
|
||||
TheUI.SelectedViewport = TheUI.MouseViewport;
|
||||
DebugLevel0Fn("selected viewport changed to %d.\n" _C_
|
||||
DebugPrint("selected viewport changed to %d.\n" _C_
|
||||
TheUI.SelectedViewport - TheUI.Viewports);
|
||||
}
|
||||
|
||||
|
@ -1467,7 +1446,6 @@ global void UIHandleButtonDown(unsigned button)
|
|||
SubScrollX = 0;
|
||||
SubScrollY = 0;
|
||||
GameCursor = TheUI.Scroll.Cursor;
|
||||
DebugLevel3("Cursor middle down %d,%d\n" _C_ CursorX _C_ CursorY);
|
||||
} else if (MouseButtons & RightButton) {
|
||||
if (!GameObserve && !GamePaused) {
|
||||
Unit* unit;
|
||||
|
@ -1557,7 +1535,7 @@ global void UIHandleButtonDown(unsigned button)
|
|||
if (!GameObserve && !GamePaused &&
|
||||
PlayersTeamed(ThisPlayer->Player, Selected[0]->Player->Player)) {
|
||||
if (ButtonUnderCursor < Selected[0]->Data.Train.Count) {
|
||||
DebugLevel0Fn("Cancel slot %d %s\n" _C_
|
||||
DebugPrint("Cancel slot %d %s\n" _C_
|
||||
ButtonUnderCursor _C_
|
||||
Selected[0]->Data.Train.What[ButtonUnderCursor]->Ident);
|
||||
SendCommandCancelTraining(Selected[0],
|
||||
|
@ -1572,7 +1550,7 @@ global void UIHandleButtonDown(unsigned button)
|
|||
if (!GameObserve && !GamePaused &&
|
||||
PlayersTeamed(ThisPlayer->Player, Selected[0]->Player->Player)) {
|
||||
if (ButtonUnderCursor == 0 && NumSelected == 1) {
|
||||
DebugLevel0Fn("Cancel upgrade %s\n" _C_
|
||||
DebugPrint("Cancel upgrade %s\n" _C_
|
||||
Selected[0]->Type->Ident);
|
||||
SendCommandCancelUpgradeTo(Selected[0]);
|
||||
}
|
||||
|
@ -1584,7 +1562,7 @@ global void UIHandleButtonDown(unsigned button)
|
|||
if (!GameObserve && !GamePaused &&
|
||||
PlayersTeamed(ThisPlayer->Player, Selected[0]->Player->Player)) {
|
||||
if (ButtonUnderCursor == 0 && NumSelected == 1) {
|
||||
DebugLevel0Fn("Cancel research %s\n" _C_
|
||||
DebugPrint("Cancel research %s\n" _C_
|
||||
Selected[0]->Type->Ident);
|
||||
SendCommandCancelResearch(Selected[0]);
|
||||
}
|
||||
|
|
|
@ -1613,7 +1613,6 @@ local int CclDefineUI(lua_State* l)
|
|||
h = LuaToNumber(l, -1);
|
||||
lua_pop(l, 1);
|
||||
lua_pop(l, 1);
|
||||
DebugLevel3Fn("Map are size is %d %d\n" _C_ w _C_ h);
|
||||
} else {
|
||||
LuaError(l, "Unsupported tag: %s" _C_ value);
|
||||
}
|
||||
|
@ -2299,8 +2298,6 @@ local int CclDefineMenu(lua_State* l)
|
|||
int args;
|
||||
int j;
|
||||
|
||||
DebugLevel3Fn("Define menu\n");
|
||||
|
||||
name = NULL;
|
||||
TheUI.Offset640X = (VideoWidth - 640) / 2;
|
||||
TheUI.Offset480Y = (VideoHeight - 480) / 2;
|
||||
|
@ -2519,8 +2516,6 @@ local int CclDefineMenuItem(lua_State* l)
|
|||
int j;
|
||||
int k;
|
||||
|
||||
DebugLevel3Fn("Define menu-item\n");
|
||||
|
||||
name = NULL;
|
||||
item = (Menuitem*)calloc(1, sizeof(Menuitem));
|
||||
|
||||
|
@ -3484,8 +3479,6 @@ local int CclDefineButton(lua_State* l)
|
|||
LuaError(l, "incorrect argument");
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Define button\n");
|
||||
|
||||
memset(&ba, 0, sizeof(ba));
|
||||
//
|
||||
// Parse the arguments
|
||||
|
|
|
@ -604,7 +604,7 @@ local void SetViewportModeSingle(void)
|
|||
{
|
||||
Viewport new_vps[MAX_NUM_VIEWPORTS];
|
||||
|
||||
DebugLevel0("Single viewport set\n");
|
||||
DebugPrint("Single viewport set\n");
|
||||
|
||||
new_vps[0].X = TheUI.MapArea.X;
|
||||
new_vps[0].Y = TheUI.MapArea.Y;
|
||||
|
@ -627,7 +627,7 @@ local void SetViewportModeSplitHoriz(void)
|
|||
{
|
||||
Viewport new_vps[MAX_NUM_VIEWPORTS];
|
||||
|
||||
DebugLevel0("Two horizontal viewports set\n");
|
||||
DebugPrint("Two horizontal viewports set\n");
|
||||
|
||||
new_vps[0].X = TheUI.MapArea.X;
|
||||
new_vps[0].Y = TheUI.MapArea.Y;
|
||||
|
@ -656,7 +656,7 @@ local void SetViewportModeSplitHoriz3(void)
|
|||
{
|
||||
Viewport new_vps[MAX_NUM_VIEWPORTS];
|
||||
|
||||
DebugLevel0("Horizontal 3-way viewport division set\n");
|
||||
DebugPrint("Horizontal 3-way viewport division set\n");
|
||||
|
||||
new_vps[0].X = TheUI.MapArea.X;
|
||||
new_vps[0].Y = TheUI.MapArea.Y;
|
||||
|
@ -690,7 +690,7 @@ local void SetViewportModeSplitVert(void)
|
|||
{
|
||||
Viewport new_vps[MAX_NUM_VIEWPORTS];
|
||||
|
||||
DebugLevel0("Two vertical viewports set\n");
|
||||
DebugPrint("Two vertical viewports set\n");
|
||||
|
||||
new_vps[0].X = TheUI.MapArea.X;
|
||||
new_vps[0].Y = TheUI.MapArea.Y;
|
||||
|
@ -719,7 +719,7 @@ local void SetViewportModeQuad(void)
|
|||
{
|
||||
Viewport new_vps[MAX_NUM_VIEWPORTS];
|
||||
|
||||
DebugLevel0("Four viewports set\n");
|
||||
DebugPrint("Four viewports set\n");
|
||||
|
||||
new_vps[0].X = TheUI.MapArea.X;
|
||||
new_vps[0].Y = TheUI.MapArea.Y;
|
||||
|
@ -770,7 +770,7 @@ global void SetViewportMode(ViewportMode new_mode)
|
|||
SetViewportModeQuad();
|
||||
break;
|
||||
default:
|
||||
DebugLevel0Fn("trying to set an unknown mode!!\n");
|
||||
DebugPrint("trying to set an unknown mode!!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ global void AddDependency(const char* target, const char* required, int count,
|
|||
rule.Type = DependRuleUpgrade;
|
||||
rule.Kind.Upgrade = UpgradeByIdent(target);
|
||||
} else {
|
||||
DebugLevel0Fn("dependency target `%s' should be unit-type or upgrade\n" _C_
|
||||
DebugPrint("dependency target `%s' should be unit-type or upgrade\n" _C_
|
||||
target);
|
||||
return;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ global void AddDependency(const char* target, const char* required, int count,
|
|||
// Adjust count.
|
||||
//
|
||||
if (count < 0 || count > 255) {
|
||||
DebugLevel0Fn("wrong count `%d' range 0 .. 255\n" _C_ count);
|
||||
DebugPrint("wrong count `%d' range 0 .. 255\n" _C_ count);
|
||||
count = 255;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ global void AddDependency(const char* target, const char* required, int count,
|
|||
temp->Type = DependRuleUpgrade;
|
||||
temp->Kind.Upgrade = UpgradeByIdent(required);
|
||||
} else {
|
||||
DebugLevel0Fn("dependency required `%s' should be unit-type or upgrade\n" _C_
|
||||
DebugPrint("dependency required `%s' should be unit-type or upgrade\n" _C_
|
||||
required);
|
||||
free(temp);
|
||||
return;
|
||||
|
@ -213,7 +213,7 @@ global int CheckDependByIdent(const Player* player, const char* target)
|
|||
}
|
||||
rule.Type = DependRuleUpgrade;
|
||||
} else {
|
||||
DebugLevel0Fn("target `%s' should be unit-type or upgrade\n" _C_ target);
|
||||
DebugPrint("target `%s' should be unit-type or upgrade\n" _C_ target);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ local int CclDefineDependency(lua_State* l)
|
|||
*/
|
||||
local int CclGetDependency(lua_State* l __attribute__((unused)))
|
||||
{
|
||||
DebugLevel0Fn("FIXME: write this %p\n" _C_ l);
|
||||
DebugPrint("FIXME: write this %p\n" _C_ l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ local int CclGetDependency(lua_State* l __attribute__((unused)))
|
|||
*/
|
||||
local int CclCheckDependency(lua_State* l __attribute__((unused)))
|
||||
{
|
||||
DebugLevel0Fn("FIXME: write this %p\n" _C_ l);
|
||||
DebugPrint("FIXME: write this %p\n" _C_ l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ global void CclParseOrder(lua_State* l, Order* order)
|
|||
slot = strtol(value + 1, NULL, 16);
|
||||
order->Goal = UnitSlots[slot];
|
||||
if (!UnitSlots[slot]) {
|
||||
DebugLevel0Fn("FIXME: Forward reference not supported\n");
|
||||
DebugPrint("FIXME: Forward reference not supported\n");
|
||||
}
|
||||
//++UnitSlots[slot]->Refs;
|
||||
|
||||
|
@ -436,7 +436,6 @@ local void CclParseResWorker(lua_State* l, Unit* unit)
|
|||
if (!strcmp(value, "time-to-harvest")) {
|
||||
lua_rawgeti(l, -1, j + 1);
|
||||
unit->Data.ResWorker.TimeToHarvest = LuaToNumber(l, -1);
|
||||
DebugLevel3("Unit %d load TimeToHarvest %d\n" _C_ unit->Slot _C_ unit->Data.ResWorker.TimeToHarvest);
|
||||
lua_pop(l, 1);
|
||||
} else if (!strcmp(value, "done-harvesting")) {
|
||||
unit->Data.ResWorker.DoneHarvesting = 1;
|
||||
|
@ -625,7 +624,6 @@ local int CclUnit(lua_State* l)
|
|||
|
||||
slot = LuaToNumber(l, j + 1);
|
||||
++j;
|
||||
DebugLevel3Fn("parsing unit #%d\n" _C_ slot);
|
||||
|
||||
unit = NULL;
|
||||
type = NULL;
|
||||
|
@ -870,7 +868,7 @@ local int CclUnit(lua_State* l)
|
|||
AssignUnitToPlayer (unit, player);
|
||||
unit->HP = hp;
|
||||
if (unit->Orders[0].Action == UnitActionBuilded) {
|
||||
DebugLevel0Fn("HACK: the building is not ready yet\n");
|
||||
DebugPrint("HACK: the building is not ready yet\n");
|
||||
// HACK: the building is not ready yet
|
||||
unit->Player->UnitTypesCount[type->Slot]--;
|
||||
}
|
||||
|
@ -958,8 +956,6 @@ local int CclUnit(lua_State* l)
|
|||
unit->Colors = &unit->RescuedFrom->UnitColors;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("unit #%d parsed\n" _C_ slot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,11 +122,9 @@ local int CclDefineUnitType(lua_State* l)
|
|||
NoWarningUnitType = i;
|
||||
#endif
|
||||
if (type) {
|
||||
DebugLevel3Fn("Redefining unit-type `%s'\n" _C_ str);
|
||||
free(str);
|
||||
redefine = 1;
|
||||
} else {
|
||||
DebugLevel3Fn("Defining unit-type `%s'\n" _C_ str);
|
||||
type = NewUnitTypeSlot(str);
|
||||
type->BoolFlag = calloc(NumberBoolFlag, sizeof(*type->BoolFlag));
|
||||
type->CanTargetFlag = calloc(NumberBoolFlag, sizeof(*type->CanTargetFlag));
|
||||
|
@ -318,7 +316,7 @@ local int CclDefineUnitType(lua_State* l)
|
|||
value = LuaToString(l, -1);
|
||||
auxtype = UnitTypeByIdent(value);
|
||||
if (!auxtype) {
|
||||
DebugLevel0("Build on top of undefined unit \"%s\".\n" _C_ str);
|
||||
DebugPrint("Build on top of undefined unit \"%s\".\n" _C_ str);
|
||||
Assert(0);
|
||||
}
|
||||
type->MustBuildOnTop = auxtype;
|
||||
|
@ -619,7 +617,6 @@ local int CclDefineUnitType(lua_State* l)
|
|||
lua_rawgeti(l, -1, k + 1);
|
||||
value = LuaToString(l, -1);
|
||||
spell = SpellTypeByIdent(value);
|
||||
DebugLevel3Fn("%d \n" _C_ id);
|
||||
if (spell == NULL) {
|
||||
LuaError(l, "Unknown spell type: %s" _C_ value);
|
||||
}
|
||||
|
@ -650,7 +647,6 @@ local int CclDefineUnitType(lua_State* l)
|
|||
lua_rawgeti(l, -1, k + 1);
|
||||
value = LuaToString(l, -1);
|
||||
spell = SpellTypeByIdent(value);
|
||||
DebugLevel3Fn("%d \n" _C_ id);
|
||||
if (spell == NULL) {
|
||||
LuaError(l, "AutoCastActive : Unknown spell type: %s" _C_ value);
|
||||
}
|
||||
|
@ -906,7 +902,6 @@ global UnitType* CclGetUnitType(lua_State* l)
|
|||
// Be kind allow also strings or symbols
|
||||
if (lua_isstring(l, -1)) {
|
||||
str = LuaToString(l, -1);
|
||||
DebugLevel3("CclGetUnitType: %s\n"_C_ str);
|
||||
return UnitTypeByIdent(str);
|
||||
} else if (lua_isuserdata(l, -1)) {
|
||||
LuaUserData* data;
|
||||
|
@ -938,7 +933,6 @@ local int CclUnitType(lua_State* l)
|
|||
|
||||
str = LuaToString(l, 1);
|
||||
type = UnitTypeByIdent(str);
|
||||
DebugLevel3Fn("CclUnitType: '%s' -> '%ld'\n" _C_ str _C_ (long)type);
|
||||
data = lua_newuserdata(l, sizeof(LuaUserData));
|
||||
data->Type = LuaUnitType;
|
||||
data->Data = type;
|
||||
|
@ -1212,12 +1206,12 @@ local int CclDefineBoolFlags(lua_State* l)
|
|||
str = LuaToString(l, j + 1);
|
||||
for (i = 0; i < NumberBoolFlag; ++i) {
|
||||
if (!strcmp(str, BoolFlagName[i])) {
|
||||
DebugLevel0("Warning, Bool flags already defined\n");
|
||||
DebugPrint("Warning, Bool flags already defined\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i != NumberBoolFlag) {
|
||||
DebugLevel0("Warning, Bool flags '%s' already defined\n" _C_ BoolFlagName[i]);
|
||||
DebugPrint("Warning, Bool flags '%s' already defined\n" _C_ BoolFlagName[i]);
|
||||
continue;
|
||||
}
|
||||
BoolFlagName = realloc(BoolFlagName, (NumberBoolFlag + 1) * sizeof(*BoolFlagName));
|
||||
|
|
|
@ -176,8 +176,6 @@ global void RefsDecrease(Unit* unit)
|
|||
global void ReleaseUnit(Unit* unit)
|
||||
{
|
||||
Unit* temp;
|
||||
DebugLevel2Fn("%lu:Unit %p %d `%s'\n" _C_ GameCycle _C_
|
||||
unit _C_ UnitNumber(unit) _C_ unit->Type->Ident);
|
||||
|
||||
Assert(unit->Type); // already free.
|
||||
Assert(unit->OrderCount == 1);
|
||||
|
@ -187,7 +185,7 @@ global void ReleaseUnit(Unit* unit)
|
|||
// First release, remove from lists/tables.
|
||||
//
|
||||
if (!unit->Destroyed) {
|
||||
DebugLevel0Fn("First release %d\n" _C_ unit->Slot);
|
||||
DebugPrint("First release %d\n" _C_ unit->Slot);
|
||||
|
||||
//
|
||||
// Are more references remaining?
|
||||
|
@ -195,8 +193,6 @@ global void ReleaseUnit(Unit* unit)
|
|||
unit->Destroyed = 1; // mark as destroyed
|
||||
|
||||
if (--unit->Refs > 0) {
|
||||
DebugLevel2Fn("%lu:More references of %d #%d\n" _C_ GameCycle _C_
|
||||
UnitNumber(unit) _C_ unit->Refs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -227,8 +223,6 @@ global void ReleaseUnit(Unit* unit)
|
|||
unit->Next = 0;
|
||||
}
|
||||
unit->Refs = GameCycle + (NetworkMaxLag << 1); // could be reuse after this time
|
||||
DebugLevel2Fn("%lu:No more references, only wait for network lag, unit %d\n" _C_
|
||||
GameCycle _C_ UnitNumber(unit));
|
||||
unit->Type = 0; // for debugging.
|
||||
free(unit->CacheLinks);
|
||||
}
|
||||
|
@ -244,7 +238,7 @@ local Unit *AllocUnit(void)
|
|||
// Game unit limit reached.
|
||||
//
|
||||
if (NumUnits >= UnitMax) {
|
||||
DebugLevel0Fn("Over all unit limit (%d) reached.\n" _C_ UnitMax);
|
||||
DebugPrint("Over all unit limit (%d) reached.\n" _C_ UnitMax);
|
||||
// FIXME: Hoping this is checked everywhere.
|
||||
return NoUnitP;
|
||||
}
|
||||
|
@ -256,10 +250,10 @@ local Unit *AllocUnit(void)
|
|||
unit = ReleasedHead;
|
||||
ReleasedHead = unit->Next;
|
||||
if (ReleasedHead == 0) { // last element
|
||||
DebugLevel0Fn("Released unit queue emptied\n");
|
||||
DebugPrint("Released unit queue emptied\n");
|
||||
ReleasedTail = ReleasedHead = 0;
|
||||
}
|
||||
DebugLevel0Fn("%lu:Release %p %d\n" _C_ GameCycle _C_ unit _C_ unit->Slot);
|
||||
DebugPrint("%lu:Release %p %d\n" _C_ GameCycle _C_ unit _C_ unit->Slot);
|
||||
slot = UnitSlots + unit->Slot;
|
||||
memset(unit, 0, sizeof(*unit));
|
||||
// FIXME: can release here more slots, reducing memory needs.
|
||||
|
@ -268,7 +262,7 @@ local Unit *AllocUnit(void)
|
|||
// Allocate structure
|
||||
//
|
||||
if (!(slot = UnitSlotFree)) { // should not happen!
|
||||
DebugLevel0Fn("Maximum of units reached\n");
|
||||
DebugPrint("Maximum of units reached\n");
|
||||
return NoUnitP;
|
||||
}
|
||||
UnitSlotFree = (void*)*slot;
|
||||
|
@ -299,8 +293,6 @@ global void InitUnit(Unit* unit, UnitType* type)
|
|||
unit->UnitSlot = &Units[NumUnits]; // back pointer
|
||||
Units[NumUnits++] = unit;
|
||||
|
||||
DebugLevel3Fn("%p %d\n" _C_ unit _C_ UnitNumber(unit));
|
||||
|
||||
//
|
||||
// Initialise unit structure (must be zero filled!)
|
||||
//
|
||||
|
@ -539,7 +531,7 @@ global Unit* MakeUnitAndPlace(int x, int y, UnitType* type, Player* player)
|
|||
global void AddUnitInContainer(Unit* unit, Unit* host)
|
||||
{
|
||||
if (unit->Container) {
|
||||
DebugLevel0Fn("Unit is already contained.\n");
|
||||
DebugPrint("Unit is already contained.\n");
|
||||
exit(0);
|
||||
}
|
||||
unit->Container = host;
|
||||
|
@ -565,11 +557,11 @@ global void RemoveUnitFromContainer(Unit* unit)
|
|||
Unit* host;
|
||||
host = unit->Container;
|
||||
if (!unit->Container) {
|
||||
DebugLevel0Fn("Unit not contained.\n");
|
||||
DebugPrint("Unit not contained.\n");
|
||||
exit(0);
|
||||
}
|
||||
if (host->InsideCount == 0) {
|
||||
DebugLevel0Fn("host's inside count reached -1.");
|
||||
DebugPrint("host's inside count reached -1.");
|
||||
exit(0);
|
||||
}
|
||||
host->InsideCount--;
|
||||
|
@ -661,8 +653,6 @@ global void RemoveUnit(Unit* unit, Unit* host)
|
|||
}
|
||||
#endif
|
||||
|
||||
DebugLevel3Fn("%d %p %p\n" _C_ UnitNumber(unit) _C_ unit _C_ unit->Next);
|
||||
|
||||
if (host) {
|
||||
UnitCacheRemove(unit);
|
||||
unit->Next = host;
|
||||
|
@ -771,7 +761,7 @@ global void UnitLost(Unit* unit)
|
|||
unit->Player->UpgradeTimers.Upgrades[unit->Data.Research.Upgrade - Upgrades] = 0;
|
||||
}
|
||||
|
||||
DebugLevel0Fn("Lost %s(%d)\n" _C_ unit->Type->Ident _C_ UnitNumber(unit));
|
||||
DebugPrint("Lost %s(%d)\n" _C_ unit->Type->Ident _C_ UnitNumber(unit));
|
||||
|
||||
// Destroy resource-platform, must re-make resource patch.
|
||||
if (type->MustBuildOnTop && unit->Value > 0) {
|
||||
|
@ -864,7 +854,6 @@ global void NearestOfUnit(const Unit* unit, int tx, int ty, int *dx, int *dy)
|
|||
x = unit->X;
|
||||
y = unit->Y;
|
||||
|
||||
DebugLevel3("Nearest of (%d,%d) - (%d,%d)\n" _C_ tx _C_ ty _C_ x _C_ y);
|
||||
if (tx >= x + unit->Type->TileWidth) {
|
||||
*dx = x + unit->Type->TileWidth - 1;
|
||||
} else if (tx < x) {
|
||||
|
@ -879,8 +868,6 @@ global void NearestOfUnit(const Unit* unit, int tx, int ty, int *dx, int *dy)
|
|||
} else {
|
||||
*dy = ty;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Goal is (%d,%d)\n" _C_ *dx _C_ *dy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -913,12 +900,8 @@ local void UnitFillSeenValues(Unit* unit)
|
|||
*/
|
||||
global void UnitGoesUnderFog(Unit* unit, const Player* player)
|
||||
{
|
||||
DebugLevel3Fn("Unit %d(%s) at %d %d goes under fog for %d\n" _C_
|
||||
unit->Slot _C_ unit->Type->Name _C_ unit->X _C_ unit->Y _C_ player->Player);
|
||||
if (unit->Type->VisibleUnderFog) {
|
||||
if (player->Type == PlayerPerson && !unit->Destroyed) {
|
||||
DebugLevel3Fn("unit %d(%s): got a ref from player %d\n" _C_
|
||||
unit->Slot _C_ unit->Type->Name _C_ p);
|
||||
RefsIncrease(unit);
|
||||
}
|
||||
//
|
||||
|
@ -958,19 +941,13 @@ global void UnitGoesUnderFog(Unit* unit, const Player* player)
|
|||
*/
|
||||
global void UnitGoesOutOfFog(Unit* unit, const Player* player)
|
||||
{
|
||||
DebugLevel3Fn("Unit %d(%s) at %d %d goes out of fog for %d.\n" _C_
|
||||
unit->Slot _C_ unit->Type->Name _C_ unit->X _C_ unit->Y _C_ player->Player);
|
||||
if (unit->Type->VisibleUnderFog) {
|
||||
if (unit->Seen.ByPlayer & (1 << (player->Player))) {
|
||||
if ((player->Type == PlayerPerson) &&
|
||||
(!( unit->Seen.Destroyed & (1 << player->Player) )) ) {
|
||||
DebugLevel3Fn("unit %d(%s): cleaned a ref from player %d\n" _C_
|
||||
unit->Slot _C_ unit->Type->Name _C_ player->Player);
|
||||
RefsDecrease(unit);
|
||||
}
|
||||
} else {
|
||||
DebugLevel3Fn("Player %d discovers unit %d(%s) at %d %d.\n" _C_ player->Player _C_
|
||||
unit->Slot _C_ unit->Type->Name _C_ unit->X _C_ unit->Y);
|
||||
unit->Seen.ByPlayer |= (1 << (player->Player));
|
||||
}
|
||||
}
|
||||
|
@ -992,14 +969,11 @@ global void UnitsOnTileMarkSeen(const Player* player, int x, int y, int cloak)
|
|||
Unit* unit;
|
||||
|
||||
n = UnitCacheOnTile(x, y,units);
|
||||
DebugLevel3Fn("I can see %d units from here.\n" _C_ n);
|
||||
while (n) {
|
||||
unit = units[--n];
|
||||
if (cloak != (int)unit->Type->PermanentCloak) {
|
||||
continue;
|
||||
}
|
||||
DebugLevel3("Unit %d(%d, %d) player %d seen %d -> %d (%d, %d)\n" _C_ unit->Slot _C_ unit->X _C_ unit->Y _C_
|
||||
player->Player _C_ unit->VisCount[player->Player] _C_ unit->VisCount[player->Player] + 1 _C_ x _C_ y);
|
||||
//
|
||||
// If the unit goes out of fog, this can happen for any player that
|
||||
// this player shares vision with, and can't YET see the unit.
|
||||
|
@ -1032,12 +1006,11 @@ global void UnitsOnTileUnmarkSeen(const Player* player, int x, int y, int cloak)
|
|||
Unit* unit;
|
||||
|
||||
n = UnitCacheOnTile(x, y, units);
|
||||
DebugLevel3Fn("I can see %d units from here.\n" _C_ n);
|
||||
while (n) {
|
||||
unit = units[--n];
|
||||
if ((unit->X > x || unit->X + unit->Type->TileWidth - 1 < x ||
|
||||
unit->Y > y || unit->Y + unit->Type->TileHeight - 1 < y)) {
|
||||
DebugLevel0Fn("Wrong cache %d %d -> %d %d\n" _C_ x _C_ y _C_ unit->X _C_ unit->Y);
|
||||
DebugPrint("Wrong cache %d %d -> %d %d\n" _C_ x _C_ y _C_ unit->X _C_ unit->Y);
|
||||
}
|
||||
Assert(unit->X <= x && unit->X + unit->Type->TileWidth - 1 >= x &&
|
||||
unit->Y <= y && unit->Y + unit->Type->TileHeight - 1 >= y);
|
||||
|
@ -1045,8 +1018,6 @@ global void UnitsOnTileUnmarkSeen(const Player* player, int x, int y, int cloak)
|
|||
continue;
|
||||
}
|
||||
p = player->Player;
|
||||
DebugLevel3("Unit %d(%d, %d) player %d seen %d -> %d (%d, %d)\n" _C_ unit->Slot _C_ unit->X _C_ unit->Y _C_
|
||||
p _C_ unit->VisCount[p] _C_ unit->VisCount[p] - 1 _C_ x _C_ y);
|
||||
Assert(unit->VisCount[p]);
|
||||
unit->VisCount[p]--;
|
||||
//
|
||||
|
@ -1274,7 +1245,7 @@ global int UnitVisibleInViewport(const Unit* unit, const Viewport* vp)
|
|||
//FIXME: ARI: Added here for early game setup state by
|
||||
// MakeAndPlaceUnit() from LoadMap(). ThisPlayer not yet set,
|
||||
// so don't show anything until first real map-draw.
|
||||
DebugLevel0Fn("Fix ME ThisPlayer not set yet?!\n");
|
||||
DebugPrint("Fix ME ThisPlayer not set yet?!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1309,7 +1280,6 @@ global int UnitVisibleOnScreen(const Unit* unit)
|
|||
|
||||
for (vp = TheUI.Viewports; vp < TheUI.Viewports + TheUI.NumViewports; ++vp) {
|
||||
if (UnitVisibleInViewport(unit, vp)) {
|
||||
DebugLevel3Fn("unit %d(%s) is visibile\n" _C_ unit->Slot _C_ unit->Type->Ident);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -1353,7 +1323,7 @@ global void ChangeUnitOwner(Unit* unit, Player* newplayer)
|
|||
|
||||
// This shouldn't happen
|
||||
if (oldplayer == newplayer) {
|
||||
DebugLevel0Fn("Change the unit owner to the same player???\n");
|
||||
DebugPrint("Change the unit owner to the same player???\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1400,7 +1370,7 @@ global void ChangeUnitOwner(Unit* unit, Player* newplayer)
|
|||
// Must change food/gold and other.
|
||||
//
|
||||
if (unit->Type->GivesResource) {
|
||||
DebugLevel0Fn("Resource transfer not supported\n");
|
||||
DebugPrint("Resource transfer not supported\n");
|
||||
}
|
||||
newplayer->Demand += unit->Type->Demand;
|
||||
newplayer->Supply += unit->Type->Supply;
|
||||
|
@ -1480,8 +1450,6 @@ global void RescueUnits(void)
|
|||
if (unit->Removed) {
|
||||
continue;
|
||||
}
|
||||
DebugLevel3("Checking %d(%s)" _C_ UnitNumber(unit) _C_
|
||||
unit->Type->Ident);
|
||||
// FIXME: I hope SelectUnits checks bounds?
|
||||
// FIXME: Yes, but caller should check.
|
||||
// NOTE: +1 right,bottom isn't inclusive :(
|
||||
|
@ -1496,7 +1464,6 @@ global void RescueUnits(void)
|
|||
unit->X + unit->Type->TileWidth + 2,
|
||||
unit->Y + unit->Type->TileHeight + 2, around);
|
||||
}
|
||||
DebugLevel3(" = %d\n" _C_ n);
|
||||
//
|
||||
// Look if ally near the unit.
|
||||
//
|
||||
|
@ -1733,7 +1700,6 @@ global void DropOutNearest(Unit* unit, int gx, int gy, int addx, int addy)
|
|||
int mask;
|
||||
int n;
|
||||
|
||||
DebugLevel3Fn("%d\n" _C_ UnitNumber(unit));
|
||||
Assert(unit->Removed);
|
||||
|
||||
x = y = -1;
|
||||
|
@ -1759,7 +1725,6 @@ global void DropOutNearest(Unit* unit, int gx, int gy, int addx, int addy)
|
|||
for (i = addy; i--; ++y) { // go down
|
||||
if (CheckedCanMoveToMask(x, y, mask)) {
|
||||
n = MapDistance(gx, gy, x, y);
|
||||
DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
|
||||
if (n < bestd) {
|
||||
bestd = n;
|
||||
bestx = x;
|
||||
|
@ -1771,7 +1736,6 @@ global void DropOutNearest(Unit* unit, int gx, int gy, int addx, int addy)
|
|||
for (i = addx; i--; ++x) { // go right
|
||||
if (CheckedCanMoveToMask(x, y, mask)) {
|
||||
n = MapDistance(gx, gy, x, y);
|
||||
DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
|
||||
if (n < bestd) {
|
||||
bestd = n;
|
||||
bestx = x;
|
||||
|
@ -1783,7 +1747,6 @@ global void DropOutNearest(Unit* unit, int gx, int gy, int addx, int addy)
|
|||
for (i = addy; i--; --y) { // go up
|
||||
if (CheckedCanMoveToMask(x, y, mask)) {
|
||||
n = MapDistance(gx, gy, x, y);
|
||||
DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
|
||||
if (n < bestd) {
|
||||
bestd = n;
|
||||
bestx = x;
|
||||
|
@ -1795,7 +1758,6 @@ global void DropOutNearest(Unit* unit, int gx, int gy, int addx, int addy)
|
|||
for (i = addx; i--; --x) { // go left
|
||||
if (CheckedCanMoveToMask(x, y, mask)) {
|
||||
n = MapDistance(gx, gy, x, y);
|
||||
DebugLevel3("Distance %d,%d %d\n" _C_ x _C_ y _C_ n);
|
||||
if (n < bestd) {
|
||||
bestd = n;
|
||||
bestx = x;
|
||||
|
@ -1831,7 +1793,7 @@ global void DropOutAll(const Unit* source)
|
|||
unit->Wait=unit->Reset = 1;
|
||||
unit->SubAction = 0;
|
||||
}
|
||||
DebugLevel0Fn("Drop out %d of %d\n" _C_ i _C_ source->Data.Resource.Active);
|
||||
DebugPrint("Drop out %d of %d\n" _C_ i _C_ source->Data.Resource.Active);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -1873,7 +1835,6 @@ global int CanBuildHere(const Unit* unit, const UnitType* type, int x, int y)
|
|||
if (type->ShoreBuilding) {
|
||||
found = 0;
|
||||
|
||||
DebugLevel3("Shore building\n");
|
||||
// Need at least one coast tile
|
||||
for (h = type->TileHeight; h--;) {
|
||||
for (w = type->TileWidth; w--;) {
|
||||
|
@ -2100,7 +2061,6 @@ global int FindTerrainType(int movemask, int resmask, int rvresult, int range,
|
|||
while (rp != ep) {
|
||||
rx = points[rp].X;
|
||||
ry = points[rp].Y;
|
||||
DebugLevel3("%d,%d\n" _C_ rx _C_ ry);
|
||||
for (i = 0; i < 8; ++i) { // mark all neighbors
|
||||
x = rx + xoffset[i];
|
||||
y = ry + yoffset[i];
|
||||
|
@ -2117,7 +2077,6 @@ global int FindTerrainType(int movemask, int resmask, int rvresult, int range,
|
|||
if (rvresult ? CanMoveToMask(x, y, resmask) : !CanMoveToMask(x, y, resmask)) {
|
||||
*px = x;
|
||||
*py = y;
|
||||
DebugLevel3("Found it! %X %X\n" _C_ TheMap.Fields[x+y*TheMap.Width].Flags _C_ resmask);
|
||||
free(points);
|
||||
return 1;
|
||||
}
|
||||
|
@ -2130,7 +2089,7 @@ global int FindTerrainType(int movemask, int resmask, int rvresult, int range,
|
|||
}
|
||||
if (wp == ep) {
|
||||
// We are out of points, give up!
|
||||
DebugLevel0Fn("Ran out of points the hard way, beware.\n");
|
||||
DebugPrint("Ran out of points the hard way, beware.\n");
|
||||
break;
|
||||
}
|
||||
} else { // unreachable
|
||||
|
@ -2293,7 +2252,6 @@ global Unit* FindResource(const Unit* unit, int x, int y, int range, int resourc
|
|||
// Continue with next set.
|
||||
ep = wp;
|
||||
}
|
||||
DebugLevel3Fn("no resource found\n");
|
||||
free(points);
|
||||
return NoUnitP;
|
||||
}
|
||||
|
@ -2360,8 +2318,6 @@ global Unit* FindDeposit(const Unit* unit, int x, int y, int range, int resource
|
|||
ep = wp = 1; // start with one point
|
||||
cdist = 0; // current distance is 0
|
||||
|
||||
DebugLevel3Fn("Searching for a deposit(%d,%d,%d,%d,%s)" _C_
|
||||
UnitNumber(unit) _C_ x _C_ y _C_ range _C_ DefaultResourceNames[resource]);
|
||||
//
|
||||
// Pop a point from stack, push all neighbors which could be entered.
|
||||
//
|
||||
|
@ -2373,7 +2329,6 @@ global Unit* FindDeposit(const Unit* unit, int x, int y, int range, int resource
|
|||
x = rx + xoffset[i];
|
||||
y = ry + yoffset[i];
|
||||
++nodes_searched;
|
||||
DebugLevel3("(%d,%d) " _C_ x _C_ y);
|
||||
// Make sure we don't leave the map.
|
||||
if (x < 0 || y < 0 || x >= TheMap.Width || y >= TheMap.Height) {
|
||||
continue;
|
||||
|
@ -2390,7 +2345,6 @@ global Unit* FindDeposit(const Unit* unit, int x, int y, int range, int resource
|
|||
((IsAllied(unit->Player, depot)) ||
|
||||
(unit->Player == depot->Player))) {
|
||||
free(points);
|
||||
DebugLevel3("Found a resource deposit at %d,%d\n" _C_ x _C_ y);
|
||||
return depot;
|
||||
}
|
||||
if (CanMoveToMask(x, y, mask)) { // reachable
|
||||
|
@ -2402,7 +2356,7 @@ global Unit* FindDeposit(const Unit* unit, int x, int y, int range, int resource
|
|||
}
|
||||
if (wp == ep) {
|
||||
// We are out of points, give up!
|
||||
DebugLevel0Fn("Ran out of points the hard way, beware.\n");
|
||||
DebugPrint("Ran out of points the hard way, beware.\n");
|
||||
break;
|
||||
}
|
||||
} else { // unreachable
|
||||
|
@ -2420,7 +2374,6 @@ global Unit* FindDeposit(const Unit* unit, int x, int y, int range, int resource
|
|||
// Continue with next set.
|
||||
ep = wp;
|
||||
}
|
||||
DebugLevel3("No resource deposit found, after we searched %d nodes.\n" _C_ nodes_searched);
|
||||
free(points);
|
||||
return NoUnitP;
|
||||
}
|
||||
|
@ -2578,7 +2531,7 @@ global void LetUnitDie(Unit* unit)
|
|||
|
||||
// removed units, just remove.
|
||||
if (unit->Removed) {
|
||||
DebugLevel0Fn("Killing a removed unit?\n");
|
||||
DebugPrint("Killing a removed unit?\n");
|
||||
RemoveUnit(unit, NULL);
|
||||
UnitLost(unit);
|
||||
UnitClearOrders(unit);
|
||||
|
@ -2656,7 +2609,7 @@ global void LetUnitDie(Unit* unit)
|
|||
Assert(unit->Type->Animations &&
|
||||
unit->Type->Animations->Die);
|
||||
UnitShowAnimation(unit, unit->Type->Animations->Die);
|
||||
DebugLevel0Fn("Frame %d\n" _C_ unit->Frame);
|
||||
DebugPrint("Frame %d\n" _C_ unit->Frame);
|
||||
MapUnmarkUnitSight(unit);
|
||||
unit->CurrentSightRange = type->Stats[unit->Player->Player].SightRange;
|
||||
MapMarkUnitSight(unit);
|
||||
|
@ -2737,7 +2690,7 @@ global void HitUnit(Unit* attacker, Unit* target, int damage)
|
|||
if (!damage) { // Can now happen by splash damage
|
||||
#ifdef DEBUG
|
||||
if (!GodMode) {
|
||||
DebugLevel0Fn("Warning no damage, try to fix by caller?\n");
|
||||
DebugPrint("Warning no damage, try to fix by caller?\n");
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
|
@ -2752,7 +2705,7 @@ global void HitUnit(Unit* attacker, Unit* target, int damage)
|
|||
}
|
||||
|
||||
if (target->Removed) {
|
||||
DebugLevel0Fn("Removed target hit\n");
|
||||
DebugPrint("Removed target hit\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2917,8 +2870,6 @@ global void HitUnit(Unit* attacker, Unit* target, int damage)
|
|||
int y;
|
||||
int d;
|
||||
|
||||
DebugLevel3Fn("Unit at %d, %d attacked from %d, %d, running away.\n" _C_
|
||||
target->X _C_ target->Y _C_ attacker->X _C_ attacker->Y);
|
||||
x = target->X - attacker->X;
|
||||
y = target->Y - attacker->Y;
|
||||
d = isqrt(x * x + y * y);
|
||||
|
@ -2985,9 +2936,6 @@ global int MapDistanceToType(int x1, int y1, const UnitType* type, int x2, int y
|
|||
}
|
||||
}
|
||||
|
||||
DebugLevel3("\tDistance %d,%d -> %d,%d = %d\n" _C_
|
||||
x1 _C_ y1 _C_ x2 _C_ y2 _C_ (dy<dx) ? dx : dy);
|
||||
|
||||
return isqrt(dy * dy + dx * dx);
|
||||
}
|
||||
|
||||
|
@ -3218,7 +3166,7 @@ global void SaveOrder(const Order* order, CLFile* file)
|
|||
break;
|
||||
|
||||
default:
|
||||
DebugLevel0Fn("Unknown action in order\n");
|
||||
DebugPrint("Unknown action in order\n");
|
||||
}
|
||||
CLprintf(file, " \"flags\", %d,", order->Flags);
|
||||
CLprintf(file, " \"range\", %d,", order->Range);
|
||||
|
@ -3433,7 +3381,6 @@ global void SaveUnit(const Unit* unit, CLFile* file)
|
|||
}
|
||||
break;
|
||||
case UnitActionResource:
|
||||
DebugLevel3("Unit %d save TimeToHarvest %d\n" _C_ unit->Slot _C_ unit->Data.ResWorker.TimeToHarvest);
|
||||
CLprintf(file, ", \"data-res-worker\", {\"time-to-harvest\", %d,", unit->Data.ResWorker.TimeToHarvest);
|
||||
if (unit->Data.ResWorker.DoneHarvesting) {
|
||||
CLprintf(file, " \"done-harvesting\",");
|
||||
|
@ -3604,7 +3551,7 @@ global void SaveUnits(CLFile* file)
|
|||
for (unit = ReleasedHead; unit; unit = unit->Next) {
|
||||
CLprintf(file, "\t{Slot = %d, FreeCycle = %d}%c \n", unit->Slot, unit->Refs,
|
||||
(unit->Next ? ',' : ' '));
|
||||
DebugLevel0Fn("{Slot = %d, FreeCycle = %d}\n" _C_ unit->Slot _C_ unit->Refs);
|
||||
DebugPrint("{Slot = %d, FreeCycle = %d}\n" _C_ unit->Slot _C_ unit->Refs);
|
||||
}
|
||||
CLprintf(file, ")\n");
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ global void UnitCacheInsert(Unit* unit)
|
|||
MapField* mf;
|
||||
UnitListItem* listitem;
|
||||
|
||||
DebugLevel3Fn("%d,%d %d %s\n" _C_ unit->X _C_ unit->Y _C_ unit->Slot _C_ unit->Type->Name);
|
||||
for (i = 0; i < unit->Type->TileHeight; ++i) {
|
||||
for (j = 0; j < unit->Type->TileWidth; ++j) {
|
||||
mf = TheMap.Fields + (i + unit->Y) * TheMap.Width + j + unit->X;
|
||||
|
@ -89,7 +88,6 @@ global void UnitCacheRemove(Unit* unit)
|
|||
MapField* mf;
|
||||
UnitListItem* listitem;
|
||||
|
||||
DebugLevel3Fn("%d,%d %d %s\n" _C_ unit->X _C_ unit->Y _C_ unit->Slot _C_ unit->Type->Name);
|
||||
for (i = 0; i < unit->Type->TileHeight; ++i) {
|
||||
for (j = 0; j < unit->Type->TileWidth; ++j) {
|
||||
mf = TheMap.Fields + (i + unit->Y) * TheMap.Width + j + unit->X;
|
||||
|
@ -102,7 +100,7 @@ global void UnitCacheRemove(Unit* unit)
|
|||
listitem->Prev->Next = listitem->Next;
|
||||
} else {
|
||||
if (mf->UnitCache != listitem) {
|
||||
DebugLevel0Fn("Try to remove unit not in cache. (%d)\n" _C_ unit->Slot);
|
||||
DebugPrint("Try to remove unit not in cache. (%d)\n" _C_ unit->Slot);
|
||||
} else {
|
||||
// item is head of the list.
|
||||
mf->UnitCache = listitem->Next;
|
||||
|
@ -165,7 +163,6 @@ global int UnitCacheSelect(int x1, int y1, int x2, int y2, Unit** table)
|
|||
if (y2 > TheMap.Height) {
|
||||
y2 = TheMap.Height;
|
||||
}
|
||||
DebugLevel3Fn("%d,%d %d,%d\n" _C_ x1 _C_ y1 _C_ x2 _C_ y2);
|
||||
|
||||
n = 0;
|
||||
for (i = y1; i < y2; ++i) {
|
||||
|
|
|
@ -896,10 +896,8 @@ local void DrawDecoration(const Unit* unit, const UnitType* type, int x, int y)
|
|||
n = 3 - ((f - 75) / (25 / 3)) + 0;
|
||||
} else if (f > 50) {
|
||||
n = 3 - ((f - 50) / (25 / 3)) + 4;
|
||||
DebugLevel3("%d - %d\n" _C_ f _C_ n);
|
||||
} else {
|
||||
n = 3 - (f / (50 / 3)) + 8;
|
||||
DebugLevel3("%d - %d\n" _C_ f _C_ n);
|
||||
}
|
||||
#endif
|
||||
Assert(n >= 0);
|
||||
|
@ -1400,7 +1398,6 @@ local void GetOrderPosition(const Unit* unit, const Order* order, int* x, int* y
|
|||
*y += (order->Type->TileHeight - 1) * TileSizeY / 2;
|
||||
}
|
||||
}
|
||||
DebugLevel3Fn(": (%d,%d)\n" _C_ order->X _C_ order->Y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1526,7 +1523,7 @@ local void ShowSingleOrder(const Unit* unit, int x1, int y1, const Order* order)
|
|||
|
||||
default:
|
||||
e_color = color = ColorGray;
|
||||
DebugLevel1Fn("Unknown action %d\n" _C_ order->Action);
|
||||
DebugPrint("Unknown action %d\n" _C_ order->Action);
|
||||
break;
|
||||
}
|
||||
VideoFillCircleClip(color, x1, y1, 2);
|
||||
|
@ -1849,7 +1846,6 @@ global void DrawUnit(const Unit* unit)
|
|||
UnitType* type;
|
||||
|
||||
if (unit->Type->Revealer) { // Revealers are not drawn
|
||||
DebugLevel3Fn("Drawing revealer %d\n" _C_ UnitNumber(unit));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1887,7 +1883,7 @@ global void DrawUnit(const Unit* unit)
|
|||
#endif
|
||||
|
||||
if ((!UnitVisible(unit, ThisPlayer)) && frame == UnitNotSeen) {
|
||||
DebugLevel0Fn("FIXME: Something is wrong, unit %d not seen but drawn time %lu?.\n" _C_
|
||||
DebugPrint("FIXME: Something is wrong, unit %d not seen but drawn time %lu?.\n" _C_
|
||||
unit->Slot _C_ GameCycle);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ global Unit* TargetOnMapTile(const Unit* source, int tx, int ty)
|
|||
if (tx < unit->X || tx >= unit->X + type->TileWidth ||
|
||||
ty < unit->Y || ty >= unit->Y + type->TileHeight) {
|
||||
// When does that happen???
|
||||
DebugLevel0("This is a wierd world");
|
||||
DebugPrint("This is a wierd world");
|
||||
continue;
|
||||
}
|
||||
if (!CanTarget(source->Type, unit->Type)) {
|
||||
|
@ -751,8 +751,6 @@ global Unit* AttackUnitsInDistance(Unit* unit, int range)
|
|||
const Player* player;
|
||||
Unit* best_unit;
|
||||
|
||||
DebugLevel3Fn("(%d)%s\n" _C_ UnitNumber(unit) _C_ unit->Type->Ident);
|
||||
|
||||
// if necessary, take possible damage on allied units into account...
|
||||
if (unit->Type->Missile.Missile->Range > 1 &&
|
||||
(range + unit->Type->Missile.Missile->Range < 15)) {
|
||||
|
@ -829,7 +827,6 @@ global Unit* AttackUnitsInDistance(Unit* unit, int range)
|
|||
cost -= CANATTACK_BONUS;
|
||||
}
|
||||
|
||||
DebugLevel3Fn("%s -> %s\t%08x\n" _C_ type->Ident _C_ dtype->Ident _C_ cost);
|
||||
//
|
||||
// Take this target?
|
||||
//
|
||||
|
@ -840,13 +837,6 @@ global Unit* AttackUnitsInDistance(Unit* unit, int range)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (best_unit) {
|
||||
DebugLevel3Fn("Attacking (%d)%s -> %s\n" _C_ UnitNumber(unit) _C_
|
||||
unit->Type->Ident _C_ best_unit->Type->Ident);
|
||||
}
|
||||
*/
|
||||
|
||||
return best_unit;
|
||||
}
|
||||
|
||||
|
@ -864,7 +854,7 @@ global Unit* AttackUnitsInRange(Unit* unit)
|
|||
//
|
||||
#ifdef DEBUG
|
||||
if (!unit->Type->CanAttack) {
|
||||
DebugLevel0Fn("Should be handled by caller?\n");
|
||||
DebugPrint("Should be handled by caller?\n");
|
||||
Assert(0);
|
||||
return NoUnitP;
|
||||
}
|
||||
|
@ -891,7 +881,7 @@ global Unit* AttackUnitsInReactRange(Unit* unit)
|
|||
type = unit->Type;
|
||||
#ifdef DEBUG
|
||||
if (!type->CanAttack) {
|
||||
DebugLevel0Fn("Should be handled by caller?\n");
|
||||
DebugPrint("Should be handled by caller?\n");
|
||||
Assert(0);
|
||||
return NoUnitP;
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ global void UpdateStats(int reset)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
DebugLevel1Fn("Where moves this unit?\n");
|
||||
DebugPrint("Where moves this unit?\n");
|
||||
type->MovementMask = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ global void UpdateStats(int reset)
|
|||
type->FieldFlags = MapFieldSeaUnit;
|
||||
break;
|
||||
default:
|
||||
DebugLevel1Fn("Where moves this unit?\n");
|
||||
DebugPrint("Where moves this unit?\n");
|
||||
type->FieldFlags = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -281,12 +281,12 @@ global void ParsePudUDTA(const char* udta, int length __attribute__((unused)))
|
|||
// FIXME: not the fastest, remove UnitTypeByWcNum from loops!
|
||||
#ifdef DEBUG
|
||||
if (length != 5694 && length != 5948) {
|
||||
DebugLevel0("\n***\n");
|
||||
DebugLevel0Fn("%d\n" _C_ length);
|
||||
DebugLevel0("***\n\n");
|
||||
DebugPrint("\n***\n");
|
||||
DebugPrint("%d\n" _C_ length);
|
||||
DebugPrint("***\n\n");
|
||||
}
|
||||
#endif
|
||||
DebugLevel0Fn("This PUD has an UDTA section, we are not sure it works.\n");
|
||||
DebugPrint("This PUD has an UDTA section, we are not sure it works.\n");
|
||||
start = udta;
|
||||
|
||||
for (i = 0; i < 110; ++i) { // overlap frames
|
||||
|
@ -502,10 +502,10 @@ global void ParsePudUDTA(const char* udta, int length __attribute__((unused)))
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (BIT(28, v)) DebugLevel0("Unused bit 28 used in %d\n" _C_ i);
|
||||
if (BIT(29, v)) DebugLevel0("Unused bit 29 used in %d\n" _C_ i);
|
||||
if (BIT(30, v)) DebugLevel0("Unused bit 30 used in %d\n" _C_ i);
|
||||
if (BIT(31, v)) DebugLevel0("Unused bit 31 used in %d\n" _C_ i);
|
||||
if (BIT(28, v)) DebugPrint("Unused bit 28 used in %d\n" _C_ i);
|
||||
if (BIT(29, v)) DebugPrint("Unused bit 29 used in %d\n" _C_ i);
|
||||
if (BIT(30, v)) DebugPrint("Unused bit 30 used in %d\n" _C_ i);
|
||||
if (BIT(31, v)) DebugPrint("Unused bit 31 used in %d\n" _C_ i);
|
||||
#endif
|
||||
#undef BIT
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ global void ParsePudUDTA(const char* udta, int length __attribute__((unused)))
|
|||
// FIXME: peon applies also to peon-with-gold and peon-with-wood
|
||||
// FIXME: oil-tanker applies also to oil-tanker-full
|
||||
|
||||
DebugLevel0("\tUDTA used %d bytes\n" _C_ udta-start);
|
||||
DebugPrint("\tUDTA used %d bytes\n" _C_ udta-start);
|
||||
|
||||
UpdateStats(1);
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ global Animations* AnimationsByIdent(const char* ident)
|
|||
if (tmp) {
|
||||
return *tmp;
|
||||
}
|
||||
DebugLevel0Fn("Warning animation `%s' not found\n" _C_ ident);
|
||||
DebugPrint("Warning animation `%s' not found\n" _C_ ident);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -666,8 +666,6 @@ global UnitType* NewUnitTypeSlot(char* ident)
|
|||
ExitFatal(-1);
|
||||
}
|
||||
type->Slot = NumUnitTypes;
|
||||
DebugLevel3Fn("Making a new unit, called %s, branded %d\n" _C_
|
||||
ident _C_ type->Type);
|
||||
type->Ident = ident;
|
||||
UnitTypes[NumUnitTypes++] = type;
|
||||
*(UnitType**)hash_add(UnitTypeHash, type->Ident) = type;
|
||||
|
@ -866,7 +864,7 @@ global void CleanUnitTypes(void)
|
|||
int res;
|
||||
Animations* anims;
|
||||
|
||||
DebugLevel0Fn("FIXME: icon, sounds not freed.\n");
|
||||
DebugPrint("FIXME: icon, sounds not freed.\n");
|
||||
|
||||
//
|
||||
// Mapping the original unit-type numbers in puds to our internal strings
|
||||
|
|
|
@ -115,13 +115,13 @@ local Upgrade* AddUpgrade(const char* ident, const char* icon,
|
|||
// Check for free slot.
|
||||
|
||||
if (NumUpgrades == UpgradeMax) {
|
||||
DebugLevel0Fn("Upgrades limit reached.\n");
|
||||
DebugPrint("Upgrades limit reached.\n");
|
||||
return NULL;
|
||||
}
|
||||
// Fill upgrade structure
|
||||
|
||||
if ((tmp = (Upgrade**)hash_find(UpgradeHash, (char*)ident)) && *tmp) {
|
||||
DebugLevel0Fn("Already defined upgrade `%s'\n" _C_ ident);
|
||||
DebugPrint("Already defined upgrade `%s'\n" _C_ ident);
|
||||
upgrade = *tmp;
|
||||
free(upgrade->Icon.Name);
|
||||
} else {
|
||||
|
@ -160,7 +160,7 @@ global Upgrade* UpgradeByIdent(const char* ident)
|
|||
return *upgrade;
|
||||
}
|
||||
|
||||
DebugLevel0Fn(" upgrade %s not found\n" _C_ ident);
|
||||
DebugPrint(" upgrade %s not found\n" _C_ ident);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ global void ParsePudALOW(const char* alow, int length __attribute__((unused)))
|
|||
int b;
|
||||
Player* player;
|
||||
|
||||
DebugLevel0Fn(" Length %d FIXME: constant must be moved to ccl\n" _C_ length);
|
||||
DebugPrint(" Length %d FIXME: constant must be moved to ccl\n" _C_ length);
|
||||
|
||||
//
|
||||
// Allow units
|
||||
|
@ -510,7 +510,6 @@ global void ParsePudUGRD(const char* ugrd, int length __attribute__((unused)))
|
|||
int flags;
|
||||
int costs[MaxCosts];
|
||||
|
||||
DebugLevel3Fn(" Length %d\n" _C_ length);
|
||||
Assert(length == 780);
|
||||
|
||||
for (i = 0; i < 52; ++i) {
|
||||
|
@ -521,9 +520,6 @@ global void ParsePudUGRD(const char* ugrd, int length __attribute__((unused)))
|
|||
icon = AccessLE16( ugrd + 52 + (i + 52 + 52 + 52) * 2);
|
||||
group = AccessLE16( ugrd + 52 + (i + 52 + 52 + 52 + 52) * 2);
|
||||
flags = AccessLE16( ugrd + 52 + (i + 52 + 52 + 52 + 52 + 52) * 2);
|
||||
DebugLevel3Fn(" (%d)%s %d,%d,%d,%d (%d)%s %d %08X\n" _C_
|
||||
i _C_ UpgradeWcNames[i] _C_ time _C_ gold _C_ lumber _C_ oil _C_
|
||||
icon _C_ IconWcNames[icon] _C_ group _C_ flags);
|
||||
|
||||
memset(costs, 0, sizeof(costs));
|
||||
costs[TimeCost] = time;
|
||||
|
@ -690,7 +686,6 @@ local int CclDefineModifier(lua_State* l)
|
|||
lua_rawgeti(l, j + 1, 2);
|
||||
value = LuaToString(l, -1);
|
||||
lua_pop(l, 1);
|
||||
DebugLevel3Fn("%s\n" _C_ value);
|
||||
if (!strncmp(value, "unit-", 5)) {
|
||||
lua_rawgeti(l, j + 1, 3);
|
||||
units[UnitTypeIdByIdent(value)] = LuaToNumber(l, -1);
|
||||
|
@ -702,7 +697,6 @@ local int CclDefineModifier(lua_State* l)
|
|||
lua_rawgeti(l, j + 1, 2);
|
||||
value = LuaToString(l, -1);
|
||||
lua_pop(l, 1);
|
||||
DebugLevel3Fn("%s\n" _C_ value);
|
||||
if (!strncmp(value, "upgrade-", 8)) {
|
||||
lua_rawgeti(l, j + 1, 3);
|
||||
upgrades[UpgradeIdByIdent(value)] = LuaToNumber(l, -1);
|
||||
|
@ -808,7 +802,7 @@ local int CclDefineUnitAllow(lua_State* l)
|
|||
++j;
|
||||
|
||||
if (strncmp(ident, "unit-", 5)) {
|
||||
DebugLevel0Fn(" wrong ident %s\n" _C_ ident);
|
||||
DebugPrint(" wrong ident %s\n" _C_ ident);
|
||||
return 0;
|
||||
}
|
||||
id = UnitTypeIdByIdent(ident);
|
||||
|
@ -862,7 +856,7 @@ local int CclDefineAllow(lua_State* l)
|
|||
AllowUpgradeId(&Players[i], id, ids[i]);
|
||||
}
|
||||
} else {
|
||||
DebugLevel0Fn(" wrong ident %s\n" _C_ ident);
|
||||
DebugPrint(" wrong ident %s\n" _C_ ident);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1056,7 +1050,6 @@ local int AddUpgradeModifier(int uid, int attack_range, int sight_range,
|
|||
for (s2 = strtok(s1, ","); s2; s2 = strtok(NULL, ",")) {
|
||||
int id;
|
||||
|
||||
DebugLevel3Fn(" %s\n" _C_ s2);
|
||||
id = UnitTypeIdByIdent(s2);
|
||||
if (id == -1) {
|
||||
break; // cade: should we cancel all and return error?!
|
||||
|
@ -1091,7 +1084,7 @@ global int UnitTypeIdByIdent(const char* ident)
|
|||
if ((type = UnitTypeByIdent(ident))) {
|
||||
return type->Slot;
|
||||
}
|
||||
DebugLevel0Fn(" fix this %s\n" _C_ ident);
|
||||
DebugPrint(" fix this %s\n" _C_ ident);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1109,7 +1102,7 @@ global int UpgradeIdByIdent(const char* ident)
|
|||
if (upgrade) {
|
||||
return upgrade - Upgrades;
|
||||
}
|
||||
DebugLevel0Fn(" fix this %s\n" _C_ ident);
|
||||
DebugPrint(" fix this %s\n" _C_ ident);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1232,7 +1225,6 @@ local void ApplyUpgradeModifier(Player* player, const UpgradeModifier* um)
|
|||
// this modifier should be applied to unittype id == z
|
||||
if (um->ApplyTo[z] == 'X') {
|
||||
|
||||
DebugLevel3Fn(" applied to %d\n" _C_ z);
|
||||
// upgrade stats
|
||||
UnitTypes[z]->Stats[pn].AttackRange += um->Modifier.AttackRange;
|
||||
UnitTypes[z]->Stats[pn].SightRange += um->Modifier.SightRange;
|
||||
|
@ -1392,7 +1384,7 @@ global char UpgradeIdentAllowed(const Player* player, const char* ident)
|
|||
if ((id = UpgradeIdByIdent(ident)) != -1) {
|
||||
return UpgradeIdAllowed(player, id);
|
||||
}
|
||||
DebugLevel0Fn("Fix your code, wrong idenifier `%s'\n" _C_ ident);
|
||||
DebugPrint("Fix your code, wrong idenifier `%s'\n" _C_ ident);
|
||||
return '-';
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ global CursorType* CursorTypeByIdent(const char* ident)
|
|||
return cursortype;
|
||||
}
|
||||
}
|
||||
DebugLevel0Fn("Cursor `%s' not found, please check your code.\n" _C_ ident);
|
||||
DebugPrint("Cursor `%s' not found, please check your code.\n" _C_ ident);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ local int DoDrawText(int x, int y, unsigned font, const unsigned char* text,
|
|||
if (*text == '~') {
|
||||
switch (*++text) {
|
||||
case '\0': // wrong formated string.
|
||||
DebugLevel0Fn("oops, format your ~\n");
|
||||
DebugPrint("oops, format your ~\n");
|
||||
return widths;
|
||||
case '~':
|
||||
break;
|
||||
|
@ -351,7 +351,7 @@ local int DoDrawText(int x, int y, unsigned font, const unsigned char* text,
|
|||
++p;
|
||||
}
|
||||
if (!*p) {
|
||||
DebugLevel0Fn("oops, format your ~\n");
|
||||
DebugPrint("oops, format your ~\n");
|
||||
return widths;
|
||||
}
|
||||
color = malloc(p - text + 1);
|
||||
|
|
|
@ -247,7 +247,7 @@ global int PlayMovie(const char* name, int flags)
|
|||
// Prepare video
|
||||
//
|
||||
if (flags & PlayMovieFullScreen) {
|
||||
DebugLevel0Fn("FIXME: full screen switch not supported\n");
|
||||
DebugPrint("FIXME: full screen switch not supported\n");
|
||||
}
|
||||
overlay = SDL_CreateYUVOverlay(avi->Width, avi->Height,
|
||||
SDL_YV12_OVERLAY, TheScreen);
|
||||
|
@ -256,7 +256,7 @@ global int PlayMovie(const char* name, int flags)
|
|||
exit(1);
|
||||
}
|
||||
if (overlay->hw_overlay) {
|
||||
DebugLevel0Fn("Got a hardware overlay.\n");
|
||||
DebugPrint("Got a hardware overlay.\n");
|
||||
}
|
||||
oldspeed = VideoSyncSpeed;
|
||||
VideoSyncSpeed = avi->FPS100 / FRAMES_PER_SECOND;
|
||||
|
@ -286,7 +286,7 @@ global int PlayMovie(const char* name, int flags)
|
|||
|
||||
wa = VideoWidth * 100 / avi->Width;
|
||||
ha = VideoHeight * 100 / avi->Height;
|
||||
DebugLevel0Fn(" %d x %d\n" _C_ wa _C_ ha);
|
||||
DebugPrint(" %d x %d\n" _C_ wa _C_ ha);
|
||||
if (wa < ha) { // Keep the aspect ratio
|
||||
rect.w = VideoWidth;
|
||||
rect.h = avi->Height * wa / 100;
|
||||
|
@ -309,7 +309,7 @@ global int PlayMovie(const char* name, int flags)
|
|||
int i;
|
||||
|
||||
GetPbParam(pbi, PBC_SET_POSTPROC, &i);
|
||||
DebugLevel0Fn("Postprocess level %d\n" _C_ i);
|
||||
DebugPrint("Postprocess level %d\n" _C_ i);
|
||||
SetPbParam(pbi, PBC_SET_POSTPROC, 6);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ global void SetVideoSync(void)
|
|||
|
||||
FrameTicks = ms / 10;
|
||||
FrameRemainder = ms % 10;
|
||||
DebugLevel0Fn("frames %d - %d.%dms\n" _C_ SkipFrames _C_ ms / 10 _C_ ms % 10);
|
||||
DebugPrint("frames %d - %d.%dms\n" _C_ SkipFrames _C_ ms / 10 _C_ ms % 10);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -255,8 +255,6 @@ global void InitVideoSdl(void)
|
|||
ColorGreen = VideoMapRGB(TheScreen->format, 0, 252, 0);
|
||||
ColorYellow = VideoMapRGB(TheScreen->format, 252, 252, 0);
|
||||
|
||||
DebugLevel3Fn("Video init ready %d %d\n" _C_ VideoDepth _C_ VideoBpp);
|
||||
|
||||
TheUI.MouseWarpX = TheUI.MouseWarpY = -1;
|
||||
}
|
||||
|
||||
|
@ -499,7 +497,6 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
{
|
||||
switch (event->type) {
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
DebugLevel3("\tbutton press %d\n" _C_ event->button.button);
|
||||
//
|
||||
// SDL has already a good order of the buttons.
|
||||
//
|
||||
|
@ -508,7 +505,6 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
DebugLevel3("\tbutton release %d\n" _C_ event->button.button);
|
||||
//
|
||||
// SDL has already a good order of the buttons.
|
||||
//
|
||||
|
@ -519,8 +515,6 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
// FIXME: check if this is only useful for the cursor
|
||||
// FIXME: if this is the case we don't need this.
|
||||
case SDL_MOUSEMOTION:
|
||||
DebugLevel3("\tmotion notify %d,%d\n" _C_ event->motion.x _C_
|
||||
event->motion.y);
|
||||
InputMouseMove(callbacks, SDL_GetTicks(),
|
||||
event->motion.x, event->motion.y);
|
||||
// FIXME: Same bug fix from X11
|
||||
|
@ -542,7 +536,6 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
if (event->active.state & SDL_APPMOUSEFOCUS) {
|
||||
static int InMainWindow = 1;
|
||||
|
||||
DebugLevel3("\tMouse focus changed\n");
|
||||
if (InMainWindow && !event->active.gain) {
|
||||
InputMouseExit(callbacks, SDL_GetTicks());
|
||||
}
|
||||
|
@ -551,7 +544,6 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
if (event->active.state & SDL_APPACTIVE) {
|
||||
static int IsVisible = 1;
|
||||
|
||||
DebugLevel3("\tApp focus changed\n");
|
||||
if (IsVisible && !event->active.gain) {
|
||||
IsVisible = 0;
|
||||
UiTogglePause();
|
||||
|
@ -563,12 +555,10 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
DebugLevel3("\tKey press\n");
|
||||
SdlHandleKeyPress(callbacks, &event->key.keysym);
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
DebugLevel3("\tKey release\n");
|
||||
SdlHandleKeyRelease(callbacks, &event->key.keysym);
|
||||
break;
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ global void SetClipping(int left, int top, int right, int bottom)
|
|||
if (left > right || top > bottom || left < 0 || left >= VideoWidth ||
|
||||
top < 0 || top >= VideoHeight || right < 0 ||
|
||||
right >= VideoWidth || bottom < 0 || bottom >= VideoHeight) {
|
||||
DebugLevel0Fn("Wrong clipping %d->%d %d->%d, write cleaner code.\n" _C_
|
||||
DebugPrint("Wrong clipping %d->%d %d->%d, write cleaner code.\n" _C_
|
||||
left _C_ right _C_ top _C_ bottom);
|
||||
// Assert(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue