From c841b4fbd1b6f48df0803ac395b670a6b93a220c Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 30 May 2014 18:04:51 +0000 Subject: [PATCH] attempt to update the openportal builtin to work with q3 as well. ignore sound() calls with empty sound names. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4675 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/pr_csqc.c | 23 ++++++++++++++++++++++- engine/common/gl_q2bsp.c | 2 +- engine/server/pr_cmds.c | 34 ++++++++++++++++++++++++++++++---- engine/server/sv_send.c | 2 +- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index c34b1ef67..fa0eb7b13 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -3455,7 +3455,28 @@ static void QCBUILTIN PF_cs_OpenPortal (pubprogfuncs_t *prinst, struct globalvar { #ifdef Q2BSPS if (cl.worldmodel->fromgame == fg_quake2) - CMQ2_SetAreaPortalState(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1)); + { + int portal; + int state = G_FLOAT(OFS_PARM1)!=0; + if (G_INT(OFS_PARM1) >= MAX_EDICTS) + portal = G_FLOAT(OFS_PARM0); //old legacy crap. + else + portal = G_EDICT(prinst, OFS_PARM0)->xv->style; //read the func_areaportal's style field. + CMQ2_SetAreaPortalState(portal, state); + } +#endif +#ifdef Q3BSPS + if (cl.worldmodel->fromgame == fg_quake3) + { + int i; + int state = G_FLOAT(OFS_PARM1)!=0; + client_t *client; + edict_t *portal = G_EDICT(prinst, OFS_PARM0); + int area1 = portal->pvsinfo.areanum, area2 = portal->pvsinfo.areanum2; + if (area1 == area2 || !area1 || !area2) + return; + CMQ3_SetAreaPortalState(portal->pvsinfo.areanum, portal->pvsinfo.areanum2, state); + } #endif } diff --git a/engine/common/gl_q2bsp.c b/engine/common/gl_q2bsp.c index 42537a58a..7ad4daceb 100644 --- a/engine/common/gl_q2bsp.c +++ b/engine/common/gl_q2bsp.c @@ -6154,7 +6154,7 @@ static void FloodAreaConnections (void) void VARGS CMQ2_SetAreaPortalState (int portalnum, qboolean open) { if (mapisq3) - Host_Error ("CMQ2_SetAreaPortalState on q3 map"); + return; if (portalnum > numareaportals) Host_Error ("areaportal > numareaportals"); diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index e3314c7ec..3886ad0fe 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -6229,9 +6229,13 @@ static void QCBUILTIN PF_OpenPortal (pubprogfuncs_t *prinst, struct globalvars_s { if (sv.world.worldmodel->fromgame == fg_quake2) { - int i, portal = G_FLOAT(OFS_PARM0); + int i, portal; int state = G_FLOAT(OFS_PARM1)!=0; client_t *client; + if (G_INT(OFS_PARM1) >= MAX_EDICTS) + portal = G_FLOAT(OFS_PARM0); //old legacy crap. + else + portal = G_EDICT(prinst, OFS_PARM0)->xv->style; //read the func_areaportal's style field. for (client = svs.clients, i = 0; i < sv.allocated_client_slots; i++, client++) { if (client->state >= cs_connected) @@ -6243,7 +6247,29 @@ static void QCBUILTIN PF_OpenPortal (pubprogfuncs_t *prinst, struct globalvars_s ClientReliableWrite_Short(client, portal); } } - CMQ2_SetAreaPortalState(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1)); + CMQ2_SetAreaPortalState(portal, state); + } + else if (sv.world.worldmodel->fromgame == fg_quake3) + { + int i; + int state = G_FLOAT(OFS_PARM1)!=0; + client_t *client; + edict_t *portal = G_EDICT(prinst, OFS_PARM0); + int area1 = portal->pvsinfo.areanum, area2 = portal->pvsinfo.areanum2; + if (area1 == area2 || !area1 || !area2) + return; + /*for (client = svs.clients, i = 0; i < sv.allocated_client_slots; i++, client++) + { + if (client->state >= cs_connected) + { + ClientReliableWrite_Begin(client, svc_setportalstate, 3); + if (state) + ClientReliableWrite_Short(client, portal | (state<<15)); + else + ClientReliableWrite_Short(client, portal); + } + }*/ + CMQ3_SetAreaPortalState(portal->pvsinfo.areanum, portal->pvsinfo.areanum2, state); } } #endif @@ -9204,8 +9230,8 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs {"externset", PF_externset, 0, 0, 0, 204, D("void(float prnum, __variant newval, string varname)", "Sets a global in the named progs by name.\nprnum=0 is the 'default' or 'main' progs.\nprnum=-1 means current progs.\nprnum=-2 will scan through the active progs and will use the first it finds.")}, {"externrefcall", PF_externrefcall, 0, 0, 0, 205, D("__variant(float prnum, void() func, ...)","Calls a function between progs by its reference. No longer needed as direct function calls now switch progs context automatically, and have done for a long time. There is no remaining merit for this function."), true}, {"instr", PF_instr, 0, 0, 0, 206, D("float(string input, string token)", "Returns substring(input, strstrpot(input, token), -1), or the null string if token was not found in input. You're probably better off using strstrpos.")}, -#ifdef Q2BSPS - {"openportal", PF_OpenPortal, 0, 0, 0, 207, D("void(float portal, float state)", "Q2BSP: Sets the portal state attached to doors. portal is your portal id from the map.\nstate=0 means that the pvs will be blocked. entities on the other side will not be seen/sent.\nstate=1 means the portal should be open, and things beyond will now be seen.")}, +#if defined(Q2BSPS) || defined(Q3BSPS) + {"openportal", PF_OpenPortal, 0, 0, 0, 207, D("void(entity portal, float state)", "Opens or closes the portals associated with a door or some such on q2 or q3 maps. On Q2BSPs, the entity should be the 'func_areaportal' entity - its style field will say which portal to open. On Q3BSPs, the entity is the door itself, the portal will be determined by the two areas found from a preceding setorigin call.")}, #endif {"RegisterTempEnt", PF_RegisterTEnt, 0, 0, 0, 208, "float(float attributes, string effectname, ...)"}, diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index 847b86c0f..7a203d4ed 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -985,7 +985,7 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, const cha // find precache number for sound if (!*sample) - sound_num = 0; + return; else { for (sound_num=1 ; sound_num