------------------------------------------------------------------------

r4256 | acceptthis | 2013-03-12 21:07:07 +0000 (Tue, 12 Mar 2013) | 5 lines

Don't mess up/crash when the snap command is used (in multiple ways).
Misc NQ+csqc compat tweaks/hacks/fixes.
Added pointsound.
Don't rely upon fragmentation support with downloads. its a bad idea.
Fixed up the text editor to be able to debug properly again.
------------------------------------------------------------------------


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4252 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2013-03-12 23:24:15 +00:00
parent dd68115e58
commit c1a80e5ba8
31 changed files with 383 additions and 180 deletions

View file

@ -3005,7 +3005,27 @@ static void QCBUILTIN PF_sound (pubprogfuncs_t *prinst, struct globalvars_s *pr_
channel |= 256;
//shift the reliable flag to 256 instead.
SVQ1_StartSound ((wedict_t*)entity, channel, sample, volume, attenuation, pitchadj);
SVQ1_StartSound (NULL, (wedict_t*)entity, channel, sample, volume, attenuation, pitchadj);
}
static void QCBUILTIN PF_pointsound(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *sample;
float *origin;
float volume;
float attenuation;
float pitchpct;
origin = G_VECTOR(OFS_PARM0);
sample = PR_GetStringOfs(prinst, OFS_PARM1);
volume = G_FLOAT(OFS_PARM2);
attenuation = G_FLOAT(OFS_PARM3);
if (prinst->callargc >= 5)
pitchpct = G_FLOAT(OFS_PARM4);
else
pitchpct = 0;
SVQ1_StartSound (origin, sv.world.edicts, 0, sample, volume, attenuation, pitchpct);
}
//an evil one from telejano.
@ -7378,7 +7398,7 @@ static void QCBUILTIN PF_h2StopSound(pubprogfuncs_t *prinst, struct globalvars_s
entity = G_EDICT(prinst, OFS_PARM0);
channel = G_FLOAT(OFS_PARM1);
SVQ1_StartSound ((wedict_t*)entity, channel, "", 1, 0, 0);
SVQ1_StartSound (NULL, (wedict_t*)entity, channel, "", 1, 0, 0);
}
static void QCBUILTIN PF_h2updatesoundpos(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -9414,7 +9434,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"registercommand", PF_Fixme, 0, 0, 0, 352, "void(string cmdname)"},//(EXT_CSQC)
{"wasfreed", PF_WasFreed,0, 0, 0, 353, "float(entity ent)"},//(EXT_CSQC) (should be availabe on server too)
{"serverkey", PF_Fixme, 0, 0, 0, 354, "string(string key)"},//
{"getentitytoken", PF_Fixme, 0, 0, 0, 355, "string()"},//;
{"getentitytoken", PF_Fixme, 0, 0, 0, 355, "string(optional string resetstring)"},//;
{"findfont", PF_Fixme, 0, 0, 0, 356, "float(string s)"},//;
{"loadfont", PF_Fixme, 0, 0, 0, 357, "float(string fontname, string fontmaps, string sizes, float slot, optional float fix_scale, optional float fix_voffset)"},
{"sendevent", PF_Fixme, 0, 0, 0, 359, "void(string evname, string evargs, ...)"},// (EXT_CSQC_1)
@ -9441,10 +9461,10 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"adddecal", PF_Fixme, 0, 0, 0, 375, "void(string shadername, vector origin, vector up, vector side, vector rgb, float alpha)"},
//END EXT_CSQC
{"memalloc", PF_memalloc, 0, 0, 0, 384, "void*(int size)"},
{"memfree", PF_memfree, 0, 0, 0, 385, "void(void *ptr)"},
{"memcpy", PF_memcpy, 0, 0, 0, 386, "void(void *dst, void *src, int size)"},
{"memset", PF_memset, 0, 0, 0, 387, "void(void *dst, int val, int size)"},
{"memalloc", PF_memalloc, 0, 0, 0, 384, "__variant*(int size)"},
{"memfree", PF_memfree, 0, 0, 0, 385, "void(__variant *ptr)"},
{"memcpy", PF_memcpy, 0, 0, 0, 386, "void(__variant *dst, __variant *src, int size)"},
{"memset", PF_memset, 0, 0, 0, 387, "void(__variant *dst, int val, int size)"},
//end fte extras
@ -9646,7 +9666,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
//restart dp extras
// {"log", PF_Fixme, 0, 0, 0, 532, "float(string mname)", true},
// {"getsoundtime", VM_getsoundtime, 0, 0, 0, 533, "float(entity e, float channel)" STUB},
// {"soundlength", VM_soundlength, 0, 0, 0, 534, "float(string sample)" STUB},
{"soundlength", PF_Ignore, 0, 0, 0, 534, "float(string sample)" STUB},
// {"buf_loadfile", PF_Fixme, 0, 0, 0, 535, "float(string filename, float bufhandle)"},
// {"buf_writefile", PF_Fixme, 0, 0, 0, 536, "float(float filehandle, float bufhandle, float startpos, float numstrings)"},
// {"bufstr_find", PF_Fixme, 0, 0, 0, 537, "float(float bufhandle, string match, float matchrule, float startpos)"},

