]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
protocol: Add max_edicts field to protocol_t. Set server limit_edicts from it
authorCloudwalk <cloudwalk009@gmail.com>
Wed, 23 Sep 2020 14:02:04 +0000 (10:02 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Wed, 23 Sep 2020 14:02:04 +0000 (10:02 -0400)
protocol.c
protocol.h
sv_main.c

index 21db9f03334481766aa2766c2701f6fb63270523..306761bc377e9fc6d6641b8da017f739e0332848 100644 (file)
@@ -43,6 +43,7 @@ protocol_t protocol_netquake =
 {
        .name = "QUAKE",
        .num = 15,
+       .max_edicts = 640,
        .WriteCoord = MSG_WriteCoord13i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector13i,
@@ -59,6 +60,7 @@ protocol_t protocol_quakedp =
 {
        .name = "QUAKEDP",
        .num = 15,
+       .max_edicts = 2048,
        .WriteCoord = MSG_WriteCoord13i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector13i,
@@ -91,6 +93,7 @@ protocol_t protocol_dpp1 =
 {
        .name = "DP1",
        .num = 96,
+       .max_edicts = MAX_EDICTS,
        .WriteCoord = MSG_WriteCoord32f,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector32f,
@@ -107,6 +110,7 @@ protocol_t protocol_dpp2 =
 {
        .name = "DP2",
        .num = 97,
+       .max_edicts = MAX_EDICTS,
        .WriteCoord = MSG_WriteCoord16i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector16i,
@@ -123,6 +127,7 @@ protocol_t protocol_dpp3 =
 {
        .name = "DP3",
        .num = 3500,
+       .max_edicts = MAX_EDICTS,
        .WriteCoord = MSG_WriteCoord16i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector16i,
@@ -139,6 +144,7 @@ protocol_t protocol_dpp4 =
 {
        .name = "DP4",
        .num = 3501,
+       .max_edicts = MAX_EDICTS,
        .WriteCoord = MSG_WriteCoord16i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector16i,
@@ -155,6 +161,7 @@ protocol_t protocol_dpp5 =
 {
        .name = "DP5",
        .num = 3502,
+       .max_edicts = MAX_EDICTS,
        .WriteCoord = MSG_WriteCoord32f,
        .WriteAngle = MSG_WriteAngle16i,
        .WriteVector = MSG_WriteVector32f,
@@ -171,6 +178,7 @@ protocol_t protocol_dpp6 =
 {
        .name = "DP6",
        .num = 3503,
+       .max_edicts = MAX_EDICTS,
        .WriteCoord = MSG_WriteCoord32f,
        .WriteAngle = MSG_WriteAngle16i,
        .WriteVector = MSG_WriteVector32f,
@@ -187,6 +195,7 @@ protocol_t protocol_dpp7 =
 {
        .name = "DP7",
        .num = 3504,
+       .max_edicts = MAX_EDICTS,
        .WriteCoord = MSG_WriteCoord32f,
        .WriteAngle = MSG_WriteAngle16i,
        .WriteVector = MSG_WriteVector32f,
@@ -204,6 +213,7 @@ protocol_t protocol_nehahramovie =
 {
        .name = "NEHAHRAMOVIE",
        .num = 250,
+       .max_edicts = 2048,
        .WriteCoord = MSG_WriteCoord13i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector13i,
@@ -220,6 +230,7 @@ protocol_t protocol_nehahrabjp =
 {
        .name = "NEHAHRABJP",
        .num = 10000,
+       .max_edicts = 4096,
        .WriteCoord = MSG_WriteCoord13i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector13i,
@@ -236,6 +247,7 @@ protocol_t protocol_nehahrabjp2 =
 {
        .name = "NEHAHRABJP2",
        .num = 10001,
+       .max_edicts = 4096,
        .WriteCoord = MSG_WriteCoord13i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector13i,
@@ -252,6 +264,7 @@ protocol_t protocol_nehahrabjp3 =
 {
        .name = "NEHAHRABJP3",
        .num = 10002,
+       .max_edicts = 4096,
        .WriteCoord = MSG_WriteCoord13i,
        .WriteAngle = MSG_WriteAngle8i,
        .WriteVector = MSG_WriteVector13i,
index 3df4f28e2540b82c0443bcf5d3bb6727bba20233..6e6730aab3ccbcf0828369e77de659d2964cbee9 100644 (file)
@@ -49,6 +49,8 @@ struct protocol_s
        const char *name;
        const int num;
 
+       const int max_edicts;
+
        void (*WriteCoord)(sizebuf_t *, float);
        void (*WriteAngle)(sizebuf_t *, float);
        void (*WriteVector)(sizebuf_t *, const vec3_t);
index 34a72b24bd9e544c3601053aa5423fb8362b180a..92adb2553d174e6d1e8aa730cbdcd6e3228219da 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -3909,16 +3909,7 @@ static void SV_VM_Setup(void)
        prog->builtins = vm_sv_builtins;
        prog->numbuiltins = vm_sv_numbuiltins;
        prog->max_edicts = 512;
-       if (sv.protocol == &protocol_netquake)
-               prog->limit_edicts = 640; // before quake mission pack 1 this was 512
-       else if (sv.protocol == &protocol_quakedp)
-               prog->limit_edicts = 2048; // guessing
-       else if (sv.protocol == &protocol_nehahramovie)
-               prog->limit_edicts = 2048; // guessing!
-       else if (sv.protocol == &protocol_nehahrabjp || sv.protocol == &protocol_nehahrabjp2 || sv.protocol == &protocol_nehahrabjp3)
-               prog->limit_edicts = 4096; // guessing!
-       else
-               prog->limit_edicts = MAX_EDICTS;
+       prog->limit_edicts = sv.protocol->max_edicts;
        prog->reserved_edicts = svs.maxclients;
        prog->edictprivate_size = sizeof(edict_engineprivate_t);
        prog->name = "server";