]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Merge branch 'Mario/dpk_support' of gitlab.com:xonotic/darkplaces
authorCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 01:47:14 +0000 (21:47 -0400)
committerCloudwalk <cloudwalk009@gmail.com>
Thu, 22 Jul 2021 01:47:14 +0000 (21:47 -0400)
54 files changed:
.travis-id_rsa-xonotic [deleted file]
.travis-id_xonotic.enc [new file with mode: 0644]
.travis-script-xonotic.sh
BSDmakefile
cl_cmd.c
cl_collision.c
cl_demo.c
cl_input.c
cl_main.c
cl_parse.c
cl_screen.c
client.h
clvm_cmds.c
cmd.c
cmd.h
com_list.h
common.c
common.h
csprogs.c
cvar.c
cvar.h
fs.c
gl_rmain.c
host.c
host.h
lhnet.c
lhnet.h
libcurl.c
makefile
makefile.inc
menu.c
model_shared.c
model_shared.h
netconn.c
progs.h
progsvm.h
protocol.c
prvm_cmds.c
prvm_edict.c
qtypes.h
sbar.c
server.h
sv_ccmds.c
sv_main.c
sv_phys.c
sv_save.c
sv_send.c
sv_user.c
svvm_cmds.c
sys_sdl.c
vid_null.c
world.c
zone.c
zone.h

diff --git a/.travis-id_rsa-xonotic b/.travis-id_rsa-xonotic
deleted file mode 100644 (file)
index c23b605..0000000
Binary files a/.travis-id_rsa-xonotic and /dev/null differ
diff --git a/.travis-id_xonotic.enc b/.travis-id_xonotic.enc
new file mode 100644 (file)
index 0000000..675b5a7
--- /dev/null
@@ -0,0 +1,3 @@
+éh3ì§\88#\99|E\7fR÷;\ 1ð\98jì^®\94¢Ïa°÷Ëûö\87\ eZ)\ 1l\90÷\9f\93z\88\ 4\91I\11º\16î}²\98V\r\ 4ãgçD(À\8f5²Í/tV¤
+n\93/\83rvðºw\96h\8f¡$ÝÏÙ\11T1\9b\80¨èU\8e±Ú¢\1c\8f\9bYFK¨Õý)¿\17CM\9c\19\12£¡R\84Óg\91íÖÓi£\\8a X\90ïvxÃ\96Ò\8dLXBm%¨aÍ/k"\vúHÊ\ 2㽿\8f\7f  ¤C\13½µ6¦{Õ\82\ 2\97|%\eåÌ\8emOþý\1e¹\95a\84þ '\13X8ñÝ\92Þk0ne·\91§»0ðá\12!\ f\14£×Ðí\13r¤¬¸\90¿<Î@Ä\ 5}[?`Ðc\fl· ]å\13>>©\10YÉæ\rs-cîcäÚ×\87\87%[°æÍÝÅÊ\8bû1×2é¢\10¸U°_\ 2î\8d\17·B8Öj0Ç\8b1´áp]Ï\rGH\11\ 5ð\b\v<r \87\9e:e¢ÿ3\aM3\ 6\r"ß3Op\18ªa¡ä9¡f,زa\95\99ÿpå\83§t\80½û"O\ 2;
+Ú*\89º_\81\131:\11eMn3¯q\ 4.ïÊç\18¤º\17\9a<£©r\ 5¿bÒÎqæ».áV
\ No newline at end of file
index d511662b06f67f211c60ca8827ff61f1748a1fb1..8ffd76db14ec21b6ca9ce489960de2a068520817 100755 (executable)
@@ -2,18 +2,17 @@
 
 set -e
 
-openssl aes-256-cbc -K $encrypted_eeb6f7a14a8e_key -iv $encrypted_eeb6f7a14a8e_iv -in .travis-id_rsa-xonotic -out id_rsa-xonotic -d
+openssl aes-256-cbc -K $encrypted_29b4419ace44_key -iv $encrypted_29b4419ace44_iv -in .travis-id_xonotic.enc -out /tmp/id_xonotic -d
 
 set -x
 
-chmod 0600 id_rsa-xonotic
-# ssh-keygen -y -f id_rsa-xonotic
+chmod 0600 /tmp/id_xonotic
 
 export USRLOCAL="$PWD"/usrlocal
 
 rev=`git rev-parse HEAD`
 
-sftp -oStrictHostKeyChecking=no -i id_rsa-xonotic -P 2222 -b - autobuild-bin-uploader@beta.xonotic.org <<EOF || true
+sftp -oStrictHostKeyChecking=no -i /tmp/id_xonotic -P 2342 -b - autobuild-bin-uploader@srv04.xonotic.org <<EOF || true
 mkdir ${rev}
 EOF
 
@@ -121,7 +120,7 @@ for os in "$@"; do
     for o in $outputs; do
       src=${o%%:*}
       dst=${o#*:}
-      sftp -oStrictHostKeyChecking=no -i id_rsa-xonotic -P 2222 -b - autobuild-bin-uploader@beta.xonotic.org <<EOF
+      sftp -oStrictHostKeyChecking=no -i /tmp/id_xonotic -P 2342 -b - autobuild-bin-uploader@srv04.xonotic.org <<EOF
 put ${src} ${rev}/${dst}
 EOF
     done
index 338293fa73b83f1f8c12b5589fde3aeb46d2c331..b98686dccb87bd85d723b4d3744eaf5ebc5b479b 100644 (file)
@@ -25,7 +25,7 @@ TARGETS_NEXUIZ=sv-nexuiz sdl-nexuiz
 # Link options
 DP_LINK_ZLIB?=shared
 DP_LINK_JPEG?=shared
-DP_LINK_ODE?=dlopen
+DP_LINK_ODE?=
 DP_LINK_CRYPTO?=dlopen
 DP_LINK_CRYPTO_RIJNDAEL?=dlopen
 DP_LINK_XMP?=dlopen
index 3687e2479ae738f2466a158217ee5a925757213b..9277ad50964b77614057f9673895fd83a0cfd15b 100644 (file)
--- a/cl_cmd.c
+++ b/cl_cmd.c
@@ -716,13 +716,13 @@ void CL_InitCommands(void)
        dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\dp");
 
        Cvar_RegisterVariable(&cl_name);
-       Cvar_RegisterAlias(&cl_name, "_cl_name");
+       Cvar_RegisterVirtual(&cl_name, "_cl_name");
        Cvar_RegisterVariable(&cl_rate);
-       Cvar_RegisterAlias(&cl_rate, "_cl_rate");
+       Cvar_RegisterVirtual(&cl_rate, "_cl_rate");
        Cvar_RegisterVariable(&cl_rate_burstsize);
-       Cvar_RegisterAlias(&cl_rate_burstsize, "_cl_rate_burstsize");
+       Cvar_RegisterVirtual(&cl_rate_burstsize, "_cl_rate_burstsize");
        Cvar_RegisterVariable(&cl_pmodel);
-       Cvar_RegisterAlias(&cl_pmodel, "_cl_pmodel");
+       Cvar_RegisterVirtual(&cl_pmodel, "_cl_pmodel");
        Cvar_RegisterVariable(&cl_color);
        Cvar_RegisterCallback(&cl_color, CL_Color_c);
        Cvar_RegisterVariable(&cl_topcolor);
index 2cd3a619a2bf56588225cf492eeeaeea7c7becdc..97303e7a92a9775678e2b5b5c7eefaaeba384cb2 100644 (file)
@@ -104,7 +104,7 @@ model_t *CL_GetModelByIndex(int modelindex)
 model_t *CL_GetModelFromEdict(prvm_edict_t *ed)
 {
        prvm_prog_t *prog = CLVM_prog;
-       if (!ed || ed->priv.server->free)
+       if (!ed || ed->free)
                return NULL;
        return CL_GetModelByIndex((int)PRVM_clientedictfloat(ed, modelindex));
 }
@@ -117,7 +117,7 @@ void CL_LinkEdict(prvm_edict_t *ent)
        if (ent == prog->edicts)
                return;         // don't add the world
 
-       if (ent->priv.server->free)
+       if (ent->free)
                return;
 
        // set the abs box
index eb4ab55e933592bbace8c10a2220e6970c9bd93d..4c826c0db6fffa0494df5d3c73126ba9ea90f47c 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -256,9 +256,8 @@ void CL_ReadDemoMessage(void)
                }
                if (cl_message.cursize > cl_message.maxsize)
                {
-                       Con_Printf("Demo message (%i) > cl_message.maxsize (%i)", cl_message.cursize, cl_message.maxsize);
+                       CL_Disconnect(false, "Demo message (%i) > cl_message.maxsize (%i)", cl_message.cursize, cl_message.maxsize);
                        cl_message.cursize = 0;
-                       CL_Disconnect();
                        return;
                }
                VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
@@ -285,7 +284,7 @@ void CL_ReadDemoMessage(void)
                }
                else
                {
-                       CL_Disconnect();
+                       CL_Disconnect(false, NULL);
                        return;
                }
        }
@@ -364,7 +363,7 @@ void CL_Record_f(cmd_state_t *cmd)
        }
 
        if (cls.state == ca_connected)
-               CL_Disconnect();
+               CL_Disconnect(false, NULL);
 
        // write the forced cd track number, or -1
        if (c == 4)
@@ -422,7 +421,7 @@ void CL_PlayDemo(const char *demo)
        cls.demostarting = true;
 
        // disconnect from server
-       CL_Disconnect();
+       CL_Disconnect(false, NULL);
 
        // update networking ports (this is mainly just needed at startup)
        NetConn_UpdateSockets();
@@ -680,7 +679,7 @@ static void CL_Demos_f(cmd_state_t *cmd)
                return;
        if (cls.demonum == -1)
                cls.demonum = 1;
-       CL_Disconnect();
+       CL_Disconnect(false, NULL);
        CL_NextDemo();
 }
 
@@ -695,7 +694,7 @@ static void CL_Stopdemo_f(cmd_state_t *cmd)
 {
        if (!cls.demoplayback)
                return;
-       CL_Disconnect();
+       CL_Disconnect(false, NULL);
 }
 
 // LadyHavoc: pausedemo command
index 651e9d28ee56f6b4e928cde0458d76266de82786..7c5598ca54960ff1666673a5efaeb4ca52060193 100644 (file)
@@ -1829,6 +1829,7 @@ void CL_SendMove(void)
                break;
        case PROTOCOL_DARKPLACES6:
        case PROTOCOL_DARKPLACES7:
+       case PROTOCOL_DARKPLACES8:
                cl.cmd.predicted = cl_movement.integer != 0;
                break;
        default:
@@ -1860,6 +1861,7 @@ void CL_SendMove(void)
                break;
        case PROTOCOL_DARKPLACES6:
        case PROTOCOL_DARKPLACES7:
+       case PROTOCOL_DARKPLACES8:
                // FIXME: cl.cmd.buttons & 16 is +button5, Nexuiz/Xonotic specific
                cl.cmd.crouch = (cl.cmd.buttons & 16) != 0;
                break;
@@ -1938,6 +1940,7 @@ void CL_SendMove(void)
        // PROTOCOL_DARKPLACES5  clc_move = 19 bytes total
        // PROTOCOL_DARKPLACES6  clc_move = 52 bytes total
        // PROTOCOL_DARKPLACES7  clc_move = 56 bytes total per move (can be up to 16 moves)
+       // PROTOCOL_DARKPLACES8  clc_move = 56 bytes total per move (can be up to 16 moves)
        // PROTOCOL_QUAKEWORLD   clc_move = 34 bytes total (typically, but can reach 43 bytes, or even 49 bytes with roll)
 
        // set prydon cursor info
@@ -2039,6 +2042,7 @@ void CL_SendMove(void)
                        MSG_WriteByte (&buf, cl.cmd.impulse);
                case PROTOCOL_DARKPLACES6:
                case PROTOCOL_DARKPLACES7:
+               case PROTOCOL_DARKPLACES8:
                        // set the maxusercmds variable to limit how many should be sent
                        maxusercmds = bound(1, cl_netrepeatinput.integer + 1, min(3, CL_MAX_USERCMDS));
                        // when movement prediction is off, there's not much point in repeating old input as it will just be ignored
@@ -2163,10 +2167,7 @@ void CL_SendMove(void)
        in_impulse = 0;
 
        if (cls.netcon->message.overflowed)
-       {
-               Con_Print("CL_SendMove: lost server connection\n");
-               CL_Disconnect();
-       }
+               CL_Disconnect(true, "Lost connection to server");
 }
 
 /*
index 4471edd3d4e24f9e6d645e2444bf406f30e75638..e4d56733a18ba40c7f93b5ce241f1d1e35b2b46f 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -360,11 +360,25 @@ Sends a disconnect message to the server
 This is also called on Host_Error, so it shouldn't cause any errors
 =====================
 */
-void CL_Disconnect(void)
+void CL_Disconnect(qbool kicked, const char *fmt, ... )
 {
+       va_list argptr;
+       char reason[512];
+
        if (cls.state == ca_dedicated)
                return;
 
+       if(fmt)
+       {
+               va_start(argptr,fmt);
+               dpvsnprintf(reason,sizeof(reason),fmt,argptr);
+               va_end(argptr);
+       }
+       else
+       {
+               dpsnprintf(reason, sizeof(reason), "Disconnect by user");
+       }
+
        if (Sys_CheckParm("-profilegameonly"))
                Sys_AllowProfiling(false);
 
@@ -395,32 +409,41 @@ void CL_Disconnect(void)
        else if (cls.netcon)
        {
                sizebuf_t buf;
-               unsigned char bufdata[8];
+               unsigned char bufdata[520];
                if (cls.demorecording)
                        CL_Stop_f(cmd_local);
 
-               // send disconnect message 3 times to improve chances of server
-               // receiving it (but it still fails sometimes)
-               memset(&buf, 0, sizeof(buf));
-               buf.data = bufdata;
-               buf.maxsize = sizeof(bufdata);
-               if (cls.protocol == PROTOCOL_QUAKEWORLD)
-               {
-                       Con_DPrint("Sending drop command\n");
-                       MSG_WriteByte(&buf, qw_clc_stringcmd);
-                       MSG_WriteString(&buf, "drop");
-               }
-               else
+               if(!kicked)
                {
-                       Con_DPrint("Sending clc_disconnect\n");
-                       MSG_WriteByte(&buf, clc_disconnect);
+                       // send disconnect message 3 times to improve chances of server
+                       // receiving it (but it still fails sometimes)
+                       memset(&buf, 0, sizeof(buf));
+                       buf.data = bufdata;
+                       buf.maxsize = sizeof(bufdata);
+                       if (cls.protocol == PROTOCOL_QUAKEWORLD)
+                       {
+                               Con_DPrint("Sending drop command\n");
+                               MSG_WriteByte(&buf, qw_clc_stringcmd);
+                               MSG_WriteString(&buf, "drop");
+                       }
+                       else
+                       {
+                               Con_DPrint("Sending clc_disconnect\n");
+                               MSG_WriteByte(&buf, clc_disconnect);
+                               if(cls.protocol == PROTOCOL_DARKPLACES8)
+                                       MSG_WriteString(&buf, reason);
+                       }
+                       NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false);
+                       NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false);
+                       NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false);
                }
-               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false);
-               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false);
-               NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false);
+
                NetConn_Close(cls.netcon);
                cls.netcon = NULL;
-               Con_Printf("Disconnected\n");
+               if(fmt)
+                       Con_Printf("Disconnect: %s\n", reason);
+               else
+                       Con_Printf("Disconnected\n");
        }
        cls.state = ca_disconnected;
        cl.islocalgame = false;
@@ -515,7 +538,7 @@ static void CL_Connect_f(cmd_state_t *cmd)
 
 void CL_Disconnect_f(cmd_state_t *cmd)
 {
-       CL_Disconnect();
+       CL_Disconnect(false, Cmd_Argc(cmd) > 1 ? Cmd_Argv(cmd, 1) : NULL);
 }
 
 
@@ -2493,6 +2516,7 @@ static void CL_MeshEntities_Restart(void)
        for (i = 0; i < NUM_MESHENTITIES; i++)
        {
                ent = cl_meshentities + i;
+               Mod_Mesh_Destroy(ent->render.model);
                Mod_Mesh_Create(ent->render.model, cl_meshentitynames[i]);
        }
 }
@@ -2908,7 +2932,7 @@ void CL_Shutdown (void)
        S_StopAllSounds();
        
        // disconnect client from server if active
-       CL_Disconnect();
+       CL_Disconnect(false, NULL);
        
        CL_Video_Shutdown();
 
