ref: 2855c1081facf4812cc74a48c880bc8832b0ede1
parent: 73a1d06182b142d412cee5099ad619174604e6e4
author: Simon Howard <fraggle@soulsphere.org>
date: Thu Sep 28 04:48:23 EDT 2017
net: Make a bunch of things const. @turol pointed out in #943 that these should be marked as const. This requires fixing `NET_WriteString()` but is the right thing to do nonetheless.
--- a/src/net_common.c
+++ b/src/net_common.c
@@ -35,10 +35,12 @@
#define KEEPALIVE_PERIOD 1
+// String names for the enum values in net_protocol_t, which are what is
+// sent over the wire. Every enum value must have an entry in this list.
static struct
{
net_protocol_t protocol;
- char *name;
+ const char *name;
} protocol_names[] = {
{NET_PROTOCOL_CHOCOLATE_DOOM_0, "CHOCOLATE_DOOM_0"},
};
@@ -480,7 +482,7 @@
return true;
}
-static net_protocol_t ParseProtocolName(char *name)
+static net_protocol_t ParseProtocolName(const char *name)
{
int i;
@@ -500,7 +502,7 @@
// protocol.
net_protocol_t NET_ReadProtocol(net_packet_t *packet)
{
- char *name;
+ const char *name;
name = NET_ReadString(packet);
if (name == NULL)
@@ -551,7 +553,7 @@
for (i = 0; i < num_protocols; ++i)
{
net_protocol_t p;
- char *name;
+ const char *name;
name = NET_ReadString(packet);
if (name == NULL)
--- a/src/net_packet.c
+++ b/src/net_packet.c
@@ -302,7 +302,7 @@
packet->len += 4;
}
-void NET_WriteString(net_packet_t *packet, char *string)
+void NET_WriteString(net_packet_t *packet, const char *string)
{
byte *p;
size_t string_size;
--- a/src/net_packet.h
+++ b/src/net_packet.h
@@ -39,7 +39,7 @@
void NET_WriteInt16(net_packet_t *packet, unsigned int i);
void NET_WriteInt32(net_packet_t *packet, unsigned int i);
-void NET_WriteString(net_packet_t *packet, char *string);
+void NET_WriteString(net_packet_t *packet, const char *string);
#endif /* #ifndef NET_PACKET_H */