summaryrefslogtreecommitdiffhomepage
path: root/Stars45/CampaignPlanAssignment.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-01 21:23:39 +0200
committerAki <please@ignore.pl>2022-04-01 21:23:39 +0200
commit3c487c5cd69c53d6fea948643c0a76df03516605 (patch)
tree72730c7b8b26a5ef8fc9a987ec4c16129efd5aac /Stars45/CampaignPlanAssignment.cpp
parent8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff)
downloadstarshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2
Moved Stars45 to StarsEx
Diffstat (limited to 'Stars45/CampaignPlanAssignment.cpp')
-rw-r--r--Stars45/CampaignPlanAssignment.cpp156
1 files changed, 0 insertions, 156 deletions
diff --git a/Stars45/CampaignPlanAssignment.cpp b/Stars45/CampaignPlanAssignment.cpp
deleted file mode 100644
index c4381ed..0000000
--- a/Stars45/CampaignPlanAssignment.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Starshatter: The Open Source Project
- Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
- Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
- Copyright (c) 1997-2006, Destroyer Studios LLC.
-
- AUTHOR: John DiCamillo
-
-
- OVERVIEW
- ========
- CampaignPlanAssignment creates combat assignments for
- assets within each combat zone as the third step in
- force tasking.
-*/
-
-#include "CampaignPlanAssignment.h"
-#include "Campaign.h"
-#include "Combatant.h"
-#include "CombatAssignment.h"
-#include "CombatGroup.h"
-#include "CombatUnit.h"
-#include "CombatZone.h"
-#include "Mission.h"
-
-// +--------------------------------------------------------------------+
-
-void
-CampaignPlanAssignment::ExecFrame()
-{
- if (campaign && campaign->IsActive()) {
- // once every few minutes is plenty:
- if (Campaign::Stardate() - exec_time < 300)
- return;
-
- ListIter<Combatant> iter = campaign->GetCombatants();
- while (++iter) {
- ProcessCombatant(iter.value());
- }
-
- exec_time = Campaign::Stardate();
- }
-}
-
-// +--------------------------------------------------------------------+
-
-void
-CampaignPlanAssignment::ProcessCombatant(Combatant* c)
-{
- CombatGroup* force = c->GetForce();
- if (force) {
- force->CalcValue();
- force->ClearAssignments();
- }
-
- ListIter<CombatZone> zone = campaign->GetZones();
- while (++zone) {
- ProcessZone(c, zone.value());
- }
-}
-
-// +--------------------------------------------------------------------+
-
-void
-CampaignPlanAssignment::BuildZoneList(CombatGroup* g, CombatZone* zone, List<CombatGroup>& groups)
-{
- if (!g)
- return;
-
- if (g->GetAssignedZone() == zone)
- groups.append(g);
-
- ListIter<CombatGroup> iter = g->GetComponents();
- while (++iter)
- BuildZoneList(iter.value(), zone, groups);
-}
-
-// +--------------------------------------------------------------------+
-
-void
-CampaignPlanAssignment::BuildAssetList(const int* pref,
-List<CombatGroup>& groups,
-List<CombatGroup>& assets)
-{
- if (!pref)
- return;
-
- while (*pref) {
- ListIter<CombatGroup> g = groups;
- while (++g) {
- if (g->Type() == *pref && g->CountUnits() > 0)
- assets.append(g.value());
- }
-
- pref++;
- }
-}
-
-// +--------------------------------------------------------------------+
-
-void
-CampaignPlanAssignment::ProcessZone(Combatant* c, CombatZone* zone)
-{
- List<CombatGroup> groups;
- BuildZoneList(c->GetForce(), zone, groups);
-
- ZoneForce* force = zone->FindForce(c->GetIFF());
-
- // defensive assignments:
- ListIter<CombatGroup> def = force->GetDefendList();
- while (++def) {
- List<CombatGroup> assets;
- BuildAssetList(CombatGroup::PreferredDefender(def->Type()), groups, assets);
-
- ListIter<CombatGroup> g = assets;
- while (++g) {
- CombatAssignment* a = new
- CombatAssignment(Mission::DEFEND,
- def.value(),
- g.value());
-
- if (a)
- g->GetAssignments().append(a);
- }
- }
-
- // offensive assignments:
- ListIter<CombatGroup> tgt = force->GetTargetList();
- while (++tgt) {
- CombatGroup* target = tgt.value();
-
- List<CombatGroup> assets;
- BuildAssetList(CombatGroup::PreferredAttacker(tgt->Type()), groups, assets);
-
- ListIter<CombatGroup> g = assets;
- while (++g) {
- CombatGroup* asset = g.value();
- int mtype = Mission::ASSAULT;
-
- if (target->IsStrikeTarget())
- mtype = Mission::STRIKE;
-
- else if (target->IsFighterGroup())
- mtype = Mission::SWEEP;
-
- else if (target->Type() == CombatGroup::LCA_SQUADRON)
- mtype = Mission::INTERCEPT;
-
- CombatAssignment* a = new
- CombatAssignment(mtype, target, asset);
-
- if (a)
- g->GetAssignments().append(a);
- }
- }
-}
-