index 2a4b29e2c95a8a5d7ca949d192b266b83cb014da..326c1fc0eff4e2a6ce8eb15c43eacfd9642c2e3f 100644 (file)
@@ -35,7 +35,7 @@ const char *svc_strings[128] =
 {
        "svc_bad",
        "svc_nop",
-       "svc_disconnect",
+       "svc_disconnect",       // (DP8) [string] null terminated parting message
        "svc_updatestat",
        "svc_version",          // [int] server version
        "svc_setview",          // [short] entity number
@@ -3391,8 +3391,10 @@ static void CL_NetworkTimeReceived(double newtime)
        // update the csqc's server timestamps, critical for proper sync
        CSQC_UpdateNetworkTimes(cl.mtime[0], cl.mtime[1]);
 
+#ifdef USEODE
        if (cl.mtime[0] > cl.mtime[1])
                World_Physics_Frame(&cl.world, cl.mtime[0] - cl.mtime[1], cl.movevars_gravity);
+#endif
 
        // only lerp entities that also get an update in this frame, when lerp excess is used
        if(cl_lerpexcess.value > 0)
@@ -3529,7 +3531,7 @@ void CL_ParseServerMessage(void)
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
-                                       CL_Disconnect();
+                                       CL_Disconnect(true, NULL);
                                break;
 
                        case qw_svc_print:
@@ -3909,7 +3911,7 @@ void CL_ParseServerMessage(void)
                                if (cls.demonum != -1)
                                        CL_NextDemo();
                                else
-                                       CL_Disconnect();
+                                       CL_Disconnect(true, cls.protocol == PROTOCOL_DARKPLACES8 ? MSG_ReadString(&cl_message, cl_readstring, sizeof(cl_readstring)) : NULL);
                                break;
 
                        case svc_print:
index 75324c176df64a4c869c1edec94d23c031d069ba..50a9df41fc183545355df6b3371e032ad14522d8 100644 (file)
@@ -835,7 +835,7 @@ void CL_Screen_Init(void)
        Cvar_RegisterVariable(&scr_stipple);
        Cvar_RegisterVariable(&scr_refresh);
        Cvar_RegisterVariable(&net_graph);
-       Cvar_RegisterAlias(&net_graph, "shownetgraph");
+       Cvar_RegisterVirtual(&net_graph, "shownetgraph");
        Cvar_RegisterVariable(&cl_demo_mousegrab);
        Cvar_RegisterVariable(&timedemo_screenshotframelist);
        Cvar_RegisterVariable(&vid_touchscreen_outlinealpha);
index 8e6d0f50dba4625435d23164ce20accc2242c33d..3e007c70bde34b181c6f6739917f2a2e4def9d21 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1223,7 +1223,7 @@ void CL_StartVideo(void);
 
 void CL_EstablishConnection(const char *host, int firstarg);
 
-void CL_Disconnect (void);
+void CL_Disconnect (qbool kicked, const char *reason, ... );
 void CL_Disconnect_f(cmd_state_t *cmd);
 
 void CL_UpdateRenderEntity(entity_render_t *ent);
index 23c438f6250f1139cbcba1373de3a408eeaa8428..cbb31b42eccf63961cf031b02573968b71cda183 100644 (file)
@@ -50,7 +50,7 @@ static void VM_CL_setorigin (prvm_prog_t *prog)
                VM_Warning(prog, "setorigin: can not modify world entity\n");
                return;
        }
-       if (e->priv.required->free)
+       if (e->free)
        {
                VM_Warning(prog, "setorigin: can not modify free entity\n");
                return;
@@ -151,7 +151,7 @@ static void VM_CL_setsize (prvm_prog_t *prog)
                VM_Warning(prog, "setsize: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setsize: can not modify free entity\n");
                return;
@@ -537,7 +537,7 @@ static void VM_CL_droptofloor (prvm_prog_t *prog)
                VM_Warning(prog, "droptofloor: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "droptofloor: can not modify free entity\n");
                return;
@@ -761,14 +761,14 @@ static void VM_CL_R_AddEntities (prvm_prog_t *prog)
                // so we can easily check if CSQC entity #edictnum is currently drawn
                cl.csqcrenderentities[i].entitynumber = 0;
                ed = &prog->edicts[i];
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                CSQC_Think(ed);
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                // note that for RF_USEAXIS entities, Predraw sets v_forward/v_right/v_up globals that are read by CSQC_AddRenderEdict
                CSQC_Predraw(ed);
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                if(!((int)PRVM_clientedictfloat(ed, drawmask) & drawmask))
                        continue;
@@ -2523,7 +2523,7 @@ static void VM_CL_makestatic (prvm_prog_t *prog)
                VM_Warning(prog, "makestatic: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "makestatic: can not modify free entity\n");
                return;
@@ -2619,7 +2619,7 @@ static void VM_CL_copyentity (prvm_prog_t *prog)
                VM_Warning(prog, "copyentity: can not read world entity\n");
                return;
        }
-       if (in->priv.server->free)
+       if (in->free)
        {
                VM_Warning(prog, "copyentity: can not read free entity\n");
                return;
@@ -2630,7 +2630,7 @@ static void VM_CL_copyentity (prvm_prog_t *prog)
                VM_Warning(prog, "copyentity: can not modify world entity\n");
                return;
        }
-       if (out->priv.server->free)
+       if (out->free)
        {
                VM_Warning(prog, "copyentity: can not modify free entity\n");
                return;
@@ -3089,7 +3089,7 @@ static void VM_CL_setattachment (prvm_prog_t *prog)
                VM_Warning(prog, "setattachment: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setattachment: can not modify free entity\n");
                return;
@@ -3229,7 +3229,7 @@ int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int
 
        if (ent == prog->edicts)
                return 1;
-       if (ent->priv.server->free)
+       if (ent->free)
                return 2;
 
        model = CL_GetModelFromEdict(ent);
@@ -3321,7 +3321,7 @@ static void VM_CL_gettagindex (prvm_prog_t *prog)
                VM_Warning(prog, "VM_CL_gettagindex(entity #%i): can't affect world entity\n", PRVM_NUM_FOR_EDICT(ent));
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "VM_CL_gettagindex(entity #%i): can't affect free entity\n", PRVM_NUM_FOR_EDICT(ent));
                return;
@@ -4416,7 +4416,7 @@ static void VM_CL_walkmove (prvm_prog_t *prog)
                VM_Warning(prog, "walkmove: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "walkmove: can not modify free entity\n");
                return;
@@ -4487,7 +4487,7 @@ static void VM_CL_checkpvs (prvm_prog_t *prog)
        VectorCopy(PRVM_G_VECTOR(OFS_PARM0), viewpos);
        viewee = PRVM_G_EDICT(OFS_PARM1);
 
-       if(viewee->priv.required->free)
+       if(viewee->free)
        {
                VM_Warning(prog, "checkpvs: can not check free entity\n");
                PRVM_G_FLOAT(OFS_RETURN) = 4;
diff --git a/cmd.c b/cmd.c
index 8fef16f446aa45c44d7d7c4272617a5b44d43a4d..abc512eef3a4e547ba72e24e07e1aaad43cbe961 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -86,12 +86,8 @@ static void Cmd_Defer_f (cmd_state_t *cmd)
                        Con_Printf("No commands are pending.\n");
                else
                {
-                       llist_t *pos;
-               List_For_Each(pos, &cbuf->deferred)
-               {
-                               current = List_Entry(*pos, cmd_input_t, list);
+                       List_For_Each_Entry(current, &cbuf->deferred, list)
                                Con_Printf("-> In %9.2f: %s\n", current->delay, current->text);
-                       }
                }
        }
        else if(Cmd_Argc(cmd) == 2 && !strcasecmp("clear", Cmd_Argv(cmd, 1)))
@@ -183,7 +179,7 @@ static cmd_input_t *Cbuf_LinkGet(cmd_buf_t *cbuf, cmd_input_t *existing)
                ret = existing;
        else if(!List_Is_Empty(&cbuf->free))
        {
-               ret = List_Entry(*cbuf->free.next, cmd_input_t, list);
+               ret = List_Entry(cbuf->free.next, cmd_input_t, list);
                ret->length = 0;
                ret->pending = false;
        }
@@ -370,7 +366,7 @@ void Cbuf_AddText (cmd_state_t *cmd, const char *text)
                Con_Print("Cbuf_AddText: overflow\n");
        else
        {
-               Cbuf_LinkCreate(cmd, &llist, (List_Is_Empty(&cbuf->start) ? NULL : List_Entry(*cbuf->start.prev, cmd_input_t, list)), text);
+               Cbuf_LinkCreate(cmd, &llist, (List_Is_Empty(&cbuf->start) ? NULL : List_Entry(cbuf->start.prev, cmd_input_t, list)), text);
                if(!List_Is_Empty(&llist))
                        List_Splice_Tail(&llist, &cbuf->start);
        }
@@ -398,7 +394,7 @@ void Cbuf_InsertText (cmd_state_t *cmd, const char *text)
                Con_Print("Cbuf_InsertText: overflow\n");
        else
        {
-               Cbuf_LinkCreate(cmd, &llist, List_Entry(*cbuf->start.next, cmd_input_t, list), text);
+               Cbuf_LinkCreate(cmd, &llist, List_Entry(cbuf->start.next, cmd_input_t, list), text);
                if(!List_Is_Empty(&llist))
                        List_Splice(&llist, &cbuf->start);
        }
@@ -413,7 +409,6 @@ Cbuf_Execute_Deferred --blub
 */
 static void Cbuf_Execute_Deferred (cmd_buf_t *cbuf)
 {
-       llist_t *pos;
        cmd_input_t *current;
        double eat;
 
@@ -424,14 +419,13 @@ static void Cbuf_Execute_Deferred (cmd_buf_t *cbuf)
                return;
        cbuf->deferred_oldtime = host.realtime;
 
-    List_For_Each(pos, &cbuf->deferred)
+       List_For_Each_Entry(current, &cbuf->deferred, list)
        {
-               current = List_Entry(*pos, cmd_input_t, list);
                current->delay -= eat;
                if(current->delay <= 0)
                {
                        cbuf->size += current->length;
-                       List_Move(pos, &cbuf->start);
+                       List_Move(&current->list, &cbuf->start);
                        // We must return and come back next frame or the engine will freeze. Fragile... like glass :3
                        return;
                }
@@ -460,7 +454,7 @@ void Cbuf_Execute (cmd_buf_t *cbuf)
                 * commands down. This is necessary because commands (exec, alias)
                 * can insert data at the beginning of the text buffer
                 */
-               current = List_Entry(*cbuf->start.next, cmd_input_t, list);
+               current = List_Entry(cbuf->start.next, cmd_input_t, list);
                
                // Recycle memory so using WASD doesn't cause a malloc and free
                List_Move_Tail(&current->list, &cbuf->free);
diff --git a/cmd.h b/cmd.h
index a1cd3be600c7a9109553729be8059076bb03120d..c80fdf9078307f31f2f0afe5f9715af6fad25170 100644 (file)
--- a/cmd.h
+++ b/cmd.h
@@ -57,7 +57,7 @@ struct cmd_state_s;
 #define CF_USERINFO             (1<<9)  // command or cvar used to communicate userinfo to the server
 #define CF_PERSISTENT           (1<<10) // cvar must not be reset on gametype switch (such as scr_screenshot_name, which otherwise isn't set to the mod name properly)
 #define CF_PRIVATE              (1<<11) // cvar should not be $ expanded or sent to the server under any circumstances (rcon_password, etc)
-#define CF_MAXFLAGSVAL          4095    // used to determine if flags is valid
+#define CF_MAXFLAGSVAL          ((1<<12) - 1)    // used to determine if flags is valid
 // for internal use only!
 #define CF_DEFAULTSET (1<<30)
 #define CF_ALLOCATED (1<<31)
index 188f8d54d0cf6bea204df6b59db1ee2165492a20..074b550414a8a6bca30f28c6fbe85c5d8a66b3ff 100644 (file)
@@ -100,6 +100,7 @@ typedef struct llist_s
 #define List_For_Each_Safe(pos, n, head) \
        for (pos = (head)->next, n = pos->next; pos != (head); \
             pos = n, n = pos->next)
+
 /*
  * Iterate over a list backwards, safe against removal of list entry
  */
@@ -107,6 +108,7 @@ typedef struct llist_s
        for (pos = (head)->prev, n = pos->prev; \
             pos != (head); \
             pos = n, n = pos->prev)
+
 /*
  * Test if the entry points to the head of the list
  */
@@ -173,6 +175,7 @@ typedef struct llist_s
             n = List_Next_Entry(pos, member); \
             !List_Entry_Is_Head(pos, head, member); \
             pos = n, n = List_Next_Entry(n, member))
+
 /*
  * Continue iteration over a list of a given type, after the current position, safe against removal of list entry
  */
@@ -190,7 +193,6 @@ typedef struct llist_s
             !List_Entry_Is_Head(pos, head, member); \
             pos = n, n = List_Next_Entry(n, member))
 
-
 /*
  * Iterate over a list of a given type backwards, safe against removal of list entry
  */
@@ -217,7 +219,7 @@ static inline qbool List_Is_Empty(const llist_t *list)
  */
 static inline void List_Create(llist_t *list)
 {
-       list->next = list->prev = NULL;
+       list->next = list->prev = list;
 }
 
 /*
index 8cecd03d41aba9353a0b9d993c03746e2cc380e8..35e9610656247eba96b4265fd5f9ec2d95c3380d 100644 (file)
--- a/common.c
+++ b/common.c
@@ -903,9 +903,9 @@ void COM_Init_Commands (void)
        Cvar_RegisterVariable (&registered);
        Cvar_RegisterVariable (&cmdline);
        Cvar_RegisterVariable(&cl_playermodel);
-       Cvar_RegisterAlias(&cl_playermodel, "_cl_playermodel");
+       Cvar_RegisterVirtual(&cl_playermodel, "_cl_playermodel");
        Cvar_RegisterVariable(&cl_playerskin);
-       Cvar_RegisterAlias(&cl_playerskin, "_cl_playerskin");
+       Cvar_RegisterVirtual(&cl_playerskin, "_cl_playerskin");
 
        // reconstitute the command line for the cmdline externally visible cvar
        n = 0;
index 4f5e88b36f5d0583ad5bbfdd975d06fa2446e180..169d989bd257a82c12b0eab8a7673e2565b29526 100644 (file)
--- a/common.h
+++ b/common.h
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define COMMON_H
 
 #include <stdarg.h>
+#include <assert.h>
 #include "qtypes.h"
 #include "qdefs.h"
 
@@ -42,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 //============================================================================
 
-#define ContainerOf(ptr, type, member) ((type *)((char *)&(ptr) - offsetof(type, member)))
+#define ContainerOf(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
 
 typedef struct sizebuf_s
 {
@@ -130,6 +131,7 @@ void StoreLittleShort (unsigned char *buffer, unsigned short i);
 typedef enum protocolversion_e
 {
        PROTOCOL_UNKNOWN,
+       PROTOCOL_DARKPLACES8, ///< added parting messages. WIP
        PROTOCOL_DARKPLACES7, ///< added QuakeWorld-style movement protocol to allow more consistent prediction
        PROTOCOL_DARKPLACES6, ///< various changes
        PROTOCOL_DARKPLACES5, ///< uses EntityFrame5 entity snapshot encoder/decoder which is based on a Tribes networking article at http://www.garagegames.com/articles/networking1/
@@ -216,16 +218,22 @@ void COM_InitGameType (void);
 char *va(char *buf, size_t buflen, const char *format, ...) DP_FUNC_PRINTF(3);
 // does a varargs printf into provided buffer, returns buffer (so it can be called in-line unlike dpsnprintf)
 
+// GCC with -Werror=c++-compat will error out if static_assert is used even though the macro is valid C11...
+#ifndef __cplusplus
+#define DP_STATIC_ASSERT(expr, str) _Static_assert(expr, str)
+#else
+#define DP_STATIC_ASSERT(expr, str) static_assert(expr, str)
+#endif
 
 // snprintf and vsnprintf are NOT portable. Use their DP counterparts instead
 #ifdef snprintf
 # undef snprintf
 #endif
-#define snprintf DO_NOT_USE_SNPRINTF__USE_DPSNPRINTF
+#define snprintf DP_STATIC_ASSERT(0, "snprintf is forbidden for portability reasons. Use dpsnprintf instead.")
 #ifdef vsnprintf
 # undef vsnprintf
 #endif
-#define vsnprintf DO_NOT_USE_VSNPRINTF__USE_DPVSNPRINTF
+#define vsnprintf DP_STATIC_ASSERT(0, "vsnprintf is forbidden for portability reasons. Use dpvsnprintf instead.")
 
 // dpsnprintf and dpvsnprintf
 // return the number of printed characters, excluding the final '\0'
@@ -237,15 +245,15 @@ extern int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_
 // A bunch of functions are forbidden for security reasons (and also to please MSVS 2005, for some of them)
 // LadyHavoc: added #undef lines here to avoid warnings in Linux
 #undef strcat
-#define strcat DO_NOT_USE_STRCAT__USE_STRLCAT_OR_MEMCPY
+#define strcat DP_STATIC_ASSERT(0, "strcat is forbidden for security reasons. Use strlcat or memcpy instead.")
 #undef strncat
-#define strncat DO_NOT_USE_STRNCAT__USE_STRLCAT_OR_MEMCPY
+#define strncat DP_STATIC_ASSERT(0, "strncat is forbidden for security reasons. Use strlcat or memcpy instead.")
 #undef strcpy
-#define strcpy DO_NOT_USE_STRCPY__USE_STRLCPY_OR_MEMCPY
+#define strcpy DP_STATIC_ASSERT(0, "strcpy is forbidden for security reasons. Use strlcpy or memcpy instead.")
 #undef strncpy
-#define strncpy DO_NOT_USE_STRNCPY__USE_STRLCPY_OR_MEMCPY
-//#undef sprintf
-//#define sprintf DO_NOT_USE_SPRINTF__USE_DPSNPRINTF
+#define strncpy DP_STATIC_ASSERT(0, "strncpy is forbidden for security reasons. Use strlcpy or memcpy instead.")
+#undef sprintf
+#define sprintf DP_STATIC_ASSERT(0, "sprintf is forbidden for security reasons. Use dpsnprintf instead.")
 
 
 //============================================================================
index bd30f4667ad4c214082500ab87f833cb7a7d1997..47ac1ef22a4b77b627fb85ce47de3523e9326943 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -883,7 +883,7 @@ static void CLVM_end_increase_edicts(prvm_prog_t *prog)
 
        // link every entity except world
        for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++)
-               if (!ent->priv.server->free && !VectorCompare(PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax)))
+               if (!ent->free && !VectorCompare(PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax)))
                        CL_LinkEdict(ent);
 }
 
@@ -906,8 +906,10 @@ static void CLVM_free_edict(prvm_prog_t *prog, prvm_edict_t *ed)
        World_UnlinkEdict(ed);
        memset(ed->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
        VM_RemoveEdictSkeleton(prog, ed);
+#ifdef USEODE
        World_Physics_RemoveFromEntity(&cl.world, ed);
        World_Physics_RemoveJointFromEntity(&cl.world, ed);
+#endif
 }
 
 static void CLVM_count_edicts(prvm_prog_t *prog)
@@ -919,7 +921,7 @@ static void CLVM_count_edicts(prvm_prog_t *prog)
        for (i=0 ; i<prog->num_edicts ; i++)
        {
                ent = PRVM_EDICT_NUM(i);
-               if (ent->priv.server->free)
+               if (ent->free)
                        continue;
                active++;
                if (PRVM_clientedictfloat(ent, solid))
@@ -1041,8 +1043,7 @@ void CL_VM_Init (void)
                        else
                        {
                                Mem_Free(csprogsdata);
-                               Con_Printf(CON_ERROR "Your %s is not the same version as the server (CRC is %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize);
-                               CL_Disconnect();
+                               CL_Disconnect(false, "Your %s is not the same version as the server (CRC is %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize);
                                return;
                        }
                }
@@ -1050,13 +1051,7 @@ void CL_VM_Init (void)
        else
        {
                if (requiredcrc >= 0)
-               {
-                       if (cls.demoplayback)
-                               Con_Printf(CON_ERROR "CL_VM_Init: demo requires CSQC, but \"%s\" wasn't found\n", csqc_progname.string);
-                       else
-                               Con_Printf(CON_ERROR "CL_VM_Init: server requires CSQC, but \"%s\" wasn't found\n", csqc_progname.string);
-                       CL_Disconnect();
-               }
+                       CL_Disconnect(false, CON_ERROR "CL_VM_Init: %s requires CSQC, but \"%s\" wasn't found\n", cls.demoplayback ? "demo" : "server", csqc_progname.string);
                return;
        }
 
@@ -1092,11 +1087,8 @@ void CL_VM_Init (void)
 
        if (!prog->loaded)
        {
-               Host_Error("CSQC %s failed to load\n", csprogsfn);
-               if(!sv.active)
-                       CL_Disconnect();
                Mem_Free(csprogsdata);
-               return;
+               Host_Error("CSQC %s failed to load\n", csprogsfn);
        }
 
        if(cls.demorecording)
@@ -1191,7 +1183,7 @@ qbool CL_VM_GetEntitySoundOrigin(int entnum, vec3_t out)
 
        ed = PRVM_EDICT_NUM(entnum - MAX_EDICTS);
 
-       if(!ed->priv.required->free)
+       if(!ed->free)
        {
                mod = CL_GetModelFromEdict(ed);
                VectorCopy(PRVM_clientedictvector(ed, origin), out);
diff --git a/cvar.c b/cvar.c
index 58562d6b642742e911d879ddc0fdc55dd50af0c4..cbe8b0f6b56205446f0da1c285de48c6c25fcd74 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -492,28 +492,28 @@ void Cvar_RegisterCallback(cvar_t *variable, void (*callback)(cvar_t *))
        variable->callback = callback;
 }
 
-void Cvar_RegisterAlias(cvar_t *variable, const char *alias )
+void Cvar_RegisterVirtual(cvar_t *variable, const char *name )
 {
        cvar_state_t *cvars = &cvars_all;
        cvar_hash_t *hash;
        int hashindex;
 
-       if(!*alias)
+       if(!*name)
        {
-               Con_Printf("Cvar_RegisterAlias: invalid alias name\n");
+               Con_Printf("Cvar_RegisterVirtual: invalid virtual cvar name\n");
                return;
        }
 
        // check for overlap with a command
-       if (Cmd_Exists(cmd_local, alias))
+       if (Cmd_Exists(cmd_local, name))
        {
-               Con_Printf("Cvar_RegisterAlias: %s is a command\n", alias);
+               Con_Printf("Cvar_RegisterVirtual: %s is a command\n", name);
                return;
        }
 
-       if(Cvar_FindVar(&cvars_all, alias, 0))
+       if(Cvar_FindVar(&cvars_all, name, 0))
        {
-               Con_Printf("Cvar_RegisterAlias: %s is a cvar\n", alias);
+               Con_Printf("Cvar_RegisterVirtual: %s is a cvar\n", name);
                return;
        }
 
@@ -525,13 +525,13 @@ void Cvar_RegisterAlias(cvar_t *variable, const char *alias )
        variable->aliases[variable->aliases_size + 1] = NULL;
        
        // Add to it
-       variable->aliases[variable->aliases_size] = (char *)Z_Malloc(strlen(alias) + 1);
-       memcpy(variable->aliases[variable->aliases_size], alias, strlen(alias) + 1);
+       variable->aliases[variable->aliases_size] = (char *)Z_Malloc(strlen(name) + 1);
+       memcpy(variable->aliases[variable->aliases_size], name, strlen(name) + 1);
        variable->aliases_size++;
 
        // link to head of list in this hash table index
        hash = (cvar_hash_t *)Z_Malloc(sizeof(cvar_hash_t));
-       hashindex = CRC_Block((const unsigned char *)alias, strlen(alias)) % CVAR_HASHSIZE;
+       hashindex = CRC_Block((const unsigned char *)name, strlen(name)) % CVAR_HASHSIZE;
        hash->next = cvars->hashtable[hashindex];
        cvars->hashtable[hashindex] = hash;
        hash->cvar = variable;
diff --git a/cvar.h b/cvar.h
index 660320390f99358d826e0f8f1fa0b12f790840c4..92ea81cdc54ee26ce172ce63e5ee429cb8d235b9 100644 (file)
--- a/cvar.h
+++ b/cvar.h
@@ -105,7 +105,7 @@ cvar_state_t;
 extern cvar_state_t cvars_all;
 extern cvar_state_t cvars_null; // used by cmd_serverfromclient which intentionally has no cvars available
 
-void Cvar_RegisterAlias(cvar_t *variable, const char *alias );
+void Cvar_RegisterVirtual(cvar_t *variable, const char *name );
 
 void Cvar_RegisterCallback(cvar_t *variable, void (*callback)(cvar_t *));
 
diff --git a/fs.c b/fs.c
index f8266c71a2a7e7e10b4ee3c21f1d533f6e657010..f5f4d6b917f0d458fc89065ccc9f8bae626b64fd 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1578,7 +1578,7 @@ qbool FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qbool compl
 
        if (cls.demoplayback)
        {
-               CL_Disconnect();
+               CL_Disconnect(false, NULL);
                cls.demonum = 0;
        }
 
@@ -1629,7 +1629,7 @@ static void FS_GameDir_f(cmd_state_t *cmd)
        }
 
        // halt demo playback to close the file
-       CL_Disconnect();
+       CL_Disconnect(false, NULL);
 
        FS_ChangeGameDirs(numgamedirs, gamedirs, true, true);
 }
index 3efa46d2042499b24b106bef687b5505d42512fc..d164550d78b37c7f6c266d90ddeb29254df53a48 100644 (file)
@@ -247,6 +247,7 @@ cvar_t r_glsl_saturation_redcompensate = {CF_CLIENT | CF_ARCHIVE, "r_glsl_satura
 
 cvar_t r_glsl_vertextextureblend_usebothalphas = {CF_CLIENT | CF_ARCHIVE, "r_glsl_vertextextureblend_usebothalphas", "0", "use both alpha layers on vertex blended surfaces, each alpha layer sets amount of 'blend leak' on another layer, requires mod_q3shader_force_terrain_alphaflag on."};
 
+// FIXME: This cvar would grow to a ridiculous size after several launches and clean exits when used during surface sorting.
 cvar_t r_framedatasize = {CF_CLIENT | CF_ARCHIVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"};
 cvar_t r_buffermegs[R_BUFFERDATA_COUNT] =
 {
@@ -6123,7 +6124,7 @@ static void R_DrawEntityBBoxes(prvm_prog_t *prog)
        for (i = 0; i < prog->num_edicts; i++)
        {
                edict = PRVM_EDICT_NUM(i);
-               if (edict->priv.server->free)
+               if (edict->free)
                        continue;
                // exclude the following for now, as they don't live in world coordinate space and can't be solid:
                if (PRVM_gameedictedict(edict, tag_entity) != 0)
diff --git a/host.c b/host.c
index efcba3e2f156f479c3a113cfd86035b68a2457bf..21650a24c9f1f190f0349e80c9b8c93bd0fe56cf 100644 (file)
--- a/host.c
+++ b/host.c
@@ -38,7 +38,7 @@ Memory is cleared / released when a server or client begins, not when they end.
 
 */
 
-host_t host;
+host_static_t host;
 
 // pretend frames take this amount of time (in seconds), 0 = realtime
 cvar_t host_framerate = {CF_CLIENT | CF_SERVER, "host_framerate","0", "locks frame timing to this value in seconds, 0.05 is 20fps for example, note that this can easily run too fast, use cl_maxfps if you want to limit your framerate instead, or sys_ticrate to limit server speed"};
@@ -134,7 +134,7 @@ void Host_Error (const char *error, ...)
        if (cls.state == ca_dedicated)
                Sys_Error ("Host_Error: %s",hosterrorstring2);  // dedicated servers exit
 
-       CL_Disconnect ();
+       CL_Disconnect (false, NULL);
        cls.demonum = -1;
 
        hosterror = false;
@@ -683,7 +683,7 @@ static inline void Host_Sleep(double time)
        else
                Sys_Sleep((int)time);
        delta = Sys_DirtyTime() - time0;
-       if (delta < 0 || delta >= 1800) 
+       if (delta < 0 || delta >= 1800)
                delta = 0;
        host.sleeptime += delta;
 //                     R_TimeReport("sleep");
diff --git a/host.h b/host.h
index 1d553c2509fdf3dbe0ebf8c96adc27879a245729..26465423839b5523830ae599f25370180699f1c6 100644 (file)
--- a/host.h
+++ b/host.h
@@ -16,7 +16,7 @@ typedef enum host_state_e
        host_active
 } host_state_t;
 
-typedef struct host_s
+typedef struct host_static_s
 {
        jmp_buf abortframe;
        int state;
@@ -31,16 +31,16 @@ typedef struct host_s
        struct
        {
                void (*ConnectLocal)(void);
-               void (*Disconnect)(void);
+               void (*Disconnect)(qbool, const char *, ... );
                void (*ToggleMenu)(void);
                qbool (*CL_Intermission)(void); // Quake compatibility
                void (*CL_SendCvar)(struct cmd_state_s *);
                void (*SV_SendCvar)(struct cmd_state_s *);
                void (*SV_Shutdown)(void);
        } hook;
-} host_t;
+} host_static_t;
 
-extern host_t host;
+extern host_static_t host;
 
 void Host_Main(void);
 void Host_Shutdown(void);
diff --git a/lhnet.c b/lhnet.c
index d043f81cf7cb9e69d3e1610a9ef6fcce6829567a..fff523dd3ece9da7f64aa0e3d4bfecd5da546666 100644 (file)
--- a/lhnet.c
+++ b/lhnet.c
@@ -719,7 +719,7 @@ typedef struct lhnetpacket_s
 #ifndef STANDALONETEST
        double sentdoubletime;
 #endif
-       struct lhnetpacket_s *next, *prev;
+       llist_t list;
 }
 lhnetpacket_t;
 
