}
}
- if(cmd <= protocol->max_svcmsg && protocol->svcmsg[cmd].func)
+ if(cmd <= protocol->svc->size && protocol->svc->msg[cmd].func)
{
- SHOWNET(protocol->svcmsg[cmd].name);
- cmdlogname[cmdindex] = protocol->svcmsg[cmd].name;
+ SHOWNET(protocol->svc->msg[cmd].name);
+ cmdlogname[cmdindex] = protocol->svc->msg[cmd].name;
if (!cmdlogname[cmdindex])
{
// LadyHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
const char *d = "<unknown>";
cmdlogname[cmdindex] = d;
}
- protocol->svcmsg[cmd].func(protocol);
+ protocol->svc->msg[cmd].func(protocol);
}
else
{
#include "quakedef.h"
#include "cl_protocol_ext.h"
-protocol_netmsg_t netmsg_dpext_svc[] =
+protocol_netmsg_t netmsg_dpext_svc =
{
- NETMSG_DPEXT_SVC
+ .size = 62,
+ .msg = {NETMSG_DPEXT_SVC}
};
\ No newline at end of file
#include "protocol.h"
#include "cl_protocol_basenq.h"
-protocol_netmsg_t netmsg_nq_svc[] =
+protocol_netmsg_t netmsg_nq_svc =
{
- NETMSG_BASENQ_SVC
+ .size = 34,
+ .msg = {NETMSG_BASENQ_SVC}
};
#include "cl_protocol_baseqw.h"
-protocol_netmsg_t netmsg_qw_svc[] =
+protocol_netmsg_t netmsg_qw_svc =
{
- {"svc_bad", NULL}, // 0
- {"svc_nop", Netmsg_svc_nop}, // 1
- {"svc_disconnect", Netmsg_svc_disconnect}, // 2
- {"svc_updatestat", Netmsg_svc_updatestat}, // 3 // [byte] [byte]
- {"", NULL}, // 4
- {"svc_setview", NULL}, // 5 // [short] entity number
- {"svc_sound", Netmsg_svc_sound}, // 6 // <see code>
- {"", NULL}, // 7
- {"svc_print", Netmsg_svc_print}, // 8 // [byte] id [string] null terminated string
- {"svc_stufftext", Netmsg_svc_stufftext}, // 9 // [string] stuffed into client's console buffer
- {"svc_setangle", Netmsg_svc_setangle}, // 10 // [angle3] set the view angle to this absolute value
- {"svc_serverdata", Netmsg_svc_serverdata}, // 11 // [long] protocol ...
- {"svc_lightstyle", Netmsg_svc_lightstyle}, // 12 // [byte] [string]
- {"", NULL}, // 13
- {"svc_updatefrags", Netmsg_svc_updatefrags}, // 14 // [byte] [short]
- {"", NULL}, // 15
- {"svc_stopsound", Netmsg_svc_stopsound}, // 16 // <see code>
- {"", NULL}, // 17
- {"", NULL}, // 18
- {"svc_damage", Netmsg_svc_damage}, // 19
- {"svc_spawnstatic", Netmsg_svc_spawnstatic}, // 20
- {"", NULL}, // 21
- {"svc_spawnbaseline", Netmsg_svc_spawnbaseline}, // 22
- {"svc_temp_entity", Netmsg_svc_temp_entity}, // 23 // variable
- {"svc_setpause", Netmsg_svc_setpause}, // 24 // [byte] on / off
- {"", NULL}, // 25
- {"svc_centerprint", Netmsg_svc_centerprint}, // 26 // [string] to put in center of the screen
- {"svc_killedmonster", Netmsg_svc_killedmonster}, // 27
- {"svc_foundsecret", Netmsg_svc_foundsecret}, // 28
- {"svc_spawnstaticsound", Netmsg_svc_spawnstaticsound}, // 29 // [coord3] [byte] samp [byte] vol [byte] aten
- {"svc_intermission", Netmsg_svc_intermission}, // 30 // [vec3_t] origin [vec3_t] angle
- {"svc_finale", Netmsg_svc_finale}, // 31 // [string] text
- {"svc_cdtrack", Netmsg_svc_cdtrack}, // 32 // [byte] track
- {"svc_sellscreen", Netmsg_svc_sellscreen}, // 33
- {"svc_smallkick", Netmsg_svc_smallkick}, // 34 // set client punchangle to 2
- {"svc_bigkick", Netmsg_svc_bigkick}, // 35 // set client punchangle to 4
- {"svc_updateping", Netmsg_svc_updateping}, // 36 // [byte] [short]
- {"svc_updateentertime", Netmsg_svc_updateentertime}, // 37 // [byte] [float]
- {"svc_updatestatlong", Netmsg_svc_updatestatlong}, // 38 // [byte] [long]
- {"svc_muzzleflash", Netmsg_svc_muzzleflash}, // 39 // [short] entity
- {"svc_updateuserinfo", Netmsg_svc_updateuserinfo}, // 40 // [byte] slot [long] uid
- {"svc_download", Netmsg_svc_download}, // 41 // [short] size [size bytes]
- {"svc_playerinfo", Netmsg_svc_playerinfo}, // 42 // variable
- {"svc_nails", Netmsg_svc_nails}, // 43 // [byte] num [48 bits] xyzpy 12 12 12 4 8
- {"svc_chokecount", Netmsg_svc_chokecount}, // 44 // [byte] packets choked
- {"svc_modellist", Netmsg_svc_modellist}, // 45 // [strings]
- {"svc_soundlist", Netmsg_svc_soundlist}, // 46 // [strings]
- {"svc_packetentities", Netmsg_svc_packetentities}, // 47 // [...]
- {"svc_deltapacketentities", Netmsg_svc_deltapacketentities}, // 48 // [...]
- {"svc_maxspeed", Netmsg_svc_maxspeed}, // 49 // maxspeed change, for prediction
- {"svc_entgravity", Netmsg_svc_entgravity}, // 50 // gravity change, for prediction
- {"svc_setinfo", Netmsg_svc_setinfo}, // 51 // setinfo on a client
- {"svc_serverinfo", Netmsg_svc_serverinfo}, // 52 // serverinfo
- {"svc_updatepl", Netmsg_svc_updatepl} // 53 // [byte] [byte]
+ .size = 53,
+ .msg =
+ {
+ {"svc_bad", NULL}, // 0
+ {"svc_nop", Netmsg_svc_nop}, // 1
+ {"svc_disconnect", Netmsg_svc_disconnect}, // 2
+ {"svc_updatestat", Netmsg_svc_updatestat}, // 3 // [byte] [byte]
+ {"", NULL}, // 4
+ {"svc_setview", NULL}, // 5 // [short] entity number
+ {"svc_sound", Netmsg_svc_sound}, // 6 // <see code>
+ {"", NULL}, // 7
+ {"svc_print", Netmsg_svc_print}, // 8 // [byte] id [string] null terminated string
+ {"svc_stufftext", Netmsg_svc_stufftext}, // 9 // [string] stuffed into client's console buffer
+ {"svc_setangle", Netmsg_svc_setangle}, // 10 // [angle3] set the view angle to this absolute value
+ {"svc_serverdata", Netmsg_svc_serverdata}, // 11 // [long] protocol ...
+ {"svc_lightstyle", Netmsg_svc_lightstyle}, // 12 // [byte] [string]
+ {"", NULL}, // 13
+ {"svc_updatefrags", Netmsg_svc_updatefrags}, // 14 // [byte] [short]
+ {"", NULL}, // 15
+ {"svc_stopsound", Netmsg_svc_stopsound}, // 16 // <see code>
+ {"", NULL}, // 17
+ {"", NULL}, // 18
+ {"svc_damage", Netmsg_svc_damage}, // 19
+ {"svc_spawnstatic", Netmsg_svc_spawnstatic}, // 20
+ {"", NULL}, // 21
+ {"svc_spawnbaseline", Netmsg_svc_spawnbaseline}, // 22
+ {"svc_temp_entity", Netmsg_svc_temp_entity}, // 23 // variable
+ {"svc_setpause", Netmsg_svc_setpause}, // 24 // [byte] on / off
+ {"", NULL}, // 25
+ {"svc_centerprint", Netmsg_svc_centerprint}, // 26 // [string] to put in center of the screen
+ {"svc_killedmonster", Netmsg_svc_killedmonster}, // 27
+ {"svc_foundsecret", Netmsg_svc_foundsecret}, // 28
+ {"svc_spawnstaticsound", Netmsg_svc_spawnstaticsound}, // 29 // [coord3] [byte] samp [byte] vol [byte] aten
+ {"svc_intermission", Netmsg_svc_intermission}, // 30 // [vec3_t] origin [vec3_t] angle
+ {"svc_finale", Netmsg_svc_finale}, // 31 // [string] text
+ {"svc_cdtrack", Netmsg_svc_cdtrack}, // 32 // [byte] track
+ {"svc_sellscreen", Netmsg_svc_sellscreen}, // 33
+ {"svc_smallkick", Netmsg_svc_smallkick}, // 34 // set client punchangle to 2
+ {"svc_bigkick", Netmsg_svc_bigkick}, // 35 // set client punchangle to 4
+ {"svc_updateping", Netmsg_svc_updateping}, // 36 // [byte] [short]
+ {"svc_updateentertime", Netmsg_svc_updateentertime}, // 37 // [byte] [float]
+ {"svc_updatestatlong", Netmsg_svc_updatestatlong}, // 38 // [byte] [long]
+ {"svc_muzzleflash", Netmsg_svc_muzzleflash}, // 39 // [short] entity
+ {"svc_updateuserinfo", Netmsg_svc_updateuserinfo}, // 40 // [byte] slot [long] uid
+ {"svc_download", Netmsg_svc_download}, // 41 // [short] size [size bytes]
+ {"svc_playerinfo", Netmsg_svc_playerinfo}, // 42 // variable
+ {"svc_nails", Netmsg_svc_nails}, // 43 // [byte] num [48 bits] xyzpy 12 12 12 4 8
+ {"svc_chokecount", Netmsg_svc_chokecount}, // 44 // [byte] packets choked
+ {"svc_modellist", Netmsg_svc_modellist}, // 45 // [strings]
+ {"svc_soundlist", Netmsg_svc_soundlist}, // 46 // [strings]
+ {"svc_packetentities", Netmsg_svc_packetentities}, // 47 // [...]
+ {"svc_deltapacketentities", Netmsg_svc_deltapacketentities}, // 48 // [...]
+ {"svc_maxspeed", Netmsg_svc_maxspeed}, // 49 // maxspeed change, for prediction
+ {"svc_entgravity", Netmsg_svc_entgravity}, // 50 // gravity change, for prediction
+ {"svc_setinfo", Netmsg_svc_setinfo}, // 51 // setinfo on a client
+ {"svc_serverinfo", Netmsg_svc_serverinfo}, // 52 // serverinfo
+ {"svc_updatepl", Netmsg_svc_updatepl} // 53 // [byte] [byte]
+ }
};
.ReadCoord = MSG_ReadCoord13i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector13i,
- .max_svcmsg = 34,
- .svcmsg = netmsg_nq_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_nq_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_quakedp =
.ReadCoord = MSG_ReadCoord13i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector13i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_quakeworld =
.ReadCoord = MSG_ReadCoord13i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector13i,
- .max_svcmsg = 53,
- .svcmsg = netmsg_qw_svc,
- .max_clcmsg = 59,
- .clcmsg = NULL
+ .svc = &netmsg_qw_svc,
+ .clc = NULL
};
protocol_t protocol_dpp1 =
.ReadCoord = MSG_ReadCoord32f,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector32f,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_dpp2 =
.ReadCoord = MSG_ReadCoord16i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector16i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_dpp3 =
.ReadCoord = MSG_ReadCoord16i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector16i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_dpp4 =
.ReadCoord = MSG_ReadCoord16i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector16i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_dpp5 =
.ReadCoord = MSG_ReadCoord32f,
.ReadAngle = MSG_ReadAngle16i,
.ReadVector = MSG_ReadVector32f,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_dpp6 =
.ReadCoord = MSG_ReadCoord32f,
.ReadAngle = MSG_ReadAngle16i,
.ReadVector = MSG_ReadVector32f,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_dpp7 =
.ReadCoord = MSG_ReadCoord32f,
.ReadAngle = MSG_ReadAngle16i,
.ReadVector = MSG_ReadVector32f,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
.ReadCoord = MSG_ReadCoord13i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector13i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_nehahrabjp =
.ReadCoord = MSG_ReadCoord13i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector13i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_nehahrabjp2 =
.ReadCoord = MSG_ReadCoord13i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector13i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t protocol_nehahrabjp3 =
.ReadCoord = MSG_ReadCoord13i,
.ReadAngle = MSG_ReadAngle8i,
.ReadVector = MSG_ReadVector13i,
- .max_svcmsg = 62,
- .svcmsg = netmsg_dpext_svc,
- .max_clcmsg = 59,
- .clcmsg = netmsg_base_clc
+ .svc = &netmsg_dpext_svc,
+ .clc = &netmsg_base_clc
};
protocol_t *protocols[] =
void (*ReadVector)(sizebuf_t *, vec3_t);
// TODO: Other info?
- const int max_svcmsg;
- struct protocol_netmsg_s *svcmsg;
- const int max_clcmsg;
- struct protocol_netmsg_s *clcmsg;
+ struct protocol_netmsg_s *svc;
+ struct protocol_netmsg_s *clc;
};
struct protocol_netmsg_s
{
- const char *name;
- void (*func)(struct protocol_s *);
+ const int size;
+ struct
+ {
+ const char *name;
+ void (*func)(struct protocol_s *);
+ } msg[256];
};
typedef struct protocol_s protocol_t;
extern protocol_t protocol_nehahrabjp2;
extern protocol_t protocol_nehahrabjp3;
-extern protocol_netmsg_t netmsg_nq_svc[];
-extern protocol_netmsg_t netmsg_qw_svc[];
-extern protocol_netmsg_t netmsg_dpext_svc[];
-extern protocol_netmsg_t netmsg_base_clc[];
+extern protocol_netmsg_t netmsg_nq_svc;
+extern protocol_netmsg_t netmsg_qw_svc;
+extern protocol_netmsg_t netmsg_dpext_svc;
+extern protocol_netmsg_t netmsg_base_clc;
#define PF_PREDICTION (1<<0)
#define PF_MOVE_CROUCH (1<<1)
#include "quakedef.h"
#include "sv_protocol_base.h"
-protocol_netmsg_t netmsg_base_clc[] =
+protocol_netmsg_t netmsg_base_clc =
{
- {"clc_bad", NULL},
- {"clc_nop", Netmsg_clc_nop},
- {"clc_disconnect", Netmsg_clc_disconnect},
- {"clc_move", Netmsg_clc_move},
- {"clc_stringcmd", Netmsg_clc_stringcmd},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {NULL, NULL},
- {"clc_ackframe", Netmsg_clc_ackframe},
- {"clc_ackdownloaddata", Netmsg_clc_ackdownloaddata},
- {"clc_unusedlh2", NULL},
- {"clc_unusedlh3", NULL},
- {"clc_unusedlh4", NULL},
- {"clc_unusedlh5", NULL},
- {"clc_unusedlh6", NULL},
- {"clc_unusedlh7", NULL},
- {"clc_unusedlh8", NULL},
- {"clc_unusedlh9", NULL}
+ .size = 59,
+ .msg =
+ {
+ {"clc_bad", NULL},
+ {"clc_nop", Netmsg_clc_nop},
+ {"clc_disconnect", Netmsg_clc_disconnect},
+ {"clc_move", Netmsg_clc_move},
+ {"clc_stringcmd", Netmsg_clc_stringcmd},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {NULL, NULL},
+ {"clc_ackframe", Netmsg_clc_ackframe},
+ {"clc_ackdownloaddata", Netmsg_clc_ackdownloaddata},
+ {"clc_unusedlh2", NULL},
+ {"clc_unusedlh3", NULL},
+ {"clc_unusedlh4", NULL},
+ {"clc_unusedlh5", NULL},
+ {"clc_unusedlh6", NULL},
+ {"clc_unusedlh7", NULL},
+ {"clc_unusedlh8", NULL},
+ {"clc_unusedlh9", NULL}
+ }
};
\ No newline at end of file
SV_ExecuteClientMoves();
break;
}
- if(!netcmd || netcmd >= protocol->max_clcmsg || !protocol->clcmsg[netcmd].func)
+ if(!netcmd || netcmd >= protocol->clc->size || !protocol->clc->msg[netcmd].func)
{
Con_Printf("SV_ReadClientMessage: unknown command char %i (at offset 0x%x)\n", netcmd, sv_message.readcount);
if (developer_networking.integer)
return;
}
else
- protocol->clcmsg[netcmd].func(protocol);
+ protocol->clc->msg[netcmd].func(protocol);
}
}