--- /dev/null
+é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
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
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
# 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
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);
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));
}
if (ent == prog->edicts)
return; // don't add the world
- if (ent->priv.server->free)
+ if (ent->free)
return;
// set the abs box
}
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]);
}
else
{
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
return;
}
}
}
if (cls.state == ca_connected)
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
// write the forced cd track number, or -1
if (c == 4)
cls.demostarting = true;
// disconnect from server
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
// update networking ports (this is mainly just needed at startup)
NetConn_UpdateSockets();
return;
if (cls.demonum == -1)
cls.demonum = 1;
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
CL_NextDemo();
}
{
if (!cls.demoplayback)
return;
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
}
// LadyHavoc: pausedemo command
break;
case PROTOCOL_DARKPLACES6:
case PROTOCOL_DARKPLACES7:
+ case PROTOCOL_DARKPLACES8:
cl.cmd.predicted = cl_movement.integer != 0;
break;
default:
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;
// 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
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
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");
}
/*
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);
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;
void CL_Disconnect_f(cmd_state_t *cmd)
{
- CL_Disconnect();
+ CL_Disconnect(false, Cmd_Argc(cmd) > 1 ? Cmd_Argv(cmd, 1) : NULL);
}
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]);
}
}
S_StopAllSounds();
// disconnect client from server if active
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
CL_Video_Shutdown();
{
"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
// 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)
if (cls.demonum != -1)
CL_NextDemo();
else
- CL_Disconnect();
+ CL_Disconnect(true, NULL);
break;
case qw_svc_print:
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:
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);
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);
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;
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;
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;
// 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;
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;
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;
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;
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;
if (ent == prog->edicts)
return 1;
- if (ent->priv.server->free)
+ if (ent->free)
return 2;
model = CL_GetModelFromEdict(ent);
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;
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;
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;
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)))
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;
}
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);
}
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);
}
*/
static void Cbuf_Execute_Deferred (cmd_buf_t *cbuf)
{
- llist_t *pos;
cmd_input_t *current;
double eat;
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(¤t->list, &cbuf->start);
// We must return and come back next frame or the engine will freeze. Fragile... like glass :3
return;
}
* 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(¤t->list, &cbuf->free);
#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)
#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
*/
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
*/
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
*/
!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
*/
*/
static inline void List_Create(llist_t *list)
{
- list->next = list->prev = NULL;
+ list->next = list->prev = list;
}
/*
Cvar_RegisterVariable (®istered);
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;
#define COMMON_H
#include <stdarg.h>
+#include <assert.h>
#include "qtypes.h"
#include "qdefs.h"
//============================================================================
-#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
{
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/
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'
// 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.")
//============================================================================
// 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);
}
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)
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))
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;
}
}
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;
}
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)
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);
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;
}
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;
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 *));
if (cls.demoplayback)
{
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
cls.demonum = 0;
}
}
// halt demo playback to close the file
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
FS_ChangeGameDirs(numgamedirs, gamedirs, true, true);
}
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] =
{
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)
*/
-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"};
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;
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");
host_active
} host_state_t;
-typedef struct host_s
+typedef struct host_static_s
{
jmp_buf abortframe;
int state;
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);
#ifndef STANDALONETEST
double sentdoubletime;
#endif
- struct lhnetpacket_s *next, *prev;
+ llist_t list;
}
lhnetpacket_t;
{
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);
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
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)
{
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)
}
}
// 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;
}
}
#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());
{
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)
{
// 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;
}
else
value = -1;
// unlink and free
- p->next->prev = p->prev;
- p->prev->next = p->next;
+ List_Delete(&p->list);
Z_Free(p);
}
}
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
#define LHNET_H
#include <stddef.h>
+#include "com_list.h"
typedef enum lhnetaddresstype_e
{
{
lhnetaddress_t address;
int inetsocket;
- struct lhnetsocket_s *next, *prev;
+ llist_t list;
}
lhnetsocket_t;
dpsnprintf(donecommand, sizeof(donecommand), "connect %s", cls.netcon->address);
Curl_CommandWhenDone(donecommand);
noclear = true;
- CL_Disconnect();
+ CL_Disconnect(false, NULL);
noclear = false;
Curl_CheckCommandWhenDone();
}
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
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
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
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
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
#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)
for (i=0 ; i<prog->num_edicts ; i++)
{
ent = PRVM_EDICT_NUM(i);
- if (ent->priv.required->free)
+ if (ent->free)
continue;
active++;
}
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
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)
{
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;
}
}
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;
#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;
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)
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);
#define ODEFUNC_FORCE 3
#define ODEFUNC_TORQUE 4
+#ifdef USEODE
typedef struct edict_odefunc_s
{
int type;
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;
frameblend_t frameblend[MAX_FRAMEBLENDS];
skeleton_t skeleton;
+#ifdef USEODE
// physics parameters
qbool ode_physics;
void *ode_body;
vec3_t ode_joint_velocity; // second joint axis
vec3_t ode_joint_movedir; // parameters
void *ode_massbuf;
+#endif
}
edict_engineprivate_t;
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;
}
protocolversioninfo[] =
{
+ { 3505, PROTOCOL_DARKPLACES8 , "DP8"},
{ 3504, PROTOCOL_DARKPLACES7 , "DP7"},
{ 3503, PROTOCOL_DARKPLACES6 , "DP6"},
{ 3502, PROTOCOL_DARKPLACES5 , "DP5"},
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;
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" );
{
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)
{
prog->xfunction->builtinsprofile++;
ed = PRVM_EDICT_NUM(e);
- if (ed->priv.required->free)
+ if (ed->free)
continue;
if (PRVM_E_FLOAT(ed,f) == s)
{
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)
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;
{
prog->xfunction->builtinsprofile++;
ed = PRVM_EDICT_NUM(e);
- if (ed->priv.required->free)
+ if (ed->free)
continue;
if (!PRVM_E_FLOAT(ed,f))
continue;
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;
return;
}
ent = PRVM_EDICT_NUM(i);
- if (!ent->priv.required->free)
+ if (!ent->free)
{
VM_RETURN_EDICT(ent);
return;
}
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;
// 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));
// 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;
// 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);
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;
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;
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)
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)
// 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)
}
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)
{
}
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)
{
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)
{
f.type = ODEFUNC_TORQUE;
VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
VM_physics_ApplyCmd(ed, &f);
+#endif
}
extern cvar_t prvm_coverage;
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);
*/
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
}
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);
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;
FS_Print(f, "{\n");
- if (ed->priv.required->free)
+ if (ed->free)
{
FS_Print(f, "}\n");
return;
}
if (!init) {
- ent->priv.required->free = true;
- ent->priv.required->freetime = host.realtime;
+ ent->free = true;
+ ent->freetime = host.realtime;
}
return data;
//
// 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))
{
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
PRVM_ED_CallPrespawnFunction(prog, ent);
- if(ent->priv.required->free)
+ if(ent->free)
{
inhibited++;
continue;
PRVM_ED_CallPostspawnFunction(prog, ent);
spawned++;
- if (ent->priv.required->free)
+ if (ent->free)
died++;
}
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++)
{
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)
{
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)
{
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;
}
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;
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)
#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
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
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);
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);
Cvar_Set(&cvars_all, "warpmark", "");
if(host.hook.Disconnect)
- host.hook.Disconnect();
+ host.hook.Disconnect(false, NULL);
SV_Shutdown();
{
const char *who;
const char *message = NULL;
+ char reason[512];
client_t *save;
int i;
qbool byNumber = false;
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;
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);
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)
{
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);
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);
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);
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);
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)
{
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;
// 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;
// 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;
}
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();
// 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);
}
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;
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))
// 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");
}
/*
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)
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)
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);
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;
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;
}
/*
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);
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);
// 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)
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)
{
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)
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
// 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
// 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);
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);
}
// stop playing demos
if (cls.demoplayback)
- CL_Disconnect ();
+ CL_Disconnect (false, NULL);
#ifdef CONFIG_MENU
// remove menu
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);
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);
}
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++;
// 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))
{
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;
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;
}
}
// 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__);
}
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;
}
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:
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:
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;
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;
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;
// 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;
// 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;
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;
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;
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;
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;
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;
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;
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;
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;
if (ent == prog->edicts)
return 1;
- if (ent->priv.server->free)
+ if (ent->free)
return 2;
modelindex = (int)PRVM_serveredictfloat(ent, modelindex);
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;
}
oldhostclient = host_client;
host_client = svs.clients + clientnum;
- SV_DropClient(false);
+ SV_DropClient(false, "Client dropped");
host_client = oldhostclient;
}
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;
-#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")
{
}
+#ifndef WIN32
static void signal_handler(int sig)
{
Con_Printf("Received signal %d, exiting...\n", sig);
static void InitSig(void)
{
-#ifndef WIN32
signal(SIGHUP, signal_handler);
signal(SIGINT, signal_handler);
signal(SIGQUIT, signal_handler);
signal(SIGFPE, signal_handler);
signal(SIGSEGV, signal_handler);
signal(SIGTERM, signal_handler);
-#endif
}
+#endif
void VID_SetMouse (qbool fullscreengrab, qbool relative, qbool hidecursor)
{
void VID_Init(void)
{
+#ifndef WIN32
InitSig(); // trap evil signals
+#endif
}
qbool VID_InitMode(viddef_mode_t *mode)
*/
+#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
}
//============================================================================
// 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));
}
/*
{
prvm_prog_t *prog = world->prog;
int numlist;
- llist_t *pos;
link_t *grid;
link_t *l;
prvm_edict_t *ent;
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;
{
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;
return;
// don't add free entities
- if (ent->priv.server->free)
+ if (ent->free)
return;
VectorCopy(mins, ent->priv.server->areamins);
// {"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 [] =
{
}
#endif
}
-#endif
}
-
static void World_Physics_Shutdown(void)
{
-#ifdef USEODE
#ifndef LINK_TO_LIBODE
if (ode_dll)
#endif
ode_dll = NULL;
#endif
}
-#endif
}
-#ifdef USEODE
static void World_Physics_UpdateODE(world_t *world)
{
dWorldID odeworld;
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);
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)
// 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;
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;
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)
default:
break;
}
-#endif
}
-#ifdef USEODE
static void World_Physics_Frame_BodyToEntity(world_t *world, prvm_edict_t *ed)
{
prvm_prog_t *prog = world->prog;
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);
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
return;
ed1 = (prvm_edict_t *) dGeomGetData(o1);
- if(ed1 && ed1->priv.server->free)
+ if(ed1 && ed1->free)
ed1 = NULL;
if(ed1)
{
}
ed2 = (prvm_edict_t *) dGeomGetData(o2);
- if(ed2 && ed2->priv.server->free)
+ if(ed2 && ed2->free)
ed2 = NULL;
if(ed2)
{
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;
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);
}
{
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)
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
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)
}
}
}
-#endif
}
+#endif
// (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;
Sys_Sleep(1000);
}
return NULL;
+#endif
}
#endif
}
-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;
}
#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__)
// 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
{
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;