View file

@ -31,6 +31,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define VMFSID_Q1QVM 57235 //a cookie
void PR_SV_FillWorldGlobals(world_t *w);
#if GAME_API_VERSION >= 13
#define WASTED_EDICT_T_SIZE (VM_NonNative(q1qvm)?sizeof(int):sizeof(void*))
//in version 13, the actual edict_t struct is gone, and there's a pointer to it in its place (which we don't need, but it changes size based on vm/native).
@ -639,7 +641,7 @@ static qintptr_t syscallhandle (void *offset, quintptr_t mask, qintptr_t fn, con
case G_SOUND:
// ( int edn, int channel, char *samp, float vol, float att )
SVQ1_StartSound ((wedict_t*)Q1QVMPF_EdictNum(svprogfuncs, VM_LONG(arg[0])), VM_LONG(arg[1]), VM_POINTER(arg[2]), VM_FLOAT(arg[3])*255, VM_FLOAT(arg[4]), 0);
SVQ1_StartSound (NULL, (wedict_t*)Q1QVMPF_EdictNum(svprogfuncs, VM_LONG(arg[0])), VM_LONG(arg[1]), VM_POINTER(arg[2]), VM_FLOAT(arg[3])*255, VM_FLOAT(arg[4]), 0);
break;
case G_TRACELINE:
@ -1321,8 +1323,6 @@ void Q1QVM_Event_Think(world_t *w, wedict_t *s)
pr_global_struct->self = EDICT_TO_PROG(w->progs, s);
pr_global_struct->other = EDICT_TO_PROG(w->progs, w->edicts);
VM_Call(q1qvm, GAME_EDICT_THINK);
PR_ExecuteProgram (w->progs, s->v->think);
}
qboolean Q1QVM_Event_ContentsTransition(world_t *w, wedict_t *ent, int oldwatertype, int newwatertype)
@ -1334,6 +1334,7 @@ qboolean PR_LoadQ1QVM(void)
{
static float writable;
static float dimensionsend;
static float physics_mode = 2;
int i;
gameDataN_t *gd, gdm;
gameData32_t *gd32;
@ -1473,6 +1474,7 @@ qboolean PR_LoadQ1QVM(void)
pr_global_ptrs->trace_surfaceflags = &writable;
pr_global_ptrs->trace_endcontents = &writable;
pr_global_ptrs->dimension_send = &dimensionsend;
pr_global_ptrs->physics_mode = &physics_mode;
dimensionsend = 255;
for (i = 0; i < 16; i++)
@ -1487,6 +1489,8 @@ qboolean PR_LoadQ1QVM(void)
if ((unsigned)gd->global->mapname && (unsigned)gd->global->mapname+MAPNAME_LEN < VM_MemoryMask(q1qvm))
Q_strncpyz((char*)VM_MemoryBase(q1qvm) + gd->global->mapname, sv.mapname, MAPNAME_LEN);
PR_SV_FillWorldGlobals(&sv.world);
return true;
}

