]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_edict.c
client: improve server connection status messages
[xonotic/darkplaces.git] / prvm_edict.c
index 54609bb25ee9627687ea2baea67b44fffbb04350..fa313eff12f2b9a6a0354a60d42ed93a373f78bf 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
 }
@@ -297,7 +297,11 @@ prvm_edict_t *PRVM_ED_Alloc(prvm_prog_t *prog)
 PRVM_ED_Free
 
 Marks the edict as free
+
 FIXME: walk all entities and NULL out references to this entity
+bones_was_here: do not want, that would break chains immediately!
+Currently chains aren't broken by removing an entity, at least with prvm_reuseedicts_neverinsameframe 1
+which is very handy and some QC code will depend on it.
 =================
 */
 void PRVM_ED_Free(prvm_prog_t *prog, prvm_edict_t *ed)
@@ -308,8 +312,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);
@@ -474,11 +478,11 @@ static char *PRVM_ValueString (prvm_prog_t *prog, etype_t type, prvm_eval_t *val
                break;
        case ev_float:
                // LadyHavoc: changed from %5.1f to %10.4f
-               dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float);
+               dpsnprintf (line, linelength, PRVM_FLOAT_LOSSLESS_FORMAT, val->_float);
                break;
        case ev_vector:
                // LadyHavoc: changed from %5.1f to %10.4f
-               dpsnprintf (line, linelength, "'" VECTOR_LOSSLESS_FORMAT "'", val->vector[0], val->vector[1], val->vector[2]);
+               dpsnprintf (line, linelength, "'" PRVM_VECTOR_LOSSLESS_FORMAT "'", val->vector[0], val->vector[1], val->vector[2]);
                break;
        case ev_pointer:
                dpsnprintf (line, linelength, "pointer");
@@ -567,10 +571,10 @@ char *PRVM_UglyValueString (prvm_prog_t *prog, etype_t type, prvm_eval_t *val, c
                dpsnprintf (line, linelength, "void");
                break;
        case ev_float:
-               dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float);
+               dpsnprintf (line, linelength, PRVM_FLOAT_LOSSLESS_FORMAT, val->_float);
                break;
        case ev_vector:
-               dpsnprintf (line, linelength, VECTOR_LOSSLESS_FORMAT, val->vector[0], val->vector[1], val->vector[2]);
+               dpsnprintf (line, linelength, PRVM_VECTOR_LOSSLESS_FORMAT, val->vector[0], val->vector[1], val->vector[2]);
                break;
        default:
                dpsnprintf (line, linelength, "bad type %i", type);
@@ -654,7 +658,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 +741,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 +1355,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 +1383,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 +1459,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 +1534,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 +1548,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++;
        }
 
@@ -2460,7 +2464,7 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char * filename, unsigned char * da
                        if ( a >= prog->progs_numglobals)
                                prog->error_cmd("PRVM_LoadProgs: out of bounds global index (statement %d) in %s", i, prog->name);
                        if (b || c)     //Spike -- added this check just as a diagnostic...
-                               Con_DPrintf("PRVM_LoadProgs: unxpected offset on call opcode in %s. Hexen2 format is not supported\n", prog->name);
+                               Con_DPrintf("PRVM_LoadProgs: unexpected offset on call opcode in %s. Hexen2 format is not supported\n", prog->name);
                        prog->statements[i].op = op;
                        prog->statements[i].operand[0] = remapglobal(a);
                        prog->statements[i].operand[1] = -1;
