]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
-Added a more descriptive comment for prvm_edict_t::p
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 15 Oct 2004 21:18:02 +0000 (21:18 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 15 Oct 2004 21:18:02 +0000 (21:18 +0000)
-Added 3 new builtins to the new VM: ftoe, etof, parseentitydata
-Changed the Win32 driver to reuse the GL hDC if possible instead of
 calling GetDC and ReleaseDC every frame.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4637 d7cf8633-e32d-0410-b094-e92efae38249

progsvm.h
prvm_cmds.c
vid_wgl.c

index 12c85cd1d99e2eac96e8abf3ccc33939beb71cd4..f9c1666a803a2139a77ef20c3c6b6ceff26aa1de 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -174,7 +174,22 @@ typedef struct prvm_edict_s
        {
                prvm_edict_private_t *e;
                void                             *vp;
-               //add other types as you desire
+               // add other private structs as you desire
+               // new structs have to start with the elements of prvm_edit_private_t
+               // e.g. a new struct has to either look like this:
+               //      typedef struct server_edict_private_s {
+               //              prvm_edict_private_t base;
+               //              vec3_t moved_from;
+               //      vec3_t moved_fromangles;
+               //              ... } server_edict_private_t;
+               // or:
+               //      typedef struct server_edict_private_s {
+               //              qboolean free;
+               //              float freetime;
+               //              vec3_t moved_from;
+               //      vec3_t moved_fromangles;
+               //              ... } server_edict_private_t;
+               // However, the first one should be preferred.
        } p;
        // QuakeC fields (stored in dynamically resized array)
        //entvars_t *v;
index 6b390e7b59198a58c56122f9401a27f731668004..4d2c97373a0c04bb20d28d4e3d7575bac6b491ec 100644 (file)
@@ -96,6 +96,9 @@ float search_getsize(float handle)
 string search_getfilename(float handle, float num)
 
 string chr(float ascii)
+
+float  etof(entity ent)
+entity ftoe(float num)
                
 perhaps only : Menu : WriteMsg 
 ===============================
@@ -142,7 +145,7 @@ string      findkeysforcommand(string command)
 float  gethostcachevalue(float type)
 string gethostcachestring(float type, float hostnr)
 
-
+               parseentitydata(entity ent, string data)
 */
 
 #include "quakedef.h"
@@ -834,6 +837,38 @@ void VM_stof(void)
        PRVM_G_FLOAT(OFS_RETURN) = atof(string);
 }
 
+/*
+========================
+VM_etof
+
+float etof(entity ent)
+========================
+*/
+void VM_etof(void)
+{
+       VM_SAFEPARMCOUNT(1, VM_etof);
+       PRVM_G_FLOAT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
+}
+
+/*
+========================
+VM_ftoe
+
+entity ftoe(float num)
+========================
+*/
+void VM_ftoe(void)
+{
+       int ent;
+       VM_SAFEPARMCOUNT(1, VM_ftoe);
+
+       ent = PRVM_G_FLOAT(OFS_PARM0);
+       if(PRVM_PROG_TO_EDICT(ent)->p.e->free)
+               PRVM_ERROR ("VM_ftoe: %s tried to access a freed entity (entity %i)!\n", PRVM_NAME, ent);
+    
+       PRVM_G_INT(OFS_RETURN) = ent;
+}
+
 /*
 =========
 VM_spawn
@@ -2219,6 +2254,34 @@ void VM_loadfromdata(void)
        PRVM_ED_LoadFromFile(PRVM_G_STRING(OFS_PARM0));
 }
 
+/*
+========================
+VM_M_parseentitydata
+
+parseentitydata(entity ent, string data)
+========================
+*/
+void VM_M_parseentitydata(void)
+{
+       prvm_edict_t *ent;
+       const char *data;
+
+       VM_SAFEPARMCOUNT(2, VM_parseentitydata);
+    
+    // get edict and test it
+       ent = PRVM_G_EDICT(OFS_PARM0);
+       if (ent->p.e->free)
+               PRVM_ERROR ("VM_parseentitydata: %s: Can only set already spawned entities (entity %i is free)!\n", PRVM_NAME, PRVM_NUM_FOR_EDICT(ent));
+
+       data = PRVM_G_STRING(OFS_PARM1);
+
+    // parse the opening brace
+       if (!COM_ParseToken(&data, false) || com_token[0] != '{' )
+               PRVM_ERROR ("VM_parseentitydata: %s: Couldn't parse entity data:\n%s\n", PRVM_NAME, data );
+
+       PRVM_ED_ParseEdict (data, ent);
+}
+
 /*
 =========
 VM_loadfromfile
@@ -3277,8 +3340,9 @@ prvm_builtin_t vm_m_builtins[] = {
        VM_search_end,
        VM_search_getsize,
        VM_search_getfilename, // 77
-       VM_chr, //78
-       0,0,// 80
+       VM_chr, 
+       VM_etof,
+       VM_ftoe,// 80
        e10,                    // 90
        e10,                    // 100
        e100,                   // 200
@@ -3327,7 +3391,8 @@ prvm_builtin_t vm_m_builtins[] = {
        VM_M_keynumtostring,
        VM_M_findkeysforcommand,// 610
        VM_M_gethostcachevalue,
-       VM_M_gethostcachestring // 612 
+       VM_M_gethostcachestring,
+       VM_M_parseentitydata    // 613
 };
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
index 2200c87e0c22d5dbd7964a3063bd0d46a017707a..6b40c25823f98d4ff7623992bcde8a8b31f22b07 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -318,9 +318,13 @@ void VID_Finish (void)
        {
                if (r_speeds.integer || gl_finish.integer)
                        qglFinish();
-               hdc = GetDC(mainwindow);
-               SwapBuffers(hdc);
-               ReleaseDC(mainwindow, hdc);
+               if (qwglGetCurrentDC) 
+                       SwapBuffers(qwglGetCurrentDC());
+               else {
+                       hdc = GetDC(mainwindow);
+                       SwapBuffers(hdc);
+                       ReleaseDC(mainwindow, hdc);
+               }
        }
 
 // handle the mouse state when windowed if that's changed
@@ -993,7 +997,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp)
 
 // COMMANDLINEOPTION: Windows WGL: -novideosync disables WGL_EXT_swap_control
        gl_videosyncavailable = GL_CheckExtension("WGL_EXT_swap_control", wglswapintervalfuncs, "-novideosync", false);
-       ReleaseDC(mainwindow, hdc);
+       //ReleaseDC(mainwindow, hdc);
 
        GL_Init ();