summaryrefslogtreecommitdiffhomepage
path: root/StarsEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-03-26 01:45:33 +0100
committerAki <please@ignore.pl>2024-03-26 01:49:16 +0100
commitea4c0557d0b7c2317e03d3d3aaefd6063c99f091 (patch)
treedad4634faf3c17f3642d736f62350df88c117a59 /StarsEx
parent38332f77dc1e7bb03776631101eff6e8ad8bcaef (diff)
downloadstarshatter-ea4c0557d0b7c2317e03d3d3aaefd6063c99f091.zip
starshatter-ea4c0557d0b7c2317e03d3d3aaefd6063c99f091.tar.gz
starshatter-ea4c0557d0b7c2317e03d3d3aaefd6063c99f091.tar.bz2
DWORD replaced with std::uint32_t in non-Win32-related parts
With the exception of some netcode. This brings some important questions and solidifies me in pursuing better abstract over definitions. It might also be a good idea to have distinct aliases or compound types for time and (net) identifiers.
Diffstat (limited to 'StarsEx')
-rw-r--r--StarsEx/CmpLoadDlg.h11
-rw-r--r--StarsEx/Contact.cpp6
-rw-r--r--StarsEx/Contact.h17
-rw-r--r--StarsEx/Element.cpp14
-rw-r--r--StarsEx/Element.h20
-rw-r--r--StarsEx/FighterAI.cpp4
-rw-r--r--StarsEx/FighterAI.h13
-rw-r--r--StarsEx/FighterTacticalAI.h18
-rw-r--r--StarsEx/Hangar.cpp26
-rw-r--r--StarsEx/Hangar.h21
-rw-r--r--StarsEx/NetChat.cpp2
-rw-r--r--StarsEx/NetChat.h13
-rw-r--r--StarsEx/NetLobbyServer.cpp27
-rw-r--r--StarsEx/NetLobbyServer.h17
-rw-r--r--StarsEx/NetPacket.cpp83
-rw-r--r--StarsEx/NetPacket.h28
-rw-r--r--StarsEx/NetPlayer.cpp46
-rw-r--r--StarsEx/NetPlayer.h28
-rw-r--r--StarsEx/NetUser.cpp4
-rw-r--r--StarsEx/NetUser.h19
-rw-r--r--StarsEx/NetUtil.cpp13
-rw-r--r--StarsEx/NetUtil.h9
-rw-r--r--StarsEx/ParseUtil.cpp72
-rw-r--r--StarsEx/ParseUtil.h15
-rw-r--r--StarsEx/ParseUtil.inl.h30
-rw-r--r--StarsEx/Player.cpp8
-rw-r--r--StarsEx/Player.h15
-rw-r--r--StarsEx/Ship.cpp155
-rw-r--r--StarsEx/Ship.h46
-rw-r--r--StarsEx/ShipAI.cpp36
-rw-r--r--StarsEx/ShipAI.h15
-rw-r--r--StarsEx/Sim.cpp109
-rw-r--r--StarsEx/Sim.h34
-rw-r--r--StarsEx/SimObject.cpp4
-rw-r--r--StarsEx/SimObject.h18
-rw-r--r--StarsEx/Starshatter.h14
-rw-r--r--StarsEx/StarshipAI.cpp6
-rw-r--r--StarsEx/StarshipAI.h16
-rw-r--r--StarsEx/StarshipTacticalAI.h14
-rw-r--r--StarsEx/SteerAI.h14
-rw-r--r--StarsEx/System.h21
-rw-r--r--StarsEx/Thruster.cpp32
-rw-r--r--StarsEx/Thruster.h19
-rw-r--r--StarsEx/Weapon.cpp30
-rw-r--r--StarsEx/Weapon.h18
-rw-r--r--StarsEx/WeaponDesign.cpp15
-rw-r--r--StarsEx/WeaponDesign.h18
-rw-r--r--StarsEx/WeaponGroup.cpp12
-rw-r--r--StarsEx/WeaponGroup.h16
49 files changed, 566 insertions, 675 deletions
diff --git a/StarsEx/CmpLoadDlg.h b/StarsEx/CmpLoadDlg.h
index 67fdba5..486f403 100644
--- a/StarsEx/CmpLoadDlg.h
+++ b/StarsEx/CmpLoadDlg.h
@@ -11,10 +11,10 @@
Campaign title card and load progress dialog
*/
-#ifndef CmpLoadDlg_h
-#define CmpLoadDlg_h
+#pragma once
+
+#include <cstdint>
-#include "Types.h"
#include "FormWindow.h"
// +--------------------------------------------------------------------+
@@ -38,8 +38,5 @@ protected:
Slider* lbl_progress;
ActiveWindow* lbl_title;
ImageBox* img_title;
- DWORD show_time;
+ std::uint32_t show_time;
};
-
-#endif // CmpLoadDlg_h
-
diff --git a/StarsEx/Contact.cpp b/StarsEx/Contact.cpp
index ab6e753..1369010 100644
--- a/StarsEx/Contact.cpp
+++ b/StarsEx/Contact.cpp
@@ -12,15 +12,15 @@
*/
#include "Contact.h"
+
+#include "Clock.h"
#include "Drone.h"
+#include "Game.h"
#include "Sensor.h"
#include "Ship.h"
#include "Sim.h"
#include "WeaponDesign.h"
-#include "Game.h"
-#include "Clock.h"
-
// +----------------------------------------------------------------------+
const int DEFAULT_TRACK_UPDATE = 500; // milliseconds
diff --git a/StarsEx/Contact.h b/StarsEx/Contact.h
index 66acb9c..dbc4ed6 100644
--- a/StarsEx/Contact.h
+++ b/StarsEx/Contact.h
@@ -11,10 +11,10 @@
Sensor Contact class
*/
-#ifndef Contact_h
-#define Contact_h
+#pragma once
+
+#include <cstdint>
-#include "Types.h"
#include "SimObject.h"
#include "System.h"
#include "Geometry.h"
@@ -49,7 +49,7 @@ public:
double Age() const;
bool IsProbed() const { return probe; }
- DWORD AcquisitionTime() const { return acquire_time; }
+ std::uint32_t AcquisitionTime() const { return acquire_time; }
int GetIFF(const Ship* observer) const;
void GetBearing(const Ship* observer, double& az, double& el, double& r) const;
@@ -74,17 +74,14 @@ private:
Ship* ship;
Shot* shot;
Point loc;
- DWORD acquire_time;
- DWORD time;
+ std::uint32_t acquire_time;
+ std::uint32_t time;
Point* track;
int ntrack;
- DWORD track_time;
+ std::uint32_t track_time;
float d_pas; // power output
float d_act; // mass, size
bool probe; // scanned by probe
};
-
-#endif // Contact_h
-
diff --git a/StarsEx/Element.cpp b/StarsEx/Element.cpp
index 23254d5..7479a35 100644
--- a/StarsEx/Element.cpp
+++ b/StarsEx/Element.cpp
@@ -12,14 +12,16 @@
*/
#include "Element.h"
+
+#include <cstdint>
+
+#include "Game.h"
#include "Instruction.h"
-#include "RadioMessage.h"
+#include "NetUtil.h"
#include "RadioHandler.h"
-#include "Sim.h"
+#include "RadioMessage.h"
#include "Ship.h"
-#include "NetUtil.h"
-
-#include "Game.h"
+#include "Sim.h"
// +----------------------------------------------------------------------+
@@ -280,7 +282,7 @@ Element::IsObjectiveTargetOf(const Ship* s) const
// +----------------------------------------------------------------------+
void
-Element::SetLaunchTime(DWORD t)
+Element::SetLaunchTime(std::uint32_t t)
{
if (launch_time == 0 || t == 0)
launch_time = t;
diff --git a/StarsEx/Element.h b/StarsEx/Element.h
index 8f188e4..cefe533 100644
--- a/StarsEx/Element.h
+++ b/StarsEx/Element.h
@@ -11,14 +11,15 @@
Package Element (e.g. Flight) class
*/
-#ifndef Element_h
-#define Element_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
+#include <Text.h>
-#include "Types.h"
#include "Geometry.h"
#include "SimObject.h"
-#include "List.h"
-#include "Text.h"
// +--------------------------------------------------------------------+
@@ -48,8 +49,8 @@ public:
virtual int GetIFF() const { return iff; }
int Player() const { return player; }
void SetPlayer(int p) { player = p; }
- DWORD GetLaunchTime() const { return launch_time; }
- void SetLaunchTime(DWORD t);
+ std::uint32_t GetLaunchTime() const { return launch_time; }
+ void SetLaunchTime(std::uint32_t t);
int IntelLevel() const { return intel; }
void SetIntelLevel(int i) { intel = i; }
@@ -158,7 +159,7 @@ protected:
CombatGroup* combat_group;
CombatUnit* combat_unit;
- DWORD launch_time;
+ std::uint32_t launch_time;
double hold_time;
bool rogue;
@@ -166,6 +167,3 @@ protected:
bool zone_lock;
int load[16];
};
-
-#endif // Element_h
-
diff --git a/StarsEx/FighterAI.cpp b/StarsEx/FighterAI.cpp
index cc010f2..d31fb30 100644
--- a/StarsEx/FighterAI.cpp
+++ b/StarsEx/FighterAI.cpp
@@ -12,6 +12,7 @@
*/
#include "FighterAI.h"
+
#include "FighterTacticalAI.h"
#include "Ship.h"
#include "Shot.h"
@@ -31,7 +32,6 @@
#include "StarSystem.h"
#include "RadioMessage.h"
#include "RadioTraffic.h"
-
#include "Clock.h"
#include "ContentBundle.h"
@@ -1644,7 +1644,7 @@ FighterAI::EvadeThreat()
evade_p = Transform(evade_w2);
if (!target) {
- DWORD jink_rate = 400 + 200 * (3-ai_level);
+ std::uint32_t jink_rate = 400 + 200 * (3-ai_level);
if (Clock::GetInstance()->GameTime() - jink_time > jink_rate) {
jink_time = Clock::GetInstance()->GameTime();
diff --git a/StarsEx/FighterAI.h b/StarsEx/FighterAI.h
index 21bc7f8..ad56644 100644
--- a/StarsEx/FighterAI.h
+++ b/StarsEx/FighterAI.h
@@ -11,10 +11,10 @@
Fighter (low-level) Artifical Intelligence class
*/
-#ifndef FighterAI_h
-#define FighterAI_h
+#pragma once
+
+#include <cstdint>
-#include "Types.h"
#include "ShipAI.h"
// +--------------------------------------------------------------------+
@@ -71,14 +71,9 @@ protected:
InboundSlot* inbound;
int rtb_code;
bool evading;
- DWORD jink_time;
+ std::uint32_t jink_time;
Point jink;
bool over_threshold;
bool form_up;
bool go_manual;
};
-
-// +--------------------------------------------------------------------+
-
-#endif // FighterAI_h
-
diff --git a/StarsEx/FighterTacticalAI.h b/StarsEx/FighterTacticalAI.h
index bda69ec..fd39a05 100644
--- a/StarsEx/FighterTacticalAI.h
+++ b/StarsEx/FighterTacticalAI.h
@@ -11,12 +11,13 @@
Fighter-specific mid-level (tactical) AI
*/
-#ifndef FighterTacticalAI_h
-#define FighterTacticalAI_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
-#include "Types.h"
#include "TacticalAI.h"
-#include "List.h"
// +--------------------------------------------------------------------+
@@ -44,12 +45,7 @@ protected:
virtual int ListSecondariesForTarget(Ship* tgt, List<WeaponGroup>& weps);
bool winchester[4];
- DWORD THREAT_REACTION_TIME;
- DWORD secondary_selection_time;
+ std::uint32_t THREAT_REACTION_TIME;
+ std::uint32_t secondary_selection_time;
int ai_level;
};
-
-// +--------------------------------------------------------------------+
-
-#endif // FighterTacticalAI_h
-
diff --git a/StarsEx/Hangar.cpp b/StarsEx/Hangar.cpp
index 01a8894..4f822ae 100644
--- a/StarsEx/Hangar.cpp
+++ b/StarsEx/Hangar.cpp
@@ -14,21 +14,23 @@
*/
#include "Hangar.h"
-#include "FlightDeck.h"
-#include "Ship.h"
-#include "ShipDesign.h"
-#include "Sim.h"
-#include "Instruction.h"
-#include "Element.h"
-#include "Mission.h"
-#include "RadioMessage.h"
+
+#include <cstdint>
+
#include "Campaign.h"
#include "Combatant.h"
#include "CombatGroup.h"
-
-#include "Game.h"
#include "ContentBundle.h"
+#include "Element.h"
+#include "FlightDeck.h"
+#include "Game.h"
+#include "Instruction.h"
+#include "Mission.h"
+#include "RadioMessage.h"
#include "Random.h"
+#include "ShipDesign.h"
+#include "Ship.h"
+#include "Sim.h"
// +======================================================================+
@@ -902,14 +904,14 @@ Hangar::GetActiveElements(List<Element>& active_list)
// +--------------------------------------------------------------------+
-DWORD
+std::uint32_t
Hangar::GetLastPatrolLaunch() const
{
return last_patrol_launch;
}
void
-Hangar::SetLastPatrolLaunch(DWORD t)
+Hangar::SetLastPatrolLaunch(std::uint32_t t)
{
last_patrol_launch = t;
}
diff --git a/StarsEx/Hangar.h b/StarsEx/Hangar.h
index 1305c31..67b6aac 100644
--- a/StarsEx/Hangar.h
+++ b/StarsEx/Hangar.h
@@ -13,13 +13,14 @@
See Also: FlightDeck
*/
-#ifndef Hangar_h
-#define Hangar_h
+#pragma once
+
+#include <cstdint>
+
+#include <Text.h>
-#include "Types.h"
#include "Geometry.h"
#include "SimObject.h"
-#include "Text.h"
// +--------------------------------------------------------------------+
@@ -107,8 +108,8 @@ public:
Text StatusName(const HangarSlot* s) const;
int PreflightQueue(FlightDeck* d) const;
- DWORD GetLastPatrolLaunch() const;
- void SetLastPatrolLaunch(DWORD t);
+ std::uint32_t GetLastPatrolLaunch() const;
+ void SetLastPatrolLaunch(std::uint32_t t);
protected:
Ship* ship;
@@ -116,11 +117,5 @@ protected:
int nslots[MAX_SQUADRONS];
Text names[MAX_SQUADRONS];
HangarSlot* squadrons[MAX_SQUADRONS];
- DWORD last_patrol_launch;
+ std::uint32_t last_patrol_launch;
};
-
-// +--------------------------------------------------------------------+
-
-
-#endif // Hangar_h
-
diff --git a/StarsEx/NetChat.cpp b/StarsEx/NetChat.cpp
index d296b0c..044d969 100644
--- a/StarsEx/NetChat.cpp
+++ b/StarsEx/NetChat.cpp
@@ -11,7 +11,6 @@
Single chat message and sender
*/
-
#include "NetChat.h"
#include "NetLayer.h"
@@ -48,4 +47,3 @@ NetChatEntry::NetChatEntry(int msg_id, const char* u, const char* s)
NetChatEntry::~NetChatEntry()
{ }
-
diff --git a/StarsEx/NetChat.h b/StarsEx/NetChat.h
index 2aacc62..cdf6e86 100644
--- a/StarsEx/NetChat.h
+++ b/StarsEx/NetChat.h
@@ -11,11 +11,10 @@
Single chat message and sender
*/
+#pragma once
-#ifndef NetChat_h
-#define NetChat_h
+#include <cstdint>
-#include "Types.h"
#include "NetUser.h"
// +-------------------------------------------------------------------+
@@ -36,16 +35,12 @@ public:
const Text& GetUser() const { return user; }
Color GetColor() const { return color; }
const Text& GetMessage() const { return msg; }
- DWORD GetTime() const { return time; }
+ std::uint32_t GetTime() const { return time; }
private:
int id;
Text user;
Text msg;
Color color;
- DWORD time;
+ std::uint32_t time;
};
-
-// +-------------------------------------------------------------------+
-
-#endif // NetChat_h \ No newline at end of file
diff --git a/StarsEx/NetLobbyServer.cpp b/StarsEx/NetLobbyServer.cpp
index dfb0422..d853982 100644
--- a/StarsEx/NetLobbyServer.cpp
+++ b/StarsEx/NetLobbyServer.cpp
@@ -13,7 +13,11 @@
#include "NetLobbyServer.h"
+#include <cstdint>
+
#include <InfoEx.h>
+#include <List.h>
+#include <Text.h>
#include "NetServerConfig.h"
#include "NetClientConfig.h"
@@ -25,7 +29,6 @@
#include "Mission.h"
#include "ShipDesign.h"
#include "Sim.h"
-#include "Text.h"
#include "ModConfig.h"
#include "ModInfo.h"
@@ -57,8 +60,8 @@ NetLobbyServer::NetLobbyServer()
selected_mission = 0;
- Text hostname = "0.0.0.0";
- WORD server_port = 11100;
+ Text hostname = "0.0.0.0";
+ std::uint16_t server_port = 11100;
server_config = NetServerConfig::GetInstance();
if (server_config) {
@@ -76,7 +79,7 @@ NetLobbyServer::NetLobbyServer()
LoadMOTD();
auto game = Game::GetInstance();
- DWORD mission_id = 0;
+ std::uint32_t mission_id = 0;
// only one mission:
if (game->Server() && server_mission.length() > 0) {
@@ -269,7 +272,7 @@ NetLobbyServer::ExecFrame()
}
auto game = Game::GetInstance();
- DWORD mission_id = 0;
+ std::uint32_t mission_id = 0;
// restart persistent mission?
if (game->Server() && game->GetGameMode() == Game::MENU_MODE && server_mission.length() > 0) {
@@ -325,9 +328,9 @@ NetLobbyServer::SendData(NetUser* dst, int type, Text msg)
{
if (link && dst && type > 0 && type < 255) {
if (msg.length())
- link->SendMessage(dst->GetNetID(), (BYTE) type, msg.data(), msg.length(), NetMsg::RELIABLE);
+ link->SendMessage(dst->GetNetID(), static_cast<std::uint8_t>(type), msg.data(), msg.length(), NetMsg::RELIABLE);
else
- link->SendMessage(dst->GetNetID(), (BYTE) type, 0, 0, NetMsg::RELIABLE);
+ link->SendMessage(dst->GetNetID(), static_cast<std::uint8_t>(type), 0, 0, NetMsg::RELIABLE);
}
}
@@ -580,7 +583,7 @@ NetLobbyServer::SaveChat()
// +-------------------------------------------------------------------+
void
-NetLobbyServer::SelectMission(DWORD id)
+NetLobbyServer::SelectMission(std::uint32_t id)
{
if (GetStatus() == NetServerInfo::PERSISTENT)
return;
@@ -834,7 +837,7 @@ NetLobbyServer::DoServerInfo(NetPeer* peer, Text s)
{
if (peer && peer->NetID()) {
char buffer[1024];
- WORD gameport = 11101;
+ std::uint16_t gameport = 11101;
if (server_config)
gameport = server_config->GetGamePort();
@@ -847,7 +850,8 @@ NetLobbyServer::DoServerInfo(NetPeer* peer, Text s)
HasHost() ? "true" : "false",
gameport);
- link->SendMessage(peer->NetID(), (BYTE) NET_LOBBY_SERVER_INFO, buffer, strlen(buffer), NetMsg::RELIABLE);
+ link->SendMessage(
+ peer->NetID(), static_cast<std::uint8_t>(NET_LOBBY_SERVER_INFO), buffer, strlen(buffer), NetMsg::RELIABLE);
}
}
@@ -876,7 +880,8 @@ NetLobbyServer::DoServerMods(NetPeer* peer, Text s)
response += "\" ";
}
- link->SendMessage(peer->NetID(), (BYTE) NET_LOBBY_SERVER_MODS, response, response.length(), NetMsg::RELIABLE);
+ link->SendMessage(
+ peer->NetID(), static_cast<std::uint8_t>(NET_LOBBY_SERVER_MODS), response, response.length(), NetMsg::RELIABLE);
}
}
diff --git a/StarsEx/NetLobbyServer.h b/StarsEx/NetLobbyServer.h
index 2f08f83..ea5c0d7 100644
--- a/StarsEx/NetLobbyServer.h
+++ b/StarsEx/NetLobbyServer.h
@@ -11,13 +11,16 @@
UDP Server Engine for Multiplayer Lobby
*/
-
-#ifndef NetLobbyServer_h
-#define NetLobbyServer_h
+#pragma once
// FOR NETWORK MENU TESTING (extra latency in msec):
// #define EXTRA_LATENCY 300
+#include <cstdint>
+
+#include <List.h>
+#include <Text.h>
+
#include "NetLobby.h"
// +-------------------------------------------------------------------+
@@ -59,7 +62,7 @@ public:
virtual void UnmapUnit(const char* user);
virtual void SendUnits();
- virtual void SelectMission(DWORD id);
+ virtual void SelectMission(std::uint32_t id);
virtual Text Serialize(Mission* m, NetUser* u=0);
virtual Mission* GetSelectedMission();
@@ -105,14 +108,10 @@ protected:
Text server_name;
NetAddr server_addr;
- DWORD announce_time;
+ std::uint32_t announce_time;
NetServerConfig* server_config;
Text server_mission;
int motd_index;
List<Text> motd;
};
-
-// +-------------------------------------------------------------------+
-
-#endif // NetLobbyServer_h \ No newline at end of file
diff --git a/StarsEx/NetPacket.cpp b/StarsEx/NetPacket.cpp
index e8964c2..96d61a6 100644
--- a/StarsEx/NetPacket.cpp
+++ b/StarsEx/NetPacket.cpp
@@ -12,12 +12,14 @@
*/
#include "NetPacket.h"
+
+#include <cstdint>
+
+#include "Game.h"
#include "NetLink.h"
#include "NetMsg.h"
#include "Ship.h"
-#include "Game.h"
-
// +--------------------------------------------------------------------+
const int PING_SIZE = 8;
@@ -32,7 +34,7 @@ NetPacket::NetPacket(NetMsg* g)
: msg(g)
{ }
-NetPacket::NetPacket(DWORD netid, BYTE type)
+NetPacket::NetPacket(std::uint32_t netid, std::uint8_t type)
{
int len = 0;
char buf[256];
@@ -72,7 +74,7 @@ NetPacket::Send(NetLink& link)
// +--------------------------------------------------------------------+
-DWORD
+std::uint32_t
NetPacket::NetID() const
{
if (msg)
@@ -81,7 +83,7 @@ NetPacket::NetID() const
return 0;
}
-BYTE
+std::uint8_t
NetPacket::Type() const
{
if (msg)
@@ -92,11 +94,11 @@ NetPacket::Type() const
// +--------------------------------------------------------------------+
-DWORD
+std::uint32_t
NetPacket::GetPingSequence()
{
if (msg && msg->Length() >= PING_SIZE) {
- DWORD* data = (DWORD*) (msg->Data()+4);
+ auto* data = reinterpret_cast<std::uint32_t*>(msg->Data() + 4);
return *data;
}
@@ -104,21 +106,21 @@ NetPacket::GetPingSequence()
}
void
-NetPacket::SetPingSequence(DWORD seq)
+NetPacket::SetPingSequence(std::uint32_t seq)
{
if (msg && msg->Length() >= PING_SIZE) {
- DWORD* data = (DWORD*) (msg->Data()+4);
+ auto* data = reinterpret_cast<std::uint32_t*>(msg->Data() + 4);
*data = seq;
}
}
// +--------------------------------------------------------------------+
-DWORD
+std::uint32_t
NetPacket::GetNetID()
{
if (msg && msg->Length() >= PING_SIZE) {
- DWORD* data = (DWORD*) (msg->Data()+4);
+ auto* data = reinterpret_cast<std::uint32_t*>(msg->Data() + 4);
return *data;
}
@@ -126,10 +128,10 @@ NetPacket::GetNetID()
}
void
-NetPacket::SetNetID(DWORD id)
+NetPacket::SetNetID(std::uint32_t id)
{
if (msg && msg->Length() >= PING_SIZE) {
- DWORD* data = (DWORD*) (msg->Data()+4);
+ auto* data = reinterpret_cast<std::uint32_t*>(msg->Data() + 4);
*data = id;
}
}
@@ -140,7 +142,7 @@ Point
NetPacket::GetShipLocation()
{
if (msg && msg->Length() >= SHIP_LOC_SIZE) {
- long* data = (long*) (msg->Data()+8);
+ auto* data = reinterpret_cast<long*>(msg->Data() + 8);
long x = *(data + 0);
long y = *(data + 1);
long z = *(data + 2);
@@ -159,7 +161,7 @@ NetPacket::SetShipLocation(const Point& loc)
long y = (long) (loc.y * 100);
long z = (long) (loc.z * 100);
- long* data = (long*) (msg->Data()+8);
+ auto* data = reinterpret_cast<long*>(msg->Data() + 8);
*(data + 0) = x;
*(data + 1) = y;
@@ -173,7 +175,7 @@ Point
NetPacket::GetShipVelocity()
{
if (msg && msg->Length() >= SHIP_LOC_SIZE) {
- short* data = (short*) (msg->Data()+20);
+ auto* data = reinterpret_cast<short*>(msg->Data() + 20);
short dx = *(data + 0);
short dy = *(data + 1);
@@ -189,7 +191,7 @@ void
NetPacket::SetShipVelocity(const Point& vel)
{
if (msg && msg->Length() >= SHIP_LOC_SIZE) {
- short* data = (short*) (msg->Data()+20);
+ auto* data = reinterpret_cast<short*>(msg->Data() + 20);
*(data + 0) = (short) vel.x;
*(data + 1) = (short) vel.y;
@@ -203,7 +205,7 @@ Point
NetPacket::GetShipOrientation()
{
if (msg && msg->Length() >= SHIP_LOC_SIZE) {
- short* data = (short*) (msg->Data()+26);
+ auto* data = reinterpret_cast<short*>(msg->Data() + 26);
short r = *(data + 0);
short p = *(data + 1);
@@ -219,7 +221,7 @@ void
NetPacket::SetShipOrientation(const Point& rpy)
{
if (msg && msg->Length() >= SHIP_LOC_SIZE) {
- short* data = (short*) (msg->Data()+26);
+ auto* data = reinterpret_cast<short*>(msg->Data() + 26);
*(data + 0) = (short) (32767*rpy.x/(2*PI));
*(data + 1) = (short) (32767*rpy.y/(2*PI));
@@ -233,9 +235,9 @@ double
NetPacket::GetThrottle()
{
if (msg && msg->Length() >= SHIP_LOC_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+32;
+ auto* data = reinterpret_cast<std::uint8_t*>(msg->Data() + 32);
- return (double) *data;
+ return static_cast<double>(*data);
}
return 0;
@@ -245,9 +247,9 @@ void
NetPacket::SetThrottle(double t)
{
if (msg && msg->Length() >= SHIP_LOC_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+32;
+ auto* data = reinterpret_cast<std::uint8_t*>(msg->Data() + 32);
- *data = (BYTE) t;
+ *data = static_cast<std::uint8_t>(t);
}
}
@@ -257,9 +259,9 @@ bool
NetPacket::GetTrigger(int i)
{
if (i >= 0 && i < 8 && msg && msg->Length() >= SHIP_LOC_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+33;
+ auto* data = reinterpret_cast<std::uint8_t*>(msg->Data() + 33);
- BYTE select = 1 << i;
+ std::uint8_t select = 1 << i;
return (*data & select)?true:false;
}
@@ -270,9 +272,9 @@ void
NetPacket::SetTrigger(int i, bool trigger)
{
if (i >= 0 && i < 8 && msg && msg->Length() >= SHIP_LOC_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+33;
+ auto* data = reinterpret_cast<std::uint8_t*>(msg->Data() + 33);
- BYTE select = 1 << i;
+ std::uint8_t select = 1 << i;
if (trigger)
*data = *data | select;
@@ -287,9 +289,9 @@ const char*
NetPacket::GetName()
{
if (msg && msg->Length() >= JOIN_REQ_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+20;
+ auto* data = reinterpret_cast<const char*>(msg->Data() + 20);
- return (const char*) data;
+ return data;
}
return 0;
@@ -299,8 +301,8 @@ void
NetPacket::SetName(const char* name)
{
if (msg && msg->Length() >= JOIN_REQ_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+20;
- strncpy((char*) data, name, 32);
+ auto* data = reinterpret_cast<char*>(msg->Data() + 20);
+ strncpy(data, name, 32);
}
}
@@ -310,9 +312,9 @@ const char*
NetPacket::GetDesign()
{
if (msg && msg->Length() >= JOIN_REQ_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+52;
+ auto* data = reinterpret_cast<const char*>(msg->Data() + 52);
- return (const char*) data;
+ return data;
}
return 0;
@@ -322,8 +324,8 @@ void
NetPacket::SetDesign(const char* design)
{
if (msg && msg->Length() >= JOIN_REQ_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+52;
- strncpy((char*) data, design, 32);
+ auto* data = reinterpret_cast<char*>(msg->Data() + 52);
+ strncpy(data, design, 32);
}
}
@@ -333,9 +335,9 @@ const char*
NetPacket::GetRegion()
{
if (msg && msg->Length() >= JOIN_REQ_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+84;
+ auto* data = reinterpret_cast<const char*>(msg->Data() + 84);
- return (const char*) data;
+ return data;
}
return 0;
@@ -345,10 +347,7 @@ void
NetPacket::SetRegion(const char* rgn_name)
{
if (msg && msg->Length() >= JOIN_REQ_SIZE) {
- BYTE* data = (BYTE*) msg->Data()+84;
- strncpy((char*) data, rgn_name, 32);
+ auto* data = reinterpret_cast<char*>(msg->Data() + 84);
+ strncpy(data, rgn_name, 32);
}
}
-
-// +--------------------------------------------------------------------+
-
diff --git a/StarsEx/NetPacket.h b/StarsEx/NetPacket.h
index c527c1e..437aaf8 100644
--- a/StarsEx/NetPacket.h
+++ b/StarsEx/NetPacket.h
@@ -11,10 +11,10 @@
Wrapper for low-level datagram class
*/
-#ifndef NetPacket_h
-#define NetPacket_h
+#pragma once
+
+#include <cstdint>
-#include "Types.h"
#include "Geometry.h"
#include "NetData.h"
@@ -31,19 +31,20 @@ public:
static const char* TYPENAME() { return "NetPacket"; }
NetPacket(NetMsg* g);
- NetPacket(DWORD netid, BYTE type);
+ NetPacket(std::uint32_t netid, std::uint8_t type);
~NetPacket();
bool Send(NetLink& link);
// various accessors:
- DWORD NetID() const;
- BYTE Type() const;
+ std::uint32_t NetID() const;
+ std::uint8_t Type() const;
+
+ std::uint32_t GetPingSequence();
+ void SetPingSequence(std::uint32_t seq);
+ std::uint32_t GetNetID();
+ void SetNetID(std::uint32_t id);
- DWORD GetPingSequence();
- void SetPingSequence(DWORD seq);
- DWORD GetNetID();
- void SetNetID(DWORD id);
Point GetShipLocation();
void SetShipLocation(const Point& loc);
Point GetShipVelocity();
@@ -61,13 +62,6 @@ public:
bool GetTrigger(int i);
void SetTrigger(int i, bool trigger);
-
protected:
NetMsg* msg;
};
-
-
-// +--------------------------------------------------------------------+
-
-#endif // NetPacket_h
-
diff --git a/StarsEx/NetPlayer.cpp b/StarsEx/NetPlayer.cpp
index d098e5c..ed27751 100644
--- a/StarsEx/NetPlayer.cpp
+++ b/StarsEx/NetPlayer.cpp
@@ -15,32 +15,32 @@
#define NOMINMAX
#endif
+#include "NetPlayer.h"
+
#include <algorithm>
-#include "NetPlayer.h"
+#include "Element.h"
+#include "Explosion.h"
+#include "Farcaster.h"
+#include "Game.h"
+#include "HUDView.h"
+#include "Light.h"
+#include "NetData.h"
#include "NetGame.h"
+#include "NetHost.h"
#include "NetMsg.h"
-#include "NetData.h"
#include "NetUtil.h"
-#include "Ship.h"
-#include "ShipDesign.h"
+#include "RadioMessage.h"
+#include "RadioTraffic.h"
#include "Shield.h"
+#include "ShipDesign.h"
+#include "Ship.h"
#include "Shot.h"
-#include "Sim.h"
#include "SimEvent.h"
+#include "Sim.h"
#include "System.h"
-#include "Weapon.h"
#include "WeaponGroup.h"
-#include "Element.h"
-#include "HUDView.h"
-#include "Explosion.h"
-#include "Farcaster.h"
-#include "RadioMessage.h"
-#include "RadioTraffic.h"
-
-#include "NetHost.h"
-#include "Game.h"
-#include "Light.h"
+#include "Weapon.h"
// +--------------------------------------------------------------------+
@@ -136,8 +136,8 @@ NetPlayer::DoObjHyper(NetObjHyper* obj_hyper)
if (ship && obj_hyper) {
Sim* sim = Sim::GetSim();
SimRegion* rgn = sim->FindRegion(obj_hyper->GetRegion());
- DWORD fc1_id = obj_hyper->GetFarcaster1();
- DWORD fc2_id = obj_hyper->GetFarcaster2();
+ auto fc1_id = obj_hyper->GetFarcaster1();
+ auto fc2_id = obj_hyper->GetFarcaster2();
Ship* fc1 = 0;
Ship* fc2 = 0;
int trans = obj_hyper->GetTransitionType();
@@ -189,7 +189,7 @@ bool
NetPlayer::DoObjTarget(NetObjTarget* obj_target)
{
if (ship && obj_target) {
- DWORD tgtid = obj_target->GetTgtID();
+ auto tgtid = obj_target->GetTgtID();
int subid = obj_target->GetSubtarget();
SimObject* target = 0;
System* subtgt = 0;
@@ -236,7 +236,7 @@ NetPlayer::DoWepTrigger(NetWepTrigger* trigger)
if (ship && trigger) {
int index = trigger->GetIndex();
int count = trigger->GetCount();
- DWORD tgtid = trigger->GetTgtID();
+ auto tgtid = trigger->GetTgtID();
int subid = trigger->GetSubtarget();
bool decoy = trigger->GetDecoy();
bool probe = trigger->GetProbe();
@@ -272,7 +272,7 @@ NetPlayer::DoWepTrigger(NetWepTrigger* trigger)
net_game->SendData(trigger);
}
else {
- DWORD wepid = NetGame::GetNextObjID(NetGame::SHOT);
+ auto wepid = NetGame::GetNextObjID(NetGame::SHOT);
Shot* shot = w->NetFireSecondary(target, subtgt, wepid);
if (shot && shot->IsDrone()) {
@@ -315,8 +315,8 @@ NetPlayer::DoWepRelease(NetWepRelease* release)
{
if (ship && release) {
int index = release->GetIndex();
- DWORD tgtid = release->GetTgtID();
- DWORD wepid = release->GetWepID();
+ auto tgtid = release->GetTgtID();
+ auto wepid = release->GetWepID();
int subid = release->GetSubtarget();
bool decoy = release->GetDecoy();
bool probe = release->GetProbe();
diff --git a/StarsEx/NetPlayer.h b/StarsEx/NetPlayer.h
index 143a8be..d79f263 100644
--- a/StarsEx/NetPlayer.h
+++ b/StarsEx/NetPlayer.h
@@ -11,15 +11,16 @@
Network Player (Director) class
*/
-#ifndef NetPlayer_h
-#define NetPlayer_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
+#include <Text.h>
-#include "Types.h"
#include "Geometry.h"
#include "Director.h"
#include "SimObject.h"
-#include "List.h"
-#include "Text.h"
// +--------------------------------------------------------------------+
@@ -44,14 +45,14 @@ class NetPlayer : public Director, public SimObserver
public:
static const char* TYPENAME() { return "NetPlayer"; }
- NetPlayer(DWORD nid) : netid(nid), objid(0), ship(0), iff(0) { }
+ NetPlayer(std::uint32_t nid) : netid(nid), objid(0), ship(0), iff(0) { }
~NetPlayer();
int operator == (const NetPlayer& p) const { return netid == p.netid; }
- DWORD GetNetID() const { return netid; }
- DWORD GetObjID() const { return objid; }
- void SetObjID(DWORD o) { objid = o; }
+ std::uint32_t GetNetID() const { return netid; }
+ std::uint32_t GetObjID() const { return objid; }
+ void SetObjID(std::uint32_t o) { objid = o; }
int GetIFF() const { return iff; }
Ship* GetShip() const { return ship; }
@@ -80,8 +81,8 @@ public:
virtual const char* GetObserverName() const;
protected:
- DWORD netid;
- DWORD objid;
+ std::uint32_t netid;
+ std::uint32_t objid;
Text name;
Text serno;
Ship* ship;
@@ -90,8 +91,3 @@ protected:
Point loc_error;
double bleed_time;
};
-
-// +--------------------------------------------------------------------+
-
-#endif // NetPlayer_h
-
diff --git a/StarsEx/NetUser.cpp b/StarsEx/NetUser.cpp
index d7ba9eb..3eb17ad 100644
--- a/StarsEx/NetUser.cpp
+++ b/StarsEx/NetUser.cpp
@@ -11,12 +11,12 @@
This class represents a user connecting to the multiplayer lobby
*/
-
#include "NetUser.h"
+
+#include "FormatUtil.h"
#include "NetAuth.h"
#include "NetLobby.h"
#include "Player.h"
-#include "FormatUtil.h"
// +-------------------------------------------------------------------+
diff --git a/StarsEx/NetUser.h b/StarsEx/NetUser.h
index e218aca..69499f4 100644
--- a/StarsEx/NetUser.h
+++ b/StarsEx/NetUser.h
@@ -11,14 +11,15 @@
This class represents a user connecting to the multiplayer lobby
*/
+#pragma once
-#ifndef NetUser_h
-#define NetUser_h
+#include <cstdint>
-#include "Types.h"
+#include <Text.h>
+
+#include "Color.h"
#include "NetAddr.h"
#include "NetLobby.h"
-#include "Color.h"
// +-------------------------------------------------------------------+
@@ -42,7 +43,7 @@ public:
const NetAddr& GetAddress() const { return addr; }
Color GetColor() const { return color; }
const Text& GetSessionID() const { return session_id; }
- DWORD GetNetID() const { return netid; }
+ std::uint32_t GetNetID() const { return netid; }
bool IsHost() const { return host; }
int AuthLevel() const { return auth_level; }
@@ -64,7 +65,7 @@ public:
{ addr = a; }
void SetColor(Color c) { color = c; }
- void SetNetID(DWORD id) { netid = id; }
+ void SetNetID(std::uint32_t id) { netid = id; }
void SetSessionID(Text s) { session_id = s; }
void SetHost(bool h) { host = h; }
@@ -87,7 +88,7 @@ protected:
Text pass;
Text session_id;
NetAddr addr;
- DWORD netid;
+ std::uint32_t netid;
Color color;
bool host;
@@ -105,7 +106,3 @@ protected:
int kills;
int losses;
};
-
-// +-------------------------------------------------------------------+
-
-#endif // NetUser_h \ No newline at end of file
diff --git a/StarsEx/NetUtil.cpp b/StarsEx/NetUtil.cpp
index ff212c5..50e76a4 100644
--- a/StarsEx/NetUtil.cpp
+++ b/StarsEx/NetUtil.cpp
@@ -11,14 +11,15 @@
Utility class to simplify sending NetData messages.
*/
-
#include "NetUtil.h"
-#include "NetData.h"
-#include "NetGame.h"
-#include "NetGameServer.h"
+
+#include <cstdint>
#include "Element.h"
#include "Instruction.h"
+#include "NetData.h"
+#include "NetGame.h"
+#include "NetGameServer.h"
#include "Random.h"
#include "Ship.h"
#include "Shot.h"
@@ -230,7 +231,7 @@ NetUtil::SendWepRelease(Weapon* wep, Shot* shot)
if (!net_game || !wep || !shot) return;
if (net_game->IsServer() && wep->IsMissile()) {
- DWORD wepid = NetGame::GetNextObjID(NetGame::SHOT);
+ auto wepid = NetGame::GetNextObjID(NetGame::SHOT);
shot->SetObjID(wepid);
NetWepRelease release;
@@ -275,7 +276,7 @@ NetUtil::SendWepDestroy(Shot* shot)
// +-------------------------------------------------------------------+
void
-NetUtil::SendChat(DWORD dst, const char* name, const char* text)
+NetUtil::SendChat(std::uint32_t dst, const char* name, const char* text)
{
NetGame* net_game = NetGame::GetInstance();
if (!net_game || !name || !*name || !text || !*text) return;
diff --git a/StarsEx/NetUtil.h b/StarsEx/NetUtil.h
index 3f02f49..0d68891 100644
--- a/StarsEx/NetUtil.h
+++ b/StarsEx/NetUtil.h
@@ -11,11 +11,10 @@
Utility class to simplify sending NetData messages.
*/
+#pragma once
-#ifndef NetUtil_h
-#define NetUtil_h
+#include <cstdint>
-#include "Types.h"
#include "Geometry.h"
// +-------------------------------------------------------------------+
@@ -43,7 +42,7 @@ public:
static void SendWepTrigger(Weapon* wep, int count=1);
static void SendWepRelease(Weapon* wep, Shot* shot);
static void SendWepDestroy(Shot* shot);
- static void SendChat(DWORD dst, const char* name, const char* text);
+ static void SendChat(std::uint32_t dst, const char* name, const char* text);
static void SendElemRequest(const char* name);
static void SendElemCreate(Element* elem, int squadron, int* slots, bool alert, bool in_flight=false);
static void SendShipLaunch(Ship* carrier, int squadron, int slot);
@@ -51,5 +50,3 @@ public:
static void SendNavDelete(Element* elem, int index);
static void SendSelfDestruct(Ship* ship, double damage);
};
-
-#endif // NetUtil_h \ No newline at end of file
diff --git a/StarsEx/ParseUtil.cpp b/StarsEx/ParseUtil.cpp
index 2a7ad65..fe86127 100644
--- a/StarsEx/ParseUtil.cpp
+++ b/StarsEx/ParseUtil.cpp
@@ -74,78 +74,6 @@ bool GetDefText(char* dst, TermDef* def, const char* file)
return false;
}
-bool GetDefNumber(int& dst, TermDef* def, const char* file)
-{
- if (!def || !def->term()) {
- Print("WARNING: missing NUMBER TermDef in '%s'\n", file);
- return false;
- }
-
- TermNumber* tr = def->term()->isNumber();
- if (tr) {
- dst = (int) tr->value();
- return true;
- }
- else
- Print("WARNING: invalid NUMBER %s in '%s'\n", def->name()->value().data(), file);
-
- return false;
-}
-
-bool GetDefNumber(DWORD& dst, TermDef* def, const char* file)
-{
- if (!def || !def->term()) {
- Print("WARNING: missing NUMBER TermDef in '%s'\n", file);
- return false;
- }
-
- TermNumber* tr = def->term()->isNumber();
- if (tr) {
- dst = (DWORD) tr->value();
- return true;
- }
- else
- Print("WARNING: invalid NUMBER %s in '%s'\n", def->name()->value().data(), file);
-
- return false;
-}
-
-bool GetDefNumber(float& dst, TermDef* def, const char* file)
-{
- if (!def || !def->term()) {
- Print("WARNING: missing NUMBER TermDef in '%s'\n", file);
- return false;
- }
-
- TermNumber* tr = def->term()->isNumber();
- if (tr) {
- dst = (float) tr->value();
- return true;
- }
- else
- Print("WARNING: invalid NUMBER %s in '%s'\n", def->name()->value().data(), file);
-
- return false;
-}
-
-bool GetDefNumber(double& dst, TermDef* def, const char* file)
-{
- if (!def || !def->term()) {
- Print("WARNING: missing NUMBER TermDef in '%s'\n", file);
- return false;
- }
-
- TermNumber* tr = def->term()->isNumber();
- if (tr) {
- dst = (double) tr->value();
- return true;
- }
- else
- Print("WARNING: invalid NUMBER %s in '%s'\n", def->name()->value().data(), file);
-
- return false;
-}
-
bool GetDefVec(Vec3& dst, TermDef* def, const char* file)
{
if (!def || !def->term()) {
diff --git a/StarsEx/ParseUtil.h b/StarsEx/ParseUtil.h
index 0e147e0..221531e 100644
--- a/StarsEx/ParseUtil.h
+++ b/StarsEx/ParseUtil.h
@@ -11,9 +11,9 @@
Parser utility functions
*/
-#ifndef ParseUtil_h
-#define ParseUtil_h
+#pragma once
+#include <cstdint>
#include <vector>
#include <starshatter/definition.h>
@@ -23,28 +23,21 @@
#include "Geometry.h"
#include "Color.h"
-// +--------------------------------------------------------------------+
bool GetDefBool(bool& dst, TermDef* def, const char* file);
bool GetDefText(Text& dst, TermDef* def, const char* file);
bool GetDefText(char* dst, TermDef* def, const char* file);
-bool GetDefNumber(int& dst, TermDef* def, const char* file);
-bool GetDefNumber(DWORD& dst, TermDef* def, const char* file);
-bool GetDefNumber(float& dst, TermDef* def, const char* file);
-bool GetDefNumber(double& dst, TermDef* def, const char* file);
+template <typename Number> bool GetDefNumber(Number& dst, TermDef* def, const char* file);
bool GetDefVec(Vec3& dst, TermDef* def, const char* file);
bool GetDefColor(Color& dst, TermDef* def, const char* file);
bool GetDefColor(ColorValue& dst, TermDef* def, const char* file);
bool GetDefRect(Rect& dst, TermDef* def, const char* file);
bool GetDefInsets(Insets& dst, TermDef* def, const char* file);
bool GetDefTime(int& dst, TermDef* def, const char* file);
-
bool GetDefArray(int* dst, int size, TermDef* def, const char* file);
bool GetDefArray(float* dst, int size, TermDef* def, const char* file);
bool GetDefArray(double* dst, int size, TermDef* def, const char* file);
bool GetDefArray(std::vector<DWORD>& array, TermDef* def, const char* file);
bool GetDefArray(std::vector<float>& array, TermDef* def, const char* file);
-// +--------------------------------------------------------------------+
-
-#endif // ParseUtil_h
+#include "ParseUtil.inl.h"
diff --git a/StarsEx/ParseUtil.inl.h b/StarsEx/ParseUtil.inl.h
new file mode 100644
index 0000000..f59489b
--- /dev/null
+++ b/StarsEx/ParseUtil.inl.h
@@ -0,0 +1,30 @@
+/* Starshatter: The Open Source Project
+ Copyright (c) 2021-2024, Starshatter: The Open Source Project Contributors
+ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
+ Copyright (c) 1997-2006, Destroyer Studios LLC.
+*/
+
+#include <type_traits>
+
+#include <starshatter/definition.h>
+#include <Utils.h>
+
+
+template <typename Number>
+bool
+GetDefNumber(Number& dst, TermDef* def, const char* file)
+{
+ static_assert(std::is_convertible<long double, Number>::value);
+ if (!def || !def->term()) {
+ Print("WARNING: missing NUMBER TermDef in '%s'\n", file);
+ return false;
+ }
+ TermNumber* tr = def->term()->isNumber();
+ if (tr) {
+ dst = static_cast<Number>(tr->value());
+ return true;
+ }
+ else
+ Print("WARNING: invalid NUMBER %s in '%s'\n", def->name()->value().data(), file);
+ return false;
+}
diff --git a/StarsEx/Player.cpp b/StarsEx/Player.cpp
index 4be2cff..fffa9a6 100644
--- a/StarsEx/Player.cpp
+++ b/StarsEx/Player.cpp
@@ -11,8 +11,10 @@
Player / Logbook class
*/
-
#include "Player.h"
+
+#include <cstdint>
+
#include "NetLobbyServer.h"
#include "NetLayer.h"
#include "Ship.h"
@@ -633,7 +635,7 @@ Player::CommandRankRequired(int ship_class)
// +-------------------------------------------------------------------+
int
-Player::GetMissionPoints(ShipStats* s, DWORD start_time)
+Player::GetMissionPoints(ShipStats* s, std::uint32_t start_time)
{
int result = 0;
@@ -667,7 +669,7 @@ Player::GetMissionPoints(ShipStats* s, DWORD start_time)
// +-------------------------------------------------------------------+
void
-Player::ProcessStats(ShipStats* s, DWORD start_time)
+Player::ProcessStats(ShipStats* s, std::uint32_t start_time)
{
if (!s) return;
diff --git a/StarsEx/Player.h b/StarsEx/Player.h
index 7cbebad..c0a9b6c 100644
--- a/StarsEx/Player.h
+++ b/StarsEx/Player.h
@@ -11,13 +11,12 @@
Player / Logbook class
*/
+#pragma once
-#ifndef Player_h
-#define Player_h
+#include <cstdint>
-#include "Types.h"
-#include "List.h"
-#include "Text.h"
+#include <List.h>
+#include <Text.h>
// +-------------------------------------------------------------------+
@@ -117,8 +116,8 @@ public:
Text EncodeStats();
void DecodeStats(const char* stats);
- int GetMissionPoints(ShipStats* stats, DWORD start_time);
- void ProcessStats(ShipStats* stats, DWORD start_time);
+ int GetMissionPoints(ShipStats* stats, std::uint32_t start_time);
+ void ProcessStats(ShipStats* stats, std::uint32_t start_time);
bool EarnedAward(AwardInfo* a, ShipStats* s);
static const char* RankName(int rank);
@@ -182,5 +181,3 @@ protected:
// transient:
AwardInfo* award;
};
-
-#endif // Player_h \ No newline at end of file
diff --git a/StarsEx/Ship.cpp b/StarsEx/Ship.cpp
index 532d5f8..b511b8b 100644
--- a/StarsEx/Ship.cpp
+++ b/StarsEx/Ship.cpp
@@ -12,77 +12,80 @@
*/
#include "Ship.h"
-#include "ShipAI.h"
-#include "ShipCtrl.h"
-#include "ShipDesign.h"
-#include "ShipKiller.h"
-#include "Shot.h"
-#include "Drone.h"
-#include "SeekerAI.h"
-#include "HardPoint.h"
-#include "Weapon.h"
-#include "WeaponGroup.h"
-#include "Shield.h"
-#include "ShieldRep.h"
+
+#include <cstdint>
+
+#include <List.h>
+
+#include "AudioConfig.h"
+#include "Bitmap.h"
+#include "Bolt.h"
+#include "Button.h"
+#include "CameraDirector.h"
+#include "Clock.h"
+#include "CombatUnit.h"
+#include "Component.h"
#include "Computer.h"
-#include "FlightComp.h"
+#include "Contact.h"
+#include "ContentBundle.h"
#include "Drive.h"
-#include "QuantumDrive.h"
+#include "Drone.h"
+#include "DropShipAI.h"
+#include "Element.h"
+#include "Explosion.h"
#include "Farcaster.h"
-#include "Thruster.h"
-#include "Power.h"
+#include "FlightComp.h"
#include "FlightDeck.h"
-#include "LandingGear.h"
+#include "Game.h"
#include "Hangar.h"
-#include "Sensor.h"
-#include "Contact.h"
-#include "CombatUnit.h"
-#include "Element.h"
+#include "HardPoint.h"
+#include "HUDView.h"
#include "Instruction.h"
-#include "RadioMessage.h"
-#include "RadioHandler.h"
-#include "RadioTraffic.h"
+#include "Joystick.h"
+#include "Keyboard.h"
+#include "KeyMap.h"
+#include "LandingGear.h"
+#include "Light.h"
+#include "MissionEvent.h"
+#include "MotionController.h"
+#include "NavAI.h"
#include "NavLight.h"
#include "NavSystem.h"
-#include "NavAI.h"
-#include "DropShipAI.h"
-#include "Explosion.h"
-#include "MissionEvent.h"
-#include "ShipSolid.h"
-#include "Sim.h"
-#include "SimEvent.h"
-#include "StarSystem.h"
-#include "TerrainRegion.h"
-#include "Terrain.h"
-#include "System.h"
-#include "Component.h"
-#include "KeyMap.h"
-#include "RadioView.h"
-#include "AudioConfig.h"
-#include "CameraDirector.h"
-#include "HUDView.h"
-#include "Random.h"
-#include "RadioVox.h"
-
#include "NetGame.h"
#include "NetUtil.h"
-
-#include "MotionController.h"
-#include "Keyboard.h"
-#include "Joystick.h"
-#include "Bolt.h"
-#include "Game.h"
-#include "Clock.h"
-#include "ContentBundle.h"
-#include "Solid.h"
+#include "Panic.h"
+#include "Power.h"
+#include "QuantumDrive.h"
+#include "RadioHandler.h"
+#include "RadioMessage.h"
+#include "RadioTraffic.h"
+#include "RadioView.h"
+#include "RadioVox.h"
+#include "Random.h"
+#include "SeekerAI.h"
+#include "Sensor.h"
#include "Shadow.h"
+#include "Shield.h"
+#include "ShieldRep.h"
+#include "ShipAI.h"
+#include "ShipCtrl.h"
+#include "ShipDesign.h"
+#include "ShipKiller.h"
+#include "ShipSolid.h"
+#include "Shot.h"
+#include "SimEvent.h"
+#include "Sim.h"
#include "Skin.h"
-#include "Sprite.h"
-#include "Light.h"
-#include "Bitmap.h"
-#include "Button.h"
+#include "Solid.h"
#include "Sound.h"
-#include "Panic.h"
+#include "Sprite.h"
+#include "StarSystem.h"
+#include "System.h"
+#include "Terrain.h"
+#include "TerrainRegion.h"
+#include "Thruster.h"
+#include "WeaponGroup.h"
+#include "Weapon.h"
// +----------------------------------------------------------------------+
@@ -396,7 +399,7 @@ Ship::Ship(const char* ship_name, const char* reg_num, ShipDesign* ship_dsn, int
NavLight* navlight = new NavLight(*design->navlights[i]);
navlight->SetShip(this);
navlight->SetID(sys_id++);
- navlight->SetOffset(((DWORD) this) << 2);
+ navlight->SetOffset(((std::uint32_t) this) << 2);
navlights.append(navlight);
systems.append(navlight);
}
@@ -1048,7 +1051,7 @@ Ship::UpdateTrack()
const int DEFAULT_TRACK_UPDATE = 500; // milliseconds
const int DEFAULT_TRACK_LENGTH = 20; // 10 seconds
- DWORD time = Clock::GetInstance()->GameTime();
+ auto time = Clock::GetInstance()->GameTime();
if (!track) {
track = new Point[DEFAULT_TRACK_LENGTH];
@@ -1473,7 +1476,7 @@ Ship::CollidesWith(Physical& o)
// +--------------------------------------------------------------------+
-static DWORD ff_warn_time = 0;
+static std::uint32_t ff_warn_time = 0;
int
Ship::HitBy(Shot* shot, Point& impact)
@@ -1522,7 +1525,7 @@ Ship::HitBy(Shot* shot, Point& impact)
if (hit_type) {
if (shot->Damage() > 0) {
- DWORD flash = Explosion::HULL_FLASH;
+ std::uint32_t flash = Explosion::HULL_FLASH;
if ((hit_type & HIT_SHIELD) != 0)
flash = Explosion::SHIELD_FLASH;
@@ -1838,7 +1841,7 @@ Ship::InflictNetDamage(double damage, Shot* shot)
}
void
-Ship::InflictNetSystemDamage(System* system, double damage, BYTE dmg_type)
+Ship::InflictNetSystemDamage(System* system, double damage, std::uint8_t dmg_type)
{
if (system && damage > 0 && !IsNetObserver()) {
bool dmg_normal = dmg_type == WeaponDesign::DMG_NORMAL;
@@ -2007,7 +2010,7 @@ Ship::CheckFriendlyFire()
}
}
- friendly_fire_time = Clock::GetInstance()->GameTime() + (DWORD) Random(0, 500);
+ friendly_fire_time = Clock::GetInstance()->GameTime() + static_cast<std::uint32_t>(Random(0, 500));
}
// +----------------------------------------------------------------------+
@@ -2603,8 +2606,8 @@ Ship::ExecEvalFrame(double seconds)
// is it already too late?
if (life == 0 || integrity < 1) return;
- const DWORD EVAL_FREQUENCY = 1000; // once every second
- static DWORD last_eval_frame = 0; // one ship per game frame
+ const std::uint32_t EVAL_FREQUENCY = 1000; // once every second
+ static std::uint32_t last_eval_frame = 0; // one ship per game frame
if (element && element->NumObjectives() > 0 &&
Clock::GetInstance()->GameTime() - last_eval_time > EVAL_FREQUENCY &&
@@ -3936,7 +3939,7 @@ Ship::SetMissileEta(int id, int eta)
if (eta > 3599)
eta = 3599;
- missile_eta[index] = (BYTE) eta;
+ missile_eta[index] = static_cast<std::uint8_t>(eta);
}
}
@@ -4015,9 +4018,9 @@ Ship::CycleFLCSMode()
default:
if (IsStarship())
- flcs_mode = (BYTE) FLCS_HELM;
+ flcs_mode = static_cast<std::uint8_t>(FLCS_HELM);
else
- flcs_mode = (BYTE) FLCS_AUTO;
+ flcs_mode = static_cast<std::uint8_t>(FLCS_AUTO);
break;
}
@@ -4030,7 +4033,7 @@ Ship::CycleFLCSMode()
SetHelmPitch(CompassPitch());
}
else {
- flcs_mode = (BYTE) FLCS_AUTO;
+ flcs_mode = static_cast<std::uint8_t>(FLCS_AUTO);
}
}
}
@@ -4038,10 +4041,10 @@ Ship::CycleFLCSMode()
void
Ship::SetFLCSMode(int mode)
{
- flcs_mode = (BYTE) mode;
+ flcs_mode = static_cast<std::uint8_t>(mode);
if (IsAirborne())
- flcs_mode = (BYTE) FLCS_MANUAL;
+ flcs_mode = static_cast<std::uint8_t>(FLCS_MANUAL);
if (dir && dir->Type() < SteerAI::SEEKER) {
switch (flcs_mode) {
@@ -4804,8 +4807,8 @@ Ship::ExecMaintFrame(double seconds)
// is it already too late?
if (life == 0 || integrity < 1) return;
- const DWORD REPAIR_FREQUENCY = 5000; // once every five seconds
- static DWORD last_repair_frame = 0; // one ship per game frame
+ const std::uint32_t REPAIR_FREQUENCY = 5000; // once every five seconds
+ static std::uint32_t last_repair_frame = 0; // one ship per game frame
if (auto_repair &&
Clock::GetInstance()->GameTime() - last_repair_time > REPAIR_FREQUENCY &&
@@ -5149,7 +5152,7 @@ Ship::SetEMCON(int e, bool from_net)
{
if (e < 1) emcon = 1;
else if (e > 3) emcon = 3;
- else emcon = (BYTE) e;
+ else emcon = static_cast<std::uint8_t>(e);
if (emcon != old_emcon && !from_net && NetGame::GetInstance())
NetUtil::SendObjEmcon(this);
@@ -5189,7 +5192,7 @@ Ship::ACS() const
return acs;
}
-DWORD
+std::uint32_t
Ship::MissionClock() const
{
if (launch_time > 0)
diff --git a/StarsEx/Ship.h b/StarsEx/Ship.h
index cdf38bd..2e04cba 100644
--- a/StarsEx/Ship.h
+++ b/StarsEx/Ship.h
@@ -11,15 +11,16 @@
Starship (or space/ground station) class
*/
-#ifndef Ship_h
-#define Ship_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
-#include "Types.h"
#include "SimObject.h"
#include "DetailSet.h"
#include "Director.h"
#include "Geometry.h"
-#include "List.h"
// +--------------------------------------------------------------------+
@@ -150,9 +151,9 @@ public:
virtual void SetNetworkControl(Director* net_ctrl=0);
void SetDirectorInfo(const char* msg) { director_info = msg; }
const char* GetDirectorInfo() const { return director_info; }
- void SetAIMode(int n) { ai_mode = (BYTE) n; }
+ void SetAIMode(int n) { ai_mode = static_cast<std::uint8_t>(n); }
int GetAIMode() const { return (int) ai_mode; }
- void SetCommandAILevel(int n) { command_ai_level = (BYTE) n; }
+ void SetCommandAILevel(int n) { command_ai_level = static_cast<std::uint8_t>(n); }
int GetCommandAILevel() const { return command_ai_level; }
virtual int GetFlightPhase() const { return flight_phase; }
virtual void SetFlightPhase(OP_MODE phase);
@@ -301,7 +302,7 @@ public:
virtual double InflictSystemDamage(double damage, Shot* shot, Point impact);
virtual void InflictNetDamage(double damage, Shot* shot=0);
- virtual void InflictNetSystemDamage(System* system, double damage, BYTE type);
+ virtual void InflictNetSystemDamage(System* system, double damage, std::uint8_t type);
virtual void SetNetSystemStatus(System* system, int status, int power, int reactor, double avail);
virtual void SetIntegrity(float n) { integrity = n; }
@@ -354,7 +355,7 @@ public:
void SetFriendlyFire(int f);
void IncFriendlyFire(int f=1);
double Agility() const { return agility; }
- DWORD MissionClock() const;
+ std::uint32_t MissionClock() const;
Graphic* Cockpit() const;
void ShowCockpit();
void HideCockpit();
@@ -520,19 +521,19 @@ protected:
Vec3 bridge_vec;
const char* director_info;
- BYTE ai_mode;
- BYTE command_ai_level;
- BYTE flcs_mode;
+ std::uint8_t ai_mode;
+ std::uint8_t command_ai_level;
+ std::uint8_t flcs_mode;
bool net_observer_mode;
float pcs; // passive sensor cross section
float acs; // active sensor cross section
- BYTE emcon;
- BYTE old_emcon;
+ std::uint8_t emcon;
+ std::uint8_t old_emcon;
bool invulnerable;
- DWORD launch_time;
- DWORD friendly_fire_time;
+ std::uint32_t launch_time;
+ std::uint32_t friendly_fire_time;
Ship* carrier;
FlightDeck* dock;
@@ -542,7 +543,7 @@ protected:
Point* track;
int ntrack;
- DWORD track_time;
+ std::uint32_t track_time;
float helm_heading;
float helm_pitch;
@@ -560,13 +561,13 @@ protected:
bool master_caution;
bool auto_repair;
- DWORD last_repair_time;
- DWORD last_eval_time;
- DWORD last_beam_time;
- DWORD last_bolt_time;
+ std::uint32_t last_repair_time;
+ std::uint32_t last_eval_time;
+ std::uint32_t last_beam_time;
+ std::uint32_t last_bolt_time;
int missile_id[4];
- BYTE missile_eta[4];
+ std::uint8_t missile_eta[4];
bool trigger[4];
int* loadout;
@@ -577,6 +578,3 @@ protected:
static int landing_model;
static double friendly_fire_level;
};
-
-#endif // Ship_h
-
diff --git a/StarsEx/ShipAI.cpp b/StarsEx/ShipAI.cpp
index bc0fc76..de95a6d 100644
--- a/StarsEx/ShipAI.cpp
+++ b/StarsEx/ShipAI.cpp
@@ -12,31 +12,31 @@
*/
#include "ShipAI.h"
-#include "TacticalAI.h"
-#include "Ship.h"
-#include "ShipDesign.h"
-#include "Shot.h"
+
+#include "Asteroid.h"
+#include "Clock.h"
+#include "Contact.h"
+#include "ContentBundle.h"
+#include "Debris.h"
+#include "Drive.h"
#include "Element.h"
-#include "NavLight.h"
+#include "Farcaster.h"
+#include "FlightComp.h"
#include "Instruction.h"
+#include "NavLight.h"
+#include "Player.h"
+#include "QuantumDrive.h"
#include "RadioMessage.h"
#include "RadioTraffic.h"
-#include "Contact.h"
-#include "WeaponGroup.h"
-#include "Drive.h"
+#include "Random.h"
#include "Shield.h"
+#include "ShipDesign.h"
+#include "Ship.h"
+#include "Shot.h"
#include "Sim.h"
-#include "Player.h"
#include "StarSystem.h"
-#include "FlightComp.h"
-#include "Farcaster.h"
-#include "QuantumDrive.h"
-#include "Debris.h"
-#include "Asteroid.h"
-
-#include "Clock.h"
-#include "ContentBundle.h"
-#include "Random.h"
+#include "TacticalAI.h"
+#include "WeaponGroup.h"
// +----------------------------------------------------------------------+
diff --git a/StarsEx/ShipAI.h b/StarsEx/ShipAI.h
index e706c4b..2bf037b 100644
--- a/StarsEx/ShipAI.h
+++ b/StarsEx/ShipAI.h
@@ -11,10 +11,10 @@
Common base class and interface for low-level ship AI
*/
-#ifndef ShipAI_h
-#define ShipAI_h
+#pragma once
+
+#include <cstdint>
-#include "Types.h"
#include "SteerAI.h"
// +--------------------------------------------------------------------+
@@ -131,8 +131,8 @@ protected:
double seconds;
double drop_time;
double brake;
- DWORD last_avoid_time;
- DWORD last_call_time;
+ std::uint32_t last_avoid_time;
+ std::uint32_t last_call_time;
int element_index;
int too_close;
@@ -145,8 +145,3 @@ protected:
Point patrol_loc;
int ai_level;
};
-
-// +--------------------------------------------------------------------+
-
-#endif // ShipAI_h
-
diff --git a/StarsEx/Sim.cpp b/StarsEx/Sim.cpp
index 23b01c9..bdf843b 100644
--- a/StarsEx/Sim.cpp
+++ b/StarsEx/Sim.cpp
@@ -12,71 +12,72 @@
*/
#include "Sim.h"
-#include "SimEvent.h"
-#include "SimObject.h"
-#include "Starshatter.h"
-#include "StarSystem.h"
+
+#include <cstdint>
+
+#include "Asteroid.h"
+#include "AudioConfig.h"
+#include "Bitmap.h"
+#include "Bolt.h"
+#include "Callsign.h"
+#include "CameraDirector.h"
+#include "Clock.h"
+#include "Combatant.h"
+#include "CombatGroup.h"
+#include "CombatUnit.h"
#include "Contact.h"
-#include "Ship.h"
-#include "ShipDesign.h"
-#include "Element.h"
-#include "Instruction.h"
-#include "RadioTraffic.h"
-#include "Shot.h"
-#include "Drone.h"
-#include "Explosion.h"
+#include "ContentBundle.h"
#include "Debris.h"
-#include "Asteroid.h"
#include "Drive.h"
-#include "QuantumDrive.h"
-#include "Sensor.h"
-#include "NavLight.h"
-#include "Shield.h"
-#include "Weapon.h"
-#include "WeaponGroup.h"
-#include "Hangar.h"
+#include "Drone.h"
+#include "Element.h"
+#include "Explosion.h"
#include "FlightDeck.h"
-#include "Sky.h"
+#include "Game.h"
+#include "GameScreen.h"
#include "Grid.h"
+#include "Hangar.h"
+#include "HUDView.h"
+#include "Instruction.h"
+#include "Light.h"
#include "Mfd.h"
-#include "AudioConfig.h"
-#include "Mission.h"
#include "MissionEvent.h"
-#include "CameraDirector.h"
+#include "Mission.h"
+#include "MouseController.h"
#include "MusicDirector.h"
-#include "Combatant.h"
-#include "CombatGroup.h"
-#include "CombatUnit.h"
-#include "HUDView.h"
-#include "SeekerAI.h"
-#include "ShipAI.h"
-#include "Power.h"
-#include "Callsign.h"
-#include "GameScreen.h"
-#include "Terrain.h"
-#include "TerrainPatch.h"
-
-#include "NetGame.h"
+#include "NavLight.h"
#include "NetClientConfig.h"
-#include "NetServerConfig.h"
+#include "NetData.h"
+#include "NetGame.h"
#include "NetPlayer.h"
+#include "NetServerConfig.h"
#include "NetUtil.h"
-#include "NetData.h"
-
-#include "Game.h"
-#include "Clock.h"
-#include "ContentBundle.h"
-#include "Sound.h"
-#include "Bolt.h"
-#include "Solid.h"
-#include "Sprite.h"
-#include "Light.h"
-#include "Bitmap.h"
#include "ParseUtil.h"
-#include "MouseController.h"
#include "Player.h"
+#include "Power.h"
+#include "QuantumDrive.h"
+#include "RadioTraffic.h"
#include "Random.h"
+#include "SeekerAI.h"
+#include "Sensor.h"
+#include "Shield.h"
+#include "ShipAI.h"
+#include "ShipDesign.h"
+#include "Ship.h"
+#include "Shot.h"
+#include "SimEvent.h"
+#include "SimObject.h"
+#include "Sky.h"
+#include "Solid.h"
+#include "Sound.h"
+#include "Sprite.h"
+#include "Starshatter.h"
+#include "StarSystem.h"
+#include "Terrain.h"
+#include "TerrainPatch.h"
#include "Video.h"
+#include "WeaponGroup.h"
+#include "Weapon.h"
const char* FormatGameTime();
@@ -1048,7 +1049,7 @@ Sim::NetDockShip(Ship* ship, Ship* carrier, FlightDeck* deck)
}
Ship*
-Sim::FindShipByObjID(DWORD objid)
+Sim::FindShipByObjID(std::uint32_t objid)
{
Ship* ship = 0;
@@ -1060,7 +1061,7 @@ Sim::FindShipByObjID(DWORD objid)
}
Shot*
-Sim::FindShotByObjID(DWORD objid)
+Sim::FindShotByObjID(std::uint32_t objid)
{
Shot* shot = 0;
@@ -3302,7 +3303,7 @@ SimRegion::FindShip(const char* ship_name)
}
Ship*
-SimRegion::FindShipByObjID(DWORD objid)
+SimRegion::FindShipByObjID(std::uint32_t objid)
{
Ship* ship = 0;
@@ -3317,7 +3318,7 @@ SimRegion::FindShipByObjID(DWORD objid)
}
Shot*
-SimRegion::FindShotByObjID(DWORD objid)
+SimRegion::FindShotByObjID(std::uint32_t objid)
{
Shot* shot = 0;
diff --git a/StarsEx/Sim.h b/StarsEx/Sim.h
index 912a420..6e5a0d4 100644
--- a/StarsEx/Sim.h
+++ b/StarsEx/Sim.h
@@ -11,16 +11,17 @@
Simulation Universe and Region classes
*/
-#ifndef Sim_h
-#define Sim_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
+#include <Text.h>
-#include "Types.h"
-#include "Universe.h"
-#include "Scene.h"
-#include "Physical.h"
#include "Geometry.h"
-#include "List.h"
-#include "Text.h"
+#include "Physical.h"
+#include "Scene.h"
+#include "Universe.h"
// +--------------------------------------------------------------------+
@@ -109,8 +110,8 @@ public:
void DestroyShip(Ship* ship);
void NetDockShip(Ship* ship, Ship* carrier, FlightDeck* deck);
- virtual Ship* FindShipByObjID(DWORD objid);
- virtual Shot* FindShotByObjID(DWORD objid);
+ virtual Ship* FindShipByObjID(std::uint32_t objid);
+ virtual Shot* FindShotByObjID(std::uint32_t objid);
Mission* GetMission() { return mission; }
List<MissionEvent>& GetEvents() { return events; }
@@ -166,7 +167,7 @@ public:
void ExecEvents(double seconds);
void ProcessEventTrigger(int type, int event_id=0, const char* ship=0, int param=0);
double MissionClock() const;
- DWORD StartTime() const { return start_time; }
+ std::uint32_t StartTime() const { return start_time; }
// Create a list of mission elements based on the current
// state of the simulation. Used for multiplayer join in progress.
@@ -206,7 +207,7 @@ protected:
Mission* mission;
NetGame* netgame;
- DWORD start_time;
+ std::uint32_t start_time;
};
// +--------------------------------------------------------------------+
@@ -243,8 +244,8 @@ public:
bool IsOrbital() const { return type == REAL_SPACE; }
bool CanTimeSkip()const;
- virtual Ship* FindShipByObjID(DWORD objid);
- virtual Shot* FindShotByObjID(DWORD objid);
+ virtual Ship* FindShipByObjID(std::uint32_t objid);
+ virtual Shot* FindShotByObjID(std::uint32_t objid);
virtual void InsertObject(Ship* ship);
virtual void InsertObject(Shot* shot);
@@ -321,9 +322,6 @@ protected:
List<Contact> track_database[5];
List<SimRegion> links;
- DWORD sim_time;
+ std::uint32_t sim_time;
int ai_index;
};
-
-#endif // Sim_h
-
diff --git a/StarsEx/SimObject.cpp b/StarsEx/SimObject.cpp
index 60c2295..8ee8db7 100644
--- a/StarsEx/SimObject.cpp
+++ b/StarsEx/SimObject.cpp
@@ -13,8 +13,8 @@
#include "SimObject.h"
-#include "Graphic.h"
-#include "Light.h"
+#include <List.h>
+
#include "Scene.h"
// +--------------------------------------------------------------------+
diff --git a/StarsEx/SimObject.h b/StarsEx/SimObject.h
index 0985e99..955a204 100644
--- a/StarsEx/SimObject.h
+++ b/StarsEx/SimObject.h
@@ -11,12 +11,13 @@
Simulation Object and Observer classes
*/
-#ifndef SimObject_h
-#define SimObject_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
-#include "Types.h"
#include "Physical.h"
-#include "List.h"
// +--------------------------------------------------------------------+
@@ -58,8 +59,8 @@ public:
virtual void Activate(Scene& scene);
virtual void Deactivate(Scene& scene);
- virtual DWORD GetObjID() const { return objid; }
- virtual void SetObjID(DWORD id) { objid = id; }
+ virtual std::uint32_t GetObjID() const { return objid; }
+ virtual void SetObjID(std::uint32_t id) { objid = id; }
virtual bool IsHostileTo(const SimObject* o)
const { return false; }
@@ -67,7 +68,7 @@ public:
protected:
SimRegion* region;
List<SimObserver> observers;
- DWORD objid;
+ std::uint32_t objid;
bool active;
bool notifying;
};
@@ -93,6 +94,3 @@ public:
protected:
List<SimObject> observe_list;
};
-
-#endif // SimObject_h
-
diff --git a/StarsEx/Starshatter.h b/StarsEx/Starshatter.h
index f6e5cfd..8b8b41f 100644
--- a/StarsEx/Starshatter.h
+++ b/StarsEx/Starshatter.h
@@ -7,14 +7,16 @@
*/
-#ifndef Starshatter_h
-#define Starshatter_h
+#pragma once
+
+#include <cstdint>
+
+#include <Text.h>
#include "Types.h"
#include "GameWinDX9.h"
#include "Bitmap.h"
#include "KeyMap.h"
-#include "Text.h"
// +--------------------------------------------------------------------+
@@ -164,8 +166,8 @@ protected:
Font* limerick12;
Font* ocrb;
- DWORD time_mark;
- DWORD minutes;
+ std::uint32_t time_mark;
+ std::uint32_t minutes;
double field_of_view;
double orig_fov;
@@ -206,5 +208,3 @@ protected:
private:
static Starshatter* instance;
};
-
-#endif // Starshatter_h
diff --git a/StarsEx/StarshipAI.cpp b/StarsEx/StarshipAI.cpp
index 8b10a49..1de816e 100644
--- a/StarsEx/StarshipAI.cpp
+++ b/StarsEx/StarshipAI.cpp
@@ -12,6 +12,9 @@
*/
#include "StarshipAI.h"
+
+#include <cstdint>
+
#include "StarshipTacticalAI.h"
#include "Ship.h"
#include "ShipDesign.h"
@@ -27,7 +30,6 @@
#include "FlightComp.h"
#include "Farcaster.h"
#include "QuantumDrive.h"
-
#include "Clock.h"
#include "ContentBundle.h"
#include "Random.h"
@@ -65,7 +67,7 @@ StarshipAI::StarshipAI(SimObject* s)
tactical = new StarshipTacticalAI(this);
}
- sub_select_time = Clock::GetInstance()->GameTime() + (DWORD) Random(0, 2000);
+ sub_select_time = Clock::GetInstance()->GameTime() + static_cast<std::uint32_t>(Random(0, 2000));
point_defense_time = sub_select_time;
}
diff --git a/StarsEx/StarshipAI.h b/StarsEx/StarshipAI.h
index d84380e..a186997 100644
--- a/StarsEx/StarshipAI.h
+++ b/StarsEx/StarshipAI.h
@@ -11,13 +11,12 @@
Starship (low-level) Artifical Intelligence class
*/
-#ifndef StarshipAI_h
-#define StarshipAI_h
+#pragma once
+
+#include <cstdint>
-#include "Types.h"
#include "ShipAI.h"
-// +--------------------------------------------------------------------+
class StarshipAI : public ShipAI
{
@@ -49,13 +48,8 @@ protected:
System* SelectSubtarget();
bool AssessTargetPointDefense();
- DWORD sub_select_time;
- DWORD point_defense_time;
+ std::uint32_t sub_select_time;
+ std::uint32_t point_defense_time;
System* subtarget;
bool tgt_point_defense;
};
-
-// +--------------------------------------------------------------------+
-
-#endif // StarshipAI_h
-
diff --git a/StarsEx/StarshipTacticalAI.h b/StarsEx/StarshipTacticalAI.h
index afe2616..17e7f05 100644
--- a/StarsEx/StarshipTacticalAI.h
+++ b/StarsEx/StarshipTacticalAI.h
@@ -11,13 +11,12 @@
Starship-specific mid-level (tactical) AI
*/
-#ifndef StarshipTacticalAI_h
-#define StarshipTacticalAI_h
+#pragma once
+
+#include <cstdint>
-#include "Types.h"
#include "TacticalAI.h"
-// +--------------------------------------------------------------------+
class StarshipTacticalAI : public TacticalAI
{
@@ -33,14 +32,9 @@ protected:
virtual void CheckBugOut(Ship* c_ship, double range);
- DWORD THREAT_REACTION_TIME;
+ std::uint32_t THREAT_REACTION_TIME;
int ai_level;
double drop_time;
double initial_integrity;
bool bugout;
};
-
-// +--------------------------------------------------------------------+
-
-#endif // StarshipTacticalAI_h
-
diff --git a/StarsEx/SteerAI.h b/StarsEx/SteerAI.h
index d33e492..0f5c887 100644
--- a/StarsEx/SteerAI.h
+++ b/StarsEx/SteerAI.h
@@ -11,13 +11,11 @@
Steering (low-level) Artifical Intelligence class
*/
-#ifndef SteerAI_h
-#define SteerAI_h
+#pragma once
-#include "Types.h"
-#include "SimObject.h"
#include "Director.h"
#include "Geometry.h"
+#include "SimObject.h"
// +--------------------------------------------------------------------+
@@ -109,16 +107,10 @@ protected:
Steer accumulator;
double magnitude;
- DWORD evade_time;
+ std::uint32_t evade_time;
double seek_gain;
double seek_damp;
int ai_type;
};
-
-
-// +--------------------------------------------------------------------+
-
-#endif // SteerAI_h
-
diff --git a/StarsEx/System.h b/StarsEx/System.h
index 70262a8..1652d59 100644
--- a/StarsEx/System.h
+++ b/StarsEx/System.h
@@ -11,15 +11,13 @@
Generic ship System class
*/
-#ifndef System_h
-#define System_h
+#pragma once
-#include "Types.h"
-#include "Physical.h"
-#include "Geometry.h"
+#include <List.h>
+#include <Text.h>
-#include "List.h"
-#include "Text.h"
+#include "Geometry.h"
+#include "Physical.h"
// +--------------------------------------------------------------------+
@@ -157,10 +155,10 @@ protected:
float sink_rate;
float power_level;
int source_index;
- DWORD power_flags;
+ std::uint32_t power_flags;
bool power_on;
- BYTE emcon_power[3];
- BYTE emcon;
+ std::uint8_t emcon_power[3];
+ std::uint8_t emcon;
int explosion_type;
@@ -168,6 +166,3 @@ protected:
SystemDesign* design;
List<Component> components;
};
-
-#endif // System_h
-
diff --git a/StarsEx/Thruster.cpp b/StarsEx/Thruster.cpp
index 16f3710..3d80a30 100644
--- a/StarsEx/Thruster.cpp
+++ b/StarsEx/Thruster.cpp
@@ -12,25 +12,27 @@
*/
#include "Thruster.h"
+
+#include <cstdint>
+
+#include "AudioConfig.h"
+#include "Bitmap.h"
+#include "Bolt.h"
+#include "CameraDirector.h"
#include "Component.h"
+#include "ContentBundle.h"
+#include "DataLoader.h"
#include "Drive.h"
#include "FlightComp.h"
-#include "SystemDesign.h"
-#include "Ship.h"
+#include "Game.h"
+#include "Light.h"
+#include "Random.h"
#include "ShipDesign.h"
+#include "Ship.h"
#include "Sim.h"
-#include "CameraDirector.h"
-#include "AudioConfig.h"
-#include "Random.h"
-
-#include "Light.h"
-#include "Bitmap.h"
#include "Sound.h"
-#include "DataLoader.h"
-#include "ContentBundle.h"
-#include "Bolt.h"
#include "Sprite.h"
-#include "Game.h"
+#include "SystemDesign.h"
// +----------------------------------------------------------------------+
@@ -44,7 +46,7 @@ extern Bitmap* drive_trail_bitmap[8];
// +----------------------------------------------------------------------+
-ThrusterPort::ThrusterPort(int t, const Point& l, DWORD f, float s)
+ThrusterPort::ThrusterPort(int t, const Point& l, std::uint32_t f, float s)
: type(t), loc(l), flare(0), trail(0), fire(f), burn(0), scale(s)
{ }
@@ -498,7 +500,7 @@ Thruster::ExecTrans(double x, double y, double z)
// +--------------------------------------------------------------------+
void
-Thruster::AddPort(int type, const Point& loc, DWORD fire, float flare_scale)
+Thruster::AddPort(int type, const Point& loc, std::uint32_t fire, float flare_scale)
{
if (flare_scale == 0) flare_scale = scale;
ThrusterPort* port = new ThrusterPort(type, loc, fire, flare_scale);
@@ -506,7 +508,7 @@ Thruster::AddPort(int type, const Point& loc, DWORD fire, float flare_scale)
}
void
-Thruster::CreatePort(int type, const Point& loc, DWORD fire, float flare_scale)
+Thruster::CreatePort(int type, const Point& loc, std::uint32_t fire, float flare_scale)
{
Bitmap* flare_bmp = drive_flare_bitmap[subtype];
Bitmap* trail_bmp = drive_trail_bitmap[subtype];
diff --git a/StarsEx/Thruster.h b/StarsEx/Thruster.h
index ea98fd9..c64de31 100644
--- a/StarsEx/Thruster.h
+++ b/StarsEx/Thruster.h
@@ -11,10 +11,12 @@
Conventional Thruster (system) class
*/
-#ifndef Thruster_h
-#define Thruster_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
-#include "Types.h"
#include "System.h"
#include "Geometry.h"
@@ -27,11 +29,11 @@ class Ship;
struct ThrusterPort {
static const char* TYPENAME() { return "ThrusterPort"; }
- ThrusterPort(int t, const Point& l, DWORD f, float s);
+ ThrusterPort(int t, const Point& l, std::uint32_t f, float s);
~ThrusterPort();
int type;
- DWORD fire;
+ std::uint32_t fire;
float burn;
float scale;
Point loc;
@@ -66,8 +68,8 @@ public:
virtual double TransYLimit();
virtual double TransZLimit();
- virtual void AddPort(int type, const Point& loc, DWORD fire, float flare_scale=0);
- virtual void CreatePort(int type, const Point& loc, DWORD fire, float flare_scale);
+ virtual void AddPort(int type, const Point& loc, std::uint32_t fire, float flare_scale=0);
+ virtual void CreatePort(int type, const Point& loc, std::uint32_t fire, float flare_scale);
int NumThrusters() const;
Graphic* Flare(int engine) const;
@@ -91,6 +93,3 @@ protected:
List<ThrusterPort> ports;
};
-
-#endif // Thruster_h
-
diff --git a/StarsEx/Weapon.cpp b/StarsEx/Weapon.cpp
index 77ac1fa..5316831 100644
--- a/StarsEx/Weapon.cpp
+++ b/StarsEx/Weapon.cpp
@@ -12,21 +12,25 @@
*/
#include "Weapon.h"
-#include "Shot.h"
-#include "Drone.h"
-#include "Contact.h"
-#include "Ship.h"
-#include "Sim.h"
-#include "SimEvent.h"
-#include "Random.h"
-#include "NetGame.h"
-#include "NetUtil.h"
+#include <cstdint>
+
+#include <List.h>
-#include "Game.h"
#include "Clock.h"
+#include "Contact.h"
#include "ContentBundle.h"
+#include "Drone.h"
+#include "Game.h"
+#include "NetGame.h"
+#include "NetUtil.h"
+#include "Random.h"
+#include "Ship.h"
+#include "Shot.h"
+#include "SimEvent.h"
+#include "Sim.h"
#include "Solid.h"
+#include "System.h"
// +----------------------------------------------------------------------+
@@ -440,7 +444,7 @@ Weapon::SetSweep(int s)
// +--------------------------------------------------------------------+
bool
-Weapon::CanTarget(DWORD classification) const
+Weapon::CanTarget(std::uint32_t classification) const
{
return (design->target_type & classification) ? true : false;
}
@@ -694,7 +698,7 @@ Weapon::NetFirePrimary(SimObject* tgt, System* sub, int count)
}
Shot*
-Weapon::NetFireSecondary(SimObject* tgt, System* sub, DWORD objid)
+Weapon::NetFireSecondary(SimObject* tgt, System* sub, std::uint32_t objid)
{
Shot* shot = 0;
@@ -1145,7 +1149,7 @@ Weapon::CanLockPoint(const Point& test, double& az, double& el, Point* obj)
void
Weapon::AimTurret(double az, double el)
{
- double seconds = (Clock::GetInstance()->GameTime() - aim_time) / 1000.0;
+ const auto seconds = static_cast<double>(Clock::GetInstance()->GameTime() - aim_time) / 1000.0;
// don't let the weapon turn faster than turret slew rate:
double max_turn = design->slew_rate * seconds;
diff --git a/StarsEx/Weapon.h b/StarsEx/Weapon.h
index 082abb2..4fadd80 100644
--- a/StarsEx/Weapon.h
+++ b/StarsEx/Weapon.h
@@ -11,15 +11,16 @@
Weapon (gun or missile launcher) class
*/
-#ifndef Weapon_h
-#define Weapon_h
+#pragma once
+
+#include <cstdint>
+
+#include "Text.h"
-#include "Types.h"
#include "SimObject.h"
#include "System.h"
#include "WeaponDesign.h"
#include "Geometry.h"
-#include "Text.h"
// +--------------------------------------------------------------------+
@@ -50,10 +51,10 @@ public:
int Track(SimObject* targ, System* sub);
Shot* Fire();
Shot* NetFirePrimary(SimObject* targ, System* sub, int count);
- Shot* NetFireSecondary(SimObject* targ, System* sub, DWORD objid);
+ Shot* NetFireSecondary(SimObject* targ, System* sub, std::uint32_t objid);
void SetTarget(SimObject* t, System* sub);
void SelectTarget();
- bool CanTarget(DWORD classification) const;
+ bool CanTarget(std::uint32_t classification) const; // TODO
SimObject* GetTarget() const { return target; }
System* GetSubTarget() const { return subtarget; }
void SetFiringOrders(int o);
@@ -194,10 +195,7 @@ protected:
float aim_el_min; // minimum deflection in elevation
float aim_el_rest; // elevation of turret at rest
- DWORD aim_time;
+ std::uint32_t aim_time;
Shot** beams;
};
-
-#endif // Weapon_h
-
diff --git a/StarsEx/WeaponDesign.cpp b/StarsEx/WeaponDesign.cpp
index ff26ec1..12a2ed3 100644
--- a/StarsEx/WeaponDesign.cpp
+++ b/StarsEx/WeaponDesign.cpp
@@ -12,19 +12,18 @@
*/
#include "WeaponDesign.h"
-#include "ShipDesign.h"
-#include "Weapon.h"
-#include "Game.h"
+#include "Bitmap.h"
#include "ContentBundle.h"
-#include "Sprite.h"
+#include "DataLoader.h"
+#include "Game.h"
#include "Light.h"
-#include "Bitmap.h"
+#include "ParseUtil.h"
+#include "ShipDesign.h"
#include "Solid.h"
#include "Sound.h"
-#include "DataLoader.h"
-
-#include "ParseUtil.h"
+#include "Sprite.h"
+#include "Weapon.h"
// +--------------------------------------------------------------------+
diff --git a/StarsEx/WeaponDesign.h b/StarsEx/WeaponDesign.h
index 4fa97d4..74529a6 100644
--- a/StarsEx/WeaponDesign.h
+++ b/StarsEx/WeaponDesign.h
@@ -11,14 +11,15 @@
Weapon (gun or missile launcher) Design parameters class
*/
-#ifndef WeaponDesign_h
-#define WeaponDesign_h
+#pragma once
+
+#include <cstdint>
+
+#include <List.h>
+#include <Text.h>
-#include "Types.h"
-#include "Geometry.h"
#include "Color.h"
-#include "List.h"
-#include "Text.h"
+#include "Geometry.h"
// +--------------------------------------------------------------------+
@@ -71,7 +72,7 @@ public:
int value; // AI importance of system
int decoy_type; // Ship Classifcation of decoy signature
bool probe; // is sensor probe?
- DWORD target_type; // bitmask of acceptable target classes
+ std::uint32_t target_type; // bitmask of acceptable target classes
// for turrets:
Vec3 muzzle_pts[MAX_STORES]; // default turret muzzle points
@@ -181,6 +182,3 @@ public:
private:
static void LoadDesign(const char* path, const char* filename, bool mod=false);
};
-
-#endif // WeaponDesign_h
-
diff --git a/StarsEx/WeaponGroup.cpp b/StarsEx/WeaponGroup.cpp
index 70fe18f..98ba0b8 100644
--- a/StarsEx/WeaponGroup.cpp
+++ b/StarsEx/WeaponGroup.cpp
@@ -12,7 +12,15 @@
*/
#include "WeaponGroup.h"
-#include "Ship.h"
+
+#include <cstdint>
+
+#include <List.h>
+
+#include "SimObject.h"
+#include "System.h"
+#include "Weapon.h"
+
// +----------------------------------------------------------------------+
@@ -159,7 +167,7 @@ WeaponGroup::GetSelected() const
}
bool
-WeaponGroup::CanTarget(DWORD tgt_class) const
+WeaponGroup::CanTarget(std::uint32_t tgt_class) const
{
if (selected >= 0 && selected < weapons.size())
return weapons[selected]->CanTarget(tgt_class);
diff --git a/StarsEx/WeaponGroup.h b/StarsEx/WeaponGroup.h
index a35ba76..3edad1d 100644
--- a/StarsEx/WeaponGroup.h
+++ b/StarsEx/WeaponGroup.h
@@ -11,12 +11,15 @@
Weapon Control Category (Group) class
*/
-#ifndef WeaponGroup_h
-#define WeaponGroup_h
+#pragma once
-#include "Types.h"
+#include <cstdint>
+
+#include <Text.h>
+
+#include "SimObject.h"
+#include "System.h"
#include "Weapon.h"
-#include "Text.h"
// +--------------------------------------------------------------------+
@@ -77,7 +80,7 @@ public:
int Status() const;
WeaponDesign* GetDesign() const;
- bool CanTarget(DWORD tgt_class) const;
+ bool CanTarget(std::uint32_t tgt_class) const;
void PowerOn();
void PowerOff();
@@ -100,6 +103,3 @@ protected:
float mass;
float resist;
};
-
-#endif // WeaponGroup_h
-