Use nullptr
instead of NULL
.
This commit is contained in:
parent
8720f1fbb0
commit
390b143f3d
169 changed files with 1131 additions and 1131 deletions
|
@ -333,8 +333,8 @@ bool COrder_Attack::IsAttackGroundOrWall() const
|
||||||
|
|
||||||
CUnit *const COrder_Attack::BestTarget(const CUnit &unit, CUnit *const target1, CUnit *const target2) const
|
CUnit *const COrder_Attack::BestTarget(const CUnit &unit, CUnit *const target1, CUnit *const target2) const
|
||||||
{
|
{
|
||||||
Assert(target1 != NULL);
|
Assert(target1 != nullptr);
|
||||||
Assert(target2 != NULL);
|
Assert(target2 != nullptr);
|
||||||
|
|
||||||
return (GameSettings.SimplifiedAutoTargeting
|
return (GameSettings.SimplifiedAutoTargeting
|
||||||
? ((TargetPriorityCalculate(&unit, target1) > TargetPriorityCalculate(&unit, target2)) ? target1 : target2)
|
? ((TargetPriorityCalculate(&unit, target1) > TargetPriorityCalculate(&unit, target2)) ? target1 : target2)
|
||||||
|
@ -350,7 +350,7 @@ CUnit *const COrder_Attack::BestTarget(const CUnit &unit, CUnit *const target1,
|
||||||
*/
|
*/
|
||||||
void COrder_Attack::OfferNewTarget(const CUnit &unit, CUnit *const target)
|
void COrder_Attack::OfferNewTarget(const CUnit &unit, CUnit *const target)
|
||||||
{
|
{
|
||||||
Assert(target != NULL);
|
Assert(target != nullptr);
|
||||||
Assert(this->IsAutoTargeting() || unit.Player->AiEnabled);
|
Assert(this->IsAutoTargeting() || unit.Player->AiEnabled);
|
||||||
|
|
||||||
/// if attacker cant't move (stand_ground, building, in a bunker or transport)
|
/// if attacker cant't move (stand_ground, building, in a bunker or transport)
|
||||||
|
@ -358,10 +358,10 @@ void COrder_Attack::OfferNewTarget(const CUnit &unit, CUnit *const target)
|
||||||
if (immobile && !InAttackRange(unit, *target)) {
|
if (immobile && !InAttackRange(unit, *target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CUnit *best = (this->offeredTarget != NULL && this->offeredTarget->IsVisibleAsGoal(*unit.Player))
|
CUnit *best = (this->offeredTarget != nullptr && this->offeredTarget->IsVisibleAsGoal(*unit.Player))
|
||||||
? BestTarget(unit, this->offeredTarget, target)
|
? BestTarget(unit, this->offeredTarget, target)
|
||||||
: target;
|
: target;
|
||||||
if (this->offeredTarget != NULL) {
|
if (this->offeredTarget != nullptr) {
|
||||||
this->offeredTarget.Reset();
|
this->offeredTarget.Reset();
|
||||||
}
|
}
|
||||||
this->offeredTarget = best;
|
this->offeredTarget = best;
|
||||||
|
@ -404,7 +404,7 @@ bool COrder_Attack::CheckIfGoalValid(CUnit &unit)
|
||||||
** Turn unit to Target or position on map for attack.
|
** Turn unit to Target or position on map for attack.
|
||||||
**
|
**
|
||||||
** @param unit Unit to turn.
|
** @param unit Unit to turn.
|
||||||
** @param target Turn to this Target. If NULL then turn to goalPos.
|
** @param target Turn to this Target. If nullptr then turn to goalPos.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
void COrder_Attack::TurnToTarget(CUnit &unit, const CUnit *target)
|
void COrder_Attack::TurnToTarget(CUnit &unit, const CUnit *target)
|
||||||
|
@ -434,7 +434,7 @@ void COrder_Attack::TurnToTarget(CUnit &unit, const CUnit *target)
|
||||||
** Also if there is no active target Attack-Move action will be saved.
|
** Also if there is no active target Attack-Move action will be saved.
|
||||||
**
|
**
|
||||||
** @param unit Attacker.
|
** @param unit Attacker.
|
||||||
** @param target Turn to this Target. If NULL then turn to goalPos.
|
** @param target Turn to this Target. If nullptr then turn to goalPos.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
void COrder_Attack::SetAutoTarget(CUnit &unit, CUnit *target)
|
void COrder_Attack::SetAutoTarget(CUnit &unit, CUnit *target)
|
||||||
|
@ -473,12 +473,12 @@ bool COrder_Attack::AutoSelectTarget(CUnit &unit)
|
||||||
// if unit can't attack, or if unit is not bunkered and removed - exit, no targets
|
// if unit can't attack, or if unit is not bunkered and removed - exit, no targets
|
||||||
if (unit.Type->CanAttack == false
|
if (unit.Type->CanAttack == false
|
||||||
|| (unit.Removed
|
|| (unit.Removed
|
||||||
&& (unit.Container == NULL || unit.Container->Type->BoolFlag[ATTACKFROMTRANSPORTER_INDEX].value == false))) {
|
&& (unit.Container == nullptr || unit.Container->Type->BoolFlag[ATTACKFROMTRANSPORTER_INDEX].value == false))) {
|
||||||
this->offeredTarget.Reset();
|
this->offeredTarget.Reset();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CUnit *goal = this->GetGoal();
|
CUnit *goal = this->GetGoal();
|
||||||
CUnit *newTarget = NULL;
|
CUnit *newTarget = nullptr;
|
||||||
if (unit.Selected)
|
if (unit.Selected)
|
||||||
{
|
{
|
||||||
DebugPrint("UnderAttack counter: %d \n" _C_ unit.UnderAttack);
|
DebugPrint("UnderAttack counter: %d \n" _C_ unit.UnderAttack);
|
||||||
|
@ -492,7 +492,7 @@ bool COrder_Attack::AutoSelectTarget(CUnit &unit)
|
||||||
newTarget = AttackUnitsInReactRange(unit); // search for enemies in reaction range
|
newTarget = AttackUnitsInReactRange(unit); // search for enemies in reaction range
|
||||||
}
|
}
|
||||||
/// If we have target offered from outside - try it
|
/// If we have target offered from outside - try it
|
||||||
if (this->offeredTarget != NULL) {
|
if (this->offeredTarget != nullptr) {
|
||||||
if (this->offeredTarget->IsVisibleAsGoal(*unit.Player)
|
if (this->offeredTarget->IsVisibleAsGoal(*unit.Player)
|
||||||
&& (!immobile || InAttackRange(unit, *this->offeredTarget))) {
|
&& (!immobile || InAttackRange(unit, *this->offeredTarget))) {
|
||||||
|
|
||||||
|
@ -759,7 +759,7 @@ void COrder_Attack::MoveToTarget(CUnit &unit)
|
||||||
&& InAttackRange(unit, this->goalPos)) {
|
&& InAttackRange(unit, this->goalPos)) {
|
||||||
|
|
||||||
// Reached wall or ground, now attacking it
|
// Reached wall or ground, now attacking it
|
||||||
TurnToTarget(unit, NULL);
|
TurnToTarget(unit, nullptr);
|
||||||
this->State &= AUTO_TARGETING;
|
this->State &= AUTO_TARGETING;
|
||||||
this->State |= ATTACK_TARGET;
|
this->State |= ATTACK_TARGET;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -223,7 +223,7 @@ static void EnterTransporter(CUnit &unit, COrder_Board &order)
|
||||||
{
|
{
|
||||||
CUnit *transporter = order.GetGoal();
|
CUnit *transporter = order.GetGoal();
|
||||||
|
|
||||||
Assert(transporter != NULL);
|
Assert(transporter != nullptr);
|
||||||
|
|
||||||
if (!transporter->IsVisibleAsGoal(*unit.Player)) {
|
if (!transporter->IsVisibleAsGoal(*unit.Player)) {
|
||||||
DebugPrint("Transporter gone\n");
|
DebugPrint("Transporter gone\n");
|
||||||
|
|
|
@ -100,7 +100,7 @@ enum {
|
||||||
file.printf(" \"range\", %d,", this->Range);
|
file.printf(" \"range\", %d,", this->Range);
|
||||||
file.printf(" \"tile\", {%d, %d},", this->goalPos.x, this->goalPos.y);
|
file.printf(" \"tile\", {%d, %d},", this->goalPos.x, this->goalPos.y);
|
||||||
|
|
||||||
if (this->BuildingUnit != NULL) {
|
if (this->BuildingUnit != nullptr) {
|
||||||
file.printf(" \"building\", \"%s\",", UnitReference(this->BuildingUnit).c_str());
|
file.printf(" \"building\", \"%s\",", UnitReference(this->BuildingUnit).c_str());
|
||||||
}
|
}
|
||||||
file.printf(" \"type\", \"%s\",", this->Type->Ident.c_str());
|
file.printf(" \"type\", \"%s\",", this->Type->Ident.c_str());
|
||||||
|
@ -172,7 +172,7 @@ void COrder_Build::AiUnitKilled(CUnit &unit)
|
||||||
DebugPrint("%d: %d(%s) killed, with order %s!\n" _C_
|
DebugPrint("%d: %d(%s) killed, with order %s!\n" _C_
|
||||||
unit.Player->Index _C_ UnitNumber(unit) _C_
|
unit.Player->Index _C_ UnitNumber(unit) _C_
|
||||||
unit.Type->Ident.c_str() _C_ this->Type->Ident.c_str());
|
unit.Type->Ident.c_str() _C_ this->Type->Ident.c_str());
|
||||||
if (this->BuildingUnit == NULL) {
|
if (this->BuildingUnit == nullptr) {
|
||||||
AiReduceMadeInBuilt(*unit.Player->Ai, *this->Type);
|
AiReduceMadeInBuilt(*unit.Player->Ai, *this->Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
||||||
|
|
||||||
CUnit *ontop = CanBuildUnitType(&unit, type, pos, 1);
|
CUnit *ontop = CanBuildUnitType(&unit, type, pos, 1);
|
||||||
|
|
||||||
if (ontop != NULL) {
|
if (ontop != nullptr) {
|
||||||
return ontop;
|
return ontop;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -285,7 +285,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
||||||
* enabled/disable via game lua scripting
|
* enabled/disable via game lua scripting
|
||||||
*/
|
*/
|
||||||
CUnit *building = AlreadyBuildingFinder(unit, type).Find(Map.Field(pos));
|
CUnit *building = AlreadyBuildingFinder(unit, type).Find(Map.Field(pos));
|
||||||
if (building != NULL) {
|
if (building != nullptr) {
|
||||||
if (unit.CurrentOrder() == this) {
|
if (unit.CurrentOrder() == this) {
|
||||||
DebugPrint("%d: Worker [%d] is helping build: %s [%d]\n"
|
DebugPrint("%d: Worker [%d] is helping build: %s [%d]\n"
|
||||||
_C_ unit.Player->Index _C_ unit.Slot
|
_C_ unit.Player->Index _C_ unit.Slot
|
||||||
|
@ -294,7 +294,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
||||||
|
|
||||||
delete this; // Bad
|
delete this; // Bad
|
||||||
unit.Orders[0] = COrder::NewActionRepair(unit, *building);
|
unit.Orders[0] = COrder::NewActionRepair(unit, *building);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -303,7 +303,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
||||||
// To keep the load low, retry each 10 cycles
|
// To keep the load low, retry each 10 cycles
|
||||||
// NOTE: we can already inform the AI about this problem?
|
// NOTE: we can already inform the AI about this problem?
|
||||||
unit.Wait = 10;
|
unit.Wait = 10;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ bool COrder_Build::StartBuilding(CUnit &unit, CUnit &ontop)
|
||||||
CUnit *build = MakeUnit(const_cast<CUnitType &>(type), unit.Player);
|
CUnit *build = MakeUnit(const_cast<CUnitType &>(type), unit.Player);
|
||||||
|
|
||||||
// If unable to make unit, stop, and report message
|
// If unable to make unit, stop, and report message
|
||||||
if (build == NULL) {
|
if (build == nullptr) {
|
||||||
// FIXME: Should we retry this?
|
// FIXME: Should we retry this?
|
||||||
unit.Player->Notify(NotifyYellow, unit.tilePos,
|
unit.Player->Notify(NotifyYellow, unit.tilePos,
|
||||||
_("Unable to create building %s"), type.Name.c_str());
|
_("Unable to create building %s"), type.Name.c_str());
|
||||||
|
@ -339,7 +339,7 @@ bool COrder_Build::StartBuilding(CUnit &unit, CUnit &ontop)
|
||||||
build->Variable[GIVERESOURCE_INDEX].Value = ontop.Variable[GIVERESOURCE_INDEX].Value;
|
build->Variable[GIVERESOURCE_INDEX].Value = ontop.Variable[GIVERESOURCE_INDEX].Value;
|
||||||
build->Variable[GIVERESOURCE_INDEX].Max = ontop.Variable[GIVERESOURCE_INDEX].Max;
|
build->Variable[GIVERESOURCE_INDEX].Max = ontop.Variable[GIVERESOURCE_INDEX].Max;
|
||||||
build->Variable[GIVERESOURCE_INDEX].Enable = ontop.Variable[GIVERESOURCE_INDEX].Enable;
|
build->Variable[GIVERESOURCE_INDEX].Enable = ontop.Variable[GIVERESOURCE_INDEX].Enable;
|
||||||
ontop.Remove(NULL); // Destroy building beneath
|
ontop.Remove(nullptr); // Destroy building beneath
|
||||||
UnitLost(ontop);
|
UnitLost(ontop);
|
||||||
UnitClearOrders(ontop);
|
UnitClearOrders(ontop);
|
||||||
ontop.Release();
|
ontop.Release();
|
||||||
|
@ -394,7 +394,7 @@ static void AnimateActionBuild(CUnit &unit)
|
||||||
{
|
{
|
||||||
CAnimations *animations = unit.Type->Animations;
|
CAnimations *animations = unit.Type->Animations;
|
||||||
|
|
||||||
if (animations == NULL) {
|
if (animations == nullptr) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
if (animations->Build) {
|
if (animations->Build) {
|
||||||
|
@ -414,7 +414,7 @@ bool COrder_Build::BuildFromOutside(CUnit &unit) const
|
||||||
{
|
{
|
||||||
AnimateActionBuild(unit);
|
AnimateActionBuild(unit);
|
||||||
|
|
||||||
if (this->BuildingUnit == NULL) {
|
if (this->BuildingUnit == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ CUnit *COrder_Build::GetBuildingUnit() const
|
||||||
|
|
||||||
/* virtual */ void COrder_Build::UpdateUnitVariables(CUnit &unit) const
|
/* virtual */ void COrder_Build::UpdateUnitVariables(CUnit &unit) const
|
||||||
{
|
{
|
||||||
if (this->State == State_BuildFromOutside && this->BuildingUnit != NULL) {
|
if (this->State == State_BuildFromOutside && this->BuildingUnit != nullptr) {
|
||||||
unit.Variable[TRAINING_INDEX].Value = this->BuildingUnit->Variable[BUILD_INDEX].Value;
|
unit.Variable[TRAINING_INDEX].Value = this->BuildingUnit->Variable[BUILD_INDEX].Value;
|
||||||
unit.Variable[TRAINING_INDEX].Max = this->BuildingUnit->Variable[BUILD_INDEX].Max;
|
unit.Variable[TRAINING_INDEX].Max = this->BuildingUnit->Variable[BUILD_INDEX].Max;
|
||||||
}
|
}
|
||||||
|
@ -464,7 +464,7 @@ CUnit *COrder_Build::GetBuildingUnit() const
|
||||||
}
|
}
|
||||||
CUnit *ontop = this->CheckCanBuild(unit);
|
CUnit *ontop = this->CheckCanBuild(unit);
|
||||||
|
|
||||||
if (ontop != NULL) {
|
if (ontop != nullptr) {
|
||||||
this->StartBuilding(unit, *ontop);
|
this->StartBuilding(unit, *ontop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ CUnit *COrder_Build::GetBuildingUnit() const
|
||||||
|
|
||||||
/* virtual */ void COrder_Build::Cancel(CUnit &unit)
|
/* virtual */ void COrder_Build::Cancel(CUnit &unit)
|
||||||
{
|
{
|
||||||
if (this->State == State_BuildFromOutside && this->BuildingUnit != NULL && this->BuildingUnit->CurrentAction() == UnitActionBuilt) {
|
if (this->State == State_BuildFromOutside && this->BuildingUnit != nullptr && this->BuildingUnit->CurrentAction() == UnitActionBuilt) {
|
||||||
COrder_Built &targetOrder = *static_cast<COrder_Built *>(this->BuildingUnit->CurrentOrder());
|
COrder_Built &targetOrder = *static_cast<COrder_Built *>(this->BuildingUnit->CurrentOrder());
|
||||||
targetOrder.Cancel(*this->BuildingUnit);
|
targetOrder.Cancel(*this->BuildingUnit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);
|
||||||
cframe = cframe->Next;
|
cframe = cframe->Next;
|
||||||
++frame;
|
++frame;
|
||||||
}
|
}
|
||||||
if (this->Worker != NULL) {
|
if (this->Worker != nullptr) {
|
||||||
file.printf("\"worker\", \"%s\", ", UnitReference(this->Worker).c_str());
|
file.printf("\"worker\", \"%s\", ", UnitReference(this->Worker).c_str());
|
||||||
}
|
}
|
||||||
file.printf("\"progress\", %d, \"frame\", %d", this->ProgressCounter, frame);
|
file.printf("\"progress\", %d, \"frame\", %d", this->ProgressCounter, frame);
|
||||||
|
@ -109,7 +109,7 @@ extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);
|
||||||
++j;
|
++j;
|
||||||
int frame = LuaToNumber(l, -1, j + 1);
|
int frame = LuaToNumber(l, -1, j + 1);
|
||||||
CConstructionFrame *cframe = unit.Type->Construction->Frames;
|
CConstructionFrame *cframe = unit.Type->Construction->Frames;
|
||||||
while (frame-- && cframe->Next != NULL) {
|
while (frame-- && cframe->Next != nullptr) {
|
||||||
cframe = cframe->Next;
|
cframe = cframe->Next;
|
||||||
}
|
}
|
||||||
this->Frame = cframe;
|
this->Frame = cframe;
|
||||||
|
@ -132,16 +132,16 @@ extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);
|
||||||
|
|
||||||
static void CancelBuilt(COrder_Built &order, CUnit *unit)
|
static void CancelBuilt(COrder_Built &order, CUnit *unit)
|
||||||
{
|
{
|
||||||
Assert(unit == NULL || unit->CurrentOrder() == &order);
|
Assert(unit == nullptr || unit->CurrentOrder() == &order);
|
||||||
CUnit *worker = order.GetWorkerPtr();
|
CUnit *worker = order.GetWorkerPtr();
|
||||||
|
|
||||||
// Drop out unit
|
// Drop out unit
|
||||||
if (worker != NULL && worker->CurrentAction() == UnitActionBuild) {
|
if (worker != nullptr && worker->CurrentAction() == UnitActionBuild) {
|
||||||
worker->ClearAction();
|
worker->ClearAction();
|
||||||
|
|
||||||
DropOutOnSide(*worker, LookingW, unit);
|
DropOutOnSide(*worker, LookingW, unit);
|
||||||
}
|
}
|
||||||
if (unit != NULL) {
|
if (unit != nullptr) {
|
||||||
// Player gets back 75% of the original cost for a building.
|
// Player gets back 75% of the original cost for a building.
|
||||||
unit->Player->AddCostsFactor(unit->Stats->Costs, CancelBuildingCostsFactor);
|
unit->Player->AddCostsFactor(unit->Stats->Costs, CancelBuildingCostsFactor);
|
||||||
// Cancel building
|
// Cancel building
|
||||||
|
@ -169,11 +169,11 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
||||||
}
|
}
|
||||||
CUnit *worker = order.GetWorkerPtr();
|
CUnit *worker = order.GetWorkerPtr();
|
||||||
|
|
||||||
if (worker != NULL) {
|
if (worker != nullptr) {
|
||||||
if (type.BoolFlag[BUILDERLOST_INDEX].value) {
|
if (type.BoolFlag[BUILDERLOST_INDEX].value) {
|
||||||
// Bye bye worker.
|
// Bye bye worker.
|
||||||
LetUnitDie(*worker);
|
LetUnitDie(*worker);
|
||||||
worker = NULL;
|
worker = nullptr;
|
||||||
} else { // Drop out the worker.
|
} else { // Drop out the worker.
|
||||||
worker->ClearAction();
|
worker->ClearAction();
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.AiEnabled) {
|
if (player.AiEnabled) {
|
||||||
/* Worker can be NULL */
|
/* Worker can be nullptr */
|
||||||
AiWorkComplete(worker, unit);
|
AiWorkComplete(worker, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
||||||
// FIXME: Johns: hardcoded unit-type wall / more races!
|
// FIXME: Johns: hardcoded unit-type wall / more races!
|
||||||
if (&type == UnitTypeOrcWall || &type == UnitTypeHumanWall) {
|
if (&type == UnitTypeOrcWall || &type == UnitTypeHumanWall) {
|
||||||
Map.SetWall(unit.tilePos, &type == UnitTypeHumanWall);
|
Map.SetWall(unit.tilePos, &type == UnitTypeHumanWall);
|
||||||
unit.Remove(NULL);
|
unit.Remove(nullptr);
|
||||||
UnitLost(unit);
|
UnitLost(unit);
|
||||||
UnitClearOrders(unit);
|
UnitClearOrders(unit);
|
||||||
unit.Release();
|
unit.Release();
|
||||||
|
@ -253,7 +253,7 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
||||||
|
|
||||||
COrder_Built::~COrder_Built()
|
COrder_Built::~COrder_Built()
|
||||||
{
|
{
|
||||||
CancelBuilt(*this, NULL);
|
CancelBuilt(*this, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ void COrder_Built::Execute(CUnit &unit)
|
/* virtual */ void COrder_Built::Execute(CUnit &unit)
|
||||||
|
@ -351,7 +351,7 @@ void COrder_Built::UpdateConstructionFrame(CUnit &unit)
|
||||||
const int percent = this->ProgressCounter / (type.Stats[unit.Player->Index].Costs[TimeCost] * 6);
|
const int percent = this->ProgressCounter / (type.Stats[unit.Player->Index].Costs[TimeCost] * 6);
|
||||||
const CConstructionFrame *cframe = FindCFramePercent(*type.Construction->Frames, percent);
|
const CConstructionFrame *cframe = FindCFramePercent(*type.Construction->Frames, percent);
|
||||||
|
|
||||||
Assert(cframe != NULL);
|
Assert(cframe != nullptr);
|
||||||
|
|
||||||
if (cframe != this->Frame) {
|
if (cframe != this->Frame) {
|
||||||
this->Frame = cframe;
|
this->Frame = cframe;
|
||||||
|
|
|
@ -197,7 +197,7 @@ enum {
|
||||||
DebugPrint("Goal gone\n");
|
DebugPrint("Goal gone\n");
|
||||||
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
||||||
this->ClearGoal();
|
this->ClearGoal();
|
||||||
goal = NULL;
|
goal = nullptr;
|
||||||
if (this->State == State_Defending) {
|
if (this->State == State_Defending) {
|
||||||
this->Finished = true;
|
this->Finished = true;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -80,7 +80,7 @@ static bool AnimateActionDie(CUnit &unit)
|
||||||
{
|
{
|
||||||
const CAnimations *animations = unit.Type->Animations;
|
const CAnimations *animations = unit.Type->Animations;
|
||||||
|
|
||||||
if (animations == NULL) {
|
if (animations == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (animations->Death[unit.DamagedType]) {
|
if (animations->Death[unit.DamagedType]) {
|
||||||
|
@ -107,8 +107,8 @@ static bool AnimateActionDie(CUnit &unit)
|
||||||
const CUnitType &type = *unit.Type;
|
const CUnitType &type = *unit.Type;
|
||||||
|
|
||||||
// Die sequence terminated, generate corpse.
|
// Die sequence terminated, generate corpse.
|
||||||
if (type.CorpseType == NULL) {
|
if (type.CorpseType == nullptr) {
|
||||||
unit.Remove(NULL);
|
unit.Remove(nullptr);
|
||||||
unit.Release();
|
unit.Release();
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ static bool AnimateActionDie(CUnit &unit)
|
||||||
// We have to unmark BEFORE changing the type.
|
// We have to unmark BEFORE changing the type.
|
||||||
// Always do that, since types can have different vision properties.
|
// Always do that, since types can have different vision properties.
|
||||||
|
|
||||||
unit.Remove(NULL);
|
unit.Remove(nullptr);
|
||||||
unit.Type = &corpseType;
|
unit.Type = &corpseType;
|
||||||
unit.Stats = &corpseType.Stats[unit.Player->Index];
|
unit.Stats = &corpseType.Stats[unit.Player->Index];
|
||||||
UpdateUnitSightRange(unit);
|
UpdateUnitSightRange(unit);
|
||||||
|
|
|
@ -222,7 +222,7 @@ enum {
|
||||||
goal->Variable[MANA_INDEX].Value -= goal->Goal->Type->TeleportCost;
|
goal->Variable[MANA_INDEX].Value -= goal->Goal->Type->TeleportCost;
|
||||||
}
|
}
|
||||||
// Everything is OK, now teleport the unit
|
// Everything is OK, now teleport the unit
|
||||||
unit.Remove(NULL);
|
unit.Remove(nullptr);
|
||||||
if (goal->Type->TeleportEffectIn) {
|
if (goal->Type->TeleportEffectIn) {
|
||||||
goal->Type->TeleportEffectIn->pushPreamble();
|
goal->Type->TeleportEffectIn->pushPreamble();
|
||||||
goal->Type->TeleportEffectIn->pushInteger(UnitNumber(unit));
|
goal->Type->TeleportEffectIn->pushInteger(UnitNumber(unit));
|
||||||
|
@ -232,7 +232,7 @@ enum {
|
||||||
goal->Type->TeleportEffectIn->run();
|
goal->Type->TeleportEffectIn->run();
|
||||||
}
|
}
|
||||||
unit.tilePos = goal->Goal->tilePos;
|
unit.tilePos = goal->Goal->tilePos;
|
||||||
DropOutOnSide(unit, unit.Direction, NULL);
|
DropOutOnSide(unit, unit.Direction, nullptr);
|
||||||
|
|
||||||
// FIXME: we must check if the units supports the new order.
|
// FIXME: we must check if the units supports the new order.
|
||||||
CUnit &dest = *goal->Goal;
|
CUnit &dest = *goal->Goal;
|
||||||
|
@ -245,7 +245,7 @@ enum {
|
||||||
dest.Type->TeleportEffectOut->run();
|
dest.Type->TeleportEffectOut->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest.NewOrder == NULL
|
if (dest.NewOrder == nullptr
|
||||||
|| (dest.NewOrder->Action == UnitActionResource && !unit.Type->BoolFlag[HARVESTER_INDEX].value)
|
|| (dest.NewOrder->Action == UnitActionResource && !unit.Type->BoolFlag[HARVESTER_INDEX].value)
|
||||||
|| (dest.NewOrder->Action == UnitActionAttack && !unit.Type->CanAttack)
|
|| (dest.NewOrder->Action == UnitActionAttack && !unit.Type->CanAttack)
|
||||||
|| (dest.NewOrder->Action == UnitActionBoard && unit.Type->UnitType != UnitTypeLand)) {
|
|| (dest.NewOrder->Action == UnitActionBoard && unit.Type->UnitType != UnitTypeLand)) {
|
||||||
|
@ -255,7 +255,7 @@ enum {
|
||||||
if (dest.NewOrder->HasGoal()) {
|
if (dest.NewOrder->HasGoal()) {
|
||||||
if (dest.NewOrder->GetGoal()->Destroyed) {
|
if (dest.NewOrder->GetGoal()->Destroyed) {
|
||||||
delete dest.NewOrder;
|
delete dest.NewOrder;
|
||||||
dest.NewOrder = NULL;
|
dest.NewOrder = nullptr;
|
||||||
this->Finished = true;
|
this->Finished = true;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ enum {
|
||||||
DebugPrint("Goal gone\n");
|
DebugPrint("Goal gone\n");
|
||||||
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
||||||
this->ClearGoal();
|
this->ClearGoal();
|
||||||
goal = NULL;
|
goal = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.Anim.Unbreakable) {
|
if (unit.Anim.Unbreakable) {
|
||||||
|
@ -293,7 +293,7 @@ enum {
|
||||||
CUnit *target = AttackUnitsInReactRange(unit);
|
CUnit *target = AttackUnitsInReactRange(unit);
|
||||||
if (target) {
|
if (target) {
|
||||||
// Save current command to come back.
|
// Save current command to come back.
|
||||||
COrder *savedOrder = NULL;
|
COrder *savedOrder = nullptr;
|
||||||
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
||||||
savedOrder = this->Clone();
|
savedOrder = this->Clone();
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ enum {
|
||||||
this->Finished = true;
|
this->Finished = true;
|
||||||
unit.Orders.insert(unit.Orders.begin() + 1, COrder::NewActionAttack(unit, target->tilePos));
|
unit.Orders.insert(unit.Orders.begin() + 1, COrder::NewActionAttack(unit, target->tilePos));
|
||||||
|
|
||||||
if (savedOrder != NULL) {
|
if (savedOrder != nullptr) {
|
||||||
unit.SavedOrder = savedOrder;
|
unit.SavedOrder = savedOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
}
|
}
|
||||||
file.printf(" \"tile\", {%d, %d},", this->goalPos.x, this->goalPos.y);
|
file.printf(" \"tile\", {%d, %d},", this->goalPos.x, this->goalPos.y);
|
||||||
|
|
||||||
if (this->ReparableTarget != NULL) {
|
if (this->ReparableTarget != nullptr) {
|
||||||
file.printf(" \"repair-target\", \"%s\",", UnitReference(this->GetReparableTarget()).c_str());
|
file.printf(" \"repair-target\", \"%s\",", UnitReference(this->GetReparableTarget()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
{
|
{
|
||||||
PixelPos targetPos;
|
PixelPos targetPos;
|
||||||
|
|
||||||
if (this->ReparableTarget != NULL) {
|
if (this->ReparableTarget != nullptr) {
|
||||||
targetPos = vp.MapToScreenPixelPos(this->ReparableTarget->GetMapPixelPosCenter());
|
targetPos = vp.MapToScreenPixelPos(this->ReparableTarget->GetMapPixelPosCenter());
|
||||||
} else {
|
} else {
|
||||||
targetPos = vp.TilePosToScreen_Center(this->goalPos);
|
targetPos = vp.TilePosToScreen_Center(this->goalPos);
|
||||||
|
@ -149,10 +149,10 @@
|
||||||
const CUnit &unit = *input.GetUnit();
|
const CUnit &unit = *input.GetUnit();
|
||||||
|
|
||||||
input.SetMinRange(0);
|
input.SetMinRange(0);
|
||||||
input.SetMaxRange(ReparableTarget != NULL ? unit.Type->RepairRange : 0);
|
input.SetMaxRange(ReparableTarget != nullptr ? unit.Type->RepairRange : 0);
|
||||||
|
|
||||||
Vec2i tileSize;
|
Vec2i tileSize;
|
||||||
if (ReparableTarget != NULL) {
|
if (ReparableTarget != nullptr) {
|
||||||
tileSize.x = ReparableTarget->Type->TileWidth;
|
tileSize.x = ReparableTarget->Type->TileWidth;
|
||||||
tileSize.y = ReparableTarget->Type->TileHeight;
|
tileSize.y = ReparableTarget->Type->TileHeight;
|
||||||
input.SetGoal(ReparableTarget->tilePos, tileSize);
|
input.SetGoal(ReparableTarget->tilePos, tileSize);
|
||||||
|
@ -255,9 +255,9 @@ static void AnimateActionRepair(CUnit &unit)
|
||||||
if (!goal->IsVisibleAsGoal(*unit.Player)) {
|
if (!goal->IsVisibleAsGoal(*unit.Player)) {
|
||||||
DebugPrint("repair target gone.\n");
|
DebugPrint("repair target gone.\n");
|
||||||
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
||||||
ReparableTarget = NULL;
|
ReparableTarget = nullptr;
|
||||||
this->ClearGoal();
|
this->ClearGoal();
|
||||||
goal = NULL;
|
goal = nullptr;
|
||||||
}
|
}
|
||||||
} else if (unit.Player->AiEnabled) {
|
} else if (unit.Player->AiEnabled) {
|
||||||
// Ai players workers should stop if target is killed
|
// Ai players workers should stop if target is killed
|
||||||
|
@ -292,8 +292,8 @@ static void AnimateActionRepair(CUnit &unit)
|
||||||
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
||||||
// FIXME: should I clear this here?
|
// FIXME: should I clear this here?
|
||||||
this->ClearGoal();
|
this->ClearGoal();
|
||||||
ReparableTarget = NULL;
|
ReparableTarget = nullptr;
|
||||||
goal = NULL;
|
goal = nullptr;
|
||||||
} else {
|
} else {
|
||||||
const int dist = unit.MapDistanceTo(*goal);
|
const int dist = unit.MapDistanceTo(*goal);
|
||||||
|
|
||||||
|
|
|
@ -176,16 +176,16 @@ static bool FindNearestReachableTerrainType(int movemask, int resmask, int range
|
||||||
|
|
||||||
// Destination could be killed. NETWORK!
|
// Destination could be killed. NETWORK!
|
||||||
if (depot && depot->Destroyed) {
|
if (depot && depot->Destroyed) {
|
||||||
depot = NULL;
|
depot = nullptr;
|
||||||
}
|
}
|
||||||
// clicking on an allied depot still doesn't allow you to deposit there depending on preference
|
// clicking on an allied depot still doesn't allow you to deposit there depending on preference
|
||||||
if (depot && !GameSettings.AllyDepositsAllowed && depot->Player != harvester.Player) {
|
if (depot && !GameSettings.AllyDepositsAllowed && depot->Player != harvester.Player) {
|
||||||
depot = NULL;
|
depot = nullptr;
|
||||||
}
|
}
|
||||||
order->CurrentResource = harvester.CurrentResource;
|
order->CurrentResource = harvester.CurrentResource;
|
||||||
order->DoneHarvesting = true;
|
order->DoneHarvesting = true;
|
||||||
|
|
||||||
if (depot == NULL) {
|
if (depot == nullptr) {
|
||||||
depot = FindDeposit(harvester, 1000, harvester.CurrentResource);
|
depot = FindDeposit(harvester, 1000, harvester.CurrentResource);
|
||||||
}
|
}
|
||||||
if (depot) {
|
if (depot) {
|
||||||
|
@ -201,7 +201,7 @@ static bool FindNearestReachableTerrainType(int movemask, int resmask, int range
|
||||||
|
|
||||||
Vec2i COrder_Resource::GetHarvestLocation() const
|
Vec2i COrder_Resource::GetHarvestLocation() const
|
||||||
{
|
{
|
||||||
if (this->Resource.Mine != NULL) {
|
if (this->Resource.Mine != nullptr) {
|
||||||
return this->Resource.Mine->tilePos;
|
return this->Resource.Mine->tilePos;
|
||||||
} else {
|
} else {
|
||||||
return this->Resource.Pos;
|
return this->Resource.Pos;
|
||||||
|
@ -226,12 +226,12 @@ bool COrder_Resource::IsGatheringWaiting() const
|
||||||
COrder_Resource::~COrder_Resource()
|
COrder_Resource::~COrder_Resource()
|
||||||
{
|
{
|
||||||
CUnit *mine = this->Resource.Mine;
|
CUnit *mine = this->Resource.Mine;
|
||||||
this->Resource.Mine = NULL;
|
this->Resource.Mine = nullptr;
|
||||||
if (mine && mine->IsAlive()) {
|
if (mine && mine->IsAlive()) {
|
||||||
worker->DeAssignWorkerFromMine(*mine);
|
worker->DeAssignWorkerFromMine(*mine);
|
||||||
}
|
}
|
||||||
|
|
||||||
Depot = NULL;
|
Depot = nullptr;
|
||||||
|
|
||||||
CUnit *goal = this->GetGoal();
|
CUnit *goal = this->GetGoal();
|
||||||
if (goal) {
|
if (goal) {
|
||||||
|
@ -255,15 +255,15 @@ COrder_Resource::~COrder_Resource()
|
||||||
}
|
}
|
||||||
file.printf(" \"tile\", {%d, %d},", this->goalPos.x, this->goalPos.y);
|
file.printf(" \"tile\", {%d, %d},", this->goalPos.x, this->goalPos.y);
|
||||||
|
|
||||||
Assert(this->worker != NULL && worker->IsAlive());
|
Assert(this->worker != nullptr && worker->IsAlive());
|
||||||
file.printf(" \"worker\", \"%s\",", UnitReference(worker).c_str());
|
file.printf(" \"worker\", \"%s\",", UnitReference(worker).c_str());
|
||||||
file.printf(" \"current-res\", %d,", this->CurrentResource);
|
file.printf(" \"current-res\", %d,", this->CurrentResource);
|
||||||
|
|
||||||
file.printf(" \"res-pos\", {%d, %d},", this->Resource.Pos.x, this->Resource.Pos.y);
|
file.printf(" \"res-pos\", {%d, %d},", this->Resource.Pos.x, this->Resource.Pos.y);
|
||||||
if (this->Resource.Mine != NULL) {
|
if (this->Resource.Mine != nullptr) {
|
||||||
file.printf(" \"res-mine\", \"%s\",", UnitReference(this->Resource.Mine).c_str());
|
file.printf(" \"res-mine\", \"%s\",", UnitReference(this->Resource.Mine).c_str());
|
||||||
}
|
}
|
||||||
if (this->Depot != NULL) {
|
if (this->Depot != nullptr) {
|
||||||
file.printf(" \"res-depot\", \"%s\",", UnitReference(this->Depot).c_str());
|
file.printf(" \"res-depot\", \"%s\",", UnitReference(this->Depot).c_str());
|
||||||
}
|
}
|
||||||
if (this->DoneHarvesting) {
|
if (this->DoneHarvesting) {
|
||||||
|
@ -702,7 +702,7 @@ int COrder_Resource::GatherResource(CUnit &unit)
|
||||||
if (resinfo.HarvestFromOutside || resinfo.TerrainHarvester) {
|
if (resinfo.HarvestFromOutside || resinfo.TerrainHarvester) {
|
||||||
AnimateActionHarvest(unit);
|
AnimateActionHarvest(unit);
|
||||||
} else {
|
} else {
|
||||||
unit.Anim.CurrAnim = NULL;
|
unit.Anim.CurrAnim = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->TimeToHarvest--;
|
this->TimeToHarvest--;
|
||||||
|
@ -806,11 +806,11 @@ int COrder_Resource::GatherResource(CUnit &unit)
|
||||||
LetUnitDie(*source);
|
LetUnitDie(*source);
|
||||||
// FIXME: make the workers inside look for a new resource.
|
// FIXME: make the workers inside look for a new resource.
|
||||||
}
|
}
|
||||||
source = NULL;
|
source = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (resinfo.HarvestFromOutside) {
|
if (resinfo.HarvestFromOutside) {
|
||||||
if ((unit.ResourcesHeld == resinfo.ResourceCapacity) || (source == NULL)) {
|
if ((unit.ResourcesHeld == resinfo.ResourceCapacity) || (source == nullptr)) {
|
||||||
// Mark as complete.
|
// Mark as complete.
|
||||||
this->DoneHarvesting = true;
|
this->DoneHarvesting = true;
|
||||||
}
|
}
|
||||||
|
@ -828,7 +828,7 @@ int GetNumWaitingWorkers(const CUnit &mine)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
CUnit *worker = mine.Resource.Workers;
|
CUnit *worker = mine.Resource.Workers;
|
||||||
|
|
||||||
for (int i = 0; NULL != worker; worker = worker->NextWorker, ++i) {
|
for (int i = 0; nullptr != worker; worker = worker->NextWorker, ++i) {
|
||||||
Assert(worker->CurrentAction() == UnitActionResource);
|
Assert(worker->CurrentAction() == UnitActionResource);
|
||||||
COrder_Resource &order = *static_cast<COrder_Resource *>(worker->CurrentOrder());
|
COrder_Resource &order = *static_cast<COrder_Resource *>(worker->CurrentOrder());
|
||||||
|
|
||||||
|
@ -876,8 +876,8 @@ int COrder_Resource::StopGathering(CUnit &unit)
|
||||||
if (source->Type->MaxOnBoard) {
|
if (source->Type->MaxOnBoard) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
CUnit *worker = source->Resource.Workers;
|
CUnit *worker = source->Resource.Workers;
|
||||||
CUnit *next = NULL;
|
CUnit *next = nullptr;
|
||||||
for (; NULL != worker; worker = worker->NextWorker) {
|
for (; nullptr != worker; worker = worker->NextWorker) {
|
||||||
Assert(worker->CurrentAction() == UnitActionResource);
|
Assert(worker->CurrentAction() == UnitActionResource);
|
||||||
COrder_Resource &order = *static_cast<COrder_Resource *>(worker->CurrentOrder());
|
COrder_Resource &order = *static_cast<COrder_Resource *>(worker->CurrentOrder());
|
||||||
if (worker != &unit && order.IsGatheringWaiting()) {
|
if (worker != &unit && order.IsGatheringWaiting()) {
|
||||||
|
@ -908,7 +908,7 @@ int COrder_Resource::StopGathering(CUnit &unit)
|
||||||
} else {
|
} else {
|
||||||
// Store resource position.
|
// Store resource position.
|
||||||
this->Resource.Pos = unit.tilePos;
|
this->Resource.Pos = unit.tilePos;
|
||||||
Assert(this->Resource.Mine == NULL);
|
Assert(this->Resource.Mine == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -937,7 +937,7 @@ int COrder_Resource::StopGathering(CUnit &unit)
|
||||||
|
|
||||||
if (mine) {
|
if (mine) {
|
||||||
unit.DeAssignWorkerFromMine(*mine);
|
unit.DeAssignWorkerFromMine(*mine);
|
||||||
this->Resource.Mine = NULL;
|
this->Resource.Mine = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPrint("%d: Worker %d report: Can't find a resource [%d] deposit.\n"
|
DebugPrint("%d: Worker %d report: Can't find a resource [%d] deposit.\n"
|
||||||
|
@ -1037,7 +1037,7 @@ int COrder_Resource::MoveToDepot(CUnit &unit)
|
||||||
SelectionChanged();
|
SelectionChanged();
|
||||||
unit.Removed = 1;
|
unit.Removed = 1;
|
||||||
}
|
}
|
||||||
unit.Anim.CurrAnim = NULL;
|
unit.Anim.CurrAnim = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update resource.
|
// Update resource.
|
||||||
|
@ -1101,14 +1101,14 @@ bool COrder_Resource::WaitInDepot(CUnit &unit)
|
||||||
// Use depot's ref counter for that
|
// Use depot's ref counter for that
|
||||||
if (longWay || !mine || (depot->Refs > tooManyWorkers)) {
|
if (longWay || !mine || (depot->Refs > tooManyWorkers)) {
|
||||||
newdepot = AiGetSuitableDepot(unit, *depot, &goal);
|
newdepot = AiGetSuitableDepot(unit, *depot, &goal);
|
||||||
if (newdepot == NULL && longWay) {
|
if (newdepot == nullptr && longWay) {
|
||||||
// We need a new depot
|
// We need a new depot
|
||||||
AiNewDepotRequest(unit);
|
AiNewDepotRequest(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If goal is not NULL, then we got it in AiGetSuitableDepot
|
// If goal is not nullptr, then we got it in AiGetSuitableDepot
|
||||||
if (!goal) {
|
if (!goal) {
|
||||||
if (mine != nullptr && mine->IsAlive()) {
|
if (mine != nullptr && mine->IsAlive()) {
|
||||||
goal = mine;
|
goal = mine;
|
||||||
|
@ -1153,7 +1153,7 @@ bool COrder_Resource::WaitInDepot(CUnit &unit)
|
||||||
}
|
}
|
||||||
if (mine) {
|
if (mine) {
|
||||||
unit.DeAssignWorkerFromMine(*mine);
|
unit.DeAssignWorkerFromMine(*mine);
|
||||||
this->Resource.Mine = NULL;
|
this->Resource.Mine = nullptr;
|
||||||
}
|
}
|
||||||
this->Finished = true;
|
this->Finished = true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1174,7 +1174,7 @@ void COrder_Resource::DropResource(CUnit &unit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fast clean both resource data: pos and mine
|
//fast clean both resource data: pos and mine
|
||||||
this->Resource.Mine = NULL;
|
this->Resource.Mine = nullptr;
|
||||||
unit.CurrentResource = 0;
|
unit.CurrentResource = 0;
|
||||||
unit.ResourcesHeld = 0;
|
unit.ResourcesHeld = 0;
|
||||||
}
|
}
|
||||||
|
@ -1252,7 +1252,7 @@ bool COrder_Resource::ActionResourceInit(CUnit &unit)
|
||||||
|
|
||||||
if (mine) {
|
if (mine) {
|
||||||
unit.DeAssignWorkerFromMine(*mine);
|
unit.DeAssignWorkerFromMine(*mine);
|
||||||
this->Resource.Mine = NULL;
|
this->Resource.Mine = nullptr;
|
||||||
}
|
}
|
||||||
if (goal && goal->IsAlive() == false) {
|
if (goal && goal->IsAlive() == false) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -134,7 +134,7 @@ private:
|
||||||
/* virtual */ void COrder_Still::OnAnimationAttack(CUnit &unit)
|
/* virtual */ void COrder_Still::OnAnimationAttack(CUnit &unit)
|
||||||
{
|
{
|
||||||
CUnit *goal = this->GetGoal();
|
CUnit *goal = this->GetGoal();
|
||||||
if (goal == NULL) {
|
if (goal == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (IsTargetInRange(unit)(goal) == false) {
|
if (IsTargetInRange(unit)(goal) == false) {
|
||||||
|
@ -262,7 +262,7 @@ private:
|
||||||
** @param unit unit which can repair.
|
** @param unit unit which can repair.
|
||||||
** @param range range to find a repairable unit.
|
** @param range range to find a repairable unit.
|
||||||
**
|
**
|
||||||
** @return unit to repair if found, NULL otherwise
|
** @return unit to repair if found, nullptr otherwise
|
||||||
**
|
**
|
||||||
** @todo FIXME: find the best unit (most damaged, ...).
|
** @todo FIXME: find the best unit (most damaged, ...).
|
||||||
*/
|
*/
|
||||||
|
@ -287,18 +287,18 @@ bool AutoRepair(CUnit &unit)
|
||||||
}
|
}
|
||||||
CUnit *repairedUnit = UnitToRepairInRange(unit, repairRange);
|
CUnit *repairedUnit = UnitToRepairInRange(unit, repairRange);
|
||||||
|
|
||||||
if (repairedUnit == NULL) {
|
if (repairedUnit == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const Vec2i invalidPos(-1, -1);
|
const Vec2i invalidPos(-1, -1);
|
||||||
COrder *savedOrder = NULL;
|
COrder *savedOrder = nullptr;
|
||||||
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
||||||
savedOrder = unit.CurrentOrder()->Clone();
|
savedOrder = unit.CurrentOrder()->Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Command* will clear unit.SavedOrder
|
//Command* will clear unit.SavedOrder
|
||||||
CommandRepair(unit, invalidPos, repairedUnit, FlushCommands);
|
CommandRepair(unit, invalidPos, repairedUnit, FlushCommands);
|
||||||
if (savedOrder != NULL) {
|
if (savedOrder != nullptr) {
|
||||||
unit.SavedOrder = savedOrder;
|
unit.SavedOrder = savedOrder;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -314,7 +314,7 @@ bool COrder_Still::AutoAttackStand(CUnit &unit)
|
||||||
// Removed units can only attack in AttackRange, from bunker
|
// Removed units can only attack in AttackRange, from bunker
|
||||||
CUnit *autoAttackUnit = AttackUnitsInRange(unit);
|
CUnit *autoAttackUnit = AttackUnitsInRange(unit);
|
||||||
|
|
||||||
if (autoAttackUnit == NULL) {
|
if (autoAttackUnit == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,10 +364,10 @@ bool AutoAttack(CUnit &unit)
|
||||||
// Normal units react in reaction range.
|
// Normal units react in reaction range.
|
||||||
CUnit *goal = AttackUnitsInReactRange(unit);
|
CUnit *goal = AttackUnitsInReactRange(unit);
|
||||||
|
|
||||||
if (goal == NULL) {
|
if (goal == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
COrder *savedOrder = NULL;
|
COrder *savedOrder = nullptr;
|
||||||
|
|
||||||
if (unit.CurrentAction() == UnitActionStill) {
|
if (unit.CurrentAction() == UnitActionStill) {
|
||||||
savedOrder = COrder::NewActionAttack(unit, unit.tilePos);
|
savedOrder = COrder::NewActionAttack(unit, unit.tilePos);
|
||||||
|
@ -375,9 +375,9 @@ bool AutoAttack(CUnit &unit)
|
||||||
savedOrder = unit.CurrentOrder()->Clone();
|
savedOrder = unit.CurrentOrder()->Clone();
|
||||||
}
|
}
|
||||||
// Weak goal, can choose other unit, come back after attack
|
// Weak goal, can choose other unit, come back after attack
|
||||||
CommandAttack(unit, goal->tilePos, NULL, FlushCommands);
|
CommandAttack(unit, goal->tilePos, nullptr, FlushCommands);
|
||||||
|
|
||||||
if (savedOrder != NULL) {
|
if (savedOrder != nullptr) {
|
||||||
unit.SavedOrder = savedOrder;
|
unit.SavedOrder = savedOrder;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -388,7 +388,7 @@ bool AutoAttack(CUnit &unit)
|
||||||
{
|
{
|
||||||
// If unit is not bunkered and removed, wait
|
// If unit is not bunkered and removed, wait
|
||||||
if (unit.Removed
|
if (unit.Removed
|
||||||
&& (unit.Container == NULL || unit.Container->Type->BoolFlag[ATTACKFROMTRANSPORTER_INDEX].value == false)) {
|
&& (unit.Container == nullptr || unit.Container->Type->BoolFlag[ATTACKFROMTRANSPORTER_INDEX].value == false)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
this->Finished = false;
|
this->Finished = false;
|
||||||
|
|
|
@ -141,7 +141,7 @@ void COrder_Train::ConvertUnitType(const CUnit &unit, CUnitType &newType)
|
||||||
*/
|
*/
|
||||||
static bool CanHandleOrder(const CUnit &unit, COrder *order)
|
static bool CanHandleOrder(const CUnit &unit, COrder *order)
|
||||||
{
|
{
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (order->Action == UnitActionResource) {
|
if (order->Action == UnitActionResource) {
|
||||||
|
@ -204,7 +204,7 @@ static void AnimateActionTrain(CUnit &unit)
|
||||||
|
|
||||||
CUnit *newUnit = MakeUnit(nType, &player);
|
CUnit *newUnit = MakeUnit(nType, &player);
|
||||||
|
|
||||||
if (newUnit == NULL) { // No more memory :/
|
if (newUnit == nullptr) { // No more memory :/
|
||||||
player.Notify(NotifyYellow, unit.tilePos, _("Unable to train %s"), nType.Name.c_str());
|
player.Notify(NotifyYellow, unit.tilePos, _("Unable to train %s"), nType.Name.c_str());
|
||||||
unit.Wait = CYCLES_PER_SECOND / 6;
|
unit.Wait = CYCLES_PER_SECOND / 6;
|
||||||
return ;
|
return ;
|
||||||
|
@ -249,7 +249,7 @@ static void AnimateActionTrain(CUnit &unit)
|
||||||
if (unit.NewOrder && unit.NewOrder->HasGoal()
|
if (unit.NewOrder && unit.NewOrder->HasGoal()
|
||||||
&& unit.NewOrder->GetGoal()->Destroyed) {
|
&& unit.NewOrder->GetGoal()->Destroyed) {
|
||||||
delete unit.NewOrder;
|
delete unit.NewOrder;
|
||||||
unit.NewOrder = NULL;
|
unit.NewOrder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CanHandleOrder(*newUnit, unit.NewOrder) == true) {
|
if (CanHandleOrder(*newUnit, unit.NewOrder) == true) {
|
||||||
|
|
|
@ -316,7 +316,7 @@ static int ClosestFreeDropZone(CUnit &transporter, const Vec2i &startPos, int ma
|
||||||
|
|
||||||
if (!isTransporterRemoved) {
|
if (!isTransporterRemoved) {
|
||||||
// Remove transporter to avoid "collision" with itself.
|
// Remove transporter to avoid "collision" with itself.
|
||||||
transporter.Remove(NULL);
|
transporter.Remove(nullptr);
|
||||||
}
|
}
|
||||||
const bool res = ClosestFreeDropZone_internal(transporter, startPos, maxRange, resPos);
|
const bool res = ClosestFreeDropZone_internal(transporter, startPos, maxRange, resPos);
|
||||||
if (!isTransporterRemoved) {
|
if (!isTransporterRemoved) {
|
||||||
|
@ -339,7 +339,7 @@ bool COrder_Unload::LeaveTransporter(CUnit &transporter)
|
||||||
int stillonboard = 0;
|
int stillonboard = 0;
|
||||||
|
|
||||||
// Goal is the specific unit unit that you want to unload.
|
// Goal is the specific unit unit that you want to unload.
|
||||||
// This can be NULL, in case you want to unload everything.
|
// This can be nullptr, in case you want to unload everything.
|
||||||
if (this->HasGoal()) {
|
if (this->HasGoal()) {
|
||||||
CUnit &goal = *this->GetGoal();
|
CUnit &goal = *this->GetGoal();
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ static int TransformUnitIntoType(CUnit &unit, const CUnitType &newtype)
|
||||||
// by removing the unit and looking at the map fields
|
// by removing the unit and looking at the map fields
|
||||||
removed = true;
|
removed = true;
|
||||||
SaveSelection();
|
SaveSelection();
|
||||||
unit.Remove(NULL);
|
unit.Remove(nullptr);
|
||||||
if (!UnitTypeCanBeAt(newtype, pos)) {
|
if (!UnitTypeCanBeAt(newtype, pos)) {
|
||||||
unit.Place(unit.tilePos);
|
unit.Place(unit.tilePos);
|
||||||
RestoreSelection();
|
RestoreSelection();
|
||||||
|
|
|
@ -151,7 +151,7 @@ void COrder::UpdatePathFinderData_NotCalled(PathFinderInput &input)
|
||||||
if (unit.CurrentAction() == UnitActionDie) {
|
if (unit.CurrentAction() == UnitActionDie) {
|
||||||
unit.Seen.State = 3;
|
unit.Seen.State = 3;
|
||||||
}
|
}
|
||||||
unit.Seen.CFrame = NULL;
|
unit.Seen.CFrame = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ bool COrder::OnAiHitUnit(CUnit &unit, CUnit *attacker, int /*damage*/)
|
/* virtual */ bool COrder::OnAiHitUnit(CUnit &unit, CUnit *attacker, int /*damage*/)
|
||||||
|
@ -188,7 +188,7 @@ void COrder::UpdatePathFinderData_NotCalled(PathFinderInput &input)
|
||||||
}
|
}
|
||||||
CUnit *goal = AttackUnitsInRange(unit);
|
CUnit *goal = AttackUnitsInRange(unit);
|
||||||
|
|
||||||
if (goal != NULL) {
|
if (goal != nullptr) {
|
||||||
const Vec2i invalidPos(-1, -1);
|
const Vec2i invalidPos(-1, -1);
|
||||||
|
|
||||||
FireMissile(unit, goal, invalidPos);
|
FireMissile(unit, goal, invalidPos);
|
||||||
|
@ -399,10 +399,10 @@ static void HandleUnitAction(CUnit &unit)
|
||||||
{
|
{
|
||||||
// If current action is breakable proceed with next one.
|
// If current action is breakable proceed with next one.
|
||||||
if (!unit.Anim.Unbreakable) {
|
if (!unit.Anim.Unbreakable) {
|
||||||
if (unit.CriticalOrder != NULL) {
|
if (unit.CriticalOrder != nullptr) {
|
||||||
unit.CriticalOrder->Execute(unit);
|
unit.CriticalOrder->Execute(unit);
|
||||||
delete unit.CriticalOrder;
|
delete unit.CriticalOrder;
|
||||||
unit.CriticalOrder = NULL;
|
unit.CriticalOrder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.Orders[0]->Finished && unit.Orders[0]->Action != UnitActionStill
|
if (unit.Orders[0]->Finished && unit.Orders[0]->Action != UnitActionStill
|
||||||
|
@ -424,7 +424,7 @@ static void HandleUnitAction(CUnit &unit)
|
||||||
// timfel: I observed this exactly once and could never reproduce it, so I don't know why this
|
// timfel: I observed this exactly once and could never reproduce it, so I don't know why this
|
||||||
// can happen, but in case it happens again, bring the unit back
|
// can happen, but in case it happens again, bring the unit back
|
||||||
DebugPrint("Dropping out stuck unit\n");
|
DebugPrint("Dropping out stuck unit\n");
|
||||||
DropOutOnSide(unit, LookingW, NULL);
|
DropOutOnSide(unit, LookingW, nullptr);
|
||||||
} else {
|
} else {
|
||||||
DebugPrint("Flushing removed unit\n");
|
DebugPrint("Flushing removed unit\n");
|
||||||
// This happens, if building with ALT+SHIFT.
|
// This happens, if building with ALT+SHIFT.
|
||||||
|
@ -480,7 +480,7 @@ static void UnitActionsEachSecond(UNITP_ITERATOR begin, UNITP_ITERATOR end)
|
||||||
static void DumpUnitInfo(CUnit &unit)
|
static void DumpUnitInfo(CUnit &unit)
|
||||||
{
|
{
|
||||||
// Dump the unit to find the network sync bugs.
|
// Dump the unit to find the network sync bugs.
|
||||||
static FILE *logf = NULL;
|
static FILE *logf = nullptr;
|
||||||
|
|
||||||
if (!logf) {
|
if (!logf) {
|
||||||
time_t now;
|
time_t now;
|
||||||
|
@ -549,7 +549,7 @@ static void DumpUnitInfo(CUnit &unit)
|
||||||
#if 0
|
#if 0
|
||||||
SaveUnit(unit, logf);
|
SaveUnit(unit, logf);
|
||||||
#endif
|
#endif
|
||||||
fflush(NULL);
|
fflush(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename UNITP_ITERATOR>
|
template <typename UNITP_ITERATOR>
|
||||||
|
|
|
@ -105,9 +105,9 @@ static COrderPtr *GetNextOrder(CUnit &unit, int flush)
|
||||||
const unsigned int maxOrderCount = 0x7F;
|
const unsigned int maxOrderCount = 0x7F;
|
||||||
|
|
||||||
if (unit.Orders.size() == maxOrderCount) {
|
if (unit.Orders.size() == maxOrderCount) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
unit.Orders.push_back(NULL);
|
unit.Orders.push_back(nullptr);
|
||||||
return &unit.Orders.back();
|
return &unit.Orders.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ static void RemoveOrder(CUnit &unit, unsigned int order)
|
||||||
static void ClearNewAction(CUnit &unit)
|
static void ClearNewAction(CUnit &unit)
|
||||||
{
|
{
|
||||||
delete unit.NewOrder;
|
delete unit.NewOrder;
|
||||||
unit.NewOrder = NULL;
|
unit.NewOrder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,7 +145,7 @@ static void ClearNewAction(CUnit &unit)
|
||||||
static void ClearSavedAction(CUnit &unit)
|
static void ClearSavedAction(CUnit &unit)
|
||||||
{
|
{
|
||||||
delete unit.SavedOrder;
|
delete unit.SavedOrder;
|
||||||
unit.SavedOrder = NULL;
|
unit.SavedOrder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsUnitValidForNetwork(const CUnit &unit)
|
static bool IsUnitValidForNetwork(const CUnit &unit)
|
||||||
|
@ -168,7 +168,7 @@ void CommandStopUnit(CUnit &unit)
|
||||||
// Ignore that the unit could be removed.
|
// Ignore that the unit could be removed.
|
||||||
COrderPtr *order = GetNextOrder(unit, FlushCommands); // Flush them.
|
COrderPtr *order = GetNextOrder(unit, FlushCommands); // Flush them.
|
||||||
Assert(order);
|
Assert(order);
|
||||||
Assert(*order == NULL);
|
Assert(*order == nullptr);
|
||||||
*order = COrder::NewActionStill();
|
*order = COrder::NewActionStill();
|
||||||
|
|
||||||
ClearSavedAction(unit);
|
ClearSavedAction(unit);
|
||||||
|
@ -190,7 +190,7 @@ void CommandStandGround(CUnit &unit, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ void CommandDefend(CUnit &unit, CUnit &dest, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ void CommandFollow(CUnit &unit, CUnit &dest, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ void CommandMove(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ void CommandRepair(CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ void CommandAttack(CUnit &unit, const Vec2i &pos, CUnit *target, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ void CommandAttackGround(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ void CommandPatrolUnit(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
Vec2i startPos = unit.tilePos;
|
Vec2i startPos = unit.tilePos;
|
||||||
COrderPtr *prevOrder = &unit.Orders.back();
|
COrderPtr *prevOrder = &unit.Orders.back();
|
||||||
|
|
||||||
if(*prevOrder != NULL) {
|
if(*prevOrder != nullptr) {
|
||||||
Vec2i prevGoalPos = (*prevOrder)->GetGoalPos();
|
Vec2i prevGoalPos = (*prevOrder)->GetGoalPos();
|
||||||
if(prevGoalPos != invalidPos) {
|
if(prevGoalPos != invalidPos) {
|
||||||
startPos = prevGoalPos;
|
startPos = prevGoalPos;
|
||||||
|
@ -426,7 +426,7 @@ void CommandPatrolUnit(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ void CommandBoard(CUnit &unit, CUnit &dest, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ void CommandBoard(CUnit &unit, CUnit &dest, int flush)
|
||||||
**
|
**
|
||||||
** @param unit pointer to unit.
|
** @param unit pointer to unit.
|
||||||
** @param pos map position to unload.
|
** @param pos map position to unload.
|
||||||
** @param what unit to be unloaded, NULL for all.
|
** @param what unit to be unloaded, nullptr for all.
|
||||||
** @param flush if true, flush command queue.
|
** @param flush if true, flush command queue.
|
||||||
*/
|
*/
|
||||||
void CommandUnload(CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
|
void CommandUnload(CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
|
||||||
|
@ -480,7 +480,7 @@ void CommandUnload(CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
|
||||||
}
|
}
|
||||||
COrderPtr *order = GetNextOrder(unit, flush);
|
COrderPtr *order = GetNextOrder(unit, flush);
|
||||||
|
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*order = COrder::NewActionUnload(pos, what);
|
*order = COrder::NewActionUnload(pos, what);
|
||||||
|
@ -507,7 +507,7 @@ void CommandBuildBuilding(CUnit &unit, const Vec2i &pos, CUnitType &what, int fl
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,7 +533,7 @@ void CommandExplore(CUnit &unit, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@ void CommandResourceLoc(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,7 +616,7 @@ void CommandResource(CUnit &unit, CUnit &dest, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -648,7 +648,7 @@ void CommandReturnGoods(CUnit &unit, CUnit *depot, int flush)
|
||||||
order = &unit.NewOrder;
|
order = &unit.NewOrder;
|
||||||
} else {
|
} else {
|
||||||
order = GetNextOrder(unit, flush);
|
order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -683,7 +683,7 @@ void CommandTrainUnit(CUnit &unit, CUnitType &type, int)
|
||||||
const int noFlushCommands = 0;
|
const int noFlushCommands = 0;
|
||||||
COrderPtr *order = GetNextOrder(unit, noFlushCommands);
|
COrderPtr *order = GetNextOrder(unit, noFlushCommands);
|
||||||
|
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*order = COrder::NewActionTrain(unit, type);
|
*order = COrder::NewActionTrain(unit, type);
|
||||||
|
@ -757,7 +757,7 @@ void CommandUpgradeTo(CUnit &unit, CUnitType &type, int flush, bool instant)
|
||||||
|
|
||||||
COrderPtr *order = GetNextOrder(unit, flush);
|
COrderPtr *order = GetNextOrder(unit, flush);
|
||||||
|
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*order = COrder::NewActionUpgradeTo(unit, type, instant);
|
*order = COrder::NewActionUpgradeTo(unit, type, instant);
|
||||||
|
@ -775,7 +775,7 @@ void CommandTransformIntoType(CUnit &unit, CUnitType &type)
|
||||||
if (unit.CriticalOrder && unit.CriticalOrder->Action == UnitActionTransformInto) {
|
if (unit.CriticalOrder && unit.CriticalOrder->Action == UnitActionTransformInto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert(unit.CriticalOrder == NULL);
|
Assert(unit.CriticalOrder == nullptr);
|
||||||
|
|
||||||
unit.CriticalOrder = COrder::NewActionTransformInto(type);
|
unit.CriticalOrder = COrder::NewActionTransformInto(type);
|
||||||
}
|
}
|
||||||
|
@ -815,7 +815,7 @@ void CommandResearch(CUnit &unit, CUpgrade &what, int flush)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
COrderPtr *order = GetNextOrder(unit, flush);
|
COrderPtr *order = GetNextOrder(unit, flush);
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*order = COrder::NewActionResearch(unit, what);
|
*order = COrder::NewActionResearch(unit, what);
|
||||||
|
@ -861,7 +861,7 @@ void CommandSpellCast(CUnit &unit, const Vec2i &pos, CUnit *dest, const SpellTyp
|
||||||
}
|
}
|
||||||
COrderPtr *order = GetNextOrder(unit, flush);
|
COrderPtr *order = GetNextOrder(unit, flush);
|
||||||
|
|
||||||
if (order == NULL) {
|
if (order == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -446,7 +446,7 @@ void AiInit(CPlayer &player)
|
||||||
Exit(0);
|
Exit(0);
|
||||||
}
|
}
|
||||||
size_t i;
|
size_t i;
|
||||||
CAiType *ait = NULL;
|
CAiType *ait = nullptr;
|
||||||
|
|
||||||
for (i = 0; i < AiTypes.size(); ++i) {
|
for (i = 0; i < AiTypes.size(); ++i) {
|
||||||
ait = AiTypes[i];
|
ait = AiTypes[i];
|
||||||
|
@ -495,7 +495,7 @@ void CleanAi()
|
||||||
{
|
{
|
||||||
for (int p = 0; p < PlayerMax; ++p) {
|
for (int p = 0; p < PlayerMax; ++p) {
|
||||||
delete Players[p].Ai;
|
delete Players[p].Ai;
|
||||||
Players[p].Ai = NULL;
|
Players[p].Ai = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ void AiHelpMe(const CUnit *attacker, CUnit &defender)
|
||||||
const COrder_Attack &orderAttack = *static_cast<COrder_Attack *>(aiunit.CurrentOrder());
|
const COrder_Attack &orderAttack = *static_cast<COrder_Attack *>(aiunit.CurrentOrder());
|
||||||
const CUnit *oldGoal = orderAttack.GetGoal();
|
const CUnit *oldGoal = orderAttack.GetGoal();
|
||||||
|
|
||||||
if (oldGoal == NULL || (ThreatCalculate(defender, *attacker) < ThreatCalculate(defender, *oldGoal)
|
if (oldGoal == nullptr || (ThreatCalculate(defender, *attacker) < ThreatCalculate(defender, *oldGoal)
|
||||||
&& aiunit.MapDistanceTo(defender) <= aiunit.Stats->Variables[ATTACKRANGE_INDEX].Max)) {
|
&& aiunit.MapDistanceTo(defender) <= aiunit.Stats->Variables[ATTACKRANGE_INDEX].Max)) {
|
||||||
shouldAttack = true;
|
shouldAttack = true;
|
||||||
}
|
}
|
||||||
|
@ -700,7 +700,7 @@ void AiHelpMe(const CUnit *attacker, CUnit &defender)
|
||||||
|
|
||||||
if (aiunit.CanStoreOrder(savedOrder) == false) {
|
if (aiunit.CanStoreOrder(savedOrder) == false) {
|
||||||
delete savedOrder;
|
delete savedOrder;
|
||||||
savedOrder = NULL;
|
savedOrder = nullptr;
|
||||||
} else {
|
} else {
|
||||||
aiunit.SavedOrder = savedOrder;
|
aiunit.SavedOrder = savedOrder;
|
||||||
}
|
}
|
||||||
|
@ -899,14 +899,14 @@ static void AiMoveUnitInTheWay(CUnit &unit)
|
||||||
// Don't move more than 1 unit.
|
// Don't move more than 1 unit.
|
||||||
if (movablenb) {
|
if (movablenb) {
|
||||||
const int index = SyncRand() % movablenb;
|
const int index = SyncRand() % movablenb;
|
||||||
COrder *savedOrder = NULL;
|
COrder *savedOrder = nullptr;
|
||||||
if (movableunits[index]->IsIdle() == false) {
|
if (movableunits[index]->IsIdle() == false) {
|
||||||
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
||||||
savedOrder = unit.CurrentOrder()->Clone();
|
savedOrder = unit.CurrentOrder()->Clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommandMove(*movableunits[index], movablepos[index], FlushCommands);
|
CommandMove(*movableunits[index], movablepos[index], FlushCommands);
|
||||||
if (savedOrder != NULL) {
|
if (savedOrder != nullptr) {
|
||||||
unit.SavedOrder = savedOrder;
|
unit.SavedOrder = savedOrder;
|
||||||
}
|
}
|
||||||
AiPlayer->LastCanNotMoveGameCycle = GameCycle;
|
AiPlayer->LastCanNotMoveGameCycle = GameCycle;
|
||||||
|
|
|
@ -172,7 +172,7 @@ VisitResult BuildingPlaceFinder::Visit(TerrainTraversal &terrainTraversal, const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (CanBuildUnitType(&worker, type, pos, 1)
|
if (CanBuildUnitType(&worker, type, pos, 1)
|
||||||
&& !AiEnemyUnitsInDistance(*worker.Player, NULL, pos, 8)) {
|
&& !AiEnemyUnitsInDistance(*worker.Player, nullptr, pos, 8)) {
|
||||||
bool backupok;
|
bool backupok;
|
||||||
if (AiCheckSurrounding(worker, type, pos, backupok) && checkSurround) {
|
if (AiCheckSurrounding(worker, type, pos, backupok) && checkSurround) {
|
||||||
*resultPos = pos;
|
*resultPos = pos;
|
||||||
|
@ -207,7 +207,7 @@ static bool AiFindBuildingPlace2(const CUnit &worker, const CUnitType &type, con
|
||||||
terrainTraversal.SetSize(Map.Info.MapWidth, Map.Info.MapHeight);
|
terrainTraversal.SetSize(Map.Info.MapWidth, Map.Info.MapHeight);
|
||||||
terrainTraversal.Init();
|
terrainTraversal.Init();
|
||||||
|
|
||||||
if (startUnit != NULL) {
|
if (startUnit != nullptr) {
|
||||||
terrainTraversal.PushUnitPosAndNeighboor(*startUnit);
|
terrainTraversal.PushUnitPosAndNeighboor(*startUnit);
|
||||||
} else {
|
} else {
|
||||||
Assert(Map.Info.IsPointOnMap(startPos));
|
Assert(Map.Info.IsPointOnMap(startPos));
|
||||||
|
@ -339,7 +339,7 @@ static bool AiFindHallPlace(const CUnit &worker,
|
||||||
if (terrainTraversal.Run(hallPlaceFinder)) {
|
if (terrainTraversal.Run(hallPlaceFinder)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return AiFindBuildingPlace2(worker, type, startPos, NULL, true, resultPos);
|
return AiFindBuildingPlace2(worker, type, startPos, nullptr, true, resultPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
class LumberMillPlaceFinder
|
class LumberMillPlaceFinder
|
||||||
|
@ -368,7 +368,7 @@ VisitResult LumberMillPlaceFinder::Visit(TerrainTraversal &terrainTraversal, con
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (Map.Field(pos)->IsTerrainResourceOnMap(resource)) {
|
if (Map.Field(pos)->IsTerrainResourceOnMap(resource)) {
|
||||||
if (AiFindBuildingPlace2(worker, type, from, NULL, true, resultPos)) {
|
if (AiFindBuildingPlace2(worker, type, from, nullptr, true, resultPos)) {
|
||||||
return VisitResult_Finished;
|
return VisitResult_Finished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ static bool AiFindMiningPlace(const CUnit &worker,
|
||||||
Vec2i *resultPos)
|
Vec2i *resultPos)
|
||||||
{
|
{
|
||||||
// look near (mine = ResourceOnMap(pos, resource, false) ?
|
// look near (mine = ResourceOnMap(pos, resource, false) ?
|
||||||
return AiFindBuildingPlace2(worker, type, startPos, NULL, false, resultPos);
|
return AiFindBuildingPlace2(worker, type, startPos, nullptr, false, resultPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -456,12 +456,12 @@ bool AiFindBuildingPlace(const CUnit &worker, const CUnitType &type, const Vec2i
|
||||||
return AiFindMiningPlace(worker, type, startPos, i, resultPos);
|
return AiFindMiningPlace(worker, type, startPos, i, resultPos);
|
||||||
} else {
|
} else {
|
||||||
//Mine can be build without resource restrictions: solar panels, etc
|
//Mine can be build without resource restrictions: solar panels, etc
|
||||||
return AiFindBuildingPlace2(worker, type, startPos, NULL, true, resultPos);
|
return AiFindBuildingPlace2(worker, type, startPos, nullptr, true, resultPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AiFindBuildingPlace2(worker, type, startPos, NULL, true, resultPos);
|
return AiFindBuildingPlace2(worker, type, startPos, nullptr, true, resultPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
find_type(find_type),
|
find_type(find_type),
|
||||||
result_unit(result_unit)
|
result_unit(result_unit)
|
||||||
{
|
{
|
||||||
*result_unit = NULL;
|
*result_unit = nullptr;
|
||||||
}
|
}
|
||||||
VisitResult Visit(TerrainTraversal &terrainTraversal, const Vec2i &pos, const Vec2i &from);
|
VisitResult Visit(TerrainTraversal &terrainTraversal, const Vec2i &pos, const Vec2i &from);
|
||||||
private:
|
private:
|
||||||
|
@ -108,7 +108,7 @@ VisitResult EnemyUnitFinder::Visit(TerrainTraversal &terrainTraversal, const Vec
|
||||||
if ((find_type != AIATTACK_BUILDING || dtype.BoolFlag[BUILDING_INDEX].value) && (find_type != AIATTACK_AGRESSIVE || dest->IsAgressive())) {
|
if ((find_type != AIATTACK_BUILDING || dtype.BoolFlag[BUILDING_INDEX].value) && (find_type != AIATTACK_AGRESSIVE || dest->IsAgressive())) {
|
||||||
*result_unit = dest;
|
*result_unit = dest;
|
||||||
return VisitResult_Finished;
|
return VisitResult_Finished;
|
||||||
} else if (*result_unit == NULL) { // if trying to search for buildings or aggressive units specifically, still put the first found unit (even if it doesn't fit those parameters) as the result unit, so that it can be returned if no unit with the specified parameters is found
|
} else if (*result_unit == nullptr) { // if trying to search for buildings or aggressive units specifically, still put the first found unit (even if it doesn't fit those parameters) as the result unit, so that it can be returned if no unit with the specified parameters is found
|
||||||
*result_unit = dest;
|
*result_unit = dest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,24 +121,24 @@ class AiForceEnemyFinder
|
||||||
public:
|
public:
|
||||||
AiForceEnemyFinder(int force, const CUnit **enemy) : enemy(enemy)
|
AiForceEnemyFinder(int force, const CUnit **enemy) : enemy(enemy)
|
||||||
{
|
{
|
||||||
Assert(enemy != NULL);
|
Assert(enemy != nullptr);
|
||||||
*enemy = NULL;
|
*enemy = nullptr;
|
||||||
AiPlayer->Force[force].Units.for_each_if(*this);
|
AiPlayer->Force[force].Units.for_each_if(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AiForceEnemyFinder(AiForce &force, const CUnit **enemy) : enemy(enemy)
|
AiForceEnemyFinder(AiForce &force, const CUnit **enemy) : enemy(enemy)
|
||||||
{
|
{
|
||||||
Assert(enemy != NULL);
|
Assert(enemy != nullptr);
|
||||||
*enemy = NULL;
|
*enemy = nullptr;
|
||||||
force.Units.for_each_if(*this);
|
force.Units.for_each_if(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found() const { return *enemy != NULL; }
|
bool found() const { return *enemy != nullptr; }
|
||||||
|
|
||||||
bool operator()(const CUnit *const unit) const
|
bool operator()(const CUnit *const unit) const
|
||||||
{
|
{
|
||||||
if (unit->Type->CanAttack == false) {
|
if (unit->Type->CanAttack == false) {
|
||||||
return *enemy == NULL;
|
return *enemy == nullptr;
|
||||||
}
|
}
|
||||||
if (FIND_TYPE == AIATTACK_RANGE) {
|
if (FIND_TYPE == AIATTACK_RANGE) {
|
||||||
*enemy = AttackUnitsInReactRange(*unit);
|
*enemy = AttackUnitsInReactRange(*unit);
|
||||||
|
@ -148,7 +148,7 @@ public:
|
||||||
terrainTraversal.SetSize(Map.Info.MapWidth, Map.Info.MapHeight);
|
terrainTraversal.SetSize(Map.Info.MapWidth, Map.Info.MapHeight);
|
||||||
terrainTraversal.Init();
|
terrainTraversal.Init();
|
||||||
terrainTraversal.PushUnitPosAndNeighboor(*unit);
|
terrainTraversal.PushUnitPosAndNeighboor(*unit);
|
||||||
CUnit *result_unit = NULL;
|
CUnit *result_unit = nullptr;
|
||||||
EnemyUnitFinder enemyUnitFinder(*unit, &result_unit, FIND_TYPE);
|
EnemyUnitFinder enemyUnitFinder(*unit, &result_unit, FIND_TYPE);
|
||||||
terrainTraversal.Run(enemyUnitFinder);
|
terrainTraversal.Run(enemyUnitFinder);
|
||||||
*enemy = result_unit;
|
*enemy = result_unit;
|
||||||
|
@ -161,17 +161,17 @@ public:
|
||||||
// } else if (FIND_TYPE == AIATTACK_BUILDING) {
|
// } else if (FIND_TYPE == AIATTACK_BUILDING) {
|
||||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsBuildingType());
|
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsBuildingType());
|
||||||
// Assert(!*enemy);
|
// Assert(!*enemy);
|
||||||
// if (*enemy == NULL || !(*enemy)->Type->Building) {
|
// if (*enemy == nullptr || !(*enemy)->Type->Building) {
|
||||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
|
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
|
||||||
// }
|
// }
|
||||||
// } else if (FIND_TYPE == AIATTACK_AGRESSIVE) {
|
// } else if (FIND_TYPE == AIATTACK_AGRESSIVE) {
|
||||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsAggresiveUnit());
|
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsAggresiveUnit());
|
||||||
// Assert(!*enemy || (*enemy)->IsAgressive());
|
// Assert(!*enemy || (*enemy)->IsAgressive());
|
||||||
// if (*enemy == NULL) {
|
// if (*enemy == nullptr) {
|
||||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
|
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return *enemy == NULL;
|
return *enemy == nullptr;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
const CUnit **enemy;
|
const CUnit **enemy;
|
||||||
|
@ -404,7 +404,7 @@ private:
|
||||||
VisitResult AiForceRallyPointFinder::Visit(TerrainTraversal &terrainTraversal, const Vec2i &pos, const Vec2i &from)
|
VisitResult AiForceRallyPointFinder::Visit(TerrainTraversal &terrainTraversal, const Vec2i &pos, const Vec2i &from)
|
||||||
{
|
{
|
||||||
const int minDist = 15;
|
const int minDist = 15;
|
||||||
if (AiEnemyUnitsInDistance(*startUnit.Player, NULL, pos, minDist) == false
|
if (AiEnemyUnitsInDistance(*startUnit.Player, nullptr, pos, minDist) == false
|
||||||
&& Distance(pos, startPos) <= abs(distance - minDist)) {
|
&& Distance(pos, startPos) <= abs(distance - minDist)) {
|
||||||
*resultPos = pos;
|
*resultPos = pos;
|
||||||
return VisitResult_Finished;
|
return VisitResult_Finished;
|
||||||
|
@ -475,7 +475,7 @@ void AiForce::Attack(const Vec2i &pos)
|
||||||
}
|
}
|
||||||
if (Map.Info.IsPointOnMap(goalPos) == false) {
|
if (Map.Info.IsPointOnMap(goalPos) == false) {
|
||||||
/* Search in entire map */
|
/* Search in entire map */
|
||||||
const CUnit *enemy = NULL;
|
const CUnit *enemy = nullptr;
|
||||||
if (isTransporter) {
|
if (isTransporter) {
|
||||||
AiForceEnemyFinder<AIATTACK_AGRESSIVE>(*this, &enemy);
|
AiForceEnemyFinder<AIATTACK_AGRESSIVE>(*this, &enemy);
|
||||||
} else if (isNaval) {
|
} else if (isNaval) {
|
||||||
|
@ -513,7 +513,7 @@ void AiForce::Attack(const Vec2i &pos)
|
||||||
}
|
}
|
||||||
// Send all units in the force to enemy.
|
// Send all units in the force to enemy.
|
||||||
|
|
||||||
CUnit *leader = NULL;
|
CUnit *leader = nullptr;
|
||||||
for (size_t i = 0; i != this->Units.size(); ++i) {
|
for (size_t i = 0; i != this->Units.size(); ++i) {
|
||||||
CUnit *const unit = this->Units[i];
|
CUnit *const unit = this->Units[i];
|
||||||
|
|
||||||
|
@ -525,12 +525,12 @@ void AiForce::Attack(const Vec2i &pos)
|
||||||
for (size_t i = 0; i != this->Units.size(); ++i) {
|
for (size_t i = 0; i != this->Units.size(); ++i) {
|
||||||
CUnit *const unit = this->Units[i];
|
CUnit *const unit = this->Units[i];
|
||||||
|
|
||||||
if (unit->Container == NULL) {
|
if (unit->Container == nullptr) {
|
||||||
const int delay = i / 5; // To avoid lot of CPU consuption, send them with a small time difference.
|
const int delay = i / 5; // To avoid lot of CPU consuption, send them with a small time difference.
|
||||||
|
|
||||||
unit->Wait = delay;
|
unit->Wait = delay;
|
||||||
if (unit->IsAgressive()) {
|
if (unit->IsAgressive()) {
|
||||||
CommandAttack(*unit, this->GoalPos, NULL, FlushCommands);
|
CommandAttack(*unit, this->GoalPos, nullptr, FlushCommands);
|
||||||
} else {
|
} else {
|
||||||
if (leader) {
|
if (leader) {
|
||||||
CommandDefend(*unit, *leader, FlushCommands);
|
CommandDefend(*unit, *leader, FlushCommands);
|
||||||
|
@ -877,7 +877,7 @@ static void AiGroupAttackerForTransport(AiForce &aiForce)
|
||||||
const CUnit &unit = *aiForce.Units[i];
|
const CUnit &unit = *aiForce.Units[i];
|
||||||
const CUnit &transporter = *aiForce.Units[transporterIndex];
|
const CUnit &transporter = *aiForce.Units[transporterIndex];
|
||||||
|
|
||||||
if (CanTransport(transporter, unit) && unit.Container == NULL) {
|
if (CanTransport(transporter, unit) && unit.Container == nullptr) {
|
||||||
forceIsReady = false;
|
forceIsReady = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -896,7 +896,7 @@ static void AiGroupAttackerForTransport(AiForce &aiForce)
|
||||||
}
|
}
|
||||||
if (CanTransport(transporter, unit) && (unit.IsIdle()
|
if (CanTransport(transporter, unit) && (unit.IsIdle()
|
||||||
|| (unit.CurrentAction() == UnitActionBoard && !unit.Moving
|
|| (unit.CurrentAction() == UnitActionBoard && !unit.Moving
|
||||||
&& static_cast<COrder_Board *>(unit.CurrentOrder())->GetGoal() != &transporter)) && unit.Container == NULL) {
|
&& static_cast<COrder_Board *>(unit.CurrentOrder())->GetGoal() != &transporter)) && unit.Container == nullptr) {
|
||||||
CommandBoard(unit, transporter, FlushCommands);
|
CommandBoard(unit, transporter, FlushCommands);
|
||||||
CommandFollow(transporter, unit, 0);
|
CommandFollow(transporter, unit, 0);
|
||||||
if (--nbToTransport == 0) { // full : next transporter.
|
if (--nbToTransport == 0) { // full : next transporter.
|
||||||
|
@ -994,12 +994,12 @@ void AiForce::Update()
|
||||||
const int delay = i / 5; // To avoid lot of CPU consuption, send them with a small time difference.
|
const int delay = i / 5; // To avoid lot of CPU consuption, send them with a small time difference.
|
||||||
|
|
||||||
trans.Wait = delay;
|
trans.Wait = delay;
|
||||||
CommandUnload(trans, this->GoalPos, NULL, FlushCommands);
|
CommandUnload(trans, this->GoalPos, nullptr, FlushCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CUnit *leader = NULL;
|
CUnit *leader = nullptr;
|
||||||
for (unsigned int i = 0; i != Size(); ++i) {
|
for (unsigned int i = 0; i != Size(); ++i) {
|
||||||
CUnit &aiunit = *Units[i];
|
CUnit &aiunit = *Units[i];
|
||||||
|
|
||||||
|
@ -1026,7 +1026,7 @@ void AiForce::Update()
|
||||||
--WaitOnRallyPoint;
|
--WaitOnRallyPoint;
|
||||||
}
|
}
|
||||||
if (maxDist <= thresholdDist || !WaitOnRallyPoint) {
|
if (maxDist <= thresholdDist || !WaitOnRallyPoint) {
|
||||||
const CUnit *unit = NULL;
|
const CUnit *unit = nullptr;
|
||||||
|
|
||||||
AiForceEnemyFinder<AIATTACK_BUILDING>(*this, &unit);
|
AiForceEnemyFinder<AIATTACK_BUILDING>(*this, &unit);
|
||||||
if (!unit) {
|
if (!unit) {
|
||||||
|
@ -1049,7 +1049,7 @@ void AiForce::Update()
|
||||||
|
|
||||||
aiunit.Wait = delay;
|
aiunit.Wait = delay;
|
||||||
if (aiunit.IsAgressive()) {
|
if (aiunit.IsAgressive()) {
|
||||||
CommandAttack(aiunit, this->GoalPos, NULL, FlushCommands);
|
CommandAttack(aiunit, this->GoalPos, nullptr, FlushCommands);
|
||||||
} else {
|
} else {
|
||||||
if (leader) {
|
if (leader) {
|
||||||
CommandDefend(aiunit, *leader, FlushCommands);
|
CommandDefend(aiunit, *leader, FlushCommands);
|
||||||
|
@ -1075,7 +1075,7 @@ void AiForce::Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (State == AiForceAttackingState_Attacking && idleUnits.size() == this->Size()) {
|
if (State == AiForceAttackingState_Attacking && idleUnits.size() == this->Size()) {
|
||||||
const CUnit *unit = NULL;
|
const CUnit *unit = nullptr;
|
||||||
|
|
||||||
bool isNaval = false;
|
bool isNaval = false;
|
||||||
for (size_t i = 0; i != this->Units.size(); ++i) {
|
for (size_t i = 0; i != this->Units.size(); ++i) {
|
||||||
|
@ -1118,16 +1118,16 @@ void AiForce::Update()
|
||||||
if (leader) {
|
if (leader) {
|
||||||
if (aiunit.IsAgressive()) {
|
if (aiunit.IsAgressive()) {
|
||||||
if (State == AiForceAttackingState_Attacking) {
|
if (State == AiForceAttackingState_Attacking) {
|
||||||
CommandAttack(aiunit, leader->tilePos, NULL, FlushCommands);
|
CommandAttack(aiunit, leader->tilePos, nullptr, FlushCommands);
|
||||||
} else {
|
} else {
|
||||||
CommandAttack(aiunit, this->GoalPos, NULL, FlushCommands);
|
CommandAttack(aiunit, this->GoalPos, nullptr, FlushCommands);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CommandDefend(aiunit, *leader, FlushCommands);
|
CommandDefend(aiunit, *leader, FlushCommands);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (aiunit.IsAgressive()) {
|
if (aiunit.IsAgressive()) {
|
||||||
CommandAttack(aiunit, this->GoalPos, NULL, FlushCommands);
|
CommandAttack(aiunit, this->GoalPos, nullptr, FlushCommands);
|
||||||
} else {
|
} else {
|
||||||
CommandMove(aiunit, this->GoalPos, FlushCommands);
|
CommandMove(aiunit, this->GoalPos, FlushCommands);
|
||||||
}
|
}
|
||||||
|
@ -1165,7 +1165,7 @@ void AiForceManager::Update()
|
||||||
for (unsigned int i = 0; i != force.Size(); ++i) {
|
for (unsigned int i = 0; i != force.Size(); ++i) {
|
||||||
if (force.Units[i]->MapDistanceTo(force.GoalPos) <= nearDist) {
|
if (force.Units[i]->MapDistanceTo(force.GoalPos) <= nearDist) {
|
||||||
// Look if still enemies in attack range.
|
// Look if still enemies in attack range.
|
||||||
const CUnit *dummy = NULL;
|
const CUnit *dummy = nullptr;
|
||||||
maxPathing--;
|
maxPathing--;
|
||||||
if (!AiForceEnemyFinder<AIATTACK_RANGE>(force, &dummy).found()) {
|
if (!AiForceEnemyFinder<AIATTACK_RANGE>(force, &dummy).found()) {
|
||||||
force.ReturnToHome();
|
force.ReturnToHome();
|
||||||
|
@ -1199,12 +1199,12 @@ void AiForceManager::Update()
|
||||||
for (unsigned int i = 0; i != idleUnits.size(); ++i) {
|
for (unsigned int i = 0; i != idleUnits.size(); ++i) {
|
||||||
CUnit *const unit = idleUnits[i];
|
CUnit *const unit = idleUnits[i];
|
||||||
|
|
||||||
if (unit->Container == NULL) {
|
if (unit->Container == nullptr) {
|
||||||
const int delay = i / 5; // To avoid lot of CPU consuption, send them with a small time difference.
|
const int delay = i / 5; // To avoid lot of CPU consuption, send them with a small time difference.
|
||||||
|
|
||||||
unit->Wait = delay;
|
unit->Wait = delay;
|
||||||
if (unit->Type->CanAttack) {
|
if (unit->Type->CanAttack) {
|
||||||
CommandAttack(*unit, force.GoalPos, NULL, FlushCommands);
|
CommandAttack(*unit, force.GoalPos, nullptr, FlushCommands);
|
||||||
} else {
|
} else {
|
||||||
CommandMove(*unit, force.GoalPos, FlushCommands);
|
CommandMove(*unit, force.GoalPos, FlushCommands);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
class AiRequestType
|
class AiRequestType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AiRequestType() : Count(0), Type(NULL) {}
|
AiRequestType() : Count(0), Type(nullptr) {}
|
||||||
|
|
||||||
unsigned int Count; /// elements in table
|
unsigned int Count; /// elements in table
|
||||||
CUnitType *Type; /// the type
|
CUnitType *Type; /// the type
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
class AiUnitType
|
class AiUnitType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AiUnitType() : Want(0), Type(NULL) {}
|
AiUnitType() : Want(0), Type(nullptr) {}
|
||||||
|
|
||||||
unsigned int Want; /// number of this unit-type wanted
|
unsigned int Want; /// number of this unit-type wanted
|
||||||
CUnitType *Type; /// unit-type self
|
CUnitType *Type; /// unit-type self
|
||||||
|
@ -246,7 +246,7 @@ private:
|
||||||
class AiBuildQueue
|
class AiBuildQueue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AiBuildQueue() : Want(0), Made(0), Type(NULL), Wait(0)
|
AiBuildQueue() : Want(0), Made(0), Type(nullptr), Wait(0)
|
||||||
{
|
{
|
||||||
Pos.x = Pos.y = -1;
|
Pos.x = Pos.y = -1;
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ public:
|
||||||
class PlayerAi
|
class PlayerAi
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlayerAi() : Player(NULL), AiType(NULL),
|
PlayerAi() : Player(nullptr), AiType(nullptr),
|
||||||
SleepCycles(0), NeededMask(0), NeedSupply(false),
|
SleepCycles(0), NeededMask(0), NeedSupply(false),
|
||||||
ScriptDebug(false), BuildDepots(true), LastExplorationGameCycle(0),
|
ScriptDebug(false), BuildDepots(true), LastExplorationGameCycle(0),
|
||||||
LastCanNotMoveGameCycle(0), LastRepairBuilding(0)
|
LastCanNotMoveGameCycle(0), LastRepairBuilding(0)
|
||||||
|
|
|
@ -110,7 +110,7 @@ private:
|
||||||
*/
|
*/
|
||||||
static CUnit *EnemyOnMapTile(const CUnit &source, const Vec2i &pos)
|
static CUnit *EnemyOnMapTile(const CUnit &source, const Vec2i &pos)
|
||||||
{
|
{
|
||||||
CUnit *enemy = NULL;
|
CUnit *enemy = nullptr;
|
||||||
|
|
||||||
_EnemyOnMapTile filter(source, pos, &enemy);
|
_EnemyOnMapTile filter(source, pos, &enemy);
|
||||||
Map.Field(pos)->UnitCache.for_each(filter);
|
Map.Field(pos)->UnitCache.for_each(filter);
|
||||||
|
@ -203,7 +203,7 @@ int AiFindWall(AiForce *force)
|
||||||
for (unsigned int i = 0; i < force->Units.size(); ++i) {
|
for (unsigned int i = 0; i < force->Units.size(); ++i) {
|
||||||
CUnit &aiunit = *force->Units[i];
|
CUnit &aiunit = *force->Units[i];
|
||||||
if (aiunit.Type->CanAttack) {
|
if (aiunit.Type->CanAttack) {
|
||||||
CommandAttack(aiunit, wallPos, NULL, FlushCommands);
|
CommandAttack(aiunit, wallPos, nullptr, FlushCommands);
|
||||||
} else {
|
} else {
|
||||||
CommandMove(aiunit, wallPos, FlushCommands);
|
CommandMove(aiunit, wallPos, FlushCommands);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ int AiForce::PlanAttack()
|
||||||
|
|
||||||
CUnit *transporter = Units.find(IsAFreeTransporter());
|
CUnit *transporter = Units.find(IsAFreeTransporter());
|
||||||
|
|
||||||
if (transporter != NULL) {
|
if (transporter != nullptr) {
|
||||||
DebugPrint("%d: Transporter #%d\n" _C_ player.Index _C_ UnitNumber(*transporter));
|
DebugPrint("%d: Transporter #%d\n" _C_ player.Index _C_ UnitNumber(*transporter));
|
||||||
MarkReacheableTerrainType(*transporter, &transporterTerrainTraversal);
|
MarkReacheableTerrainType(*transporter, &transporterTerrainTraversal);
|
||||||
} else {
|
} else {
|
||||||
|
@ -370,7 +370,7 @@ int AiForce::PlanAttack()
|
||||||
// Find a land unit of the force.
|
// Find a land unit of the force.
|
||||||
// FIXME: if force is split over different places -> broken
|
// FIXME: if force is split over different places -> broken
|
||||||
CUnit *landUnit = Units.find(CUnitTypeFinder(UnitTypeLand));
|
CUnit *landUnit = Units.find(CUnitTypeFinder(UnitTypeLand));
|
||||||
if (landUnit == NULL) {
|
if (landUnit == nullptr) {
|
||||||
DebugPrint("%d: No land unit in force\n" _C_ player.Index);
|
DebugPrint("%d: No land unit in force\n" _C_ player.Index);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ int AiForce::PlanAttack()
|
||||||
|
|
||||||
static bool ChooseRandomUnexploredPositionNear(const Vec2i ¢er, Vec2i *pos)
|
static bool ChooseRandomUnexploredPositionNear(const Vec2i ¢er, Vec2i *pos)
|
||||||
{
|
{
|
||||||
Assert(pos != NULL);
|
Assert(pos != nullptr);
|
||||||
|
|
||||||
int ray = 3;
|
int ray = 3;
|
||||||
const int maxTryCount = 8;
|
const int maxTryCount = 8;
|
||||||
|
@ -450,11 +450,11 @@ static CUnit *GetBestExplorer(const AiExplorationRequest &request, Vec2i *pos)
|
||||||
// Choose a target, "near"
|
// Choose a target, "near"
|
||||||
const Vec2i ¢er = request.pos;
|
const Vec2i ¢er = request.pos;
|
||||||
if (ChooseRandomUnexploredPositionNear(center, pos) == false) {
|
if (ChooseRandomUnexploredPositionNear(center, pos) == false) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// We have an unexplored tile in sight (pos)
|
// We have an unexplored tile in sight (pos)
|
||||||
|
|
||||||
CUnit *bestunit = NULL;
|
CUnit *bestunit = nullptr;
|
||||||
// Find an idle unit, responding to the mask
|
// Find an idle unit, responding to the mask
|
||||||
bool flyeronly = false;
|
bool flyeronly = false;
|
||||||
int bestSquareDistance = -1;
|
int bestSquareDistance = -1;
|
||||||
|
@ -517,7 +517,7 @@ void AiSendExplorers()
|
||||||
|
|
||||||
Vec2i pos;
|
Vec2i pos;
|
||||||
CUnit *bestunit = GetBestExplorer(request, &pos);
|
CUnit *bestunit = GetBestExplorer(request, &pos);
|
||||||
if (bestunit != NULL) {
|
if (bestunit != nullptr) {
|
||||||
CommandMove(*bestunit, pos, FlushCommands);
|
CommandMove(*bestunit, pos, FlushCommands);
|
||||||
AiPlayer->LastExplorationGameCycle = GameCycle;
|
AiPlayer->LastExplorationGameCycle = GameCycle;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -216,7 +216,7 @@ bool AiEnemyUnitsInDistance(const CPlayer &player,
|
||||||
const Vec2i offset(range, range);
|
const Vec2i offset(range, range);
|
||||||
std::vector<CUnit *> units;
|
std::vector<CUnit *> units;
|
||||||
|
|
||||||
if (type == NULL) {
|
if (type == nullptr) {
|
||||||
Select<1>(pos - offset, pos + offset, units, IsAEnemyUnitOf<true>(player));
|
Select<1>(pos - offset, pos + offset, units, IsAEnemyUnitOf<true>(player));
|
||||||
return static_cast<int>(units.size());
|
return static_cast<int>(units.size());
|
||||||
} else {
|
} else {
|
||||||
|
@ -370,14 +370,14 @@ void AiNewDepotRequest(CUnit &worker)
|
||||||
const Vec2i pos = order.GetHarvestLocation();
|
const Vec2i pos = order.GetHarvestLocation();
|
||||||
const int range = 15;
|
const int range = 15;
|
||||||
|
|
||||||
if (pos.x != -1 && NULL != FindDepositNearLoc(*worker.Player, pos, range, resource)) {
|
if (pos.x != -1 && nullptr != FindDepositNearLoc(*worker.Player, pos, range, resource)) {
|
||||||
/*
|
/*
|
||||||
* New Depot has just be finished and worker just return to old depot
|
* New Depot has just be finished and worker just return to old depot
|
||||||
* (far away) from new Deopt.
|
* (far away) from new Deopt.
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CUnitType *best_type = NULL;
|
CUnitType *best_type = nullptr;
|
||||||
int best_cost = 0;
|
int best_cost = 0;
|
||||||
//int best_mask = 0;
|
//int best_mask = 0;
|
||||||
// Count the already made build requests.
|
// Count the already made build requests.
|
||||||
|
@ -404,7 +404,7 @@ void AiNewDepotRequest(CUnit &worker)
|
||||||
cost += type.Stats[worker.Player->Index].Costs[c];
|
cost += type.Stats[worker.Player->Index].Costs[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_type == NULL || (cost < best_cost)) {
|
if (best_type == nullptr || (cost < best_cost)) {
|
||||||
best_type = &type;
|
best_type = &type;
|
||||||
best_cost = cost;
|
best_cost = cost;
|
||||||
//best_mask = needmask;
|
//best_mask = needmask;
|
||||||
|
@ -462,7 +462,7 @@ private:
|
||||||
** @param oldDepot Old assigned depot.
|
** @param oldDepot Old assigned depot.
|
||||||
** @param resUnit Resource to harvest from, if succeed
|
** @param resUnit Resource to harvest from, if succeed
|
||||||
**
|
**
|
||||||
** @return new depot if found, NULL otherwise.
|
** @return new depot if found, nullptr otherwise.
|
||||||
*/
|
*/
|
||||||
CUnit *AiGetSuitableDepot(const CUnit &worker, const CUnit &oldDepot, CUnit **resUnit)
|
CUnit *AiGetSuitableDepot(const CUnit &worker, const CUnit &oldDepot, CUnit **resUnit)
|
||||||
{
|
{
|
||||||
|
@ -480,7 +480,7 @@ CUnit *AiGetSuitableDepot(const CUnit &worker, const CUnit &oldDepot, CUnit **re
|
||||||
}
|
}
|
||||||
// If there aren't any alternatives, exit
|
// If there aren't any alternatives, exit
|
||||||
if (depots.size() < 2) {
|
if (depots.size() < 2) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::sort(depots.begin(), depots.end(), CompareDepotsByDistance(worker));
|
std::sort(depots.begin(), depots.end(), CompareDepotsByDistance(worker));
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ CUnit *AiGetSuitableDepot(const CUnit &worker, const CUnit &oldDepot, CUnit **re
|
||||||
return &unit;
|
return &unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1154,7 +1154,7 @@ static void AiCollectResources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unit = NULL;
|
unit = nullptr;
|
||||||
|
|
||||||
// Try to complete each ressource in the priority order
|
// Try to complete each ressource in the priority order
|
||||||
for (int i = 0; i < MaxCosts; ++i) {
|
for (int i = 0; i < MaxCosts; ++i) {
|
||||||
|
@ -1218,7 +1218,7 @@ static void AiCollectResources()
|
||||||
|
|
||||||
// unit can't harvest : next one
|
// unit can't harvest : next one
|
||||||
if (!unit->Type->ResInfo[c] || !AiAssignHarvester(*unit, c)) {
|
if (!unit->Type->ResInfo[c] || !AiAssignHarvester(*unit, c)) {
|
||||||
unit = NULL;
|
unit = nullptr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1305,10 +1305,10 @@ static bool AiRepairBuilding(const CPlayer &player, const CUnitType &type, CUnit
|
||||||
|
|
||||||
const int maxRange = 15;
|
const int maxRange = 15;
|
||||||
const int movemask = type.MovementMask & ~(MapFieldLandUnit | MapFieldAirUnit | MapFieldSeaUnit);
|
const int movemask = type.MovementMask & ~(MapFieldLandUnit | MapFieldAirUnit | MapFieldSeaUnit);
|
||||||
CUnit *unit = NULL;
|
CUnit *unit = nullptr;
|
||||||
UnitFinder unitFinder(player, table, maxRange, movemask, &unit);
|
UnitFinder unitFinder(player, table, maxRange, movemask, &unit);
|
||||||
|
|
||||||
if (terrainTraversal.Run(unitFinder) && unit != NULL) {
|
if (terrainTraversal.Run(unitFinder) && unit != nullptr) {
|
||||||
const Vec2i invalidPos(-1, -1);
|
const Vec2i invalidPos(-1, -1);
|
||||||
CommandRepair(*unit, invalidPos, &building, FlushCommands);
|
CommandRepair(*unit, invalidPos, &building, FlushCommands);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -132,7 +132,7 @@ static std::vector<CUnitType *> getSupplyUnits()
|
||||||
// Now, sort them, best first.
|
// Now, sort them, best first.
|
||||||
while (!res.empty()) {
|
while (!res.empty()) {
|
||||||
float bestscore = 0;
|
float bestscore = 0;
|
||||||
CUnitType *besttype = NULL;
|
CUnitType *besttype = nullptr;
|
||||||
|
|
||||||
for (std::vector<CUnitType *>::const_iterator i = res.begin(); i != res.end(); ++i) {
|
for (std::vector<CUnitType *>::const_iterator i = res.begin(); i != res.end(); ++i) {
|
||||||
CUnitType &type = **i;
|
CUnitType &type = **i;
|
||||||
|
@ -364,7 +364,7 @@ static CAiType *GetAiTypesByName(const char *name)
|
||||||
return ait;
|
return ait;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -491,7 +491,7 @@ static AiRequestType *FindInUnitTypeRequests(const CUnitType *type)
|
||||||
return &AiPlayer->UnitTypeRequests[i];
|
return &AiPlayer->UnitTypeRequests[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -614,7 +614,7 @@ static int CclAiDebugPlayer(lua_State *l)
|
||||||
if (lua_isstring(l, j + 1)) {
|
if (lua_isstring(l, j + 1)) {
|
||||||
item = LuaToString(l, j + 1);
|
item = LuaToString(l, j + 1);
|
||||||
} else {
|
} else {
|
||||||
item = NULL;
|
item = nullptr;
|
||||||
}
|
}
|
||||||
if (item && !strcmp(item, "none")) {
|
if (item && !strcmp(item, "none")) {
|
||||||
for (int i = 0; i != NumPlayers; ++i) {
|
for (int i = 0; i != NumPlayers; ++i) {
|
||||||
|
@ -1368,7 +1368,7 @@ static int CclAiResearch(lua_State *l)
|
||||||
upgrade = CUpgrade::Get(str);
|
upgrade = CUpgrade::Get(str);
|
||||||
} else {
|
} else {
|
||||||
LuaError(l, "Upgrade needed");
|
LuaError(l, "Upgrade needed");
|
||||||
upgrade = NULL;
|
upgrade = nullptr;
|
||||||
}
|
}
|
||||||
InsertResearchRequests(upgrade);
|
InsertResearchRequests(upgrade);
|
||||||
lua_pushboolean(l, 0);
|
lua_pushboolean(l, 0);
|
||||||
|
@ -1679,7 +1679,7 @@ static int CclDefineAiPlayer(lua_State *l)
|
||||||
if (!strcmp(value, "ai-type")) {
|
if (!strcmp(value, "ai-type")) {
|
||||||
const char *aiName = LuaToString(l, j + 1);
|
const char *aiName = LuaToString(l, j + 1);
|
||||||
CAiType *ait = GetAiTypesByName(aiName);
|
CAiType *ait = GetAiTypesByName(aiName);
|
||||||
if (ait == NULL) {
|
if (ait == nullptr) {
|
||||||
LuaError(l, "ai-type not found: %s" _C_ aiName);
|
LuaError(l, "ai-type not found: %s" _C_ aiName);
|
||||||
}
|
}
|
||||||
ai->AiType = ait;
|
ai->AiType = ait;
|
||||||
|
@ -1935,7 +1935,7 @@ static CTCPSocket * AiProcessorSendState(lua_State *l, char prefix)
|
||||||
{
|
{
|
||||||
LuaCheckArgs(l, 3);
|
LuaCheckArgs(l, 3);
|
||||||
CTCPSocket *s = (CTCPSocket *)lua_touserdata(l, 1);
|
CTCPSocket *s = (CTCPSocket *)lua_touserdata(l, 1);
|
||||||
if (s == NULL) {
|
if (s == nullptr) {
|
||||||
LuaError(l, "first argument must be valid handle returned from a previous AiProcessorSetup call");
|
LuaError(l, "first argument must be valid handle returned from a previous AiProcessorSetup call");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ int ParseAnimInt(const CUnit &unit, const char *parseint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char *next = strchr(cur, '.');
|
char *next = strchr(cur, '.');
|
||||||
if (next == NULL) {
|
if (next == nullptr) {
|
||||||
fprintf(stderr, "Need also specify the variable '%s' tag \n", cur);
|
fprintf(stderr, "Need also specify the variable '%s' tag \n", cur);
|
||||||
ExitFatal(1);
|
ExitFatal(1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -227,7 +227,7 @@ int ParseAnimInt(const CUnit &unit, const char *parseint)
|
||||||
if (*cur == '(') {
|
if (*cur == '(') {
|
||||||
++cur;
|
++cur;
|
||||||
char *end = strchr(cur, ')');
|
char *end = strchr(cur, ')');
|
||||||
if (end == NULL) {
|
if (end == nullptr) {
|
||||||
fprintf(stderr, "ParseAnimInt: expected ')'\n");
|
fprintf(stderr, "ParseAnimInt: expected ')'\n");
|
||||||
ExitFatal(1);
|
ExitFatal(1);
|
||||||
}
|
}
|
||||||
|
@ -236,20 +236,20 @@ int ParseAnimInt(const CUnit &unit, const char *parseint)
|
||||||
} else {
|
} else {
|
||||||
next = strchr(cur, '.');
|
next = strchr(cur, '.');
|
||||||
}
|
}
|
||||||
if (next == NULL) {
|
if (next == nullptr) {
|
||||||
fprintf(stderr, "Need also specify the %s player's property\n", cur);
|
fprintf(stderr, "Need also specify the %s player's property\n", cur);
|
||||||
ExitFatal(1);
|
ExitFatal(1);
|
||||||
} else {
|
} else {
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
}
|
}
|
||||||
char *arg = strchr(next + 1, '.');
|
char *arg = strchr(next + 1, '.');
|
||||||
if (arg != NULL) {
|
if (arg != nullptr) {
|
||||||
*arg = '\0';
|
*arg = '\0';
|
||||||
}
|
}
|
||||||
return GetPlayerData(ParseAnimPlayer(unit, cur), next + 1, arg + 1);
|
return GetPlayerData(ParseAnimPlayer(unit, cur), next + 1, arg + 1);
|
||||||
} else if (s[0] == 'r') { //random value
|
} else if (s[0] == 'r') { //random value
|
||||||
char *next = strchr(cur, '.');
|
char *next = strchr(cur, '.');
|
||||||
if (next == NULL) {
|
if (next == nullptr) {
|
||||||
return SyncRand(atoi(cur) + 1);
|
return SyncRand(atoi(cur) + 1);
|
||||||
} else {
|
} else {
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
|
@ -410,7 +410,7 @@ CAnimations *AnimationsByIdent(const std::string &ident)
|
||||||
if (ret != AnimationMap.end()) {
|
if (ret != AnimationMap.end()) {
|
||||||
return (*ret).second;
|
return (*ret).second;
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeAnimations()
|
void FreeAnimations()
|
||||||
|
@ -560,7 +560,7 @@ static CAnimation *FindLabel(lua_State *l, const std::string &name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LuaError(l, "Label not found: %s" _C_ name.c_str());
|
LuaError(l, "Label not found: %s" _C_ name.c_str());
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -600,7 +600,7 @@ static CAnimation *ParseAnimationFrame(lua_State *l, const char *str)
|
||||||
size_t begin = std::min(len, all.find_first_not_of(' ', end));
|
size_t begin = std::min(len, all.find_first_not_of(' ', end));
|
||||||
const std::string extraArg(all, begin);
|
const std::string extraArg(all, begin);
|
||||||
|
|
||||||
CAnimation *anim = NULL;
|
CAnimation *anim = nullptr;
|
||||||
if (op1 == "frame") {
|
if (op1 == "frame") {
|
||||||
anim = new CAnimation_Frame;
|
anim = new CAnimation_Frame;
|
||||||
} else if (op1 == "exact-frame") {
|
} else if (op1 == "exact-frame") {
|
||||||
|
@ -664,7 +664,7 @@ static CAnimation *ParseAnimation(lua_State *l, int idx)
|
||||||
const int args = lua_rawlen(l, idx);
|
const int args = lua_rawlen(l, idx);
|
||||||
|
|
||||||
if (args == 0) {
|
if (args == 0) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Labels.clear();
|
Labels.clear();
|
||||||
LabelsLater.clear();
|
LabelsLater.clear();
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
int CAnimation_ExactFrame::ParseAnimInt(const CUnit *unit) const
|
int CAnimation_ExactFrame::ParseAnimInt(const CUnit *unit) const
|
||||||
{
|
{
|
||||||
if (unit == NULL) {
|
if (unit == nullptr) {
|
||||||
return atoi(this->frame.c_str());
|
return atoi(this->frame.c_str());
|
||||||
} else {
|
} else {
|
||||||
return ::ParseAnimInt(*unit, this->frame.c_str());
|
return ::ParseAnimInt(*unit, this->frame.c_str());
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
int CAnimation_Frame::ParseAnimInt(const CUnit *unit) const
|
int CAnimation_Frame::ParseAnimInt(const CUnit *unit) const
|
||||||
{
|
{
|
||||||
if (unit == NULL) {
|
if (unit == nullptr) {
|
||||||
return atoi(this->frame.c_str());
|
return atoi(this->frame.c_str());
|
||||||
} else {
|
} else {
|
||||||
return ::ParseAnimInt(*unit, this->frame.c_str());
|
return ::ParseAnimInt(*unit, this->frame.c_str());
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
char *next = strchr(arg1, '.');
|
char *next = strchr(arg1, '.');
|
||||||
if (next == NULL) {
|
if (next == nullptr) {
|
||||||
// Special case for non-CVariable variables
|
// Special case for non-CVariable variables
|
||||||
if (!strcmp(arg1, "DamageType")) {
|
if (!strcmp(arg1, "DamageType")) {
|
||||||
int death = ExtraDeathIndex(this->valueStr.c_str());
|
int death = ExtraDeathIndex(this->valueStr.c_str());
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
PixelPos start;
|
PixelPos start;
|
||||||
PixelPos dest;
|
PixelPos dest;
|
||||||
MissileType *mtype = MissileTypeByIdent(this->missileTypeStr);
|
MissileType *mtype = MissileTypeByIdent(this->missileTypeStr);
|
||||||
if (mtype == NULL) {
|
if (mtype == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
FindNearestDrop(*type, pos, resPos, LookingW);
|
FindNearestDrop(*type, pos, resPos, LookingW);
|
||||||
if (SquareDistance(pos, resPos) <= square(range)) {
|
if (SquareDistance(pos, resPos) <= square(range)) {
|
||||||
CUnit *target = MakeUnit(*type, &player);
|
CUnit *target = MakeUnit(*type, &player);
|
||||||
if (target != NULL) {
|
if (target != nullptr) {
|
||||||
target->tilePos = resPos;
|
target->tilePos = resPos;
|
||||||
target->Place(resPos);
|
target->Place(resPos);
|
||||||
if (flags & SU_Summoned) {
|
if (flags & SU_Summoned) {
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
CommandDefend(*target, unit, FlushCommands);
|
CommandDefend(*target, unit, FlushCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//DropOutOnSide(*target, LookingW, NULL);
|
//DropOutOnSide(*target, LookingW, nullptr);
|
||||||
} else {
|
} else {
|
||||||
DebugPrint("Unable to allocate Unit");
|
DebugPrint("Unable to allocate Unit");
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,12 +271,12 @@ static void EditorActionPlaceUnit(const Vec2i &pos, const CUnitType &type, CPlay
|
||||||
|
|
||||||
// FIXME: vladi: should check place when mirror editing is enabled...?
|
// FIXME: vladi: should check place when mirror editing is enabled...?
|
||||||
CUnit *unit = MakeUnitAndPlace(pos, type, player);
|
CUnit *unit = MakeUnitAndPlace(pos, type, player);
|
||||||
if (unit == NULL) {
|
if (unit == nullptr) {
|
||||||
DebugPrint("Unable to allocate Unit");
|
DebugPrint("Unable to allocate Unit");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBuildRestrictionOnTop *b = OnTopDetails(*unit, NULL);
|
CBuildRestrictionOnTop *b = OnTopDetails(*unit, nullptr);
|
||||||
if (b && b->ReplaceOnBuild) {
|
if (b && b->ReplaceOnBuild) {
|
||||||
CUnitCache &unitCache = Map.Field(pos)->UnitCache;
|
CUnitCache &unitCache = Map.Field(pos)->UnitCache;
|
||||||
CUnitCache::iterator it = std::find_if(unitCache.begin(), unitCache.end(), HasSameTypeAs(*b->Parent));
|
CUnitCache::iterator it = std::find_if(unitCache.begin(), unitCache.end(), HasSameTypeAs(*b->Parent));
|
||||||
|
@ -287,13 +287,13 @@ static void EditorActionPlaceUnit(const Vec2i &pos, const CUnitType &type, CPlay
|
||||||
unit->Variable[GIVERESOURCE_INDEX].Value = replacedUnit.Variable[GIVERESOURCE_INDEX].Value;
|
unit->Variable[GIVERESOURCE_INDEX].Value = replacedUnit.Variable[GIVERESOURCE_INDEX].Value;
|
||||||
unit->Variable[GIVERESOURCE_INDEX].Max = replacedUnit.Variable[GIVERESOURCE_INDEX].Max;
|
unit->Variable[GIVERESOURCE_INDEX].Max = replacedUnit.Variable[GIVERESOURCE_INDEX].Max;
|
||||||
unit->Variable[GIVERESOURCE_INDEX].Enable = replacedUnit.Variable[GIVERESOURCE_INDEX].Enable;
|
unit->Variable[GIVERESOURCE_INDEX].Enable = replacedUnit.Variable[GIVERESOURCE_INDEX].Enable;
|
||||||
replacedUnit.Remove(NULL); // Destroy building beneath
|
replacedUnit.Remove(nullptr); // Destroy building beneath
|
||||||
UnitLost(replacedUnit);
|
UnitLost(replacedUnit);
|
||||||
UnitClearOrders(replacedUnit);
|
UnitClearOrders(replacedUnit);
|
||||||
replacedUnit.Release();
|
replacedUnit.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unit != NULL) {
|
if (unit != nullptr) {
|
||||||
if (type.GivesResource) {
|
if (type.GivesResource) {
|
||||||
if (type.StartingResources != 0) {
|
if (type.StartingResources != 0) {
|
||||||
unit->ResourcesHeld = type.StartingResources;
|
unit->ResourcesHeld = type.StartingResources;
|
||||||
|
@ -336,7 +336,7 @@ static void EditorPlaceUnit(const Vec2i &pos, CUnitType &type, CPlayer *player)
|
||||||
*/
|
*/
|
||||||
static void EditorActionRemoveUnit(CUnit &unit)
|
static void EditorActionRemoveUnit(CUnit &unit)
|
||||||
{
|
{
|
||||||
unit.Remove(NULL);
|
unit.Remove(nullptr);
|
||||||
UnitLost(unit);
|
UnitLost(unit);
|
||||||
UnitClearOrders(unit);
|
UnitClearOrders(unit);
|
||||||
unit.Release();
|
unit.Release();
|
||||||
|
@ -429,7 +429,7 @@ static void CalculateMaxIconSize()
|
||||||
for (unsigned int i = 0; i < Editor.UnitTypes.size(); ++i) {
|
for (unsigned int i = 0; i < Editor.UnitTypes.size(); ++i) {
|
||||||
if (!Editor.UnitTypes[i].empty()) {
|
if (!Editor.UnitTypes[i].empty()) {
|
||||||
const CUnitType *type = UnitTypeByIdent(Editor.UnitTypes[i].c_str());
|
const CUnitType *type = UnitTypeByIdent(Editor.UnitTypes[i].c_str());
|
||||||
if (type != NULL && type->Icon.Icon) {
|
if (type != nullptr && type->Icon.Icon) {
|
||||||
const CIcon &icon = *type->Icon.Icon;
|
const CIcon &icon = *type->Icon.Icon;
|
||||||
|
|
||||||
IconWidth = std::max(IconWidth, icon.G->Width);
|
IconWidth = std::max(IconWidth, icon.G->Width);
|
||||||
|
@ -451,7 +451,7 @@ static void RecalculateShownUnits(size_t start = 0, size_t stop = INT_MAX)
|
||||||
const CUnitType *type = UnitTypeByIdent(Editor.UnitTypes[i].c_str());
|
const CUnitType *type = UnitTypeByIdent(Editor.UnitTypes[i].c_str());
|
||||||
Editor.ShownUnitTypes.push_back(type);
|
Editor.ShownUnitTypes.push_back(type);
|
||||||
} else {
|
} else {
|
||||||
Editor.ShownUnitTypes.push_back(NULL);
|
Editor.ShownUnitTypes.push_back(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ static bool forEachUnitIconArea(std::function<bool(int,ButtonStyle*,int,int,int,
|
||||||
static void DrawUnitIcons()
|
static void DrawUnitIcons()
|
||||||
{
|
{
|
||||||
forEachUnitIconArea([](int i, ButtonStyle *style, int x, int y, int w, int h) {
|
forEachUnitIconArea([](int i, ButtonStyle *style, int x, int y, int w, int h) {
|
||||||
if (Editor.ShownUnitTypes[i] == NULL) {
|
if (Editor.ShownUnitTypes[i] == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CIcon &icon = *Editor.ShownUnitTypes[i]->Icon.Icon;
|
CIcon &icon = *Editor.ShownUnitTypes[i]->Icon.Icon;
|
||||||
|
@ -1304,7 +1304,7 @@ static void EditorCallbackButtonDown(unsigned button)
|
||||||
|
|
||||||
// Right click on a resource
|
// Right click on a resource
|
||||||
if (Editor.State == EditorSelecting) {
|
if (Editor.State == EditorSelecting) {
|
||||||
if ((MouseButtons & RightButton) && (UnitUnderCursor != NULL || !Selected.empty())) {
|
if ((MouseButtons & RightButton) && (UnitUnderCursor != nullptr || !Selected.empty())) {
|
||||||
lua_getglobal(Lua, "EditUnitProperties");
|
lua_getglobal(Lua, "EditUnitProperties");
|
||||||
if (lua_isfunction(Lua, -1) == 1) {
|
if (lua_isfunction(Lua, -1) == 1) {
|
||||||
lua_newtable(Lua);
|
lua_newtable(Lua);
|
||||||
|
@ -1331,11 +1331,11 @@ static void EditorCallbackButtonDown(unsigned button)
|
||||||
if (MouseButtons & RightButton) {
|
if (MouseButtons & RightButton) {
|
||||||
if (Editor.State == EditorEditUnit && Editor.SelectedUnitIndex != -1) {
|
if (Editor.State == EditorEditUnit && Editor.SelectedUnitIndex != -1) {
|
||||||
Editor.SelectedUnitIndex = -1;
|
Editor.SelectedUnitIndex = -1;
|
||||||
CursorBuilding = NULL;
|
CursorBuilding = nullptr;
|
||||||
return;
|
return;
|
||||||
} else if (Editor.State == EditorEditTile && Editor.SelectedTileIndex != -1) {
|
} else if (Editor.State == EditorEditTile && Editor.SelectedTileIndex != -1) {
|
||||||
Editor.SelectedTileIndex = -1;
|
Editor.SelectedTileIndex = -1;
|
||||||
CursorBuilding = NULL;
|
CursorBuilding = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1353,7 +1353,7 @@ static void EditorCallbackButtonDown(unsigned button)
|
||||||
EditTiles(tilePos, Editor.SelectedTileIndex != -1 ? Editor.ShownTileTypes[Editor.SelectedTileIndex] : -1, TileCursorSize);
|
EditTiles(tilePos, Editor.SelectedTileIndex != -1 ? Editor.ShownTileTypes[Editor.SelectedTileIndex] : -1, TileCursorSize);
|
||||||
} else if (Editor.State == EditorEditUnit) {
|
} else if (Editor.State == EditorEditUnit) {
|
||||||
if (!UnitPlacedThisPress && CursorBuilding) {
|
if (!UnitPlacedThisPress && CursorBuilding) {
|
||||||
if (CanBuildUnitType(NULL, *CursorBuilding, tilePos, 1)) {
|
if (CanBuildUnitType(nullptr, *CursorBuilding, tilePos, 1)) {
|
||||||
PlayGameSound(GameSounds.PlacementSuccess[ThisPlayer->Race].Sound,
|
PlayGameSound(GameSounds.PlacementSuccess[ThisPlayer->Race].Sound,
|
||||||
MaxSampleVolume);
|
MaxSampleVolume);
|
||||||
EditorPlaceUnit(tilePos, *CursorBuilding, Players + Editor.SelectedPlayer);
|
EditorPlaceUnit(tilePos, *CursorBuilding, Players + Editor.SelectedPlayer);
|
||||||
|
@ -1487,7 +1487,7 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
||||||
|
|
||||||
case SDLK_BACKSPACE:
|
case SDLK_BACKSPACE:
|
||||||
case SDLK_DELETE: // Delete
|
case SDLK_DELETE: // Delete
|
||||||
if (UnitUnderCursor != NULL) {
|
if (UnitUnderCursor != nullptr) {
|
||||||
EditorRemoveUnit(*UnitUnderCursor);
|
EditorRemoveUnit(*UnitUnderCursor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1510,7 +1510,7 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
if (!(KeyModifiers & ModifierAlt)) {
|
if (!(KeyModifiers & ModifierAlt)) {
|
||||||
if (UnitUnderCursor != NULL) {
|
if (UnitUnderCursor != nullptr) {
|
||||||
UnitUnderCursor->ChangeOwner(Players[PlayerNumNeutral]);
|
UnitUnderCursor->ChangeOwner(Players[PlayerNumNeutral]);
|
||||||
UI.StatusLine.Set(_("Unit owner modified"));
|
UI.StatusLine.Set(_("Unit owner modified"));
|
||||||
}
|
}
|
||||||
|
@ -1529,7 +1529,7 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (UnitUnderCursor != NULL && Map.Info.PlayerType[pnum] != PlayerTypes::PlayerNobody) {
|
if (UnitUnderCursor != nullptr && Map.Info.PlayerType[pnum] != PlayerTypes::PlayerNobody) {
|
||||||
UnitUnderCursor->ChangeOwner(Players[pnum]);
|
UnitUnderCursor->ChangeOwner(Players[pnum]);
|
||||||
UI.StatusLine.Set(_("Unit owner modified"));
|
UI.StatusLine.Set(_("Unit owner modified"));
|
||||||
UpdateMinimap = true;
|
UpdateMinimap = true;
|
||||||
|
@ -1645,7 +1645,7 @@ static bool EditorCallbackMouse_EditUnitArea(const PixelPos &screenPos)
|
||||||
|
|
||||||
noHit = forEachUnitIconArea([screenPos](int i, ButtonStyle*, int x, int y, int w, int h) {
|
noHit = forEachUnitIconArea([screenPos](int i, ButtonStyle*, int x, int y, int w, int h) {
|
||||||
if (x < screenPos.x && screenPos.x < x + w && y < screenPos.y && screenPos.y < y + h) {
|
if (x < screenPos.x && screenPos.x < x + w && y < screenPos.y && screenPos.y < y + h) {
|
||||||
if (Editor.ShownUnitTypes[i] == NULL) {
|
if (Editor.ShownUnitTypes[i] == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
@ -1777,7 +1777,7 @@ static void EditorCallbackMouse(const PixelPos &pos)
|
||||||
EditTiles(tilePos, Editor.SelectedTileIndex != -1 ? Editor.ShownTileTypes[Editor.SelectedTileIndex] : -1, TileCursorSize);
|
EditTiles(tilePos, Editor.SelectedTileIndex != -1 ? Editor.ShownTileTypes[Editor.SelectedTileIndex] : -1, TileCursorSize);
|
||||||
} else if (Editor.State == EditorEditUnit && CursorBuilding) {
|
} else if (Editor.State == EditorEditUnit && CursorBuilding) {
|
||||||
if (!UnitPlacedThisPress) {
|
if (!UnitPlacedThisPress) {
|
||||||
if (CanBuildUnitType(NULL, *CursorBuilding, tilePos, 1)) {
|
if (CanBuildUnitType(nullptr, *CursorBuilding, tilePos, 1)) {
|
||||||
EditorPlaceUnit(tilePos, *CursorBuilding, Players + Editor.SelectedPlayer);
|
EditorPlaceUnit(tilePos, *CursorBuilding, Players + Editor.SelectedPlayer);
|
||||||
UnitPlacedThisPress = true;
|
UnitPlacedThisPress = true;
|
||||||
UI.StatusLine.Clear();
|
UI.StatusLine.Clear();
|
||||||
|
@ -1839,7 +1839,7 @@ static void EditorCallbackMouse(const PixelPos &pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map
|
// Map
|
||||||
UnitUnderCursor = NULL;
|
UnitUnderCursor = nullptr;
|
||||||
if (UI.MapArea.Contains(screenPos)) {
|
if (UI.MapArea.Contains(screenPos)) {
|
||||||
CViewport *vp = GetViewport(screenPos);
|
CViewport *vp = GetViewport(screenPos);
|
||||||
Assert(vp);
|
Assert(vp);
|
||||||
|
@ -1854,7 +1854,7 @@ static void EditorCallbackMouse(const PixelPos &pos)
|
||||||
const PixelPos cursorMapPos = UI.MouseViewport->ScreenToMapPixelPos(CursorScreenPos);
|
const PixelPos cursorMapPos = UI.MouseViewport->ScreenToMapPixelPos(CursorScreenPos);
|
||||||
UnitUnderCursor = UnitOnScreen(cursorMapPos.x, cursorMapPos.y);
|
UnitUnderCursor = UnitOnScreen(cursorMapPos.x, cursorMapPos.y);
|
||||||
|
|
||||||
if (UnitUnderCursor != NULL) {
|
if (UnitUnderCursor != nullptr) {
|
||||||
ShowUnitInfo(*UnitUnderCursor);
|
ShowUnitInfo(*UnitUnderCursor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1943,9 +1943,9 @@ void CEditor::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (UI.ButtonPanel.G != NULL) {
|
if (UI.ButtonPanel.G != nullptr) {
|
||||||
ButtonPanelWidth = UI.ButtonPanel.G->Width;
|
ButtonPanelWidth = UI.ButtonPanel.G->Width;
|
||||||
} else if (UI.InfoPanel.G != NULL) {
|
} else if (UI.InfoPanel.G != nullptr) {
|
||||||
ButtonPanelWidth = UI.InfoPanel.G->Width;
|
ButtonPanelWidth = UI.InfoPanel.G->Width;
|
||||||
} else {
|
} else {
|
||||||
ButtonPanelWidth = 170;
|
ButtonPanelWidth = 170;
|
||||||
|
@ -1957,9 +1957,9 @@ void CEditor::Init()
|
||||||
if (!StartUnitName.empty()) {
|
if (!StartUnitName.empty()) {
|
||||||
StartUnit = UnitTypeByIdent(StartUnitName);
|
StartUnit = UnitTypeByIdent(StartUnitName);
|
||||||
}
|
}
|
||||||
Select.Icon = NULL;
|
Select.Icon = nullptr;
|
||||||
Select.Load();
|
Select.Load();
|
||||||
Units.Icon = NULL;
|
Units.Icon = nullptr;
|
||||||
Units.Load();
|
Units.Load();
|
||||||
|
|
||||||
Map.Tileset->fillSolidTiles(&Editor.ShownTileTypes);
|
Map.Tileset->fillSolidTiles(&Editor.ShownTileTypes);
|
||||||
|
@ -2280,7 +2280,7 @@ void EditorMainLoop()
|
||||||
|
|
||||||
WaitEventsOneFrame();
|
WaitEventsOneFrame();
|
||||||
}
|
}
|
||||||
CursorBuilding = NULL;
|
CursorBuilding = nullptr;
|
||||||
if (!Editor.MapLoaded) {
|
if (!Editor.MapLoaded) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2318,7 +2318,7 @@ void EditorMainLoop()
|
||||||
/**
|
/**
|
||||||
** Start the editor
|
** Start the editor
|
||||||
**
|
**
|
||||||
** @param filename Map to load, NULL to create a new map
|
** @param filename Map to load, nullptr to create a new map
|
||||||
*/
|
*/
|
||||||
void StartEditor(const char *filename)
|
void StartEditor(const char *filename)
|
||||||
{
|
{
|
||||||
|
@ -2327,7 +2327,7 @@ void StartEditor(const char *filename)
|
||||||
GetDefaultTextColors(nc, rc);
|
GetDefaultTextColors(nc, rc);
|
||||||
if (filename) {
|
if (filename) {
|
||||||
if (strcpy_s(CurrentMapPath, sizeof(CurrentMapPath), filename) != 0) {
|
if (strcpy_s(CurrentMapPath, sizeof(CurrentMapPath), filename) != 0) {
|
||||||
filename = NULL;
|
filename = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
|
|
||||||
CEditor::CEditor() :
|
CEditor::CEditor() :
|
||||||
TerrainEditable(true),
|
TerrainEditable(true),
|
||||||
StartUnit(NULL),
|
StartUnit(nullptr),
|
||||||
UnitIndex(0), CursorUnitIndex(-1), SelectedUnitIndex(-1),
|
UnitIndex(0), CursorUnitIndex(-1), SelectedUnitIndex(-1),
|
||||||
TileIndex(0), CursorTileIndex(-1), SelectedTileIndex(-1),
|
TileIndex(0), CursorTileIndex(-1), SelectedTileIndex(-1),
|
||||||
CursorPlayer(-1), SelectedPlayer(PlayerNumNeutral),
|
CursorPlayer(-1), SelectedPlayer(PlayerNumNeutral),
|
||||||
|
|
|
@ -367,28 +367,28 @@ static void EditorRandomizeUnit(const char *unit_type, int count, int value, int
|
||||||
|
|
||||||
// FIXME: can overlap units
|
// FIXME: can overlap units
|
||||||
CUnit *unit = MakeUnitAndPlace(rpos, type, &Players[PlayerNumNeutral]);
|
CUnit *unit = MakeUnitAndPlace(rpos, type, &Players[PlayerNumNeutral]);
|
||||||
if (unit == NULL) {
|
if (unit == nullptr) {
|
||||||
DebugPrint("Unable to allocate Unit");
|
DebugPrint("Unable to allocate Unit");
|
||||||
} else {
|
} else {
|
||||||
unit->ResourcesHeld = value;
|
unit->ResourcesHeld = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
unit = MakeUnitAndPlace(tmirrorh, type, &Players[PlayerNumNeutral]);
|
unit = MakeUnitAndPlace(tmirrorh, type, &Players[PlayerNumNeutral]);
|
||||||
if (unit == NULL) {
|
if (unit == nullptr) {
|
||||||
DebugPrint("Unable to allocate Unit");
|
DebugPrint("Unable to allocate Unit");
|
||||||
} else {
|
} else {
|
||||||
unit->ResourcesHeld = value;
|
unit->ResourcesHeld = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
unit = MakeUnitAndPlace(tmirrorv, type, &Players[PlayerNumNeutral]);
|
unit = MakeUnitAndPlace(tmirrorv, type, &Players[PlayerNumNeutral]);
|
||||||
if (unit == NULL) {
|
if (unit == nullptr) {
|
||||||
DebugPrint("Unable to allocate Unit");
|
DebugPrint("Unable to allocate Unit");
|
||||||
} else {
|
} else {
|
||||||
unit->ResourcesHeld = value;
|
unit->ResourcesHeld = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
unit = MakeUnitAndPlace(tmirror, type, &Players[PlayerNumNeutral]);
|
unit = MakeUnitAndPlace(tmirror, type, &Players[PlayerNumNeutral]);
|
||||||
if (unit == NULL) {
|
if (unit == nullptr) {
|
||||||
DebugPrint("Unable to allocate Unit");
|
DebugPrint("Unable to allocate Unit");
|
||||||
} else {
|
} else {
|
||||||
unit->ResourcesHeld = value;
|
unit->ResourcesHeld = value;
|
||||||
|
@ -404,7 +404,7 @@ static void EditorDestroyAllUnits()
|
||||||
while (UnitManager->empty() == false) {
|
while (UnitManager->empty() == false) {
|
||||||
CUnit &unit = **UnitManager->begin();
|
CUnit &unit = **UnitManager->begin();
|
||||||
|
|
||||||
unit.Remove(NULL);
|
unit.Remove(nullptr);
|
||||||
UnitLost(unit);
|
UnitLost(unit);
|
||||||
UnitClearOrders(unit);
|
UnitClearOrders(unit);
|
||||||
unit.Release();
|
unit.Release();
|
||||||
|
|
|
@ -258,7 +258,7 @@ static void WriteMapPreview(const char *mapname, CMap &map)
|
||||||
const SDL_PixelFormat *fmt = MinimapSurface->format;
|
const SDL_PixelFormat *fmt = MinimapSurface->format;
|
||||||
SDL_Surface *preview = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
SDL_Surface *preview = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||||
UI.Minimap.W, UI.Minimap.H, 32, fmt->Rmask, fmt->Gmask, fmt->Bmask, 0);
|
UI.Minimap.W, UI.Minimap.H, 32, fmt->Rmask, fmt->Gmask, fmt->Bmask, 0);
|
||||||
SDL_BlitSurface(MinimapSurface, NULL, preview, NULL);
|
SDL_BlitSurface(MinimapSurface, nullptr, preview, nullptr);
|
||||||
|
|
||||||
SDL_LockSurface(preview);
|
SDL_LockSurface(preview);
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ std::string PlayerTypeNames[static_cast<int>(PlayerTypes::PlayerRescueActive) +
|
||||||
// Write the map presentation file
|
// Write the map presentation file
|
||||||
static int WriteMapPresentation(const std::string &mapname, CMap &map, Vec2i newSize)
|
static int WriteMapPresentation(const std::string &mapname, CMap &map, Vec2i newSize)
|
||||||
{
|
{
|
||||||
FileWriter *f = NULL;
|
FileWriter *f = nullptr;
|
||||||
|
|
||||||
int numplayers = 0;
|
int numplayers = 0;
|
||||||
int topplayer = PlayerMax - 2;
|
int topplayer = PlayerMax - 2;
|
||||||
|
@ -347,7 +347,7 @@ static int WriteMapPresentation(const std::string &mapname, CMap &map, Vec2i new
|
||||||
*/
|
*/
|
||||||
int WriteMapSetup(const char *mapSetup, CMap &map, int writeTerrain, Vec2i newSize, Vec2i offset)
|
int WriteMapSetup(const char *mapSetup, CMap &map, int writeTerrain, Vec2i newSize, Vec2i offset)
|
||||||
{
|
{
|
||||||
FileWriter *f = NULL;
|
FileWriter *f = nullptr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
f = CreateFileWriter(mapSetup);
|
f = CreateFileWriter(mapSetup);
|
||||||
|
@ -837,7 +837,7 @@ void CreateGame(const std::string &filename, CMap *map)
|
||||||
if (SaveGameLoading) {
|
if (SaveGameLoading) {
|
||||||
SaveGameLoading = false;
|
SaveGameLoading = false;
|
||||||
// Load game, already created game with Init/LoadModules
|
// Load game, already created game with Init/LoadModules
|
||||||
CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog(nullptr, NoUnitP, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,7 +1090,7 @@ void CreateGame(const std::string &filename, CMap *map)
|
||||||
|
|
||||||
GameResult = GameNoResult;
|
GameResult = GameNoResult;
|
||||||
|
|
||||||
CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog(nullptr, NoUnitP, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
Video.ClearScreen();
|
Video.ClearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,8 +1139,8 @@ void CleanGame()
|
||||||
Map.Clean();
|
Map.Clean();
|
||||||
CleanReplayLog();
|
CleanReplayLog();
|
||||||
FreePathfinder();
|
FreePathfinder();
|
||||||
CursorBuilding = NULL;
|
CursorBuilding = nullptr;
|
||||||
UnitUnderCursor = NULL;
|
UnitUnderCursor = nullptr;
|
||||||
GameEstablishing = false;
|
GameEstablishing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ class LogEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LogEntry() : GameCycle(0), Flush(0), PosX(0), PosY(0), DestUnitNumber(0),
|
LogEntry() : GameCycle(0), Flush(0), PosX(0), PosY(0), DestUnitNumber(0),
|
||||||
Num(0), SyncRandSeed(0), Next(NULL)
|
Num(0), SyncRandSeed(0), Next(nullptr)
|
||||||
{
|
{
|
||||||
UnitNumber = 0;
|
UnitNumber = 0;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class FullReplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FullReplay() :
|
FullReplay() :
|
||||||
MapId(0), LocalPlayer(0), Commands(NULL)
|
MapId(0), LocalPlayer(0), Commands(nullptr)
|
||||||
{
|
{
|
||||||
ReplaySettings.Init();
|
ReplaySettings.Init();
|
||||||
memset(Engine, 0, sizeof(Engine));
|
memset(Engine, 0, sizeof(Engine));
|
||||||
|
@ -395,7 +395,7 @@ void CommandLog(const char *action, const CUnit *unit, int flush,
|
||||||
// don't retry for each command
|
// don't retry for each command
|
||||||
CommandLogDisabled = false;
|
CommandLogDisabled = false;
|
||||||
delete LogFile;
|
delete LogFile;
|
||||||
LogFile = NULL;
|
LogFile = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LastLogFileName = path;
|
LastLogFileName = path;
|
||||||
|
@ -533,7 +533,7 @@ static int CclReplayLog(lua_State *l)
|
||||||
LuaError(l, "incorrect argument");
|
LuaError(l, "incorrect argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(CurrentReplay == NULL);
|
Assert(CurrentReplay == nullptr);
|
||||||
|
|
||||||
replay = new FullReplay;
|
replay = new FullReplay;
|
||||||
|
|
||||||
|
@ -672,13 +672,13 @@ void EndReplayLog()
|
||||||
if (LogFile) {
|
if (LogFile) {
|
||||||
LogFile->close();
|
LogFile->close();
|
||||||
delete LogFile;
|
delete LogFile;
|
||||||
LogFile = NULL;
|
LogFile = nullptr;
|
||||||
}
|
}
|
||||||
if (CurrentReplay) {
|
if (CurrentReplay) {
|
||||||
DeleteReplay(CurrentReplay);
|
DeleteReplay(CurrentReplay);
|
||||||
CurrentReplay = NULL;
|
CurrentReplay = nullptr;
|
||||||
}
|
}
|
||||||
ReplayStep = NULL;
|
ReplayStep = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -690,7 +690,7 @@ void CleanReplayLog()
|
||||||
DeleteReplay(CurrentReplay);
|
DeleteReplay(CurrentReplay);
|
||||||
CurrentReplay = nullptr;
|
CurrentReplay = nullptr;
|
||||||
}
|
}
|
||||||
ReplayStep = NULL;
|
ReplayStep = nullptr;
|
||||||
|
|
||||||
// if (DisabledLog) {
|
// if (DisabledLog) {
|
||||||
CommandLogDisabled = false;
|
CommandLogDisabled = false;
|
||||||
|
@ -720,8 +720,8 @@ static void DoNextReplay()
|
||||||
const Vec2i pos(ReplayStep->PosX, ReplayStep->PosY);
|
const Vec2i pos(ReplayStep->PosX, ReplayStep->PosY);
|
||||||
const int arg1 = ReplayStep->PosX;
|
const int arg1 = ReplayStep->PosX;
|
||||||
const int arg2 = ReplayStep->PosY;
|
const int arg2 = ReplayStep->PosY;
|
||||||
CUnit *unit = unitSlot != -1 ? &UnitManager->GetSlotUnit(unitSlot) : NULL;
|
CUnit *unit = unitSlot != -1 ? &UnitManager->GetSlotUnit(unitSlot) : nullptr;
|
||||||
CUnit *dunit = (ReplayStep->DestUnitNumber != -1 ? &UnitManager->GetSlotUnit(ReplayStep->DestUnitNumber) : NULL);
|
CUnit *dunit = (ReplayStep->DestUnitNumber != -1 ? &UnitManager->GetSlotUnit(ReplayStep->DestUnitNumber) : nullptr);
|
||||||
const char *val = ReplayStep->Value.c_str();
|
const char *val = ReplayStep->Value.c_str();
|
||||||
const int num = ReplayStep->Num;
|
const int num = ReplayStep->Num;
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ static void DoNextReplay()
|
||||||
} else if (!strcmp(action, "train")) {
|
} else if (!strcmp(action, "train")) {
|
||||||
SendCommandTrainUnit(*unit, *UnitTypeByIdent(val), flags);
|
SendCommandTrainUnit(*unit, *UnitTypeByIdent(val), flags);
|
||||||
} else if (!strcmp(action, "cancel-train")) {
|
} else if (!strcmp(action, "cancel-train")) {
|
||||||
SendCommandCancelTraining(*unit, num, (val && *val) ? UnitTypeByIdent(val) : NULL);
|
SendCommandCancelTraining(*unit, num, (val && *val) ? UnitTypeByIdent(val) : nullptr);
|
||||||
} else if (!strcmp(action, "upgrade-to")) {
|
} else if (!strcmp(action, "upgrade-to")) {
|
||||||
SendCommandUpgradeTo(*unit, *UnitTypeByIdent(val), flags);
|
SendCommandUpgradeTo(*unit, *UnitTypeByIdent(val), flags);
|
||||||
} else if (!strcmp(action, "cancel-upgrade-to")) {
|
} else if (!strcmp(action, "cancel-upgrade-to")) {
|
||||||
|
|
|
@ -150,7 +150,7 @@ static CompareFunction GetCompareFunction(const char *op)
|
||||||
} else if (op[0] == '!' && op[1] == '=' && op[2] == '\0') {
|
} else if (op[0] == '!' && op[1] == '=' && op[2] == '\0') {
|
||||||
return &CompareNEq;
|
return &CompareNEq;
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -708,7 +708,7 @@ void CleanTriggers()
|
||||||
Trigger = 0;
|
Trigger = 0;
|
||||||
|
|
||||||
delete[] ActiveTriggers;
|
delete[] ActiveTriggers;
|
||||||
ActiveTriggers = NULL;
|
ActiveTriggers = nullptr;
|
||||||
|
|
||||||
GameTimer.Reset();
|
GameTimer.Reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class COrder_Attack : public COrder
|
||||||
friend COrder *COrder::NewActionAttackGround(const CUnit &attacker, const Vec2i &dest);
|
friend COrder *COrder::NewActionAttackGround(const CUnit &attacker, const Vec2i &dest);
|
||||||
public:
|
public:
|
||||||
explicit COrder_Attack(bool ground) : COrder(ground ? UnitActionAttackGround : UnitActionAttack),
|
explicit COrder_Attack(bool ground) : COrder(ground ? UnitActionAttackGround : UnitActionAttack),
|
||||||
State(0), MinRange(0), Range(0), SkirmishRange(0), offeredTarget(NULL), goalPos(-1, -1), attackMovePos(-1, -1), Sleep(0) {}
|
State(0), MinRange(0), Range(0), SkirmishRange(0), offeredTarget(nullptr), goalPos(-1, -1), attackMovePos(-1, -1), Sleep(0) {}
|
||||||
|
|
||||||
virtual COrder_Attack *Clone() const { return new COrder_Attack(*this); }
|
virtual COrder_Attack *Clone() const { return new COrder_Attack(*this); }
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class COrder_Build : public COrder
|
||||||
{
|
{
|
||||||
friend COrder *COrder::NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building);
|
friend COrder *COrder::NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building);
|
||||||
public:
|
public:
|
||||||
COrder_Build() : COrder(UnitActionBuild), Type(NULL), State(0), Range(0)
|
COrder_Build() : COrder(UnitActionBuild), Type(nullptr), State(0), Range(0)
|
||||||
{
|
{
|
||||||
goalPos.x = -1;
|
goalPos.x = -1;
|
||||||
goalPos.y = -1;
|
goalPos.y = -1;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class COrder_Built : public COrder
|
||||||
{
|
{
|
||||||
friend COrder *COrder::NewActionBuilt(CUnit &builder, CUnit &unit);
|
friend COrder *COrder::NewActionBuilt(CUnit &builder, CUnit &unit);
|
||||||
public:
|
public:
|
||||||
COrder_Built() : COrder(UnitActionBuilt), ProgressCounter(0), IsCancelled(false), Frame(NULL) {}
|
COrder_Built() : COrder(UnitActionBuilt), ProgressCounter(0), IsCancelled(false), Frame(nullptr) {}
|
||||||
~COrder_Built();
|
~COrder_Built();
|
||||||
|
|
||||||
virtual COrder_Built *Clone() const { return new COrder_Built(*this); }
|
virtual COrder_Built *Clone() const { return new COrder_Built(*this); }
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
class COrder_Research : public COrder
|
class COrder_Research : public COrder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
COrder_Research() : COrder(UnitActionResearch), Upgrade(NULL) {}
|
COrder_Research() : COrder(UnitActionResearch), Upgrade(nullptr) {}
|
||||||
|
|
||||||
virtual COrder_Research *Clone() const { return new COrder_Research(*this); }
|
virtual COrder_Research *Clone() const { return new COrder_Research(*this); }
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class COrder_SpellCast : public COrder
|
||||||
{
|
{
|
||||||
friend COrder *COrder::NewActionSpellCast(const SpellType &spell, const Vec2i &pos, CUnit *target, bool isAutocast);
|
friend COrder *COrder::NewActionSpellCast(const SpellType &spell, const Vec2i &pos, CUnit *target, bool isAutocast);
|
||||||
public:
|
public:
|
||||||
COrder_SpellCast(bool autocast = false) : COrder(UnitActionSpellCast), Spell(NULL), State(0), Range(0), isAutocast(autocast)
|
COrder_SpellCast(bool autocast = false) : COrder(UnitActionSpellCast), Spell(nullptr), State(0), Range(0), isAutocast(autocast)
|
||||||
{
|
{
|
||||||
goalPos.x = -1;
|
goalPos.x = -1;
|
||||||
goalPos.y = -1;
|
goalPos.y = -1;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class COrder_Train : public COrder
|
||||||
{
|
{
|
||||||
friend COrder *COrder::NewActionTrain(CUnit &trainer, CUnitType &type);
|
friend COrder *COrder::NewActionTrain(CUnit &trainer, CUnitType &type);
|
||||||
public:
|
public:
|
||||||
COrder_Train() : COrder(UnitActionTrain), Type(NULL), Ticks(0) {}
|
COrder_Train() : COrder(UnitActionTrain), Type(nullptr), Ticks(0) {}
|
||||||
|
|
||||||
virtual COrder_Train *Clone() const { return new COrder_Train(*this); }
|
virtual COrder_Train *Clone() const { return new COrder_Train(*this); }
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class COrder_TransformInto : public COrder
|
||||||
{
|
{
|
||||||
friend COrder *COrder::NewActionTransformInto(CUnitType &type);
|
friend COrder *COrder::NewActionTransformInto(CUnitType &type);
|
||||||
public:
|
public:
|
||||||
COrder_TransformInto() : COrder(UnitActionTransformInto), Type(NULL) {}
|
COrder_TransformInto() : COrder(UnitActionTransformInto), Type(nullptr) {}
|
||||||
|
|
||||||
virtual COrder_TransformInto *Clone() const { return new COrder_TransformInto(*this); }
|
virtual COrder_TransformInto *Clone() const { return new COrder_TransformInto(*this); }
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class COrder_UpgradeTo : public COrder
|
||||||
{
|
{
|
||||||
friend COrder *COrder::NewActionUpgradeTo(CUnit &unit, CUnitType &type, bool instant);
|
friend COrder *COrder::NewActionUpgradeTo(CUnit &unit, CUnitType &type, bool instant);
|
||||||
public:
|
public:
|
||||||
COrder_UpgradeTo() : COrder(UnitActionUpgradeTo), Type(NULL), Ticks(0) {}
|
COrder_UpgradeTo() : COrder(UnitActionUpgradeTo), Type(nullptr), Ticks(0) {}
|
||||||
|
|
||||||
virtual COrder_UpgradeTo *Clone() const { return new COrder_UpgradeTo(*this); }
|
virtual COrder_UpgradeTo *Clone() const { return new COrder_UpgradeTo(*this); }
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public:
|
||||||
|
|
||||||
virtual void UpdatePathFinderData(PathFinderInput &input) = 0;
|
virtual void UpdatePathFinderData(PathFinderInput &input) = 0;
|
||||||
|
|
||||||
bool HasGoal() const { return Goal != NULL; }
|
bool HasGoal() const { return Goal != nullptr; }
|
||||||
CUnit *GetGoal() const { return Goal; };
|
CUnit *GetGoal() const { return Goal; };
|
||||||
void SetGoal(CUnit *const new_goal);
|
void SetGoal(CUnit *const new_goal);
|
||||||
void ClearGoal();
|
void ClearGoal();
|
||||||
|
|
|
@ -94,12 +94,12 @@ enum SetVar_ModifyTypes {
|
||||||
class CAnimation
|
class CAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAnimation(AnimationType type) : Type(type), Next(NULL) {}
|
CAnimation(AnimationType type) : Type(type), Next(nullptr) {}
|
||||||
|
|
||||||
virtual ~CAnimation() {}
|
virtual ~CAnimation() {}
|
||||||
|
|
||||||
virtual void Action(CUnit &unit, int &move, int scale) const = 0;
|
virtual void Action(CUnit &unit, int &move, int scale) const = 0;
|
||||||
virtual void Init(const char *s, lua_State *l = NULL) {}
|
virtual void Init(const char *s, lua_State *l = nullptr) {}
|
||||||
|
|
||||||
const AnimationType Type;
|
const AnimationType Type;
|
||||||
CAnimation *Next;
|
CAnimation *Next;
|
||||||
|
@ -108,9 +108,9 @@ public:
|
||||||
class CAnimations
|
class CAnimations
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAnimations() : Attack(NULL), RangedAttack(NULL), Build(NULL), Move(NULL), Repair(NULL),
|
CAnimations() : Attack(nullptr), RangedAttack(nullptr), Build(nullptr), Move(nullptr), Repair(nullptr),
|
||||||
Research(NULL), SpellCast(NULL), Start(NULL), Still(NULL),
|
Research(nullptr), SpellCast(nullptr), Start(nullptr), Still(nullptr),
|
||||||
Train(NULL), Upgrade(NULL), hasDeathAnimation(false)
|
Train(nullptr), Upgrade(nullptr), hasDeathAnimation(false)
|
||||||
{
|
{
|
||||||
memset(Death, 0, sizeof(Death));
|
memset(Death, 0, sizeof(Death));
|
||||||
memset(Harvest, 0, sizeof(Harvest));
|
memset(Harvest, 0, sizeof(Harvest));
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
class CAnimation_Goto : public CAnimation
|
class CAnimation_Goto : public CAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAnimation_Goto() : CAnimation(AnimationGoto), gotoLabel(NULL) {}
|
CAnimation_Goto() : CAnimation(AnimationGoto), gotoLabel(nullptr) {}
|
||||||
|
|
||||||
virtual void Action(CUnit &unit, int &move, int scale) const;
|
virtual void Action(CUnit &unit, int &move, int scale) const;
|
||||||
virtual void Init(const char *s, lua_State *l);
|
virtual void Init(const char *s, lua_State *l);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
class CAnimation_IfVar : public CAnimation
|
class CAnimation_IfVar : public CAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAnimation_IfVar() : CAnimation(AnimationIfVar), binOpFunc(NULL), gotoLabel(NULL) {}
|
CAnimation_IfVar() : CAnimation(AnimationIfVar), binOpFunc(nullptr), gotoLabel(nullptr) {}
|
||||||
|
|
||||||
virtual void Action(CUnit &unit, int &move, int scale) const;
|
virtual void Action(CUnit &unit, int &move, int scale) const;
|
||||||
virtual void Init(const char *s, lua_State *l);
|
virtual void Init(const char *s, lua_State *l);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
class CAnimation_LuaCallback : public CAnimation
|
class CAnimation_LuaCallback : public CAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAnimation_LuaCallback() : CAnimation(AnimationLuaCallback), cb(NULL) {}
|
CAnimation_LuaCallback() : CAnimation(AnimationLuaCallback), cb(nullptr) {}
|
||||||
~CAnimation_LuaCallback() { delete cb; }
|
~CAnimation_LuaCallback() { delete cb; }
|
||||||
|
|
||||||
virtual void Action(CUnit &unit, int &move, int scale) const;
|
virtual void Action(CUnit &unit, int &move, int scale) const;
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
class CAnimation_RandomGoto : public CAnimation
|
class CAnimation_RandomGoto : public CAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAnimation_RandomGoto() : CAnimation(AnimationRandomGoto), gotoLabel(NULL) {}
|
CAnimation_RandomGoto() : CAnimation(AnimationRandomGoto), gotoLabel(nullptr) {}
|
||||||
|
|
||||||
virtual void Action(CUnit &unit, int &move, int scale) const;
|
virtual void Action(CUnit &unit, int &move, int scale) const;
|
||||||
virtual void Init(const char *s, lua_State *l);
|
virtual void Init(const char *s, lua_State *l);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
class CAnimation_Wiggle : public CAnimation
|
class CAnimation_Wiggle : public CAnimation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAnimation_Wiggle() : CAnimation(AnimationWiggle), isHeading(false), isZDisplacement(false), speed(""), ifNotReached(NULL) {}
|
CAnimation_Wiggle() : CAnimation(AnimationWiggle), isHeading(false), isZDisplacement(false), speed(""), ifNotReached(nullptr) {}
|
||||||
|
|
||||||
virtual void Action(CUnit &unit, int &move, int scale) const;
|
virtual void Action(CUnit &unit, int &move, int scale) const;
|
||||||
virtual void Init(const char *s, lua_State *l);
|
virtual void Init(const char *s, lua_State *l);
|
||||||
|
|
|
@ -113,7 +113,7 @@ class CConstructionFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CConstructionFrame() : Percent(0), File(ConstructionFileConstruction),
|
CConstructionFrame() : Percent(0), File(ConstructionFileConstruction),
|
||||||
Frame(0), Next(NULL) {}
|
Frame(0), Next(nullptr) {}
|
||||||
|
|
||||||
int Percent; /// Percent complete
|
int Percent; /// Percent complete
|
||||||
ConstructionFileType File; /// Graphic to use
|
ConstructionFileType File; /// Graphic to use
|
||||||
|
@ -125,8 +125,8 @@ public:
|
||||||
class CConstruction
|
class CConstruction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CConstruction() : Frames(NULL), Sprite(NULL), Width(0),
|
CConstruction() : Frames(nullptr), Sprite(nullptr), Width(0),
|
||||||
Height(0), ShadowSprite(NULL), ShadowWidth(0), ShadowHeight(0)
|
Height(0), ShadowSprite(nullptr), ShadowWidth(0), ShadowHeight(0)
|
||||||
{
|
{
|
||||||
File.Width = 0;
|
File.Width = 0;
|
||||||
File.Height = 0;
|
File.Height = 0;
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
** CCursor::Race
|
** CCursor::Race
|
||||||
**
|
**
|
||||||
** Owning Race of this cursor ("human", "orc", "alliance",
|
** Owning Race of this cursor ("human", "orc", "alliance",
|
||||||
** "mythical", ...). If NULL, this cursor could be used by any
|
** "mythical", ...). If nullptr, this cursor could be used by any
|
||||||
** race.
|
** race.
|
||||||
**
|
**
|
||||||
** CCursor::HotPos
|
** CCursor::HotPos
|
||||||
|
@ -125,7 +125,7 @@ class CCursor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCursor() : HotPos(0, 0),
|
CCursor() : HotPos(0, 0),
|
||||||
SpriteFrame(0), FrameRate(0), G(NULL) {}
|
SpriteFrame(0), FrameRate(0), G(nullptr) {}
|
||||||
|
|
||||||
~CCursor();
|
~CCursor();
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ private:
|
||||||
class CursorConfig
|
class CursorConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CursorConfig() : Cursor(NULL) {}
|
CursorConfig() : Cursor(nullptr) {}
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ class CFont : public gcn::Font
|
||||||
private:
|
private:
|
||||||
explicit CFont(const std::string &ident) :
|
explicit CFont(const std::string &ident) :
|
||||||
Ident(ident),
|
Ident(ident),
|
||||||
CharWidth(NULL),
|
CharWidth(nullptr),
|
||||||
G(NULL)
|
G(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -172,7 +172,7 @@ private:
|
||||||
class IconConfig
|
class IconConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IconConfig() : Icon(NULL) {}
|
IconConfig() : Icon(nullptr) {}
|
||||||
|
|
||||||
bool LoadNoLog();
|
bool LoadNoLog();
|
||||||
bool Load();
|
bool Load();
|
||||||
|
|
|
@ -88,8 +88,8 @@ typedef bool (*ButtonCheckFunc)(const CUnit &, const ButtonAction &);
|
||||||
class ButtonAction
|
class ButtonAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ButtonAction() : Pos(0), Level(0), AlwaysShow(false), Action(ButtonMove), Value(0), Payload(NULL),
|
ButtonAction() : Pos(0), Level(0), AlwaysShow(false), Action(ButtonMove), Value(0), Payload(nullptr),
|
||||||
Allowed(NULL), Key(0) {}
|
Allowed(nullptr), Key(0) {}
|
||||||
|
|
||||||
int Pos; /// button position in the grid
|
int Pos; /// button position in the grid
|
||||||
int Level; /// requires button level
|
int Level; /// requires button level
|
||||||
|
|
|
@ -424,7 +424,7 @@ public:
|
||||||
|
|
||||||
void DrawMissile(const CViewport &vp) const;
|
void DrawMissile(const CViewport &vp) const;
|
||||||
void SaveMissile(CFile &file) const;
|
void SaveMissile(CFile &file) const;
|
||||||
void MissileHit(CUnit *unit = NULL);
|
void MissileHit(CUnit *unit = nullptr);
|
||||||
bool NextMissileFrame(char sign, char longAnimation);
|
bool NextMissileFrame(char sign, char longAnimation);
|
||||||
void NextMissileFrameCycle();
|
void NextMissileFrameCycle();
|
||||||
void MissileNewHeadingFromXY(const PixelPos &delta);
|
void MissileNewHeadingFromXY(const PixelPos &delta);
|
||||||
|
@ -566,7 +566,7 @@ public:
|
||||||
class BurningBuildingFrame
|
class BurningBuildingFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BurningBuildingFrame() : Percent(0), Missile(NULL) {};
|
BurningBuildingFrame() : Percent(0), Missile(nullptr) {};
|
||||||
|
|
||||||
int Percent; /// HP percent
|
int Percent; /// HP percent
|
||||||
MissileType *Missile; /// Missile to draw
|
MissileType *Missile; /// Missile to draw
|
||||||
|
|
|
@ -44,7 +44,7 @@ class MissileType;
|
||||||
class MissileConfig
|
class MissileConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MissileConfig() : Missile(NULL) {}
|
MissileConfig() : Missile(nullptr) {}
|
||||||
|
|
||||||
bool MapMissileNoLog();
|
bool MapMissileNoLog();
|
||||||
bool MapMissile();
|
bool MapMissile();
|
||||||
|
|
|
@ -87,8 +87,8 @@ struct OggData {
|
||||||
class Movie : public gcn::Image
|
class Movie : public gcn::Image
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Movie() : rect(NULL), yuv_overlay(NULL), surface(NULL), need_data(true), start_time(0),
|
Movie() : rect(nullptr), yuv_overlay(nullptr), surface(nullptr), need_data(true), start_time(0),
|
||||||
is_dirty(true), Width(0), Height(0), data(NULL), f(NULL) {};
|
is_dirty(true), Width(0), Height(0), data(nullptr), f(nullptr) {};
|
||||||
~Movie();
|
~Movie();
|
||||||
bool Load(const std::string &filename, int w, int h);
|
bool Load(const std::string &filename, int w, int h);
|
||||||
bool IsPlaying() const { return is_dirty; }
|
bool IsPlaying() const { return is_dirty; }
|
||||||
|
@ -138,7 +138,7 @@ public:
|
||||||
bool Load(const std::string &filename, int w, int h) { return false; };
|
bool Load(const std::string &filename, int w, int h) { return false; };
|
||||||
bool IsPlaying() const { return false; };
|
bool IsPlaying() const { return false; };
|
||||||
//guichan
|
//guichan
|
||||||
virtual void *_getData() const { return NULL; };
|
virtual void *_getData() const { return nullptr; };
|
||||||
virtual int getWidth() const { return 0; };
|
virtual int getWidth() const { return 0; };
|
||||||
virtual int getHeight() const { return 0; };
|
virtual int getHeight() const { return 0; };
|
||||||
virtual bool isDirty() const { return false; };
|
virtual bool isDirty() const { return false; };
|
||||||
|
|
|
@ -174,7 +174,7 @@ extern void PlayMissileSound(const Missile &missile, CSound *sound);
|
||||||
extern void PlayGameSound(CSound *sound, unsigned char volume, bool always = false);
|
extern void PlayGameSound(CSound *sound, unsigned char volume, bool always = false);
|
||||||
|
|
||||||
/// Play a sound file
|
/// Play a sound file
|
||||||
extern int PlayFile(const std::string &name, LuaActionListener *listener = NULL);
|
extern int PlayFile(const std::string &name, LuaActionListener *listener = nullptr);
|
||||||
|
|
||||||
/// Modify the range of a given sound.
|
/// Modify the range of a given sound.
|
||||||
extern void SetSoundRange(CSound *sound, unsigned char range);
|
extern void SetSoundRange(CSound *sound, unsigned char range);
|
||||||
|
|
|
@ -71,7 +71,7 @@ extern Mix_Music *LoadMusic(const std::string &name);
|
||||||
extern Mix_Chunk *LoadSample(const std::string &name);
|
extern Mix_Chunk *LoadSample(const std::string &name);
|
||||||
extern void FreeSample(Mix_Chunk *sample);
|
extern void FreeSample(Mix_Chunk *sample);
|
||||||
/// Play a sample
|
/// Play a sample
|
||||||
extern int PlaySample(Mix_Chunk *sample, Origin *origin = NULL);
|
extern int PlaySample(Mix_Chunk *sample, Origin *origin = nullptr);
|
||||||
/// Play a sample, registering a "finished" callback
|
/// Play a sample, registering a "finished" callback
|
||||||
extern int PlaySample(Mix_Chunk *sample, void (*callback)(int channel));
|
extern int PlaySample(Mix_Chunk *sample, void (*callback)(int channel));
|
||||||
/// Play a sound file
|
/// Play a sound file
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
class Spell_AdjustVariable : public SpellActionType
|
class Spell_AdjustVariable : public SpellActionType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Spell_AdjustVariable() : Var(NULL) {};
|
Spell_AdjustVariable() : Var(nullptr) {};
|
||||||
~Spell_AdjustVariable() { delete [](this->Var); };
|
~Spell_AdjustVariable() { delete [](this->Var); };
|
||||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||||
CUnit *&target, const Vec2i &goalPos);
|
CUnit *&target, const Vec2i &goalPos);
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Spell_AreaBombardment : public SpellActionType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Spell_AreaBombardment() : Fields(0), Shards(0), Damage(0),
|
Spell_AreaBombardment() : Fields(0), Shards(0), Damage(0),
|
||||||
StartOffsetX(0), StartOffsetY(0), Missile(NULL) {};
|
StartOffsetX(0), StartOffsetY(0), Missile(nullptr) {};
|
||||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||||
CUnit *&target, const Vec2i &goalPos);
|
CUnit *&target, const Vec2i &goalPos);
|
||||||
virtual void Parse(lua_State *l, int startIndex, int endIndex);
|
virtual void Parse(lua_State *l, int startIndex, int endIndex);
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
class Spell_LuaCallback : public SpellActionType
|
class Spell_LuaCallback : public SpellActionType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Spell_LuaCallback() : Func(NULL) {};
|
Spell_LuaCallback() : Func(nullptr) {};
|
||||||
~Spell_LuaCallback() { delete Func; };
|
~Spell_LuaCallback() { delete Func; };
|
||||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||||
CUnit *&target, const Vec2i &goalPos);
|
CUnit *&target, const Vec2i &goalPos);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
class Spell_Polymorph : public SpellActionType
|
class Spell_Polymorph : public SpellActionType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Spell_Polymorph() : SpellActionType(1), NewForm(NULL), PlayerNeutral(0) {};
|
Spell_Polymorph() : SpellActionType(1), NewForm(nullptr), PlayerNeutral(0) {};
|
||||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||||
CUnit *&target, const Vec2i &goalPos);
|
CUnit *&target, const Vec2i &goalPos);
|
||||||
virtual void Parse(lua_State *l, int startIndex, int endIndex);
|
virtual void Parse(lua_State *l, int startIndex, int endIndex);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
class Spell_Summon : public SpellActionType
|
class Spell_Summon : public SpellActionType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Spell_Summon() : SpellActionType(1), UnitType(NULL), TTL(0),
|
Spell_Summon() : SpellActionType(1), UnitType(nullptr), TTL(0),
|
||||||
RequireCorpse(false), JoinToAiForce(false) {};
|
RequireCorpse(false), JoinToAiForce(false) {};
|
||||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||||
CUnit *&target, const Vec2i &goalPos);
|
CUnit *&target, const Vec2i &goalPos);
|
||||||
|
|
|
@ -137,7 +137,7 @@ class ConditionInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConditionInfo() : Alliance(0), Opponent(0), TargetSelf(1),
|
ConditionInfo() : Alliance(0), Opponent(0), TargetSelf(1),
|
||||||
BoolFlag(NULL), Variable(NULL), CheckFunc(NULL) {};
|
BoolFlag(nullptr), Variable(nullptr), CheckFunc(nullptr) {};
|
||||||
~ConditionInfo()
|
~ConditionInfo()
|
||||||
{
|
{
|
||||||
delete[] BoolFlag;
|
delete[] BoolFlag;
|
||||||
|
@ -173,8 +173,8 @@ public:
|
||||||
// Special flags for priority sorting
|
// Special flags for priority sorting
|
||||||
#define ACP_NOVALUE -1
|
#define ACP_NOVALUE -1
|
||||||
#define ACP_DISTANCE -2
|
#define ACP_DISTANCE -2
|
||||||
AutoCastInfo() : Range(0), MinRange(0), PriorytyVar(ACP_NOVALUE), ReverseSort(false), Condition(NULL),
|
AutoCastInfo() : Range(0), MinRange(0), PriorytyVar(ACP_NOVALUE), ReverseSort(false), Condition(nullptr),
|
||||||
Combat(0), Attacker(0), Corpse(CONDITION_FALSE), PositionAutoCast(NULL) {};
|
Combat(0), Attacker(0), Corpse(CONDITION_FALSE), PositionAutoCast(nullptr) {};
|
||||||
~AutoCastInfo()
|
~AutoCastInfo()
|
||||||
{
|
{
|
||||||
delete Condition;
|
delete Condition;
|
||||||
|
|
|
@ -32,8 +32,8 @@ inline void print_backtrace(int sz = 100) {
|
||||||
char* name;
|
char* name;
|
||||||
|
|
||||||
process = GetCurrentProcess();
|
process = GetCurrentProcess();
|
||||||
SymInitialize(process, NULL, TRUE);
|
SymInitialize(process, nullptr, TRUE);
|
||||||
frames = CaptureStackBackTrace(0, sz, stack, NULL);
|
frames = CaptureStackBackTrace(0, sz, stack, nullptr);
|
||||||
fprintf(stderr, "backtrace returned %d addresses\n", frames);
|
fprintf(stderr, "backtrace returned %d addresses\n", frames);
|
||||||
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 1024 * sizeof(char), 1);
|
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 1024 * sizeof(char), 1);
|
||||||
symbol->MaxNameLen = 1024;
|
symbol->MaxNameLen = 1024;
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
class TitleScreen
|
class TitleScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TitleScreen() : StretchImage(true), Timeout(0), Iterations(0), Editor(0), Labels(NULL) {}
|
TitleScreen() : StretchImage(true), Timeout(0), Iterations(0), Editor(0), Labels(nullptr) {}
|
||||||
~TitleScreen()
|
~TitleScreen()
|
||||||
{
|
{
|
||||||
if (this->Labels) {
|
if (this->Labels) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ enum TextAlignment {
|
||||||
class ButtonStyleProperties
|
class ButtonStyleProperties
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ButtonStyleProperties() : Sprite(NULL), Frame(0), BorderColor(0),
|
ButtonStyleProperties() : Sprite(nullptr), Frame(0), BorderColor(0),
|
||||||
BorderSize(0), TextAlign(TextAlignUndefined),
|
BorderSize(0), TextAlign(TextAlignUndefined),
|
||||||
TextPos(0, 0)
|
TextPos(0, 0)
|
||||||
{}
|
{}
|
||||||
|
@ -124,9 +124,9 @@ public:
|
||||||
class CUIButton
|
class CUIButton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUIButton() : X(0), Y(0), Style(NULL), Callback(NULL) {} //OLD BUTTON STYLE CODE
|
CUIButton() : X(0), Y(0), Style(nullptr), Callback(nullptr) {} //OLD BUTTON STYLE CODE
|
||||||
// NEW CODE BELOW, THANKS TO ANDRETTIN - MODIFIED BY DINKY
|
// NEW CODE BELOW, THANKS TO ANDRETTIN - MODIFIED BY DINKY
|
||||||
// CUIButton() : X(0), Y(0), Clicked(false), HotKeyPressed(false), Style(NULL), Callback(NULL) {}
|
// CUIButton() : X(0), Y(0), Clicked(false), HotKeyPressed(false), Style(nullptr), Callback(nullptr) {}
|
||||||
~CUIButton() {}
|
~CUIButton() {}
|
||||||
|
|
||||||
bool Contains(const PixelPos &screenPos) const;
|
bool Contains(const PixelPos &screenPos) const;
|
||||||
|
@ -186,8 +186,8 @@ class ConditionPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConditionPanel() : ShowOnlySelected(false), HideNeutral(false),
|
ConditionPanel() : ShowOnlySelected(false), HideNeutral(false),
|
||||||
HideAllied(false), ShowOpponent(false), BoolFlags(NULL),
|
HideAllied(false), ShowOpponent(false), BoolFlags(nullptr),
|
||||||
Variables(NULL) {}
|
Variables(nullptr) {}
|
||||||
~ConditionPanel()
|
~ConditionPanel()
|
||||||
{
|
{
|
||||||
delete[] BoolFlags;
|
delete[] BoolFlags;
|
||||||
|
@ -211,7 +211,7 @@ class CUnitInfoPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUnitInfoPanel() : PosX(0), PosY(0), DefaultFont(0),
|
CUnitInfoPanel() : PosX(0), PosY(0), DefaultFont(0),
|
||||||
Contents(), Condition(NULL) {}
|
Contents(), Condition(nullptr) {}
|
||||||
~CUnitInfoPanel();
|
~CUnitInfoPanel();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -222,14 +222,14 @@ public:
|
||||||
|
|
||||||
std::vector<CContentType *>Contents; /// Array of contents to display.
|
std::vector<CContentType *>Contents; /// Array of contents to display.
|
||||||
|
|
||||||
ConditionPanel *Condition; /// Condition to show the panel; if NULL, no condition.
|
ConditionPanel *Condition; /// Condition to show the panel; if nullptr, no condition.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CFiller
|
class CFiller
|
||||||
{
|
{
|
||||||
struct bits_map {
|
struct bits_map {
|
||||||
bits_map() : Width(0), Height(0), bstore(NULL) {}
|
bits_map() : Width(0), Height(0), bstore(nullptr) {}
|
||||||
~bits_map();
|
~bits_map();
|
||||||
|
|
||||||
void Init(CGraphic *g);
|
void Init(CGraphic *g);
|
||||||
|
@ -253,7 +253,7 @@ class CFiller
|
||||||
|
|
||||||
bits_map map;
|
bits_map map;
|
||||||
public:
|
public:
|
||||||
CFiller() : G(NULL), X(0), Y(0) {}
|
CFiller() : G(nullptr), X(0), Y(0) {}
|
||||||
|
|
||||||
void Load();
|
void Load();
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ public:
|
||||||
class CButtonPanel
|
class CButtonPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CButtonPanel() : G(NULL), X(0), Y(0), ShowCommandKey(true)
|
CButtonPanel() : G(nullptr), X(0), Y(0), ShowCommandKey(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Draw();
|
void Draw();
|
||||||
|
@ -315,7 +315,7 @@ public:
|
||||||
class CPieMenu
|
class CPieMenu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPieMenu() : G(NULL), MouseButton(NoButton)
|
CPieMenu() : G(nullptr), MouseButton(NoButton)
|
||||||
{
|
{
|
||||||
memset(this->X, 0, sizeof(this->X));
|
memset(this->X, 0, sizeof(this->X));
|
||||||
memset(this->Y, 0, sizeof(this->Y));
|
memset(this->Y, 0, sizeof(this->Y));
|
||||||
|
@ -340,7 +340,7 @@ public:
|
||||||
class CResourceInfo
|
class CResourceInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CResourceInfo() : G(NULL), IconFrame(0), IconX(0), IconY(0), IconWidth(-1),
|
CResourceInfo() : G(nullptr), IconFrame(0), IconX(0), IconY(0), IconWidth(-1),
|
||||||
TextX(-1), TextY(-1) {}
|
TextX(-1), TextY(-1) {}
|
||||||
|
|
||||||
CGraphic *G; /// icon graphic
|
CGraphic *G; /// icon graphic
|
||||||
|
@ -356,7 +356,7 @@ public:
|
||||||
class CInfoPanel
|
class CInfoPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CInfoPanel() : G(NULL), X(0), Y(0) {}
|
CInfoPanel() : G(nullptr), X(0), Y(0) {}
|
||||||
|
|
||||||
void Draw();
|
void Draw();
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class ConditionPanel;
|
||||||
class CContentType
|
class CContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CContentType() : Pos(0, 0), Condition(NULL) {}
|
CContentType() : Pos(0, 0), Condition(nullptr) {}
|
||||||
virtual ~CContentType();
|
virtual ~CContentType();
|
||||||
|
|
||||||
/// Tell how show the variable Index.
|
/// Tell how show the variable Index.
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PixelPos Pos; /// Coordinate where to display.
|
PixelPos Pos; /// Coordinate where to display.
|
||||||
ConditionPanel *Condition; /// Condition to show the content; if NULL, no condition.
|
ConditionPanel *Condition; /// Condition to show the content; if nullptr, no condition.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,7 @@ public:
|
||||||
class CContentTypeText : public CContentType
|
class CContentTypeText : public CContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CContentTypeText() : Text(NULL), Font(NULL), Centered(0), Index(-1),
|
CContentTypeText() : Text(nullptr), Font(nullptr), Centered(0), Index(-1),
|
||||||
Component(VariableValue), ShowName(0), Stat(0) {}
|
Component(VariableValue), ShowName(0), Stat(0) {}
|
||||||
virtual ~CContentTypeText()
|
virtual ~CContentTypeText()
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ private:
|
||||||
class CContentTypeFormattedText : public CContentType
|
class CContentTypeFormattedText : public CContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CContentTypeFormattedText() : Font(NULL), Centered(false),
|
CContentTypeFormattedText() : Font(nullptr), Centered(false),
|
||||||
Index(-1), Component(VariableValue) {}
|
Index(-1), Component(VariableValue) {}
|
||||||
virtual ~CContentTypeFormattedText() {}
|
virtual ~CContentTypeFormattedText() {}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ private:
|
||||||
class CContentTypeFormattedText2 : public CContentType
|
class CContentTypeFormattedText2 : public CContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CContentTypeFormattedText2() : Font(NULL), Centered(false),
|
CContentTypeFormattedText2() : Font(nullptr), Centered(false),
|
||||||
Index1(-1), Component1(VariableValue), Index2(-1), Component2(VariableValue) {}
|
Index1(-1), Component1(VariableValue), Index2(-1), Component2(VariableValue) {}
|
||||||
virtual ~CContentTypeFormattedText2() {}
|
virtual ~CContentTypeFormattedText2() {}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ private:
|
||||||
class CContentTypeLifeBar : public CContentType
|
class CContentTypeLifeBar : public CContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CContentTypeLifeBar() : Index(-1), ValueFunc(NULL), ValueMax(-1), Width(0), Height(0), hasBorder(1), colors(NULL), values(NULL) {}
|
CContentTypeLifeBar() : Index(-1), ValueFunc(nullptr), ValueMax(-1), Width(0), Height(0), hasBorder(1), colors(nullptr), values(nullptr) {}
|
||||||
virtual ~CContentTypeLifeBar()
|
virtual ~CContentTypeLifeBar()
|
||||||
{
|
{
|
||||||
FreeNumberDesc(ValueFunc);
|
FreeNumberDesc(ValueFunc);
|
||||||
|
|
|
@ -53,7 +53,7 @@ class PopupConditionPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PopupConditionPanel() : HasHint(false), HasDescription(false), HasDependencies(false),
|
PopupConditionPanel() : HasHint(false), HasDescription(false), HasDependencies(false),
|
||||||
ButtonAction(-1), BoolFlags(NULL), Variables(NULL) {}
|
ButtonAction(-1), BoolFlags(nullptr), Variables(nullptr) {}
|
||||||
~PopupConditionPanel()
|
~PopupConditionPanel()
|
||||||
{
|
{
|
||||||
delete[] BoolFlags;
|
delete[] BoolFlags;
|
||||||
|
@ -75,7 +75,7 @@ class CPopupContentType
|
||||||
public:
|
public:
|
||||||
CPopupContentType() : pos(0, 0),
|
CPopupContentType() : pos(0, 0),
|
||||||
MarginX(MARGIN_X), MarginY(MARGIN_Y), minSize(0, 0),
|
MarginX(MARGIN_X), MarginY(MARGIN_Y), minSize(0, 0),
|
||||||
Wrap(true), Condition(NULL) {}
|
Wrap(true), Condition(nullptr) {}
|
||||||
virtual ~CPopupContentType() { delete Condition; }
|
virtual ~CPopupContentType() { delete Condition; }
|
||||||
|
|
||||||
/// Tell how show the variable Index.
|
/// Tell how show the variable Index.
|
||||||
|
@ -100,7 +100,7 @@ protected:
|
||||||
std::string TextColor; /// Color used for plain text in content.
|
std::string TextColor; /// Color used for plain text in content.
|
||||||
std::string HighlightColor; /// Color used for highlighted letters.
|
std::string HighlightColor; /// Color used for highlighted letters.
|
||||||
public:
|
public:
|
||||||
PopupConditionPanel *Condition; /// Condition to show the content; if NULL, no condition.
|
PopupConditionPanel *Condition; /// Condition to show the content; if nullptr, no condition.
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PopupButtonInfo_Types {
|
enum PopupButtonInfo_Types {
|
||||||
|
@ -112,7 +112,7 @@ enum PopupButtonInfo_Types {
|
||||||
class CPopupContentTypeButtonInfo : public CPopupContentType
|
class CPopupContentTypeButtonInfo : public CPopupContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPopupContentTypeButtonInfo() : InfoType(0), MaxWidth(0), Font(NULL) {}
|
CPopupContentTypeButtonInfo() : InfoType(0), MaxWidth(0), Font(nullptr) {}
|
||||||
virtual ~CPopupContentTypeButtonInfo() {}
|
virtual ~CPopupContentTypeButtonInfo() {}
|
||||||
|
|
||||||
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
|
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
|
||||||
|
@ -131,7 +131,7 @@ private:
|
||||||
class CPopupContentTypeText : public CPopupContentType
|
class CPopupContentTypeText : public CPopupContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPopupContentTypeText() : MaxWidth(0), Font(NULL) {}
|
CPopupContentTypeText() : MaxWidth(0), Font(nullptr) {}
|
||||||
virtual ~CPopupContentTypeText() {}
|
virtual ~CPopupContentTypeText() {}
|
||||||
|
|
||||||
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
|
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
|
||||||
|
@ -150,7 +150,7 @@ private:
|
||||||
class CPopupContentTypeCosts : public CPopupContentType
|
class CPopupContentTypeCosts : public CPopupContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPopupContentTypeCosts() : Font(NULL), Centered(0) {}
|
CPopupContentTypeCosts() : Font(nullptr), Centered(0) {}
|
||||||
virtual ~CPopupContentTypeCosts() {}
|
virtual ~CPopupContentTypeCosts() {}
|
||||||
|
|
||||||
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
|
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
|
||||||
|
@ -187,7 +187,7 @@ private:
|
||||||
class CPopupContentTypeVariable : public CPopupContentType
|
class CPopupContentTypeVariable : public CPopupContentType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPopupContentTypeVariable() : Text(NULL), Font(NULL), Centered(0), Index(-1) {}
|
CPopupContentTypeVariable() : Text(nullptr), Font(nullptr), Centered(0), Index(-1) {}
|
||||||
virtual ~CPopupContentTypeVariable()
|
virtual ~CPopupContentTypeVariable()
|
||||||
{
|
{
|
||||||
FreeStringDesc(Text);
|
FreeStringDesc(Text);
|
||||||
|
|
|
@ -37,7 +37,7 @@ class CFont;
|
||||||
class CUITimer
|
class CUITimer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUITimer() : X(0), Y(0), Font(NULL) {}
|
CUITimer() : X(0), Y(0), Font(nullptr) {}
|
||||||
|
|
||||||
void Draw(int second) const;
|
void Draw(int second) const;
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,8 @@ enum _directions_ {
|
||||||
class CUnit
|
class CUnit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUnit() : tilePos(-1, -1), pathFinderData(NULL), SavedOrder(NULL), NewOrder(NULL), CriticalOrder(NULL), Colors(-1),
|
CUnit() : tilePos(-1, -1), pathFinderData(nullptr), SavedOrder(nullptr), NewOrder(nullptr), CriticalOrder(nullptr), Colors(-1),
|
||||||
AutoCastSpell(NULL), SpellCoolDownTimers(NULL), Variable(NULL) { Init(); }
|
AutoCastSpell(nullptr), SpellCoolDownTimers(nullptr), Variable(nullptr) { Init(); }
|
||||||
~CUnit();
|
~CUnit();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -388,11 +388,11 @@ public:
|
||||||
|
|
||||||
unsigned TeamSelected; /// unit is selected by a team member.
|
unsigned TeamSelected; /// unit is selected by a team member.
|
||||||
CPlayer *RescuedFrom; /// The original owner of a rescued unit.
|
CPlayer *RescuedFrom; /// The original owner of a rescued unit.
|
||||||
/// NULL if the unit was not rescued.
|
/// nullptr if the unit was not rescued.
|
||||||
/* Seen stuff. */
|
/* Seen stuff. */
|
||||||
int VisCount[PlayerMax]; /// Unit visibility counts
|
int VisCount[PlayerMax]; /// Unit visibility counts
|
||||||
struct _seen_stuff_ {
|
struct _seen_stuff_ {
|
||||||
_seen_stuff_() : CFrame(NULL), Type(NULL), tilePos(-1, -1) {}
|
_seen_stuff_() : CFrame(nullptr), Type(nullptr), tilePos(-1, -1) {}
|
||||||
const CConstructionFrame *CFrame; /// Seen construction frame
|
const CConstructionFrame *CFrame; /// Seen construction frame
|
||||||
int Frame; /// last seen frame/stage of buildings
|
int Frame; /// last seen frame/stage of buildings
|
||||||
const CUnitType *Type; /// Pointer to last seen unit-type
|
const CUnitType *Type; /// Pointer to last seen unit-type
|
||||||
|
@ -455,7 +455,7 @@ public:
|
||||||
IconsShift(false), StereoSound(true), MineNotifications(false),
|
IconsShift(false), StereoSound(true), MineNotifications(false),
|
||||||
DeselectInMine(false), NoStatusLineTooltips(false),
|
DeselectInMine(false), NoStatusLineTooltips(false),
|
||||||
SelectionRectangleIndicatesDamage(false), FormationMovement(true),
|
SelectionRectangleIndicatesDamage(false), FormationMovement(true),
|
||||||
IconFrameG(NULL), PressedIconFrameG(NULL), HardwareCursor(false),
|
IconFrameG(nullptr), PressedIconFrameG(nullptr), HardwareCursor(false),
|
||||||
ShowOrders(0), ShowNameDelay(0), ShowNameTime(0), AutosaveMinutes(5) {};
|
ShowOrders(0), ShowNameDelay(0), ShowNameTime(0), AutosaveMinutes(5) {};
|
||||||
|
|
||||||
bool ShowSightRange; /// Show sight range.
|
bool ShowSightRange; /// Show sight range.
|
||||||
|
@ -633,7 +633,7 @@ extern Vec2i GetRndPosInDirection(const Vec2i &srcPos, const Vec2i &dirPos, cons
|
||||||
|
|
||||||
|
|
||||||
/// Hit unit with damage, if destroyed give attacker the points
|
/// Hit unit with damage, if destroyed give attacker the points
|
||||||
extern void HitUnit(CUnit *attacker, CUnit &target, int damage, const Missile *missile = NULL);
|
extern void HitUnit(CUnit *attacker, CUnit &target, int damage, const Missile *missile = nullptr);
|
||||||
|
|
||||||
/// Calculate the distance from current view point to coordinate
|
/// Calculate the distance from current view point to coordinate
|
||||||
extern int ViewPointDistance(const Vec2i &pos);
|
extern int ViewPointDistance(const Vec2i &pos);
|
||||||
|
|
|
@ -80,14 +80,14 @@ public:
|
||||||
* @brief Find the first unit in a tile cache for which a predicate is true.
|
* @brief Find the first unit in a tile cache for which a predicate is true.
|
||||||
* @param pred A predicate object vith bool operator()(const CUnit *).
|
* @param pred A predicate object vith bool operator()(const CUnit *).
|
||||||
* @return The first unit u in the cache
|
* @return The first unit u in the cache
|
||||||
* such that @p pred(u) is true, or NULL if no such unit exists.
|
* such that @p pred(u) is true, or nullptr if no such unit exists.
|
||||||
*/
|
*/
|
||||||
template<typename _T>
|
template<typename _T>
|
||||||
CUnit *find(const _T &pred) const
|
CUnit *find(const _T &pred) const
|
||||||
{
|
{
|
||||||
std::vector<CUnit *>::const_iterator ret = std::find_if(Units.begin(), Units.end(), pred);
|
std::vector<CUnit *>::const_iterator ret = std::find_if(Units.begin(), Units.end(), pred);
|
||||||
|
|
||||||
return ret != Units.end() ? (*ret) : NULL;
|
return ret != Units.end() ? (*ret) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -305,7 +305,7 @@ CUnit *FindUnit_IfFixed(const Vec2i <Pos, const Vec2i &rbPos, Pred pred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Pred>
|
template <typename Pred>
|
||||||
|
@ -320,7 +320,7 @@ CUnit *FindUnit_If(const Vec2i <Pos, const Vec2i &rbPos, Pred pred)
|
||||||
|
|
||||||
/// Find resource
|
/// Find resource
|
||||||
extern CUnit *UnitFindResource(const CUnit &unit, const CUnit &startUnit, int range,
|
extern CUnit *UnitFindResource(const CUnit &unit, const CUnit &startUnit, int range,
|
||||||
int resource, bool check_usage = false, const CUnit *deposit = NULL);
|
int resource, bool check_usage = false, const CUnit *deposit = nullptr);
|
||||||
|
|
||||||
/// Find nearest deposit
|
/// Find nearest deposit
|
||||||
extern CUnit *FindDeposit(const CUnit &unit, int range, int resource);
|
extern CUnit *FindDeposit(const CUnit &unit, int range, int resource);
|
||||||
|
@ -346,7 +346,7 @@ extern CUnit *ResourceOnMap(const Vec2i &pos, int resource, bool mine_on_top = t
|
||||||
extern CUnit *ResourceDepositOnMap(const Vec2i &pos, int resource);
|
extern CUnit *ResourceDepositOnMap(const Vec2i &pos, int resource);
|
||||||
|
|
||||||
/// Check map for obstacles in a line between 2 tiles
|
/// Check map for obstacles in a line between 2 tiles
|
||||||
extern bool CheckObstaclesBetweenTiles(const Vec2i &unitPos, const Vec2i &goalPos, unsigned short flags, int *distance = NULL);
|
extern bool CheckObstaclesBetweenTiles(const Vec2i &unitPos, const Vec2i &goalPos, unsigned short flags, int *distance = nullptr);
|
||||||
/// Find best enemy in numeric range to attack
|
/// Find best enemy in numeric range to attack
|
||||||
extern CUnit *AttackUnitsInDistance(const CUnit &unit, int range, CUnitFilter pred);
|
extern CUnit *AttackUnitsInDistance(const CUnit &unit, int range, CUnitFilter pred);
|
||||||
extern CUnit *AttackUnitsInDistance(const CUnit &unit, int range);
|
extern CUnit *AttackUnitsInDistance(const CUnit &unit, int range);
|
||||||
|
|
|
@ -41,7 +41,7 @@ class CUnit;
|
||||||
class CUnitPtr
|
class CUnitPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUnitPtr() : unit(NULL) {}
|
CUnitPtr() : unit(nullptr) {}
|
||||||
CUnitPtr(CUnit *u);
|
CUnitPtr(CUnit *u);
|
||||||
CUnitPtr(const CUnitPtr &u);
|
CUnitPtr(const CUnitPtr &u);
|
||||||
~CUnitPtr() { Reset(); }
|
~CUnitPtr() { Reset(); }
|
||||||
|
|
|
@ -54,8 +54,8 @@ class CSound;
|
||||||
class SoundConfig
|
class SoundConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SoundConfig() : Sound(NULL) {}
|
SoundConfig() : Sound(nullptr) {}
|
||||||
SoundConfig(std::string name) : Name(name), Sound(NULL) {}
|
SoundConfig(std::string name) : Name(name), Sound(nullptr) {}
|
||||||
|
|
||||||
bool MapSound();
|
bool MapSound();
|
||||||
void SetSoundRange(unsigned char range);
|
void SetSoundRange(unsigned char range);
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
ResourceInfo() : WaitAtResource(0), ResourceStep(0),
|
ResourceInfo() : WaitAtResource(0), ResourceStep(0),
|
||||||
ResourceCapacity(0), WaitAtDepot(0), ResourceId(0), FinalResource(0),
|
ResourceCapacity(0), WaitAtDepot(0), ResourceId(0), FinalResource(0),
|
||||||
TerrainHarvester(0), LoseResources(0), HarvestFromOutside(0),
|
TerrainHarvester(0), LoseResources(0), HarvestFromOutside(0),
|
||||||
SpriteWhenLoaded(NULL), SpriteWhenEmpty(NULL)
|
SpriteWhenLoaded(nullptr), SpriteWhenEmpty(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string FileWhenLoaded; /// Change the graphic when the unit is loaded.
|
std::string FileWhenLoaded; /// Change the graphic when the unit is loaded.
|
||||||
|
@ -310,7 +310,7 @@ public:
|
||||||
class CDecoVarText : public CDecoVar
|
class CDecoVarText : public CDecoVar
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CDecoVarText() : Font(NULL) {};
|
CDecoVarText() : Font(nullptr) {};
|
||||||
/// function to draw the decorations.
|
/// function to draw the decorations.
|
||||||
virtual void Draw(int x, int y, const CUnitType &type, const CVariable &var) const;
|
virtual void Draw(int x, int y, const CUnitType &type, const CVariable &var) const;
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ class CBuildRestrictionAddOn : public CBuildRestriction
|
||||||
const Vec2i pos; //functor work position
|
const Vec2i pos; //functor work position
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
CBuildRestrictionAddOn() : Offset(0, 0), Parent(NULL) {}
|
CBuildRestrictionAddOn() : Offset(0, 0), Parent(nullptr) {}
|
||||||
virtual ~CBuildRestrictionAddOn() {}
|
virtual ~CBuildRestrictionAddOn() {}
|
||||||
virtual void Init() {this->Parent = UnitTypeByIdent(this->ParentName);}
|
virtual void Init() {this->Parent = UnitTypeByIdent(this->ParentName);}
|
||||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||||
|
@ -443,7 +443,7 @@ class CBuildRestrictionOnTop : public CBuildRestriction
|
||||||
const Vec2i pos; //functor work position
|
const Vec2i pos; //functor work position
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
CBuildRestrictionOnTop() : Parent(NULL), ReplaceOnDie(0), ReplaceOnBuild(0) {};
|
CBuildRestrictionOnTop() : Parent(nullptr), ReplaceOnDie(0), ReplaceOnBuild(0) {};
|
||||||
virtual ~CBuildRestrictionOnTop() {};
|
virtual ~CBuildRestrictionOnTop() {};
|
||||||
virtual void Init() {this->Parent = UnitTypeByIdent(this->ParentName);};
|
virtual void Init() {this->Parent = UnitTypeByIdent(this->ParentName);};
|
||||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||||
|
@ -457,7 +457,7 @@ public:
|
||||||
class CBuildRestrictionDistance : public CBuildRestriction
|
class CBuildRestrictionDistance : public CBuildRestriction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBuildRestrictionDistance() : Distance(0), CheckBuilder(false), RestrictType(NULL), Diagonal(true) {};
|
CBuildRestrictionDistance() : Distance(0), CheckBuilder(false), RestrictType(nullptr), Diagonal(true) {};
|
||||||
virtual ~CBuildRestrictionDistance() {};
|
virtual ~CBuildRestrictionDistance() {};
|
||||||
virtual void Init() {this->RestrictType = UnitTypeByIdent(this->RestrictTypeName);};
|
virtual void Init() {this->RestrictType = UnitTypeByIdent(this->RestrictTypeName);};
|
||||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||||
|
@ -474,7 +474,7 @@ public:
|
||||||
class CBuildRestrictionHasUnit : public CBuildRestriction
|
class CBuildRestrictionHasUnit : public CBuildRestriction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBuildRestrictionHasUnit() : Count(0), RestrictType(NULL) {};
|
CBuildRestrictionHasUnit() : Count(0), RestrictType(nullptr) {};
|
||||||
virtual ~CBuildRestrictionHasUnit() {};
|
virtual ~CBuildRestrictionHasUnit() {};
|
||||||
virtual void Init() { this->RestrictType = UnitTypeByIdent(this->RestrictTypeName); };
|
virtual void Init() { this->RestrictType = UnitTypeByIdent(this->RestrictTypeName); };
|
||||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||||
|
@ -489,7 +489,7 @@ public:
|
||||||
class CBuildRestrictionSurroundedBy : public CBuildRestriction
|
class CBuildRestrictionSurroundedBy : public CBuildRestriction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBuildRestrictionSurroundedBy() : Count(0), Distance(0), DistanceType(Equal), CountType(Equal), RestrictType(NULL), CheckBuilder(false) {};
|
CBuildRestrictionSurroundedBy() : Count(0), Distance(0), DistanceType(Equal), CountType(Equal), RestrictType(nullptr), CheckBuilder(false) {};
|
||||||
virtual ~CBuildRestrictionSurroundedBy() {};
|
virtual ~CBuildRestrictionSurroundedBy() {};
|
||||||
virtual void Init() { this->RestrictType = UnitTypeByIdent(this->RestrictTypeName); };
|
virtual void Init() { this->RestrictType = UnitTypeByIdent(this->RestrictTypeName); };
|
||||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||||
|
@ -744,7 +744,7 @@ public:
|
||||||
return ((*it).first).c_str();
|
return ((*it).first).c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -129,7 +129,7 @@ extern int GetResourceIdByName(lua_State *l, const char *resourceName);
|
||||||
class CUnitStats
|
class CUnitStats
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUnitStats() : Variables(NULL)
|
CUnitStats() : Variables(nullptr)
|
||||||
{
|
{
|
||||||
memset(Costs, 0, sizeof(Costs));
|
memset(Costs, 0, sizeof(Costs));
|
||||||
memset(Storing, 0, sizeof(Storing));
|
memset(Storing, 0, sizeof(Storing));
|
||||||
|
@ -182,7 +182,7 @@ public:
|
||||||
class CUpgradeModifier
|
class CUpgradeModifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CUpgradeModifier() : UpgradeId(0), ModifyPercent(NULL), SpeedResearch(0), ConvertTo(NULL)
|
CUpgradeModifier() : UpgradeId(0), ModifyPercent(nullptr), SpeedResearch(0), ConvertTo(nullptr)
|
||||||
{
|
{
|
||||||
memset(ChangeUnits, 0, sizeof(ChangeUnits));
|
memset(ChangeUnits, 0, sizeof(ChangeUnits));
|
||||||
memset(ChangeUpgrades, 0, sizeof(ChangeUpgrades));
|
memset(ChangeUpgrades, 0, sizeof(ChangeUpgrades));
|
||||||
|
|
|
@ -99,11 +99,11 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CGraphic() : Surface(NULL), SurfaceFlip(NULL), frame_map(NULL),
|
CGraphic() : Surface(nullptr), SurfaceFlip(nullptr), frame_map(nullptr),
|
||||||
Width(0), Height(0), NumFrames(1), GraphicWidth(0), GraphicHeight(0),
|
Width(0), Height(0), NumFrames(1), GraphicWidth(0), GraphicHeight(0),
|
||||||
Refs(1), Resized(false)
|
Refs(1), Resized(false)
|
||||||
{
|
{
|
||||||
frameFlip_map = NULL;
|
frameFlip_map = nullptr;
|
||||||
}
|
}
|
||||||
~CGraphic() {}
|
~CGraphic() {}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public:
|
||||||
// minor programmatic editing features
|
// minor programmatic editing features
|
||||||
void OverlayGraphic(CGraphic *other, bool mask = false);
|
void OverlayGraphic(CGraphic *other, bool mask = false);
|
||||||
|
|
||||||
inline bool IsLoaded(bool flipped = false) const { return Surface != NULL && (!flipped || SurfaceFlip != NULL); }
|
inline bool IsLoaded(bool flipped = false) const { return Surface != nullptr && (!flipped || SurfaceFlip != nullptr); }
|
||||||
|
|
||||||
//guichan
|
//guichan
|
||||||
virtual void *_getData() const { return Surface; }
|
virtual void *_getData() const { return Surface; }
|
||||||
|
@ -277,14 +277,14 @@ class Mng : public gcn::Image
|
||||||
Mng() {};
|
Mng() {};
|
||||||
~Mng() {};
|
~Mng() {};
|
||||||
public:
|
public:
|
||||||
static Mng *New(const std::string &name) { return NULL; }
|
static Mng *New(const std::string &name) { return nullptr; }
|
||||||
static void Free(Mng *mng) {};
|
static void Free(Mng *mng) {};
|
||||||
bool Load() { return false; };
|
bool Load() { return false; };
|
||||||
void Reset() {};
|
void Reset() {};
|
||||||
void Draw(int x, int y) {};
|
void Draw(int x, int y) {};
|
||||||
|
|
||||||
//guichan
|
//guichan
|
||||||
virtual void *_getData() const { return NULL; };
|
virtual void *_getData() const { return nullptr; };
|
||||||
virtual int getWidth() const { return 0; };
|
virtual int getWidth() const { return 0; };
|
||||||
virtual int getHeight() const { return 0; };
|
virtual int getHeight() const { return 0; };
|
||||||
virtual bool isDirty() const { return false; };
|
virtual bool isDirty() const { return false; };
|
||||||
|
@ -536,11 +536,11 @@ inline Uint32 IndexToColor(unsigned int index) {
|
||||||
|
|
||||||
static const char *ColorNames[] = {"red", "yellow", "green", "light-gray",
|
static const char *ColorNames[] = {"red", "yellow", "green", "light-gray",
|
||||||
"gray", "dark-gray", "white", "orange",
|
"gray", "dark-gray", "white", "orange",
|
||||||
"light-blue", "blue", "dark-green", "black", NULL};
|
"light-blue", "blue", "dark-green", "black", nullptr};
|
||||||
|
|
||||||
inline int GetColorIndexByName(const char *colorName) {
|
inline int GetColorIndexByName(const char *colorName) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (ColorNames[i] != NULL) {
|
while (ColorNames[i] != nullptr) {
|
||||||
if (!strcmp(colorName, ColorNames[i])) {
|
if (!strcmp(colorName, ColorNames[i])) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,8 +268,8 @@ class ImageTextField : public gcn::TextField
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImageTextField() : TextField(), itemImage(NULL) {}
|
ImageTextField() : TextField(), itemImage(nullptr) {}
|
||||||
ImageTextField(const std::string& text) : gcn::TextField(text), itemImage(NULL) {}
|
ImageTextField(const std::string& text) : gcn::TextField(text), itemImage(nullptr) {}
|
||||||
virtual void draw(gcn::Graphics *graphics);
|
virtual void draw(gcn::Graphics *graphics);
|
||||||
virtual void drawBorder(gcn::Graphics *graphics);
|
virtual void drawBorder(gcn::Graphics *graphics);
|
||||||
void setItemImage(CGraphic *image) { itemImage = image; }
|
void setItemImage(CGraphic *image) { itemImage = image; }
|
||||||
|
@ -419,7 +419,7 @@ public:
|
||||||
class ImageDropDownWidget : public DropDownWidget
|
class ImageDropDownWidget : public DropDownWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageDropDownWidget() : itemImage(NULL) {
|
ImageDropDownWidget() : itemImage(nullptr) {
|
||||||
mListBox.addActionListener(this);
|
mListBox.addActionListener(this);
|
||||||
setListModel(&listmodel);
|
setListModel(&listmodel);
|
||||||
mScrollArea->setContent(&mListBox);
|
mScrollArea->setContent(&mListBox);
|
||||||
|
|
|
@ -132,7 +132,7 @@ void CFieldOfView::Refresh(const CPlayer &player, const CUnit &unit, const Vec2i
|
||||||
{
|
{
|
||||||
/// FIXME: sometimes when quit from game this assert is triggered
|
/// FIXME: sometimes when quit from game this assert is triggered
|
||||||
if (unit.ReleaseCycle) return;
|
if (unit.ReleaseCycle) return;
|
||||||
Assert(unit.Type != NULL);
|
Assert(unit.Type != nullptr);
|
||||||
// Units under construction have no sight range.
|
// Units under construction have no sight range.
|
||||||
if (!range) {
|
if (!range) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -143,7 +143,7 @@ void CFogOfWar::InitTiled()
|
||||||
if (Settings.Type == FogOfWarTypes::cTiledLegacy) {
|
if (Settings.Type == FogOfWarTypes::cTiledLegacy) {
|
||||||
TileOfFogOnly = SDL_CreateRGBSurface(SDL_SWSURFACE, PixelTileSize.x, PixelTileSize.y,
|
TileOfFogOnly = SDL_CreateRGBSurface(SDL_SWSURFACE, PixelTileSize.x, PixelTileSize.y,
|
||||||
32, RMASK, GMASK, BMASK, AMASK);
|
32, RMASK, GMASK, BMASK, AMASK);
|
||||||
SDL_FillRect(TileOfFogOnly, NULL, Settings.FogColorSDL | uint32_t(Settings.ExploredOpacity) << ASHIFT);
|
SDL_FillRect(TileOfFogOnly, nullptr, Settings.FogColorSDL | uint32_t(Settings.ExploredOpacity) << ASHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface * const newFogSurface = SDL_ConvertSurfaceFormat(CFogOfWar::TiledFogSrc->Surface,
|
SDL_Surface * const newFogSurface = SDL_ConvertSurfaceFormat(CFogOfWar::TiledFogSrc->Surface,
|
||||||
|
@ -422,7 +422,7 @@ void CFogOfWar::Draw(CViewport &viewport)
|
||||||
if (Settings.Type == FogOfWarTypes::cTiledLegacy) {
|
if (Settings.Type == FogOfWarTypes::cTiledLegacy) {
|
||||||
DrawTiledLegacy(viewport);
|
DrawTiledLegacy(viewport);
|
||||||
} else {
|
} else {
|
||||||
SDL_FillRect(viewport.GetFogSurface(), NULL, 0x00);
|
SDL_FillRect(viewport.GetFogSurface(), nullptr, 0x00);
|
||||||
|
|
||||||
if (Settings.Type == FogOfWarTypes::cTiled) {
|
if (Settings.Type == FogOfWarTypes::cTiled) {
|
||||||
DrawTiled(viewport);
|
DrawTiled(viewport);
|
||||||
|
|
|
@ -318,7 +318,7 @@ void CMapInfo::Clear()
|
||||||
this->MapUID = 0;
|
this->MapUID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMap::CMap() : Fields(NULL), NoFogOfWar(false), TileGraphic(NULL), Tileset(NULL)
|
CMap::CMap() : Fields(nullptr), NoFogOfWar(false), TileGraphic(nullptr), Tileset(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,12 +363,12 @@ void CMap::Clean(const bool isHardClean /* = false*/)
|
||||||
// Tileset freed by Tileset?
|
// Tileset freed by Tileset?
|
||||||
|
|
||||||
this->Info.Clear();
|
this->Info.Clear();
|
||||||
this->Fields = NULL;
|
this->Fields = nullptr;
|
||||||
this->NoFogOfWar = false;
|
this->NoFogOfWar = false;
|
||||||
this->Tileset->clear();
|
this->Tileset->clear();
|
||||||
this->TileModelsFileName.clear();
|
this->TileModelsFileName.clear();
|
||||||
CGraphic::Free(this->TileGraphic);
|
CGraphic::Free(this->TileGraphic);
|
||||||
this->TileGraphic = NULL;
|
this->TileGraphic = nullptr;
|
||||||
|
|
||||||
FlagRevealMap = MapRevealModes::cHidden;
|
FlagRevealMap = MapRevealModes::cHidden;
|
||||||
ReplayRevealMap = 0;
|
ReplayRevealMap = 0;
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
bool CViewport::ShowGrid = false;
|
bool CViewport::ShowGrid = false;
|
||||||
|
|
||||||
|
|
||||||
CViewport::CViewport() : MapWidth(0), MapHeight(0), Unit(NULL)
|
CViewport::CViewport() : MapWidth(0), MapHeight(0), Unit(nullptr)
|
||||||
{
|
{
|
||||||
this->TopLeftPos.x = this->TopLeftPos.y = 0;
|
this->TopLeftPos.x = this->TopLeftPos.y = 0;
|
||||||
this->BottomRightPos.x = this->BottomRightPos.y = 0;
|
this->BottomRightPos.x = this->BottomRightPos.y = 0;
|
||||||
|
@ -429,7 +429,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
||||||
this->DrawMapBackgroundInViewport<true>(highlightChecker);
|
this->DrawMapBackgroundInViewport<true>(highlightChecker);
|
||||||
}
|
}
|
||||||
|
|
||||||
Missile *clickMissile = NULL;
|
Missile *clickMissile = nullptr;
|
||||||
CurrentViewport = this;
|
CurrentViewport = this;
|
||||||
{
|
{
|
||||||
// Now we need to sort units, missiles, particles by draw level and draw them
|
// Now we need to sort units, missiles, particles by draw level and draw them
|
||||||
|
@ -454,7 +454,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
||||||
if (i == nunits) {
|
if (i == nunits) {
|
||||||
if (missiletable[j]->Type->DrawLevel < particletable[k]->getDrawLevel()) {
|
if (missiletable[j]->Type->DrawLevel < particletable[k]->getDrawLevel()) {
|
||||||
missiletable[j]->DrawMissile(*this);
|
missiletable[j]->DrawMissile(*this);
|
||||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||||
clickMissile = missiletable[j];
|
clickMissile = missiletable[j];
|
||||||
}
|
}
|
||||||
++j;
|
++j;
|
||||||
|
@ -476,7 +476,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
missiletable[j]->DrawMissile(*this);
|
missiletable[j]->DrawMissile(*this);
|
||||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||||
clickMissile = missiletable[j];
|
clickMissile = missiletable[j];
|
||||||
}
|
}
|
||||||
++j;
|
++j;
|
||||||
|
@ -493,7 +493,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
||||||
} else {
|
} else {
|
||||||
if (missiletable[j]->Type->DrawLevel < particletable[k]->getDrawLevel()) {
|
if (missiletable[j]->Type->DrawLevel < particletable[k]->getDrawLevel()) {
|
||||||
missiletable[j]->DrawMissile(*this);
|
missiletable[j]->DrawMissile(*this);
|
||||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||||
clickMissile = missiletable[j];
|
clickMissile = missiletable[j];
|
||||||
}
|
}
|
||||||
++j;
|
++j;
|
||||||
|
@ -509,7 +509,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
||||||
}
|
}
|
||||||
for (; j < nmissiles; ++j) {
|
for (; j < nmissiles; ++j) {
|
||||||
missiletable[j]->DrawMissile(*this);
|
missiletable[j]->DrawMissile(*this);
|
||||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||||
clickMissile = missiletable[j];
|
clickMissile = missiletable[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
||||||
this->DrawMapFogOfWar();
|
this->DrawMapFogOfWar();
|
||||||
|
|
||||||
// If there was a click missile, draw it again here above the fog
|
// If there was a click missile, draw it again here above the fog
|
||||||
if (clickMissile != NULL) {
|
if (clickMissile != nullptr) {
|
||||||
Vec2i pos = Map.MapPixelPosToTilePos(clickMissile->position);
|
Vec2i pos = Map.MapPixelPosToTilePos(clickMissile->position);
|
||||||
Map.Clamp(pos);
|
Map.Clamp(pos);
|
||||||
if (Map.Field(pos.x, pos.y)->playerInfo.TeamVisibilityState(*ThisPlayer) != 2) {
|
if (Map.Field(pos.x, pos.y)->playerInfo.TeamVisibilityState(*ThisPlayer) != 2) {
|
||||||
|
@ -557,7 +557,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
||||||
&& ((isMapFieldVisile && !UnitUnderCursor->Type->BoolFlag[ISNOTSELECTABLE_INDEX].value) || ReplayRevealMap)) {
|
&& ((isMapFieldVisile && !UnitUnderCursor->Type->BoolFlag[ISNOTSELECTABLE_INDEX].value) || ReplayRevealMap)) {
|
||||||
ShowUnitName(*this, CursorScreenPos, UnitUnderCursor);
|
ShowUnitName(*this, CursorScreenPos, UnitUnderCursor);
|
||||||
} else if (!isMapFieldVisile) {
|
} else if (!isMapFieldVisile) {
|
||||||
ShowUnitName(*this, CursorScreenPos, NULL, true);
|
ShowUnitName(*this, CursorScreenPos, nullptr, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class _filter_flags
|
||||||
public:
|
public:
|
||||||
_filter_flags(const CPlayer &p, int *fogmask) : player(&p), fogmask(fogmask)
|
_filter_flags(const CPlayer &p, int *fogmask) : player(&p), fogmask(fogmask)
|
||||||
{
|
{
|
||||||
Assert(fogmask != NULL);
|
Assert(fogmask != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const CUnit *const unit) const
|
void operator()(const CUnit *const unit) const
|
||||||
|
@ -436,7 +436,7 @@ void CViewport::AdjustFogSurface()
|
||||||
SDL_SetSurfaceBlendMode(this->FogSurface, SDL_BLENDMODE_NONE);
|
SDL_SetSurfaceBlendMode(this->FogSurface, SDL_BLENDMODE_NONE);
|
||||||
|
|
||||||
const uint32_t fogColorSolid = FogOfWar->GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
const uint32_t fogColorSolid = FogOfWar->GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
||||||
SDL_FillRect(this->FogSurface, NULL, fogColorSolid);
|
SDL_FillRect(this->FogSurface, nullptr, fogColorSolid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CViewport::Clean()
|
void CViewport::Clean()
|
||||||
|
|
|
@ -143,7 +143,7 @@ void CMinimap::Create()
|
||||||
SDL_SetSurfaceBlendMode(MinimapFogSurface, SDL_BLENDMODE_BLEND);
|
SDL_SetSurfaceBlendMode(MinimapFogSurface, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
const uint32_t fogColorSolid = FogOfWar->GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
const uint32_t fogColorSolid = FogOfWar->GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
||||||
SDL_FillRect(MinimapFogSurface, NULL, fogColorSolid);
|
SDL_FillRect(MinimapFogSurface, nullptr, fogColorSolid);
|
||||||
|
|
||||||
UpdateTerrain();
|
UpdateTerrain();
|
||||||
|
|
||||||
|
@ -377,14 +377,14 @@ void CMinimap::Update()
|
||||||
|
|
||||||
// Clear Minimap background if not transparent
|
// Clear Minimap background if not transparent
|
||||||
if (!Transparent) {
|
if (!Transparent) {
|
||||||
SDL_FillRect(MinimapSurface, NULL, SDL_MapRGB(MinimapSurface->format, 0, 0, 0));
|
SDL_FillRect(MinimapSurface, nullptr, SDL_MapRGB(MinimapSurface->format, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw the terrain
|
// Draw the terrain
|
||||||
//
|
//
|
||||||
if (WithTerrain) {
|
if (WithTerrain) {
|
||||||
SDL_BlitSurface(MinimapTerrainSurface, NULL, MinimapSurface, NULL);
|
SDL_BlitSurface(MinimapTerrainSurface, nullptr, MinimapSurface, nullptr);
|
||||||
}
|
}
|
||||||
const uint32_t fogColorSDL = FogOfWar->GetFogColorSDL();
|
const uint32_t fogColorSDL = FogOfWar->GetFogColorSDL();
|
||||||
if (!ReplayRevealMap) {
|
if (!ReplayRevealMap) {
|
||||||
|
@ -444,7 +444,7 @@ static void DrawEvents()
|
||||||
void CMinimap::Draw() const
|
void CMinimap::Draw() const
|
||||||
{
|
{
|
||||||
SDL_Rect drect = {Sint16(X), Sint16(Y), 0, 0};
|
SDL_Rect drect = {Sint16(X), Sint16(Y), 0, 0};
|
||||||
SDL_BlitSurface(MinimapSurface, NULL, TheScreen, &drect);
|
SDL_BlitSurface(MinimapSurface, nullptr, TheScreen, &drect);
|
||||||
|
|
||||||
DrawEvents();
|
DrawEvents();
|
||||||
}
|
}
|
||||||
|
@ -487,21 +487,21 @@ void CMinimap::Destroy()
|
||||||
if (MinimapTerrainSurface) {
|
if (MinimapTerrainSurface) {
|
||||||
VideoPaletteListRemove(MinimapTerrainSurface);
|
VideoPaletteListRemove(MinimapTerrainSurface);
|
||||||
SDL_FreeSurface(MinimapTerrainSurface);
|
SDL_FreeSurface(MinimapTerrainSurface);
|
||||||
MinimapTerrainSurface = NULL;
|
MinimapTerrainSurface = nullptr;
|
||||||
}
|
}
|
||||||
if (MinimapSurface) {
|
if (MinimapSurface) {
|
||||||
VideoPaletteListRemove(MinimapSurface);
|
VideoPaletteListRemove(MinimapSurface);
|
||||||
SDL_FreeSurface(MinimapSurface);
|
SDL_FreeSurface(MinimapSurface);
|
||||||
MinimapSurface = NULL;
|
MinimapSurface = nullptr;
|
||||||
}
|
}
|
||||||
if (MinimapFogSurface && MinimapFogSurface->format != NULL) {
|
if (MinimapFogSurface && MinimapFogSurface->format != nullptr) {
|
||||||
SDL_FreeSurface(MinimapFogSurface);
|
SDL_FreeSurface(MinimapFogSurface);
|
||||||
MinimapFogSurface = NULL;
|
MinimapFogSurface = nullptr;
|
||||||
}
|
}
|
||||||
delete[] Minimap2MapX;
|
delete[] Minimap2MapX;
|
||||||
Minimap2MapX = NULL;
|
Minimap2MapX = nullptr;
|
||||||
delete[] Minimap2MapY;
|
delete[] Minimap2MapY;
|
||||||
Minimap2MapY = NULL;
|
Minimap2MapY = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -232,7 +232,7 @@ static int CclShowMapLocation(lua_State *l)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
CUnit *target = MakeUnit(*unitType, ThisPlayer);
|
CUnit *target = MakeUnit(*unitType, ThisPlayer);
|
||||||
if (target != NULL) {
|
if (target != nullptr) {
|
||||||
target->Variable[HP_INDEX].Value = 0;
|
target->Variable[HP_INDEX].Value = 0;
|
||||||
target->tilePos.x = LuaToNumber(l, 1);
|
target->tilePos.x = LuaToNumber(l, 1);
|
||||||
target->tilePos.y = LuaToNumber(l, 2);
|
target->tilePos.y = LuaToNumber(l, 2);
|
||||||
|
|
|
@ -1455,7 +1455,7 @@ sdl2::SurfacePtr CTilesetGraphicGenerator::composeImage(sequence_of_imagesPtrs &
|
||||||
auto dst { newBlankImage() };
|
auto dst { newBlankImage() };
|
||||||
|
|
||||||
for (auto &src : srcSequence) {
|
for (auto &src : srcSequence) {
|
||||||
SDL_BlitSurface(src, NULL, dst.get(), NULL);
|
SDL_BlitSurface(src, nullptr, dst.get(), nullptr);
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,13 +118,13 @@ void LoadMissileSprites()
|
||||||
MissileType *MissileTypeByIdent(const std::string &ident)
|
MissileType *MissileTypeByIdent(const std::string &ident)
|
||||||
{
|
{
|
||||||
if (ident.empty()) {
|
if (ident.empty()) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
MissileTypeMap::iterator it = MissileTypes.find(ident);
|
MissileTypeMap::iterator it = MissileTypes.find(ident);
|
||||||
if (it != MissileTypes.end()) {
|
if (it != MissileTypes.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,7 +146,7 @@ MissileType *NewMissileTypeSlot(const std::string &ident)
|
||||||
** Constructor
|
** Constructor
|
||||||
*/
|
*/
|
||||||
Missile::Missile() :
|
Missile::Missile() :
|
||||||
Type(NULL), SpriteFrame(0), State(0), AnimWait(0), Wait(0),
|
Type(nullptr), SpriteFrame(0), State(0), AnimWait(0), Wait(0),
|
||||||
Delay(0), SourceUnit(), TargetUnit(), Damage(0),
|
Delay(0), SourceUnit(), TargetUnit(), Damage(0),
|
||||||
TTL(-1), Hidden(0), DestroyMissile(0),
|
TTL(-1), Hidden(0), DestroyMissile(0),
|
||||||
CurrentStep(0), TotalStep(0),
|
CurrentStep(0), TotalStep(0),
|
||||||
|
@ -172,7 +172,7 @@ Missile::Missile() :
|
||||||
*/
|
*/
|
||||||
/* static */ Missile *Missile::Init(const MissileType &mtype, const PixelPos &startPos, const PixelPos &destPos)
|
/* static */ Missile *Missile::Init(const MissileType &mtype, const PixelPos &startPos, const PixelPos &destPos)
|
||||||
{
|
{
|
||||||
Missile *missile = NULL;
|
Missile *missile = nullptr;
|
||||||
|
|
||||||
switch (mtype.Class) {
|
switch (mtype.Class) {
|
||||||
case MissileClassNone :
|
case MissileClassNone :
|
||||||
|
@ -335,8 +335,8 @@ int CalculateDamage(const CUnit &attacker, const CUnit &goal, const NumberDesc *
|
||||||
TriggerData.Attacker = const_cast<CUnit *>(&attacker);
|
TriggerData.Attacker = const_cast<CUnit *>(&attacker);
|
||||||
TriggerData.Defender = const_cast<CUnit *>(&goal);
|
TriggerData.Defender = const_cast<CUnit *>(&goal);
|
||||||
const int res = EvalNumber(formula);
|
const int res = EvalNumber(formula);
|
||||||
TriggerData.Attacker = NULL;
|
TriggerData.Attacker = nullptr;
|
||||||
TriggerData.Defender = NULL;
|
TriggerData.Defender = nullptr;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ void FireMissile(CUnit &unit, CUnit *goal, const Vec2i &goalPos)
|
||||||
if (goal->CurrentAction() == UnitActionDie) {
|
if (goal->CurrentAction() == UnitActionDie) {
|
||||||
if (unit.Type->Missile.Missile->AlwaysFire) {
|
if (unit.Type->Missile.Missile->AlwaysFire) {
|
||||||
newgoalPos = goal->tilePos;
|
newgoalPos = goal->tilePos;
|
||||||
goal = NULL;
|
goal = nullptr;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -751,7 +751,7 @@ bool PointToPointMissile(Missile &missile)
|
||||||
if (missile.TotalStep == 0) {
|
if (missile.TotalStep == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Assert(missile.Type != NULL);
|
Assert(missile.Type != nullptr);
|
||||||
Assert(missile.TotalStep != 0);
|
Assert(missile.TotalStep != 0);
|
||||||
|
|
||||||
const PixelPos diff = (missile.destination - missile.source);
|
const PixelPos diff = (missile.destination - missile.source);
|
||||||
|
@ -838,12 +838,12 @@ static void MissileHitsGoal(const Missile &missile, CUnit &goal, int splash)
|
||||||
int damage;
|
int damage;
|
||||||
|
|
||||||
if (missile.Type->Damage) { // custom formula
|
if (missile.Type->Damage) { // custom formula
|
||||||
Assert(missile.SourceUnit != NULL);
|
Assert(missile.SourceUnit != nullptr);
|
||||||
damage = CalculateDamage(*missile.SourceUnit, goal, missile.Type->Damage) / splash;
|
damage = CalculateDamage(*missile.SourceUnit, goal, missile.Type->Damage) / splash;
|
||||||
} else if (missile.Damage) { // direct damage, spells mostly
|
} else if (missile.Damage) { // direct damage, spells mostly
|
||||||
damage = missile.Damage / splash;
|
damage = missile.Damage / splash;
|
||||||
} else {
|
} else {
|
||||||
Assert(missile.SourceUnit != NULL);
|
Assert(missile.SourceUnit != nullptr);
|
||||||
damage = CalculateDamage(*missile.SourceUnit, goal, Damage) / splash;
|
damage = CalculateDamage(*missile.SourceUnit, goal, Damage) / splash;
|
||||||
}
|
}
|
||||||
if (missile.Type->Pierce) { // Handle pierce factor
|
if (missile.Type->Pierce) { // Handle pierce factor
|
||||||
|
@ -877,7 +877,7 @@ static void MissileHitsWall(const Missile &missile, const Vec2i &tilePos, int sp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(missile.SourceUnit != NULL);
|
Assert(missile.SourceUnit != nullptr);
|
||||||
if (Map.HumanWallOnMap(tilePos)) {
|
if (Map.HumanWallOnMap(tilePos)) {
|
||||||
stats = UnitTypeHumanWall->Stats;
|
stats = UnitTypeHumanWall->Stats;
|
||||||
} else {
|
} else {
|
||||||
|
@ -983,7 +983,7 @@ void Missile::MissileHit(CUnit *unit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (goal.Destroyed) {
|
if (goal.Destroyed) {
|
||||||
this->TargetUnit = NULL;
|
this->TargetUnit = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MissileHitsGoal(*this, goal, 1);
|
MissileHitsGoal(*this, goal, 1);
|
||||||
|
@ -1000,7 +1000,7 @@ void Missile::MissileHit(CUnit *unit)
|
||||||
const Vec2i range(mtype.Range - 1, mtype.Range - 1);
|
const Vec2i range(mtype.Range - 1, mtype.Range - 1);
|
||||||
std::vector<CUnit *> table;
|
std::vector<CUnit *> table;
|
||||||
Select(pos - range, pos + range, table);
|
Select(pos - range, pos + range, table);
|
||||||
Assert(this->SourceUnit != NULL);
|
Assert(this->SourceUnit != nullptr);
|
||||||
for (size_t i = 0; i != table.size(); ++i) {
|
for (size_t i = 0; i != table.size(); ++i) {
|
||||||
CUnit &goal = *table[i];
|
CUnit &goal = *table[i];
|
||||||
//
|
//
|
||||||
|
@ -1022,7 +1022,7 @@ void Missile::MissileHit(CUnit *unit)
|
||||||
|
|
||||||
if (mtype.CorrectSphashDamage == true) {
|
if (mtype.CorrectSphashDamage == true) {
|
||||||
bool isPosition = false;
|
bool isPosition = false;
|
||||||
if (this->TargetUnit == NULL) {
|
if (this->TargetUnit == nullptr) {
|
||||||
if (this->SourceUnit->CurrentAction() == UnitActionSpellCast) {
|
if (this->SourceUnit->CurrentAction() == UnitActionSpellCast) {
|
||||||
const COrder_SpellCast &order = *static_cast<COrder_SpellCast *>(this->SourceUnit->CurrentOrder());
|
const COrder_SpellCast &order = *static_cast<COrder_SpellCast *>(this->SourceUnit->CurrentOrder());
|
||||||
if (order.GetSpell().Target == TargetPosition) {
|
if (order.GetSpell().Target == TargetPosition) {
|
||||||
|
@ -1037,7 +1037,7 @@ void Missile::MissileHit(CUnit *unit)
|
||||||
shouldHit = false;
|
shouldHit = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this->TargetUnit == NULL || goal.Type->UnitType != this->TargetUnit->Type->UnitType) {
|
if (this->TargetUnit == nullptr || goal.Type->UnitType != this->TargetUnit->Type->UnitType) {
|
||||||
shouldHit = false;
|
shouldHit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1235,7 +1235,7 @@ MissileType *MissileBurningBuilding(int percent)
|
||||||
return (*i)->Missile;
|
return (*i)->Missile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1264,10 +1264,10 @@ void Missile::SaveMissile(CFile &file) const
|
||||||
SavePixelPos(file, this->destination);
|
SavePixelPos(file, this->destination);
|
||||||
file.printf(",\n \"frame\", %d, \"state\", %d, \"anim-wait\", %d, \"wait\", %d, \"delay\", %d,\n ",
|
file.printf(",\n \"frame\", %d, \"state\", %d, \"anim-wait\", %d, \"wait\", %d, \"delay\", %d,\n ",
|
||||||
this->SpriteFrame, this->State, this->AnimWait, this->Wait, this->Delay);
|
this->SpriteFrame, this->State, this->AnimWait, this->Wait, this->Delay);
|
||||||
if (this->SourceUnit != NULL) {
|
if (this->SourceUnit != nullptr) {
|
||||||
file.printf(" \"source\", \"%s\",", UnitReference(this->SourceUnit).c_str());
|
file.printf(" \"source\", \"%s\",", UnitReference(this->SourceUnit).c_str());
|
||||||
}
|
}
|
||||||
if (this->TargetUnit != NULL) {
|
if (this->TargetUnit != nullptr) {
|
||||||
file.printf(" \"target\", \"%s\",", UnitReference(this->TargetUnit).c_str());
|
file.printf(" \"target\", \"%s\",", UnitReference(this->TargetUnit).c_str());
|
||||||
}
|
}
|
||||||
file.printf(" \"damage\", %d,", this->Damage);
|
file.printf(" \"damage\", %d,", this->Damage);
|
||||||
|
@ -1337,9 +1337,9 @@ MissileType::MissileType(const std::string &ident) :
|
||||||
AlwaysFire(false), Pierce(false), PierceOnce(false), IgnoreWalls(true), KillFirstUnit(false),
|
AlwaysFire(false), Pierce(false), PierceOnce(false), IgnoreWalls(true), KillFirstUnit(false),
|
||||||
Class(), NumBounces(0), ParabolCoefficient(2048), StartDelay(0),
|
Class(), NumBounces(0), ParabolCoefficient(2048), StartDelay(0),
|
||||||
Sleep(0), Speed(0), BlizzardSpeed(0), TTL(-1), ReduceFactor(100), SmokePrecision(0),
|
Sleep(0), Speed(0), BlizzardSpeed(0), TTL(-1), ReduceFactor(100), SmokePrecision(0),
|
||||||
MissileStopFlags(0), Damage(NULL), Range(0), SplashFactor(0),
|
MissileStopFlags(0), Damage(nullptr), Range(0), SplashFactor(0),
|
||||||
ImpactParticle(NULL), SmokeParticle(NULL), OnImpact(NULL),
|
ImpactParticle(nullptr), SmokeParticle(nullptr), OnImpact(nullptr),
|
||||||
G(NULL)
|
G(nullptr)
|
||||||
{
|
{
|
||||||
size.x = 0;
|
size.x = 0;
|
||||||
size.y = 0;
|
size.y = 0;
|
||||||
|
|
|
@ -47,7 +47,7 @@ void MissileClipToTarget::Action()
|
||||||
{
|
{
|
||||||
this->Wait = this->Type->Sleep;
|
this->Wait = this->Type->Sleep;
|
||||||
|
|
||||||
if (this->TargetUnit != NULL) {
|
if (this->TargetUnit != nullptr) {
|
||||||
const PixelPos halfSize = this->Type->size / 2;
|
const PixelPos halfSize = this->Type->size / 2;
|
||||||
this->position.x = this->TargetUnit->tilePos.x * PixelTileSize.x + this->TargetUnit->IX - halfSize.x;
|
this->position.x = this->TargetUnit->tilePos.x * PixelTileSize.x + this->TargetUnit->IX - halfSize.x;
|
||||||
this->position.y = this->TargetUnit->tilePos.y * PixelTileSize.y + this->TargetUnit->IY - halfSize.y;
|
this->position.y = this->TargetUnit->tilePos.y * PixelTileSize.y + this->TargetUnit->IY - halfSize.y;
|
||||||
|
|
|
@ -56,7 +56,7 @@ void MissileDeathCoil::Action()
|
||||||
if (this->NextMissileFrame(1, 0) == false) {
|
if (this->NextMissileFrame(1, 0) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert(this->SourceUnit != NULL);
|
Assert(this->SourceUnit != nullptr);
|
||||||
CUnit &source = *this->SourceUnit;
|
CUnit &source = *this->SourceUnit;
|
||||||
|
|
||||||
if (source.Destroyed) {
|
if (source.Destroyed) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ void MissileLandMine::Action()
|
||||||
{
|
{
|
||||||
const Vec2i pos = Map.MapPixelPosToTilePos(this->position);
|
const Vec2i pos = Map.MapPixelPosToTilePos(this->position);
|
||||||
|
|
||||||
if (LandMineTargetFinder(this->SourceUnit, this->Type->CanHitOwner).FindOnTile(Map.Field(pos)) != NULL) {
|
if (LandMineTargetFinder(this->SourceUnit, this->Type->CanHitOwner).FindOnTile(Map.Field(pos)) != nullptr) {
|
||||||
DebugPrint("Landmine explosion at %d,%d.\n" _C_ pos.x _C_ pos.y);
|
DebugPrint("Landmine explosion at %d,%d.\n" _C_ pos.x _C_ pos.y);
|
||||||
this->MissileHit();
|
this->MissileHit();
|
||||||
this->TTL = 0;
|
this->TTL = 0;
|
||||||
|
|
|
@ -64,7 +64,7 @@ static bool ParabolicMissile(Missile &missile)
|
||||||
if (missile.TotalStep == 0) {
|
if (missile.TotalStep == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Assert(missile.Type != NULL);
|
Assert(missile.Type != nullptr);
|
||||||
const PixelPos orig_pos = missile.position;
|
const PixelPos orig_pos = missile.position;
|
||||||
Assert(missile.TotalStep != 0);
|
Assert(missile.TotalStep != 0);
|
||||||
const PixelPos diff = (missile.destination - missile.source);
|
const PixelPos diff = (missile.destination - missile.source);
|
||||||
|
|
|
@ -58,7 +58,7 @@ static bool TracerMissile(Missile &missile)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(missile.Type != NULL);
|
Assert(missile.Type != nullptr);
|
||||||
Assert(missile.TotalStep != 0);
|
Assert(missile.TotalStep != 0);
|
||||||
if (missile.TargetUnit) {
|
if (missile.TargetUnit) {
|
||||||
missile.destination = missile.TargetUnit->GetMapPixelPosTopLeft();
|
missile.destination = missile.TargetUnit->GetMapPixelPosTopLeft();
|
||||||
|
|
|
@ -40,11 +40,11 @@
|
||||||
bool MissileConfig::MapMissileNoLog()
|
bool MissileConfig::MapMissileNoLog()
|
||||||
{
|
{
|
||||||
if (this->Name.empty()) {
|
if (this->Name.empty()) {
|
||||||
this->Missile = NULL;
|
this->Missile = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this->Missile = MissileTypeByIdent(this->Name);
|
this->Missile = MissileTypeByIdent(this->Name);
|
||||||
return this->Missile != NULL;
|
return this->Missile != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MissileConfig::MapMissile()
|
bool MissileConfig::MapMissile()
|
||||||
|
|
|
@ -70,7 +70,7 @@ static const char *MissileClassNames[] = {
|
||||||
"missile-class-clip-to-target",
|
"missile-class-clip-to-target",
|
||||||
"missile-class-continious",
|
"missile-class-continious",
|
||||||
"missile-class-straight-fly",
|
"missile-class-straight-fly",
|
||||||
NULL
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
|
@ -246,11 +246,11 @@ static int CclDefineMissileType(lua_State *l)
|
||||||
*/
|
*/
|
||||||
static int CclMissile(lua_State *l)
|
static int CclMissile(lua_State *l)
|
||||||
{
|
{
|
||||||
MissileType *type = NULL;
|
MissileType *type = nullptr;
|
||||||
PixelPos position(-1, -1);
|
PixelPos position(-1, -1);
|
||||||
PixelPos destination(-1, -1);
|
PixelPos destination(-1, -1);
|
||||||
PixelPos source(-1, -1);
|
PixelPos source(-1, -1);
|
||||||
Missile *missile = NULL;
|
Missile *missile = nullptr;
|
||||||
|
|
||||||
DebugPrint("FIXME: not finished\n");
|
DebugPrint("FIXME: not finished\n");
|
||||||
|
|
||||||
|
@ -399,14 +399,14 @@ static int CclCreateMissile(lua_State *l)
|
||||||
const int destUnitId = LuaToNumber(l, 5);
|
const int destUnitId = LuaToNumber(l, 5);
|
||||||
const bool dealDamage = LuaToBoolean(l, 6);
|
const bool dealDamage = LuaToBoolean(l, 6);
|
||||||
const bool mapRelative = arg == 7 ? LuaToBoolean(l, 7) : false;
|
const bool mapRelative = arg == 7 ? LuaToBoolean(l, 7) : false;
|
||||||
CUnit *sourceUnit = sourceUnitId != -1 ? &UnitManager->GetSlotUnit(sourceUnitId) : NULL;
|
CUnit *sourceUnit = sourceUnitId != -1 ? &UnitManager->GetSlotUnit(sourceUnitId) : nullptr;
|
||||||
CUnit *destUnit = destUnitId != -1 ? &UnitManager->GetSlotUnit(destUnitId) : NULL;
|
CUnit *destUnit = destUnitId != -1 ? &UnitManager->GetSlotUnit(destUnitId) : nullptr;
|
||||||
|
|
||||||
if (mapRelative == false) {
|
if (mapRelative == false) {
|
||||||
if (sourceUnit != NULL) {
|
if (sourceUnit != nullptr) {
|
||||||
startpos += sourceUnit->GetMapPixelPosTopLeft();
|
startpos += sourceUnit->GetMapPixelPosTopLeft();
|
||||||
}
|
}
|
||||||
if (destUnit != NULL) {
|
if (destUnit != nullptr) {
|
||||||
endpos += destUnit->GetMapPixelPosTopLeft();
|
endpos += destUnit->GetMapPixelPosTopLeft();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
void SendCommandStopUnit(CUnit &unit)
|
void SendCommandStopUnit(CUnit &unit)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandStopUnit(unit);
|
CommandStopUnit(unit);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandStop, unit, 0, 0, NoUnitP, 0, FlushCommands);
|
NetworkSendCommand(MessageCommandStop, unit, 0, 0, NoUnitP, 0, FlushCommands);
|
||||||
|
@ -75,7 +75,7 @@ void SendCommandStopUnit(CUnit &unit)
|
||||||
void SendCommandStandGround(CUnit &unit, int flush)
|
void SendCommandStandGround(CUnit &unit, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("stand-ground", &unit, flush, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("stand-ground", &unit, flush, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandStandGround(unit, flush);
|
CommandStandGround(unit, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandStand, unit, 0, 0, NoUnitP, 0, flush);
|
NetworkSendCommand(MessageCommandStand, unit, 0, 0, NoUnitP, 0, flush);
|
||||||
|
@ -92,7 +92,7 @@ void SendCommandStandGround(CUnit &unit, int flush)
|
||||||
void SendCommandDefend(CUnit &unit, CUnit &dest, int flush)
|
void SendCommandDefend(CUnit &unit, CUnit &dest, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("defend", &unit, flush, -1, -1, &dest, NULL, -1);
|
CommandLog("defend", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||||
CommandDefend(unit, dest, flush);
|
CommandDefend(unit, dest, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandDefend, unit, 0, 0, &dest, 0, flush);
|
NetworkSendCommand(MessageCommandDefend, unit, 0, 0, &dest, 0, flush);
|
||||||
|
@ -109,7 +109,7 @@ void SendCommandDefend(CUnit &unit, CUnit &dest, int flush)
|
||||||
void SendCommandFollow(CUnit &unit, CUnit &dest, int flush)
|
void SendCommandFollow(CUnit &unit, CUnit &dest, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("follow", &unit, flush, -1, -1, &dest, NULL, -1);
|
CommandLog("follow", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||||
CommandFollow(unit, dest, flush);
|
CommandFollow(unit, dest, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandFollow, unit, 0, 0, &dest, 0, flush);
|
NetworkSendCommand(MessageCommandFollow, unit, 0, 0, &dest, 0, flush);
|
||||||
|
@ -126,7 +126,7 @@ void SendCommandFollow(CUnit &unit, CUnit &dest, int flush)
|
||||||
void SendCommandMove(CUnit &unit, const Vec2i &pos, int flush)
|
void SendCommandMove(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("move", &unit, flush, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("move", &unit, flush, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandMove(unit, pos, flush);
|
CommandMove(unit, pos, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandMove, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
NetworkSendCommand(MessageCommandMove, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
||||||
|
@ -144,7 +144,7 @@ void SendCommandMove(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
void SendCommandRepair(CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
|
void SendCommandRepair(CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("repair", &unit, flush, pos.x, pos.y, dest, NULL, -1);
|
CommandLog("repair", &unit, flush, pos.x, pos.y, dest, nullptr, -1);
|
||||||
CommandRepair(unit, pos, dest, flush);
|
CommandRepair(unit, pos, dest, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandRepair, unit, pos.x, pos.y, dest, 0, flush);
|
NetworkSendCommand(MessageCommandRepair, unit, pos.x, pos.y, dest, 0, flush);
|
||||||
|
@ -160,10 +160,10 @@ void SendCommandRepair(CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
|
||||||
void SendCommandAutoRepair(CUnit &unit, int on)
|
void SendCommandAutoRepair(CUnit &unit, int on)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("auto-repair", &unit, FlushCommands, on, -1, NoUnitP, NULL, 0);
|
CommandLog("auto-repair", &unit, FlushCommands, on, -1, NoUnitP, nullptr, 0);
|
||||||
CommandAutoRepair(unit, on);
|
CommandAutoRepair(unit, on);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandAutoRepair, unit, on, -1, NoUnitP, NULL, FlushCommands);
|
NetworkSendCommand(MessageCommandAutoRepair, unit, on, -1, NoUnitP, nullptr, FlushCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ void SendCommandAutoRepair(CUnit &unit, int on)
|
||||||
void SendCommandAttack(CUnit &unit, const Vec2i &pos, CUnit *attack, int flush)
|
void SendCommandAttack(CUnit &unit, const Vec2i &pos, CUnit *attack, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("attack", &unit, flush, pos.x, pos.y, attack, NULL, -1);
|
CommandLog("attack", &unit, flush, pos.x, pos.y, attack, nullptr, -1);
|
||||||
CommandAttack(unit, pos, attack, flush);
|
CommandAttack(unit, pos, attack, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandAttack, unit, pos.x, pos.y, attack, 0, flush);
|
NetworkSendCommand(MessageCommandAttack, unit, pos.x, pos.y, attack, 0, flush);
|
||||||
|
@ -195,7 +195,7 @@ void SendCommandAttack(CUnit &unit, const Vec2i &pos, CUnit *attack, int flush)
|
||||||
void SendCommandAttackGround(CUnit &unit, const Vec2i &pos, int flush)
|
void SendCommandAttackGround(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("attack-ground", &unit, flush, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("attack-ground", &unit, flush, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandAttackGround(unit, pos, flush);
|
CommandAttackGround(unit, pos, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandGround, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
NetworkSendCommand(MessageCommandGround, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
||||||
|
@ -212,7 +212,7 @@ void SendCommandAttackGround(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
void SendCommandPatrol(CUnit &unit, const Vec2i &pos, int flush)
|
void SendCommandPatrol(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("patrol", &unit, flush, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("patrol", &unit, flush, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandPatrolUnit(unit, pos, flush);
|
CommandPatrolUnit(unit, pos, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandPatrol, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
NetworkSendCommand(MessageCommandPatrol, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
||||||
|
@ -229,7 +229,7 @@ void SendCommandPatrol(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
void SendCommandBoard(CUnit &unit, CUnit &dest, int flush)
|
void SendCommandBoard(CUnit &unit, CUnit &dest, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("board", &unit, flush, -1, -1, &dest, NULL, -1);
|
CommandLog("board", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||||
CommandBoard(unit, dest, flush);
|
CommandBoard(unit, dest, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandBoard, unit, -1, -1, &dest, 0, flush);
|
NetworkSendCommand(MessageCommandBoard, unit, -1, -1, &dest, 0, flush);
|
||||||
|
@ -247,7 +247,7 @@ void SendCommandBoard(CUnit &unit, CUnit &dest, int flush)
|
||||||
void SendCommandUnload(CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
|
void SendCommandUnload(CUnit &unit, const Vec2i &pos, CUnit *what, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("unload", &unit, flush, pos.x, pos.y, what, NULL, -1);
|
CommandLog("unload", &unit, flush, pos.x, pos.y, what, nullptr, -1);
|
||||||
CommandUnload(unit, pos, what, flush);
|
CommandUnload(unit, pos, what, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandUnload, unit, pos.x, pos.y, what, 0, flush);
|
NetworkSendCommand(MessageCommandUnload, unit, pos.x, pos.y, what, 0, flush);
|
||||||
|
@ -281,7 +281,7 @@ void SendCommandBuildBuilding(CUnit &unit, const Vec2i &pos, CUnitType &what, in
|
||||||
void SendCommandExplore(CUnit &unit, int flush)
|
void SendCommandExplore(CUnit &unit, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("explore", &unit, flush, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("explore", &unit, flush, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandExplore(unit, flush);
|
CommandExplore(unit, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandExplore, unit, 0, 0, NoUnitP, 0, flush);
|
NetworkSendCommand(MessageCommandExplore, unit, 0, 0, NoUnitP, 0, flush);
|
||||||
|
@ -297,10 +297,10 @@ void SendCommandDismiss(CUnit &unit)
|
||||||
{
|
{
|
||||||
// FIXME: currently unit and worker are same?
|
// FIXME: currently unit and worker are same?
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("dismiss", &unit, FlushCommands, -1, -1, NULL, NULL, -1);
|
CommandLog("dismiss", &unit, FlushCommands, -1, -1, nullptr, nullptr, -1);
|
||||||
CommandDismiss(unit);
|
CommandDismiss(unit);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandDismiss, unit, 0, 0, NULL, 0, FlushCommands);
|
NetworkSendCommand(MessageCommandDismiss, unit, 0, 0, nullptr, 0, FlushCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ void SendCommandDismiss(CUnit &unit)
|
||||||
void SendCommandResourceLoc(CUnit &unit, const Vec2i &pos, int flush)
|
void SendCommandResourceLoc(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("resource-loc", &unit, flush, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("resource-loc", &unit, flush, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandResourceLoc(unit, pos, flush);
|
CommandResourceLoc(unit, pos, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandResourceLoc, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
NetworkSendCommand(MessageCommandResourceLoc, unit, pos.x, pos.y, NoUnitP, 0, flush);
|
||||||
|
@ -331,7 +331,7 @@ void SendCommandResourceLoc(CUnit &unit, const Vec2i &pos, int flush)
|
||||||
void SendCommandResource(CUnit &unit, CUnit &dest, int flush)
|
void SendCommandResource(CUnit &unit, CUnit &dest, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("resource", &unit, flush, -1, -1, &dest, NULL, -1);
|
CommandLog("resource", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||||
CommandResource(unit, dest, flush);
|
CommandResource(unit, dest, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandResource, unit, 0, 0, &dest, 0, flush);
|
NetworkSendCommand(MessageCommandResource, unit, 0, 0, &dest, 0, flush);
|
||||||
|
@ -342,13 +342,13 @@ void SendCommandResource(CUnit &unit, CUnit &dest, int flush)
|
||||||
** Send command: Unit return goods.
|
** Send command: Unit return goods.
|
||||||
**
|
**
|
||||||
** @param unit pointer to unit.
|
** @param unit pointer to unit.
|
||||||
** @param goal pointer to destination of the goods. (NULL=search best)
|
** @param goal pointer to destination of the goods. (nullptr=search best)
|
||||||
** @param flush Flag flush all pending commands.
|
** @param flush Flag flush all pending commands.
|
||||||
*/
|
*/
|
||||||
void SendCommandReturnGoods(CUnit &unit, CUnit *goal, int flush)
|
void SendCommandReturnGoods(CUnit &unit, CUnit *goal, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("return", &unit, flush, -1, -1, goal, NULL, -1);
|
CommandLog("return", &unit, flush, -1, -1, goal, nullptr, -1);
|
||||||
CommandReturnGoods(unit, goal, flush);
|
CommandReturnGoods(unit, goal, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandReturn, unit, 0, 0, goal, 0, flush);
|
NetworkSendCommand(MessageCommandReturn, unit, 0, 0, goal, 0, flush);
|
||||||
|
@ -383,7 +383,7 @@ void SendCommandCancelTraining(CUnit &unit, int slot, const CUnitType *type)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP,
|
CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP,
|
||||||
type ? type->Ident.c_str() : NULL, slot);
|
type ? type->Ident.c_str() : nullptr, slot);
|
||||||
CommandCancelTraining(unit, slot, type);
|
CommandCancelTraining(unit, slot, type);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandCancelTrain, unit, slot, 0, NoUnitP,
|
NetworkSendCommand(MessageCommandCancelTrain, unit, slot, 0, NoUnitP,
|
||||||
|
@ -416,11 +416,11 @@ void SendCommandUpgradeTo(CUnit &unit, CUnitType &what, int flush)
|
||||||
void SendCommandCancelUpgradeTo(CUnit &unit)
|
void SendCommandCancelUpgradeTo(CUnit &unit)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("cancel-upgrade-to", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("cancel-upgrade-to", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandCancelUpgradeTo(unit);
|
CommandCancelUpgradeTo(unit);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandCancelUpgrade, unit,
|
NetworkSendCommand(MessageCommandCancelUpgrade, unit,
|
||||||
0, 0, NoUnitP, NULL, FlushCommands);
|
0, 0, NoUnitP, nullptr, FlushCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ void SendCommandResearch(CUnit &unit, CUpgrade &what, int flush)
|
||||||
CommandResearch(unit, what, flush);
|
CommandResearch(unit, what, flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandResearch, unit,
|
NetworkSendCommand(MessageCommandResearch, unit,
|
||||||
what.ID, 0, NoUnitP, NULL, flush);
|
what.ID, 0, NoUnitP, nullptr, flush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,11 +450,11 @@ void SendCommandResearch(CUnit &unit, CUpgrade &what, int flush)
|
||||||
void SendCommandCancelResearch(CUnit &unit)
|
void SendCommandCancelResearch(CUnit &unit)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandCancelResearch(unit);
|
CommandCancelResearch(unit);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandCancelResearch, unit,
|
NetworkSendCommand(MessageCommandCancelResearch, unit,
|
||||||
0, 0, NoUnitP, NULL, FlushCommands);
|
0, 0, NoUnitP, nullptr, FlushCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,11 +470,11 @@ void SendCommandCancelResearch(CUnit &unit)
|
||||||
void SendCommandSpellCast(CUnit &unit, const Vec2i &pos, CUnit *dest, int spellid, int flush)
|
void SendCommandSpellCast(CUnit &unit, const Vec2i &pos, CUnit *dest, int spellid, int flush)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("spell-cast", &unit, flush, pos.x, pos.y, dest, NULL, spellid);
|
CommandLog("spell-cast", &unit, flush, pos.x, pos.y, dest, nullptr, spellid);
|
||||||
CommandSpellCast(unit, pos, dest, *SpellTypeTable[spellid], flush);
|
CommandSpellCast(unit, pos, dest, *SpellTypeTable[spellid], flush);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandSpellCast + spellid,
|
NetworkSendCommand(MessageCommandSpellCast + spellid,
|
||||||
unit, pos.x, pos.y, dest, NULL, flush);
|
unit, pos.x, pos.y, dest, nullptr, flush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,11 +488,11 @@ void SendCommandSpellCast(CUnit &unit, const Vec2i &pos, CUnit *dest, int spelli
|
||||||
void SendCommandAutoSpellCast(CUnit &unit, int spellid, int on)
|
void SendCommandAutoSpellCast(CUnit &unit, int spellid, int on)
|
||||||
{
|
{
|
||||||
if (IsReplayGame()) {
|
if (IsReplayGame()) {
|
||||||
CommandLog("auto-spell-cast", &unit, FlushCommands, on, -1, NoUnitP, NULL, spellid);
|
CommandLog("auto-spell-cast", &unit, FlushCommands, on, -1, NoUnitP, nullptr, spellid);
|
||||||
CommandAutoSpellCast(unit, spellid, on);
|
CommandAutoSpellCast(unit, spellid, on);
|
||||||
} else {
|
} else {
|
||||||
NetworkSendCommand(MessageCommandSpellCast + spellid,
|
NetworkSendCommand(MessageCommandSpellCast + spellid,
|
||||||
unit, on, -1, NoUnitP, NULL, FlushCommands);
|
unit, on, -1, NoUnitP, nullptr, FlushCommands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,18 +601,18 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MessageCommandStop:
|
case MessageCommandStop:
|
||||||
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandStopUnit(unit);
|
CommandStopUnit(unit);
|
||||||
break;
|
break;
|
||||||
case MessageCommandStand:
|
case MessageCommandStand:
|
||||||
CommandLog("stand-ground", &unit, status, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("stand-ground", &unit, status, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandStandGround(unit, status);
|
CommandStandGround(unit, status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandDefend: {
|
case MessageCommandDefend: {
|
||||||
if (dstnr != (unsigned short)0xFFFF) {
|
if (dstnr != (unsigned short)0xFFFF) {
|
||||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest.Type);
|
Assert(dest.Type);
|
||||||
CommandLog("defend", &unit, status, -1, -1, &dest, NULL, -1);
|
CommandLog("defend", &unit, status, -1, -1, &dest, nullptr, -1);
|
||||||
CommandDefend(unit, dest, status);
|
CommandDefend(unit, dest, status);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -621,13 +621,13 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
if (dstnr != (unsigned short)0xFFFF) {
|
if (dstnr != (unsigned short)0xFFFF) {
|
||||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest.Type);
|
Assert(dest.Type);
|
||||||
CommandLog("follow", &unit, status, -1, -1, &dest, NULL, -1);
|
CommandLog("follow", &unit, status, -1, -1, &dest, nullptr, -1);
|
||||||
CommandFollow(unit, dest, status);
|
CommandFollow(unit, dest, status);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageCommandMove:
|
case MessageCommandMove:
|
||||||
CommandLog("move", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("move", &unit, status, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandMove(unit, pos, status);
|
CommandMove(unit, pos, status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandRepair: {
|
case MessageCommandRepair: {
|
||||||
|
@ -636,12 +636,12 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
dest = &UnitManager->GetSlotUnit(dstnr);
|
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest && dest->Type);
|
Assert(dest && dest->Type);
|
||||||
}
|
}
|
||||||
CommandLog("repair", &unit, status, pos.x, pos.y, dest, NULL, -1);
|
CommandLog("repair", &unit, status, pos.x, pos.y, dest, nullptr, -1);
|
||||||
CommandRepair(unit, pos, dest, status);
|
CommandRepair(unit, pos, dest, status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageCommandAutoRepair:
|
case MessageCommandAutoRepair:
|
||||||
CommandLog("auto-repair", &unit, status, arg1, arg2, NoUnitP, NULL, 0);
|
CommandLog("auto-repair", &unit, status, arg1, arg2, NoUnitP, nullptr, 0);
|
||||||
CommandAutoRepair(unit, arg1);
|
CommandAutoRepair(unit, arg1);
|
||||||
break;
|
break;
|
||||||
case MessageCommandAttack: {
|
case MessageCommandAttack: {
|
||||||
|
@ -650,34 +650,34 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
dest = &UnitManager->GetSlotUnit(dstnr);
|
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest && dest->Type);
|
Assert(dest && dest->Type);
|
||||||
}
|
}
|
||||||
CommandLog("attack", &unit, status, pos.x, pos.y, dest, NULL, -1);
|
CommandLog("attack", &unit, status, pos.x, pos.y, dest, nullptr, -1);
|
||||||
CommandAttack(unit, pos, dest, status);
|
CommandAttack(unit, pos, dest, status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageCommandGround:
|
case MessageCommandGround:
|
||||||
CommandLog("attack-ground", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("attack-ground", &unit, status, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandAttackGround(unit, pos, status);
|
CommandAttackGround(unit, pos, status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandPatrol:
|
case MessageCommandPatrol:
|
||||||
CommandLog("patrol", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("patrol", &unit, status, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandPatrolUnit(unit, pos, status);
|
CommandPatrolUnit(unit, pos, status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandBoard: {
|
case MessageCommandBoard: {
|
||||||
if (dstnr != (unsigned short)0xFFFF) {
|
if (dstnr != (unsigned short)0xFFFF) {
|
||||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest.Type);
|
Assert(dest.Type);
|
||||||
CommandLog("board", &unit, status, arg1, arg2, &dest, NULL, -1);
|
CommandLog("board", &unit, status, arg1, arg2, &dest, nullptr, -1);
|
||||||
CommandBoard(unit, dest, status);
|
CommandBoard(unit, dest, status);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageCommandUnload: {
|
case MessageCommandUnload: {
|
||||||
CUnit *dest = NULL;
|
CUnit *dest = nullptr;
|
||||||
if (dstnr != (unsigned short)0xFFFF) {
|
if (dstnr != (unsigned short)0xFFFF) {
|
||||||
dest = &UnitManager->GetSlotUnit(dstnr);
|
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest && dest->Type);
|
Assert(dest && dest->Type);
|
||||||
}
|
}
|
||||||
CommandLog("unload", &unit, status, pos.x, pos.y, dest, NULL, -1);
|
CommandLog("unload", &unit, status, pos.x, pos.y, dest, nullptr, -1);
|
||||||
CommandUnload(unit, pos, dest, status);
|
CommandUnload(unit, pos, dest, status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -686,29 +686,29 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
CommandBuildBuilding(unit, pos, *UnitTypes[dstnr], status);
|
CommandBuildBuilding(unit, pos, *UnitTypes[dstnr], status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandExplore:
|
case MessageCommandExplore:
|
||||||
CommandLog("explore", &unit, status, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("explore", &unit, status, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandExplore(unit, status);
|
CommandExplore(unit, status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandDismiss:
|
case MessageCommandDismiss:
|
||||||
CommandLog("dismiss", &unit, FlushCommands, -1, -1, NULL, NULL, -1);
|
CommandLog("dismiss", &unit, FlushCommands, -1, -1, nullptr, nullptr, -1);
|
||||||
CommandDismiss(unit);
|
CommandDismiss(unit);
|
||||||
break;
|
break;
|
||||||
case MessageCommandResourceLoc:
|
case MessageCommandResourceLoc:
|
||||||
CommandLog("resource-loc", &unit, status, pos.x, pos.y, NoUnitP, NULL, -1);
|
CommandLog("resource-loc", &unit, status, pos.x, pos.y, NoUnitP, nullptr, -1);
|
||||||
CommandResourceLoc(unit, pos, status);
|
CommandResourceLoc(unit, pos, status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandResource: {
|
case MessageCommandResource: {
|
||||||
if (dstnr != (unsigned short)0xFFFF) {
|
if (dstnr != (unsigned short)0xFFFF) {
|
||||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest.Type);
|
Assert(dest.Type);
|
||||||
CommandLog("resource", &unit, status, -1, -1, &dest, NULL, -1);
|
CommandLog("resource", &unit, status, -1, -1, &dest, nullptr, -1);
|
||||||
CommandResource(unit, dest, status);
|
CommandResource(unit, dest, status);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageCommandReturn: {
|
case MessageCommandReturn: {
|
||||||
CUnit *dest = (dstnr != (unsigned short)0xFFFF) ? &UnitManager->GetSlotUnit(dstnr) : NULL;
|
CUnit *dest = (dstnr != (unsigned short)0xFFFF) ? &UnitManager->GetSlotUnit(dstnr) : nullptr;
|
||||||
CommandLog("return", &unit, status, -1, -1, dest, NULL, -1);
|
CommandLog("return", &unit, status, -1, -1, dest, nullptr, -1);
|
||||||
CommandReturnGoods(unit, dest, status);
|
CommandReturnGoods(unit, dest, status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -723,8 +723,8 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
UnitTypes[dstnr]->Ident.c_str(), (short)x);
|
UnitTypes[dstnr]->Ident.c_str(), (short)x);
|
||||||
CommandCancelTraining(unit, (short)x, UnitTypes[dstnr]);
|
CommandCancelTraining(unit, (short)x, UnitTypes[dstnr]);
|
||||||
} else {
|
} else {
|
||||||
CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP, NULL, (short)x);
|
CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, (short)x);
|
||||||
CommandCancelTraining(unit, (short)x, NULL);
|
CommandCancelTraining(unit, (short)x, nullptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MessageCommandUpgrade:
|
case MessageCommandUpgrade:
|
||||||
|
@ -733,7 +733,7 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
CommandUpgradeTo(unit, *UnitTypes[dstnr], status);
|
CommandUpgradeTo(unit, *UnitTypes[dstnr], status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandCancelUpgrade:
|
case MessageCommandCancelUpgrade:
|
||||||
CommandLog("cancel-upgrade-to", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("cancel-upgrade-to", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandCancelUpgradeTo(unit);
|
CommandCancelUpgradeTo(unit);
|
||||||
break;
|
break;
|
||||||
case MessageCommandResearch:
|
case MessageCommandResearch:
|
||||||
|
@ -742,21 +742,21 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
||||||
CommandResearch(unit, *AllUpgrades[arg1], status);
|
CommandResearch(unit, *AllUpgrades[arg1], status);
|
||||||
break;
|
break;
|
||||||
case MessageCommandCancelResearch:
|
case MessageCommandCancelResearch:
|
||||||
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||||
CommandCancelResearch(unit);
|
CommandCancelResearch(unit);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
int id = (msgnr & 0x7f) - MessageCommandSpellCast;
|
int id = (msgnr & 0x7f) - MessageCommandSpellCast;
|
||||||
if (arg2 != (unsigned short)0xFFFF) {
|
if (arg2 != (unsigned short)0xFFFF) {
|
||||||
CUnit *dest = NULL;
|
CUnit *dest = nullptr;
|
||||||
if (dstnr != (unsigned short)0xFFFF) {
|
if (dstnr != (unsigned short)0xFFFF) {
|
||||||
dest = &UnitManager->GetSlotUnit(dstnr);
|
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||||
Assert(dest && dest->Type);
|
Assert(dest && dest->Type);
|
||||||
}
|
}
|
||||||
CommandLog("spell-cast", &unit, status, pos.x, pos.y, dest, NULL, id);
|
CommandLog("spell-cast", &unit, status, pos.x, pos.y, dest, nullptr, id);
|
||||||
CommandSpellCast(unit, pos, dest, *SpellTypeTable[id], status);
|
CommandSpellCast(unit, pos, dest, *SpellTypeTable[id], status);
|
||||||
} else {
|
} else {
|
||||||
CommandLog("auto-spell-cast", &unit, status, arg1, -1, NoUnitP, NULL, id);
|
CommandLog("auto-spell-cast", &unit, status, arg1, -1, NoUnitP, nullptr, id);
|
||||||
CommandAutoSpellCast(unit, id, arg1);
|
CommandAutoSpellCast(unit, id, arg1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -54,8 +54,8 @@ static int service_callback(int sock, const struct sockaddr* from, size_t addrle
|
||||||
mdns_query_answer(sock, from, addrlen, buffer, sizeof(buffer), query_id,
|
mdns_query_answer(sock, from, addrlen, buffer, sizeof(buffer), query_id,
|
||||||
offeredService.c_str(), offeredService.size(),
|
offeredService.c_str(), offeredService.size(),
|
||||||
hostname.c_str(), hostname.size(),
|
hostname.c_str(), hostname.size(),
|
||||||
ips[i], NULL, CNetworkParameter::Instance.localPort,
|
ips[i], nullptr, CNetworkParameter::Instance.localPort,
|
||||||
NULL, 0);
|
nullptr, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void MDNS::AnswerServerQueries() {
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
mdns_socket_listen(serviceSocket, buffer, sizeof(buffer), service_callback, NULL);
|
mdns_socket_listen(serviceSocket, buffer, sizeof(buffer), service_callback, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int query_callback(int sock, const struct sockaddr* from, size_t addrlen, mdns_entry_type_t entry,
|
static int query_callback(int sock, const struct sockaddr* from, size_t addrlen, mdns_entry_type_t entry,
|
||||||
|
|
|
@ -242,15 +242,15 @@ std::string NetGetHostname()
|
||||||
int NetSocketAddr(unsigned long *ips, int maxAddr)
|
int NetSocketAddr(unsigned long *ips, int maxAddr)
|
||||||
{
|
{
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
PIP_ADAPTER_ADDRESSES pFirstAddresses, pAddresses = NULL;
|
PIP_ADAPTER_ADDRESSES pFirstAddresses, pAddresses = nullptr;
|
||||||
ULONG outBufLen = 0;
|
ULONG outBufLen = 0;
|
||||||
GetAdaptersAddresses(AF_INET,
|
GetAdaptersAddresses(AF_INET,
|
||||||
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
||||||
NULL, pAddresses, &outBufLen);
|
nullptr, pAddresses, &outBufLen);
|
||||||
pAddresses = (PIP_ADAPTER_ADDRESSES)malloc(outBufLen);
|
pAddresses = (PIP_ADAPTER_ADDRESSES)malloc(outBufLen);
|
||||||
if (GetAdaptersAddresses(AF_INET,
|
if (GetAdaptersAddresses(AF_INET,
|
||||||
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
||||||
NULL, pAddresses, &outBufLen) == NO_ERROR) {
|
nullptr, pAddresses, &outBufLen) == NO_ERROR) {
|
||||||
pFirstAddresses = pAddresses;
|
pFirstAddresses = pAddresses;
|
||||||
for (pAddresses; pAddresses; pAddresses = pAddresses->Next) {
|
for (pAddresses; pAddresses; pAddresses = pAddresses->Next) {
|
||||||
if (idx == maxAddr) break;
|
if (idx == maxAddr) break;
|
||||||
|
@ -269,12 +269,12 @@ int NetSocketAddr(unsigned long *ips, int maxAddr)
|
||||||
#elif defined(USE_LINUX) || defined(USE_MAC)
|
#elif defined(USE_LINUX) || defined(USE_MAC)
|
||||||
int NetSocketAddr(unsigned long *ips, int maxAddr)
|
int NetSocketAddr(unsigned long *ips, int maxAddr)
|
||||||
{
|
{
|
||||||
struct ifaddrs *ifAddrStruct = NULL;
|
struct ifaddrs *ifAddrStruct = nullptr;
|
||||||
struct ifaddrs *ifa = NULL;
|
struct ifaddrs *ifa = nullptr;
|
||||||
void *tmpAddrPtr = NULL;
|
void *tmpAddrPtr = nullptr;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
getifaddrs(&ifAddrStruct);
|
getifaddrs(&ifAddrStruct);
|
||||||
for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
|
for (ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next) {
|
||||||
if (idx == maxAddr) break;
|
if (idx == maxAddr) break;
|
||||||
if (!ifa->ifa_addr) continue;
|
if (!ifa->ifa_addr) continue;
|
||||||
if (ifa->ifa_addr->sa_family != AF_INET) continue;
|
if (ifa->ifa_addr->sa_family != AF_INET) continue;
|
||||||
|
@ -283,7 +283,7 @@ int NetSocketAddr(unsigned long *ips, int maxAddr)
|
||||||
if ((ifa->ifa_flags & IFF_UP) == 0) continue;
|
if ((ifa->ifa_flags & IFF_UP) == 0) continue;
|
||||||
ips[idx++] = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
|
ips[idx++] = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
|
||||||
}
|
}
|
||||||
if (ifAddrStruct != NULL) {
|
if (ifAddrStruct != nullptr) {
|
||||||
freeifaddrs(ifAddrStruct);
|
freeifaddrs(ifAddrStruct);
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
|
@ -435,7 +435,7 @@ int NetSocketReady(Socket sockfd, int timeout)
|
||||||
tv.tv_usec = (timeout % 1000) * 1000;
|
tv.tv_usec = (timeout % 1000) * 1000;
|
||||||
|
|
||||||
// Data available?
|
// Data available?
|
||||||
retval = select(sockfd + 1, &mask, NULL, NULL, &tv);
|
retval = select(sockfd + 1, &mask, nullptr, nullptr, &tv);
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
} while (retval == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
|
} while (retval == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
|
||||||
#else
|
#else
|
||||||
|
@ -471,7 +471,7 @@ int SocketSet::Select(int timeout)
|
||||||
tv.tv_usec = (timeout % 1000) * 1000;
|
tv.tv_usec = (timeout % 1000) * 1000;
|
||||||
|
|
||||||
// Data available?
|
// Data available?
|
||||||
retval = select(this->MaxSockFD + 1, &mask, NULL, NULL, &tv);
|
retval = select(this->MaxSockFD + 1, &mask, nullptr, nullptr, &tv);
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
} while (retval == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
|
} while (retval == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -727,7 +727,7 @@ size_t CNetworkChat::Deserialize(const unsigned char *buf)
|
||||||
size_t CNetworkChat::Size() const
|
size_t CNetworkChat::Size() const
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
size += serialize(NULL, this->Text);
|
size += serialize(nullptr, this->Text);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ size_t CNetworkSelection::Size() const
|
||||||
|
|
||||||
size_t CNetworkPacketHeader::Serialize(unsigned char *p) const
|
size_t CNetworkPacketHeader::Serialize(unsigned char *p) const
|
||||||
{
|
{
|
||||||
if (p != NULL) {
|
if (p != nullptr) {
|
||||||
for (int i = 0; i != MaxNetworkCommands; ++i) {
|
for (int i = 0; i != MaxNetworkCommands; ++i) {
|
||||||
p += serialize8(p, this->Type[i]);
|
p += serialize8(p, this->Type[i]);
|
||||||
}
|
}
|
||||||
|
@ -870,9 +870,9 @@ size_t CNetworkPacket::Size(int numcommands) const
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
||||||
size += this->Header.Serialize(NULL);
|
size += this->Header.Serialize(nullptr);
|
||||||
for (int i = 0; i != numcommands; ++i) {
|
for (int i = 0; i != numcommands; ++i) {
|
||||||
size += serialize(NULL, this->Command[i]);
|
size += serialize(nullptr, this->Command[i]);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,7 @@ void InitNetwork1()
|
||||||
|
|
||||||
// Our communication port
|
// Our communication port
|
||||||
const int port = CNetworkParameter::Instance.localPort;
|
const int port = CNetworkParameter::Instance.localPort;
|
||||||
const char *NetworkAddr = NULL; // FIXME : bad use
|
const char *NetworkAddr = nullptr; // FIXME : bad use
|
||||||
const CHost host(NetworkAddr, port);
|
const CHost host(NetworkAddr, port);
|
||||||
NetworkFildes.Open(host);
|
NetworkFildes.Open(host);
|
||||||
if (NetworkFildes.IsValid() == false) {
|
if (NetworkFildes.IsValid() == false) {
|
||||||
|
@ -749,7 +749,7 @@ static bool IsAValidCommand_Command(const CNetworkPacket &packet, int index, con
|
||||||
CNetworkCommand nc;
|
CNetworkCommand nc;
|
||||||
nc.Deserialize(&packet.Command[index][0]);
|
nc.Deserialize(&packet.Command[index][0]);
|
||||||
const unsigned int slot = nc.Unit;
|
const unsigned int slot = nc.Unit;
|
||||||
const CUnit *unit = slot < UnitManager->GetUsedSlotCount() ? &UnitManager->GetSlotUnit(slot) : NULL;
|
const CUnit *unit = slot < UnitManager->GetUsedSlotCount() ? &UnitManager->GetSlotUnit(slot) : nullptr;
|
||||||
|
|
||||||
if (unit && (unit->Player->Index == player
|
if (unit && (unit->Player->Index == player
|
||||||
|| Players[player].IsTeamed(*unit) || unit->Player->Type == PlayerTypes::PlayerNeutral)) {
|
|| Players[player].IsTeamed(*unit) || unit->Player->Type == PlayerTypes::PlayerNeutral)) {
|
||||||
|
@ -764,7 +764,7 @@ static bool IsAValidCommand_Dismiss(const CNetworkPacket &packet, int index, con
|
||||||
CNetworkCommand nc;
|
CNetworkCommand nc;
|
||||||
nc.Deserialize(&packet.Command[index][0]);
|
nc.Deserialize(&packet.Command[index][0]);
|
||||||
const unsigned int slot = nc.Unit;
|
const unsigned int slot = nc.Unit;
|
||||||
const CUnit *unit = slot < UnitManager->GetUsedSlotCount() ? &UnitManager->GetSlotUnit(slot) : NULL;
|
const CUnit *unit = slot < UnitManager->GetUsedSlotCount() ? &UnitManager->GetSlotUnit(slot) : nullptr;
|
||||||
|
|
||||||
if (unit && unit->Type->ClicksToExplode) {
|
if (unit && unit->Type->ClicksToExplode) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1004,7 +1004,7 @@ static void NetworkExecCommand_Quit(const CNetworkCommandQueue &ncq)
|
||||||
|
|
||||||
nc.Deserialize(&ncq.Data[0]);
|
nc.Deserialize(&ncq.Data[0]);
|
||||||
NetworkRemovePlayer(nc.player);
|
NetworkRemovePlayer(nc.player);
|
||||||
CommandLog("quit", NoUnitP, FlushCommands, nc.player, -1, NoUnitP, NULL, -1);
|
CommandLog("quit", NoUnitP, FlushCommands, nc.player, -1, NoUnitP, nullptr, -1);
|
||||||
CommandQuit(nc.player);
|
CommandQuit(nc.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue