summaryrefslogtreecommitdiffhomepage
path: root/Stars45/SimEvent.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/SimEvent.cpp
parent8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff)
downloadstarshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2
Moved Stars45 to StarsEx
Diffstat (limited to 'Stars45/SimEvent.cpp')
-rw-r--r--Stars45/SimEvent.cpp261
1 files changed, 0 insertions, 261 deletions
diff --git a/Stars45/SimEvent.cpp b/Stars45/SimEvent.cpp
deleted file mode 100644
index 4fad773..0000000
--- a/Stars45/SimEvent.cpp
+++ /dev/null
@@ -1,261 +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
- ========
- Simulation Events for mission summary
-*/
-
-#include "SimEvent.h"
-#include "Sim.h"
-#include "Clock.h"
-#include "ContentBundle.h"
-
-// +====================================================================+
-
-List<ShipStats> records;
-
-// +====================================================================+
-
-SimEvent::SimEvent(int e, const char* t, const char* i)
-: event(e), count(0)
-{
- Sim* sim = Sim::GetSim();
- if (sim) {
- time = (int) sim->MissionClock();
- }
- else {
- time = (int) (Clock::GetInstance()->GameTime()/1000);
- }
-
- SetTarget(t);
- SetInfo(i);
-}
-
-SimEvent::~SimEvent()
-{
-}
-
-// +--------------------------------------------------------------------+
-
-void
-SimEvent::SetTime(int t)
-{
- time = t;
-}
-
-void
-SimEvent::SetTarget(const char* t)
-{
- if (t && t[0])
- target = t;
-}
-
-void
-SimEvent::SetInfo(const char* i)
-{
- if (i && i[0])
- info = i;
-}
-
-void
-SimEvent::SetCount(int c)
-{
- count = c;
-}
-
-Text
-SimEvent::GetEventDesc() const
-{
- switch (event) {
- case LAUNCH: return ContentBundle::GetInstance()->GetText("sim.event.Launch");
- case DOCK: return ContentBundle::GetInstance()->GetText("sim.event.Dock");
- case LAND: return ContentBundle::GetInstance()->GetText("sim.event.Land");
- case EJECT: return ContentBundle::GetInstance()->GetText("sim.event.Eject");
- case CRASH: return ContentBundle::GetInstance()->GetText("sim.event.Crash");
- case COLLIDE: return ContentBundle::GetInstance()->GetText("sim.event.Collision With");
- case DESTROYED: return ContentBundle::GetInstance()->GetText("sim.event.Destroyed By");
- case MAKE_ORBIT: return ContentBundle::GetInstance()->GetText("sim.event.Make Orbit");
- case BREAK_ORBIT: return ContentBundle::GetInstance()->GetText("sim.event.Break Orbit");
- case QUANTUM_JUMP: return ContentBundle::GetInstance()->GetText("sim.event.Quantum Jump");
- case LAUNCH_SHIP: return ContentBundle::GetInstance()->GetText("sim.event.Launch Ship");
- case RECOVER_SHIP: return ContentBundle::GetInstance()->GetText("sim.event.Recover Ship");
- case FIRE_GUNS: return ContentBundle::GetInstance()->GetText("sim.event.Fire Guns");
- case FIRE_MISSILE: return ContentBundle::GetInstance()->GetText("sim.event.Fire Missile");
- case DROP_DECOY: return ContentBundle::GetInstance()->GetText("sim.event.Drop Decoy");
- case GUNS_KILL: return ContentBundle::GetInstance()->GetText("sim.event.Guns Kill");
- case MISSILE_KILL: return ContentBundle::GetInstance()->GetText("sim.event.Missile Kill");
- case LAUNCH_PROBE: return ContentBundle::GetInstance()->GetText("sim.event.Launch Probe");
- case SCAN_TARGET: return ContentBundle::GetInstance()->GetText("sim.event.Scan Target");
- default: return ContentBundle::GetInstance()->GetText("sim.event.no event");
- }
-}
-
-// +====================================================================+
-
-ShipStats::ShipStats(const char* n, int i)
-: name(n), iff(i), kill1(0), kill2(0), lost(0), coll(0), points(0),
-cmd_points(0), gun_shots(0), gun_hits(0), missile_shots(0), missile_hits(0),
-combat_group(0), combat_unit(0), player(false), ship_class(0), elem_index(-1)
-{
- if (!n || !n[0])
- name = ContentBundle::GetInstance()->GetText("[unknown]");
-}
-
-ShipStats::~ShipStats()
-{
- events.destroy();
-}
-
-// +--------------------------------------------------------------------+
-
-void
-ShipStats::SetType(const char* t)
-{
- if (t && t[0])
- type = t;
-}
-
-void
-ShipStats::SetRole(const char* r)
-{
- if (r && r[0])
- role = r;
-}
-
-void
-ShipStats::SetRegion(const char* r)
-{
- if (r && r[0])
- region = r;
-}
-
-void
-ShipStats::SetCombatGroup(CombatGroup* g)
-{
- combat_group = g;
-}
-
-void
-ShipStats::SetCombatUnit(CombatUnit* u)
-{
- combat_unit = u;
-}
-
-void
-ShipStats::SetElementIndex(int n)
-{
- elem_index = n;
-}
-
-void
-ShipStats::SetPlayer(bool p)
-{
- player = p;
-}
-
-// +--------------------------------------------------------------------+
-
-void
-ShipStats::Summarize()
-{
- kill1 = 0;
- kill2 = 0;
- lost = 0;
- coll = 0;
-
- ListIter<SimEvent> iter = events;
- while (++iter) {
- SimEvent* event = iter.value();
- int code = event->GetEvent();
-
- if (code == SimEvent::GUNS_KILL)
- kill1++;
-
- else if (code == SimEvent::MISSILE_KILL)
- kill2++;
-
- else if (code == SimEvent::DESTROYED)
- lost++;
-
- else if (code == SimEvent::CRASH)
- coll++;
-
- else if (code == SimEvent::COLLIDE)
- coll++;
- }
-}
-
-// +--------------------------------------------------------------------+
-
-SimEvent*
-ShipStats::AddEvent(SimEvent* e)
-{
- events.append(e);
- return e;
-}
-
-SimEvent*
-ShipStats::AddEvent(int event, const char* tgt, const char* info)
-{
- SimEvent* e = new SimEvent(event, tgt, info);
- events.append(e);
- return e;
-}
-
-bool
-ShipStats::HasEvent(int event)
-{
- for (int i = 0; i < events.size(); i++)
- if (events[i]->GetEvent() == event)
- return true;
-
- return false;
-}
-
-// +--------------------------------------------------------------------+
-
-void ShipStats::Initialize() { records.destroy(); }
-void ShipStats::Close() { records.destroy(); }
-
-// +--------------------------------------------------------------------+
-
-int
-ShipStats::NumStats()
-{
- return records.size();
-}
-
-ShipStats*
-ShipStats::GetStats(int i)
-{
- if (i >= 0 && i < records.size())
- return records.at(i);
-
- return 0;
-}
-
-ShipStats*
-ShipStats::Find(const char* name)
-{
- if (name && name[0]) {
- ListIter<ShipStats> iter = records;
- while (++iter) {
- ShipStats* stats = iter.value();
- if (!strcmp(stats->GetName(), name))
- return stats;
- }
-
- ShipStats* stats = new ShipStats(name);
- records.append(stats);
- return stats;
- }
-
- return 0;
-}
-