Even more conversion, lots of superfluous macro removal

This commit is contained in:
iikorni
2026-08-29 23:14:23 -05:00
parent 70e5c02355
commit de75b014b3
102 changed files with 7060 additions and 8179 deletions
+33 -31
View File
@@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <cstring>
#include "q_stdinc.hpp"
#include "arch_def.hpp"
#include "net_sys.hpp"
@@ -29,8 +31,8 @@ qsocket_t *net_activeSockets = NULL;
qsocket_t *net_freeSockets = NULL;
int net_numsockets = 0;
qboolean ipxAvailable = false;
qboolean tcpipAvailable = false;
bool ipxAvailable = false;
bool tcpipAvailable = false;
int net_hostport;
int DEFAULTnet_hostport = 26000;
@@ -38,11 +40,11 @@ int DEFAULTnet_hostport = 26000;
char my_ipx_address[NET_NAMELEN];
char my_tcpip_address[NET_NAMELEN];
static qboolean listening = false;
static bool listening = false;
qboolean slistInProgress = false;
qboolean slistSilent = false;
qboolean slistLocal = true;
bool slistInProgress = false;
bool slistSilent = false;
bool slistLocal = true;
static double slistStartTime;
static int slistLastShown;
@@ -106,7 +108,7 @@ qsocket_t *NET_NewQSocket(void) {
sock->disconnected = false;
sock->connecttime = net_time;
Q_strcpy(sock->address, "UNSET ADDRESS");
std::strcpy(sock->address, "UNSET ADDRESS");
sock->driver = net_driverlevel;
sock->socket = 0;
sock->driverdata = NULL;
@@ -166,7 +168,7 @@ static void NET_Listen_f(void) {
return;
}
listening = Q_atoi(command::argv(1)->c_str()) ? true : false;
listening = std::atoi(command::argv(1)->c_str()) ? true : false;
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
if (net_drivers[net_driverlevel].initialized == false)
@@ -189,7 +191,7 @@ static void MaxPlayers_f(void) {
return;
}
n = Q_atoi(command::argv(1)->c_str());
n = std::atoi(command::argv(1)->c_str());
if (n < 1)
n = 1;
if (n > svs.maxclientslimit) {
@@ -198,10 +200,10 @@ static void MaxPlayers_f(void) {
}
if ((n == 1) && listening)
Cbuf_AddText("listen 0\n");
command::buffer::add_text("listen 0\n");
if ((n > 1) && (!listening))
Cbuf_AddText("listen 1\n");
command::buffer::add_text("listen 1\n");
svs.maxclients = n;
if (n == 1)
@@ -219,7 +221,7 @@ static void NET_Port_f(void) {
return;
}
n = Q_atoi(command::argv(1)->c_str());
n = std::atoi(command::argv(1)->c_str());
if (n < 1 || n > 65534) {
Con_Printf("Bad value, must be between 1 and 65534\n");
return;
@@ -230,8 +232,8 @@ static void NET_Port_f(void) {
if (listening) {
// force a change to the new port
Cbuf_AddText("listen 0\n");
Cbuf_AddText("listen 1\n");
command::buffer::add_text("listen 0\n");
command::buffer::add_text("listen 1\n");
}
}
@@ -596,7 +598,7 @@ Returns true or false if the given qsocket can currently accept a
message to be transmitted.
==================
*/
qboolean NET_CanSendMessage(qsocket_t *sock) {
bool NET_CanSendMessage(qsocket_t *sock) {
if (!sock)
return false;
@@ -613,8 +615,8 @@ int NET_SendToAll(sizebuf_t *data, double blocktime) {
double start;
int i;
int count = 0;
qboolean msg_init[MAX_SCOREBOARD]; /* did we write the message to the client's connection */
qboolean msg_sent[MAX_SCOREBOARD]; /* did the msg arrive its destination (canSend state). */
bool msg_init[MAX_SCOREBOARD]; /* did we write the message to the client's connection */
bool msg_sent[MAX_SCOREBOARD]; /* did the msg arrive its destination (canSend state). */
for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) {
/*
@@ -679,18 +681,17 @@ NET_Init
*/
void NET_Init(void) {
int i;
qsocket_t *s;
i = COM_CheckParm("-port");
if (!i)
i = COM_CheckParm("-udpport");
if (!i)
i = COM_CheckParm("-ipxport");
auto port = common::check_param("-port");
if (!port.has_value())
port = common::check_param("-udpport");
if (!port.has_value())
port = common::check_param("-ipxport");
if (i) {
if (i < com_argc - 1)
DEFAULTnet_hostport = Q_atoi(com_argv[i + 1]);
if (port.has_value()) {
if (port < com_argc - 1)
DEFAULTnet_hostport = std::atoi(com_argv[port.value() + 1]);
else
Sys_Error("NET_Init: you must specify a number after -port");
}
@@ -699,12 +700,12 @@ void NET_Init(void) {
net_numsockets = svs.maxclientslimit;
if (cls.state != ca_dedicated)
net_numsockets++;
if (COM_CheckParm("-listen") || cls.state == ca_dedicated)
if (common::check_param("-listen").has_value() || cls.state == ca_dedicated)
listening = true;
SetNetTime();
for (i = 0; i < net_numsockets; i++) {
for (auto i = 0; i < net_numsockets; i++) {
s = (qsocket_t *) Hunk_AllocName(sizeof(qsocket_t), "qsocket");
s->next = net_freeSockets;
net_freeSockets = s;
@@ -722,11 +723,12 @@ void NET_Init(void) {
command::add("maxplayers", MaxPlayers_f);
command::add("port", NET_Port_f);
int lvl;
// initialize all the drivers
for (i = net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
for (lvl = net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
if (net_drivers[net_driverlevel].Init() == -1)
continue;
i++;
lvl++;
net_drivers[net_driverlevel].initialized = true;
if (listening)
net_drivers[net_driverlevel].Listen(true);
@@ -734,7 +736,7 @@ void NET_Init(void) {
/* Loop_Init() returns -1 for dedicated server case,
* therefore the i == 0 check is correct */
if (i == 0
if (lvl == 0
&& cls.state == ca_dedicated
) {
Sys_Error("Network not available!");