Puste:
Also sorry nein, ich committe das hier nicht, und zwar weil ich das Bugpotential für zu groß halte. Das ist eigentlich eine Refaktorierung, und man sollte irgendwann wenn ein release naht sich auf möglichst wenig invasive commits beschränken. Ich fühl mich für bugs die durch meine commits verursacht werden verantwortlich und mach das - zumindest momentan - nicht.
Es ist besser, ein paar kleine bugs zu akzeptieren, anstatt erneut wieder viel rumzumachen, sonst kommt man nie zu Potte. Wodurch dann auch die bisherige großartige Leistung unserer Tester wieder relativ nutzlos würde.
Hier das patch...ich glaube die Midways bombardieren da aber gar nicht mehr...
Code: Alles auswählen
From 1b228863455fb1b16ecb30bbb9396f02d1339bf5 Mon Sep 17 00:00:00 2001
From: unknown <_@a.(none)>
Date: Thu, 31 Jan 2013 02:57:16 +0100
Subject: [PATCH] refactor neccessary unsetting of targets because of setting
orders
---
Source/GUI/GalaxyMenuView.cpp | 4 ----
Source/GUI/ShipBottomView.cpp | 16 ++++++++--------
Source/Gamedata/AI/ShipAI.cpp | 3 ---
Source/Gamedata/Ships/Ship.cpp | 18 ++++++++++++------
Source/Gamedata/Ships/Ship.h | 3 ++-
Source/Gamedata/Ships/Ships.cpp | 8 +++++---
Source/Gamedata/Ships/Ships.h | 3 ++-
7 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/Source/GUI/GalaxyMenuView.cpp b/Source/GUI/GalaxyMenuView.cpp
index 2eda9e5..e98d16f 100644
--- a/Source/GUI/GalaxyMenuView.cpp
+++ b/Source/GUI/GalaxyMenuView.cpp
@@ -1324,10 +1324,6 @@ void CGalaxyMenuView::SearchNextIdleShipAndJumpToIt(CBotf2Doc* pDoc, SHIP_ORDER:
if(previous_ship != pDoc->m_ShipMap.end() && order != SHIP_ORDER::NONE) {
previous_ship->second->SetCurrentOrder(order);
assert(order == SHIP_ORDER::WAIT_SHIP_ORDER || order == SHIP_ORDER::SENTRY_SHIP_ORDER);
- //In case the previous ship was selected via mouse instead via hotkey, which
- //checks whether there's a target != -1,-1 set, it can be a ship which still
- //has a valid target, but still would get order sentry or wait
- previous_ship->second->SetTargetKO(CPoint(-1, -1), true);
}
m_PreviouslyJumpedToShip = RememberedShip(i->second->GetShipName(), i->second->Key());
m_pPlayersRace->GetStarmap()->Select(sector);// sets orange rectangle in galaxy view
diff --git a/Source/GUI/ShipBottomView.cpp b/Source/GUI/ShipBottomView.cpp
index e77b537..1d1e8f4 100644
--- a/Source/GUI/ShipBottomView.cpp
+++ b/Source/GUI/ShipBottomView.cpp
@@ -932,13 +932,6 @@ void CShipBottomView::OnLButtonDown(UINT nFlags, CPoint point)
if (i->rect.PtInRect(point))
{
SHIP_ORDER::Typ nOrder = static_cast<SHIP_ORDER::Typ>(i - m_vSecondaryShipOrders.begin());
- // Bei manchen Befehlen müssen wir einen möglichen Zielkurs wieder zurücknehmen.
- if (nOrder != SHIP_ORDER::NONE && nOrder != SHIP_ORDER::AVOID && nOrder != SHIP_ORDER::ATTACK && nOrder != SHIP_ORDER::ENCLOAK && nOrder != SHIP_ORDER::DECLOAK && nOrder != SHIP_ORDER::ASSIGN_FLAGSHIP && nOrder != SHIP_ORDER::CREATE_FLEET && nOrder != SHIP_ORDER::TRANSPORT)
- {
- pDoc->CurrentShip()->second->SetTargetKO(CPoint(-1, -1));
- resources::pMainFrame->InvalidateView(RUNTIME_CLASS(CGalaxyMenuView));
- }
-
// Wenn wir eine Flotte bilden wollen (Schiffe gruppieren), dann in der MainView die Flottenansicht zeigen
if (nOrder == SHIP_ORDER::CREATE_FLEET)
{
@@ -966,11 +959,15 @@ void CShipBottomView::OnLButtonDown(UINT nFlags, CPoint point)
resources::pMainFrame->InvalidateView(RUNTIME_CLASS(CTransportMenuView));
}
else if (nOrder == SHIP_ORDER::TERRAFORM) {
+ resources::pMainFrame->InvalidateView(RUNTIME_CLASS(CGalaxyMenuView));
+ pDoc->CurrentShip()->second->SetTargetKO(CPoint(-1, -1));
//command is given when clicked on planet
}
else if (nOrder == SHIP_ORDER::CANCEL) {
pDoc->CurrentShip()->second->UnsetCurrentOrder();
pDoc->CurrentShip()->second->SetIsShipFlagShip(false);
+ pDoc->CurrentShip()->second->SetTargetKO(CPoint(-1, -1));
+ resources::pMainFrame->InvalidateView(RUNTIME_CLASS(CGalaxyMenuView));
}
else if (nOrder == SHIP_ORDER::ATTACK)
pDoc->CurrentShip()->second->SetCombatTactic(COMBAT_TACTIC::CT_ATTACK);
@@ -978,7 +975,10 @@ void CShipBottomView::OnLButtonDown(UINT nFlags, CPoint point)
pDoc->CurrentShip()->second->SetCombatTactic(COMBAT_TACTIC::CT_AVOID);
// ansonsten ganz normal den Befehl geben
else
- pDoc->CurrentShip()->second->SetCurrentOrder(nOrder);
+ // Bei manchen Befehlen müssen wir einen möglichen Zielkurs wieder zurücknehmen.
+ //done in SetCurrentOrder()
+ if(pDoc->CurrentShip()->second->SetCurrentOrder(nOrder))
+ resources::pMainFrame->InvalidateView(RUNTIME_CLASS(CGalaxyMenuView));
// bei Terraforming wird die Planetenansicht eingeblendet
if (nOrder == SHIP_ORDER::TERRAFORM)
{
diff --git a/Source/Gamedata/AI/ShipAI.cpp b/Source/Gamedata/AI/ShipAI.cpp
index 890230c..2f3fc6f 100644
--- a/Source/Gamedata/AI/ShipAI.cpp
+++ b/Source/Gamedata/AI/ShipAI.cpp
@@ -324,8 +324,6 @@ bool CShipAI::DoColonize(CShips* pShip)
{
if (pSector->GetPlanet(i)->GetTerraformed() && !pSector->GetPlanet(i)->GetColonized())
{
- // Hier muss als erstes ein möglicher neuer Kurs gelöscht werden
- pShip->SetTargetKO(CPoint(-1, -1));
pShip->SetCurrentOrder(SHIP_ORDER::COLONIZE);
return true;
}
@@ -596,7 +594,6 @@ bool CShipAI::DoStationBuild(CShips* pShip)
// Nur wenn der Sektor uns bzw. niemanden gehört
if (m_pDoc->GetSector(ptKO.x, ptKO.y).GetOwnerOfSector() == "" || m_pDoc->GetSector(ptKO.x, ptKO.y).GetOwnerOfSector() == sRace)
{
- pShip->SetTargetKO(CPoint(-1, -1));
pShip->SetCurrentOrder(SHIP_ORDER::BUILD_OUTPOST);
return true;
}
diff --git a/Source/Gamedata/Ships/Ship.cpp b/Source/Gamedata/Ships/Ship.cpp
index 0954513..4e19304 100644
--- a/Source/Gamedata/Ships/Ship.cpp
+++ b/Source/Gamedata/Ships/Ship.cpp
@@ -507,9 +507,9 @@ F
SetCrewExperiance(expAdd);
}
-//when setting a ship target, some running orders need to be unset if they're active
+//when setting a ship target (respectively order), some orders (resp. the target) need to be unset
//this function calculates whether that's needed
-static bool ShouldUnsetOrder(SHIP_ORDER::Typ order) {
+static bool TargetCompatible(SHIP_ORDER::Typ order) {
switch(order) {
case SHIP_ORDER::ATTACK_SYSTEM:
case SHIP_ORDER::BLOCKADE_SYSTEM:
@@ -522,9 +522,9 @@ static bool ShouldUnsetOrder(SHIP_ORDER::Typ order) {
case SHIP_ORDER::SENTRY_SHIP_ORDER:
case SHIP_ORDER::REPAIR:
case SHIP_ORDER::IMPROVE_SHIELDS:
- return true;
+ return false;
}
- return false;
+ return true;
}
void CShip::SetTargetKO(const CPoint& TargetKO, const bool simple_setter)
@@ -536,7 +536,7 @@ void CShip::SetTargetKO(const CPoint& TargetKO, const bool simple_setter)
if(simple_setter)
return;
- if(TargetKO != CPoint(-1, -1) && ShouldUnsetOrder(m_iCurrentOrder)) {
+ if(TargetKO != CPoint(-1, -1) && !TargetCompatible(m_iCurrentOrder)) {
SetTerraform(-1);
UnsetCurrentOrder();
}
@@ -547,7 +547,7 @@ void CShip::SetCurrentOrderAccordingToType() {
SetCombatTacticAccordingToType();
}
-void CShip::SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder) {
+bool CShip::SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder) {
assert(nCurrentOrder != SHIP_ORDER::TERRAFORM
&& nCurrentOrder != SHIP_ORDER::ATTACK
&& nCurrentOrder != SHIP_ORDER::AVOID
@@ -555,6 +555,12 @@ void CShip::SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder) {
if(m_iCurrentOrder == SHIP_ORDER::TERRAFORM)
SetTerraform(-1);
m_iCurrentOrder = nCurrentOrder;
+ if(HasTarget() && !TargetCompatible(nCurrentOrder))
+ {
+ SetTargetKO(CPoint(-1, -1));
+ return true;
+ }
+ return false;
}
void CShip::SetCombatTacticAccordingToType() {
diff --git a/Source/Gamedata/Ships/Ship.h b/Source/Gamedata/Ships/Ship.h
index 5a2a1d6..2b3b511 100644
--- a/Source/Gamedata/Ships/Ship.h
+++ b/Source/Gamedata/Ships/Ship.h
@@ -138,7 +138,8 @@ public:
void SetLoadedResources(USHORT add, BYTE res) {m_iLoadedResources[res] += add;}
void SetColonizePoints(BYTE ColonizePoints) {m_iColonizePoints = ColonizePoints;}
void SetStationBuildPoints(BYTE StationBuildPoints) {m_iStationBuildPoints = StationBuildPoints;}
- void SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder);
+ //@return was a target unset because of this
+ bool SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder);
void SetSpecial(int n, SHIP_SPECIAL::Typ nAbility) {m_nSpecial[n] = nAbility;}
void SetTerraform(short planetNumber = -1);
void SetShipName(const CString& ShipName) {m_strShipName = ShipName;}
diff --git a/Source/Gamedata/Ships/Ships.cpp b/Source/Gamedata/Ships/Ships.cpp
index 6ac193a..f45f943 100644
--- a/Source/Gamedata/Ships/Ships.cpp
+++ b/Source/Gamedata/Ships/Ships.cpp
@@ -289,10 +289,12 @@ void CShips::SetTerraform(short planetNumber) {
i->second->SetTerraform(planetNumber);
}
-void CShips::SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder) {
- m_Leader.SetCurrentOrder(nCurrentOrder);
+bool CShips::SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder) {
+ bool result = m_Leader.SetCurrentOrder(nCurrentOrder);
for(CShips::iterator i = begin(); i != end(); ++i)
- i->second->SetCurrentOrder(nCurrentOrder);
+ if(i->second->SetCurrentOrder(nCurrentOrder))
+ result = true;
+ return result;
}
void CShips::SetCurrentOrderAccordingToType() {
diff --git a/Source/Gamedata/Ships/Ships.h b/Source/Gamedata/Ships/Ships.h
index 9c6365c..0675008 100644
--- a/Source/Gamedata/Ships/Ships.h
+++ b/Source/Gamedata/Ships/Ships.h
@@ -200,7 +200,8 @@ public:
void SetLoadedResources(USHORT add, BYTE res) { m_Leader.SetLoadedResources(add, res); }
void SetColonizePoints(BYTE ColonizePoints) { m_Leader.SetColonizePoints(ColonizePoints); }
void SetStationBuildPoints(BYTE StationBuildPoints) { m_Leader.SetStationBuildPoints(StationBuildPoints); }
- void SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder);
+ //@return was a target unset because of this
+ bool SetCurrentOrder(SHIP_ORDER::Typ nCurrentOrder);
void SetSpecial(int n, SHIP_SPECIAL::Typ nAbility) { m_Leader.SetSpecial(n, nAbility); }
void SetTerraform(short planetNumber = -1);
void SetShipName(const CString& ShipName) { m_Leader.SetShipName(ShipName); }
--
1.7.10.msysgit.1