From d560c170ab305550f8fc6ab39d94daee5b732fbd Mon Sep 17 00:00:00 2001 From: black Date: Fri, 15 Oct 2004 21:18:02 +0000 Subject: [PATCH] -Added a more descriptive comment for prvm_edict_t::p -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 | 17 ++++++++++++- prvm_cmds.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++--- vid_wgl.c | 12 ++++++--- 3 files changed, 93 insertions(+), 9 deletions(-) diff --git a/progsvm.h b/progsvm.h index 12c85cd1..f9c1666a 100644 --- 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; diff --git a/prvm_cmds.c b/prvm_cmds.c index 6b390e7b..4d2c9737 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -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); diff --git a/vid_wgl.c b/vid_wgl.c index 2200c87e..6b40c258 100644 --- 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 (); -- 2.39.2