From aab72de84b3ee87c945edaad2077b5dc564b4f2e Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 2 Aug 2015 19:08:36 +0000 Subject: [PATCH] more webgl tweaks. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4956 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_ents.c | 5 ++- engine/client/image.c | 4 +++ engine/client/snd_al.c | 65 +++++++++++++++++------------------ engine/client/snd_dma.c | 6 ++++ engine/gl/gl_model.h | 6 ++-- engine/qclib/pr_edict.c | 4 +-- engine/qclib/pr_exec.c | 10 ++++-- engine/server/sv_send.c | 29 +++++++++++----- plugins/jabber/jabberclient.c | 24 +++++++------ 9 files changed, 93 insertions(+), 60 deletions(-) diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index 010692c43..284e4bec4 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -3116,7 +3116,7 @@ static void CL_TransitionPacketEntities(int newsequence, packet_entities_t *newp sold__origin = sold->origin; } VectorSubtract(snew__origin, sold__origin, move); - if (DotProduct(move, move) > 200*200 || snew->modelindex != sold->modelindex) + if (DotProduct(move, move) > 200*200 || snew->modelindex != sold->modelindex || ((sold->effects ^ snew->effects) & EF_TELEPORT_BIT)) { isnew = true; //disable lerping (and indirectly trails) VectorClear(move); @@ -3142,6 +3142,9 @@ static void CL_TransitionPacketEntities(int newsequence, packet_entities_t *newp } else { + if ((sold->effects ^ snew->effects) & EF_RESTARTANIM_BIT) + isnew = true; + if (snew->dpflags & RENDER_STEP) { float lfrac; diff --git a/engine/client/image.c b/engine/client/image.c index 7ecb4317a..a5e83343b 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -2285,8 +2285,10 @@ static void Image_LoadTextureMips(void *ctx, void *data, size_t a, size_t b) texid_t tex = ctx; struct pendingtextureinfo *mips = data; + //setting the dimensions here can break npot textures, so lets not do that. // tex->width = mips->mip[0].width; // tex->height = mips->mip[0].height; + if (rf->IMG_LoadTextureMips(tex, mips)) tex->status = TEX_LOADED; else @@ -2299,6 +2301,7 @@ static void Image_LoadTextureMips(void *ctx, void *data, size_t a, size_t b) BZ_Free(mips->extrafree); BZ_Free(mips); + //ezhud breaks without this. I assume other things will too. this is why you shouldn't depend upon querying an image's size. if (!strncmp(tex->ident, "gfx/", 4)) { qpic_t *pic = W_SafeGetLumpName(tex->ident+4); @@ -2308,6 +2311,7 @@ static void Image_LoadTextureMips(void *ctx, void *data, size_t a, size_t b) tex->height = pic->height; } } + //FIXME: check loaded wad files too. } #ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT diff --git a/engine/client/snd_al.c b/engine/client/snd_al.c index d8c6ed1ee..dfb511a32 100644 --- a/engine/client/snd_al.c +++ b/engine/client/snd_al.c @@ -552,11 +552,7 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, unsigned } } } - if (!schanged && sfx -#ifndef FTE_TARGET_WEB - && ((chan->flags & CF_FORCELOOP) || (!sfx->decoder.decodedata && sfx->decoder.buf && ((sfxcache_t*)sfx->decoder.buf)->loopstart)) -#endif - ) + if (!schanged && sfx) //if we don't figure out when they've finished, they'll not get replaced properly. { palGetSourcei(src, AL_SOURCE_STATE, &buf); if (buf != AL_PLAYING) @@ -613,36 +609,16 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, unsigned if (buf <= 2) { //decode periodically instead of all at the start. sc = sfx->decoder.decodedata(sfx, &sbuf, chan->pos>>PITCHSHIFT, 65536); - memcpy(&sbuf, sc, sizeof(sbuf)); - - //hack up the sound to offset it correctly - offset = (chan->pos>>PITCHSHIFT) - sbuf.soundoffset; - sbuf.data += offset * sc->width*sc->numchannels; - sbuf.length -= offset; - - if (!sbuf.length)// && (chan->pos>>PITCHSHIFT) == sbuf.soundoffset) - { - palGetSourcei(src, AL_SOURCE_STATE, &buf); - if (buf != AL_PLAYING) - { - if (chan->flags & CF_FORCELOOP) - chan->pos = 0; - else if(sbuf.loopstart != -1) - chan->pos = sbuf.loopstart<sfx = NULL; - if (sfx->decoder.ended) - { - if (!S_IsPlayingSomewhere(sfx)) - sfx->decoder.ended(sfx); - } - } - return; - } - } - else + if (sc) { + memcpy(&sbuf, sc, sizeof(sbuf)); + + //hack up the sound to offset it correctly + offset = (chan->pos>>PITCHSHIFT) - sbuf.soundoffset; + sbuf.data += offset * sc->width*sc->numchannels; + sbuf.length -= offset; + + sbuf.soundoffset = 0; //build a buffer with it and queue it up. @@ -657,6 +633,27 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, unsigned if (buf != AL_PLAYING) schanged = true; } + else + { + palGetSourcei(src, AL_SOURCE_STATE, &buf); + if (buf != AL_PLAYING) + { + if (chan->flags & CF_FORCELOOP) + chan->pos = 0; +// else if(sbuf.loopstart != -1) +// chan->pos = sbuf.loopstart<sfx = NULL; + if (sfx->decoder.ended) + { + if (!S_IsPlayingSomewhere(sfx)) + sfx->decoder.ended(sfx); + } + } + return; + } + } } } else diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index c2719185e..9090dfec5 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -2944,6 +2944,12 @@ static void S_UpdateCard(soundcardinfo_t *sc) if (!ch->sfx) continue; + if (sc->ChannelUpdate) + { + sc->ChannelUpdate(sc, ch, false); + continue; + } + SND_Spatialize(sc, ch); // respatialize channel if (!ch->vol[0] && !ch->vol[1] && !ch->vol[2] && !ch->vol[3] && !ch->vol[4] && !ch->vol[5]) continue; diff --git a/engine/gl/gl_model.h b/engine/gl/gl_model.h index 935140769..e2d35e6c9 100644 --- a/engine/gl/gl_model.h +++ b/engine/gl/gl_model.h @@ -176,11 +176,11 @@ m*_t structures are in-memory #define DPEF_SELECTABLE_ (1<<14) //highlights when prydoncursored #define DPEF_DOUBLESIDED_ (1<<15) //disables culling #define DPEF_NOSELFSHADOW_ (1<<16) //doesn't cast shadows on any noselfshadow entities. -#define DPEF_DYNAMICMODELLIGHT_ (1<<17) +#define DPEF_DYNAMICMODELLIGHT_ (1<<17) //forces dynamic lights... I have no idea what this is actually needed for. #define EF_GREEN (1<<18) #define EF_UNUSED19 (1<<19) -#define DPEF_RESTARTANIM_BIT_ (1<<20) //exact semantics seems odd -#define DPEF_TELEPORT_BIT_ (1<<21) //disable lerping while set +#define EF_RESTARTANIM_BIT (1<<20) //restarts the anim when toggled between states +#define EF_TELEPORT_BIT (1<<21) //disable lerping when toggled between states #define DPEF_LOWPRECISION (1<<22) //part of the protocol/server, not the client itself. #define EF_NOMODELFLAGS (1<<23) #define EF_MF_ROCKET (1<<24) diff --git a/engine/qclib/pr_edict.c b/engine/qclib/pr_edict.c index fb795db38..e1712ac8d 100644 --- a/engine/qclib/pr_edict.c +++ b/engine/qclib/pr_edict.c @@ -1624,7 +1624,7 @@ char *ED_WriteEdict(progfuncs_t *progfuncs, edictrun_t *ed, char *buf, int *bufo #undef AddS } -char *SaveCallStack (progfuncs_t *progfuncs, char *buf, int *bufofs, int bufmax) +char *PR_SaveCallStack (progfuncs_t *progfuncs, char *buf, int *bufofs, int bufmax) { #define AddS(str) PR_Cat(buf, str, bufofs, bufmax) char buffer[8192]; @@ -1794,7 +1794,7 @@ char *PDECL PR_SaveEnts(pubprogfuncs_t *ppf, char *buf, int *bufofs, int bufmax, { //include callstack AddS("stacktrace {\n"); - SaveCallStack(progfuncs, buf, bufofs, bufmax); + PR_SaveCallStack(progfuncs, buf, bufofs, bufmax); AddS("}\n"); } diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index 3239ed8af..d95c9ca06 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -33,6 +33,7 @@ //============================================================================= +char *PR_SaveCallStack (progfuncs_t *progfuncs, char *buf, int *bufofs, int bufmax); /* ================= PR_PrintStatement @@ -1479,8 +1480,13 @@ static int PR_ExecuteCode16 (progfuncs_t *fte_restrict progfuncs, int s, int *ft reeval16: //this can generate huge functions, so disable it on systems that can't realiably cope with such things (IE initiates an unwanted denial-of-service attack when pointed our javascript, and firefox prints a warning too) pr_xstatement = st-pr_statements16; - PR_RunError (&progfuncs->funcs, "This platform does not support QC debugging.\n"); - PR_StackTrace(&progfuncs->funcs, false); + char *stack = malloc(4*1024); //this'll leak, but whatever, we're dead anyway. + int ofs; + strcpy(stack, "This platform does not support QC debugging\nStack Trace:"); + ofs = strlen(stack); + PR_SaveCallStack (&progfuncs->funcs, stack, &ofs, 4*1024); + PR_RunError (&progfuncs->funcs, stack); + free(stack); return -1; #else #define DEBUGABLE diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index 3507560ff..225dfee23 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -1516,7 +1516,7 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) // send the data MSG_WriteByte (msg, svcnq_clientdata); - MSG_WriteShort (msg, bits); + MSG_WriteShort (msg, bits & 0xffff); if (bits & SU_EXTEND1) MSG_WriteByte(msg, bits>>16); @@ -1554,10 +1554,12 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) MSG_WriteByte (msg, ent->v->weaponframe); if (bits & SU_ARMOR) { - if (ent->v->armorvalue>255 && !(bits & FITZSU_ARMOR2)) + if (ent->v->armorvalue < 0) + MSG_WriteByte (msg, 0); + else if (ent->v->armorvalue>255 && !(bits & FITZSU_ARMOR2)) MSG_WriteByte (msg, 255); else - MSG_WriteByte (msg, ent->v->armorvalue); + MSG_WriteByte (msg, (int)ent->v->armorvalue&0xff); } if (bits & SU_WEAPONMODEL) MSG_WriteByte (msg, weaponmodelindex&0xff); @@ -1565,11 +1567,22 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) if (nqjunk) { MSG_WriteShort (msg, ent->v->health); - MSG_WriteByte (msg, min(ent->v->currentammo, 255)); - MSG_WriteByte (msg, min(ent->v->ammo_shells, 255)); - MSG_WriteByte (msg, min(ent->v->ammo_nails, 255)); - MSG_WriteByte (msg, min(ent->v->ammo_rockets, 255)); - MSG_WriteByte (msg, min(ent->v->ammo_cells, 255)); + if (client->protocol == SCP_FITZ666) + { + MSG_WriteByte (msg, (int)ent->v->currentammo & 0xff); + MSG_WriteByte (msg, (int)ent->v->ammo_shells & 0xff); + MSG_WriteByte (msg, (int)ent->v->ammo_nails & 0xff); + MSG_WriteByte (msg, (int)ent->v->ammo_rockets & 0xff); + MSG_WriteByte (msg, (int)ent->v->ammo_cells & 0xff); + } + else + { + MSG_WriteByte (msg, min(ent->v->currentammo, 255)); + MSG_WriteByte (msg, min(ent->v->ammo_shells, 255)); + MSG_WriteByte (msg, min(ent->v->ammo_nails, 255)); + MSG_WriteByte (msg, min(ent->v->ammo_rockets, 255)); + MSG_WriteByte (msg, min(ent->v->ammo_cells, 255)); + } if (standard_quake) { diff --git a/plugins/jabber/jabberclient.c b/plugins/jabber/jabberclient.c index 625854530..c5662f278 100644 --- a/plugins/jabber/jabberclient.c +++ b/plugins/jabber/jabberclient.c @@ -1197,7 +1197,7 @@ static int sasl_oauth2_initial(jclient_t *jcl, char *buf, int bufsize) if (l < 0 || l > rl) l = rl; x = XML_FromJSON(NULL, "oauth2", result, &l, rl); - XML_ConPrintTree(x, "", 1); +// XML_ConPrintTree(x, "", 1); newrefresh = XML_GetChildBody(x, "refresh_token", NULL); free(jcl->oauth2.accesstoken); @@ -2789,7 +2789,7 @@ static qboolean JCL_BuddyVCardReply(jclient_t *jcl, xmltree_t *tree, struct iq_s const char *photomime; buddy_t *b; - char *from = XML_GetParameter(tree, "from", jcl->domain); + char *from = iq->to; if (jcl->avatarupdate == iq) { @@ -3430,8 +3430,8 @@ void JCL_ParseIQ(jclient_t *jcl, xmltree_t *tree) } else { - Con_Printf("Unrecognised iq result\n"); - XML_ConPrintTree(tree, "", 0); + Con_Printf("Unrecognised iq result from %s\n", from); +// XML_ConPrintTree(tree, "", 0); } } @@ -3451,7 +3451,7 @@ void XMPP_ConversationPrintf(const char *context, const char *title, char *forma Q_vsnprintf (string, sizeof(string), format,argptr); va_end (argptr); - if (*context && pCon_GetConsoleFloat(context, "iswindow") < true) + if (*context && BUILTINISVALID(Con_GetConsoleFloat) && pCon_GetConsoleFloat(context, "iswindow") < true) { pCon_SetConsoleFloat(context, "iswindow", true); pCon_SetConsoleFloat(context, "forceutf8", true); @@ -3591,7 +3591,8 @@ void JCL_ParseMessage(jclient_t *jcl, xmltree_t *tree) { jclient_poketime = jclient_curtime + 10*1000; XMPP_ConversationPrintf(ctx, f, "%s is an attention whore.\n", f); - pCon_SetActive(ctx); + if (BUILTINISVALID(Con_SetActive)) + pCon_SetActive(ctx); if (BUILTINISVALID(LocalSound)) pLocalSound("misc/talk.wav"); } @@ -3628,7 +3629,8 @@ void JCL_ParseMessage(jclient_t *jcl, xmltree_t *tree) XMPP_ConversationPrintf(ctx, f, "* ^2%s^7 has invited you to join %s: %s.\n", who, link, reason); else XMPP_ConversationPrintf(ctx, f, "* ^2%s^7 has invited you to join %s.\n", who, link); - pCon_SetActive(ctx); + if (BUILTINISVALID(Con_SetActive)) + pCon_SetActive(ctx); } return; //ignore any body/jabber:x:conference } @@ -3648,7 +3650,8 @@ void JCL_ParseMessage(jclient_t *jcl, xmltree_t *tree) XMPP_ConversationPrintf(ctx, f, "* ^2%s^7 has invited you to join %s: %s.\n", f, link, reason); else XMPP_ConversationPrintf(ctx, f, "* ^2%s^7 has invited you to join %s.\n", f, link); - pCon_SetActive(ctx); + if (BUILTINISVALID(Con_SetActive)) + pCon_SetActive(ctx); return; //ignore any body } @@ -4069,7 +4072,7 @@ void JCL_ParsePresence(jclient_t *jcl, xmltree_t *tree) char *title = buddy->name; //if we're not currently talking with them, put the status update into the main console instead (which will probably then get dropped). - if (pCon_GetConsoleFloat(conv, "iswindow") != true) + if (!BUILTINISVALID(Con_GetConsoleFloat) || pCon_GetConsoleFloat(conv, "iswindow") != true) conv = ""; if (bres->servertype == 2) @@ -5519,7 +5522,8 @@ void JCL_Command(int accid, char *console) { pCon_Destroy(console); Con_SubPrintf(console, ""); - pCon_SetActive(console); + if (BUILTINISVALID(Con_SetActive)) + pCon_SetActive(console); } else pCmd_AddText("\nclear\n", true);