X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=csprogs.c;h=2bf194178b004845dfa98f8a192d5ca041344deb;hp=0d123a2e165017ea68879b04e80562f1305ed3b4;hb=3a75d24a80005cec4f7e915f802ccb19274da279;hpb=f1fc6de3837cc4e577f9e67baa2bd2e397233d30 diff --git a/csprogs.c b/csprogs.c index 0d123a2e..2bf19417 100644 --- a/csprogs.c +++ b/csprogs.c @@ -1,4 +1,4 @@ -###include "quakedef.h" +#include "quakedef.h" #include "progsvm.h" #include "clprogdefs.h" #include "csprogs.h" @@ -44,7 +44,7 @@ void CL_VM_Error (const char *format, ...) //[515]: hope it will be never execut Cvar_SetValueQuick(&csqc_progsize, -1); // Host_AbortCurrentFrame(); //[515]: hmmm... if server says it needs csqc then client MUST disconnect - Host_Error(va("CL_VM_Error: %s", errorstring)); + Host_Error("CL_VM_Error: %s", errorstring); } void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin) { @@ -212,6 +212,7 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed) else CL_SetEntityColormapColors(entrender, c); + entrender->flags &= ~(RENDER_SHADOW | RENDER_LIGHT | RENDER_NOSELFSHADOW); // either fullbright or lit if (!(entrender->effects & EF_FULLBRIGHT) && !r_fullbright.integer) entrender->flags |= RENDER_LIGHT; @@ -223,6 +224,8 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed) entrender->flags |= RENDER_SHADOW; if (entrender->flags & RENDER_VIEWMODEL) entrender->flags |= RENDER_NOSELFSHADOW; + if (entrender->effects & EF_NOSELFSHADOW) + entrender->flags |= RENDER_NOSELFSHADOW; // make the other useful stuff CL_UpdateRenderEntity(entrender); @@ -272,6 +275,9 @@ qboolean CL_VM_UpdateView (void) // CSQC_UpdateView function does not call R_ClearScene as it should r_refdef.scene.numentities = 0; r_refdef.scene.numlights = 0; + // pass in width and height as parameters (EXT_CSQC_1) + PRVM_G_FLOAT(OFS_PARM0) = vid.width; + PRVM_G_FLOAT(OFS_PARM1) = vid.height; PRVM_ExecuteProgram(prog->funcoffsets.CSQC_UpdateView, "QC function CSQC_UpdateView is missing"); //VectorCopy(oldangles, cl.viewangles); // Dresk : Reset Dmg Globals Here @@ -346,6 +352,46 @@ void CL_VM_Parse_StuffCmd (const char *msg) csqc_progsize.flags = sizeflags; return; } + + if(cls.demoplayback) + if(!strncmp(msg, "curl --clear_autodownload\ncurl --pak --forthismap --as ", 55)) + { + // special handling for map download commands + // run these commands IMMEDIATELY, instead of waiting for a client frame + // that way, there is no black screen when playing back demos + // I know this is a really ugly hack, but I can't think of any better way + // FIXME find the actual CAUSE of this, and make demo playback WAIT + // until all maps are loaded, then remove this hack + + char buf[MAX_INPUTLINE]; + const char *p, *q; + size_t l; + + p = msg; + + for(;;) + { + q = strchr(p, '\n'); + if(q) + l = q - p; + else + l = strlen(p); + if(l > sizeof(buf) - 1) + l = sizeof(buf) - 1; + strlcpy(buf, p, l + 1); // strlcpy needs a + 1 as it includes the newline! + + Cmd_ExecuteString(buf, src_command); + + p += l; + if(*p == '\n') + ++p; // skip the newline and continue + else + break; // end of string or overflow + } + Cmd_ExecuteString("curl --clear_autodownload", src_command); // don't inhibit CSQC loading + return; + } + if(!cl.csqc_loaded) { Cbuf_AddText(msg); @@ -563,7 +609,13 @@ void CSQC_ReadEntities (void) cl.csqc_server2csqcentitynumber[realentnum] = 0; } else - Con_Printf("Bad csqc_server2csqcentitynumber map\n"); //[515]: never happens ? + { + // LordHavoc: removing an entity that is already gone on + // the csqc side is possible for legitimate reasons (such + // as a repeat of the remove message), so no warning is + // needed + //Con_Printf("Bad csqc_server2csqcentitynumber map\n"); //[515]: never happens ? + } } else { @@ -658,6 +710,46 @@ qboolean CL_VM_CB_LoadEdict(prvm_edict_t *ent) void Cmd_ClearCsqcFuncs (void); +// returns true if the packet is valid, false if end of file is reached +// used for dumping the CSQC download into demo files +qboolean MakeDownloadPacket(const char *filename, unsigned char *data, unsigned long len, int crc, int cnt, sizebuf_t *buf, int protocol) +{ + int packetsize = buf->maxsize - 7; // byte short long + int npackets = (len + packetsize - 1) / (packetsize); + + if(protocol == PROTOCOL_QUAKEWORLD) + return false; // CSQC can't run in QW anyway + + SZ_Clear(buf); + if(cnt == 0) + { + MSG_WriteByte(buf, svc_stufftext); + MSG_WriteString(buf, va("\ncl_downloadbegin %lu %s\n", len, filename)); + return true; + } + else if(cnt >= 1 && cnt <= npackets) + { + unsigned long thispacketoffset = (cnt - 1) * packetsize; + int thispacketsize = len - thispacketoffset; + if(thispacketsize > packetsize) + thispacketsize = packetsize; + + MSG_WriteByte(buf, svc_downloaddata); + MSG_WriteLong(buf, thispacketoffset); + MSG_WriteShort(buf, thispacketsize); + SZ_Write(buf, data + thispacketoffset, thispacketsize); + + return true; + } + else if(cnt == npackets + 1) + { + MSG_WriteByte(buf, svc_stufftext); + MSG_WriteString(buf, va("\ncl_downloadfinished %lu %d\n", len, crc)); + return true; + } + return false; +} + void CL_VM_Init (void) { const char* csprogsfn; @@ -690,16 +782,19 @@ void CL_VM_Init (void) if (csprogsdata) { csprogsdatacrc = CRC_Block(csprogsdata, csprogsdatasize); - Mem_Free(csprogsdata); if (csprogsdatacrc != requiredcrc || csprogsdatasize != requiredsize) { if (cls.demoplayback) { Con_Printf("^1Warning: Your %s is not the same version as the demo was recorded with (CRC/size are %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize); - return; + // Mem_Free(csprogsdata); + // return; + // We WANT to continue here, and play the demo with different csprogs! + // After all, this is just a warning. Sure things may go wrong from here. } else { + Mem_Free(csprogsdata); Con_Printf("^1Your %s is not the same version as the server (CRC is %i/%i but should be %i/%i)\n", csqc_progname.string, csprogsdatacrc, (int)csprogsdatasize, requiredcrc, requiredsize); CL_Disconnect(); return; @@ -753,11 +848,36 @@ void CL_VM_Init (void) CL_VM_Error("CSQC %s ^2failed to load\n", csprogsfn); if(!sv.active) CL_Disconnect(); + Mem_Free(csprogsdata); return; } Con_Printf("CSQC %s ^5loaded (crc=%i, size=%i)\n", csprogsfn, csprogsdatacrc, (int)csprogsdatasize); + if(cls.demorecording) + { + if(cls.demo_lastcsprogssize != csprogsdatasize || cls.demo_lastcsprogscrc != csprogsdatacrc) + { + int i; + char buf[NET_MAXMESSAGE]; + sizebuf_t sb; + unsigned char *demobuf; fs_offset_t demofilesize; + + sb.data = (void *) buf; + sb.maxsize = sizeof(buf); + i = 0; + + CL_CutDemo(&demobuf, &demofilesize); + while(MakeDownloadPacket(csqc_progname.string, csprogsdata, csprogsdatasize, csprogsdatacrc, i++, &sb, cls.protocol)) + CL_WriteDemoMessage(&sb); + CL_PasteDemo(&demobuf, &demofilesize); + + cls.demo_lastcsprogssize = csprogsdatasize; + cls.demo_lastcsprogscrc = csprogsdatacrc; + } + } + Mem_Free(csprogsdata); + // check if OP_STATE animation is possible in this dat file if (prog->fieldoffsets.nextthink >= 0 && prog->fieldoffsets.frame >= 0 && prog->fieldoffsets.think >= 0 && prog->globaloffsets.self >= 0) prog->flag |= PRVM_OP_STATE;