ref: 1bff98bbaca8cb7b639313947b5a8435efcb3ef2
parent: f5b82c7a8618c716e77568b979057dfe699561d4
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Oct 16 07:37:05 EDT 2023
sv_protocol: use protocol version instead of id
--- a/protocol.c
+++ b/protocol.c
@@ -34,7 +34,6 @@
protocol_t protos[PROTO_NUM] = {
[PROTO_NQ] = {
- .id = PROTO_NQ,
.name = "Quake",
.version = 15,
.limit_entity = 8192,
@@ -50,7 +49,6 @@
.MSG_ReadProtocolInfo = MSG_ReadProtocolInfoNQ,
},
[PROTO_RMQ] = {
- .id = PROTO_RMQ,
.name = "RMQ",
.version = 999,
.fl_large_entity = 1<<3, .large_entity = 8192, .limit_entity = 65536,
--- a/protocol.h
+++ b/protocol.h
@@ -15,7 +15,6 @@
typedef struct protocol_t protocol_t;
struct protocol_t {
- int id;
int version;
int flags;
char *name;
--- a/sv_main.c
+++ b/sv_main.c
@@ -19,16 +19,21 @@
static void
SV_Protocol_f(void)
{
- int n;
+ int i, n;
- n = Cmd_Argc();
- if(n == 1)
- Con_Printf("\"sv_protocol\" is \"%d\" (%s)\n", sv_protocol->id, sv_protocol->name);
- else if(n == 2){
- if((n = atoi(Cmd_Argv(1))) < PROTO_NQ || n >= PROTO_NUM)
- Con_Printf("sv_protocol must be of value from %d to %d\n", PROTO_NQ, PROTO_NUM-1);
- else{
- sv_protocol = &protos[n];
+ i = Cmd_Argc();
+ if(i == 1)
+ Con_Printf("\"sv_protocol\" is \"%d\" (%s)\n", sv_protocol->version, sv_protocol->name);
+ else if(i == 2){
+ n = atoi(Cmd_Argv(1));
+ for(i = 0; i < PROTO_NUM && n != protos[i].version; i++);
+ if(i >= PROTO_NUM){
+ Con_Printf("sv_protocol must be of values:");
+ for(i = 0; i < PROTO_NUM; i++)
+ Con_Printf(" %d", protos[i].version);
+ Con_Printf("\n");
+ }else{
+ sv_protocol = &protos[i];
if(sv.active)
Con_Printf("changes will take effect on the next game\n");
}