]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
forbid world writes after precache stage (without using sv.state, instead prog->allow...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 1 Jul 2005 07:04:40 +0000 (07:04 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 1 Jul 2005 07:04:40 +0000 (07:04 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5476 d7cf8633-e32d-0410-b094-e92efae38249

progsvm.h
prvm_execprogram.h
sv_main.c

index 0884945840ba62a1d5a555b6c734056767b16527..d86b0b648b985e331173b4e4fd1165fedf73e7ae 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -328,6 +328,10 @@ typedef struct prvm_prog_s
        float                           *time;
        float                           _time;
 
+       // allow writing to world entity fields, this is set by server init and
+       // cleared before first server frame
+       qboolean                        allowworldwrites;
+
        // name of the prog, e.g. "Server", "Client" or "Menu" (used for text output)
        char                            *name; // [INIT]
 
index 07ca7a16b5de532ab2de95355ef743b053e7a434..fd50149a887dc0f9032449f48c097b8acec29056 100644 (file)
                                        return;
                                }
 #endif
-                               /*if (OPA->edict == 0 && sv.state == ss_active)
+                               if (OPA->edict == 0 && !prog->allowworldwrites)
                                {
                                        prog->xfunction->profile += profile - startprofile;
                                        startprofile = profile;
                                        prog->xstatement = st - prog->statements;
                                        Host_Error("assignment to world entity in %s", PRVM_NAME);
                                        return;
-                               }*/
+                               }
                                ed = PRVM_PROG_TO_EDICT(OPA->edict);
                                OPC->_int = (qbyte *)((int *)ed->fields.vp + OPB->_int) - (qbyte *)prog->edictsfields;
                                break;
                                break;
 
                        case OP_STATE:
-                               if(prog->flag & PRVM_OP_STATE) 
+                               if(prog->flag & PRVM_OP_STATE)
                                {
                                        prog->xfunction->profile += profile - startprofile;
                                        startprofile = profile;
                                else
                                        PRVM_ERROR("OP_STATE not supported by %s\n", PRVM_NAME);
                                break;
-                               
+
 // LordHavoc: to be enabled when Progs version 7 (or whatever it will be numbered) is finalized
 /*
                        case OP_ADD_I:
index f811ee66cbc2bb1e6be57a617a27e0076a45ab85..019ad9d49370bd8a67609543b6c1bad2c822482a 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1736,6 +1736,7 @@ void SV_SpawnServer (const char *server)
        //prog->num_edicts = svs.maxclients+1;
 
        sv.state = ss_loading;
+       prog->allowworldwrites = true;
        sv.paused = false;
 
        *prog->time = sv.time = 1.0;
@@ -1806,6 +1807,7 @@ void SV_SpawnServer (const char *server)
 
 // all setup is completed, any further precache statements are errors
        sv.state = ss_active;
+       prog->allowworldwrites = false;
 
 // run two frames to allow everything to settle
        for (i = 0;i < 2;i++)