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.
This commit is contained in:
Simon Howard 2017-09-28 08:48:23 -04:00
parent 73a1d06182
commit 2855c1081f
3 changed files with 8 additions and 6 deletions

View file

@ -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 @@ boolean NET_ValidGameSettings(GameMode_t mode, GameMission_t mission,
return true;
}
static net_protocol_t ParseProtocolName(char *name)
static net_protocol_t ParseProtocolName(const char *name)
{
int i;
@ -500,7 +502,7 @@ static net_protocol_t ParseProtocolName(char *name)
// 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 @@ net_protocol_t NET_ReadProtocolList(net_packet_t *packet)
for (i = 0; i < num_protocols; ++i)
{
net_protocol_t p;
char *name;
const char *name;
name = NET_ReadString(packet);
if (name == NULL)

View file

@ -302,7 +302,7 @@ void NET_WriteInt32(net_packet_t *packet, unsigned int i)
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;

View file

@ -39,7 +39,7 @@ void NET_WriteInt8(net_packet_t *packet, unsigned int i);
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 */