@@ -2746,7 +2750,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++)
                {
@@ -3140,6 +3144,8 @@ PRVM_Init
 */
 void PRVM_Init (void)
 {
+       unsigned int i;
+
        Cmd_AddCommand(CF_SHARED, "prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
        Cmd_AddCommand(CF_SHARED, "prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)");
        Cmd_AddCommand(CF_SHARED, "prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
@@ -3184,6 +3190,18 @@ void PRVM_Init (void)
        prvm_runawaycheck = !Sys_CheckParm("-norunaway");
 
        //VM_Cmd_Init();
+
+       // LadyHavoc: report supported extensions
+       Con_DPrintf("\nQuakeC extensions for server and client:");
+       for (i = 0; vm_sv_extensions[i]; i++)
+               Con_DPrintf(" %s", vm_sv_extensions[i]);
+       Con_DPrintf("\n");
+#ifdef CONFIG_MENU
+       Con_DPrintf("\nQuakeC extensions for menu:");
+       for (i = 0; vm_m_extensions[i]; i++)
+               Con_DPrintf(" %s", vm_m_extensions[i]);
+       Con_DPrintf("\n");
+#endif
 }
 
 /*
@@ -3356,18 +3374,18 @@ int PRVM_SetTempString(prvm_prog_t *prog, const char *s)
                return 0;
        size = (int)strlen(s) + 1;
        if (developer_insane.integer)
-               Con_DPrintf("PRVM_SetTempString: cursize %i, size %i\n", prog->tempstringsbuf.cursize, size);
+               Con_DPrintf("PRVM_SetTempString %s: cursize %i, size %i\n", prog->name, prog->tempstringsbuf.cursize, size);
        if (prog->tempstringsbuf.maxsize < prog->tempstringsbuf.cursize + size)
        {
                sizebuf_t old = prog->tempstringsbuf;
                if (prog->tempstringsbuf.cursize + size >= 1<<28)
-                       prog->error_cmd("PRVM_SetTempString: ran out of tempstring memory!  (refusing to grow tempstring buffer over 256MB, cursize %i, size %i)\n", prog->tempstringsbuf.cursize, size);
+                       prog->error_cmd("PRVM_SetTempString %s: ran out of tempstring memory!  (refusing to grow tempstring buffer over 256MB, cursize %i, size %i)\n", prog->name, prog->tempstringsbuf.cursize, size);
                prog->tempstringsbuf.maxsize = max(prog->tempstringsbuf.maxsize, 65536);
                while (prog->tempstringsbuf.maxsize < prog->tempstringsbuf.cursize + size)
                        prog->tempstringsbuf.maxsize *= 2;
                if (prog->tempstringsbuf.maxsize != old.maxsize || prog->tempstringsbuf.data == NULL)
                {
-                       Con_DPrintf("PRVM_SetTempString: enlarging tempstrings buffer (%iKB -> %iKB)\n", old.maxsize/1024, prog->tempstringsbuf.maxsize/1024);
+                       Con_DPrintf("PRVM_SetTempString %s: enlarging tempstrings buffer (%iKB -> %iKB)\n", prog->name, old.maxsize/1024, prog->tempstringsbuf.maxsize/1024);
                        prog->tempstringsbuf.data = (unsigned char *) Mem_Alloc(prog->progs_mempool, prog->tempstringsbuf.maxsize);
                        if (old.data)
                        {
@@ -3408,16 +3426,16 @@ int PRVM_AllocString(prvm_prog_t *prog, size_t bufferlength, char **pointer)
 void PRVM_FreeString(prvm_prog_t *prog, int num)
 {
        if (num == 0)
-               prog->error_cmd("PRVM_FreeString: attempt to free a NULL string");
+               prog->error_cmd("PRVM_FreeString %s: attempt to free a NULL string", prog->name);
        else if (num >= 0 && num < prog->stringssize)
-               prog->error_cmd("PRVM_FreeString: attempt to free a constant string");
+               prog->error_cmd("PRVM_FreeString %s: attempt to free a constant string", prog->name);
        else if (num >= PRVM_KNOWNSTRINGBASE && num < PRVM_KNOWNSTRINGBASE + prog->numknownstrings)
        {
                num = num - PRVM_KNOWNSTRINGBASE;
                if (!prog->knownstrings[num])
-                       prog->error_cmd("PRVM_FreeString: attempt to free a non-existent or already freed string");
+                       prog->error_cmd("PRVM_FreeString %s: attempt to free a non-existent or already freed string", prog->name);
                if (!prog->knownstrings_flags[num])
-                       prog->error_cmd("PRVM_FreeString: attempt to free a string owned by the engine");
+                       prog->error_cmd("PRVM_FreeString %s: attempt to free a string owned by the engine", prog->name);
                PRVM_Free((char *)prog->knownstrings[num]);
                if(prog->leaktest_active)
                        if(prog->knownstrings_origin[num])
@@ -3427,7 +3445,7 @@ void PRVM_FreeString(prvm_prog_t *prog, int num)
                prog->firstfreeknownstring = min(prog->firstfreeknownstring, num);
        }
        else
-               prog->error_cmd("PRVM_FreeString: invalid string offset %i", num);
+               prog->error_cmd("PRVM_FreeString %s: invalid string offset %i", prog->name, num);
 }
 
 static qbool PRVM_IsStringReferenced(prvm_prog_t *prog, string_t string)
@@ -3446,7 +3464,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 +3485,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 +3582,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 +3608,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 +3650,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)