@@ -736,8 +736,8 @@ void LHNET_Init(void)
 {
        if (lhnet_active)
                return;
-       lhnet_socketlist.next = lhnet_socketlist.prev = &lhnet_socketlist;
-       lhnet_packetlist.next = lhnet_packetlist.prev = &lhnet_packetlist;
+       List_Create(&lhnet_socketlist.list);
+       List_Create(&lhnet_packetlist.list);
        lhnet_active = 1;
 #ifdef WIN32
        lhnet_didWSAStartup = !WSAStartup(MAKEWORD(1, 1), &lhnet_winsockdata);
@@ -760,16 +760,15 @@ int LHNET_DefaultDSCP(int dscp)
 
 void LHNET_Shutdown(void)
 {
-       lhnetpacket_t *p;
+       lhnetsocket_t *s, *snext;
+       lhnetpacket_t *p, *pnext;
        if (!lhnet_active)
                return;
-       while (lhnet_socketlist.next != &lhnet_socketlist)
-               LHNET_CloseSocket(lhnet_socketlist.next);
-       while (lhnet_packetlist.next != &lhnet_packetlist)
+       List_For_Each_Entry_Safe(s, snext, &lhnet_socketlist.list, list)
+               LHNET_CloseSocket(s);
+       List_For_Each_Entry_Safe(p, pnext, &lhnet_packetlist.list, list)
        {
-               p = lhnet_packetlist.next;
-               p->prev->next = p->next;
-               p->next->prev = p->prev;
+               List_Delete(&p->list);
                Z_Free(p);
        }
 #ifdef WIN32
@@ -849,7 +848,7 @@ void LHNET_SleepUntilPacket_Microseconds(int microseconds)
        lhnetsocket_t *s;
        FD_ZERO(&fdreadset);
        lastfd = 0;
-       for (s = lhnet_socketlist.next;s != &lhnet_socketlist;s = s->next)
+       List_For_Each_Entry(s, &lhnet_socketlist.list, list)
        {
                if (s->address.addresstype == LHNETADDRESSTYPE_INET4 || s->address.addresstype == LHNETADDRESSTYPE_INET6)
                {
@@ -893,7 +892,7 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                lhnetsocket->address.port = 1024;
                                for (;;)
                                {
-                                       for (s = lhnet_socketlist.next;s != &lhnet_socketlist;s = s->next)
+                                       List_For_Each_Entry(s, &lhnet_socketlist.list, list)
                                                if (s->address.addresstype == lhnetsocket->address.addresstype && s->address.port == lhnetsocket->address.port)
                                                        break;
                                        if (s == &lhnet_socketlist)
@@ -902,15 +901,12 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                }
                        }
                        // check if the port is available
-                       for (s = lhnet_socketlist.next;s != &lhnet_socketlist;s = s->next)
+                       List_For_Each_Entry(s, &lhnet_socketlist.list, list)
                                if (s->address.addresstype == lhnetsocket->address.addresstype && s->address.port == lhnetsocket->address.port)
                                        break;
                        if (s == &lhnet_socketlist && lhnetsocket->address.port != 0)
                        {
-                               lhnetsocket->next = &lhnet_socketlist;
-                               lhnetsocket->prev = lhnetsocket->next->prev;
-                               lhnetsocket->next->prev = lhnetsocket;
-                               lhnetsocket->prev->next = lhnetsocket;
+                               List_Add_Tail(&lhnetsocket->list, &lhnet_socketlist.list);
                                return lhnetsocket;
                        }
                        break;
@@ -1018,10 +1014,7 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address)
                                                                        }
                                                                }
 #endif
-                                                               lhnetsocket->next = &lhnet_socketlist;
-                                                               lhnetsocket->prev = lhnetsocket->next->prev;
-                                                               lhnetsocket->next->prev = lhnetsocket;
-                                                               lhnetsocket->prev->next = lhnetsocket;
+                                                               List_Add_Tail(&lhnetsocket->list, &lhnet_socketlist.list);
 #ifdef WIN32
                                                                if (ioctlsocket(lhnetsocket->inetsocket, SIO_UDP_CONNRESET, &_false) == -1)
                                                                        Con_DPrintf("LHNET_OpenSocket_Connectionless: ioctlsocket SIO_UDP_CONNRESET returned error: %s\n", LHNETPRIVATE_StrError());
