Rise
The Vieneo Province
Bus.cpp
Go to the documentation of this file.
1 #include "Bus.h"
2 
3 void Bus::AddCommand(Command command, bool onlyOne)
4 {
5  if (onlyOne)
6  for (auto& i : commandStream)
7  if (i.name == command.name)
8  return;
9 
10  commandStream.emplace_back(command);
11 
12  // if command has priority then sort!
13 }
14 
15 void Bus::FrameMove(float fElapsed)
16 {
17  logger->AddToCallStack("Bus::FrameMove");
18 
19  for (UINT i = 0; i < commandStream.size(); i++)
20  {
21  Command* command = &commandStream.at(i);
22  command->delay -= fElapsed;
23  if (command->delay <= 0)
24  {
25  command->timeOnStack += fElapsed;
26  if (command->timeOnStack > command->ttl)
27  {
28  char msg[199];
29  sprintf_s(msg, 199, "Bus::FrameMove Command sat on the stack for too long (%.1fs): %s", command->ttl, command->name.c_str());
30  logger->Log(msg, Logger::Warn);
31  commandStream.erase(commandStream.begin() + i);
32  break;
33  }
34 
35  if (command->name == "ScanCargoBay")
36  {
37  Scanner.CurrentScanTarget = command->ivalues[0];
38  commandStream.erase(commandStream.begin() + i);
39  break;
40  }
41  }
42  }
43 
44  logger->AddToCallStack("Bus::FrameMove DONE");
45 }
46 
47 Bus::Bus(Logger* prmLogger)
48 {
49  GetSystemTime(&Time);
50  DebugString[0] = 0;
51 
52  logger = prmLogger;
53  ZeroMemory(CargoBays, sizeof CargoBays);
55  WPtargetC = 0L; // current selected, comes from server now
56  for (int i = 0; i < MAX_ENGINES; i++)
57  {
58  EngineThrustOutput[i] = 0.0f;
59  EngineThrustLever[i] = 0.0f;
60  ThrustReverserCommand[i] = false;
61  }
62  ZeroMemory(&assayGrid, sizeof SAssayGrid);
63 }
#define MAX_ENGINES
Definition: Bus.h:14
float timeOnStack
Definition: Command.h:14
int ivalues[2]
Definition: Command.h:21
std::vector< Command > commandStream
Definition: Bus.h:342
Definition: Logger.h:9
char DebugString[MAX_PATH]
Definition: Bus.h:419
Definition: scanDb.h:53
Bus(Logger *prmLogger)
Definition: Bus.cpp:47
void AddCommand(Command command, bool onlyOne)
Definition: Bus.cpp:3
std::string name
Definition: Command.h:11
bool ThrustReverserCommand[MAX_ENGINES]
Definition: Bus.h:61
float ttl
Definition: Command.h:17
float EngineThrustOutput[MAX_ENGINES]
Definition: Bus.h:43
Definition: Command.h:5
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition: Logger.cpp:11
unsigned short CargoBays[MAX_PODSPERSHIP]
Definition: Bus.h:365
void FrameMove(float fElapsed)
Definition: Bus.cpp:15
float delay
Definition: Command.h:8
int WPtargetC
Definition: Bus.h:390
void AddToCallStack(const char *msg)
Definition: Logger.cpp:86
_SYSTEMTIME Time
(1) Time (UTC when available, otherwise elapsed time)
Definition: Bus.h:23
SAssayGrid assayGrid
Definition: Bus.h:385
Logger * logger
Definition: Bus.h:18
float EngineThrustLever[MAX_ENGINES]
Definition: Bus.h:264