View file

@ -1038,7 +1038,7 @@ void VARGS SV_Multicast (vec3_t origin, multicast_t to);
void SV_MulticastProtExt(vec3_t origin, multicast_t to, int dimension_mask, int with, int without);
void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sample, int volume, float attenuation, int pitchadj);
void SVQ1_StartSound (wedict_t *entity, int channel, char *sample, int volume, float attenuation, int pitchadj);
void SVQ1_StartSound (float *origin, wedict_t *entity, int channel, char *sample, int volume, float attenuation, int pitchadj);
void SV_PrintToClient(client_t *cl, int level, char *string);
void SV_StuffcmdToClient(client_t *cl, char *string);
void VARGS SV_ClientPrintf (client_t *cl, int level, char *fmt, ...) LIKEPRINTF(3);

View file

@ -3037,6 +3037,7 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, qbyte *pvs,
#endif
globalvars_t *pr_globals = PR_globals(svprogfuncs, PR_CURRENT);
int pvsflags;
int limit;
if (client->spectator)
trackent = EDICT_NUM(svprogfuncs, client->spec_track);
@ -3097,7 +3098,9 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, qbyte *pvs,
else
e = 1;
for ( ; e<sv.world.num_edicts ; e++)
limit = min(client->max_net_ents, sv.world.num_edicts);
for ( ; e<limit ; e++)
{
ent = EDICT_NUM(svprogfuncs, e);

View file

@ -1744,23 +1744,20 @@ void SV_ClientProtocolExtensionsChanged(client_t *client)
else
maxpacketentities = MAX_STANDARD_PACKET_ENTITIES; //true for qw,q2
if (ISQWCLIENT(client)) //readd?
if (client->fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS)
{
if (client->fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS)
{
//you need to reconnect for this to update, of course. so make sure its not *too* low...
client->max_net_ents = bound(512, pr_maxedicts.ival, MAX_EDICTS);
client->maxmodels = MAX_MODELS; //protocol limited to 14 bits.
}
else
{
client->max_net_ents = 512;
if (client->fteprotocolextensions & PEXT_ENTITYDBL)
client->max_net_ents += 512;
if (client->fteprotocolextensions & PEXT_ENTITYDBL2)
client->max_net_ents += 1024;
}
//you need to reconnect for this to update, of course. so make sure its not *too* low...
client->max_net_ents = bound(512, pr_maxedicts.ival, MAX_EDICTS);
client->maxmodels = MAX_MODELS; //protocol limited to 14 bits.
}
else if (ISQWCLIENT(client)) //readd?
{
client->max_net_ents = 512;
if (client->fteprotocolextensions & PEXT_ENTITYDBL)
client->max_net_ents += 512;
if (client->fteprotocolextensions & PEXT_ENTITYDBL2)
client->max_net_ents += 1024;
if (client->fteprotocolextensions & PEXT_MODELDBL)
client->maxmodels = MAX_MODELS;
}

View file

@ -1043,7 +1043,7 @@ static void WPhys_CheckWaterTransition (world_t *w, wedict_t *ent)
{
if (ent->v->watertype == Q1CONTENTS_EMPTY && *sv_sound_watersplash.string)
{ // just crossed into water
w->Event_Sound(ent, 0, sv_sound_watersplash.string, 255, 1, 0);
w->Event_Sound(NULL, ent, 0, sv_sound_watersplash.string, 255, 1, 0);
}
ent->v->watertype = cont;
ent->v->waterlevel = 1;
@ -1052,7 +1052,7 @@ static void WPhys_CheckWaterTransition (world_t *w, wedict_t *ent)
{
if (ent->v->watertype != Q1CONTENTS_EMPTY && *sv_sound_watersplash.string)
{ // just crossed into open
w->Event_Sound(ent, 0, sv_sound_watersplash.string, 255, 1, 0);
w->Event_Sound(NULL, ent, 0, sv_sound_watersplash.string, 255, 1, 0);
}
ent->v->watertype = Q1CONTENTS_EMPTY;
ent->v->waterlevel = cont;
@ -1235,7 +1235,7 @@ static void WPhys_Physics_Step (world_t *w, wedict_t *ent)
{
if (hitsound && *sv_sound_land.string)
{
w->Event_Sound(ent, 0, sv_sound_land.string, 255, 1, 0);
w->Event_Sound(NULL, ent, 0, sv_sound_land.string, 255, 1, 0);
}
}
}

View file

@ -1029,19 +1029,23 @@ void SV_StartSound (int ent, vec3_t origin, int seenmask, int channel, char *sam
SV_MulticastProtExt(origin, reliable ? MULTICAST_ALL_R : MULTICAST_ALL, seenmask, requiredextensions, 0);
}
void SVQ1_StartSound (wedict_t *wentity, int channel, char *sample, int volume, float attenuation, int pitchadj)
void SVQ1_StartSound (float *origin, wedict_t *wentity, int channel, char *sample, int volume, float attenuation, int pitchadj)
{
edict_t *entity = (edict_t*)wentity;
int i;
vec3_t origin;
if (entity->v->solid == SOLID_BSP)
vec3_t originbuf;
if (!origin)
{
for (i=0 ; i<3 ; i++)
origin[i] = entity->v->origin[i]+0.5*(entity->v->mins[i]+entity->v->maxs[i]);
}
else
{
VectorCopy (entity->v->origin, origin);
origin = originbuf;
if (entity->v->solid == SOLID_BSP)
{
for (i=0 ; i<3 ; i++)
origin[i] = entity->v->origin[i]+0.5*(entity->v->mins[i]+entity->v->maxs[i]);
}
else
{
VectorCopy (entity->v->origin, origin);
}
}
SV_StartSound(NUM_FOR_EDICT(svprogfuncs, entity), origin, entity->xv->dimension_seen, channel, sample, volume, attenuation, pitchadj);

View file

@ -94,7 +94,14 @@ DWORD CrashExceptionHandler (DWORD exceptionCode, LPEXCEPTION_POINTERS exception
if (fnMiniDumpWriteDump)
{
if (MessageBox(NULL, "KABOOM! We crashed!\nBlame the monkey in the corner.\nI hope you saved your work.\nWould you like to take a dump now?", DISTRIBUTION " Sucks", MB_ICONSTOP|MB_YESNO) != IDYES)
{
if (pIsDebuggerPresent ())
{
//its possible someone attached a debugger while we were showing that message
return EXCEPTION_CONTINUE_SEARCH;
}
return EXCEPTION_EXECUTE_HANDLER;
}
/*take a dump*/
GetTempPath (sizeof(dumpPath)-16, dumpPath);

View file

@ -473,7 +473,8 @@ void SVNQ_New_f (void)
MSG_WriteByte (&host_client->netchan.message, svc_stufftext);
MSG_WriteString (&host_client->netchan.message, va("csqc_progcrc %i\n", QCRC_Block(f, com_filesize)));
host_client->csqcactive = true;
MSG_WriteByte (&host_client->netchan.message, svc_stufftext);
MSG_WriteString (&host_client->netchan.message, "cmd enablecsqc\n");
}
}
@ -1978,9 +1979,9 @@ void SV_NextChunkedDownload(unsigned int chunknum, int ezpercent, int ezfilenum)
host_client->downloadcount = chunknum*CHUNKSIZE;
}
if (host_client->datagram.cursize + CHUNKSIZE+5+50 > host_client->datagram.maxsize)
if ((host_client->datagram.cursize + CHUNKSIZE+5+50 > host_client->datagram.maxsize) || (host_client->datagram.cursize + CHUNKSIZE+5 > 1400))
{
//would overflow the packet.
//would overflow the packet, or result in (ethernet) fragmentation and high packet loss.
msg = &msg_oob;
if (!ezfilenum)
@ -2158,7 +2159,7 @@ void SV_NextUpload (void)
{
SV_ClientTPrintf(host_client, PRINT_HIGH, STL_UPLOADDENIED);
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
ClientReliableWrite_String (host_client, "stopul");
ClientReliableWrite_String (host_client, "stopul\n");
// suck out rest of packet
size = MSG_ReadShort (); MSG_ReadByte ();
@ -2171,12 +2172,13 @@ void SV_NextUpload (void)
if (!host_client->upload)
{
FS_CreatePath(host_client->uploadfn, FS_GAMEONLY);
host_client->upload = FS_OpenVFS(host_client->uploadfn, "wb", FS_GAMEONLY);
if (!host_client->upload)
{
Sys_Printf("Can't create %s\n", host_client->uploadfn);
ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
ClientReliableWrite_String (host_client, "stopul");
ClientReliableWrite_String (host_client, "stopul\n");
*host_client->uploadfn = 0;
return;
}
@ -2211,6 +2213,7 @@ void SV_NextUpload (void)
OutofBandPrintf(host_client->snap_from, "%s upload completed.\nTo download, enter:\ndownload %s\n",
host_client->uploadfn, p);
}
*host_client->uploadfn = 0; //don't let it get overwritten again
}
}
@ -2521,8 +2524,10 @@ qboolean SV_AllowDownload (const char *name)
if (!allow_download_packages.ival)
return false;
/*do not permit 'id1/pak1.pak' or 'baseq3/pak0.pk3' or any similarly named packages. such packages would violate copyright, and must be obtained through other means (like buying the damn game)*/
if (FS_GetPackageDownloadable(name+8))
return !!allow_download_packages.ival;
if (!allow_download_copyrighted.ival && !FS_GetPackageDownloadable(name+8))
return false;
return true;
}
return false;
}
@ -3682,7 +3687,8 @@ void SV_NoSnap_f(void)
{
SV_LogPlayer(host_client, "refused snap");
if (*host_client->uploadfn) {
if (*host_client->uploadfn)
{
*host_client->uploadfn = 0;
SV_BroadcastTPrintf (PRINT_HIGH, STL_SNAPREFUSED, host_client->name);
}
@ -4836,6 +4842,10 @@ ucmd_t ucmds[] =
{"notarget", Cmd_Notarget_f},
{"setpos", Cmd_SetPos_f},
#ifdef NQPROT
{"name", SVNQ_NQInfo_f},
#endif
#ifdef VOICECHAT
{"voicetarg", SV_Voice_Target_f},
{"vignore", SV_Voice_Ignore_f}, /*ignore/mute specific player*/

View file

@ -1023,15 +1023,20 @@ static trace_t World_ClipMoveToEntity (world_t *w, wedict_t *ent, vec3_t eorg, v
{
model = w->Get_CModel(w, mdlidx);
if (!model || (model->type != mod_brush && model->type != mod_heightmap))
Host_Error("SOLID_BSP with non bsp model (classname: %s)", PR_GetString(w->progs, ent->v->classname));
{
// Host_Error("SOLID_BSP with non bsp model (classname: %s)", PR_GetString(w->progs, ent->v->classname));
model = NULL;
}
}
else
model = NULL;
if (!model);
{
vec3_t boxmins, boxmaxs;
VectorSubtract (ent->v->mins, maxs, boxmins);
VectorSubtract (ent->v->maxs, mins, boxmaxs);
World_HullForBox(boxmins, boxmaxs);
model = NULL;
}
// trace a line through the apropriate clipping hull