@@ -1060,14 +1053,7 @@ void LHNET_CloseSocket(lhnetsocket_t *lhnetsocket)
 {
        if (lhnetsocket)
        {
-               // unlink from socket list
-               if (lhnetsocket->next == NULL)
-                       return; // invalid!
-               lhnetsocket->next->prev = lhnetsocket->prev;
-               lhnetsocket->prev->next = lhnetsocket->next;
-               lhnetsocket->next = NULL;
-               lhnetsocket->prev = NULL;
-
+               List_Delete(&lhnetsocket->list);
                // no special close code for loopback, just inet
                if (lhnetsocket->address.addresstype == LHNETADDRESSTYPE_INET4 || lhnetsocket->address.addresstype == LHNETADDRESSTYPE_INET6)
                {
@@ -1098,14 +1084,12 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength,
                // scan for any old packets to timeout while searching for a packet
                // that is waiting to be delivered to this socket
                currenttime = time(NULL);
-               for (p = lhnet_packetlist.next;p != &lhnet_packetlist;p = pnext)
+               List_For_Each_Entry_Safe(p, pnext, &lhnet_packetlist.list, list)
                {
-                       pnext = p->next;
                        if (p->timeout < currenttime)
                        {
                                // unlink and free
-                               p->next->prev = p->prev;
-                               p->prev->next = p->next;
+                               List_Delete(&p->list);
                                Z_Free(p);
                                continue;
                        }
@@ -1126,8 +1110,7 @@ int LHNET_Read(lhnetsocket_t *lhnetsocket, void *content, int maxcontentlength,
                                else
                                        value = -1;
                                // unlink and free
-                               p->next->prev = p->prev;
-                               p->prev->next = p->next;
+                               List_Delete(&p->list);
                                Z_Free(p);
                        }
                }
@@ -1207,10 +1190,8 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng
                p->sourceport = lhnetsocket->address.port;
                p->destinationport = address->port;
                p->timeout = time(NULL) + 10;
-               p->next = &lhnet_packetlist;
-               p->prev = p->next->prev;
-               p->next->prev = p;
-               p->prev->next = p;
+               List_Add_Tail(&p->list, &lhnet_packetlist.list);
+
 #ifndef STANDALONETEST
                p->sentdoubletime = host.realtime;
 #endif
diff --git a/lhnet.h b/lhnet.h
index 1644fb17f2da7a237f8e2bf522b6d8678d886e45..6d1d1f3f22c08f661d3c4ef40dc8da454f682e3a 100644 (file)
--- a/lhnet.h
+++ b/lhnet.h
@@ -5,6 +5,7 @@
 #define LHNET_H
 
 #include <stddef.h>
+#include "com_list.h"
 
 typedef enum lhnetaddresstype_e
 {
@@ -36,7 +37,7 @@ typedef struct lhnetsocket_s
 {
        lhnetaddress_t address;
        int inetsocket;
-       struct lhnetsocket_s *next, *prev;
+       llist_t list;
 }
 lhnetsocket_t;
 
index c29a189426b3c3abef143d51e6ac619df817d8d1..f71dfaafc6beef6ebd4673dca9ffbb7aa69681e1 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -1494,7 +1494,7 @@ static void Curl_Curl_f(cmd_state_t *cmd)
                                                dpsnprintf(donecommand, sizeof(donecommand), "connect %s", cls.netcon->address);
                                                Curl_CommandWhenDone(donecommand);
                                                noclear = true;
-                                               CL_Disconnect();
+                                               CL_Disconnect(false, NULL);
                                                noclear = false;
                                                Curl_CheckCommandWhenDone();
                                        }
index 46aa01075d802036b243d456e2dcab8aeb80311a..064a6e7b99d41c8cd387a8f981cad3ef143048e4 100644 (file)
--- a/makefile
+++ b/makefile
@@ -104,7 +104,7 @@ ifeq ($(DP_MAKE_TARGET), linux)
        DP_LINK_SDL?=shared
        DP_LINK_ZLIB?=shared
        DP_LINK_JPEG?=shared
-       DP_LINK_ODE?=dlopen
+       DP_LINK_ODE?=
        DP_LINK_CRYPTO?=dlopen
        DP_LINK_CRYPTO_RIJNDAEL?=dlopen
        DP_LINK_XMP?=dlopen
@@ -134,7 +134,7 @@ ifeq ($(DP_MAKE_TARGET), macosx)
        DP_LINK_SDL?=shared
        DP_LINK_ZLIB?=shared
        DP_LINK_JPEG?=dlopen
-       DP_LINK_ODE?=dlopen
+       DP_LINK_ODE?=
        DP_LINK_CRYPTO?=dlopen
        DP_LINK_CRYPTO_RIJNDAEL?=dlopen
        DP_LINK_XMP?=dlopen
@@ -170,7 +170,7 @@ ifeq ($(DP_MAKE_TARGET), sunos)
        DP_LINK_SDL?=shared
        DP_LINK_ZLIB?=shared
        DP_LINK_JPEG?=shared
-       DP_LINK_ODE?=dlopen
+       DP_LINK_ODE?=
        DP_LINK_CRYPTO?=dlopen
        DP_LINK_CRYPTO_RIJNDAEL?=dlopen
        DP_LINK_XMP?=dlopen
@@ -197,7 +197,7 @@ ifeq ($(DP_MAKE_TARGET), bsd)
        DP_LINK_SDL?=shared
        DP_LINK_ZLIB?=shared
        DP_LINK_JPEG?=shared
-       DP_LINK_ODE?=dlopen
+       DP_LINK_ODE?=
        DP_LINK_CRYPTO?=dlopen
        DP_LINK_CRYPTO_RIJNDAEL?=dlopen
        DP_LINK_XMP?=dlopen
@@ -243,7 +243,7 @@ ifeq ($(DP_MAKE_TARGET), mingw)
        DP_LINK_SDL?=shared
        DP_LINK_ZLIB?=dlopen
        DP_LINK_JPEG?=shared
-       DP_LINK_ODE?=dlopen
+       DP_LINK_ODE?=
        DP_LINK_CRYPTO?=dlopen
        DP_LINK_CRYPTO_RIJNDAEL?=dlopen
        DP_LINK_XMP?=dlopen
index 16dd546f0f1035299b369385af55e67837f15fc0..250ae7160a36cb8120bb891ed54e038b3698ece8 100644 (file)
@@ -448,17 +448,29 @@ prepare :
 
 
 #this checks USEODE when compiling so it needs the ODE flags as well
-prvm_cmds.o: prvm_cmds.c
+cl_parse.o: cl_parse.c
        $(CHECKLEVEL2)
        $(DO_CC) $(CFLAGS_ODE)
 
-world.o: world.c
+cs_progs.o: cs_progs.c
        $(CHECKLEVEL2)
        $(DO_CC) $(CFLAGS_ODE)
 
-vid_glx.o: vid_glx.c
+sv_main.o: sv_main.c
        $(CHECKLEVEL2)
-       $(DO_CC) -I/usr/X11R6/include
+       $(DO_CC) $(CFLAGS_ODE)
+
+sv_phys.o: sv_phys.c
+       $(CHECKLEVEL2)
+       $(DO_CC) $(CFLAGS_ODE)
+
+prvm_cmds.o: prvm_cmds.c
+       $(CHECKLEVEL2)
+       $(DO_CC) $(CFLAGS_ODE)
+
+world.o: world.c
+       $(CHECKLEVEL2)
+       $(DO_CC) $(CFLAGS_ODE)
 
 keysym2ucs.o: keysym2ucs.c
        $(CHECKLEVEL2)
diff --git a/menu.c b/menu.c
index 2dc43ec921834070a93bf383c764274a09b0f2cc..ce154097118e91e32c8aef969f53f0c789caa89a 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -5269,7 +5269,7 @@ static void MVM_count_edicts(prvm_prog_t *prog)
        for (i=0 ; i<prog->num_edicts ; i++)
        {
                ent = PRVM_EDICT_NUM(i);
-               if (ent->priv.required->free)
+               if (ent->free)
                        continue;
                active++;
        }
index e7d3228d13f8ed5e1fc377ccaf412ffaa1bea85c..8e707337afe4fe8c9b8d4273ddae4247272112c5 100644 (file)
@@ -2936,7 +2936,7 @@ void Mod_MakeSortedSurfaces(model_t *mod)
        if(cls.state == ca_dedicated)
                return;
 
-       info = (Mod_MakeSortedSurfaces_qsortsurface_t*)R_FrameData_Alloc(mod->num_surfaces * sizeof(*info));
+       info = (Mod_MakeSortedSurfaces_qsortsurface_t*)Mem_Alloc(loadmodel->mempool, mod->num_surfaces * sizeof(*info));
        if (!mod->modelsurfaces_sorted)
                mod->modelsurfaces_sorted = (int *) Mem_Alloc(loadmodel->mempool, mod->num_surfaces * sizeof(*mod->modelsurfaces_sorted));
        // the goal is to sort by submodel (can't change which submodel a surface belongs to), and then by effects and textures
@@ -2952,6 +2952,7 @@ void Mod_MakeSortedSurfaces(model_t *mod)
                        qsort(info + mod->brush.submodels[k]->submodelsurfaces_start, (size_t)mod->brush.submodels[k]->submodelsurfaces_end - mod->brush.submodels[k]->submodelsurfaces_start, sizeof(*info), Mod_MakeSortedSurfaces_qsortfunc);
        for (j = 0; j < mod->num_surfaces; j++)
                mod->modelsurfaces_sorted[j] = info[j].surfaceindex;
+       Mem_Free(info);
 }
 
 void Mod_BuildVBOs(void)
@@ -4645,25 +4646,24 @@ static void Mod_Mesh_MakeSortedSurfaces(model_t *mod)
 {
        int i, j;
        texture_t *tex;
-       unsigned char* included = (unsigned char *)R_FrameData_Alloc(mod->num_surfaces * sizeof(unsigned char));
 
        // build the sorted surfaces list properly to reduce material setup
        // this is easy because we're just sorting on texture and don't care about the order of textures
        mod->submodelsurfaces_start = 0;
        mod->submodelsurfaces_end = 0;
        for (i = 0; i < mod->num_surfaces; i++)
-               included[i] = 0;
+               mod->data_surfaces[i].included = false;
        for (i = 0; i < mod->num_surfaces; i++)
        {
-               if (included[i])
+               if (mod->data_surfaces[i].included)
                        continue;
                tex = mod->data_surfaces[i].texture;
                // j = i is intentional
                for (j = i; j < mod->num_surfaces; j++)
                {
-                       if (!included[j] && mod->data_surfaces[j].texture == tex)
+                       if (!mod->data_surfaces[j].included && mod->data_surfaces[j].texture == tex)
                        {
-                               included[j] = 1;
+                               mod->data_surfaces[j].included = 1;
                                mod->modelsurfaces_sorted[mod->submodelsurfaces_end++] = j;
                        }
                }
index 072d61f9397ca512cedabec3c321204eaaf355f6..cf5e02dc1ec4450210fceb52f9767a01ca738caf 100644 (file)
@@ -404,6 +404,9 @@ typedef struct msurface_s
        int num_firstcollisiontriangle; // q3bsp only
        int num_collisiontriangles; // number of triangles (if surface has collisions enabled)
        int num_collisionvertices; // number of vertices referenced by collision triangles (if surface has collisions enabled)
+
+       // used by Mod_Mesh_Finalize when building sortedmodelsurfaces
+       qbool included;
 }
 msurface_t;
 
index af1aae28eab4c3b8e15297ed96206ef3473f894d..ac481ca6df030e6d3d602ce11f0885880ab81b72 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -1529,7 +1529,7 @@ static void NetConn_ConnectionEstablished(lhnetsocket_t *mysocket, lhnetaddress_
 #endif
        // Disconnect from the current server or stop demo playback
        if(cls.state == ca_connected || cls.demoplayback)
-               CL_Disconnect();
+               CL_Disconnect(false, NULL);
        // allocate a net connection to keep track of things
        cls.netcon = NetConn_Open(mysocket, peeraddress);
        crypto = &cls.netcon->crypto;
@@ -2488,10 +2488,7 @@ void NetConn_ClientFrame(void)
        NetConn_QueryQueueFrame();
 #endif
        if (cls.netcon && host.realtime > cls.netcon->timeout && !sv.active)
-       {
-               Con_Print("Connection timed out\n");
-               CL_Disconnect();
-       }
+               CL_Disconnect(true, "Connection timed out");
 }
 
 static void NetConn_BuildChallengeString(char *buffer, int bufferlength)
@@ -3903,9 +3900,9 @@ void NetConn_Init(void)
        Cvar_RegisterVariable(&net_fakelag);
        Cvar_RegisterVariable(&net_fakeloss_send);
        Cvar_RegisterVariable(&net_fakeloss_receive);
-       Cvar_RegisterAlias(&net_fakelag, "cl_netlocalping");
-       Cvar_RegisterAlias(&net_fakeloss_send, "cl_netpacketloss_send");
-       Cvar_RegisterAlias(&net_fakeloss_receive, "cl_netpacketloss_receive");
+       Cvar_RegisterVirtual(&net_fakelag, "cl_netlocalping");
+       Cvar_RegisterVirtual(&net_fakeloss_send, "cl_netpacketloss_send");
+       Cvar_RegisterVirtual(&net_fakeloss_receive, "cl_netpacketloss_receive");
        Cvar_RegisterVariable(&hostname);
        Cvar_RegisterVariable(&developer_networking);
        Cvar_RegisterVariable(&cl_netport);
diff --git a/progs.h b/progs.h
index fd8d109c3ee65fa1ddebba405e2c21e445f66264..25ee3988c9e3aaa1e824bc190a029abebd6e85cb 100644 (file)
--- a/progs.h
+++ b/progs.h
@@ -57,6 +57,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define ODEFUNC_FORCE       3
 #define ODEFUNC_TORQUE      4
 
+#ifdef USEODE
 typedef struct edict_odefunc_s
 {
        int type;
@@ -64,18 +65,15 @@ typedef struct edict_odefunc_s
        vec3_t v2;
        struct edict_odefunc_s *next;
 }edict_odefunc_t;
+#endif
 
 typedef struct edict_engineprivate_s
 {
-       // true if this edict is unused
-       qbool free;
-       // sv.time when the object was freed (to prevent early reuse which could
-       // mess up client interpolation or obscure severe QuakeC bugs)
-       double freetime;
        // mark for the leak detector
        int mark;
        // place in the code where it was allocated (for the leak detector)
        const char *allocation_origin;
+
        // initially false to prevent projectiles from moving on their first frame
        // (even if they were spawned by an synchronous client think)
        qbool move;
@@ -113,6 +111,7 @@ typedef struct edict_engineprivate_s
        frameblend_t frameblend[MAX_FRAMEBLENDS];
        skeleton_t skeleton;
 
+#ifdef USEODE
        // physics parameters
        qbool ode_physics;
        void *ode_body;
@@ -145,6 +144,7 @@ typedef struct edict_engineprivate_s
        vec3_t ode_joint_velocity; // second joint axis
        vec3_t ode_joint_movedir; // parameters
        void *ode_massbuf;
+#endif
 }
 edict_engineprivate_t;
 
index ea08900d2d1ae0d35d43a3db91471cb6d6e932be..92ead5dc772a8393f7a7470fee8cec35be11a78c 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -74,23 +74,27 @@ typedef struct prvm_required_field_s
        const char *name;
 } prvm_required_field_t;
 
-
+#define PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN -1
+#define PRVM_EDICT_MARK_SETORIGIN_CAUGHT -2
 // AK: I dont call it engine private cause it doesnt really belongs to the engine
 //     it belongs to prvm.
 typedef struct prvm_edict_private_s
 {
-       qbool free;
-       double freetime; // realtime of last change to "free" (i.e. also set on allocation)
-       int mark; // used during leaktest (0 = unref, >0 = referenced); special values during server physics:
-#define PRVM_EDICT_MARK_WAIT_FOR_SETORIGIN -1
-#define PRVM_EDICT_MARK_SETORIGIN_CAUGHT -2
+       // mark for the leak detector
+       int mark;
+       // place in the code where it was allocated (for the leak detector)
        const char *allocation_origin;
 } prvm_edict_private_t;
 
 typedef struct prvm_edict_s
 {
+       // true if this edict is unused
+       qbool free;
+       // sv.time when the object was freed (to prevent early reuse which could
+       // mess up client interpolation or obscure severe QuakeC bugs)
+       double freetime;
+
        // engine-private fields (stored in dynamically resized array)
-       //edict_engineprivate_t *e;
        union
        {
                prvm_edict_private_t *required;
index 8bdb00514a07270a93d30062deb92ea4cc1672f0..5685675562e0e51096425f306fcbf741129f09f2 100644 (file)
@@ -47,6 +47,7 @@ struct protocolversioninfo_s
 }
 protocolversioninfo[] =
 {
+       { 3505, PROTOCOL_DARKPLACES8 , "DP8"},
        { 3504, PROTOCOL_DARKPLACES7 , "DP7"},
        { 3503, PROTOCOL_DARKPLACES6 , "DP6"},
        { 3502, PROTOCOL_DARKPLACES5 , "DP5"},
index 07adabf396246c2a6ec3b0e140ff3d389b1813c7..b731bcde2468c9b0f5f3a618d0babd2115be3de5 100644 (file)
@@ -930,7 +930,7 @@ void VM_ftoe(prvm_prog_t *prog)
        VM_SAFEPARMCOUNT(1, VM_ftoe);
 
        ent = (prvm_int_t)PRVM_G_FLOAT(OFS_PARM0);
-       if (ent < 0 || ent >= prog->max_edicts || PRVM_PROG_TO_EDICT(ent)->priv.required->free)
+       if (ent < 0 || ent >= prog->max_edicts || PRVM_PROG_TO_EDICT(ent)->free)
                ent = 0; // return world instead of a free or invalid entity
 
        PRVM_G_INT(OFS_RETURN) = ent;
@@ -1033,7 +1033,7 @@ void VM_remove(prvm_prog_t *prog)
                if (developer.integer > 0)
                        VM_Warning(prog, "VM_remove: tried to remove the null entity or a reserved entity!\n" );
        }
-       else if( ed->priv.required->free )
+       else if( ed->free )
        {
                if (developer.integer > 0)
                        VM_Warning(prog, "VM_remove: tried to remove an already freed entity!\n" );
@@ -1071,7 +1071,7 @@ void VM_find(prvm_prog_t *prog)
        {
                prog->xfunction->builtinsprofile++;
                ed = PRVM_EDICT_NUM(e);
-               if (ed->priv.required->free)
+               if (ed->free)
                        continue;
                t = PRVM_E_STRING(ed,f);
                if (!t)
@@ -1112,7 +1112,7 @@ void VM_findfloat(prvm_prog_t *prog)
        {
                prog->xfunction->builtinsprofile++;
                ed = PRVM_EDICT_NUM(e);
-               if (ed->priv.required->free)
+               if (ed->free)
                        continue;
                if (PRVM_E_FLOAT(ed,f) == s)
                {
@@ -1163,7 +1163,7 @@ void VM_findchain(prvm_prog_t *prog)
        for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
        {
                prog->xfunction->builtinsprofile++;
-               if (ent->priv.required->free)
+               if (ent->free)
                        continue;
                t = PRVM_E_STRING(ent,f);
                if (!t)
@@ -1214,7 +1214,7 @@ void VM_findchainfloat(prvm_prog_t *prog)
        for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
        {
                prog->xfunction->builtinsprofile++;
-               if (ent->priv.required->free)
+               if (ent->free)
                        continue;
                if (PRVM_E_FLOAT(ent,f) != s)
                        continue;
@@ -1252,7 +1252,7 @@ void VM_findflags(prvm_prog_t *prog)
        {
                prog->xfunction->builtinsprofile++;
                ed = PRVM_EDICT_NUM(e);
-               if (ed->priv.required->free)
+               if (ed->free)
                        continue;
                if (!PRVM_E_FLOAT(ed,f))
                        continue;
@@ -1300,7 +1300,7 @@ void VM_findchainflags(prvm_prog_t *prog)
        for (i = 1;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
        {
                prog->xfunction->builtinsprofile++;
-               if (ent->priv.required->free)
+               if (ent->free)
                        continue;
                if (!PRVM_E_FLOAT(ent,f))
                        continue;
@@ -1514,7 +1514,7 @@ void VM_nextent(prvm_prog_t *prog)
                        return;
                }
                ent = PRVM_EDICT_NUM(i);
-               if (!ent->priv.required->free)
+               if (!ent->free)
                {
                        VM_RETURN_EDICT(ent);
                        return;
@@ -2037,7 +2037,7 @@ void VM_writetofile(prvm_prog_t *prog)
        }
 
        ent = PRVM_G_EDICT(OFS_PARM1);
-       if(ent->priv.required->free)
+       if(ent->free)
        {
                VM_Warning(prog, "VM_writetofile: %s: entity %i is free !\n", prog->name, PRVM_NUM_FOR_EDICT(ent));
                return;
@@ -2138,7 +2138,7 @@ void VM_getentityfieldstring(prvm_prog_t *prog)
        
        // get the entity
        ent = PRVM_G_EDICT(OFS_PARM1);
-       if(ent->priv.required->free)
+       if(ent->free)
        {
                PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, "");
                VM_Warning(prog, "VM_entityfielddata: %s: entity %i is free !\n", prog->name, PRVM_NUM_FOR_EDICT(ent));
@@ -2185,7 +2185,7 @@ void VM_putentityfieldstring(prvm_prog_t *prog)
 
        // get the entity
        ent = PRVM_G_EDICT(OFS_PARM1);
-       if(ent->priv.required->free)
+       if(ent->free)
        {
                VM_Warning(prog, "VM_entityfielddata: %s: entity %i is free !\n", prog->name, PRVM_NUM_FOR_EDICT(ent));
                PRVM_G_FLOAT(OFS_RETURN) = 0.0f;
@@ -2998,7 +2998,7 @@ void VM_parseentitydata(prvm_prog_t *prog)
 
        // get edict and test it
        ent = PRVM_G_EDICT(OFS_PARM0);
-       if (ent->priv.required->free)
+       if (ent->free)
                prog->error_cmd("VM_parseentitydata: %s: Can only set already spawned entities (entity %i is free)!", prog->name, PRVM_NUM_FOR_EDICT(ent));
 
        data = PRVM_G_STRING(OFS_PARM1);
@@ -4678,7 +4678,7 @@ void VM_changeyaw (prvm_prog_t *prog)
                VM_Warning(prog, "changeyaw: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "changeyaw: can not modify free entity\n");
                return;
@@ -4734,7 +4734,7 @@ void VM_changepitch (prvm_prog_t *prog)
                VM_Warning(prog, "changepitch: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "changepitch: can not modify free entity\n");
                return;
@@ -5136,7 +5136,7 @@ void VM_digest_hex(prvm_prog_t *prog)
 void VM_wasfreed (prvm_prog_t *prog)
 {
        VM_SAFEPARMCOUNT(1, VM_wasfreed);
-       PRVM_G_FLOAT(OFS_RETURN) = PRVM_G_EDICT(OFS_PARM0)->priv.required->free;
+       PRVM_G_FLOAT(OFS_RETURN) = PRVM_G_EDICT(OFS_PARM0)->free;
 }
 
 void VM_SetTraceGlobals(prvm_prog_t *prog, const trace_t *trace)
@@ -6315,7 +6315,7 @@ void VM_getsurfacenearpoint(prvm_prog_t *prog)
        ed = PRVM_G_EDICT(OFS_PARM0);
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), point);
 
-       if (!ed || ed->priv.server->free)
+       if (!ed || ed->free)
                return;
        model = getmodel(prog, ed);
        if (!model || !model->num_surfaces)
@@ -6408,6 +6408,7 @@ void VM_getsurfacetriangle(prvm_prog_t *prog)
 // physics builtins
 //
 
+#ifdef USEODE
 #define VM_physics_ApplyCmd(ed,f) if (!ed->priv.server->ode_body) VM_physics_newstackfunction(prog, ed, f); else World_Physics_ApplyCmd(ed, f)
 
 static edict_odefunc_t *VM_physics_newstackfunction(prvm_prog_t *prog, prvm_edict_t *ed, edict_odefunc_t *f)
@@ -6426,14 +6427,17 @@ static edict_odefunc_t *VM_physics_newstackfunction(prvm_prog_t *prog, prvm_edic
        }
        return newfunc;
 }
+#endif
 
 // void(entity e, float physics_enabled) physics_enable = #;
 void VM_physics_enable(prvm_prog_t *prog)
 {
+#ifdef USEODE
        prvm_edict_t *ed;
        edict_odefunc_t f;
-       
+#endif
        VM_SAFEPARMCOUNT(2, VM_physics_enable);
+#ifdef USEODE
        ed = PRVM_G_EDICT(OFS_PARM0);
        if (!ed)
        {
@@ -6449,15 +6453,18 @@ void VM_physics_enable(prvm_prog_t *prog)
        }
        f.type = PRVM_G_FLOAT(OFS_PARM1) == 0 ? ODEFUNC_DISABLE : ODEFUNC_ENABLE;
        VM_physics_ApplyCmd(ed, &f);
+#endif
 }
 
 // void(entity e, vector force, vector relative_ofs) physics_addforce = #;
 void VM_physics_addforce(prvm_prog_t *prog)
 {
+#ifdef USEODE
        prvm_edict_t *ed;
        edict_odefunc_t f;
-       
+#endif
        VM_SAFEPARMCOUNT(3, VM_physics_addforce);
+#ifdef USEODE
        ed = PRVM_G_EDICT(OFS_PARM0);
        if (!ed)
        {
@@ -6475,15 +6482,18 @@ void VM_physics_addforce(prvm_prog_t *prog)
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
        VectorCopy(PRVM_G_VECTOR(OFS_PARM2), f.v2);
        VM_physics_ApplyCmd(ed, &f);
+#endif
 }
 
 // void(entity e, vector torque) physics_addtorque = #;
 void VM_physics_addtorque(prvm_prog_t *prog)
 {
+#ifdef USEODE
        prvm_edict_t *ed;
        edict_odefunc_t f;
-       
+#endif
        VM_SAFEPARMCOUNT(2, VM_physics_addtorque);
+#ifdef USEODE
        ed = PRVM_G_EDICT(OFS_PARM0);
        if (!ed)
        {
@@ -6500,6 +6510,7 @@ void VM_physics_addtorque(prvm_prog_t *prog)
        f.type = ODEFUNC_TORQUE;
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
        VM_physics_ApplyCmd(ed, &f);
+#endif
 }
 
 extern cvar_t prvm_coverage;
index 3c50397e70a4e324c5d4811758f4500418d6fdfe..78bcdabcc5dcbf3cfce9a7384136290ff8d74326 100644 (file)
@@ -204,8 +204,8 @@ freed and sets the allocation origin.
 void PRVM_ED_ClearEdict(prvm_prog_t *prog, prvm_edict_t *e)
 {
        memset(e->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
-       e->priv.required->free = false;
-       e->priv.required->freetime = host.realtime;
+       e->free = false;
+       e->freetime = host.realtime;
        if(e->priv.required->allocation_origin)
                Mem_Free((char *)e->priv.required->allocation_origin);
        e->priv.required->allocation_origin = PRVM_AllocationOrigin(prog);
@@ -235,15 +235,15 @@ Returns if this particular edict could get allocated by PRVM_ED_Alloc
 */
 qbool PRVM_ED_CanAlloc(prvm_prog_t *prog, prvm_edict_t *e)
 {
-       if(!e->priv.required->free)
+       if(!e->free)
                return false;
        if(prvm_reuseedicts_always_allow == host.realtime)
                return true;
-       if(host.realtime <= e->priv.required->freetime + 0.1 && prvm_reuseedicts_neverinsameframe.integer)
+       if(host.realtime <= e->freetime + 0.1 && prvm_reuseedicts_neverinsameframe.integer)
                return false; // never allow reuse in same frame (causes networking trouble)
-       if(e->priv.required->freetime < prog->starttime + prvm_reuseedicts_startuptime.value)
+       if(e->freetime < prog->starttime + prvm_reuseedicts_startuptime.value)
                return true;
-       if(host.realtime > e->priv.required->freetime + 1)
+       if(host.realtime > e->freetime + 1)
                return true;
        return false; // entity slot still blocked because the entity was freed less than one second ago
 }
@@ -308,8 +308,8 @@ void PRVM_ED_Free(prvm_prog_t *prog, prvm_edict_t *ed)
 
        prog->free_edict(prog, ed);
 
-       ed->priv.required->free = true;
-       ed->priv.required->freetime = host.realtime;
+       ed->free = true;
+       ed->freetime = host.realtime;
        if(ed->priv.required->allocation_origin)
        {
                Mem_Free((char *)ed->priv.required->allocation_origin);
@@ -654,7 +654,7 @@ void PRVM_ED_Print(prvm_prog_t *prog, prvm_edict_t *ed, const char *wildcard_fie
        char    tempstring[MAX_INPUTLINE], tempstring2[260]; // temporary string buffers
        char    valuebuf[MAX_INPUTLINE];
 
-       if (ed->priv.required->free)
+       if (ed->free)
        {
                Con_Printf("%s: FREE\n",prog->name);
                return;
@@ -737,7 +737,7 @@ void PRVM_ED_Write (prvm_prog_t *prog, qfile_t *f, prvm_edict_t *ed)
 
        FS_Print(f, "{\n");
 
-       if (ed->priv.required->free)
+       if (ed->free)
        {
                FS_Print(f, "}\n");
                return;
@@ -1351,8 +1351,8 @@ const char *PRVM_ED_ParseEdict (prvm_prog_t *prog, const char *data, prvm_edict_
        }
 
        if (!init) {
-               ent->priv.required->free = true;
-               ent->priv.required->freetime = host.realtime;
+               ent->free = true;
+               ent->freetime = host.realtime;
        }
 
        return data;
@@ -1379,7 +1379,7 @@ qbool PRVM_ED_CallSpawnFunction(prvm_prog_t *prog, prvm_edict_t *ent, const char
 //
 // immediately call spawn function, but only if there is a self global and a classname
 //
-       if (!ent->priv.required->free)
+       if (!ent->free)
        {
                if (!PRVM_alledictstring(ent, classname))
                {
@@ -1455,7 +1455,7 @@ qbool PRVM_ED_CallSpawnFunction(prvm_prog_t *prog, prvm_edict_t *ent, const char
 
 void PRVM_ED_CallPostspawnFunction (prvm_prog_t *prog, prvm_edict_t *ent)
 {
-       if(!ent->priv.required->free)
+       if(!ent->free)
        if (PRVM_serverfunction(SV_OnEntityPostSpawnFunction))
        {
                // self = ent
@@ -1530,7 +1530,7 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data)
 
                PRVM_ED_CallPrespawnFunction(prog, ent);
 
-               if(ent->priv.required->free)
+               if(ent->free)
                {
                        inhibited++;
                        continue;
@@ -1544,7 +1544,7 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data)
                PRVM_ED_CallPostspawnFunction(prog, ent);
 
                spawned++;
-               if (ent->priv.required->free)
+               if (ent->free)
                        died++;
        }
 
@@ -2746,7 +2746,7 @@ static void PRVM_Fields_f(cmd_state_t *cmd)
        for (ednum = 0;ednum < prog->max_edicts;ednum++)
        {
                ed = PRVM_EDICT_NUM(ednum);
-               if (ed->priv.required->free)
+               if (ed->free)
                        continue;
                for (i = 1;i < prog->numfielddefs;i++)
                {
@@ -3446,7 +3446,7 @@ static qbool PRVM_IsStringReferenced(prvm_prog_t *prog, string_t string)
        for(j = 0; j < prog->num_edicts; ++j)
        {
                prvm_edict_t *ed = PRVM_EDICT_NUM(j);
-               if (ed->priv.required->free)
+               if (ed->free)
                        continue;
                for (i=0; i<prog->numfielddefs; ++i)
                {
@@ -3467,7 +3467,7 @@ static qbool PRVM_IsEdictRelevant(prvm_prog_t *prog, prvm_edict_t *edict)
        char vabuf2[1024];
        if(PRVM_NUM_FOR_EDICT(edict) <= prog->reserved_edicts)
                return true; // world or clients
-       if (edict->priv.required->freetime <= prog->inittime)
+       if (edict->freetime <= prog->inittime)
                return true; // created during startup
        if (prog == SVVM_prog)
        {
@@ -3564,7 +3564,7 @@ static void PRVM_MarkReferencedEdicts(prvm_prog_t *prog)
        for(j = 0; j < prog->num_edicts; ++j)
        {
                prvm_edict_t *ed = PRVM_EDICT_NUM(j);
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                ed->priv.required->mark = PRVM_IsEdictRelevant(prog, ed) ? stage : 0;
        }
@@ -3590,7 +3590,7 @@ static void PRVM_MarkReferencedEdicts(prvm_prog_t *prog)
                for(j = 0; j < prog->num_edicts; ++j)
                {
                        prvm_edict_t *ed = PRVM_EDICT_NUM(j);
-                       if(ed->priv.required->free)
+                       if(ed->free)
                                continue;
                        if(ed->priv.required->mark)
                                continue;
@@ -3632,7 +3632,7 @@ void PRVM_LeakTest(prvm_prog_t *prog)
        for(j = 0; j < prog->num_edicts; ++j)
        {
                prvm_edict_t *ed = PRVM_EDICT_NUM(j);
-               if(ed->priv.required->free)
+               if(ed->free)
                        continue;
                if(!ed->priv.required->mark)
                if(ed->priv.required->allocation_origin)
index 69600ec163868685e3a4e4e924747a436ba35f21..7e10a4fa4310e5d7acd49ca3ea4243aa8b3f9847 100644 (file)
--- a/qtypes.h
+++ b/qtypes.h
@@ -27,6 +27,19 @@ typedef bool qbool;
 #define RESTRICT
 #endif
 
+typedef int8_t i8;
+typedef int16_t i16;
+typedef int32_t i32;
+typedef int64_t i64;
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+
+typedef intptr_t iptr;
+typedef uintptr_t uptr;
+
 // LadyHavoc: upgrade the prvm to double precision for better time values
 // LadyHavoc: to be enabled when bugs are worked out...
 //#define PRVM_64
@@ -53,9 +66,4 @@ typedef float vec_t;
 typedef vec_t vec2_t[2];
 typedef vec_t vec3_t[3];
 typedef vec_t vec4_t[4];
-typedef vec_t vec5_t[5];
-typedef vec_t vec6_t[6];
-typedef vec_t vec7_t[7];
-typedef vec_t vec8_t[8];
-
 #endif
diff --git a/sbar.c b/sbar.c
index 6fc6c327cbd3855abedacd3debdbc97dc809091f..be13963350a42847b088fb9afd0c7aa9427a8ea9 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -376,16 +376,16 @@ void Sbar_Init (void)
        Cvar_RegisterVariable(&cl_showdate_format);
        Cvar_RegisterVariable(&cl_showtex);
        
-       Cvar_RegisterAlias(&cl_showfps, "showfps");
-       Cvar_RegisterAlias(&cl_showsound, "showsound");
-       Cvar_RegisterAlias(&cl_showblur, "showblur");
-       Cvar_RegisterAlias(&cl_showspeed, "showspeed");
-       Cvar_RegisterAlias(&cl_showtopspeed, "showtopspeed");
-       Cvar_RegisterAlias(&cl_showtime, "showtime");
-       Cvar_RegisterAlias(&cl_showtime_format, "showtime_format");
-       Cvar_RegisterAlias(&cl_showdate, "showdate");
-       Cvar_RegisterAlias(&cl_showdate_format, "showdate_format");
-       Cvar_RegisterAlias(&cl_showtex, "showtex");
+       Cvar_RegisterVirtual(&cl_showfps, "showfps");
+       Cvar_RegisterVirtual(&cl_showsound, "showsound");
+       Cvar_RegisterVirtual(&cl_showblur, "showblur");
+       Cvar_RegisterVirtual(&cl_showspeed, "showspeed");
+       Cvar_RegisterVirtual(&cl_showtopspeed, "showtopspeed");
+       Cvar_RegisterVirtual(&cl_showtime, "showtime");
+       Cvar_RegisterVirtual(&cl_showtime_format, "showtime_format");
+       Cvar_RegisterVirtual(&cl_showdate, "showdate");
+       Cvar_RegisterVirtual(&cl_showdate_format, "showdate_format");
+       Cvar_RegisterVirtual(&cl_showtex, "showtex");
        
        Cvar_RegisterVariable(&sbar_alpha_bg);
        Cvar_RegisterVariable(&sbar_alpha_fg);
index 07639e4b5f52c530fa71cc50e974fe12201fc95d..02d3786bb6319ec8450539e9695b7d15f69bb472 100644 (file)
--- a/server.h
+++ b/server.h
@@ -515,7 +515,7 @@ void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int v
 void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation, float speed);
 
 void SV_ConnectClient (int clientnum, netconn_t *netconnection);
-void SV_DropClient (qbool crash);
+void SV_DropClient (qbool leaving, const char *reason, ... );
 
 void SV_ClientCommands(const char *fmt, ...) DP_FUNC_PRINTF(1);
 
index 659a2815c92c58f5a4e88cdcb0e52d8fb89b8c59..036f4c63f1588cae58155a02479a9ec77f9ae1b7 100644 (file)
@@ -62,7 +62,7 @@ static void SV_Map_f(cmd_state_t *cmd)
                Cvar_Set(&cvars_all, "warpmark", "");
 
        if(host.hook.Disconnect)
-               host.hook.Disconnect();
+               host.hook.Disconnect(false, NULL);
 
        SV_Shutdown();
 
@@ -1026,6 +1026,7 @@ static void SV_Kick_f(cmd_state_t *cmd)
 {
        const char *who;
        const char *message = NULL;
+       char reason[512];
        client_t *save;
        int i;
        qbool byNumber = false;
@@ -1084,10 +1085,11 @@ static void SV_Kick_f(cmd_state_t *cmd)
                                message++;
                }
                if (message)
-                       SV_ClientPrintf("Kicked by %s: %s\n", who, message);
+                       SV_DropClient (false, va(reason, sizeof(reason), "Kicked by %s: %s", who, message)); // kicked
+                       //SV_ClientPrintf("Kicked by %s: %s\n", who, message);
                else
-                       SV_ClientPrintf("Kicked by %s\n", who);
-               SV_DropClient (false); // kicked
+                       //SV_ClientPrintf("Kicked by %s\n", who);
+                       SV_DropClient (false, va(reason, sizeof(reason), "Kicked by %s", who)); // kicked
        }
 
        host_client = save;
@@ -1556,7 +1558,7 @@ static void SV_Ent_Remove_f(cmd_state_t *cmd)
                                return;
                }
 
-               if(!ed->priv.required->free)
+               if(!ed->free)
                {
                        print("Removed a \"%s\"\n", PRVM_GetString(prog, PRVM_serveredictstring(ed, classname)));
                        PRVM_ED_ClearEdict(prog, ed);
@@ -1580,7 +1582,7 @@ static void SV_Ent_Remove_All_f(cmd_state_t *cmd)
 
        for (i = 0, rmcount = 0, ed = PRVM_EDICT_NUM(i); i < prog->num_edicts; i++, ed = PRVM_NEXT_EDICT(ed))
        {
-               if(!ed->priv.required->free && !strcmp(PRVM_GetString(prog, PRVM_serveredictstring(ed, classname)), Cmd_Argv(cmd, 1)))
+               if(!ed->free && !strcmp(PRVM_GetString(prog, PRVM_serveredictstring(ed, classname)), Cmd_Argv(cmd, 1)))
                {
                        if(!i)
                        {
index 7754a35272c742cd698d35be3efef2f3374e552b..4479a30e6a77ad4e2eb0a46cee9bd8f4751cb243 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -526,8 +526,8 @@ void SV_Init (void)
        Cvar_RegisterVariable (&skill);
        Cvar_RegisterVariable (&host_timescale);
        Cvar_RegisterCallback (&host_timescale, Host_Timescale_c);
-       Cvar_RegisterAlias (&host_timescale, "slowmo");
-       Cvar_RegisterAlias (&host_timescale, "timescale");
+       Cvar_RegisterVirtual (&host_timescale, "slowmo");
+       Cvar_RegisterVirtual (&host_timescale, "timescale");
        Cvar_RegisterVariable (&sv_accelerate);
        Cvar_RegisterVariable (&sv_aim);
        Cvar_RegisterVariable (&sv_airaccel_qw);
@@ -618,7 +618,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_protocolname);
        Cvar_RegisterVariable (&sv_random_seed);
        Cvar_RegisterVariable (&host_limitlocal);
-       Cvar_RegisterAlias(&host_limitlocal, "sv_ratelimitlocalplayer");
+       Cvar_RegisterVirtual(&host_limitlocal, "sv_ratelimitlocalplayer");
        Cvar_RegisterVariable (&sv_sound_land);
        Cvar_RegisterVariable (&sv_sound_watersplash);
        Cvar_RegisterVariable (&sv_stepheight);
@@ -984,14 +984,31 @@ void SV_ConnectClient (int clientnum, netconn_t *netconnection)
 SV_DropClient
 
 Called when the player is getting totally kicked off the host
-if (crash = true), don't bother sending signofs
+if (leaving = true), don't bother sending signofs
 =====================
 */
-void SV_DropClient(qbool crash)
+void SV_DropClient(qbool leaving, const char *fmt, ... )
 {
        prvm_prog_t *prog = SVVM_prog;
        int i;
-       Con_Printf("Client \"%s\" dropped\n", host_client->name);
+
+       va_list argptr;
+       char reason[512] = "";
+
+       Con_Printf("Client \"%s\" dropped", host_client->name);
+
+       if(fmt)
+       {
+               va_start(argptr, fmt);
+               dpvsnprintf(reason, sizeof(reason), fmt, argptr);
+               va_end(argptr);
+
+               Con_Printf(" (%s)\n", reason);
+       }
+       else
+       {
+               Con_Printf(" \n");
+       }
 
        SV_StopDemoRecording(host_client);
 
@@ -1001,15 +1018,22 @@ void SV_DropClient(qbool crash)
        if (host_client->netconnection)
        {
                // tell the client to be gone
-               if (!crash)
+               if (!leaving)
                {
                        // LadyHavoc: no opportunity for resending, so use unreliable 3 times
-                       unsigned char bufdata[8];
+                       unsigned char bufdata[520]; // Disconnect reason string can be 512 characters
                        sizebuf_t buf;
                        memset(&buf, 0, sizeof(buf));
                        buf.data = bufdata;
                        buf.maxsize = sizeof(bufdata);
                        MSG_WriteByte(&buf, svc_disconnect);
+                       if(fmt)
+                       {
+                               if(sv.protocol == PROTOCOL_DARKPLACES8)
+                                       MSG_WriteString(&buf, reason);
+                               else
+                                       SV_ClientPrintf("%s\n", reason);
+                       }
                        NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
                        NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
                        NetConn_SendUnreliableMessage(host_client->netconnection, &buf, sv.protocol, 10000, 0, false);
@@ -1037,6 +1061,10 @@ void SV_DropClient(qbool crash)
                NetConn_Close(host_client->netconnection);
                host_client->netconnection = NULL;
        }
+       if(fmt)
+               SV_BroadcastPrintf("\003^3%s left the game (%s)\n", host_client->name, reason);
+       else
+               SV_BroadcastPrintf("\003^3%s left the game\n", host_client->name);
 
        // if a download is active, close it
        if (host_client->download_file)
@@ -1556,7 +1584,7 @@ model_t *SV_GetModelFromEdict(prvm_edict_t *ed)
 {
        prvm_prog_t *prog = SVVM_prog;
        int modelindex;
-       if (!ed || ed->priv.server->free)
+       if (!ed || ed->free)
                return NULL;
        modelindex = (int)PRVM_serveredictfloat(ed, modelindex);
        return (modelindex > 0 && modelindex < MAX_MODELS) ? sv.models[modelindex] : NULL;
@@ -1583,7 +1611,7 @@ static void SV_CreateBaseline (void)
                // LadyHavoc: always clear state values, whether the entity is in use or not
                svent->priv.server->baseline = defaultstate;
 
-               if (svent->priv.server->free)
+               if (svent->free)
                        continue;
                if (entnum > svs.maxclients && !PRVM_serveredictfloat(svent, modelindex))
                        continue;
@@ -1937,7 +1965,7 @@ void SV_SpawnServer (const char *map)
        // AK possible hack since num_edicts is still 0
        ent = PRVM_EDICT_NUM(0);
        memset (ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
-       ent->priv.server->free = false;
+       ent->free = false;
        PRVM_serveredictstring(ent, model) = PRVM_SetEngineString(prog, sv.worldname);
        PRVM_serveredictfloat(ent, modelindex) = 1;             // world model
        PRVM_serveredictfloat(ent, solid) = SOLID_BSP;
@@ -2083,7 +2111,7 @@ void SV_Shutdown(void)
        }
        for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
                if (host_client->active)
-                       SV_DropClient(false); // server shutdown
+                       SV_DropClient(false, "Server shutting down"); // server shutdown
 
        NetConn_CloseServerPorts();
 
@@ -2113,7 +2141,7 @@ static void SVVM_end_increase_edicts(prvm_prog_t *prog)
 
        // link every entity except world
        for (i = 1, ent = prog->edicts;i < prog->num_edicts;i++, ent++)
-               if (!ent->priv.server->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
+               if (!ent->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
                        SV_LinkEdict(ent);
 }
 
@@ -2189,9 +2217,10 @@ static void SVVM_free_edict(prvm_prog_t *prog, prvm_edict_t *ed)
        PRVM_serveredictfloat(ed, solid) = 0;
 
        VM_RemoveEdictSkeleton(prog, ed);
+#ifdef USEODE
        World_Physics_RemoveFromEntity(&sv.world, ed);
        World_Physics_RemoveJointFromEntity(&sv.world, ed);
-
+#endif
        // make sure csqc networking is aware of the removed entity
        e = PRVM_NUM_FOR_EDICT(ed);
        sv.csqcentityversion[e] = 0;
@@ -2209,7 +2238,7 @@ static void SVVM_count_edicts(prvm_prog_t *prog)
        for (i=0 ; i<prog->num_edicts ; i++)
        {
                ent = PRVM_EDICT_NUM(i);
-               if (ent->priv.server->free)
+               if (ent->free)
                        continue;
                active++;
                if (PRVM_serveredictfloat(ent, solid))
@@ -2445,17 +2474,8 @@ static void SV_CheckTimeouts(void)
 
        // never timeout loopback connections
        for (i = (host_isclient.integer ? 1 : 0), host_client = &svs.clients[i]; i < svs.maxclients; i++, host_client++)
-       {
                if (host_client->netconnection && host.realtime > host_client->netconnection->timeout)
-               {
-                       if (host_client->begun)
-                               SV_BroadcastPrintf("Client \"%s\" connection timed out\n", host_client->name);
-                       else
-                               Con_Printf("Client \"%s\" connection timed out\n", host_client->name);
-
-                       SV_DropClient(false);
-               }
-       }
+                       SV_DropClient(false, "Timed out");
 }
 
 /*
index a72a7ca6acf5b8a0142c5df48bc506834fb4635c..a918ea25603c7145aa59e09174643011a5e22152 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -689,7 +689,7 @@ int SV_EntitiesInBox(const vec3_t mins, const vec3_t maxs, int maxedicts, prvm_e
                for (edictindex = 1;edictindex < prog->num_edicts;edictindex++)
                {
                        ed = PRVM_EDICT_NUM(edictindex);
-                       if (!ed->priv.required->free && BoxesOverlap(PRVM_serveredictvector(ed, absmin), PRVM_serveredictvector(ed, absmax), paddedmins, paddedmaxs))
+                       if (!ed->free && BoxesOverlap(PRVM_serveredictvector(ed, absmin), PRVM_serveredictvector(ed, absmax), paddedmins, paddedmaxs))
                        {
                                resultedicts[numresultedicts++] = ed;
                                if (numresultedicts == maxedicts)
@@ -734,7 +734,7 @@ void SV_LinkEdict_TouchAreaGrid(prvm_edict_t *ent)
        if (ent == prog->edicts)
                return;         // don't add the world
 
-       if (ent->priv.server->free)
+       if (ent->free)
                return;
 
        if (PRVM_serveredictfloat(ent, solid) == SOLID_NOT)
@@ -811,7 +811,7 @@ void SV_LinkEdict (prvm_edict_t *ent)
        if (ent == prog->edicts)
                return;         // don't add the world
 
-       if (ent->priv.server->free)
+       if (ent->free)
                return;
 
        modelindex = (int)PRVM_serveredictfloat(ent, modelindex);
@@ -1089,7 +1089,7 @@ static qbool SV_RunThink (prvm_edict_t *ent)
        if (PRVM_serveredictfloat(ent, nextthink) <= 0 || PRVM_serveredictfloat(ent, nextthink) > sv.time + sv.frametime)
                return true;
 
-       for (iterations = 0;iterations < 128  && !ent->priv.server->free;iterations++)
+       for (iterations = 0;iterations < 128  && !ent->free;iterations++)
        {
                PRVM_serverglobalfloat(time) = max(sv.time, PRVM_serveredictfloat(ent, nextthink));
                PRVM_serveredictfloat(ent, nextthink) = 0;
@@ -1103,7 +1103,7 @@ static qbool SV_RunThink (prvm_edict_t *ent)
                if (PRVM_serveredictfloat(ent, nextthink) <= PRVM_serverglobalfloat(time) || PRVM_serveredictfloat(ent, nextthink) > sv.time + sv.frametime || !sv_gameplayfix_multiplethinksperframe.integer)
                        break;
        }
-       return !ent->priv.server->free;
+       return !ent->free;
 }
 
 /*
@@ -1126,7 +1126,7 @@ static void SV_Impact (prvm_edict_t *e1, trace_t *trace)
 
        VM_SetTraceGlobals(prog, trace);
 
-       if (!e1->priv.server->free && !e2->priv.server->free && PRVM_serveredictfunction(e1, touch) && PRVM_serveredictfloat(e1, solid) != SOLID_NOT)
+       if (!e1->free && !e2->free && PRVM_serveredictfunction(e1, touch) && PRVM_serveredictfloat(e1, solid) != SOLID_NOT)
        {
                PRVM_serverglobalfloat(time) = sv.time;
                PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(e1);
@@ -1134,7 +1134,7 @@ static void SV_Impact (prvm_edict_t *e1, trace_t *trace)
                prog->ExecuteProgram(prog, PRVM_serveredictfunction(e1, touch), "QC function self.touch is missing");
        }
 
-       if (!e1->priv.server->free && !e2->priv.server->free && PRVM_serveredictfunction(e2, touch) && PRVM_serveredictfloat(e2, solid) != SOLID_NOT)
+       if (!e1->free && !e2->free && PRVM_serveredictfunction(e2, touch) && PRVM_serveredictfloat(e2, solid) != SOLID_NOT)
        {
                PRVM_serverglobalfloat(time) = sv.time;
                PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(e2);
@@ -2626,7 +2626,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        // we can trust FL_ONGROUND if groundentity is world because it never moves
                        return;
                }
-               else if (ent->priv.server->suspendedinairflag && groundentity->priv.server->free)
+               else if (ent->priv.server->suspendedinairflag && groundentity->free)
                {
                        // if ent was supported by a brush model on previous frame,
                        // and groundentity is now freed, set groundentity to 0 (world)
@@ -2659,7 +2659,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                VectorScale(PRVM_serveredictvector(ent, velocity), movetime, move);
                if(!SV_PushEntity(&trace, ent, move, true))
                        return; // teleported
-               if (ent->priv.server->free)
+               if (ent->free)
                        return;
                if (trace.bmodelstartsolid && sv_gameplayfix_unstickentities.integer)
                {
@@ -2667,7 +2667,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        SV_UnstickEntity(ent);
                        if(!SV_PushEntity(&trace, ent, move, true))
                                return; // teleported
-                       if (ent->priv.server->free)
+                       if (ent->free)
                                return;
                }
                if (trace.fraction == 1)
@@ -3176,8 +3176,10 @@ void SV_Physics (void)
        PRVM_serverglobalfloat(frametime) = sv.frametime;
        prog->ExecuteProgram(prog, PRVM_serverfunction(StartFrame), "QC function StartFrame is missing");
 
+#ifdef USEODE
        // run physics engine
        World_Physics_Frame(&sv.world, sv.frametime, sv_gravity.value);
+#endif
 
 //
 // treat each object in turn
@@ -3186,22 +3188,22 @@ void SV_Physics (void)
        // if force_retouch, relink all the entities
        if (PRVM_serverglobalfloat(force_retouch) > 0)
                for (i = 1, ent = PRVM_EDICT_NUM(i);i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
-                       if (!ent->priv.server->free)
+                       if (!ent->free)
                                SV_LinkEdict_TouchAreaGrid(ent); // force retouch even for stationary
 
        if (sv_gameplayfix_consistentplayerprethink.integer)
        {
                // run physics on the client entities in 3 stages
                for (i = 1, ent = PRVM_EDICT_NUM(i), host_client = svs.clients;i <= svs.maxclients;i++, ent = PRVM_NEXT_EDICT(ent), host_client++)
-                       if (!ent->priv.server->free)
+                       if (!ent->free)
                                SV_Physics_ClientEntity_PreThink(ent);
 
                for (i = 1, ent = PRVM_EDICT_NUM(i), host_client = svs.clients;i <= svs.maxclients;i++, ent = PRVM_NEXT_EDICT(ent), host_client++)
-                       if (!ent->priv.server->free)
+                       if (!ent->free)
                                SV_Physics_ClientEntity(ent);
 
                for (i = 1, ent = PRVM_EDICT_NUM(i), host_client = svs.clients;i <= svs.maxclients;i++, ent = PRVM_NEXT_EDICT(ent), host_client++)
-                       if (!ent->priv.server->free)
+                       if (!ent->free)
                                SV_Physics_ClientEntity_PostThink(ent);
        }
        else
@@ -3209,7 +3211,7 @@ void SV_Physics (void)
                // run physics on the client entities
                for (i = 1, ent = PRVM_EDICT_NUM(i), host_client = svs.clients;i <= svs.maxclients;i++, ent = PRVM_NEXT_EDICT(ent), host_client++)
                {
-                       if (!ent->priv.server->free)
+                       if (!ent->free)
                        {
                                SV_Physics_ClientEntity_PreThink(ent);
                                SV_Physics_ClientEntity(ent);
@@ -3222,13 +3224,13 @@ void SV_Physics (void)
        if (!sv_freezenonclients.integer)
        {
                for (;i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
-                       if (!ent->priv.server->free)
+                       if (!ent->free)
                                SV_Physics_Entity(ent);
                // make a second pass to see if any ents spawned this frame and make
                // sure they run their move/think
                if (sv_gameplayfix_delayprojectiles.integer < 0)
                        for (i = svs.maxclients + 1, ent = PRVM_EDICT_NUM(i);i < prog->num_edicts;i++, ent = PRVM_NEXT_EDICT(ent))
-                               if (!ent->priv.server->move && !ent->priv.server->free)
+                               if (!ent->priv.server->move && !ent->free)
                                        SV_Physics_Entity(ent);
        }
 
index 799a0d8a08b2aa450e729dd8fa081e89dff3c1fb..814e2db13cdad1f34ce03671438b81c2618516fa 100644 (file)
--- a/sv_save.c
+++ b/sv_save.c
@@ -272,7 +272,7 @@ void SV_Loadgame_f(cmd_state_t *cmd)
 
        // stop playing demos
        if (cls.demoplayback)
-               CL_Disconnect ();
+               CL_Disconnect (false, NULL);
 
 #ifdef CONFIG_MENU
        // remove menu
@@ -434,7 +434,7 @@ void SV_Loadgame_f(cmd_state_t *cmd)
                                PRVM_MEM_IncreaseEdicts(prog);
                        ent = PRVM_EDICT_NUM(entnum);
                        memset(ent->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t));
-                       ent->priv.server->free = false;
+                       ent->free = false;
 
                        if(developer_entityparsing.integer)
                                Con_Printf("SV_Loadgame_f: loading edict %d\n", entnum);
@@ -442,7 +442,7 @@ void SV_Loadgame_f(cmd_state_t *cmd)
                        PRVM_ED_ParseEdict (prog, start, ent);
 
                        // link it into the bsp tree
-                       if (!ent->priv.server->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
+                       if (!ent->free && !VectorCompare(PRVM_serveredictvector(ent, absmin), PRVM_serveredictvector(ent, absmax)))
                                SV_LinkEdict(ent);
                }
 
index 984f9635ac4494afe78410e2d937510be2cccde2..a1ee1050ab3cb69b14251c0be1bdc3b7ef165e27 100644 (file)
--- a/sv_send.c
+++ b/sv_send.c
@@ -709,7 +709,7 @@ static void SV_PrepareEntitiesForSending(void)
        memset(sv.sendentitiesindex, 0, prog->num_edicts * sizeof(*sv.sendentitiesindex));
        for (e = 1, ent = PRVM_NEXT_EDICT(prog->edicts);e < prog->num_edicts;e++, ent = PRVM_NEXT_EDICT(ent))
        {
-               if (!ent->priv.server->free && SV_PrepareEntityForSending(ent, sv.sendentities + sv.numsendentities, e))
+               if (!ent->free && SV_PrepareEntityForSending(ent, sv.sendentities + sv.numsendentities, e))
                {
                        sv.sendentitiesindex[e] = sv.sendentities + sv.numsendentities;
                        sv.numsendentities++;
@@ -1006,7 +1006,7 @@ void SV_AddCameraEyes(void)
        // check line of sight to portal entities and add them to PVS
        for (e = 1, ed = PRVM_NEXT_EDICT(prog->edicts);e < prog->num_edicts;e++, ed = PRVM_NEXT_EDICT(ed))
        {
-               if (!ed->priv.server->free)
+               if (!ed->free)
                {
                        if(PRVM_serveredictfunction(ed, camera_transform))
                        {
@@ -1651,7 +1651,7 @@ static void SV_UpdateToReliableMessages (void)
                if (clientcamera > 0)
                {
                        int oldclientcamera = host_client->clientcamera;
-                       if (clientcamera >= prog->max_edicts || PRVM_EDICT_NUM(clientcamera)->priv.required->free)
+                       if (clientcamera >= prog->max_edicts || PRVM_EDICT_NUM(clientcamera)->free)
                                clientcamera = PRVM_NUM_FOR_EDICT(host_client->edict);
                        host_client->clientcamera = clientcamera;
 
@@ -1712,7 +1712,7 @@ void SV_SendClientMessages(void)
 
                if (host_client->netconnection->message.overflowed)
                {
-                       SV_DropClient (true);   // if the message couldn't send, kick off
+                       SV_DropClient (true, "Buffer overflow in net message"); // if the message couldn't send, kick off
                        continue;
                }
 
index 1cb5a3f057c305be869a94fdd163658e2098427b..6a621bac6d293c9ec2a573187e7ee821f1f805c9 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -718,7 +718,7 @@ static void SV_ReadClientMove (void)
                }
                // as requested by FrikaC, cursor_trace_ent is reset to world if the
                // entity is free at time of receipt
-               if (PRVM_EDICT_NUM(move->cursor_entitynumber)->priv.server->free)
+               if (PRVM_EDICT_NUM(move->cursor_entitynumber)->free)
                        move->cursor_entitynumber = 0;
                if (sv_message.badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
        }
@@ -999,14 +999,14 @@ void SV_ReadClientMessage(void)
                if (!host_client->active)
                {
                        // a command caused an error
-                       SV_DropClient (false);
+                       SV_DropClient (false, "Connection closing");
                        return;
                }
 
                if (sv_message.badread)
                {
                        Con_Print("SV_ReadClientMessage: badread\n");
-                       SV_DropClient (false);
+                       SV_DropClient (false, "An internal server error occurred");
                        return;
                }
 
@@ -1025,7 +1025,7 @@ void SV_ReadClientMessage(void)
                        Con_Printf("SV_ReadClientMessage: unknown command char %i (at offset 0x%x)\n", netcmd, sv_message.readcount);
                        if (developer_networking.integer)
                                Com_HexDumpToConsole(sv_message.data, sv_message.cursize);
-                       SV_DropClient (false);
+                       SV_DropClient (false, "Unknown message sent to the server");
                        return;
 
                case clc_nop:
@@ -1076,7 +1076,9 @@ clc_stringcmd_invalid:
                        break;
 
                case clc_disconnect:
-                       SV_DropClient (false); // client wants to disconnect
+                       SV_DropClient (true, sv.protocol == PROTOCOL_DARKPLACES8
+                                      ? MSG_ReadString(&sv_message, sv_readstring, sizeof(sv_readstring))
+                                      : "Disconnect by user"); // client wants to disconnect
                        return;
 
                case clc_move:
index e17c24ea7feb7646d1f668204b3d61441d340358..672ff70d1f8e7116237d6f81737fe2b8012a014b 100644 (file)
@@ -254,7 +254,7 @@ static void VM_SV_setorigin(prvm_prog_t *prog)
                VM_Warning(prog, "setorigin: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setorigin: can not modify free entity\n");
                return;
@@ -305,7 +305,7 @@ static void VM_SV_setsize(prvm_prog_t *prog)
                VM_Warning(prog, "setsize: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setsize: can not modify free entity\n");
                return;
@@ -338,7 +338,7 @@ static void VM_SV_setmodel(prvm_prog_t *prog)
                VM_Warning(prog, "setmodel: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setmodel: can not modify free entity\n");
                return;
@@ -806,7 +806,7 @@ static int VM_SV_newcheckclient(prvm_prog_t *prog, int check)
                // look up the client's edict
                ent = PRVM_EDICT_NUM(i);
                // check if it is to be ignored, but never ignore the one we started on (prevent infinite loop)
-               if (i != check && (ent->priv.server->free || PRVM_serveredictfloat(ent, health) <= 0 || ((int)PRVM_serveredictfloat(ent, flags) & FL_NOTARGET)))
+               if (i != check && (ent->free || PRVM_serveredictfloat(ent, health) <= 0 || ((int)PRVM_serveredictfloat(ent, flags) & FL_NOTARGET)))
                        continue;
                // found a valid client (possibly the same one again)
                break;
@@ -853,7 +853,7 @@ static void VM_SV_checkclient(prvm_prog_t *prog)
 
        // return check if it might be visible
        ent = PRVM_EDICT_NUM(sv.lastcheck);
-       if (ent->priv.server->free || PRVM_serveredictfloat(ent, health) <= 0)
+       if (ent->free || PRVM_serveredictfloat(ent, health) <= 0)
        {
                VM_RETURN_EDICT(prog->edicts);
                return;
@@ -901,7 +901,7 @@ static void VM_SV_checkpvs(prvm_prog_t *prog)
        VectorCopy(PRVM_G_VECTOR(OFS_PARM0), viewpos);
        viewee = PRVM_G_EDICT(OFS_PARM1);
 
-       if(viewee->priv.server->free)
+       if(viewee->free)
        {
                VM_Warning(prog, "checkpvs: can not check free entity\n");
                PRVM_G_FLOAT(OFS_RETURN) = 4;
@@ -1096,7 +1096,7 @@ static void VM_SV_walkmove(prvm_prog_t *prog)
                VM_Warning(prog, "walkmove: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "walkmove: can not modify free entity\n");
                return;
@@ -1151,7 +1151,7 @@ static void VM_SV_droptofloor(prvm_prog_t *prog)
                VM_Warning(prog, "droptofloor: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "droptofloor: can not modify free entity\n");
                return;
@@ -1307,7 +1307,7 @@ static void VM_SV_aim(prvm_prog_t *prog)
                VM_Warning(prog, "aim: can not use world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "aim: can not use free entity\n");
                return;
@@ -1535,7 +1535,7 @@ static void VM_SV_makestatic(prvm_prog_t *prog)
                VM_Warning(prog, "makestatic: can not modify world entity\n");
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "makestatic: can not modify free entity\n");
                return;
@@ -1768,7 +1768,7 @@ static void VM_SV_copyentity(prvm_prog_t *prog)
                VM_Warning(prog, "copyentity: can not read world entity\n");
                return;
        }
-       if (in->priv.server->free)
+       if (in->free)
        {
                VM_Warning(prog, "copyentity: can not read free entity\n");
                return;
@@ -1779,7 +1779,7 @@ static void VM_SV_copyentity(prvm_prog_t *prog)
                VM_Warning(prog, "copyentity: can not modify world entity\n");
                return;
        }
-       if (out->priv.server->free)
+       if (out->free)
        {
                VM_Warning(prog, "copyentity: can not modify free entity\n");
                return;
@@ -2378,7 +2378,7 @@ static void VM_SV_setattachment(prvm_prog_t *prog)
                VM_Warning(prog, "setattachment: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setattachment: can not modify free entity\n");
                return;
@@ -2492,7 +2492,7 @@ static int SV_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *e
 
        if (ent == prog->edicts)
                return 1;
-       if (ent->priv.server->free)
+       if (ent->free)
                return 2;
 
        modelindex = (int)PRVM_serveredictfloat(ent, modelindex);
@@ -2561,7 +2561,7 @@ static void VM_SV_gettagindex(prvm_prog_t *prog)
                VM_Warning(prog, "VM_SV_gettagindex(entity #%i): can't affect world entity\n", PRVM_NUM_FOR_EDICT(ent));
                return;
        }
-       if (ent->priv.server->free)
+       if (ent->free)
        {
                VM_Warning(prog, "VM_SV_gettagindex(entity #%i): can't affect free entity\n", PRVM_NUM_FOR_EDICT(ent));
                return;
@@ -2657,7 +2657,7 @@ static void VM_SV_dropclient(prvm_prog_t *prog)
        }
        oldhostclient = host_client;
        host_client = svs.clients + clientnum;
-       SV_DropClient(false);
+       SV_DropClient(false, "Client dropped");
        host_client = oldhostclient;
 }
 
@@ -2730,7 +2730,7 @@ static void VM_SV_setmodelindex(prvm_prog_t *prog)
                VM_Warning(prog, "setmodelindex: can not modify world entity\n");
                return;
        }
-       if (e->priv.server->free)
+       if (e->free)
        {
                VM_Warning(prog, "setmodelindex: can not modify free entity\n");
                return;
index 50cca9d99d5688c2e3442caf963f04e8bfbcfe3a..3f37a8e4f0af84045d82228817d890117bfe0816 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -1,7 +1,5 @@
-#include "darkplaces.h"
-
 #ifdef WIN32
-#include <io.h>
+#include <io.h> // Include this BEFORE darkplaces.h because it uses strncpy which trips DP_STATIC_ASSERT
 #include "conio.h"
 #else
 #include <unistd.h>
 
 #include <signal.h>
 
+/*
+ * Include this BEFORE darkplaces.h because it breaks wrapping
+ * _Static_assert. Cloudwalk has no idea how or why so don't ask.
+ */
 #include <SDL.h>
 
+#include "darkplaces.h"
+
 #ifdef WIN32
 #ifdef _MSC_VER
 #pragma comment(lib, "sdl2.lib")
index cf2ba8649865ce1d182ae0256c0414335bf136ba..5ebb7757cbb7c7602bdda239002434e9ae7f638d 100644 (file)
@@ -29,6 +29,7 @@ void VID_Shutdown(void)
 {
 }
 
+#ifndef WIN32
 static void signal_handler(int sig)
 {
        Con_Printf("Received signal %d, exiting...\n", sig);
@@ -37,7 +38,6 @@ static void signal_handler(int sig)
 
 static void InitSig(void)
 {
-#ifndef WIN32
        signal(SIGHUP, signal_handler);
        signal(SIGINT, signal_handler);
        signal(SIGQUIT, signal_handler);
@@ -48,8 +48,8 @@ static void InitSig(void)
        signal(SIGFPE, signal_handler);
        signal(SIGSEGV, signal_handler);
        signal(SIGTERM, signal_handler);
-#endif
 }
+#endif
 
 void VID_SetMouse (qbool fullscreengrab, qbool relative, qbool hidecursor)
 {
@@ -61,7 +61,9 @@ void VID_Finish (void)
 
 void VID_Init(void)
 {
+#ifndef WIN32
        InitSig(); // trap evil signals
+#endif
 }
 
 qbool VID_InitMode(viddef_mode_t *mode)
diff --git a/world.c b/world.c
index 26ffd9bbe57d4fd5365eb1b279364fc72b8a583f..9bdf107911e93256f63e51d0ae7b88b25d747a5a 100644 (file)
--- a/world.c
+++ b/world.c
@@ -32,29 +32,45 @@ line of sight checks trace->inopen and trace->inwater, but bullets don't
 
 */
 
+#ifdef USEODE
 static void World_Physics_Init(void);
+#endif
 void World_Init(void)
 {
        Collision_Init();
+#ifdef USEODE
        World_Physics_Init();
+#endif
 }
 
+#ifdef USEODE
 static void World_Physics_Shutdown(void);
+#endif
 void World_Shutdown(void)
 {
+#ifdef USEODE
        World_Physics_Shutdown();
+#endif
 }
 
+#ifdef USEODE
 static void World_Physics_Start(world_t *world);
+#endif
 void World_Start(world_t *world)
 {
+#ifdef USEODE
        World_Physics_Start(world);
+#endif
 }
 
+#ifdef USEODE
 static void World_Physics_End(world_t *world);
+#endif
 void World_End(world_t *world)
 {
+#ifdef USEODE
        World_Physics_End(world);
+#endif
 }
 
 //============================================================================
@@ -148,10 +164,10 @@ void World_UnlinkAll(world_t *world)
        // unlink all entities one by one
        grid = &world->areagrid_outside;
        while (grid->list.next != &grid->list)
-               World_UnlinkEdict(PRVM_EDICT_NUM(List_Entry(*grid->list.next, link_t, list)->entitynumber));
+               World_UnlinkEdict(PRVM_EDICT_NUM(List_Entry(grid->list.next, link_t, list)->entitynumber));
        for (i = 0, grid = world->areagrid;i < AREA_GRIDNODES;i++, grid++)
                while (grid->list.next != &grid->list)
-                       World_UnlinkEdict(PRVM_EDICT_NUM(List_Entry(*grid->list.next, link_t, list)->entitynumber));
+                       World_UnlinkEdict(PRVM_EDICT_NUM(List_Entry(grid->list.next, link_t, list)->entitynumber));
 }
 
 /*
@@ -173,7 +189,6 @@ int World_EntitiesInBox(world_t *world, const vec3_t requestmins, const vec3_t r
 {
        prvm_prog_t *prog = world->prog;
        int numlist;
-       llist_t *pos;
        link_t *grid;
        link_t *l;
        prvm_edict_t *ent;
@@ -216,14 +231,13 @@ int World_EntitiesInBox(world_t *world, const vec3_t requestmins, const vec3_t r
        if (world->areagrid_outside.list.next)
        {
                grid = &world->areagrid_outside;
-               List_For_Each(pos, &grid->list)
+               List_For_Each_Entry(l, &grid->list, list)
                {
-                       l = List_Entry(*pos, link_t, list);
                        ent = PRVM_EDICT_NUM(l->entitynumber);
                        if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
                        {
                                ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
-                               if (!ent->priv.server->free && BoxesOverlap(paddedmins, paddedmaxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
+                               if (!ent->free && BoxesOverlap(paddedmins, paddedmaxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
                                {
                                        if (numlist < maxlist)
                                                list[numlist] = ent;
@@ -241,14 +255,13 @@ int World_EntitiesInBox(world_t *world, const vec3_t requestmins, const vec3_t r
                {
                        if (grid->list.next)
                        {
-                               List_For_Each(pos, &grid->list)
+                               List_For_Each_Entry(l, &grid->list, list)
                                {
-                                       l = List_Entry(*pos, link_t, list);
                                        ent = PRVM_EDICT_NUM(l->entitynumber);
                                        if (ent->priv.server->areagridmarknumber != world->areagrid_marknumber)
                                        {
                                                ent->priv.server->areagridmarknumber = world->areagrid_marknumber;
-                                               if (!ent->priv.server->free && BoxesOverlap(paddedmins, paddedmaxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
+                                               if (!ent->free && BoxesOverlap(paddedmins, paddedmaxs, ent->priv.server->areamins, ent->priv.server->areamaxs))
                                                {
                                                        if (numlist < maxlist)
                                                                list[numlist] = ent;
@@ -316,7 +329,7 @@ void World_LinkEdict(world_t *world, prvm_edict_t *ent, const vec3_t mins, const
                return;
 
        // don't add free entities
-       if (ent->priv.server->free)
+       if (ent->free)
                return;
 
        VectorCopy(mins, ent->priv.server->areamins);
@@ -1462,15 +1475,12 @@ static dllfunction_t odefuncs[] =
 //     {"dGeomTriMeshDataUpdate",                      (void **) &dGeomTriMeshDataUpdate},
        {NULL, NULL}
 };
-
 // Handle for ODE DLL
 dllhandle_t ode_dll = NULL;
 #endif
-#endif
 
 static void World_Physics_Init(void)
 {
-#ifdef USEODE
 #ifndef LINK_TO_LIBODE
        const char* dllnames [] =
        {
@@ -1554,12 +1564,9 @@ static void World_Physics_Init(void)
                }
 #endif
        }
-#endif
 }
-
 static void World_Physics_Shutdown(void)
 {
-#ifdef USEODE
 #ifndef LINK_TO_LIBODE
        if (ode_dll)
 #endif
@@ -1570,10 +1577,8 @@ static void World_Physics_Shutdown(void)
                ode_dll = NULL;
 #endif
        }
-#endif
 }
 
-#ifdef USEODE
 static void World_Physics_UpdateODE(world_t *world)
 {
        dWorldID odeworld;
@@ -1630,20 +1635,16 @@ static void World_Physics_EnableODE(world_t *world)
 
        World_Physics_UpdateODE(world);
 }
-#endif
 
 static void World_Physics_Start(world_t *world)
 {
-#ifdef USEODE
        if (world->physics.ode)
                return;
        World_Physics_EnableODE(world);
-#endif
 }
 
 static void World_Physics_End(world_t *world)
 {
-#ifdef USEODE
        if (world->physics.ode)
        {
                dWorldDestroy((dWorldID)world->physics.ode_world);
@@ -1651,17 +1652,14 @@ static void World_Physics_End(world_t *world)
                dJointGroupDestroy((dJointGroupID)world->physics.ode_contactgroup);
                world->physics.ode = false;
        }
-#endif
 }
 
 void World_Physics_RemoveJointFromEntity(world_t *world, prvm_edict_t *ed)
 {
        ed->priv.server->ode_joint_type = 0;
-#ifdef USEODE
        if(ed->priv.server->ode_joint)
                dJointDestroy((dJointID)ed->priv.server->ode_joint);
        ed->priv.server->ode_joint = NULL;
-#endif
 }
 
 void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
@@ -1670,7 +1668,6 @@ void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
 
        // entity is not physics controlled, free any physics data
        ed->priv.server->ode_physics = false;
-#ifdef USEODE
        if (ed->priv.server->ode_geom)
                dGeomDestroy((dGeomID)ed->priv.server->ode_geom);
        ed->priv.server->ode_geom = NULL;
@@ -1700,7 +1697,6 @@ void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
                dBodyDestroy((dBodyID)ed->priv.server->ode_body);
        }
        ed->priv.server->ode_body = NULL;
-#endif
        if (ed->priv.server->ode_vertex3f)
                Mem_Free(ed->priv.server->ode_vertex3f);
        ed->priv.server->ode_vertex3f = NULL;
@@ -1723,7 +1719,6 @@ void World_Physics_RemoveFromEntity(world_t *world, prvm_edict_t *ed)
 
 void World_Physics_ApplyCmd(prvm_edict_t *ed, edict_odefunc_t *f)
 {
-#ifdef USEODE
        dBodyID body = (dBodyID)ed->priv.server->ode_body;
 
        switch(f->type)
@@ -1745,10 +1740,8 @@ void World_Physics_ApplyCmd(prvm_edict_t *ed, edict_odefunc_t *f)
        default:
                break;
        }
-#endif
 }
 
-#ifdef USEODE
 static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
 {
        prvm_prog_t *prog = world->prog;
@@ -1865,7 +1858,7 @@ static void World_Physics_Frame_ForceFromEntity(world_t *world, prvm_edict_t *ed
        if (!forcetype)
                return;
        enemy = PRVM_gameedictedict(ed, enemy);
-       if (enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].priv.required->free || prog->edicts[enemy].priv.server->ode_body == 0)
+       if (enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].free || prog->edicts[enemy].priv.server->ode_body == 0)
                return;
        VectorCopy(PRVM_gameedictvector(ed, movedir), movedir);
        VectorCopy(PRVM_gameedictvector(ed, origin), origin);
@@ -1917,9 +1910,9 @@ static void World_Physics_Frame_JointFromEntity(world_t *world, prvm_edict_t *ed
        VectorCopy(PRVM_gameedictvector(ed, movedir), movedir);
        if(movetype == MOVETYPE_PHYSICS)
                jointtype = JOINTTYPE_NONE; // can't have both
-       if(enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].priv.required->free || prog->edicts[enemy].priv.server->ode_body == 0)
+       if(enemy <= 0 || enemy >= prog->num_edicts || prog->edicts[enemy].free || prog->edicts[enemy].priv.server->ode_body == 0)
                enemy = 0;
-       if(aiment <= 0 || aiment >= prog->num_edicts || prog->edicts[aiment].priv.required->free || prog->edicts[aiment].priv.server->ode_body == 0)
+       if(aiment <= 0 || aiment >= prog->num_edicts || prog->edicts[aiment].free || prog->edicts[aiment].priv.server->ode_body == 0)
                aiment = 0;
        // see http://www.ode.org/old_list_archives/2006-January/017614.html
        // we want to set ERP? make it fps independent and work like a spring constant
@@ -2928,7 +2921,7 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2)
                return;
 
        ed1 = (prvm_edict_t *) dGeomGetData(o1);
-       if(ed1 && ed1->priv.server->free)
+       if(ed1 && ed1->free)
                ed1 = NULL;
        if(ed1)
        {
@@ -2939,7 +2932,7 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2)
        }
 
        ed2 = (prvm_edict_t *) dGeomGetData(o2);
-       if(ed2 && ed2->priv.server->free)
+       if(ed2 && ed2->free)
                ed2 = NULL;
        if(ed2)
        {
@@ -3009,11 +3002,9 @@ static void nearCallback (void *data, dGeomID o1, dGeomID o2)
                dJointAttach(c, b1, b2);
        }
 }
-#endif
 
 void World_Physics_Frame(world_t *world, double frametime, double gravity)
 {
-#ifdef USEODE
        prvm_prog_t *prog = world->prog;
        double tdelta, tdelta2, tdelta3, simulationtime, collisiontime;
 
@@ -3053,11 +3044,11 @@ void World_Physics_Frame(world_t *world, double frametime, double gravity)
                if (prog)
                {
                        for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
-                               if (!prog->edicts[i].priv.required->free)
+                               if (!prog->edicts[i].free)
                                        World_Physics_Frame_BodyFromEntity(world, ed);
                        // oh, and it must be called after all bodies were created
                        for (i = 0, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
-                               if (!prog->edicts[i].priv.required->free)
+                               if (!prog->edicts[i].free)
                                        World_Physics_Frame_JointFromEntity(world, ed);
                }
 
@@ -3078,7 +3069,7 @@ void World_Physics_Frame(world_t *world, double frametime, double gravity)
                        {
                                int j;
                                for (j = 0, ed = prog->edicts + j;j < prog->num_edicts;j++, ed++)
-                                       if (!prog->edicts[j].priv.required->free)
+                                       if (!prog->edicts[j].free)
                                                World_Physics_Frame_ForceFromEntity(world, ed);
                        }
                        // run physics (move objects, calculate new velocities)
@@ -3095,7 +3086,7 @@ void World_Physics_Frame(world_t *world, double frametime, double gravity)
                if (prog)
                {
                        for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
-                               if (!prog->edicts[i].priv.required->free)
+                               if (!prog->edicts[i].free)
                                        World_Physics_Frame_BodyToEntity(world, ed);
 
                        // print stats
@@ -3107,7 +3098,7 @@ void World_Physics_Frame(world_t *world, double frametime, double gravity)
                                world->physics.ode_activeovjects = 0;
                                for (i = 1, ed = prog->edicts + i;i < prog->num_edicts;i++, ed++)
                                {
-                                       if (prog->edicts[i].priv.required->free)
+                                       if (prog->edicts[i].free)
                                                continue;
                                        body = (dBodyID)prog->edicts[i].priv.server->ode_body;
                                        if (!body)
@@ -3120,5 +3111,5 @@ void World_Physics_Frame(world_t *world, double frametime, double gravity)
                        }
                }
        }
-#endif
 }
+#endif
diff --git a/zone.c b/zone.c
index b357a013aeec18f0c7d491a081608c37c6c764c7..23258a278c0bcc74b90323f353856bcd265ed662 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -146,6 +146,9 @@ static void mmap_free(void *mem)
 // (Windows growing its swapfile for example)
 static void *attempt_malloc(size_t size)
 {
+#ifndef WIN32
+       return malloc(size);
+#else
        void *base;
        // try for half a second or so
        unsigned int attempts = 500;
@@ -157,6 +160,7 @@ static void *attempt_malloc(size_t size)
                Sys_Sleep(1000);
        }
        return NULL;
+#endif
 }
 #endif
 
@@ -867,14 +871,14 @@ static void MemStats_f(cmd_state_t *cmd)
 }
 
 
-char* Mem_strdup (mempool_t *pool, const char* s)
+char* _Mem_strdup (mempool_t *pool, const char* s, const char *filename, int fileline)
 {
        char* p;
        size_t sz;
        if (s == NULL)
                return NULL;
        sz = strlen (s) + 1;
-       p = (char*)Mem_Alloc (pool, sz);
+       p = (char*)_Mem_Alloc (pool, NULL, sz, 16, filename, fileline);
        strlcpy (p, s, sz);
        return p;
 }
diff --git a/zone.h b/zone.h
index 5fe3c63d19a43f8121aa66bdeeda62b8966730eb..46b2d1df1125a51ee03375eb2d42bfafd46280bd 100644 (file)
--- a/zone.h
+++ b/zone.h
@@ -86,6 +86,7 @@ mempool_t;
 #define Mem_Memalign(pool,alignment,size) _Mem_Alloc(pool, NULL, size, alignment, __FILE__, __LINE__)
 #define Mem_Realloc(pool,data,size) _Mem_Alloc(pool, data, size, 16, __FILE__, __LINE__)
 #define Mem_Free(mem) _Mem_Free(mem, __FILE__, __LINE__)
+#define Mem_strdup(pool, s) _Mem_strdup(pool, s, __FILE__, __LINE__)
 #define Mem_CheckSentinels(data) _Mem_CheckSentinels(data, __FILE__, __LINE__)
 #if MEMPARANOIA
 #define Mem_CheckSentinelsGlobal()  _Mem_CheckSentinelsGlobal(__FILE__, __LINE__)
@@ -106,7 +107,7 @@ void _Mem_CheckSentinelsGlobal(const char *filename, int fileline);
 // if pool is NULL this searches ALL pools for the allocation
 qbool Mem_IsAllocated(mempool_t *pool, void *data);
 
-char* Mem_strdup (mempool_t *pool, const char* s);
+char* _Mem_strdup (mempool_t *pool, const char* s, const char *filename, int fileline);
 
 typedef struct memexpandablearray_array_s
 {
@@ -142,7 +143,9 @@ void Memory_Shutdown (void);
 void Memory_Init_Commands (void);
 
 extern mempool_t *zonemempool;
-#define Z_Malloc(size) Mem_Alloc(zonemempool,size)
+#define Z_Malloc(size) Mem_Alloc(zonemempool, size)
+#define Z_Realloc(data, size) Mem_Realloc(zonemempool, data, size)
+#define Z_strdup(s) Mem_strdup(zonemempool, s)
 #define Z_Free(data) Mem_Free(data)
 
 extern struct cvar_s developer_memory;