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
|
||||
{
|
||||
Assert(target1 != NULL);
|
||||
Assert(target2 != NULL);
|
||||
Assert(target1 != nullptr);
|
||||
Assert(target2 != nullptr);
|
||||
|
||||
return (GameSettings.SimplifiedAutoTargeting
|
||||
? ((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)
|
||||
{
|
||||
Assert(target != NULL);
|
||||
Assert(target != nullptr);
|
||||
Assert(this->IsAutoTargeting() || unit.Player->AiEnabled);
|
||||
|
||||
/// 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)) {
|
||||
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)
|
||||
: target;
|
||||
if (this->offeredTarget != NULL) {
|
||||
if (this->offeredTarget != nullptr) {
|
||||
this->offeredTarget.Reset();
|
||||
}
|
||||
this->offeredTarget = best;
|
||||
|
@ -404,7 +404,7 @@ bool COrder_Attack::CheckIfGoalValid(CUnit &unit)
|
|||
** Turn unit to Target or position on map for attack.
|
||||
**
|
||||
** @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)
|
||||
|
@ -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.
|
||||
**
|
||||
** @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)
|
||||
|
@ -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.Type->CanAttack == false
|
||||
|| (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();
|
||||
return false;
|
||||
}
|
||||
CUnit *goal = this->GetGoal();
|
||||
CUnit *newTarget = NULL;
|
||||
CUnit *newTarget = nullptr;
|
||||
if (unit.Selected)
|
||||
{
|
||||
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
|
||||
}
|
||||
/// If we have target offered from outside - try it
|
||||
if (this->offeredTarget != NULL) {
|
||||
if (this->offeredTarget != nullptr) {
|
||||
if (this->offeredTarget->IsVisibleAsGoal(*unit.Player)
|
||||
&& (!immobile || InAttackRange(unit, *this->offeredTarget))) {
|
||||
|
||||
|
@ -759,7 +759,7 @@ void COrder_Attack::MoveToTarget(CUnit &unit)
|
|||
&& InAttackRange(unit, this->goalPos)) {
|
||||
|
||||
// Reached wall or ground, now attacking it
|
||||
TurnToTarget(unit, NULL);
|
||||
TurnToTarget(unit, nullptr);
|
||||
this->State &= AUTO_TARGETING;
|
||||
this->State |= ATTACK_TARGET;
|
||||
return;
|
||||
|
|
|
@ -223,7 +223,7 @@ static void EnterTransporter(CUnit &unit, COrder_Board &order)
|
|||
{
|
||||
CUnit *transporter = order.GetGoal();
|
||||
|
||||
Assert(transporter != NULL);
|
||||
Assert(transporter != nullptr);
|
||||
|
||||
if (!transporter->IsVisibleAsGoal(*unit.Player)) {
|
||||
DebugPrint("Transporter gone\n");
|
||||
|
|
|
@ -100,7 +100,7 @@ enum {
|
|||
file.printf(" \"range\", %d,", this->Range);
|
||||
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(" \"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_
|
||||
unit.Player->Index _C_ UnitNumber(unit) _C_
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
|||
|
||||
CUnit *ontop = CanBuildUnitType(&unit, type, pos, 1);
|
||||
|
||||
if (ontop != NULL) {
|
||||
if (ontop != nullptr) {
|
||||
return ontop;
|
||||
}
|
||||
#if 0
|
||||
|
@ -285,7 +285,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
|||
* enabled/disable via game lua scripting
|
||||
*/
|
||||
CUnit *building = AlreadyBuildingFinder(unit, type).Find(Map.Field(pos));
|
||||
if (building != NULL) {
|
||||
if (building != nullptr) {
|
||||
if (unit.CurrentOrder() == this) {
|
||||
DebugPrint("%d: Worker [%d] is helping build: %s [%d]\n"
|
||||
_C_ unit.Player->Index _C_ unit.Slot
|
||||
|
@ -294,7 +294,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
|||
|
||||
delete this; // Bad
|
||||
unit.Orders[0] = COrder::NewActionRepair(unit, *building);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -303,7 +303,7 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
|
|||
// To keep the load low, retry each 10 cycles
|
||||
// NOTE: we can already inform the AI about this problem?
|
||||
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);
|
||||
|
||||
// If unable to make unit, stop, and report message
|
||||
if (build == NULL) {
|
||||
if (build == nullptr) {
|
||||
// FIXME: Should we retry this?
|
||||
unit.Player->Notify(NotifyYellow, unit.tilePos,
|
||||
_("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].Max = ontop.Variable[GIVERESOURCE_INDEX].Max;
|
||||
build->Variable[GIVERESOURCE_INDEX].Enable = ontop.Variable[GIVERESOURCE_INDEX].Enable;
|
||||
ontop.Remove(NULL); // Destroy building beneath
|
||||
ontop.Remove(nullptr); // Destroy building beneath
|
||||
UnitLost(ontop);
|
||||
UnitClearOrders(ontop);
|
||||
ontop.Release();
|
||||
|
@ -394,7 +394,7 @@ static void AnimateActionBuild(CUnit &unit)
|
|||
{
|
||||
CAnimations *animations = unit.Type->Animations;
|
||||
|
||||
if (animations == NULL) {
|
||||
if (animations == nullptr) {
|
||||
return ;
|
||||
}
|
||||
if (animations->Build) {
|
||||
|
@ -414,7 +414,7 @@ bool COrder_Build::BuildFromOutside(CUnit &unit) const
|
|||
{
|
||||
AnimateActionBuild(unit);
|
||||
|
||||
if (this->BuildingUnit == NULL) {
|
||||
if (this->BuildingUnit == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -437,7 +437,7 @@ CUnit *COrder_Build::GetBuildingUnit() 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].Max = this->BuildingUnit->Variable[BUILD_INDEX].Max;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ CUnit *COrder_Build::GetBuildingUnit() const
|
|||
}
|
||||
CUnit *ontop = this->CheckCanBuild(unit);
|
||||
|
||||
if (ontop != NULL) {
|
||||
if (ontop != nullptr) {
|
||||
this->StartBuilding(unit, *ontop);
|
||||
}
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ CUnit *COrder_Build::GetBuildingUnit() const
|
|||
|
||||
/* 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());
|
||||
targetOrder.Cancel(*this->BuildingUnit);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);
|
|||
cframe = cframe->Next;
|
||||
++frame;
|
||||
}
|
||||
if (this->Worker != NULL) {
|
||||
if (this->Worker != nullptr) {
|
||||
file.printf("\"worker\", \"%s\", ", UnitReference(this->Worker).c_str());
|
||||
}
|
||||
file.printf("\"progress\", %d, \"frame\", %d", this->ProgressCounter, frame);
|
||||
|
@ -109,7 +109,7 @@ extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);
|
|||
++j;
|
||||
int frame = LuaToNumber(l, -1, j + 1);
|
||||
CConstructionFrame *cframe = unit.Type->Construction->Frames;
|
||||
while (frame-- && cframe->Next != NULL) {
|
||||
while (frame-- && cframe->Next != nullptr) {
|
||||
cframe = cframe->Next;
|
||||
}
|
||||
this->Frame = cframe;
|
||||
|
@ -132,16 +132,16 @@ extern void AiReduceMadeInBuilt(PlayerAi &pai, const CUnitType &type);
|
|||
|
||||
static void CancelBuilt(COrder_Built &order, CUnit *unit)
|
||||
{
|
||||
Assert(unit == NULL || unit->CurrentOrder() == &order);
|
||||
Assert(unit == nullptr || unit->CurrentOrder() == &order);
|
||||
CUnit *worker = order.GetWorkerPtr();
|
||||
|
||||
// Drop out unit
|
||||
if (worker != NULL && worker->CurrentAction() == UnitActionBuild) {
|
||||
if (worker != nullptr && worker->CurrentAction() == UnitActionBuild) {
|
||||
worker->ClearAction();
|
||||
|
||||
DropOutOnSide(*worker, LookingW, unit);
|
||||
}
|
||||
if (unit != NULL) {
|
||||
if (unit != nullptr) {
|
||||
// Player gets back 75% of the original cost for a building.
|
||||
unit->Player->AddCostsFactor(unit->Stats->Costs, CancelBuildingCostsFactor);
|
||||
// Cancel building
|
||||
|
@ -169,11 +169,11 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
|||
}
|
||||
CUnit *worker = order.GetWorkerPtr();
|
||||
|
||||
if (worker != NULL) {
|
||||
if (worker != nullptr) {
|
||||
if (type.BoolFlag[BUILDERLOST_INDEX].value) {
|
||||
// Bye bye worker.
|
||||
LetUnitDie(*worker);
|
||||
worker = NULL;
|
||||
worker = nullptr;
|
||||
} else { // Drop out the worker.
|
||||
worker->ClearAction();
|
||||
|
||||
|
@ -207,7 +207,7 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
|||
}
|
||||
|
||||
if (player.AiEnabled) {
|
||||
/* Worker can be NULL */
|
||||
/* Worker can be nullptr */
|
||||
AiWorkComplete(worker, unit);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
|||
// FIXME: Johns: hardcoded unit-type wall / more races!
|
||||
if (&type == UnitTypeOrcWall || &type == UnitTypeHumanWall) {
|
||||
Map.SetWall(unit.tilePos, &type == UnitTypeHumanWall);
|
||||
unit.Remove(NULL);
|
||||
unit.Remove(nullptr);
|
||||
UnitLost(unit);
|
||||
UnitClearOrders(unit);
|
||||
unit.Release();
|
||||
|
@ -253,7 +253,7 @@ static void Finish(COrder_Built &order, CUnit &unit)
|
|||
|
||||
COrder_Built::~COrder_Built()
|
||||
{
|
||||
CancelBuilt(*this, NULL);
|
||||
CancelBuilt(*this, nullptr);
|
||||
}
|
||||
|
||||
/* 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 CConstructionFrame *cframe = FindCFramePercent(*type.Construction->Frames, percent);
|
||||
|
||||
Assert(cframe != NULL);
|
||||
Assert(cframe != nullptr);
|
||||
|
||||
if (cframe != this->Frame) {
|
||||
this->Frame = cframe;
|
||||
|
|
|
@ -197,7 +197,7 @@ enum {
|
|||
DebugPrint("Goal gone\n");
|
||||
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
||||
this->ClearGoal();
|
||||
goal = NULL;
|
||||
goal = nullptr;
|
||||
if (this->State == State_Defending) {
|
||||
this->Finished = true;
|
||||
return;
|
||||
|
|
|
@ -80,7 +80,7 @@ static bool AnimateActionDie(CUnit &unit)
|
|||
{
|
||||
const CAnimations *animations = unit.Type->Animations;
|
||||
|
||||
if (animations == NULL) {
|
||||
if (animations == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (animations->Death[unit.DamagedType]) {
|
||||
|
@ -107,8 +107,8 @@ static bool AnimateActionDie(CUnit &unit)
|
|||
const CUnitType &type = *unit.Type;
|
||||
|
||||
// Die sequence terminated, generate corpse.
|
||||
if (type.CorpseType == NULL) {
|
||||
unit.Remove(NULL);
|
||||
if (type.CorpseType == nullptr) {
|
||||
unit.Remove(nullptr);
|
||||
unit.Release();
|
||||
return ;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ static bool AnimateActionDie(CUnit &unit)
|
|||
// We have to unmark BEFORE changing the type.
|
||||
// Always do that, since types can have different vision properties.
|
||||
|
||||
unit.Remove(NULL);
|
||||
unit.Remove(nullptr);
|
||||
unit.Type = &corpseType;
|
||||
unit.Stats = &corpseType.Stats[unit.Player->Index];
|
||||
UpdateUnitSightRange(unit);
|
||||
|
|
|
@ -222,7 +222,7 @@ enum {
|
|||
goal->Variable[MANA_INDEX].Value -= goal->Goal->Type->TeleportCost;
|
||||
}
|
||||
// Everything is OK, now teleport the unit
|
||||
unit.Remove(NULL);
|
||||
unit.Remove(nullptr);
|
||||
if (goal->Type->TeleportEffectIn) {
|
||||
goal->Type->TeleportEffectIn->pushPreamble();
|
||||
goal->Type->TeleportEffectIn->pushInteger(UnitNumber(unit));
|
||||
|
@ -232,7 +232,7 @@ enum {
|
|||
goal->Type->TeleportEffectIn->run();
|
||||
}
|
||||
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.
|
||||
CUnit &dest = *goal->Goal;
|
||||
|
@ -245,7 +245,7 @@ enum {
|
|||
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 == UnitActionAttack && !unit.Type->CanAttack)
|
||||
|| (dest.NewOrder->Action == UnitActionBoard && unit.Type->UnitType != UnitTypeLand)) {
|
||||
|
@ -255,7 +255,7 @@ enum {
|
|||
if (dest.NewOrder->HasGoal()) {
|
||||
if (dest.NewOrder->GetGoal()->Destroyed) {
|
||||
delete dest.NewOrder;
|
||||
dest.NewOrder = NULL;
|
||||
dest.NewOrder = nullptr;
|
||||
this->Finished = true;
|
||||
return ;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ enum {
|
|||
DebugPrint("Goal gone\n");
|
||||
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
||||
this->ClearGoal();
|
||||
goal = NULL;
|
||||
goal = nullptr;
|
||||
}
|
||||
|
||||
if (unit.Anim.Unbreakable) {
|
||||
|
@ -293,7 +293,7 @@ enum {
|
|||
CUnit *target = AttackUnitsInReactRange(unit);
|
||||
if (target) {
|
||||
// Save current command to come back.
|
||||
COrder *savedOrder = NULL;
|
||||
COrder *savedOrder = nullptr;
|
||||
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
||||
savedOrder = this->Clone();
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ enum {
|
|||
this->Finished = true;
|
||||
unit.Orders.insert(unit.Orders.begin() + 1, COrder::NewActionAttack(unit, target->tilePos));
|
||||
|
||||
if (savedOrder != NULL) {
|
||||
if (savedOrder != nullptr) {
|
||||
unit.SavedOrder = savedOrder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
}
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@
|
|||
{
|
||||
PixelPos targetPos;
|
||||
|
||||
if (this->ReparableTarget != NULL) {
|
||||
if (this->ReparableTarget != nullptr) {
|
||||
targetPos = vp.MapToScreenPixelPos(this->ReparableTarget->GetMapPixelPosCenter());
|
||||
} else {
|
||||
targetPos = vp.TilePosToScreen_Center(this->goalPos);
|
||||
|
@ -149,10 +149,10 @@
|
|||
const CUnit &unit = *input.GetUnit();
|
||||
|
||||
input.SetMinRange(0);
|
||||
input.SetMaxRange(ReparableTarget != NULL ? unit.Type->RepairRange : 0);
|
||||
input.SetMaxRange(ReparableTarget != nullptr ? unit.Type->RepairRange : 0);
|
||||
|
||||
Vec2i tileSize;
|
||||
if (ReparableTarget != NULL) {
|
||||
if (ReparableTarget != nullptr) {
|
||||
tileSize.x = ReparableTarget->Type->TileWidth;
|
||||
tileSize.y = ReparableTarget->Type->TileHeight;
|
||||
input.SetGoal(ReparableTarget->tilePos, tileSize);
|
||||
|
@ -255,9 +255,9 @@ static void AnimateActionRepair(CUnit &unit)
|
|||
if (!goal->IsVisibleAsGoal(*unit.Player)) {
|
||||
DebugPrint("repair target gone.\n");
|
||||
this->goalPos = goal->tilePos + goal->Type->GetHalfTileSize();
|
||||
ReparableTarget = NULL;
|
||||
ReparableTarget = nullptr;
|
||||
this->ClearGoal();
|
||||
goal = NULL;
|
||||
goal = nullptr;
|
||||
}
|
||||
} else if (unit.Player->AiEnabled) {
|
||||
// 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();
|
||||
// FIXME: should I clear this here?
|
||||
this->ClearGoal();
|
||||
ReparableTarget = NULL;
|
||||
goal = NULL;
|
||||
ReparableTarget = nullptr;
|
||||
goal = nullptr;
|
||||
} else {
|
||||
const int dist = unit.MapDistanceTo(*goal);
|
||||
|
||||
|
|
|
@ -176,16 +176,16 @@ static bool FindNearestReachableTerrainType(int movemask, int resmask, int range
|
|||
|
||||
// Destination could be killed. NETWORK!
|
||||
if (depot && depot->Destroyed) {
|
||||
depot = NULL;
|
||||
depot = nullptr;
|
||||
}
|
||||
// clicking on an allied depot still doesn't allow you to deposit there depending on preference
|
||||
if (depot && !GameSettings.AllyDepositsAllowed && depot->Player != harvester.Player) {
|
||||
depot = NULL;
|
||||
depot = nullptr;
|
||||
}
|
||||
order->CurrentResource = harvester.CurrentResource;
|
||||
order->DoneHarvesting = true;
|
||||
|
||||
if (depot == NULL) {
|
||||
if (depot == nullptr) {
|
||||
depot = FindDeposit(harvester, 1000, harvester.CurrentResource);
|
||||
}
|
||||
if (depot) {
|
||||
|
@ -201,7 +201,7 @@ static bool FindNearestReachableTerrainType(int movemask, int resmask, int range
|
|||
|
||||
Vec2i COrder_Resource::GetHarvestLocation() const
|
||||
{
|
||||
if (this->Resource.Mine != NULL) {
|
||||
if (this->Resource.Mine != nullptr) {
|
||||
return this->Resource.Mine->tilePos;
|
||||
} else {
|
||||
return this->Resource.Pos;
|
||||
|
@ -226,12 +226,12 @@ bool COrder_Resource::IsGatheringWaiting() const
|
|||
COrder_Resource::~COrder_Resource()
|
||||
{
|
||||
CUnit *mine = this->Resource.Mine;
|
||||
this->Resource.Mine = NULL;
|
||||
this->Resource.Mine = nullptr;
|
||||
if (mine && mine->IsAlive()) {
|
||||
worker->DeAssignWorkerFromMine(*mine);
|
||||
}
|
||||
|
||||
Depot = NULL;
|
||||
Depot = nullptr;
|
||||
|
||||
CUnit *goal = this->GetGoal();
|
||||
if (goal) {
|
||||
|
@ -255,15 +255,15 @@ COrder_Resource::~COrder_Resource()
|
|||
}
|
||||
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(" \"current-res\", %d,", this->CurrentResource);
|
||||
|
||||
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());
|
||||
}
|
||||
if (this->Depot != NULL) {
|
||||
if (this->Depot != nullptr) {
|
||||
file.printf(" \"res-depot\", \"%s\",", UnitReference(this->Depot).c_str());
|
||||
}
|
||||
if (this->DoneHarvesting) {
|
||||
|
@ -702,7 +702,7 @@ int COrder_Resource::GatherResource(CUnit &unit)
|
|||
if (resinfo.HarvestFromOutside || resinfo.TerrainHarvester) {
|
||||
AnimateActionHarvest(unit);
|
||||
} else {
|
||||
unit.Anim.CurrAnim = NULL;
|
||||
unit.Anim.CurrAnim = nullptr;
|
||||
}
|
||||
|
||||
this->TimeToHarvest--;
|
||||
|
@ -806,11 +806,11 @@ int COrder_Resource::GatherResource(CUnit &unit)
|
|||
LetUnitDie(*source);
|
||||
// FIXME: make the workers inside look for a new resource.
|
||||
}
|
||||
source = NULL;
|
||||
source = nullptr;
|
||||
return 0;
|
||||
}
|
||||
if (resinfo.HarvestFromOutside) {
|
||||
if ((unit.ResourcesHeld == resinfo.ResourceCapacity) || (source == NULL)) {
|
||||
if ((unit.ResourcesHeld == resinfo.ResourceCapacity) || (source == nullptr)) {
|
||||
// Mark as complete.
|
||||
this->DoneHarvesting = true;
|
||||
}
|
||||
|
@ -828,7 +828,7 @@ int GetNumWaitingWorkers(const CUnit &mine)
|
|||
int ret = 0;
|
||||
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);
|
||||
COrder_Resource &order = *static_cast<COrder_Resource *>(worker->CurrentOrder());
|
||||
|
||||
|
@ -876,8 +876,8 @@ int COrder_Resource::StopGathering(CUnit &unit)
|
|||
if (source->Type->MaxOnBoard) {
|
||||
int count = 0;
|
||||
CUnit *worker = source->Resource.Workers;
|
||||
CUnit *next = NULL;
|
||||
for (; NULL != worker; worker = worker->NextWorker) {
|
||||
CUnit *next = nullptr;
|
||||
for (; nullptr != worker; worker = worker->NextWorker) {
|
||||
Assert(worker->CurrentAction() == UnitActionResource);
|
||||
COrder_Resource &order = *static_cast<COrder_Resource *>(worker->CurrentOrder());
|
||||
if (worker != &unit && order.IsGatheringWaiting()) {
|
||||
|
@ -908,7 +908,7 @@ int COrder_Resource::StopGathering(CUnit &unit)
|
|||
} else {
|
||||
// Store resource position.
|
||||
this->Resource.Pos = unit.tilePos;
|
||||
Assert(this->Resource.Mine == NULL);
|
||||
Assert(this->Resource.Mine == nullptr);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -937,7 +937,7 @@ int COrder_Resource::StopGathering(CUnit &unit)
|
|||
|
||||
if (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"
|
||||
|
@ -1037,7 +1037,7 @@ int COrder_Resource::MoveToDepot(CUnit &unit)
|
|||
SelectionChanged();
|
||||
unit.Removed = 1;
|
||||
}
|
||||
unit.Anim.CurrAnim = NULL;
|
||||
unit.Anim.CurrAnim = nullptr;
|
||||
}
|
||||
|
||||
// Update resource.
|
||||
|
@ -1101,14 +1101,14 @@ bool COrder_Resource::WaitInDepot(CUnit &unit)
|
|||
// Use depot's ref counter for that
|
||||
if (longWay || !mine || (depot->Refs > tooManyWorkers)) {
|
||||
newdepot = AiGetSuitableDepot(unit, *depot, &goal);
|
||||
if (newdepot == NULL && longWay) {
|
||||
if (newdepot == nullptr && longWay) {
|
||||
// We need a new depot
|
||||
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 (mine != nullptr && mine->IsAlive()) {
|
||||
goal = mine;
|
||||
|
@ -1153,7 +1153,7 @@ bool COrder_Resource::WaitInDepot(CUnit &unit)
|
|||
}
|
||||
if (mine) {
|
||||
unit.DeAssignWorkerFromMine(*mine);
|
||||
this->Resource.Mine = NULL;
|
||||
this->Resource.Mine = nullptr;
|
||||
}
|
||||
this->Finished = true;
|
||||
return false;
|
||||
|
@ -1174,7 +1174,7 @@ void COrder_Resource::DropResource(CUnit &unit)
|
|||
}
|
||||
}
|
||||
//fast clean both resource data: pos and mine
|
||||
this->Resource.Mine = NULL;
|
||||
this->Resource.Mine = nullptr;
|
||||
unit.CurrentResource = 0;
|
||||
unit.ResourcesHeld = 0;
|
||||
}
|
||||
|
@ -1252,7 +1252,7 @@ bool COrder_Resource::ActionResourceInit(CUnit &unit)
|
|||
|
||||
if (mine) {
|
||||
unit.DeAssignWorkerFromMine(*mine);
|
||||
this->Resource.Mine = NULL;
|
||||
this->Resource.Mine = nullptr;
|
||||
}
|
||||
if (goal && goal->IsAlive() == false) {
|
||||
return false;
|
||||
|
|
|
@ -134,7 +134,7 @@ private:
|
|||
/* virtual */ void COrder_Still::OnAnimationAttack(CUnit &unit)
|
||||
{
|
||||
CUnit *goal = this->GetGoal();
|
||||
if (goal == NULL) {
|
||||
if (goal == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (IsTargetInRange(unit)(goal) == false) {
|
||||
|
@ -262,7 +262,7 @@ private:
|
|||
** @param unit unit which can repair.
|
||||
** @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, ...).
|
||||
*/
|
||||
|
@ -287,18 +287,18 @@ bool AutoRepair(CUnit &unit)
|
|||
}
|
||||
CUnit *repairedUnit = UnitToRepairInRange(unit, repairRange);
|
||||
|
||||
if (repairedUnit == NULL) {
|
||||
if (repairedUnit == nullptr) {
|
||||
return false;
|
||||
}
|
||||
const Vec2i invalidPos(-1, -1);
|
||||
COrder *savedOrder = NULL;
|
||||
COrder *savedOrder = nullptr;
|
||||
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
||||
savedOrder = unit.CurrentOrder()->Clone();
|
||||
}
|
||||
|
||||
//Command* will clear unit.SavedOrder
|
||||
CommandRepair(unit, invalidPos, repairedUnit, FlushCommands);
|
||||
if (savedOrder != NULL) {
|
||||
if (savedOrder != nullptr) {
|
||||
unit.SavedOrder = savedOrder;
|
||||
}
|
||||
return true;
|
||||
|
@ -314,7 +314,7 @@ bool COrder_Still::AutoAttackStand(CUnit &unit)
|
|||
// Removed units can only attack in AttackRange, from bunker
|
||||
CUnit *autoAttackUnit = AttackUnitsInRange(unit);
|
||||
|
||||
if (autoAttackUnit == NULL) {
|
||||
if (autoAttackUnit == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -364,10 +364,10 @@ bool AutoAttack(CUnit &unit)
|
|||
// Normal units react in reaction range.
|
||||
CUnit *goal = AttackUnitsInReactRange(unit);
|
||||
|
||||
if (goal == NULL) {
|
||||
if (goal == nullptr) {
|
||||
return false;
|
||||
}
|
||||
COrder *savedOrder = NULL;
|
||||
COrder *savedOrder = nullptr;
|
||||
|
||||
if (unit.CurrentAction() == UnitActionStill) {
|
||||
savedOrder = COrder::NewActionAttack(unit, unit.tilePos);
|
||||
|
@ -375,9 +375,9 @@ bool AutoAttack(CUnit &unit)
|
|||
savedOrder = unit.CurrentOrder()->Clone();
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
return true;
|
||||
|
@ -388,7 +388,7 @@ bool AutoAttack(CUnit &unit)
|
|||
{
|
||||
// If unit is not bunkered and removed, wait
|
||||
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 ;
|
||||
}
|
||||
this->Finished = false;
|
||||
|
|
|
@ -141,7 +141,7 @@ void COrder_Train::ConvertUnitType(const CUnit &unit, CUnitType &newType)
|
|||
*/
|
||||
static bool CanHandleOrder(const CUnit &unit, COrder *order)
|
||||
{
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (order->Action == UnitActionResource) {
|
||||
|
@ -204,7 +204,7 @@ static void AnimateActionTrain(CUnit &unit)
|
|||
|
||||
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());
|
||||
unit.Wait = CYCLES_PER_SECOND / 6;
|
||||
return ;
|
||||
|
@ -249,7 +249,7 @@ static void AnimateActionTrain(CUnit &unit)
|
|||
if (unit.NewOrder && unit.NewOrder->HasGoal()
|
||||
&& unit.NewOrder->GetGoal()->Destroyed) {
|
||||
delete unit.NewOrder;
|
||||
unit.NewOrder = NULL;
|
||||
unit.NewOrder = nullptr;
|
||||
}
|
||||
|
||||
if (CanHandleOrder(*newUnit, unit.NewOrder) == true) {
|
||||
|
|
|
@ -316,7 +316,7 @@ static int ClosestFreeDropZone(CUnit &transporter, const Vec2i &startPos, int ma
|
|||
|
||||
if (!isTransporterRemoved) {
|
||||
// Remove transporter to avoid "collision" with itself.
|
||||
transporter.Remove(NULL);
|
||||
transporter.Remove(nullptr);
|
||||
}
|
||||
const bool res = ClosestFreeDropZone_internal(transporter, startPos, maxRange, resPos);
|
||||
if (!isTransporterRemoved) {
|
||||
|
@ -339,7 +339,7 @@ bool COrder_Unload::LeaveTransporter(CUnit &transporter)
|
|||
int stillonboard = 0;
|
||||
|
||||
// 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()) {
|
||||
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
|
||||
removed = true;
|
||||
SaveSelection();
|
||||
unit.Remove(NULL);
|
||||
unit.Remove(nullptr);
|
||||
if (!UnitTypeCanBeAt(newtype, pos)) {
|
||||
unit.Place(unit.tilePos);
|
||||
RestoreSelection();
|
||||
|
|
|
@ -151,7 +151,7 @@ void COrder::UpdatePathFinderData_NotCalled(PathFinderInput &input)
|
|||
if (unit.CurrentAction() == UnitActionDie) {
|
||||
unit.Seen.State = 3;
|
||||
}
|
||||
unit.Seen.CFrame = NULL;
|
||||
unit.Seen.CFrame = nullptr;
|
||||
}
|
||||
|
||||
/* virtual */ bool COrder::OnAiHitUnit(CUnit &unit, CUnit *attacker, int /*damage*/)
|
||||
|
@ -188,7 +188,7 @@ void COrder::UpdatePathFinderData_NotCalled(PathFinderInput &input)
|
|||
}
|
||||
CUnit *goal = AttackUnitsInRange(unit);
|
||||
|
||||
if (goal != NULL) {
|
||||
if (goal != nullptr) {
|
||||
const Vec2i invalidPos(-1, -1);
|
||||
|
||||
FireMissile(unit, goal, invalidPos);
|
||||
|
@ -399,10 +399,10 @@ static void HandleUnitAction(CUnit &unit)
|
|||
{
|
||||
// If current action is breakable proceed with next one.
|
||||
if (!unit.Anim.Unbreakable) {
|
||||
if (unit.CriticalOrder != NULL) {
|
||||
if (unit.CriticalOrder != nullptr) {
|
||||
unit.CriticalOrder->Execute(unit);
|
||||
delete unit.CriticalOrder;
|
||||
unit.CriticalOrder = NULL;
|
||||
unit.CriticalOrder = nullptr;
|
||||
}
|
||||
|
||||
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
|
||||
// can happen, but in case it happens again, bring the unit back
|
||||
DebugPrint("Dropping out stuck unit\n");
|
||||
DropOutOnSide(unit, LookingW, NULL);
|
||||
DropOutOnSide(unit, LookingW, nullptr);
|
||||
} else {
|
||||
DebugPrint("Flushing removed unit\n");
|
||||
// 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)
|
||||
{
|
||||
// Dump the unit to find the network sync bugs.
|
||||
static FILE *logf = NULL;
|
||||
static FILE *logf = nullptr;
|
||||
|
||||
if (!logf) {
|
||||
time_t now;
|
||||
|
@ -549,7 +549,7 @@ static void DumpUnitInfo(CUnit &unit)
|
|||
#if 0
|
||||
SaveUnit(unit, logf);
|
||||
#endif
|
||||
fflush(NULL);
|
||||
fflush(nullptr);
|
||||
}
|
||||
|
||||
template <typename UNITP_ITERATOR>
|
||||
|
|
|
@ -105,9 +105,9 @@ static COrderPtr *GetNextOrder(CUnit &unit, int flush)
|
|||
const unsigned int maxOrderCount = 0x7F;
|
||||
|
||||
if (unit.Orders.size() == maxOrderCount) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
unit.Orders.push_back(NULL);
|
||||
unit.Orders.push_back(nullptr);
|
||||
return &unit.Orders.back();
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ static void RemoveOrder(CUnit &unit, unsigned int order)
|
|||
static void ClearNewAction(CUnit &unit)
|
||||
{
|
||||
delete unit.NewOrder;
|
||||
unit.NewOrder = NULL;
|
||||
unit.NewOrder = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,7 +145,7 @@ static void ClearNewAction(CUnit &unit)
|
|||
static void ClearSavedAction(CUnit &unit)
|
||||
{
|
||||
delete unit.SavedOrder;
|
||||
unit.SavedOrder = NULL;
|
||||
unit.SavedOrder = nullptr;
|
||||
}
|
||||
|
||||
static bool IsUnitValidForNetwork(const CUnit &unit)
|
||||
|
@ -168,7 +168,7 @@ void CommandStopUnit(CUnit &unit)
|
|||
// Ignore that the unit could be removed.
|
||||
COrderPtr *order = GetNextOrder(unit, FlushCommands); // Flush them.
|
||||
Assert(order);
|
||||
Assert(*order == NULL);
|
||||
Assert(*order == nullptr);
|
||||
*order = COrder::NewActionStill();
|
||||
|
||||
ClearSavedAction(unit);
|
||||
|
@ -190,7 +190,7 @@ void CommandStandGround(CUnit &unit, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ void CommandDefend(CUnit &unit, CUnit &dest, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ void CommandFollow(CUnit &unit, CUnit &dest, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ void CommandMove(CUnit &unit, const Vec2i &pos, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ void CommandRepair(CUnit &unit, const Vec2i &pos, CUnit *dest, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ void CommandAttack(CUnit &unit, const Vec2i &pos, CUnit *target, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ void CommandAttackGround(CUnit &unit, const Vec2i &pos, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ void CommandPatrolUnit(CUnit &unit, const Vec2i &pos, int flush)
|
|||
Vec2i startPos = unit.tilePos;
|
||||
COrderPtr *prevOrder = &unit.Orders.back();
|
||||
|
||||
if(*prevOrder != NULL) {
|
||||
if(*prevOrder != nullptr) {
|
||||
Vec2i prevGoalPos = (*prevOrder)->GetGoalPos();
|
||||
if(prevGoalPos != invalidPos) {
|
||||
startPos = prevGoalPos;
|
||||
|
@ -426,7 +426,7 @@ void CommandPatrolUnit(CUnit &unit, const Vec2i &pos, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ void CommandBoard(CUnit &unit, CUnit &dest, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ void CommandBoard(CUnit &unit, CUnit &dest, int flush)
|
|||
**
|
||||
** @param unit pointer to unit.
|
||||
** @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.
|
||||
*/
|
||||
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);
|
||||
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
*order = COrder::NewActionUnload(pos, what);
|
||||
|
@ -507,7 +507,7 @@ void CommandBuildBuilding(CUnit &unit, const Vec2i &pos, CUnitType &what, int fl
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ void CommandExplore(CUnit &unit, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ void CommandResourceLoc(CUnit &unit, const Vec2i &pos, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ void CommandResource(CUnit &unit, CUnit &dest, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ void CommandReturnGoods(CUnit &unit, CUnit *depot, int flush)
|
|||
order = &unit.NewOrder;
|
||||
} else {
|
||||
order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ void CommandTrainUnit(CUnit &unit, CUnitType &type, int)
|
|||
const int noFlushCommands = 0;
|
||||
COrderPtr *order = GetNextOrder(unit, noFlushCommands);
|
||||
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
*order = COrder::NewActionTrain(unit, type);
|
||||
|
@ -757,7 +757,7 @@ void CommandUpgradeTo(CUnit &unit, CUnitType &type, int flush, bool instant)
|
|||
|
||||
COrderPtr *order = GetNextOrder(unit, flush);
|
||||
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
*order = COrder::NewActionUpgradeTo(unit, type, instant);
|
||||
|
@ -775,7 +775,7 @@ void CommandTransformIntoType(CUnit &unit, CUnitType &type)
|
|||
if (unit.CriticalOrder && unit.CriticalOrder->Action == UnitActionTransformInto) {
|
||||
return;
|
||||
}
|
||||
Assert(unit.CriticalOrder == NULL);
|
||||
Assert(unit.CriticalOrder == nullptr);
|
||||
|
||||
unit.CriticalOrder = COrder::NewActionTransformInto(type);
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ void CommandResearch(CUnit &unit, CUpgrade &what, int flush)
|
|||
return;
|
||||
}
|
||||
COrderPtr *order = GetNextOrder(unit, flush);
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
*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);
|
||||
|
||||
if (order == NULL) {
|
||||
if (order == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ void AiInit(CPlayer &player)
|
|||
Exit(0);
|
||||
}
|
||||
size_t i;
|
||||
CAiType *ait = NULL;
|
||||
CAiType *ait = nullptr;
|
||||
|
||||
for (i = 0; i < AiTypes.size(); ++i) {
|
||||
ait = AiTypes[i];
|
||||
|
@ -495,7 +495,7 @@ void CleanAi()
|
|||
{
|
||||
for (int p = 0; p < PlayerMax; ++p) {
|
||||
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 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)) {
|
||||
shouldAttack = true;
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ void AiHelpMe(const CUnit *attacker, CUnit &defender)
|
|||
|
||||
if (aiunit.CanStoreOrder(savedOrder) == false) {
|
||||
delete savedOrder;
|
||||
savedOrder = NULL;
|
||||
savedOrder = nullptr;
|
||||
} else {
|
||||
aiunit.SavedOrder = savedOrder;
|
||||
}
|
||||
|
@ -899,14 +899,14 @@ static void AiMoveUnitInTheWay(CUnit &unit)
|
|||
// Don't move more than 1 unit.
|
||||
if (movablenb) {
|
||||
const int index = SyncRand() % movablenb;
|
||||
COrder *savedOrder = NULL;
|
||||
COrder *savedOrder = nullptr;
|
||||
if (movableunits[index]->IsIdle() == false) {
|
||||
if (unit.CanStoreOrder(unit.CurrentOrder())) {
|
||||
savedOrder = unit.CurrentOrder()->Clone();
|
||||
}
|
||||
}
|
||||
CommandMove(*movableunits[index], movablepos[index], FlushCommands);
|
||||
if (savedOrder != NULL) {
|
||||
if (savedOrder != nullptr) {
|
||||
unit.SavedOrder = savedOrder;
|
||||
}
|
||||
AiPlayer->LastCanNotMoveGameCycle = GameCycle;
|
||||
|
|
|
@ -172,7 +172,7 @@ VisitResult BuildingPlaceFinder::Visit(TerrainTraversal &terrainTraversal, const
|
|||
}
|
||||
#endif
|
||||
if (CanBuildUnitType(&worker, type, pos, 1)
|
||||
&& !AiEnemyUnitsInDistance(*worker.Player, NULL, pos, 8)) {
|
||||
&& !AiEnemyUnitsInDistance(*worker.Player, nullptr, pos, 8)) {
|
||||
bool backupok;
|
||||
if (AiCheckSurrounding(worker, type, pos, backupok) && checkSurround) {
|
||||
*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.Init();
|
||||
|
||||
if (startUnit != NULL) {
|
||||
if (startUnit != nullptr) {
|
||||
terrainTraversal.PushUnitPosAndNeighboor(*startUnit);
|
||||
} else {
|
||||
Assert(Map.Info.IsPointOnMap(startPos));
|
||||
|
@ -339,7 +339,7 @@ static bool AiFindHallPlace(const CUnit &worker,
|
|||
if (terrainTraversal.Run(hallPlaceFinder)) {
|
||||
return true;
|
||||
}
|
||||
return AiFindBuildingPlace2(worker, type, startPos, NULL, true, resultPos);
|
||||
return AiFindBuildingPlace2(worker, type, startPos, nullptr, true, resultPos);
|
||||
}
|
||||
|
||||
class LumberMillPlaceFinder
|
||||
|
@ -368,7 +368,7 @@ VisitResult LumberMillPlaceFinder::Visit(TerrainTraversal &terrainTraversal, con
|
|||
}
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ static bool AiFindMiningPlace(const CUnit &worker,
|
|||
Vec2i *resultPos)
|
||||
{
|
||||
// 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);
|
||||
} else {
|
||||
//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),
|
||||
result_unit(result_unit)
|
||||
{
|
||||
*result_unit = NULL;
|
||||
*result_unit = nullptr;
|
||||
}
|
||||
VisitResult Visit(TerrainTraversal &terrainTraversal, const Vec2i &pos, const Vec2i &from);
|
||||
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())) {
|
||||
*result_unit = dest;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -121,24 +121,24 @@ class AiForceEnemyFinder
|
|||
public:
|
||||
AiForceEnemyFinder(int force, const CUnit **enemy) : enemy(enemy)
|
||||
{
|
||||
Assert(enemy != NULL);
|
||||
*enemy = NULL;
|
||||
Assert(enemy != nullptr);
|
||||
*enemy = nullptr;
|
||||
AiPlayer->Force[force].Units.for_each_if(*this);
|
||||
}
|
||||
|
||||
AiForceEnemyFinder(AiForce &force, const CUnit **enemy) : enemy(enemy)
|
||||
{
|
||||
Assert(enemy != NULL);
|
||||
*enemy = NULL;
|
||||
Assert(enemy != nullptr);
|
||||
*enemy = nullptr;
|
||||
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
|
||||
{
|
||||
if (unit->Type->CanAttack == false) {
|
||||
return *enemy == NULL;
|
||||
return *enemy == nullptr;
|
||||
}
|
||||
if (FIND_TYPE == AIATTACK_RANGE) {
|
||||
*enemy = AttackUnitsInReactRange(*unit);
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
terrainTraversal.SetSize(Map.Info.MapWidth, Map.Info.MapHeight);
|
||||
terrainTraversal.Init();
|
||||
terrainTraversal.PushUnitPosAndNeighboor(*unit);
|
||||
CUnit *result_unit = NULL;
|
||||
CUnit *result_unit = nullptr;
|
||||
EnemyUnitFinder enemyUnitFinder(*unit, &result_unit, FIND_TYPE);
|
||||
terrainTraversal.Run(enemyUnitFinder);
|
||||
*enemy = result_unit;
|
||||
|
@ -161,17 +161,17 @@ public:
|
|||
// } else if (FIND_TYPE == AIATTACK_BUILDING) {
|
||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsBuildingType());
|
||||
// Assert(!*enemy);
|
||||
// if (*enemy == NULL || !(*enemy)->Type->Building) {
|
||||
// if (*enemy == nullptr || !(*enemy)->Type->Building) {
|
||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
|
||||
// }
|
||||
// } else if (FIND_TYPE == AIATTACK_AGRESSIVE) {
|
||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsAggresiveUnit());
|
||||
// Assert(!*enemy || (*enemy)->IsAgressive());
|
||||
// if (*enemy == NULL) {
|
||||
// if (*enemy == nullptr) {
|
||||
// *enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
|
||||
// }
|
||||
// }
|
||||
return *enemy == NULL;
|
||||
return *enemy == nullptr;
|
||||
}
|
||||
private:
|
||||
const CUnit **enemy;
|
||||
|
@ -404,7 +404,7 @@ private:
|
|||
VisitResult AiForceRallyPointFinder::Visit(TerrainTraversal &terrainTraversal, const Vec2i &pos, const Vec2i &from)
|
||||
{
|
||||
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)) {
|
||||
*resultPos = pos;
|
||||
return VisitResult_Finished;
|
||||
|
@ -475,7 +475,7 @@ void AiForce::Attack(const Vec2i &pos)
|
|||
}
|
||||
if (Map.Info.IsPointOnMap(goalPos) == false) {
|
||||
/* Search in entire map */
|
||||
const CUnit *enemy = NULL;
|
||||
const CUnit *enemy = nullptr;
|
||||
if (isTransporter) {
|
||||
AiForceEnemyFinder<AIATTACK_AGRESSIVE>(*this, &enemy);
|
||||
} else if (isNaval) {
|
||||
|
@ -513,7 +513,7 @@ void AiForce::Attack(const Vec2i &pos)
|
|||
}
|
||||
// Send all units in the force to enemy.
|
||||
|
||||
CUnit *leader = NULL;
|
||||
CUnit *leader = nullptr;
|
||||
for (size_t i = 0; i != this->Units.size(); ++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) {
|
||||
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.
|
||||
|
||||
unit->Wait = delay;
|
||||
if (unit->IsAgressive()) {
|
||||
CommandAttack(*unit, this->GoalPos, NULL, FlushCommands);
|
||||
CommandAttack(*unit, this->GoalPos, nullptr, FlushCommands);
|
||||
} else {
|
||||
if (leader) {
|
||||
CommandDefend(*unit, *leader, FlushCommands);
|
||||
|
@ -877,7 +877,7 @@ static void AiGroupAttackerForTransport(AiForce &aiForce)
|
|||
const CUnit &unit = *aiForce.Units[i];
|
||||
const CUnit &transporter = *aiForce.Units[transporterIndex];
|
||||
|
||||
if (CanTransport(transporter, unit) && unit.Container == NULL) {
|
||||
if (CanTransport(transporter, unit) && unit.Container == nullptr) {
|
||||
forceIsReady = false;
|
||||
break;
|
||||
}
|
||||
|
@ -896,7 +896,7 @@ static void AiGroupAttackerForTransport(AiForce &aiForce)
|
|||
}
|
||||
if (CanTransport(transporter, unit) && (unit.IsIdle()
|
||||
|| (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);
|
||||
CommandFollow(transporter, unit, 0);
|
||||
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.
|
||||
|
||||
trans.Wait = delay;
|
||||
CommandUnload(trans, this->GoalPos, NULL, FlushCommands);
|
||||
CommandUnload(trans, this->GoalPos, nullptr, FlushCommands);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
CUnit *leader = NULL;
|
||||
CUnit *leader = nullptr;
|
||||
for (unsigned int i = 0; i != Size(); ++i) {
|
||||
CUnit &aiunit = *Units[i];
|
||||
|
||||
|
@ -1026,7 +1026,7 @@ void AiForce::Update()
|
|||
--WaitOnRallyPoint;
|
||||
}
|
||||
if (maxDist <= thresholdDist || !WaitOnRallyPoint) {
|
||||
const CUnit *unit = NULL;
|
||||
const CUnit *unit = nullptr;
|
||||
|
||||
AiForceEnemyFinder<AIATTACK_BUILDING>(*this, &unit);
|
||||
if (!unit) {
|
||||
|
@ -1049,7 +1049,7 @@ void AiForce::Update()
|
|||
|
||||
aiunit.Wait = delay;
|
||||
if (aiunit.IsAgressive()) {
|
||||
CommandAttack(aiunit, this->GoalPos, NULL, FlushCommands);
|
||||
CommandAttack(aiunit, this->GoalPos, nullptr, FlushCommands);
|
||||
} else {
|
||||
if (leader) {
|
||||
CommandDefend(aiunit, *leader, FlushCommands);
|
||||
|
@ -1075,7 +1075,7 @@ void AiForce::Update()
|
|||
}
|
||||
|
||||
if (State == AiForceAttackingState_Attacking && idleUnits.size() == this->Size()) {
|
||||
const CUnit *unit = NULL;
|
||||
const CUnit *unit = nullptr;
|
||||
|
||||
bool isNaval = false;
|
||||
for (size_t i = 0; i != this->Units.size(); ++i) {
|
||||
|
@ -1118,16 +1118,16 @@ void AiForce::Update()
|
|||
if (leader) {
|
||||
if (aiunit.IsAgressive()) {
|
||||
if (State == AiForceAttackingState_Attacking) {
|
||||
CommandAttack(aiunit, leader->tilePos, NULL, FlushCommands);
|
||||
CommandAttack(aiunit, leader->tilePos, nullptr, FlushCommands);
|
||||
} else {
|
||||
CommandAttack(aiunit, this->GoalPos, NULL, FlushCommands);
|
||||
CommandAttack(aiunit, this->GoalPos, nullptr, FlushCommands);
|
||||
}
|
||||
} else {
|
||||
CommandDefend(aiunit, *leader, FlushCommands);
|
||||
}
|
||||
} else {
|
||||
if (aiunit.IsAgressive()) {
|
||||
CommandAttack(aiunit, this->GoalPos, NULL, FlushCommands);
|
||||
CommandAttack(aiunit, this->GoalPos, nullptr, FlushCommands);
|
||||
} else {
|
||||
CommandMove(aiunit, this->GoalPos, FlushCommands);
|
||||
}
|
||||
|
@ -1165,7 +1165,7 @@ void AiForceManager::Update()
|
|||
for (unsigned int i = 0; i != force.Size(); ++i) {
|
||||
if (force.Units[i]->MapDistanceTo(force.GoalPos) <= nearDist) {
|
||||
// Look if still enemies in attack range.
|
||||
const CUnit *dummy = NULL;
|
||||
const CUnit *dummy = nullptr;
|
||||
maxPathing--;
|
||||
if (!AiForceEnemyFinder<AIATTACK_RANGE>(force, &dummy).found()) {
|
||||
force.ReturnToHome();
|
||||
|
@ -1199,12 +1199,12 @@ void AiForceManager::Update()
|
|||
for (unsigned int i = 0; i != idleUnits.size(); ++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.
|
||||
|
||||
unit->Wait = delay;
|
||||
if (unit->Type->CanAttack) {
|
||||
CommandAttack(*unit, force.GoalPos, NULL, FlushCommands);
|
||||
CommandAttack(*unit, force.GoalPos, nullptr, FlushCommands);
|
||||
} else {
|
||||
CommandMove(*unit, force.GoalPos, FlushCommands);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
class AiRequestType
|
||||
{
|
||||
public:
|
||||
AiRequestType() : Count(0), Type(NULL) {}
|
||||
AiRequestType() : Count(0), Type(nullptr) {}
|
||||
|
||||
unsigned int Count; /// elements in table
|
||||
CUnitType *Type; /// the type
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
class AiUnitType
|
||||
{
|
||||
public:
|
||||
AiUnitType() : Want(0), Type(NULL) {}
|
||||
AiUnitType() : Want(0), Type(nullptr) {}
|
||||
|
||||
unsigned int Want; /// number of this unit-type wanted
|
||||
CUnitType *Type; /// unit-type self
|
||||
|
@ -246,7 +246,7 @@ private:
|
|||
class AiBuildQueue
|
||||
{
|
||||
public:
|
||||
AiBuildQueue() : Want(0), Made(0), Type(NULL), Wait(0)
|
||||
AiBuildQueue() : Want(0), Made(0), Type(nullptr), Wait(0)
|
||||
{
|
||||
Pos.x = Pos.y = -1;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ public:
|
|||
class PlayerAi
|
||||
{
|
||||
public:
|
||||
PlayerAi() : Player(NULL), AiType(NULL),
|
||||
PlayerAi() : Player(nullptr), AiType(nullptr),
|
||||
SleepCycles(0), NeededMask(0), NeedSupply(false),
|
||||
ScriptDebug(false), BuildDepots(true), LastExplorationGameCycle(0),
|
||||
LastCanNotMoveGameCycle(0), LastRepairBuilding(0)
|
||||
|
|
|
@ -110,7 +110,7 @@ private:
|
|||
*/
|
||||
static CUnit *EnemyOnMapTile(const CUnit &source, const Vec2i &pos)
|
||||
{
|
||||
CUnit *enemy = NULL;
|
||||
CUnit *enemy = nullptr;
|
||||
|
||||
_EnemyOnMapTile filter(source, pos, &enemy);
|
||||
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) {
|
||||
CUnit &aiunit = *force->Units[i];
|
||||
if (aiunit.Type->CanAttack) {
|
||||
CommandAttack(aiunit, wallPos, NULL, FlushCommands);
|
||||
CommandAttack(aiunit, wallPos, nullptr, FlushCommands);
|
||||
} else {
|
||||
CommandMove(aiunit, wallPos, FlushCommands);
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ int AiForce::PlanAttack()
|
|||
|
||||
CUnit *transporter = Units.find(IsAFreeTransporter());
|
||||
|
||||
if (transporter != NULL) {
|
||||
if (transporter != nullptr) {
|
||||
DebugPrint("%d: Transporter #%d\n" _C_ player.Index _C_ UnitNumber(*transporter));
|
||||
MarkReacheableTerrainType(*transporter, &transporterTerrainTraversal);
|
||||
} else {
|
||||
|
@ -370,7 +370,7 @@ int AiForce::PlanAttack()
|
|||
// Find a land unit of the force.
|
||||
// FIXME: if force is split over different places -> broken
|
||||
CUnit *landUnit = Units.find(CUnitTypeFinder(UnitTypeLand));
|
||||
if (landUnit == NULL) {
|
||||
if (landUnit == nullptr) {
|
||||
DebugPrint("%d: No land unit in force\n" _C_ player.Index);
|
||||
return 0;
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ int AiForce::PlanAttack()
|
|||
|
||||
static bool ChooseRandomUnexploredPositionNear(const Vec2i ¢er, Vec2i *pos)
|
||||
{
|
||||
Assert(pos != NULL);
|
||||
Assert(pos != nullptr);
|
||||
|
||||
int ray = 3;
|
||||
const int maxTryCount = 8;
|
||||
|
@ -450,11 +450,11 @@ static CUnit *GetBestExplorer(const AiExplorationRequest &request, Vec2i *pos)
|
|||
// Choose a target, "near"
|
||||
const Vec2i ¢er = request.pos;
|
||||
if (ChooseRandomUnexploredPositionNear(center, pos) == false) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
// We have an unexplored tile in sight (pos)
|
||||
|
||||
CUnit *bestunit = NULL;
|
||||
CUnit *bestunit = nullptr;
|
||||
// Find an idle unit, responding to the mask
|
||||
bool flyeronly = false;
|
||||
int bestSquareDistance = -1;
|
||||
|
@ -517,7 +517,7 @@ void AiSendExplorers()
|
|||
|
||||
Vec2i pos;
|
||||
CUnit *bestunit = GetBestExplorer(request, &pos);
|
||||
if (bestunit != NULL) {
|
||||
if (bestunit != nullptr) {
|
||||
CommandMove(*bestunit, pos, FlushCommands);
|
||||
AiPlayer->LastExplorationGameCycle = GameCycle;
|
||||
break;
|
||||
|
|
|
@ -216,7 +216,7 @@ bool AiEnemyUnitsInDistance(const CPlayer &player,
|
|||
const Vec2i offset(range, range);
|
||||
std::vector<CUnit *> units;
|
||||
|
||||
if (type == NULL) {
|
||||
if (type == nullptr) {
|
||||
Select<1>(pos - offset, pos + offset, units, IsAEnemyUnitOf<true>(player));
|
||||
return static_cast<int>(units.size());
|
||||
} else {
|
||||
|
@ -370,14 +370,14 @@ void AiNewDepotRequest(CUnit &worker)
|
|||
const Vec2i pos = order.GetHarvestLocation();
|
||||
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
|
||||
* (far away) from new Deopt.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
CUnitType *best_type = NULL;
|
||||
CUnitType *best_type = nullptr;
|
||||
int best_cost = 0;
|
||||
//int best_mask = 0;
|
||||
// Count the already made build requests.
|
||||
|
@ -404,7 +404,7 @@ void AiNewDepotRequest(CUnit &worker)
|
|||
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_cost = cost;
|
||||
//best_mask = needmask;
|
||||
|
@ -462,7 +462,7 @@ private:
|
|||
** @param oldDepot Old assigned depot.
|
||||
** @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)
|
||||
{
|
||||
|
@ -480,7 +480,7 @@ CUnit *AiGetSuitableDepot(const CUnit &worker, const CUnit &oldDepot, CUnit **re
|
|||
}
|
||||
// If there aren't any alternatives, exit
|
||||
if (depots.size() < 2) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
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 NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1154,7 +1154,7 @@ static void AiCollectResources()
|
|||
}
|
||||
}
|
||||
}
|
||||
unit = NULL;
|
||||
unit = nullptr;
|
||||
|
||||
// Try to complete each ressource in the priority order
|
||||
for (int i = 0; i < MaxCosts; ++i) {
|
||||
|
@ -1218,7 +1218,7 @@ static void AiCollectResources()
|
|||
|
||||
// unit can't harvest : next one
|
||||
if (!unit->Type->ResInfo[c] || !AiAssignHarvester(*unit, c)) {
|
||||
unit = NULL;
|
||||
unit = nullptr;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1305,10 +1305,10 @@ static bool AiRepairBuilding(const CPlayer &player, const CUnitType &type, CUnit
|
|||
|
||||
const int maxRange = 15;
|
||||
const int movemask = type.MovementMask & ~(MapFieldLandUnit | MapFieldAirUnit | MapFieldSeaUnit);
|
||||
CUnit *unit = NULL;
|
||||
CUnit *unit = nullptr;
|
||||
UnitFinder unitFinder(player, table, maxRange, movemask, &unit);
|
||||
|
||||
if (terrainTraversal.Run(unitFinder) && unit != NULL) {
|
||||
if (terrainTraversal.Run(unitFinder) && unit != nullptr) {
|
||||
const Vec2i invalidPos(-1, -1);
|
||||
CommandRepair(*unit, invalidPos, &building, FlushCommands);
|
||||
return true;
|
||||
|
|
|
@ -132,7 +132,7 @@ static std::vector<CUnitType *> getSupplyUnits()
|
|||
// Now, sort them, best first.
|
||||
while (!res.empty()) {
|
||||
float bestscore = 0;
|
||||
CUnitType *besttype = NULL;
|
||||
CUnitType *besttype = nullptr;
|
||||
|
||||
for (std::vector<CUnitType *>::const_iterator i = res.begin(); i != res.end(); ++i) {
|
||||
CUnitType &type = **i;
|
||||
|
@ -364,7 +364,7 @@ static CAiType *GetAiTypesByName(const char *name)
|
|||
return ait;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -491,7 +491,7 @@ static AiRequestType *FindInUnitTypeRequests(const CUnitType *type)
|
|||
return &AiPlayer->UnitTypeRequests[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -614,7 +614,7 @@ static int CclAiDebugPlayer(lua_State *l)
|
|||
if (lua_isstring(l, j + 1)) {
|
||||
item = LuaToString(l, j + 1);
|
||||
} else {
|
||||
item = NULL;
|
||||
item = nullptr;
|
||||
}
|
||||
if (item && !strcmp(item, "none")) {
|
||||
for (int i = 0; i != NumPlayers; ++i) {
|
||||
|
@ -1368,7 +1368,7 @@ static int CclAiResearch(lua_State *l)
|
|||
upgrade = CUpgrade::Get(str);
|
||||
} else {
|
||||
LuaError(l, "Upgrade needed");
|
||||
upgrade = NULL;
|
||||
upgrade = nullptr;
|
||||
}
|
||||
InsertResearchRequests(upgrade);
|
||||
lua_pushboolean(l, 0);
|
||||
|
@ -1679,7 +1679,7 @@ static int CclDefineAiPlayer(lua_State *l)
|
|||
if (!strcmp(value, "ai-type")) {
|
||||
const char *aiName = LuaToString(l, j + 1);
|
||||
CAiType *ait = GetAiTypesByName(aiName);
|
||||
if (ait == NULL) {
|
||||
if (ait == nullptr) {
|
||||
LuaError(l, "ai-type not found: %s" _C_ aiName);
|
||||
}
|
||||
ai->AiType = ait;
|
||||
|
@ -1935,7 +1935,7 @@ static CTCPSocket * AiProcessorSendState(lua_State *l, char prefix)
|
|||
{
|
||||
LuaCheckArgs(l, 3);
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ int ParseAnimInt(const CUnit &unit, const char *parseint)
|
|||
}
|
||||
}
|
||||
char *next = strchr(cur, '.');
|
||||
if (next == NULL) {
|
||||
if (next == nullptr) {
|
||||
fprintf(stderr, "Need also specify the variable '%s' tag \n", cur);
|
||||
ExitFatal(1);
|
||||
} else {
|
||||
|
@ -227,7 +227,7 @@ int ParseAnimInt(const CUnit &unit, const char *parseint)
|
|||
if (*cur == '(') {
|
||||
++cur;
|
||||
char *end = strchr(cur, ')');
|
||||
if (end == NULL) {
|
||||
if (end == nullptr) {
|
||||
fprintf(stderr, "ParseAnimInt: expected ')'\n");
|
||||
ExitFatal(1);
|
||||
}
|
||||
|
@ -236,20 +236,20 @@ int ParseAnimInt(const CUnit &unit, const char *parseint)
|
|||
} else {
|
||||
next = strchr(cur, '.');
|
||||
}
|
||||
if (next == NULL) {
|
||||
if (next == nullptr) {
|
||||
fprintf(stderr, "Need also specify the %s player's property\n", cur);
|
||||
ExitFatal(1);
|
||||
} else {
|
||||
*next = '\0';
|
||||
}
|
||||
char *arg = strchr(next + 1, '.');
|
||||
if (arg != NULL) {
|
||||
if (arg != nullptr) {
|
||||
*arg = '\0';
|
||||
}
|
||||
return GetPlayerData(ParseAnimPlayer(unit, cur), next + 1, arg + 1);
|
||||
} else if (s[0] == 'r') { //random value
|
||||
char *next = strchr(cur, '.');
|
||||
if (next == NULL) {
|
||||
if (next == nullptr) {
|
||||
return SyncRand(atoi(cur) + 1);
|
||||
} else {
|
||||
*next = '\0';
|
||||
|
@ -410,7 +410,7 @@ CAnimations *AnimationsByIdent(const std::string &ident)
|
|||
if (ret != AnimationMap.end()) {
|
||||
return (*ret).second;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
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());
|
||||
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));
|
||||
const std::string extraArg(all, begin);
|
||||
|
||||
CAnimation *anim = NULL;
|
||||
CAnimation *anim = nullptr;
|
||||
if (op1 == "frame") {
|
||||
anim = new CAnimation_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);
|
||||
|
||||
if (args == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
Labels.clear();
|
||||
LabelsLater.clear();
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
int CAnimation_ExactFrame::ParseAnimInt(const CUnit *unit) const
|
||||
{
|
||||
if (unit == NULL) {
|
||||
if (unit == nullptr) {
|
||||
return atoi(this->frame.c_str());
|
||||
} else {
|
||||
return ::ParseAnimInt(*unit, this->frame.c_str());
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
int CAnimation_Frame::ParseAnimInt(const CUnit *unit) const
|
||||
{
|
||||
if (unit == NULL) {
|
||||
if (unit == nullptr) {
|
||||
return atoi(this->frame.c_str());
|
||||
} else {
|
||||
return ::ParseAnimInt(*unit, this->frame.c_str());
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
}
|
||||
|
||||
char *next = strchr(arg1, '.');
|
||||
if (next == NULL) {
|
||||
if (next == nullptr) {
|
||||
// Special case for non-CVariable variables
|
||||
if (!strcmp(arg1, "DamageType")) {
|
||||
int death = ExtraDeathIndex(this->valueStr.c_str());
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
PixelPos start;
|
||||
PixelPos dest;
|
||||
MissileType *mtype = MissileTypeByIdent(this->missileTypeStr);
|
||||
if (mtype == NULL) {
|
||||
if (mtype == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
FindNearestDrop(*type, pos, resPos, LookingW);
|
||||
if (SquareDistance(pos, resPos) <= square(range)) {
|
||||
CUnit *target = MakeUnit(*type, &player);
|
||||
if (target != NULL) {
|
||||
if (target != nullptr) {
|
||||
target->tilePos = resPos;
|
||||
target->Place(resPos);
|
||||
if (flags & SU_Summoned) {
|
||||
|
@ -76,7 +76,7 @@
|
|||
CommandDefend(*target, unit, FlushCommands);
|
||||
}
|
||||
}
|
||||
//DropOutOnSide(*target, LookingW, NULL);
|
||||
//DropOutOnSide(*target, LookingW, nullptr);
|
||||
} else {
|
||||
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...?
|
||||
CUnit *unit = MakeUnitAndPlace(pos, type, player);
|
||||
if (unit == NULL) {
|
||||
if (unit == nullptr) {
|
||||
DebugPrint("Unable to allocate Unit");
|
||||
return;
|
||||
}
|
||||
|
||||
CBuildRestrictionOnTop *b = OnTopDetails(*unit, NULL);
|
||||
CBuildRestrictionOnTop *b = OnTopDetails(*unit, nullptr);
|
||||
if (b && b->ReplaceOnBuild) {
|
||||
CUnitCache &unitCache = Map.Field(pos)->UnitCache;
|
||||
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].Max = replacedUnit.Variable[GIVERESOURCE_INDEX].Max;
|
||||
unit->Variable[GIVERESOURCE_INDEX].Enable = replacedUnit.Variable[GIVERESOURCE_INDEX].Enable;
|
||||
replacedUnit.Remove(NULL); // Destroy building beneath
|
||||
replacedUnit.Remove(nullptr); // Destroy building beneath
|
||||
UnitLost(replacedUnit);
|
||||
UnitClearOrders(replacedUnit);
|
||||
replacedUnit.Release();
|
||||
}
|
||||
}
|
||||
if (unit != NULL) {
|
||||
if (unit != nullptr) {
|
||||
if (type.GivesResource) {
|
||||
if (type.StartingResources != 0) {
|
||||
unit->ResourcesHeld = type.StartingResources;
|
||||
|
@ -336,7 +336,7 @@ static void EditorPlaceUnit(const Vec2i &pos, CUnitType &type, CPlayer *player)
|
|||
*/
|
||||
static void EditorActionRemoveUnit(CUnit &unit)
|
||||
{
|
||||
unit.Remove(NULL);
|
||||
unit.Remove(nullptr);
|
||||
UnitLost(unit);
|
||||
UnitClearOrders(unit);
|
||||
unit.Release();
|
||||
|
@ -429,7 +429,7 @@ static void CalculateMaxIconSize()
|
|||
for (unsigned int i = 0; i < Editor.UnitTypes.size(); ++i) {
|
||||
if (!Editor.UnitTypes[i].empty()) {
|
||||
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;
|
||||
|
||||
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());
|
||||
Editor.ShownUnitTypes.push_back(type);
|
||||
} 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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
CIcon &icon = *Editor.ShownUnitTypes[i]->Icon.Icon;
|
||||
|
@ -1304,7 +1304,7 @@ static void EditorCallbackButtonDown(unsigned button)
|
|||
|
||||
// Right click on a resource
|
||||
if (Editor.State == EditorSelecting) {
|
||||
if ((MouseButtons & RightButton) && (UnitUnderCursor != NULL || !Selected.empty())) {
|
||||
if ((MouseButtons & RightButton) && (UnitUnderCursor != nullptr || !Selected.empty())) {
|
||||
lua_getglobal(Lua, "EditUnitProperties");
|
||||
if (lua_isfunction(Lua, -1) == 1) {
|
||||
lua_newtable(Lua);
|
||||
|
@ -1331,11 +1331,11 @@ static void EditorCallbackButtonDown(unsigned button)
|
|||
if (MouseButtons & RightButton) {
|
||||
if (Editor.State == EditorEditUnit && Editor.SelectedUnitIndex != -1) {
|
||||
Editor.SelectedUnitIndex = -1;
|
||||
CursorBuilding = NULL;
|
||||
CursorBuilding = nullptr;
|
||||
return;
|
||||
} else if (Editor.State == EditorEditTile && Editor.SelectedTileIndex != -1) {
|
||||
Editor.SelectedTileIndex = -1;
|
||||
CursorBuilding = NULL;
|
||||
CursorBuilding = nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1353,7 +1353,7 @@ static void EditorCallbackButtonDown(unsigned button)
|
|||
EditTiles(tilePos, Editor.SelectedTileIndex != -1 ? Editor.ShownTileTypes[Editor.SelectedTileIndex] : -1, TileCursorSize);
|
||||
} else if (Editor.State == EditorEditUnit) {
|
||||
if (!UnitPlacedThisPress && CursorBuilding) {
|
||||
if (CanBuildUnitType(NULL, *CursorBuilding, tilePos, 1)) {
|
||||
if (CanBuildUnitType(nullptr, *CursorBuilding, tilePos, 1)) {
|
||||
PlayGameSound(GameSounds.PlacementSuccess[ThisPlayer->Race].Sound,
|
||||
MaxSampleVolume);
|
||||
EditorPlaceUnit(tilePos, *CursorBuilding, Players + Editor.SelectedPlayer);
|
||||
|
@ -1487,7 +1487,7 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
|||
|
||||
case SDLK_BACKSPACE:
|
||||
case SDLK_DELETE: // Delete
|
||||
if (UnitUnderCursor != NULL) {
|
||||
if (UnitUnderCursor != nullptr) {
|
||||
EditorRemoveUnit(*UnitUnderCursor);
|
||||
}
|
||||
break;
|
||||
|
@ -1510,7 +1510,7 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
|||
break;
|
||||
case '0':
|
||||
if (!(KeyModifiers & ModifierAlt)) {
|
||||
if (UnitUnderCursor != NULL) {
|
||||
if (UnitUnderCursor != nullptr) {
|
||||
UnitUnderCursor->ChangeOwner(Players[PlayerNumNeutral]);
|
||||
UI.StatusLine.Set(_("Unit owner modified"));
|
||||
}
|
||||
|
@ -1529,7 +1529,7 @@ static void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (UnitUnderCursor != NULL && Map.Info.PlayerType[pnum] != PlayerTypes::PlayerNobody) {
|
||||
if (UnitUnderCursor != nullptr && Map.Info.PlayerType[pnum] != PlayerTypes::PlayerNobody) {
|
||||
UnitUnderCursor->ChangeOwner(Players[pnum]);
|
||||
UI.StatusLine.Set(_("Unit owner modified"));
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
char buf[256];
|
||||
|
@ -1777,7 +1777,7 @@ static void EditorCallbackMouse(const PixelPos &pos)
|
|||
EditTiles(tilePos, Editor.SelectedTileIndex != -1 ? Editor.ShownTileTypes[Editor.SelectedTileIndex] : -1, TileCursorSize);
|
||||
} else if (Editor.State == EditorEditUnit && CursorBuilding) {
|
||||
if (!UnitPlacedThisPress) {
|
||||
if (CanBuildUnitType(NULL, *CursorBuilding, tilePos, 1)) {
|
||||
if (CanBuildUnitType(nullptr, *CursorBuilding, tilePos, 1)) {
|
||||
EditorPlaceUnit(tilePos, *CursorBuilding, Players + Editor.SelectedPlayer);
|
||||
UnitPlacedThisPress = true;
|
||||
UI.StatusLine.Clear();
|
||||
|
@ -1839,7 +1839,7 @@ static void EditorCallbackMouse(const PixelPos &pos)
|
|||
}
|
||||
|
||||
// Map
|
||||
UnitUnderCursor = NULL;
|
||||
UnitUnderCursor = nullptr;
|
||||
if (UI.MapArea.Contains(screenPos)) {
|
||||
CViewport *vp = GetViewport(screenPos);
|
||||
Assert(vp);
|
||||
|
@ -1854,7 +1854,7 @@ static void EditorCallbackMouse(const PixelPos &pos)
|
|||
const PixelPos cursorMapPos = UI.MouseViewport->ScreenToMapPixelPos(CursorScreenPos);
|
||||
UnitUnderCursor = UnitOnScreen(cursorMapPos.x, cursorMapPos.y);
|
||||
|
||||
if (UnitUnderCursor != NULL) {
|
||||
if (UnitUnderCursor != nullptr) {
|
||||
ShowUnitInfo(*UnitUnderCursor);
|
||||
return;
|
||||
}
|
||||
|
@ -1943,9 +1943,9 @@ void CEditor::Init()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (UI.ButtonPanel.G != NULL) {
|
||||
if (UI.ButtonPanel.G != nullptr) {
|
||||
ButtonPanelWidth = UI.ButtonPanel.G->Width;
|
||||
} else if (UI.InfoPanel.G != NULL) {
|
||||
} else if (UI.InfoPanel.G != nullptr) {
|
||||
ButtonPanelWidth = UI.InfoPanel.G->Width;
|
||||
} else {
|
||||
ButtonPanelWidth = 170;
|
||||
|
@ -1957,9 +1957,9 @@ void CEditor::Init()
|
|||
if (!StartUnitName.empty()) {
|
||||
StartUnit = UnitTypeByIdent(StartUnitName);
|
||||
}
|
||||
Select.Icon = NULL;
|
||||
Select.Icon = nullptr;
|
||||
Select.Load();
|
||||
Units.Icon = NULL;
|
||||
Units.Icon = nullptr;
|
||||
Units.Load();
|
||||
|
||||
Map.Tileset->fillSolidTiles(&Editor.ShownTileTypes);
|
||||
|
@ -2280,7 +2280,7 @@ void EditorMainLoop()
|
|||
|
||||
WaitEventsOneFrame();
|
||||
}
|
||||
CursorBuilding = NULL;
|
||||
CursorBuilding = nullptr;
|
||||
if (!Editor.MapLoaded) {
|
||||
break;
|
||||
}
|
||||
|
@ -2318,7 +2318,7 @@ void EditorMainLoop()
|
|||
/**
|
||||
** 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)
|
||||
{
|
||||
|
@ -2327,7 +2327,7 @@ void StartEditor(const char *filename)
|
|||
GetDefaultTextColors(nc, rc);
|
||||
if (filename) {
|
||||
if (strcpy_s(CurrentMapPath, sizeof(CurrentMapPath), filename) != 0) {
|
||||
filename = NULL;
|
||||
filename = nullptr;
|
||||
}
|
||||
}
|
||||
if (!filename) {
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
CEditor::CEditor() :
|
||||
TerrainEditable(true),
|
||||
StartUnit(NULL),
|
||||
StartUnit(nullptr),
|
||||
UnitIndex(0), CursorUnitIndex(-1), SelectedUnitIndex(-1),
|
||||
TileIndex(0), CursorTileIndex(-1), SelectedTileIndex(-1),
|
||||
CursorPlayer(-1), SelectedPlayer(PlayerNumNeutral),
|
||||
|
|
|
@ -367,28 +367,28 @@ static void EditorRandomizeUnit(const char *unit_type, int count, int value, int
|
|||
|
||||
// FIXME: can overlap units
|
||||
CUnit *unit = MakeUnitAndPlace(rpos, type, &Players[PlayerNumNeutral]);
|
||||
if (unit == NULL) {
|
||||
if (unit == nullptr) {
|
||||
DebugPrint("Unable to allocate Unit");
|
||||
} else {
|
||||
unit->ResourcesHeld = value;
|
||||
}
|
||||
|
||||
unit = MakeUnitAndPlace(tmirrorh, type, &Players[PlayerNumNeutral]);
|
||||
if (unit == NULL) {
|
||||
if (unit == nullptr) {
|
||||
DebugPrint("Unable to allocate Unit");
|
||||
} else {
|
||||
unit->ResourcesHeld = value;
|
||||
}
|
||||
|
||||
unit = MakeUnitAndPlace(tmirrorv, type, &Players[PlayerNumNeutral]);
|
||||
if (unit == NULL) {
|
||||
if (unit == nullptr) {
|
||||
DebugPrint("Unable to allocate Unit");
|
||||
} else {
|
||||
unit->ResourcesHeld = value;
|
||||
}
|
||||
|
||||
unit = MakeUnitAndPlace(tmirror, type, &Players[PlayerNumNeutral]);
|
||||
if (unit == NULL) {
|
||||
if (unit == nullptr) {
|
||||
DebugPrint("Unable to allocate Unit");
|
||||
} else {
|
||||
unit->ResourcesHeld = value;
|
||||
|
@ -404,7 +404,7 @@ static void EditorDestroyAllUnits()
|
|||
while (UnitManager->empty() == false) {
|
||||
CUnit &unit = **UnitManager->begin();
|
||||
|
||||
unit.Remove(NULL);
|
||||
unit.Remove(nullptr);
|
||||
UnitLost(unit);
|
||||
UnitClearOrders(unit);
|
||||
unit.Release();
|
||||
|
|
|
@ -258,7 +258,7 @@ static void WriteMapPreview(const char *mapname, CMap &map)
|
|||
const SDL_PixelFormat *fmt = MinimapSurface->format;
|
||||
SDL_Surface *preview = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||
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);
|
||||
|
||||
|
@ -291,7 +291,7 @@ std::string PlayerTypeNames[static_cast<int>(PlayerTypes::PlayerRescueActive) +
|
|||
// Write the map presentation file
|
||||
static int WriteMapPresentation(const std::string &mapname, CMap &map, Vec2i newSize)
|
||||
{
|
||||
FileWriter *f = NULL;
|
||||
FileWriter *f = nullptr;
|
||||
|
||||
int numplayers = 0;
|
||||
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)
|
||||
{
|
||||
FileWriter *f = NULL;
|
||||
FileWriter *f = nullptr;
|
||||
|
||||
try {
|
||||
f = CreateFileWriter(mapSetup);
|
||||
|
@ -837,7 +837,7 @@ void CreateGame(const std::string &filename, CMap *map)
|
|||
if (SaveGameLoading) {
|
||||
SaveGameLoading = false;
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ void CreateGame(const std::string &filename, CMap *map)
|
|||
|
||||
GameResult = GameNoResult;
|
||||
|
||||
CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
||||
CommandLog(nullptr, NoUnitP, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||
Video.ClearScreen();
|
||||
}
|
||||
|
||||
|
@ -1139,8 +1139,8 @@ void CleanGame()
|
|||
Map.Clean();
|
||||
CleanReplayLog();
|
||||
FreePathfinder();
|
||||
CursorBuilding = NULL;
|
||||
UnitUnderCursor = NULL;
|
||||
CursorBuilding = nullptr;
|
||||
UnitUnderCursor = nullptr;
|
||||
GameEstablishing = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class LogEntry
|
|||
{
|
||||
public:
|
||||
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;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class FullReplay
|
|||
{
|
||||
public:
|
||||
FullReplay() :
|
||||
MapId(0), LocalPlayer(0), Commands(NULL)
|
||||
MapId(0), LocalPlayer(0), Commands(nullptr)
|
||||
{
|
||||
ReplaySettings.Init();
|
||||
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
|
||||
CommandLogDisabled = false;
|
||||
delete LogFile;
|
||||
LogFile = NULL;
|
||||
LogFile = nullptr;
|
||||
return;
|
||||
}
|
||||
LastLogFileName = path;
|
||||
|
@ -533,7 +533,7 @@ static int CclReplayLog(lua_State *l)
|
|||
LuaError(l, "incorrect argument");
|
||||
}
|
||||
|
||||
Assert(CurrentReplay == NULL);
|
||||
Assert(CurrentReplay == nullptr);
|
||||
|
||||
replay = new FullReplay;
|
||||
|
||||
|
@ -672,13 +672,13 @@ void EndReplayLog()
|
|||
if (LogFile) {
|
||||
LogFile->close();
|
||||
delete LogFile;
|
||||
LogFile = NULL;
|
||||
LogFile = nullptr;
|
||||
}
|
||||
if (CurrentReplay) {
|
||||
DeleteReplay(CurrentReplay);
|
||||
CurrentReplay = NULL;
|
||||
CurrentReplay = nullptr;
|
||||
}
|
||||
ReplayStep = NULL;
|
||||
ReplayStep = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -690,7 +690,7 @@ void CleanReplayLog()
|
|||
DeleteReplay(CurrentReplay);
|
||||
CurrentReplay = nullptr;
|
||||
}
|
||||
ReplayStep = NULL;
|
||||
ReplayStep = nullptr;
|
||||
|
||||
// if (DisabledLog) {
|
||||
CommandLogDisabled = false;
|
||||
|
@ -720,8 +720,8 @@ static void DoNextReplay()
|
|||
const Vec2i pos(ReplayStep->PosX, ReplayStep->PosY);
|
||||
const int arg1 = ReplayStep->PosX;
|
||||
const int arg2 = ReplayStep->PosY;
|
||||
CUnit *unit = unitSlot != -1 ? &UnitManager->GetSlotUnit(unitSlot) : NULL;
|
||||
CUnit *dunit = (ReplayStep->DestUnitNumber != -1 ? &UnitManager->GetSlotUnit(ReplayStep->DestUnitNumber) : NULL);
|
||||
CUnit *unit = unitSlot != -1 ? &UnitManager->GetSlotUnit(unitSlot) : nullptr;
|
||||
CUnit *dunit = (ReplayStep->DestUnitNumber != -1 ? &UnitManager->GetSlotUnit(ReplayStep->DestUnitNumber) : nullptr);
|
||||
const char *val = ReplayStep->Value.c_str();
|
||||
const int num = ReplayStep->Num;
|
||||
|
||||
|
@ -788,7 +788,7 @@ static void DoNextReplay()
|
|||
} else if (!strcmp(action, "train")) {
|
||||
SendCommandTrainUnit(*unit, *UnitTypeByIdent(val), flags);
|
||||
} 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")) {
|
||||
SendCommandUpgradeTo(*unit, *UnitTypeByIdent(val), flags);
|
||||
} 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') {
|
||||
return &CompareNEq;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -708,7 +708,7 @@ void CleanTriggers()
|
|||
Trigger = 0;
|
||||
|
||||
delete[] ActiveTriggers;
|
||||
ActiveTriggers = NULL;
|
||||
ActiveTriggers = nullptr;
|
||||
|
||||
GameTimer.Reset();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class COrder_Attack : public COrder
|
|||
friend COrder *COrder::NewActionAttackGround(const CUnit &attacker, const Vec2i &dest);
|
||||
public:
|
||||
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); }
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class COrder_Build : public COrder
|
|||
{
|
||||
friend COrder *COrder::NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building);
|
||||
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.y = -1;
|
||||
|
|
|
@ -38,7 +38,7 @@ class COrder_Built : public COrder
|
|||
{
|
||||
friend COrder *COrder::NewActionBuilt(CUnit &builder, CUnit &unit);
|
||||
public:
|
||||
COrder_Built() : COrder(UnitActionBuilt), ProgressCounter(0), IsCancelled(false), Frame(NULL) {}
|
||||
COrder_Built() : COrder(UnitActionBuilt), ProgressCounter(0), IsCancelled(false), Frame(nullptr) {}
|
||||
~COrder_Built();
|
||||
|
||||
virtual COrder_Built *Clone() const { return new COrder_Built(*this); }
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
class COrder_Research : public COrder
|
||||
{
|
||||
public:
|
||||
COrder_Research() : COrder(UnitActionResearch), Upgrade(NULL) {}
|
||||
COrder_Research() : COrder(UnitActionResearch), Upgrade(nullptr) {}
|
||||
|
||||
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);
|
||||
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.y = -1;
|
||||
|
|
|
@ -38,7 +38,7 @@ class COrder_Train : public COrder
|
|||
{
|
||||
friend COrder *COrder::NewActionTrain(CUnit &trainer, CUnitType &type);
|
||||
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); }
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class COrder_TransformInto : public COrder
|
|||
{
|
||||
friend COrder *COrder::NewActionTransformInto(CUnitType &type);
|
||||
public:
|
||||
COrder_TransformInto() : COrder(UnitActionTransformInto), Type(NULL) {}
|
||||
COrder_TransformInto() : COrder(UnitActionTransformInto), Type(nullptr) {}
|
||||
|
||||
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);
|
||||
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); }
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
|
||||
virtual void UpdatePathFinderData(PathFinderInput &input) = 0;
|
||||
|
||||
bool HasGoal() const { return Goal != NULL; }
|
||||
bool HasGoal() const { return Goal != nullptr; }
|
||||
CUnit *GetGoal() const { return Goal; };
|
||||
void SetGoal(CUnit *const new_goal);
|
||||
void ClearGoal();
|
||||
|
|
|
@ -94,12 +94,12 @@ enum SetVar_ModifyTypes {
|
|||
class CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation(AnimationType type) : Type(type), Next(NULL) {}
|
||||
CAnimation(AnimationType type) : Type(type), Next(nullptr) {}
|
||||
|
||||
virtual ~CAnimation() {}
|
||||
|
||||
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;
|
||||
CAnimation *Next;
|
||||
|
@ -108,9 +108,9 @@ public:
|
|||
class CAnimations
|
||||
{
|
||||
public:
|
||||
CAnimations() : Attack(NULL), RangedAttack(NULL), Build(NULL), Move(NULL), Repair(NULL),
|
||||
Research(NULL), SpellCast(NULL), Start(NULL), Still(NULL),
|
||||
Train(NULL), Upgrade(NULL), hasDeathAnimation(false)
|
||||
CAnimations() : Attack(nullptr), RangedAttack(nullptr), Build(nullptr), Move(nullptr), Repair(nullptr),
|
||||
Research(nullptr), SpellCast(nullptr), Start(nullptr), Still(nullptr),
|
||||
Train(nullptr), Upgrade(nullptr), hasDeathAnimation(false)
|
||||
{
|
||||
memset(Death, 0, sizeof(Death));
|
||||
memset(Harvest, 0, sizeof(Harvest));
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
class CAnimation_Goto : public CAnimation
|
||||
{
|
||||
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 Init(const char *s, lua_State *l);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
class CAnimation_IfVar : public CAnimation
|
||||
{
|
||||
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 Init(const char *s, lua_State *l);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
class CAnimation_LuaCallback : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_LuaCallback() : CAnimation(AnimationLuaCallback), cb(NULL) {}
|
||||
CAnimation_LuaCallback() : CAnimation(AnimationLuaCallback), cb(nullptr) {}
|
||||
~CAnimation_LuaCallback() { delete cb; }
|
||||
|
||||
virtual void Action(CUnit &unit, int &move, int scale) const;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
class CAnimation_RandomGoto : public CAnimation
|
||||
{
|
||||
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 Init(const char *s, lua_State *l);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
class CAnimation_Wiggle : public CAnimation
|
||||
{
|
||||
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 Init(const char *s, lua_State *l);
|
||||
|
|
|
@ -113,7 +113,7 @@ class CConstructionFrame
|
|||
{
|
||||
public:
|
||||
CConstructionFrame() : Percent(0), File(ConstructionFileConstruction),
|
||||
Frame(0), Next(NULL) {}
|
||||
Frame(0), Next(nullptr) {}
|
||||
|
||||
int Percent; /// Percent complete
|
||||
ConstructionFileType File; /// Graphic to use
|
||||
|
@ -125,8 +125,8 @@ public:
|
|||
class CConstruction
|
||||
{
|
||||
public:
|
||||
CConstruction() : Frames(NULL), Sprite(NULL), Width(0),
|
||||
Height(0), ShadowSprite(NULL), ShadowWidth(0), ShadowHeight(0)
|
||||
CConstruction() : Frames(nullptr), Sprite(nullptr), Width(0),
|
||||
Height(0), ShadowSprite(nullptr), ShadowWidth(0), ShadowHeight(0)
|
||||
{
|
||||
File.Width = 0;
|
||||
File.Height = 0;
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
** CCursor::Race
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** CCursor::HotPos
|
||||
|
@ -125,7 +125,7 @@ class CCursor
|
|||
{
|
||||
public:
|
||||
CCursor() : HotPos(0, 0),
|
||||
SpriteFrame(0), FrameRate(0), G(NULL) {}
|
||||
SpriteFrame(0), FrameRate(0), G(nullptr) {}
|
||||
|
||||
~CCursor();
|
||||
|
||||
|
@ -153,7 +153,7 @@ private:
|
|||
class CursorConfig
|
||||
{
|
||||
public:
|
||||
CursorConfig() : Cursor(NULL) {}
|
||||
CursorConfig() : Cursor(nullptr) {}
|
||||
|
||||
void Load();
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ class CFont : public gcn::Font
|
|||
private:
|
||||
explicit CFont(const std::string &ident) :
|
||||
Ident(ident),
|
||||
CharWidth(NULL),
|
||||
G(NULL)
|
||||
CharWidth(nullptr),
|
||||
G(nullptr)
|
||||
{}
|
||||
|
||||
public:
|
||||
|
|
|
@ -172,7 +172,7 @@ private:
|
|||
class IconConfig
|
||||
{
|
||||
public:
|
||||
IconConfig() : Icon(NULL) {}
|
||||
IconConfig() : Icon(nullptr) {}
|
||||
|
||||
bool LoadNoLog();
|
||||
bool Load();
|
||||
|
|
|
@ -88,8 +88,8 @@ typedef bool (*ButtonCheckFunc)(const CUnit &, const ButtonAction &);
|
|||
class ButtonAction
|
||||
{
|
||||
public:
|
||||
ButtonAction() : Pos(0), Level(0), AlwaysShow(false), Action(ButtonMove), Value(0), Payload(NULL),
|
||||
Allowed(NULL), Key(0) {}
|
||||
ButtonAction() : Pos(0), Level(0), AlwaysShow(false), Action(ButtonMove), Value(0), Payload(nullptr),
|
||||
Allowed(nullptr), Key(0) {}
|
||||
|
||||
int Pos; /// button position in the grid
|
||||
int Level; /// requires button level
|
||||
|
|
|
@ -424,7 +424,7 @@ public:
|
|||
|
||||
void DrawMissile(const CViewport &vp) const;
|
||||
void SaveMissile(CFile &file) const;
|
||||
void MissileHit(CUnit *unit = NULL);
|
||||
void MissileHit(CUnit *unit = nullptr);
|
||||
bool NextMissileFrame(char sign, char longAnimation);
|
||||
void NextMissileFrameCycle();
|
||||
void MissileNewHeadingFromXY(const PixelPos &delta);
|
||||
|
@ -566,7 +566,7 @@ public:
|
|||
class BurningBuildingFrame
|
||||
{
|
||||
public:
|
||||
BurningBuildingFrame() : Percent(0), Missile(NULL) {};
|
||||
BurningBuildingFrame() : Percent(0), Missile(nullptr) {};
|
||||
|
||||
int Percent; /// HP percent
|
||||
MissileType *Missile; /// Missile to draw
|
||||
|
|
|
@ -44,7 +44,7 @@ class MissileType;
|
|||
class MissileConfig
|
||||
{
|
||||
public:
|
||||
MissileConfig() : Missile(NULL) {}
|
||||
MissileConfig() : Missile(nullptr) {}
|
||||
|
||||
bool MapMissileNoLog();
|
||||
bool MapMissile();
|
||||
|
|
|
@ -87,8 +87,8 @@ struct OggData {
|
|||
class Movie : public gcn::Image
|
||||
{
|
||||
public:
|
||||
Movie() : rect(NULL), yuv_overlay(NULL), surface(NULL), need_data(true), start_time(0),
|
||||
is_dirty(true), Width(0), Height(0), data(NULL), f(NULL) {};
|
||||
Movie() : rect(nullptr), yuv_overlay(nullptr), surface(nullptr), need_data(true), start_time(0),
|
||||
is_dirty(true), Width(0), Height(0), data(nullptr), f(nullptr) {};
|
||||
~Movie();
|
||||
bool Load(const std::string &filename, int w, int h);
|
||||
bool IsPlaying() const { return is_dirty; }
|
||||
|
@ -138,7 +138,7 @@ public:
|
|||
bool Load(const std::string &filename, int w, int h) { return false; };
|
||||
bool IsPlaying() const { return false; };
|
||||
//guichan
|
||||
virtual void *_getData() const { return NULL; };
|
||||
virtual void *_getData() const { return nullptr; };
|
||||
virtual int getWidth() const { return 0; };
|
||||
virtual int getHeight() const { return 0; };
|
||||
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);
|
||||
|
||||
/// 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.
|
||||
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 void FreeSample(Mix_Chunk *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
|
||||
extern int PlaySample(Mix_Chunk *sample, void (*callback)(int channel));
|
||||
/// Play a sound file
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
class Spell_AdjustVariable : public SpellActionType
|
||||
{
|
||||
public:
|
||||
Spell_AdjustVariable() : Var(NULL) {};
|
||||
Spell_AdjustVariable() : Var(nullptr) {};
|
||||
~Spell_AdjustVariable() { delete [](this->Var); };
|
||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||
CUnit *&target, const Vec2i &goalPos);
|
||||
|
|
|
@ -42,7 +42,7 @@ class Spell_AreaBombardment : public SpellActionType
|
|||
{
|
||||
public:
|
||||
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,
|
||||
CUnit *&target, const Vec2i &goalPos);
|
||||
virtual void Parse(lua_State *l, int startIndex, int endIndex);
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
class Spell_LuaCallback : public SpellActionType
|
||||
{
|
||||
public:
|
||||
Spell_LuaCallback() : Func(NULL) {};
|
||||
Spell_LuaCallback() : Func(nullptr) {};
|
||||
~Spell_LuaCallback() { delete Func; };
|
||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||
CUnit *&target, const Vec2i &goalPos);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
class Spell_Polymorph : public SpellActionType
|
||||
{
|
||||
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,
|
||||
CUnit *&target, const Vec2i &goalPos);
|
||||
virtual void Parse(lua_State *l, int startIndex, int endIndex);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
class Spell_Summon : public SpellActionType
|
||||
{
|
||||
public:
|
||||
Spell_Summon() : SpellActionType(1), UnitType(NULL), TTL(0),
|
||||
Spell_Summon() : SpellActionType(1), UnitType(nullptr), TTL(0),
|
||||
RequireCorpse(false), JoinToAiForce(false) {};
|
||||
virtual int Cast(CUnit &caster, const SpellType &spell,
|
||||
CUnit *&target, const Vec2i &goalPos);
|
||||
|
|
|
@ -137,7 +137,7 @@ class ConditionInfo
|
|||
{
|
||||
public:
|
||||
ConditionInfo() : Alliance(0), Opponent(0), TargetSelf(1),
|
||||
BoolFlag(NULL), Variable(NULL), CheckFunc(NULL) {};
|
||||
BoolFlag(nullptr), Variable(nullptr), CheckFunc(nullptr) {};
|
||||
~ConditionInfo()
|
||||
{
|
||||
delete[] BoolFlag;
|
||||
|
@ -173,8 +173,8 @@ public:
|
|||
// Special flags for priority sorting
|
||||
#define ACP_NOVALUE -1
|
||||
#define ACP_DISTANCE -2
|
||||
AutoCastInfo() : Range(0), MinRange(0), PriorytyVar(ACP_NOVALUE), ReverseSort(false), Condition(NULL),
|
||||
Combat(0), Attacker(0), Corpse(CONDITION_FALSE), PositionAutoCast(NULL) {};
|
||||
AutoCastInfo() : Range(0), MinRange(0), PriorytyVar(ACP_NOVALUE), ReverseSort(false), Condition(nullptr),
|
||||
Combat(0), Attacker(0), Corpse(CONDITION_FALSE), PositionAutoCast(nullptr) {};
|
||||
~AutoCastInfo()
|
||||
{
|
||||
delete Condition;
|
||||
|
|
|
@ -32,8 +32,8 @@ inline void print_backtrace(int sz = 100) {
|
|||
char* name;
|
||||
|
||||
process = GetCurrentProcess();
|
||||
SymInitialize(process, NULL, TRUE);
|
||||
frames = CaptureStackBackTrace(0, sz, stack, NULL);
|
||||
SymInitialize(process, nullptr, TRUE);
|
||||
frames = CaptureStackBackTrace(0, sz, stack, nullptr);
|
||||
fprintf(stderr, "backtrace returned %d addresses\n", frames);
|
||||
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 1024 * sizeof(char), 1);
|
||||
symbol->MaxNameLen = 1024;
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
class TitleScreen
|
||||
{
|
||||
public:
|
||||
TitleScreen() : StretchImage(true), Timeout(0), Iterations(0), Editor(0), Labels(NULL) {}
|
||||
TitleScreen() : StretchImage(true), Timeout(0), Iterations(0), Editor(0), Labels(nullptr) {}
|
||||
~TitleScreen()
|
||||
{
|
||||
if (this->Labels) {
|
||||
|
|
|
@ -85,7 +85,7 @@ enum TextAlignment {
|
|||
class ButtonStyleProperties
|
||||
{
|
||||
public:
|
||||
ButtonStyleProperties() : Sprite(NULL), Frame(0), BorderColor(0),
|
||||
ButtonStyleProperties() : Sprite(nullptr), Frame(0), BorderColor(0),
|
||||
BorderSize(0), TextAlign(TextAlignUndefined),
|
||||
TextPos(0, 0)
|
||||
{}
|
||||
|
@ -124,9 +124,9 @@ public:
|
|||
class CUIButton
|
||||
{
|
||||
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
|
||||
// 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() {}
|
||||
|
||||
bool Contains(const PixelPos &screenPos) const;
|
||||
|
@ -186,8 +186,8 @@ class ConditionPanel
|
|||
{
|
||||
public:
|
||||
ConditionPanel() : ShowOnlySelected(false), HideNeutral(false),
|
||||
HideAllied(false), ShowOpponent(false), BoolFlags(NULL),
|
||||
Variables(NULL) {}
|
||||
HideAllied(false), ShowOpponent(false), BoolFlags(nullptr),
|
||||
Variables(nullptr) {}
|
||||
~ConditionPanel()
|
||||
{
|
||||
delete[] BoolFlags;
|
||||
|
@ -211,7 +211,7 @@ class CUnitInfoPanel
|
|||
{
|
||||
public:
|
||||
CUnitInfoPanel() : PosX(0), PosY(0), DefaultFont(0),
|
||||
Contents(), Condition(NULL) {}
|
||||
Contents(), Condition(nullptr) {}
|
||||
~CUnitInfoPanel();
|
||||
|
||||
public:
|
||||
|
@ -222,14 +222,14 @@ public:
|
|||
|
||||
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
|
||||
{
|
||||
struct bits_map {
|
||||
bits_map() : Width(0), Height(0), bstore(NULL) {}
|
||||
bits_map() : Width(0), Height(0), bstore(nullptr) {}
|
||||
~bits_map();
|
||||
|
||||
void Init(CGraphic *g);
|
||||
|
@ -253,7 +253,7 @@ class CFiller
|
|||
|
||||
bits_map map;
|
||||
public:
|
||||
CFiller() : G(NULL), X(0), Y(0) {}
|
||||
CFiller() : G(nullptr), X(0), Y(0) {}
|
||||
|
||||
void Load();
|
||||
|
||||
|
@ -274,7 +274,7 @@ public:
|
|||
class CButtonPanel
|
||||
{
|
||||
public:
|
||||
CButtonPanel() : G(NULL), X(0), Y(0), ShowCommandKey(true)
|
||||
CButtonPanel() : G(nullptr), X(0), Y(0), ShowCommandKey(true)
|
||||
{}
|
||||
|
||||
void Draw();
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
class CPieMenu
|
||||
{
|
||||
public:
|
||||
CPieMenu() : G(NULL), MouseButton(NoButton)
|
||||
CPieMenu() : G(nullptr), MouseButton(NoButton)
|
||||
{
|
||||
memset(this->X, 0, sizeof(this->X));
|
||||
memset(this->Y, 0, sizeof(this->Y));
|
||||
|
@ -340,7 +340,7 @@ public:
|
|||
class CResourceInfo
|
||||
{
|
||||
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) {}
|
||||
|
||||
CGraphic *G; /// icon graphic
|
||||
|
@ -356,7 +356,7 @@ public:
|
|||
class CInfoPanel
|
||||
{
|
||||
public:
|
||||
CInfoPanel() : G(NULL), X(0), Y(0) {}
|
||||
CInfoPanel() : G(nullptr), X(0), Y(0) {}
|
||||
|
||||
void Draw();
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class ConditionPanel;
|
|||
class CContentType
|
||||
{
|
||||
public:
|
||||
CContentType() : Pos(0, 0), Condition(NULL) {}
|
||||
CContentType() : Pos(0, 0), Condition(nullptr) {}
|
||||
virtual ~CContentType();
|
||||
|
||||
/// Tell how show the variable Index.
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
public:
|
||||
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
|
||||
{
|
||||
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) {}
|
||||
virtual ~CContentTypeText()
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
class CContentTypeFormattedText : public CContentType
|
||||
{
|
||||
public:
|
||||
CContentTypeFormattedText() : Font(NULL), Centered(false),
|
||||
CContentTypeFormattedText() : Font(nullptr), Centered(false),
|
||||
Index(-1), Component(VariableValue) {}
|
||||
virtual ~CContentTypeFormattedText() {}
|
||||
|
||||
|
@ -114,7 +114,7 @@ private:
|
|||
class CContentTypeFormattedText2 : public CContentType
|
||||
{
|
||||
public:
|
||||
CContentTypeFormattedText2() : Font(NULL), Centered(false),
|
||||
CContentTypeFormattedText2() : Font(nullptr), Centered(false),
|
||||
Index1(-1), Component1(VariableValue), Index2(-1), Component2(VariableValue) {}
|
||||
virtual ~CContentTypeFormattedText2() {}
|
||||
|
||||
|
@ -168,7 +168,7 @@ private:
|
|||
class CContentTypeLifeBar : public CContentType
|
||||
{
|
||||
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()
|
||||
{
|
||||
FreeNumberDesc(ValueFunc);
|
||||
|
|
|
@ -53,7 +53,7 @@ class PopupConditionPanel
|
|||
{
|
||||
public:
|
||||
PopupConditionPanel() : HasHint(false), HasDescription(false), HasDependencies(false),
|
||||
ButtonAction(-1), BoolFlags(NULL), Variables(NULL) {}
|
||||
ButtonAction(-1), BoolFlags(nullptr), Variables(nullptr) {}
|
||||
~PopupConditionPanel()
|
||||
{
|
||||
delete[] BoolFlags;
|
||||
|
@ -75,7 +75,7 @@ class CPopupContentType
|
|||
public:
|
||||
CPopupContentType() : pos(0, 0),
|
||||
MarginX(MARGIN_X), MarginY(MARGIN_Y), minSize(0, 0),
|
||||
Wrap(true), Condition(NULL) {}
|
||||
Wrap(true), Condition(nullptr) {}
|
||||
virtual ~CPopupContentType() { delete Condition; }
|
||||
|
||||
/// Tell how show the variable Index.
|
||||
|
@ -100,7 +100,7 @@ protected:
|
|||
std::string TextColor; /// Color used for plain text in content.
|
||||
std::string HighlightColor; /// Color used for highlighted letters.
|
||||
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 {
|
||||
|
@ -112,7 +112,7 @@ enum PopupButtonInfo_Types {
|
|||
class CPopupContentTypeButtonInfo : public CPopupContentType
|
||||
{
|
||||
public:
|
||||
CPopupContentTypeButtonInfo() : InfoType(0), MaxWidth(0), Font(NULL) {}
|
||||
CPopupContentTypeButtonInfo() : InfoType(0), MaxWidth(0), Font(nullptr) {}
|
||||
virtual ~CPopupContentTypeButtonInfo() {}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
CPopupContentTypeText() : MaxWidth(0), Font(NULL) {}
|
||||
CPopupContentTypeText() : MaxWidth(0), Font(nullptr) {}
|
||||
virtual ~CPopupContentTypeText() {}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
CPopupContentTypeCosts() : Font(NULL), Centered(0) {}
|
||||
CPopupContentTypeCosts() : Font(nullptr), Centered(0) {}
|
||||
virtual ~CPopupContentTypeCosts() {}
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
CPopupContentTypeVariable() : Text(NULL), Font(NULL), Centered(0), Index(-1) {}
|
||||
CPopupContentTypeVariable() : Text(nullptr), Font(nullptr), Centered(0), Index(-1) {}
|
||||
virtual ~CPopupContentTypeVariable()
|
||||
{
|
||||
FreeStringDesc(Text);
|
||||
|
|
|
@ -37,7 +37,7 @@ class CFont;
|
|||
class CUITimer
|
||||
{
|
||||
public:
|
||||
CUITimer() : X(0), Y(0), Font(NULL) {}
|
||||
CUITimer() : X(0), Y(0), Font(nullptr) {}
|
||||
|
||||
void Draw(int second) const;
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@ enum _directions_ {
|
|||
class CUnit
|
||||
{
|
||||
public:
|
||||
CUnit() : tilePos(-1, -1), pathFinderData(NULL), SavedOrder(NULL), NewOrder(NULL), CriticalOrder(NULL), Colors(-1),
|
||||
AutoCastSpell(NULL), SpellCoolDownTimers(NULL), Variable(NULL) { Init(); }
|
||||
CUnit() : tilePos(-1, -1), pathFinderData(nullptr), SavedOrder(nullptr), NewOrder(nullptr), CriticalOrder(nullptr), Colors(-1),
|
||||
AutoCastSpell(nullptr), SpellCoolDownTimers(nullptr), Variable(nullptr) { Init(); }
|
||||
~CUnit();
|
||||
|
||||
void Init();
|
||||
|
@ -388,11 +388,11 @@ public:
|
|||
|
||||
unsigned TeamSelected; /// unit is selected by a team member.
|
||||
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. */
|
||||
int VisCount[PlayerMax]; /// Unit visibility counts
|
||||
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
|
||||
int Frame; /// last seen frame/stage of buildings
|
||||
const CUnitType *Type; /// Pointer to last seen unit-type
|
||||
|
@ -455,7 +455,7 @@ public:
|
|||
IconsShift(false), StereoSound(true), MineNotifications(false),
|
||||
DeselectInMine(false), NoStatusLineTooltips(false),
|
||||
SelectionRectangleIndicatesDamage(false), FormationMovement(true),
|
||||
IconFrameG(NULL), PressedIconFrameG(NULL), HardwareCursor(false),
|
||||
IconFrameG(nullptr), PressedIconFrameG(nullptr), HardwareCursor(false),
|
||||
ShowOrders(0), ShowNameDelay(0), ShowNameTime(0), AutosaveMinutes(5) {};
|
||||
|
||||
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
|
||||
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
|
||||
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.
|
||||
* @param pred A predicate object vith bool operator()(const CUnit *).
|
||||
* @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>
|
||||
CUnit *find(const _T &pred) const
|
||||
{
|
||||
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>
|
||||
|
@ -320,7 +320,7 @@ CUnit *FindUnit_If(const Vec2i <Pos, const Vec2i &rbPos, Pred pred)
|
|||
|
||||
/// Find resource
|
||||
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
|
||||
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);
|
||||
|
||||
/// 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
|
||||
extern CUnit *AttackUnitsInDistance(const CUnit &unit, int range, CUnitFilter pred);
|
||||
extern CUnit *AttackUnitsInDistance(const CUnit &unit, int range);
|
||||
|
|
|
@ -41,7 +41,7 @@ class CUnit;
|
|||
class CUnitPtr
|
||||
{
|
||||
public:
|
||||
CUnitPtr() : unit(NULL) {}
|
||||
CUnitPtr() : unit(nullptr) {}
|
||||
CUnitPtr(CUnit *u);
|
||||
CUnitPtr(const CUnitPtr &u);
|
||||
~CUnitPtr() { Reset(); }
|
||||
|
|
|
@ -54,8 +54,8 @@ class CSound;
|
|||
class SoundConfig
|
||||
{
|
||||
public:
|
||||
SoundConfig() : Sound(NULL) {}
|
||||
SoundConfig(std::string name) : Name(name), Sound(NULL) {}
|
||||
SoundConfig() : Sound(nullptr) {}
|
||||
SoundConfig(std::string name) : Name(name), Sound(nullptr) {}
|
||||
|
||||
bool MapSound();
|
||||
void SetSoundRange(unsigned char range);
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
ResourceInfo() : WaitAtResource(0), ResourceStep(0),
|
||||
ResourceCapacity(0), WaitAtDepot(0), ResourceId(0), FinalResource(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.
|
||||
|
@ -310,7 +310,7 @@ public:
|
|||
class CDecoVarText : public CDecoVar
|
||||
{
|
||||
public:
|
||||
CDecoVarText() : Font(NULL) {};
|
||||
CDecoVarText() : Font(nullptr) {};
|
||||
/// function to draw the decorations.
|
||||
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
|
||||
};
|
||||
public:
|
||||
CBuildRestrictionAddOn() : Offset(0, 0), Parent(NULL) {}
|
||||
CBuildRestrictionAddOn() : Offset(0, 0), Parent(nullptr) {}
|
||||
virtual ~CBuildRestrictionAddOn() {}
|
||||
virtual void Init() {this->Parent = UnitTypeByIdent(this->ParentName);}
|
||||
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
|
||||
};
|
||||
public:
|
||||
CBuildRestrictionOnTop() : Parent(NULL), ReplaceOnDie(0), ReplaceOnBuild(0) {};
|
||||
CBuildRestrictionOnTop() : Parent(nullptr), ReplaceOnDie(0), ReplaceOnBuild(0) {};
|
||||
virtual ~CBuildRestrictionOnTop() {};
|
||||
virtual void Init() {this->Parent = UnitTypeByIdent(this->ParentName);};
|
||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||
|
@ -457,7 +457,7 @@ public:
|
|||
class CBuildRestrictionDistance : public CBuildRestriction
|
||||
{
|
||||
public:
|
||||
CBuildRestrictionDistance() : Distance(0), CheckBuilder(false), RestrictType(NULL), Diagonal(true) {};
|
||||
CBuildRestrictionDistance() : Distance(0), CheckBuilder(false), RestrictType(nullptr), Diagonal(true) {};
|
||||
virtual ~CBuildRestrictionDistance() {};
|
||||
virtual void Init() {this->RestrictType = UnitTypeByIdent(this->RestrictTypeName);};
|
||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||
|
@ -474,7 +474,7 @@ public:
|
|||
class CBuildRestrictionHasUnit : public CBuildRestriction
|
||||
{
|
||||
public:
|
||||
CBuildRestrictionHasUnit() : Count(0), RestrictType(NULL) {};
|
||||
CBuildRestrictionHasUnit() : Count(0), RestrictType(nullptr) {};
|
||||
virtual ~CBuildRestrictionHasUnit() {};
|
||||
virtual void Init() { this->RestrictType = UnitTypeByIdent(this->RestrictTypeName); };
|
||||
virtual bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const;
|
||||
|
@ -489,7 +489,7 @@ public:
|
|||
class CBuildRestrictionSurroundedBy : public CBuildRestriction
|
||||
{
|
||||
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 void Init() { this->RestrictType = UnitTypeByIdent(this->RestrictTypeName); };
|
||||
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 NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -129,7 +129,7 @@ extern int GetResourceIdByName(lua_State *l, const char *resourceName);
|
|||
class CUnitStats
|
||||
{
|
||||
public:
|
||||
CUnitStats() : Variables(NULL)
|
||||
CUnitStats() : Variables(nullptr)
|
||||
{
|
||||
memset(Costs, 0, sizeof(Costs));
|
||||
memset(Storing, 0, sizeof(Storing));
|
||||
|
@ -182,7 +182,7 @@ public:
|
|||
class CUpgradeModifier
|
||||
{
|
||||
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(ChangeUpgrades, 0, sizeof(ChangeUpgrades));
|
||||
|
|
|
@ -99,11 +99,11 @@ public:
|
|||
};
|
||||
|
||||
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),
|
||||
Refs(1), Resized(false)
|
||||
{
|
||||
frameFlip_map = NULL;
|
||||
frameFlip_map = nullptr;
|
||||
}
|
||||
~CGraphic() {}
|
||||
|
||||
|
@ -177,7 +177,7 @@ public:
|
|||
// minor programmatic editing features
|
||||
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
|
||||
virtual void *_getData() const { return Surface; }
|
||||
|
@ -277,14 +277,14 @@ class Mng : public gcn::Image
|
|||
Mng() {};
|
||||
~Mng() {};
|
||||
public:
|
||||
static Mng *New(const std::string &name) { return NULL; }
|
||||
static Mng *New(const std::string &name) { return nullptr; }
|
||||
static void Free(Mng *mng) {};
|
||||
bool Load() { return false; };
|
||||
void Reset() {};
|
||||
void Draw(int x, int y) {};
|
||||
|
||||
//guichan
|
||||
virtual void *_getData() const { return NULL; };
|
||||
virtual void *_getData() const { return nullptr; };
|
||||
virtual int getWidth() const { return 0; };
|
||||
virtual int getHeight() const { return 0; };
|
||||
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",
|
||||
"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) {
|
||||
int i = 0;
|
||||
while (ColorNames[i] != NULL) {
|
||||
while (ColorNames[i] != nullptr) {
|
||||
if (!strcmp(colorName, ColorNames[i])) {
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -268,8 +268,8 @@ class ImageTextField : public gcn::TextField
|
|||
{
|
||||
|
||||
public:
|
||||
ImageTextField() : TextField(), itemImage(NULL) {}
|
||||
ImageTextField(const std::string& text) : gcn::TextField(text), itemImage(NULL) {}
|
||||
ImageTextField() : TextField(), itemImage(nullptr) {}
|
||||
ImageTextField(const std::string& text) : gcn::TextField(text), itemImage(nullptr) {}
|
||||
virtual void draw(gcn::Graphics *graphics);
|
||||
virtual void drawBorder(gcn::Graphics *graphics);
|
||||
void setItemImage(CGraphic *image) { itemImage = image; }
|
||||
|
@ -419,7 +419,7 @@ public:
|
|||
class ImageDropDownWidget : public DropDownWidget
|
||||
{
|
||||
public:
|
||||
ImageDropDownWidget() : itemImage(NULL) {
|
||||
ImageDropDownWidget() : itemImage(nullptr) {
|
||||
mListBox.addActionListener(this);
|
||||
setListModel(&listmodel);
|
||||
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
|
||||
if (unit.ReleaseCycle) return;
|
||||
Assert(unit.Type != NULL);
|
||||
Assert(unit.Type != nullptr);
|
||||
// Units under construction have no sight range.
|
||||
if (!range) {
|
||||
return;
|
||||
|
|
|
@ -143,7 +143,7 @@ void CFogOfWar::InitTiled()
|
|||
if (Settings.Type == FogOfWarTypes::cTiledLegacy) {
|
||||
TileOfFogOnly = SDL_CreateRGBSurface(SDL_SWSURFACE, PixelTileSize.x, PixelTileSize.y,
|
||||
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,
|
||||
|
@ -422,7 +422,7 @@ void CFogOfWar::Draw(CViewport &viewport)
|
|||
if (Settings.Type == FogOfWarTypes::cTiledLegacy) {
|
||||
DrawTiledLegacy(viewport);
|
||||
} else {
|
||||
SDL_FillRect(viewport.GetFogSurface(), NULL, 0x00);
|
||||
SDL_FillRect(viewport.GetFogSurface(), nullptr, 0x00);
|
||||
|
||||
if (Settings.Type == FogOfWarTypes::cTiled) {
|
||||
DrawTiled(viewport);
|
||||
|
|
|
@ -318,7 +318,7 @@ void CMapInfo::Clear()
|
|||
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?
|
||||
|
||||
this->Info.Clear();
|
||||
this->Fields = NULL;
|
||||
this->Fields = nullptr;
|
||||
this->NoFogOfWar = false;
|
||||
this->Tileset->clear();
|
||||
this->TileModelsFileName.clear();
|
||||
CGraphic::Free(this->TileGraphic);
|
||||
this->TileGraphic = NULL;
|
||||
this->TileGraphic = nullptr;
|
||||
|
||||
FlagRevealMap = MapRevealModes::cHidden;
|
||||
ReplayRevealMap = 0;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
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->BottomRightPos.x = this->BottomRightPos.y = 0;
|
||||
|
@ -429,7 +429,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
|||
this->DrawMapBackgroundInViewport<true>(highlightChecker);
|
||||
}
|
||||
|
||||
Missile *clickMissile = NULL;
|
||||
Missile *clickMissile = nullptr;
|
||||
CurrentViewport = this;
|
||||
{
|
||||
// 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 (missiletable[j]->Type->DrawLevel < particletable[k]->getDrawLevel()) {
|
||||
missiletable[j]->DrawMissile(*this);
|
||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
clickMissile = missiletable[j];
|
||||
}
|
||||
++j;
|
||||
|
@ -476,7 +476,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
|||
++i;
|
||||
} else {
|
||||
missiletable[j]->DrawMissile(*this);
|
||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
clickMissile = missiletable[j];
|
||||
}
|
||||
++j;
|
||||
|
@ -493,7 +493,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
|||
} else {
|
||||
if (missiletable[j]->Type->DrawLevel < particletable[k]->getDrawLevel()) {
|
||||
missiletable[j]->DrawMissile(*this);
|
||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
clickMissile = missiletable[j];
|
||||
}
|
||||
++j;
|
||||
|
@ -509,7 +509,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
|||
}
|
||||
for (; j < nmissiles; ++j) {
|
||||
missiletable[j]->DrawMissile(*this);
|
||||
if (clickMissile == NULL && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
if (clickMissile == nullptr && missiletable[j]->Type->Ident == ClickMissile) {
|
||||
clickMissile = missiletable[j];
|
||||
}
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ void CViewport::Draw(const fieldHighlightChecker highlightChecker /* = nullptr *
|
|||
this->DrawMapFogOfWar();
|
||||
|
||||
// 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);
|
||||
Map.Clamp(pos);
|
||||
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)) {
|
||||
ShowUnitName(*this, CursorScreenPos, UnitUnderCursor);
|
||||
} else if (!isMapFieldVisile) {
|
||||
ShowUnitName(*this, CursorScreenPos, NULL, true);
|
||||
ShowUnitName(*this, CursorScreenPos, nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class _filter_flags
|
|||
public:
|
||||
_filter_flags(const CPlayer &p, int *fogmask) : player(&p), fogmask(fogmask)
|
||||
{
|
||||
Assert(fogmask != NULL);
|
||||
Assert(fogmask != nullptr);
|
||||
}
|
||||
|
||||
void operator()(const CUnit *const unit) const
|
||||
|
@ -436,7 +436,7 @@ void CViewport::AdjustFogSurface()
|
|||
SDL_SetSurfaceBlendMode(this->FogSurface, SDL_BLENDMODE_NONE);
|
||||
|
||||
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()
|
||||
|
|
|
@ -143,7 +143,7 @@ void CMinimap::Create()
|
|||
SDL_SetSurfaceBlendMode(MinimapFogSurface, SDL_BLENDMODE_BLEND);
|
||||
|
||||
const uint32_t fogColorSolid = FogOfWar->GetFogColorSDL() | (uint32_t(0xFF) << ASHIFT);
|
||||
SDL_FillRect(MinimapFogSurface, NULL, fogColorSolid);
|
||||
SDL_FillRect(MinimapFogSurface, nullptr, fogColorSolid);
|
||||
|
||||
UpdateTerrain();
|
||||
|
||||
|
@ -377,14 +377,14 @@ void CMinimap::Update()
|
|||
|
||||
// Clear Minimap background if not 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
|
||||
//
|
||||
if (WithTerrain) {
|
||||
SDL_BlitSurface(MinimapTerrainSurface, NULL, MinimapSurface, NULL);
|
||||
SDL_BlitSurface(MinimapTerrainSurface, nullptr, MinimapSurface, nullptr);
|
||||
}
|
||||
const uint32_t fogColorSDL = FogOfWar->GetFogColorSDL();
|
||||
if (!ReplayRevealMap) {
|
||||
|
@ -444,7 +444,7 @@ static void DrawEvents()
|
|||
void CMinimap::Draw() const
|
||||
{
|
||||
SDL_Rect drect = {Sint16(X), Sint16(Y), 0, 0};
|
||||
SDL_BlitSurface(MinimapSurface, NULL, TheScreen, &drect);
|
||||
SDL_BlitSurface(MinimapSurface, nullptr, TheScreen, &drect);
|
||||
|
||||
DrawEvents();
|
||||
}
|
||||
|
@ -487,21 +487,21 @@ void CMinimap::Destroy()
|
|||
if (MinimapTerrainSurface) {
|
||||
VideoPaletteListRemove(MinimapTerrainSurface);
|
||||
SDL_FreeSurface(MinimapTerrainSurface);
|
||||
MinimapTerrainSurface = NULL;
|
||||
MinimapTerrainSurface = nullptr;
|
||||
}
|
||||
if (MinimapSurface) {
|
||||
VideoPaletteListRemove(MinimapSurface);
|
||||
SDL_FreeSurface(MinimapSurface);
|
||||
MinimapSurface = NULL;
|
||||
MinimapSurface = nullptr;
|
||||
}
|
||||
if (MinimapFogSurface && MinimapFogSurface->format != NULL) {
|
||||
if (MinimapFogSurface && MinimapFogSurface->format != nullptr) {
|
||||
SDL_FreeSurface(MinimapFogSurface);
|
||||
MinimapFogSurface = NULL;
|
||||
MinimapFogSurface = nullptr;
|
||||
}
|
||||
delete[] Minimap2MapX;
|
||||
Minimap2MapX = NULL;
|
||||
Minimap2MapX = nullptr;
|
||||
delete[] Minimap2MapY;
|
||||
Minimap2MapY = NULL;
|
||||
Minimap2MapY = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -232,7 +232,7 @@ static int CclShowMapLocation(lua_State *l)
|
|||
return 0;
|
||||
}
|
||||
CUnit *target = MakeUnit(*unitType, ThisPlayer);
|
||||
if (target != NULL) {
|
||||
if (target != nullptr) {
|
||||
target->Variable[HP_INDEX].Value = 0;
|
||||
target->tilePos.x = LuaToNumber(l, 1);
|
||||
target->tilePos.y = LuaToNumber(l, 2);
|
||||
|
|
|
@ -1455,7 +1455,7 @@ sdl2::SurfacePtr CTilesetGraphicGenerator::composeImage(sequence_of_imagesPtrs &
|
|||
auto dst { newBlankImage() };
|
||||
|
||||
for (auto &src : srcSequence) {
|
||||
SDL_BlitSurface(src, NULL, dst.get(), NULL);
|
||||
SDL_BlitSurface(src, nullptr, dst.get(), nullptr);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
|
|
@ -118,13 +118,13 @@ void LoadMissileSprites()
|
|||
MissileType *MissileTypeByIdent(const std::string &ident)
|
||||
{
|
||||
if (ident.empty()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
MissileTypeMap::iterator it = MissileTypes.find(ident);
|
||||
if (it != MissileTypes.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +146,7 @@ MissileType *NewMissileTypeSlot(const std::string &ident)
|
|||
** Constructor
|
||||
*/
|
||||
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),
|
||||
TTL(-1), Hidden(0), DestroyMissile(0),
|
||||
CurrentStep(0), TotalStep(0),
|
||||
|
@ -172,7 +172,7 @@ Missile::Missile() :
|
|||
*/
|
||||
/* static */ Missile *Missile::Init(const MissileType &mtype, const PixelPos &startPos, const PixelPos &destPos)
|
||||
{
|
||||
Missile *missile = NULL;
|
||||
Missile *missile = nullptr;
|
||||
|
||||
switch (mtype.Class) {
|
||||
case MissileClassNone :
|
||||
|
@ -335,8 +335,8 @@ int CalculateDamage(const CUnit &attacker, const CUnit &goal, const NumberDesc *
|
|||
TriggerData.Attacker = const_cast<CUnit *>(&attacker);
|
||||
TriggerData.Defender = const_cast<CUnit *>(&goal);
|
||||
const int res = EvalNumber(formula);
|
||||
TriggerData.Attacker = NULL;
|
||||
TriggerData.Defender = NULL;
|
||||
TriggerData.Attacker = nullptr;
|
||||
TriggerData.Defender = nullptr;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ void FireMissile(CUnit &unit, CUnit *goal, const Vec2i &goalPos)
|
|||
if (goal->CurrentAction() == UnitActionDie) {
|
||||
if (unit.Type->Missile.Missile->AlwaysFire) {
|
||||
newgoalPos = goal->tilePos;
|
||||
goal = NULL;
|
||||
goal = nullptr;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -751,7 +751,7 @@ bool PointToPointMissile(Missile &missile)
|
|||
if (missile.TotalStep == 0) {
|
||||
return true;
|
||||
}
|
||||
Assert(missile.Type != NULL);
|
||||
Assert(missile.Type != nullptr);
|
||||
Assert(missile.TotalStep != 0);
|
||||
|
||||
const PixelPos diff = (missile.destination - missile.source);
|
||||
|
@ -838,12 +838,12 @@ static void MissileHitsGoal(const Missile &missile, CUnit &goal, int splash)
|
|||
int damage;
|
||||
|
||||
if (missile.Type->Damage) { // custom formula
|
||||
Assert(missile.SourceUnit != NULL);
|
||||
Assert(missile.SourceUnit != nullptr);
|
||||
damage = CalculateDamage(*missile.SourceUnit, goal, missile.Type->Damage) / splash;
|
||||
} else if (missile.Damage) { // direct damage, spells mostly
|
||||
damage = missile.Damage / splash;
|
||||
} else {
|
||||
Assert(missile.SourceUnit != NULL);
|
||||
Assert(missile.SourceUnit != nullptr);
|
||||
damage = CalculateDamage(*missile.SourceUnit, goal, Damage) / splash;
|
||||
}
|
||||
if (missile.Type->Pierce) { // Handle pierce factor
|
||||
|
@ -877,7 +877,7 @@ static void MissileHitsWall(const Missile &missile, const Vec2i &tilePos, int sp
|
|||
return;
|
||||
}
|
||||
|
||||
Assert(missile.SourceUnit != NULL);
|
||||
Assert(missile.SourceUnit != nullptr);
|
||||
if (Map.HumanWallOnMap(tilePos)) {
|
||||
stats = UnitTypeHumanWall->Stats;
|
||||
} else {
|
||||
|
@ -983,7 +983,7 @@ void Missile::MissileHit(CUnit *unit)
|
|||
}
|
||||
}
|
||||
if (goal.Destroyed) {
|
||||
this->TargetUnit = NULL;
|
||||
this->TargetUnit = nullptr;
|
||||
return;
|
||||
}
|
||||
MissileHitsGoal(*this, goal, 1);
|
||||
|
@ -1000,7 +1000,7 @@ void Missile::MissileHit(CUnit *unit)
|
|||
const Vec2i range(mtype.Range - 1, mtype.Range - 1);
|
||||
std::vector<CUnit *> table;
|
||||
Select(pos - range, pos + range, table);
|
||||
Assert(this->SourceUnit != NULL);
|
||||
Assert(this->SourceUnit != nullptr);
|
||||
for (size_t i = 0; i != table.size(); ++i) {
|
||||
CUnit &goal = *table[i];
|
||||
//
|
||||
|
@ -1022,7 +1022,7 @@ void Missile::MissileHit(CUnit *unit)
|
|||
|
||||
if (mtype.CorrectSphashDamage == true) {
|
||||
bool isPosition = false;
|
||||
if (this->TargetUnit == NULL) {
|
||||
if (this->TargetUnit == nullptr) {
|
||||
if (this->SourceUnit->CurrentAction() == UnitActionSpellCast) {
|
||||
const COrder_SpellCast &order = *static_cast<COrder_SpellCast *>(this->SourceUnit->CurrentOrder());
|
||||
if (order.GetSpell().Target == TargetPosition) {
|
||||
|
@ -1037,7 +1037,7 @@ void Missile::MissileHit(CUnit *unit)
|
|||
shouldHit = false;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
@ -1235,7 +1235,7 @@ MissileType *MissileBurningBuilding(int percent)
|
|||
return (*i)->Missile;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1264,10 +1264,10 @@ void Missile::SaveMissile(CFile &file) const
|
|||
SavePixelPos(file, this->destination);
|
||||
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);
|
||||
if (this->SourceUnit != NULL) {
|
||||
if (this->SourceUnit != nullptr) {
|
||||
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(" \"damage\", %d,", this->Damage);
|
||||
|
@ -1337,9 +1337,9 @@ MissileType::MissileType(const std::string &ident) :
|
|||
AlwaysFire(false), Pierce(false), PierceOnce(false), IgnoreWalls(true), KillFirstUnit(false),
|
||||
Class(), NumBounces(0), ParabolCoefficient(2048), StartDelay(0),
|
||||
Sleep(0), Speed(0), BlizzardSpeed(0), TTL(-1), ReduceFactor(100), SmokePrecision(0),
|
||||
MissileStopFlags(0), Damage(NULL), Range(0), SplashFactor(0),
|
||||
ImpactParticle(NULL), SmokeParticle(NULL), OnImpact(NULL),
|
||||
G(NULL)
|
||||
MissileStopFlags(0), Damage(nullptr), Range(0), SplashFactor(0),
|
||||
ImpactParticle(nullptr), SmokeParticle(nullptr), OnImpact(nullptr),
|
||||
G(nullptr)
|
||||
{
|
||||
size.x = 0;
|
||||
size.y = 0;
|
||||
|
|
|
@ -47,7 +47,7 @@ void MissileClipToTarget::Action()
|
|||
{
|
||||
this->Wait = this->Type->Sleep;
|
||||
|
||||
if (this->TargetUnit != NULL) {
|
||||
if (this->TargetUnit != nullptr) {
|
||||
const PixelPos halfSize = this->Type->size / 2;
|
||||
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;
|
||||
|
|
|
@ -56,7 +56,7 @@ void MissileDeathCoil::Action()
|
|||
if (this->NextMissileFrame(1, 0) == false) {
|
||||
return;
|
||||
}
|
||||
Assert(this->SourceUnit != NULL);
|
||||
Assert(this->SourceUnit != nullptr);
|
||||
CUnit &source = *this->SourceUnit;
|
||||
|
||||
if (source.Destroyed) {
|
||||
|
|
|
@ -67,7 +67,7 @@ void MissileLandMine::Action()
|
|||
{
|
||||
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);
|
||||
this->MissileHit();
|
||||
this->TTL = 0;
|
||||
|
|
|
@ -64,7 +64,7 @@ static bool ParabolicMissile(Missile &missile)
|
|||
if (missile.TotalStep == 0) {
|
||||
return true;
|
||||
}
|
||||
Assert(missile.Type != NULL);
|
||||
Assert(missile.Type != nullptr);
|
||||
const PixelPos orig_pos = missile.position;
|
||||
Assert(missile.TotalStep != 0);
|
||||
const PixelPos diff = (missile.destination - missile.source);
|
||||
|
|
|
@ -58,7 +58,7 @@ static bool TracerMissile(Missile &missile)
|
|||
return true;
|
||||
}
|
||||
|
||||
Assert(missile.Type != NULL);
|
||||
Assert(missile.Type != nullptr);
|
||||
Assert(missile.TotalStep != 0);
|
||||
if (missile.TargetUnit) {
|
||||
missile.destination = missile.TargetUnit->GetMapPixelPosTopLeft();
|
||||
|
|
|
@ -40,11 +40,11 @@
|
|||
bool MissileConfig::MapMissileNoLog()
|
||||
{
|
||||
if (this->Name.empty()) {
|
||||
this->Missile = NULL;
|
||||
this->Missile = nullptr;
|
||||
return true;
|
||||
}
|
||||
this->Missile = MissileTypeByIdent(this->Name);
|
||||
return this->Missile != NULL;
|
||||
return this->Missile != nullptr;
|
||||
}
|
||||
|
||||
bool MissileConfig::MapMissile()
|
||||
|
|
|
@ -70,7 +70,7 @@ static const char *MissileClassNames[] = {
|
|||
"missile-class-clip-to-target",
|
||||
"missile-class-continious",
|
||||
"missile-class-straight-fly",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -246,11 +246,11 @@ static int CclDefineMissileType(lua_State *l)
|
|||
*/
|
||||
static int CclMissile(lua_State *l)
|
||||
{
|
||||
MissileType *type = NULL;
|
||||
MissileType *type = nullptr;
|
||||
PixelPos position(-1, -1);
|
||||
PixelPos destination(-1, -1);
|
||||
PixelPos source(-1, -1);
|
||||
Missile *missile = NULL;
|
||||
Missile *missile = nullptr;
|
||||
|
||||
DebugPrint("FIXME: not finished\n");
|
||||
|
||||
|
@ -399,14 +399,14 @@ static int CclCreateMissile(lua_State *l)
|
|||
const int destUnitId = LuaToNumber(l, 5);
|
||||
const bool dealDamage = LuaToBoolean(l, 6);
|
||||
const bool mapRelative = arg == 7 ? LuaToBoolean(l, 7) : false;
|
||||
CUnit *sourceUnit = sourceUnitId != -1 ? &UnitManager->GetSlotUnit(sourceUnitId) : NULL;
|
||||
CUnit *destUnit = destUnitId != -1 ? &UnitManager->GetSlotUnit(destUnitId) : NULL;
|
||||
CUnit *sourceUnit = sourceUnitId != -1 ? &UnitManager->GetSlotUnit(sourceUnitId) : nullptr;
|
||||
CUnit *destUnit = destUnitId != -1 ? &UnitManager->GetSlotUnit(destUnitId) : nullptr;
|
||||
|
||||
if (mapRelative == false) {
|
||||
if (sourceUnit != NULL) {
|
||||
if (sourceUnit != nullptr) {
|
||||
startpos += sourceUnit->GetMapPixelPosTopLeft();
|
||||
}
|
||||
if (destUnit != NULL) {
|
||||
if (destUnit != nullptr) {
|
||||
endpos += destUnit->GetMapPixelPosTopLeft();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
void SendCommandStopUnit(CUnit &unit)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
||||
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||
CommandStopUnit(unit);
|
||||
} else {
|
||||
NetworkSendCommand(MessageCommandStop, unit, 0, 0, NoUnitP, 0, FlushCommands);
|
||||
|
@ -75,7 +75,7 @@ void SendCommandStopUnit(CUnit &unit)
|
|||
void SendCommandStandGround(CUnit &unit, int flush)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("defend", &unit, flush, -1, -1, &dest, NULL, -1);
|
||||
CommandLog("defend", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||
CommandDefend(unit, dest, flush);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("follow", &unit, flush, -1, -1, &dest, NULL, -1);
|
||||
CommandLog("follow", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||
CommandFollow(unit, dest, flush);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} 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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("board", &unit, flush, -1, -1, &dest, NULL, -1);
|
||||
CommandLog("board", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||
CommandBoard(unit, dest, flush);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("explore", &unit, flush, -1, -1, NoUnitP, NULL, -1);
|
||||
CommandLog("explore", &unit, flush, -1, -1, NoUnitP, nullptr, -1);
|
||||
CommandExplore(unit, flush);
|
||||
} else {
|
||||
NetworkSendCommand(MessageCommandExplore, unit, 0, 0, NoUnitP, 0, flush);
|
||||
|
@ -297,10 +297,10 @@ void SendCommandDismiss(CUnit &unit)
|
|||
{
|
||||
// FIXME: currently unit and worker are same?
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("dismiss", &unit, FlushCommands, -1, -1, NULL, NULL, -1);
|
||||
CommandLog("dismiss", &unit, FlushCommands, -1, -1, nullptr, nullptr, -1);
|
||||
CommandDismiss(unit);
|
||||
} 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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("resource", &unit, flush, -1, -1, &dest, NULL, -1);
|
||||
CommandLog("resource", &unit, flush, -1, -1, &dest, nullptr, -1);
|
||||
CommandResource(unit, dest, flush);
|
||||
} else {
|
||||
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.
|
||||
**
|
||||
** @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.
|
||||
*/
|
||||
void SendCommandReturnGoods(CUnit &unit, CUnit *goal, int flush)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("return", &unit, flush, -1, -1, goal, NULL, -1);
|
||||
CommandLog("return", &unit, flush, -1, -1, goal, nullptr, -1);
|
||||
CommandReturnGoods(unit, goal, flush);
|
||||
} else {
|
||||
NetworkSendCommand(MessageCommandReturn, unit, 0, 0, goal, 0, flush);
|
||||
|
@ -383,7 +383,7 @@ void SendCommandCancelTraining(CUnit &unit, int slot, const CUnitType *type)
|
|||
{
|
||||
if (IsReplayGame()) {
|
||||
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);
|
||||
} else {
|
||||
NetworkSendCommand(MessageCommandCancelTrain, unit, slot, 0, NoUnitP,
|
||||
|
@ -416,11 +416,11 @@ void SendCommandUpgradeTo(CUnit &unit, CUnitType &what, int flush)
|
|||
void SendCommandCancelUpgradeTo(CUnit &unit)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (IsReplayGame()) {
|
||||
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
||||
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||
CommandCancelResearch(unit);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
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;
|
||||
|
||||
case MessageCommandStop:
|
||||
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
||||
CommandLog("stop", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||
CommandStopUnit(unit);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
case MessageCommandDefend: {
|
||||
if (dstnr != (unsigned short)0xFFFF) {
|
||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
@ -621,13 +621,13 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
|||
if (dstnr != (unsigned short)0xFFFF) {
|
||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
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);
|
||||
break;
|
||||
case MessageCommandRepair: {
|
||||
|
@ -636,12 +636,12 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
|||
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
break;
|
||||
case MessageCommandAttack: {
|
||||
|
@ -650,34 +650,34 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
|||
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
case MessageCommandBoard: {
|
||||
if (dstnr != (unsigned short)0xFFFF) {
|
||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageCommandUnload: {
|
||||
CUnit *dest = NULL;
|
||||
CUnit *dest = nullptr;
|
||||
if (dstnr != (unsigned short)0xFFFF) {
|
||||
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
@ -686,29 +686,29 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
|||
CommandBuildBuilding(unit, pos, *UnitTypes[dstnr], status);
|
||||
break;
|
||||
case MessageCommandExplore:
|
||||
CommandLog("explore", &unit, status, -1, -1, NoUnitP, NULL, -1);
|
||||
CommandLog("explore", &unit, status, -1, -1, NoUnitP, nullptr, -1);
|
||||
CommandExplore(unit, status);
|
||||
break;
|
||||
case MessageCommandDismiss:
|
||||
CommandLog("dismiss", &unit, FlushCommands, -1, -1, NULL, NULL, -1);
|
||||
CommandLog("dismiss", &unit, FlushCommands, -1, -1, nullptr, nullptr, -1);
|
||||
CommandDismiss(unit);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
case MessageCommandResource: {
|
||||
if (dstnr != (unsigned short)0xFFFF) {
|
||||
CUnit &dest = UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageCommandReturn: {
|
||||
CUnit *dest = (dstnr != (unsigned short)0xFFFF) ? &UnitManager->GetSlotUnit(dstnr) : NULL;
|
||||
CommandLog("return", &unit, status, -1, -1, dest, NULL, -1);
|
||||
CUnit *dest = (dstnr != (unsigned short)0xFFFF) ? &UnitManager->GetSlotUnit(dstnr) : nullptr;
|
||||
CommandLog("return", &unit, status, -1, -1, dest, nullptr, -1);
|
||||
CommandReturnGoods(unit, dest, status);
|
||||
break;
|
||||
}
|
||||
|
@ -723,8 +723,8 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
|||
UnitTypes[dstnr]->Ident.c_str(), (short)x);
|
||||
CommandCancelTraining(unit, (short)x, UnitTypes[dstnr]);
|
||||
} else {
|
||||
CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP, NULL, (short)x);
|
||||
CommandCancelTraining(unit, (short)x, NULL);
|
||||
CommandLog("cancel-train", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, (short)x);
|
||||
CommandCancelTraining(unit, (short)x, nullptr);
|
||||
}
|
||||
break;
|
||||
case MessageCommandUpgrade:
|
||||
|
@ -733,7 +733,7 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
|||
CommandUpgradeTo(unit, *UnitTypes[dstnr], status);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
case MessageCommandResearch:
|
||||
|
@ -742,21 +742,21 @@ void ExecCommand(unsigned char msgnr, UnitRef unum,
|
|||
CommandResearch(unit, *AllUpgrades[arg1], status);
|
||||
break;
|
||||
case MessageCommandCancelResearch:
|
||||
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
||||
CommandLog("cancel-research", &unit, FlushCommands, -1, -1, NoUnitP, nullptr, -1);
|
||||
CommandCancelResearch(unit);
|
||||
break;
|
||||
default: {
|
||||
int id = (msgnr & 0x7f) - MessageCommandSpellCast;
|
||||
if (arg2 != (unsigned short)0xFFFF) {
|
||||
CUnit *dest = NULL;
|
||||
CUnit *dest = nullptr;
|
||||
if (dstnr != (unsigned short)0xFFFF) {
|
||||
dest = &UnitManager->GetSlotUnit(dstnr);
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
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,
|
||||
offeredService.c_str(), offeredService.size(),
|
||||
hostname.c_str(), hostname.size(),
|
||||
ips[i], NULL, CNetworkParameter::Instance.localPort,
|
||||
NULL, 0);
|
||||
ips[i], nullptr, CNetworkParameter::Instance.localPort,
|
||||
nullptr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void MDNS::AnswerServerQueries() {
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -242,15 +242,15 @@ std::string NetGetHostname()
|
|||
int NetSocketAddr(unsigned long *ips, int maxAddr)
|
||||
{
|
||||
int idx = 0;
|
||||
PIP_ADAPTER_ADDRESSES pFirstAddresses, pAddresses = NULL;
|
||||
PIP_ADAPTER_ADDRESSES pFirstAddresses, pAddresses = nullptr;
|
||||
ULONG outBufLen = 0;
|
||||
GetAdaptersAddresses(AF_INET,
|
||||
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);
|
||||
if (GetAdaptersAddresses(AF_INET,
|
||||
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;
|
||||
for (pAddresses; pAddresses; pAddresses = pAddresses->Next) {
|
||||
if (idx == maxAddr) break;
|
||||
|
@ -269,12 +269,12 @@ int NetSocketAddr(unsigned long *ips, int maxAddr)
|
|||
#elif defined(USE_LINUX) || defined(USE_MAC)
|
||||
int NetSocketAddr(unsigned long *ips, int maxAddr)
|
||||
{
|
||||
struct ifaddrs *ifAddrStruct = NULL;
|
||||
struct ifaddrs *ifa = NULL;
|
||||
void *tmpAddrPtr = NULL;
|
||||
struct ifaddrs *ifAddrStruct = nullptr;
|
||||
struct ifaddrs *ifa = nullptr;
|
||||
void *tmpAddrPtr = nullptr;
|
||||
int idx = 0;
|
||||
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 (!ifa->ifa_addr) 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;
|
||||
ips[idx++] = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
|
||||
}
|
||||
if (ifAddrStruct != NULL) {
|
||||
if (ifAddrStruct != nullptr) {
|
||||
freeifaddrs(ifAddrStruct);
|
||||
}
|
||||
return idx;
|
||||
|
@ -435,7 +435,7 @@ int NetSocketReady(Socket sockfd, int timeout)
|
|||
tv.tv_usec = (timeout % 1000) * 1000;
|
||||
|
||||
// Data available?
|
||||
retval = select(sockfd + 1, &mask, NULL, NULL, &tv);
|
||||
retval = select(sockfd + 1, &mask, nullptr, nullptr, &tv);
|
||||
#ifdef USE_WINSOCK
|
||||
} while (retval == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
|
||||
#else
|
||||
|
@ -471,7 +471,7 @@ int SocketSet::Select(int timeout)
|
|||
tv.tv_usec = (timeout % 1000) * 1000;
|
||||
|
||||
// Data available?
|
||||
retval = select(this->MaxSockFD + 1, &mask, NULL, NULL, &tv);
|
||||
retval = select(this->MaxSockFD + 1, &mask, nullptr, nullptr, &tv);
|
||||
#ifdef USE_WINSOCK
|
||||
} while (retval == SOCKET_ERROR && WSAGetLastError() == WSAEINTR);
|
||||
#else
|
||||
|
|
|
@ -727,7 +727,7 @@ size_t CNetworkChat::Deserialize(const unsigned char *buf)
|
|||
size_t CNetworkChat::Size() const
|
||||
{
|
||||
size_t size = 0;
|
||||
size += serialize(NULL, this->Text);
|
||||
size += serialize(nullptr, this->Text);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -816,7 +816,7 @@ size_t CNetworkSelection::Size() const
|
|||
|
||||
size_t CNetworkPacketHeader::Serialize(unsigned char *p) const
|
||||
{
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
for (int i = 0; i != MaxNetworkCommands; ++i) {
|
||||
p += serialize8(p, this->Type[i]);
|
||||
}
|
||||
|
@ -870,9 +870,9 @@ size_t CNetworkPacket::Size(int numcommands) const
|
|||
{
|
||||
size_t size = 0;
|
||||
|
||||
size += this->Header.Serialize(NULL);
|
||||
size += this->Header.Serialize(nullptr);
|
||||
for (int i = 0; i != numcommands; ++i) {
|
||||
size += serialize(NULL, this->Command[i]);
|
||||
size += serialize(nullptr, this->Command[i]);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ void InitNetwork1()
|
|||
|
||||
// Our communication port
|
||||
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);
|
||||
NetworkFildes.Open(host);
|
||||
if (NetworkFildes.IsValid() == false) {
|
||||
|
@ -749,7 +749,7 @@ static bool IsAValidCommand_Command(const CNetworkPacket &packet, int index, con
|
|||
CNetworkCommand nc;
|
||||
nc.Deserialize(&packet.Command[index][0]);
|
||||
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
|
||||
|| 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;
|
||||
nc.Deserialize(&packet.Command[index][0]);
|
||||
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) {
|
||||
return true;
|
||||
|
@ -1004,7 +1004,7 @@ static void NetworkExecCommand_Quit(const CNetworkCommandQueue &ncq)
|
|||
|
||||
nc.Deserialize(&ncq.Data[0]);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue